Wasm es6 模块无法使用 Jest 加载,但可以在 Node 中工作

问题描述

我可以使用 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)

我创建了一个简单的重现案例,步骤如下:

  1. 克隆此存储库:https://github.com/modulitos/jest-wasm-esm-example
  2. 使用 npm iyarn 安装 deps
  3. 运行npm run test-jest

请注意,运行 npm run test-node 在 Node.js 中成功加载模块。那么为什么 Jest 会失败呢?

(我也提交了这个 as an issue in the Jest repo,但已经几个星期没有任何解决方案了。有兴趣看看这里是否有人有反馈)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...