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

Can't resolve 'wasmer_wasi_js_bg.wasm' #290

Open
MihaelIsaev opened this issue Jan 29, 2022 · 7 comments
Open

Can't resolve 'wasmer_wasi_js_bg.wasm' #290

MihaelIsaev opened this issue Jan 29, 2022 · 7 comments

Comments

@MihaelIsaev
Copy link

Trying to compile my files using webpack and getting weird error Can't resolve 'wasmer_wasi_js_bg.wasm'

Seems it is related to @wasmer/wasi, please help

Screenshot 2022-01-30 at 01 41 41

@corwin-of-amber
Copy link
Contributor

Is this Webpack 5? I would recommend declaring .wasm files as resource assets in your webpack.config.js, like this:
https://webpack.js.org/guides/asset-modules/#resource-assets

@corwin-of-amber
Copy link
Contributor

Actually, looking at my own node_modules/@wasmer, it looks like wasmer_wasi_js_bg.wasm is not there at all. It sill manages to load WASM binaries though... (disclaimer: I have not tried it with Webpack.)

@MihaelIsaev
Copy link
Author

Is this Webpack 5?

webpack: 5.67.0
webpack-cli: 4.9.2

I rolled back to @wasmer/wasi@0.12.0 for now where everything just worked

@corwin-of-amber
Copy link
Contributor

well ofc 0.12.0 did not have any wasm component. I looked at the code a little bit, the wasm should be dataurl-packed into the JS, but for some reason there is still a URL pointing at the code. I believe this can be worked around using externals (https://webpack.js.org/configuration/externals/) to make webpack ignore the missing file, since it will not actually be required at runtime. Have to try myself with Webpack later.

@corwin-of-amber
Copy link
Contributor

I managed to convince Webpack with the following externals config:

    externals: {
        'wasmer_wasi_js_bg.wasm': true
    }

Clearly a bit weird... @syrusakbary any idea why the line:

input = await WebAssembly.compile(dataUriToBuffer(wasm_bytes as any as string));

generates a fetch in Library.esm.js?

    if (typeof input === 'undefined') {
        input = new URL('wasmer_wasi_js_bg.wasm', import.meta.url);
    }
    ...
    input = fetch(input);

@amesgen
Copy link

amesgen commented Dec 31, 2022

For anyone looking how to resolve this when using Parcel: An approach that worked for me is to use the parcel-resolver-ignore plugin (see setup docs there), and then to add

  "parcelIgnore": [
    "wasmer_wasi_js_bg.wasm"
  ]

to package.json.

tyfkda added a commit to tyfkda/wasi-on-js-test that referenced this issue Apr 23, 2023
  * wasmer_wasi_js_bg.wasm がない
    * [Can't resolve 'wasmer_wasi_js_bg.wasm' · Issue #290 · wasmerio/wasmer-js](wasmerio/wasmer-js#290)
    * ず無視リストに入れると一応動く
  * 標準出力をフックする方法はあるか?
@enriquebarco
Copy link

I managed to convince Webpack with the following externals config:

    externals: {
        'wasmer_wasi_js_bg.wasm': true
    }

Clearly a bit weird... @syrusakbary any idea why the line:

input = await WebAssembly.compile(dataUriToBuffer(wasm_bytes as any as string));

generates a fetch in Library.esm.js?

    if (typeof input === 'undefined') {
        input = new URL('wasmer_wasi_js_bg.wasm', import.meta.url);
    }
    ...
    input = fetch(input);

This helped me resolve the issue. Thanks @corwin-of-amber for the tip.

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

4 participants