Wasm es6 modules fail to load with Jest, but work in Node
See original GitHub issueš Bug Report
Iām able to load an es6 module with Node, but Iām unable to load the same module when running with Jest. When I try loading the module with Jest, I get the following error:
node --experimental-modules --experimental-wasm-modules --experimental-vm-modules node_modules/.bin/jest
(node:72954) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time (Use
node --trace-warnings ...
to show where the warning was created) FAIL tests/test_jest.test.mjs ā Test suite failed to run/Users/me/projects/bin_packing/jest-wasm/node_modules/bin_packer_3d/bin_packer_3d_wasm_bg.wasm:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){ SyntaxError: Invalid or unexpected token at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
To Reproduce
Steps to reproduce the behavior:
- Clone this repo: https://github.com/modulitos/jest-wasm-esm-example
- run
npm run test-jest
Note that running npm run test-node
loads the module successfully in Node. So why does it fail with Jest?
Expected behavior
The module loads when running npm run test-jest
.
Link to repl or repo (highly encouraged)
https://github.com/modulitos/jest-wasm-esm-example
envinfo
⯠npx envinfo --preset jest npx: installed 1 in 1.358s
System: OS: macOS 10.15.7 CPU: (4) x64 Intel® Core⢠i5-7360U CPU @ 2.30GHz Binaries: Node: 14.15.4 - ~/.asdf/installs/nodejs/14.15.4/bin/node npm: 6.14.10 - ~/.asdf/installs/nodejs/14.15.4/bin/npm npmPackages: jest: ^26.6.3 => 26.6.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:24 (9 by maintainers)
https://github.com/facebook/jest/releases/tag/v29.3.0
Nice! Just tested 29.3.0 against the same demo project and it worked without a local patch! š