Repository navigation
Commit ef3dc36
committed
Add an ES module build for browsers
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.1 parent ec31f1b commit ef3dc36
13 files changed
Lines changed: 7651 additions & 27 deletions
File tree
- docs
- examples
- web-test-runner
- test
- webpack
- script
- test
- safe
- support
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
47 | 70 | | |
48 | 71 | | |
49 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments