tc39 / proposal-dynamic-import

import() proposal for JavaScript
https://tc39.github.io/proposal-dynamic-import/
MIT License
1.86k stars 47 forks source link

need to explicitly create namespace object #38

Closed GeorgNeis closed 7 years ago

GeorgNeis commented 7 years ago

In FinishDynamicImport, moduleRecord.[[Namespace]] will in most cases still be undefined. I suppose you want to explicitly call GetModuleNamespace to force the creation of the namespace object.

domenic commented 7 years ago

Great catch, thank you. I wonder why the spec creates [[Namespace]] lazily.

caridy commented 7 years ago

@domenic the reason why it is created lazily is because we don't need the namespace object for most modules, we only really needed when:

a. a module is imported by other module via import * as x ... b. a module is imported via import()

the rest of the graph is connected via the bindings in the env rec associated to the module record.

domenic commented 7 years ago

That feels like it'd be better left as an implementation optimization instead of coded into the spec, but it works either way.