Skip to content

Add an ES module build for browsers - #549

Merged
rosston merged 1 commit into
mainfrom
fix-494-web-test-runner
Oct 12, 2026
Merged

rosston merged 1 commit into
mainfrom
fix-494-web-test-runner

Conversation

@rosston

@rosston rosston commented Oct 12, 2026

Copy link
Copy Markdown
Member

Fixes #494

testdouble's only import entry, lib/index.mjs, re-exports CommonJS files and quibble, so tools that serve node_modules to the browser as native ES modules, like @web/test-runner, failed to load it.

Wrap the browserify bundle as a self-contained ES module, dist/testdouble.mjs, and route import under the browser export condition to it. require still resolves to lib/ under that condition. The export names come from the built bundle, and it doesn't set a global td. Expose dist/testdouble.js and dist/testdouble.mjs as subpath exports, so the documented browser bundle can be imported by path again.

Add a Node test that checks the bundle's exports against lib/index.mjs, and an @web/test-runner example that runs in headless Chrome on Node 22+. Split the webpack example into three builds, so the import entry checks both the browser build and lib/index.mjs.

Fixes #494

testdouble's only `import` entry, lib/index.mjs, re-exports CommonJS
files and quibble, so tools that serve node_modules to the browser as
native ES modules, like @web/test-runner, failed to load it.

Wrap the browserify bundle as a self-contained ES module,
dist/testdouble.mjs, and route `import` under the `browser` export
condition to it. `require` still resolves to lib/ under that
condition. The export names come from the built bundle, and it doesn't
set a global `td`. Expose dist/testdouble.js and dist/testdouble.mjs as
subpath exports, so the documented browser bundle can be imported by
path again.

Add a Node test that checks the bundle's exports against lib/index.mjs,
and an @web/test-runner example that runs in headless Chrome on Node
22+. Split the webpack example into three builds, so the `import` entry
checks both the browser build and lib/index.mjs.
@rosston rosston self-assigned this Oct 12, 2026
@rosston
rosston marked this pull request as ready for review October 12, 2026 16:26
@rosston
rosston merged commit ef3dc36 into main Oct 12, 2026
12 checks passed
@rosston
rosston deleted the fix-494-web-test-runner branch October 12, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trying to use testdouble in @web/test-runner fails with error about quibble

1 participant