vite keeps looking for a file named crate_js which is the wrong file name
delebash opened this issue · 2 comments
I am trying to use the wasm package photon from https://github.com/silvia-odwyer/photon
The crate compiles just fine. However there are 2 problems
My folder structure is
crate
app
npm_modules
package.json
vite.config.js
- Even though I am dealing with just a local crate vite still wants to look for an npm_module called crate.
- It is also looking for a file named crate.js however, photon crate outputs different file names such as photon_rs.js
My vite plugin is this plugins: [wasmPack(['./crate']),vue(),
The error I get initially when running vite server is no such file or directory node_modules\crate\crate.js'
I can fix this by changing my vite config to plugins: [wasmPack(['./crate'], ['crate']),vue(),
Now it finds the crate under node_modules but I get an error that it cannot find file crate.js but the actual file name in the package is outputed as photon_rs.js
Any help is appriciated. TY I am new to wasm so still learning.
hi @delebash I made it works
to make it work , we have to build crate with wasm-pack build --target web
, so it can be load in browser.
I rebuilt the photon library and published it here
https://www.npmjs.com/package/photon-web
then set our plugin as
// we have no local crate, so leave the first param an empty array
plugins: [wasmPack([], ["photon-web"])],
full code
Thank you very much!!!