问题描述
我可以使用 Node 加载 es6 wasm 模块,但是在使用 Jest 运行时我无法加载相同的模块。当我尝试使用 Jest 加载模块时,出现以下错误:
RangeError: Maximum call stack size exceeded
at Resolver.resolveStubModuleName (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-resolve/build/index.js:515:19)
at Resolver.resolveModule (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-resolve/build/index.js:297:12)
at Runtime._resolveModule (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-runtime/build/index.js:1145:32)
at Runtime.linkModules (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-runtime/build/index.js:610:27)
at /Users/me/projects/bin_packing/jest-wasm/node_modules/jest-runtime/build/index.js:572:18
at ModuleWrap.<anonymous> (internal/vm/module.js:319:30)
at SourceTextModule.<computed> (internal/vm/module.js:318:36)
at SourceTextModule.link (internal/vm/module.js:196:22)
at Runtime.loadEsmModule (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-runtime/build/index.js:571:12)
at Runtime.linkModules (/Users/me/projects/bin_packing/jest-wasm/node_modules/jest-runtime/build/index.js:616:19)
我创建了一个简单的重现案例,步骤如下:
- 克隆此存储库:https://github.com/modulitos/jest-wasm-esm-example
- 使用
npm i
或yarn
安装 deps - 运行
npm run test-jest
请注意,运行 npm run test-node
在 Node.js 中成功加载模块。那么为什么 Jest 会失败呢?
(我也提交了这个 as an issue in the Jest repo,但已经几个星期没有任何解决方案了。有兴趣看看这里是否有人有反馈)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)