Skip to content

Supporting import maps in worker environments #8173

@guybedford

Description

@guybedford

I'd like to propose we work towards a solution for providing import maps to worker environments.

Currently new Worker(..., { type: 'module' }) will run in a unique resolution environment that does not provide access to the import maps present in the parent page.

Bringing the benefits of import maps to workers would be a worthwhile effort.

I would like to propose that the API support the following capabilities:

  • The ability to instantiate a Worker such that it shares the import map of the parent resolution environment.
  • The ability to instantiate a Worker with a custom import map JSON object.
  • Optionally, but not necessarily, the ability to update the import map of a worker after the worker is initialized.
  • Extending these options not only to Worker but also to SharedWorker and Worklet initializations.

If there is rough agreement on this direction, and some of the above requirements, perhaps we can start to sketch out an API with an eye towards a PR soon? I think it would be really good to get this moving at this point in time so that users can benefit from import maps outside of the main thread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions