Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch started as a conversation with @guybedford. I tried writing some spec for one of the potential approaches discussed in WICG/import-maps#2.
This PR is not actually ready as I have not finished reading all the discussions about the topic and I haven't talked with any implementation, but it's better to leave it here as a draft in case somebody is interested than just keeping it hidden in a branch :)
There are two commits: one that allows workers to inherit the import map from their creator (which probably will be the most common use case?), and one that allows to explicitly pass an import map object. The two commits don't conceptually depend on each other, so it would also be ok to decide to only do one of them.
This patch does not support import maps for SharedWorker, but thanks to the work done in #10528 it would be possible to support them: when a page connects to an existing shared worker, the shared worker's import map can get "updated" with the new one. Generally import maps in multiple pages of a same application match in their intersection, so this would probably give a good behavior (the alternative is to throw when passing an import map that is different from the existing one).
This approach does not work for ServiceWorker, and they would likely need a completely different solution (such as the HTTP-header based ones that were suggested in WICG/import-maps#2).
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )