tc39 / proposal-dynamic-import

import() proposal for JavaScript

Home Page:https://tc39.github.io/proposal-dynamic-import/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

need to explicitly create namespace object

GeorgNeis opened this issue · comments

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.

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

@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.

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