Is importing JS modules in the source phase expected to throw?
From the JS Module Source section in github I understand that importing a JS module in the source phase should return a valid object with AbstractModuleSource.prototype in the prototype chain, but from the spec, I understand that it should throw. What is the expected behavior?
Here is how I'm reading the spec: HTML's create a JavaScript module script calls TC39's Parse Module, which is not modified in the source phase import proposal, so it leaves the Abstract Module Record's new [[ModuleSource]] slot EMPTY. So that would throw in the Linking inside InitializeEnvironments when checking the imports and for dynamic imports in ContinueDynamicImport when finishing the import for the JS script.
Under this specification, it throws a SyntaxError when it sees no [[ModuleSource]] defined as you describe in https://tc39.es/proposal-source-phase-imports/#sec-source-text-module-record-initialize-environment (and also separately for dynamic imports).
With the new ESM Phase Imports proposal (https://github.com/tc39/proposal-esm-phase-imports) this case is then supported and does not throw.
Thanks! It would be nice to update this section to reflect this.