web-platform-tests / web-platform-tests/interop

JS Module Scripts in more contexts (2027 edition)

Open
#1,386 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

focus-area-proposal
Dominant language
JavaScript
Stars
524
Forks
35
Avg merge
1d 4h
Merged PRs (30d)
10

Description

Description

ECMA262 specifies two kinds of goal symbols for JavaScript: (classic) scripts and modules. The JS ecosystem keeps moving towards using modules, both on the web platform and server-side runtimes, both as an authoring and distribution format, however not every browser supports them in every context. This issue is about improving interoperability for JS modules in contexts where browser support is already existent but partial, in particular, XHTML documents, SVG documents, but also Web Extensions if they are in the scope of the Interop project, which I am unsure of.

This was previously submitted for Interop 2025 (see #869). While not accepted at the time, there still has been some progress in this area since then:

  • every major browser now supports JS modules in Service Workers in web content
  • a new API for running Web Extensions has been added to WPT, through which this area could likely be tested nowadays
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)

web-feature

web-features: js-modules

Test Links
Additional Signals
Site Breakage and Workaround

Code expected to be consumed as JS modules (using syntax-enabled features such as static imports, top-level await or whose execution should be deferred) can not be run everywhere.
For example, one can not write a module that runs both in a HTML document, a XHTML document, and a SVG document. Also one can not write a Web Extension Service Worker background script that runs in every browser.
Currently, instead of being able to distribute isomorphic code using only JS modules, multiple distribution targets are required.

Current State of the Feature

Use share for JS modules on the web keeps increasing: https://chromestatus.com/metrics/webfeature/timeline/popularity/47

Integration specs, existing tests, documentation, browser bugs and implementation status

This issue is about improving interoperability for JS modules in contexts where browser support is already partial, such as:

Out of scope features

See the previous issue for examples of other contexts / integration points where JS modules could be added, but are not yet supported in any browser AFAIK.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing WPT cases at html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml and svg/interact/scripted/module-01.svg, along with the linked HTML, SVG, and WebExtensions specifications. Clarify which contexts are in scope and which missing tests are needed. Done means the selected contexts have agreed interoperability coverage and documented browser results.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.