Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Node.js version
v16.15.0
Reproduction repository
https://github.com/akunzai/react-boilerplate
Reproduction steps
yarn add msw@0.41.0
CI=true yarn build
Current behavior
The CI pipeline failed with warnings: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Creating an optimized production build...
Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.
Failed to compile.
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
and the warning was caused by ./node_modules/msw/lib/esm/index.js
.
$ yarn start
Compiled with warnings.
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
WARNING in ./node_modules/msw/lib/esm/index.js 30:70-77
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./node_modules/msw/lib/esm/index.js 33:45-52
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
webpack compiled with 2 warnings
Expected behavior
Run the CI pipeline successfully.
Creating an optimized production build...
Compiled successfully.
Issue Analytics
- State:
- Created a year ago
- Reactions:20
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Critical dependency: require function is used in a way in which ...
Critical dependency : require function is used in a way in which dependencies cannot be statically extracted · Subscribe to RSS.
Read more >Incompatible with Webpack - Google Groups
"require function is used in a way, in which dependencies cannot be statically extracted" These errors come when trying to "require" specific modules, ......
Read more >Critical dependency: require function is ... - Auth0 Community
Error message : Critical dependency: require function is used in a way in which dependencies cannot be statically extracted.
Read more >Node.js – WARNING in Critical dependency: require function ...
Node.js – WARNING in Critical dependency: require function is used in a way in which dependencies cannot be statically extracted. angularnode.jswebpack.
Read more >Linting error with Moralis react - Largest Web3 Dev Community
Critical dependency : require function is used in a way in which dependencies cannot be statically extracted.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’d be our fault if UMD slips through somehow. We’ve removed the UMD build target in 0.41.0.
The error originates from the
esm
target, which should not have anyrequire
statements. It’d be nice to explore that built module and see if it indeed has arequire
and see why so.Released: v0.42.0 🎉
This has been released in v0.42.0!
Make sure to always update to the latest version (
npm i msw@latest
) to get the newest features and bug fixes.Predictable release automation by @ossjs/release.