← Back to release summary

ES Modules for service workers ('module' type option)

Category
Service Worker
Type
New or changed feature
Status
Enabled by default (Chrome 91)
Intent stage
Start prototyping

Summary

JavaScript will support modules in service workers. Setting 'module' type by the constructor's type attribute, worker scripts are loaded as ES modules and the import statement is available on worker contexts.

Motivation

With this feature, web developers can more easily write programs in a composable way and share them among a page and workers.

Standards & signals

Docs: https://docs.google.com/document/d/1SeQ085YdBTtW3D_ygSpO0Wz2DAe8QiS1gj37IG5lstg/edit#

Explainers: https://github.com/w3c/ServiceWorker/commit/6d9500e99e764c12b117c63d10107e094d243662

View on chromestatus.com