HTML defines import maps that map specifiers to URLs (and presumably can be extended to map specifiers to other specifiers), however as currently defined, the feature depends on HTML, which requires central management and coordination to use import maps to rewrite client-side dependencies to URLs, as even transitive dependencies need to be mapped one by one.
What if import maps could also be included via import attributes?
import "/importmap.json" with { type: "importmap" };
Perhaps type is not the right attribute, since it could be quite useful to import import maps written in JS (which can have their own dependency graph, not just better syntax), so perhaps we need a separate attribute:
// JSON syntax
import "/importmap.json" with { type: "json", is: "importmap" };
// JS syntax
import "/importmap.js" with { is: "importmap" };
Though another direction seems to be registering a separate media type for them, which would lock the syntax to JSON. I’m not aware of any more recent work in that direction however.
In terms of resolution semantics, import maps would only be able to affect specifier resolutions of modules imported after them. Conflicts would be handled in the same way as is already defined (first one wins) or via runtime error.
Not only could this be huge for making it possible to use client-side dependencies without bundlers, it could also help decouple dependency resolution from the JS runtime used. And if this is implemented before external import maps, it could even provide a better solution for that. Currently authors are stuck including import maps as a JSON island embedded in every single HTML page which is atrocious for DX, caching, etc.
If folks think this could be a good idea, I’d be happy to draft a proposal for the Jan plenary.