Closed mima0815 closed 1 year ago
The WASM file you attempted to import tree-sitter-json.wasm
is NOT an ESM WebAssembly file. It has an import named env
but not a real package to import. Handling it with this plugin is like there's a JS file writing import env from "env";
.
$ node --experimental-wasm-modules
Welcome to Node.js v18.11.0.
Type ".help" for more information.
> await import("/Users/Menci/vitewasm/node_modules/@swagger-api/apidom-parser-adapter-json/wasm/tree-sitter-json.wasm")
(node:67004) ExperimentalWarning: Importing WebAssembly modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'env' imported from /Users/Menci/vitewasm/node_modules/@swagger-api/apidom-parser-adapter-json/wasm/tree-sitter-json.wasm
at __node_internal_captureLargerStackTrace (node:internal/errors:484:5)
at new NodeError (node:internal/errors:393:5)
at packageResolve (node:internal/modules/esm/resolve:860:9)
at moduleResolve (node:internal/modules/esm/resolve:909:20)
at defaultResolve (node:internal/modules/esm/resolve:1124:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18) {
code: 'ERR_MODULE_NOT_FOUND'
}
Hi, i got stuck when using this plugin to use packages with wasm files and vite.
Don't know if the issue is in this plugin or in the package i use.
Here is a repo to reproduce the issue: https://github.com/mima0815/vitewasm with the package:
@swagger-api/apidom-parser-adapter-openapi-json-3-0
if i import this https://github.com/mima0815/vitewasm/blob/main/src/components/HelloWorld.vue#L3 and use it here: https://github.com/mima0815/vitewasm/blob/main/src/components/HelloWorld.vue#L10
i get the following errors when building or using the vitejs dev mode:
adding this to the vite.config.json, removes the errors:
but then it fails later with an missing default export:
The packages are in use and are able to be loaded e.g. here: https://editor-next.swagger.io/
I never worked with wasm dependencies before, could it be that those packages are not compatible with vite+this plugin? or do i need to configure Vite in some way?
Could be a similar issue like here: https://github.com/Menci/vite-plugin-wasm/issues/31