tc39 / proposal-esm-phase-imports

Home Page:https://tc39.es/proposal-esm-phase-imports/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`hasDynamicImport` with eval dynamic import

legendecas opened this issue · comments

Could AbstractModuleSource.prototype.hasDynamicImport determinisitically be true if the module contains dynamic imports via eval?

This is a great point, thanks. This may be justification to remove this feature, I'll post a PR.

In this case, the dynamic import will have no context (for resolving a relative module) IMO. I don't want this feature to be removed.

In Node.js, I get the following:

subfolder/mod.mjs

eval("import('./dep.mjs')");

Attempting to load subfolder/dep.mjs. So the context works fine I believe?

I also tried this and dug into the spec. Yes, it will have the context, even indirect eval works, so it's ok to remove hasDynamicImport

Thanks for the follow-up. Since it is so close to the meeting, I will leave the PR open for now.

It depends on if the eval is a direct eval. If it is an indirect eval, it depends on whether the host propagates the active script properly (actually, it's not tc39/ecma262#3195).

Removed in #15.