Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const moduleFileExtensions = [
'json',
'web.jsx',
'jsx',
'wasm',
];

// Resolve file paths in the same order as webpack
Expand Down
4 changes: 2 additions & 2 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ module.exports = function(webpackEnv) {
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise be processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// Also exclude `html`, `wasm` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
exclude: [/\.(js|mjs|jsx|ts|tsx|wasm)$/, /\.html$/, /\.json$/],
Copy link
Contributor

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

Copy link
Author

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

options: {
name: 'static/media/[name].[hash:8].[ext]',
},
Expand Down