WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.65k stars 69 forks source link

Throwing TypeError in resolve a module specifier? #277

Closed allstarschh closed 1 year ago

allstarschh commented 2 years ago

According to the import maps spec, resolve a module specifier will throw, https://wicg.github.io/import-maps/#resolve-a-module-specifier, step 12

Also the callers will be updated as well, according to https://wicg.github.io/import-maps/#resolving-updates

But what about https://html.spec.whatwg.org/multipage/webappapis.html#validate-requested-module-specifiers According to the HTML spec, the error should be propagated to the script's parse error https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-parse-error

and later it will be the error to rethrow object of the script. https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-error-to-rethrow

So in this case, should 'resolve a module specifier' still throw a TypeError if it has any? Or it should return failure (like the original 'resolve a module specifier' does), and let script to propagate the error?

Note: V8's implementation is in JSModuleScript::Create ModulatorImplBase::ResolveModuleSpecifier and ImportMap::Resolve

domenic commented 2 years ago

Yes, you're right that the propagation is a bit more complex for that caller. My plan was to convert it to catch the error and store it.

domenic commented 2 years ago

I believe this is fixed in https://github.com/whatwg/html/pull/8075. Please check. If so, I will close this when I remove all spec text from this repository and instead let HTML be the new source of truth.