Closed smorimoto closed 4 months ago
We decided to adopt this strategy for releasing the wasm
package as discussed in the following issue: https://github.com/napi-rs/napi-rs/issues/1794
If you encounter any issues, comments are welcome in the original issue.
On StackBlitz, the value of process.arch
will be wasm32
btw
Vercel's edge runtime seems to resolve the browser, which requires wasm code, but in the current setup it is not installed in typical environments. It might not be ideal, but it might be helpful to get rid of the cpu constraint to work around the weird error with Next.js + edge runtime.
@smorimoto For the edge runtime scenario, you can use npm install --cpu=wasm32
to let the package manager pick the right dependency.
You can't use it with yarn. And in esbuild, nothing is specified: https://github.com/evanw/esbuild/blob/main/npm/esbuild-wasm/package.json
You can't use it with yarn
For yarn1.x, you can use yarn install --ignore-platform
to install wasm32
package
For yarn2+, you can set the supportedArchitectures.cpu
to ["current", "wasm32"]
by running yarn config set --json supportedArchitectures.cpu '["current", "wasm32"]'
We added wasm32
to the CPU field because we don't want to increase the installation size for users who don't want to use the wasm package. And for the platforms like StackBlitz, the user won't need to install an additional package manually like esbuild-wasm
to make things work.
And sharp chooses the same strategy to publish wasm package: https://github.com/lovell/sharp/blob/main/npm/wasm32/package.json#L40
That pointer definitely helped me! Thank you!
cpu
inpackage.json
refers toprocess.arch
, butwasm 32
is not a valid value.https://github.com/napi-rs/node-rs/blob/de1e89bfd55f444090e4d3dc97dc5772ddd89296/packages/bcrypt/npm/wasm32-wasi/package.json#L4-L6
This might cause an error such as the following:
Ref