[node-rs/jieba, lunr.zh error] top-level await is not available in the configured target environment
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 52
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 19
Description
I am getting following error while building my project:
✘ [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js:22:19:
22 │ const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
╵ ~~~~~
✘ [ERROR] This require call is not allowed because the transitive dependency "node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" contains a top-level await
node_modules/lunr-languages/lunr.zh.js:33:37:
33 │ module.exports = factory(require('@node-rs/jieba'))
╵ ~~~~~~~~~~~~~~~~
The file "node_modules/@node-rs/jieba/browser.js" imports the file
"node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" here:
node_modules/@node-rs/jieba/browser.js:1:14:
1 │ export * from '@node-rs/jieba-wasm32-wasi'
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The top-level await in "node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" is here:
node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js:22:19:
22 │ const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
Following is the environment
vue 3.4.4
vite 4.5.3
node 18.16
Appreciate your help with this issue. Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the build with Vue 3.4.4, Vite 4.5.3, and Node 18.16, then trace the imports through node_modules/lunr-languages/lunr.zh.js, node_modules/@node-rs/jieba/browser.js, and jieba.wasi-browser.js. Determine the compatible change for the reported target-environment error and verify that the project builds without the top-level-await and require errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, vite, wasm
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100