Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine notes on worker interactions, include section on external import maps #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Currently the following new features have been [specified in this proposal](http

* [Specifyng module integrity](#integrity) (https://github.com/WICG/import-maps/issues/221)
* [Worker import maps](#worker-import-maps) (https://github.com/WICG/import-maps/issues/2)
* [External import maps](#external-import-maps) (https://github.com/WICG/import-maps/issues/235)
* [Depcache: Optimizing the unbounded latency cost of deep dependency discovery](#depcache) (https://github.com/WICG/import-maps/issues/21)
* [Isolated Scopes: Ensuring modular scope isolation](#isolated-scopes)
* [Supporting lazy-loading of import maps](#lazy-loading-of-import-maps) (https://github.com/WICG/import-maps/issues/19)
Expand Down Expand Up @@ -105,14 +106,43 @@ new Worker(path, {

where the semantics of `'inherit'` would exactly be to get the serialized import map from the current context, and pass it into the worker.

If [external import maps](#external-import-maps) are supported, then `importMap` may permit a URL string value:

```js
new Worker(path, {
type: 'module',
importMap: '/importmap.json'
});
```

Where the string `'inherit'` would effectively be an exclusion before applying the URL parser.

For supporting Service Worker and Dedicated Worker import maps, URLs may well be desired to allow import map updates for service workers, and
to allow easier worker coalescing between dedicated worker instantiations, which may otherwise need to use a hash of the import map as part of
the guarantee for dedicated worker identity.

In the mean time, while `importMap` URLs are not supported, it might make sense to explicitly disallow `importMap` for Service Workers and Dedicated
Workers.

### Alternatives

An alternative design could be to only support `importMap: 'inherits' | 'blank'` and instead have a new API for setting the import map.

Instead of the worker having its own entire import map data structure, it could also be an option to treat the import map as data in shared memory,
where if there were APIs for mutating import maps in future, this would share between workers.
Instead of the worker having its own entire import map data structure, it could also be an option to treat the import map as shared data
between the workers. The import map must then be synchronized between the threads, and the transition into
[import maps allowed](https://html.spec.whatwg.org/multipage/webappapis.html#import-maps-allowed) being set to false must also be synchronized
between threads.

To avoid the synchronization complexities, for now, serialization and copying seems to provide the simplest semantics unless there are
strong arguments for either of the above.

## External Import Maps

> Status: Formerly specified in import maps (https://github.com/WICG/import-maps/blob/e2eceb7ac3b7497e1f6c7f06cd86d7177da9a799/spec.bs#L241), not upstreamed to HTML

This feature is fully described in the original import maps spec repo at https://github.com/WICG/import-maps/tree/main?tab=readme-ov-file#installation.

For now, serialization and copying seems to provide the simplest semantics unless there are strong arguments for either of the above.
Remotivation and specification work may be driven within this effort further in future.

## Depcache

Expand Down