question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@next react-scripts(webpack.config.js) to resolve `.wasm` extension?

See original GitHub issue

I was curious if there was any reason .wasm extension was left out from resolve.extensions list?

Webpack also default to include .wasm.

It’d be nice to start using/experimenting wasm from create-react-app!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:32
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

10reactions
dlechcommented, Jan 12, 2021

From what I have seen in other discussions, it seems like the create-react-app philosophy is to ignore the fact that it uses webpack internally - in other words, webpack features should not be relied upon. However, webpack includes a match for .wasm in defaultRules which does not magically work for all .wasm files.

For example, when using a .wasm file created with Emscripten (https://github.com/webpack/webpack/issues/7352) in a create-react-app project, we get the error:

Failed to compile.

./src/sagas/mpy-cross.wasm
Module parse failed: magic header not detected
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: magic header not detected

So it would be nice if create-create-react app could disable this default rule in webpack so users can handle .wasm files however they like without webpack interfering.

As a workaround, I changed the file extension of the .wasm file to .emcwasm so that webpack just treated it like a normal binary file instead of trying to load it as a JavaScript module. (And had to configure the web server to serve .emcwasm files with the application/wasm MIME type.)

3reactions
alojzmiliceviccommented, Nov 22, 2019

Is there no way of making it work by overriding config in config-overrides?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize webpack configuration of React App created with ...
It was Saturday night hanging around to solve the issue of “ReferenceError: legacyLib is not defined” in my React+Typescript app.
Read more >
Using WebAssembly with React - Telerik
Modify Webpack to Support WebAssembly. We need to add a config-overrides.js file to the root of our app. This file will allow us...
Read more >
An Introduction to WebAssembly - Part 2 - Section.io
This article includes WebAssembly walk through the steps of building a react application the consumes a Wasm module.
Read more >
How to use WebAssembly (wasm) with create-react-app
The following solution is for CRA 3.x. For CRA 4.x you should use craco. CRA does not support WASM. But you can workaround...
Read more >
WASM in Create-React-App 4 in 5mn (without ejecting)
Run WASM code in your create-react-app without pain (and without ejecting). ... /\.wasm$/; webpackConfig.resolve.extensions.push('.wasm'); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found