-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Passthrough wasm files to webpack internal loaders #7911
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
Conversation
// by webpacks internal loaders. | ||
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], | ||
exclude: [/\.(js|mjs|jsx|ts|tsx|wasm)$/, /\.html$/, /\.json$/], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! If we were to make this change, perhaps we should add the extension to
const moduleFileExtensions = [ |
Presumably you could then import ./foo
which could resolves ./foo.wasm
. Webpack appears to support this behavior by default: https://webpack.js.org/configuration/resolve/#resolveextensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I made and tested the change you suggested.
Also, here's a test repo, for reference: https://github.com/pmrcunha/cra-wasm-test
It's not quite clear to me if this is fully supported on webpack's side. It sounds like it's still very much experimental. For example this PR: webpack/webpack#9415 as well as https://github.com/webpack/webpack/blob/master/examples/wasm-simple/webpack.config.js seem to indicate setting |
I think you're right: https://github.com/webpack/changelog-v5/blob/master/README.md#experiments I'm quite new to wasm myself, so my idea was more that CRA could allow people to experiment with wasm without ejecting, by letting the wasm files through, not so much to fully support it. I totally get it if you feel that that could be risky though. |
Thanks for the link! This line in that change log is interesting:
If that's the case, it's not likely that we will want to enable this under the I'm going to close this for now, but please do let us know when it becomes stable in webpack and we'll do our best to support it! |
Closes #4912.
Hi!
I was unable to load a .wasm file in an app generated with CRA, since the file-loader was catching it and throwing an error.
After ejecting, I realized that a minor change would allow the wasm files to be handled by webpack's internal loaders. This PR adds that change to CRA, so that wasm can be used without ejecting.
I tested my changes manually, by creating an app with CRA, linking my version of react-scripts, running the app normally, and then running the app loading an hello-world wasm project.
Hope this is useful!