-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(relay-reactjs): ensure cjs files are processed by webpack
This is because @chainsafe/libp2p includes one cjs module. Can be avoided if facebook/create-react-app#12605 is merged.
- Loading branch information
1 parent
4bebf60
commit 86d0271
Showing
3 changed files
with
209 additions
and
1,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const {getLoaders, loaderByName} = require("@craco/craco"); | ||
|
||
module.exports = { | ||
webpack: { | ||
configure: (webpackConfig) => { | ||
const {hasFoundAny, matches} = getLoaders(webpackConfig, loaderByName("babel-loader")); | ||
|
||
if (hasFoundAny) { | ||
matches.forEach(c => { | ||
// Modify test to include cjs for @chainsafe/libp2p-gossipsub rpc module | ||
if (c.loader.test.toString().includes("mjs")) { | ||
// If your project uses typescript then do not forget to include `ts`/`tsx` | ||
if (c.loader.test.toString().includes('jsx')) { | ||
c.loader.test = /\.(js|cjs|mjs|jsx)$/ | ||
} else { | ||
c.loader.test = /\.(js|cjs|mjs)$/ | ||
} | ||
} | ||
}); | ||
} | ||
|
||
return webpackConfig; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.