Repository navigation
Add an ES module build for browsers - #549
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #494
testdouble's only
importentry, 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
importunder thebrowserexport condition to it.requirestill resolves to lib/ under that condition. The export names come from the built bundle, and it doesn't set a globaltd. 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
importentry checks both the browser build and lib/index.mjs.