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

wasm-pack and webpack 5 #835

Open
BenoitDel opened this issue Apr 27, 2020 · 6 comments
Open

wasm-pack and webpack 5 #835

BenoitDel opened this issue Apr 27, 2020 · 6 comments

Comments

@BenoitDel
Copy link

I am trying to make wasm-pack and webpack 5 works together.
They work well all together (out of the box) only for the most simple use case.
If memory or imports are necessary, modification has to be made to the wasm-pack build to adjust with:

  • the new import syntax of webpack 5
  • the absence of node module like utils

I have several questions:

  • What is the roadmap for wasm-pack and webpack 5 ?
  • may i fill issue(s) about these compatibility problems ?
  • If yes, should i fill the issue here or on wasm-bindgen repo ?
@BenoitDel
Copy link
Author

wasm-bindgen is taking care of it.
wasm bindgen-2110

@samvv
Copy link

samvv commented Feb 3, 2021

A short update on Webpack 5 support. If you're using the most recent version of Webpack you need to add the following to webpack.config.js:

{
  module: {
    rules: [
      {
        test: /\.wasm$/,
        type: 'webassembly/sync',
      }
    ]
  },
  experiments: {
    syncWebAssembly: true
  }
}

Note that this requires the now deprecated syncWebAssembly backend. If you're getting the following error:

Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #0 module="./edmund_bg.js" function="__wbg_new_59cb74e423758ede" error: function import requires a callable

You're using the new experimental asyncWebAssembly backend that is currently not working too well with wasm-pack.

Given that the working configuration is now deprecated, I'm curious to how asyncWebAssembly will evolve and how it will integrate with wasm-pack. No idea if the error is a bug in Webpack or in this project.

@superjose
Copy link

I'm currently diving into Web Assembly, and I was wondering what is this "new Web Assembly spec", and whether it's something that wasm-pack will handle, or is there a consideration that we need to take into working with Rust itself.

@tcper
Copy link

tcper commented Jul 16, 2022

Finally, I found this!
CRA not work freaks me out, recommend add this content to README

@HarikrishnanBalagopal
Copy link

Any update on this? Still facing issues

@klu235
Copy link

klu235 commented Sep 10, 2023

I am using webpack v5.88.2 and webpack-dev-server v4.15.1. I tried samvv's suggested changes in webpack.config.js, and still got the following error when trying to run webpack-dev-server:

export 'memory' (imported as 'memory') was not found in 'wasm-for-my-site/my_website_bg'

The export of the memory variable is supposed to be done by my_website_bg.wasm.d.ts, and this export works perfectly in webpack4, but not in webpack5.

webpack's frequent breaking of backwards compatibility is disappointing, to say the least. Its documentation also contains many grammar mistakes that some of the maintainers refuse to correct, even when given pull requests with corrections of those errors and no other changes.

I hope the Rust and WASM communities move on to better-documented and more consistent bundlers in the future.

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

6 participants