Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project does not work with renamed packages #18

Open
SnowyCoder opened this issue Jun 30, 2022 · 0 comments
Open

Project does not work with renamed packages #18

SnowyCoder opened this issue Jun 30, 2022 · 0 comments

Comments

@SnowyCoder
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant