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

Incompatibility with wasm-pack 0.13.0 #9

Open
acheroncrypto opened this issue Aug 3, 2024 · 1 comment
Open

Incompatibility with wasm-pack 0.13.0 #9

acheroncrypto opened this issue Aug 3, 2024 · 1 comment

Comments

@acheroncrypto
Copy link

Problem

Upgrading wasm-pack to the latest version (0.13.0) results in the following error with bundlers:

Module not found: Error: Can't resolve '../../..' in '/home/runner/work/solana-playground/solana-playground/client/node_modules/@solana-playground/rust-analyzer/snippets/wasm-bindgen-rayon-7afa899f36665473/src'
Did you mean 'rust_analyzer_wasm.js'?
BREAKING CHANGE: The request '../../..' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

// This might need updating if the generated structure changes on wasm-bindgen
// side ever in the future, but works well with bundlers today. The whole
// point of this crate, after all, is to abstract away unstable features
// and temporary bugs so that you don't need to deal with them in your code.
import initWbg, { wbg_rayon_start_worker } from '../../../';

The structure of the wasm-bindgen generated package didn't change, but rustwasm/wasm-pack#1061 added type: "module" to the package.json which expects full path imports.

Related upstream issue: rustwasm/wasm-pack#1402

Solution

This should probably get fixed from wasm-pack's side by introducing an option for wasm-pack build that changes the type used.

In the meantime, there are 2 possible immediate workarounds for people who run into this:

  • Remove type: "module" from the generated package.json
  • Downgrade to wasm-pack 0.12.1
acheroncrypto added a commit to solana-playground/solana-playground that referenced this issue Aug 8, 2024
`wasm-bindgen-rayon` is not compatible with `wasm-pack 0.13.0`, see RReverser/wasm-bindgen-rayon#9
@noname0310
Copy link
Contributor

Here's another solution using the latest version of wasm-pack, if you're having the same problem, it might help.

Just set resolvefullyspecified to false in your webpack config
https://webpack.js.org/configuration/module/#resolvefullyspecified

This is how I'm applying it in my project

https://github.com/noname0310/babylon-mmd/blob/main/webpack.config.ts#L70-L73

export default (env: any): webpack.Configuration & { devServer?: WebpackDevServerConfiguration } => ({
    // ...
    module: {
        rules: [
            {
                test: /\.m?js$/,
                resolve: {
                    fullySpecified: false
                }
            },
        ]
    },
    // ...
});

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

2 participants