denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.27k stars 5.41k forks source link

Add support for multiple import maps #25450

Open yoavweiss opened 3 months ago

yoavweiss commented 3 months ago

Import maps currently have to load before any ES module and there can only be a single import map per document. That makes them fragile and potentially slow to use in real-life scenarios: Any module that loads before them breaks the entire app, and in apps with many modules the become a large blocking resource, as the entire map for all possible modules needs to load first.

There's an HTML PR proposal to enable multiple import maps per document, by merging them in a consistent and deterministic way.

I'd appreciate y'all's opinions.

marvinhagemeister commented 3 months ago

We're eagerly waiting for that proposal to be fleshed out. For now our solution to that problem is publishing on JSR. With JSR each library can have their own import map. Other than that there isn't another option at the moment. We're waiting for the proposal you linked to, to be finished to support nested import maps outside of JSR and npm packages.

yoavweiss commented 3 months ago

That's great to hear!! FWIW, I feel the proposal has already gotten a lot of feedback and is in good shape. I also have a Chromium implementation going, but that is just starting its review process.

oscarotero commented 2 days ago

Hi. The multiple import maps proposal has merged! Now we have a standard way to import ES modules using other maps and merge them in the main import map. That's a huge leap forward for HTTP imports and dependencies dedupe.

bartlomieju commented 2 days ago

@oscarotero could you please link to the relevant proposal change? I'm having trouble finding it.

oscarotero commented 2 days ago

@bartlomieju This is the link to the new section https://html.spec.whatwg.org/multipage/webappapis.html#merge-existing-and-new-import-maps

And the pull request where you can see the changes and conversation: https://github.com/whatwg/html/pull/10528