You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESM has been available in all major browsers through HTML's <script type="module"> for years now and more recently in Workers and Worklets, however JS execution in browsers is not limited to these contexts.
This issue is about improving interoperability for ESM in contexts where browser support is partial, that is to say, other types of documents (XHTML, SVG) and specialized types of worker (Service Workers).
Contexts without any known integration effort for ESM, such as content scripts, would not be included in this proposal.
Specification
See https://tc39.es/ecma262/#sec-modules for the main spec defining modules though this issue is more about their integration in multiple other consuming specs (see links below)
Additional Signals
Site Breakage and Workaround
Classic JS scripts and JS module scripts (or ESM for short) are two types of scripts with incompatible grammars and different sets of features. While support for some new features (static imports, top-level await...) is restricted to ESM, ESM is not yet available everywhere in browsers, making writing or consuming isomorphic code difficult. For example, one cannot write a module that works in all browsers both in a HTML document, a XHTML document, a SVG document and a Service Worker. Without transpilation, the workaround is often using classic scripts and not benefiting from these newer syntax-enabled features, as they are not really polyfillable and detecting support for them is not straightforward. Of course the other way is not targeting some browsers at all 😢
Integration specs, existing tests, documentation and browser bugs
This issue is about improving interoperability for ESM in contexts where browser support is already partial, such as:
<script type="module"> in HTML documents with XML syntax (aka XHTML documents)
Please! 10th anniversary of modules, and how partial the web is at allowing modules to be used is a bad look.
Also related is #715 , on import-maps not being usable in workers. Without import-maps, the usability of modules is very low, requiring modules to be rewritten/mangled from their authored form. Import-maps are what make modules modular and feel critical to the equation of modules being viable & successful.
Description
ESM has been available in all major browsers through HTML's
<script type="module">
for years now and more recently in Workers and Worklets, however JS execution in browsers is not limited to these contexts.This issue is about improving interoperability for ESM in contexts where browser support is partial, that is to say, other types of documents (XHTML, SVG) and specialized types of worker (Service Workers).
Contexts without any known integration effort for ESM, such as content scripts, would not be included in this proposal.
Specification
See https://tc39.es/ecma262/#sec-modules for the main spec defining modules though this issue is more about their integration in multiple other consuming specs (see links below)
Additional Signals
Site Breakage and Workaround
Classic JS scripts and JS module scripts (or ESM for short) are two types of scripts with incompatible grammars and different sets of features. While support for some new features (static
import
s, top-levelawait
...) is restricted to ESM, ESM is not yet available everywhere in browsers, making writing or consuming isomorphic code difficult. For example, one cannot write a module that works in all browsers both in a HTML document, a XHTML document, a SVG document and a Service Worker. Without transpilation, the workaround is often using classic scripts and not benefiting from these newer syntax-enabled features, as they are not really polyfillable and detecting support for them is not straightforward. Of course the other way is not targeting some browsers at all 😢Integration specs, existing tests, documentation and browser bugs
This issue is about improving interoperability for ESM in contexts where browser support is already partial, such as:
<script type="module">
in HTML documents with XML syntax (aka XHTML documents)<script type="module">
in SVG documentstype: "module"
for Service Workers registered viaServiceWorkerContainer.register(...)
"type": "module"
for background scripts defined via the"background.service_worker"
key in Web Extension ManifestsOut of scope features
Contexts without enough signal from browsers to integrate ESM in them would not be included in this effort, such as:
WorkerGlobalScope.importScripts(...)
in Workers{browser,chrome}.{scripting,tabs}.executeScript(...)
in Web Extensions"content_scripts"
key in Web Extension Manifests"user_scripts.api_script"
key in Web Extension Manifests"background.scripts"
key in Web Extension Manifestsimport(...)
in Service Workers ( see How should import() work in service workers? w3c/ServiceWorker#1585 )The text was updated successfully, but these errors were encountered: