WICG / import-maps

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

Slim down to a minimal core #176

Closed domenic closed 4 years ago

domenic commented 4 years ago

This re-focuses the import maps explainer and specification on a minimal core which is more likely to be implementable and agreeable in the near future. It removes multiple import map support, fallback support, and built-in module support for now. The explainer contains a "Further work" section which details these and other potential future work.

In terms of normative changes:


This is not ready to merge yet as I've only updated the reference implementation (not spec) for parsing and resolving. All the content is there though, so this could be reviewed as-is.


Preview | Diff

jkrems commented 4 years ago

Does removal of array support complicate its future addition? It would require user-agent sniffing (or waiting a long time) to use array syntax if past versions wouldn't be able to accept them.

For node we currently plan to support synchronous arrays only, e.g. we'll never try to fetch more than one of the resolutions. That way a "protocol whitelist" is enough to make the decision while still allowing for future std: modules or more complex guards.

domenic commented 4 years ago

Does removal of array support complicate its future addition? It would require user-agent sniffing (or waiting a long time) to use array syntax if past versions wouldn't be able to accept them.

Or feature detection, using the error event to detect parse errors.

However, I find it unlikely that we'll add the array syntax back at any point, given the implementation complexities that come with it, and the standards quagmire around built-in modules. I currently have no plans to do so.

For node we currently plan to support synchronous arrays only, e.g. we'll never try to fetch more than one of the resolutions. That way a "protocol whitelist" is enough to make the decision while still allowing for future std: modules or more complex guards.

I would suggest following the spec and not supporting arrays at all.

jkrems commented 4 years ago

I would suggest following the spec and not supporting arrays at all.

To clarify: We're not literally implementing import maps (at least not yet). Unfortunately there are use cases that require declarative switching between implementations so we'll have to implement something in node and likely rather sooner than later or the ecosystem will find a way™.

domenic commented 4 years ago

I finished this off, and will merge it now in the interest of having an up-to-date explainer. Review still appreciated.