Project does not work with renamed packages
SnowyCoder opened this issue · 0 comments
SnowyCoder commented
It's not unusual to have wasm-pack packages exported with different names,
and since this is not yet supported by wasm-pack people have been using sed to replace the "name" field in package.json
(rustwasm/wasm-pack#427).
This plugin does not seem to work when the imported package name fails to match the package files.
I tried to open a pull request but I'm new to rollup/vite plugin and I don't want to waste the next 5 months trying to reimplement classic-js resolution algorithm, so I'll leave this issue if anyone wants to work into it.
As a workaround you can use this in your wasm-pack Makefile to rename "my_module_wasm" into "my_module":
sed -i -e 's/my\([-_]\)module[-_]wasm/my\1module/g' pkg/package.json pkg/my_module_wasm.js
for f in pkg/my_module_wasm*; do mv "$$f" $$(echo "$$f" | sed 's/my_module_wasm/my_module/g'); done
The double $$
are required to escape bash variables from make.