nshen/vite-plugin-wasm-pack

issue resolving modules with "/" in the name

seeker-3 opened this issue · 4 comments

for using a module from that is within a nested scope from npm e.g. @scope/package-name

I configured the plugin like this

wasmPack([], '@scope/package-name')

and here is the error I get.

vite-plugin-wasm-pack-error

this line suggests to me it's looking here

node_modules/package-name/package_name.js

when it should be looking here

node_modules/@scope/package-name/package_name.js

I also tried path /a/b/c to see what it did and it only looked in /c it seems to only be grabbing everything after the last slash.

wasm-pack has an -s flag for adding an @scope/ to the package.json's output name. maybe for the config it could accept an array of strings or objects and one of the object fields is 'scope'.

nshen commented

Hi, @seeker-3 sorry I'm late, could you try v0.1.8, let me know if the scope works, thanks.

Excellent! Thank you so much @nshen!

This appears to have broken what I would consider to be a fairly normal use case when the cratePath is ../../my-crate:

my-crate/
  Cargo.toml
  pkg/   <--- wasm-pack generates here
  www/
     node_modules/my-crate   <--- vite-plugin-wasm-pack copies pkg to here
     package.json

I had to downgrade to 0.1.7.

nshen commented

hi @johanventer thanks for let me know, could you upload an example?