WASM-BIND库和开玩笑:无效或意外令牌 @import&quot?
我正在尝试在导入Rust/WASM库的React-Typecript项目中使用Jest,而在运行前端时它可以使用,但Jest测试失败了:
/workspace/react-jest-rust/node_modules/rust-wasm-lib/index.js:73
export function message(s) {
^^^^^^
SyntaxError: Unexpected token 'export'
我创建了一个示例,只需运行>克隆后的纱线测试a
: https://github.com/github.com/findetton/findetton/reaeact--reaect--react--react--开玩笑
我尝试配置开玩笑。如果我将其添加到package.json:
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!rust-wasm-lib)/"
]
}
然后在运行纱线测试
时会遇到其他错误:
/big/workspace/sequent/react-jest-rust/node_modules/rust-wasm-lib/index.js:125
input = new URL('index_bg.wasm', import.meta.url);
^^^^
SyntaxError: Cannot use 'import.meta' outside a module
2 | import logo from './logo.svg';
3 | import './App.css';
> 4 | import init, {test} from 'rust-wasm-lib';
| ^
I'm trying to use jest in a react-typescript project that imports a rust/wasm library and while it works when I run the front-end, the jest test fails with:
/workspace/react-jest-rust/node_modules/rust-wasm-lib/index.js:73
export function message(s) {
^^^^^^
SyntaxError: Unexpected token 'export'
I've created an example, just run yarn test a
after cloning: https://github.com/Findeton/react-jest-rust
I've tried configuring jest. If I add this to package.json:
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!rust-wasm-lib)/"
]
}
Then I get this other error when running yarn test a
:
/big/workspace/sequent/react-jest-rust/node_modules/rust-wasm-lib/index.js:125
input = new URL('index_bg.wasm', import.meta.url);
^^^^
SyntaxError: Cannot use 'import.meta' outside a module
2 | import logo from './logo.svg';
3 | import './App.css';
> 4 | import init, {test} from 'rust-wasm-lib';
| ^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论