-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #1252
Comments
Issue introduced in v0.41.0 |
Workarounds to suppress the warnings
Reference
|
I have same issue running my app on local. It's really annoying because @mswjs/data is using msw@latest so even if i downgrade this one, i will still get the error because @mswjs/data will use 0.41.0 |
@baptistefkt use |
Hey, @akunzai. Thanks for reporting this. I will take a look at what causes this issue when I have time. Anybody else is also welcome to tackle it—I think it's a matter of |
Maybe the reason is that Webpack does not like UMD wrappers. Not the fault of Reference |
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 |
Same issue here |
Please wait for the next release. You can see that there's a linked PR above and it fixes the issue. Thank you. |
I'm using version 0.40 as suggested until then |
Released: v0.42.0 🎉This has been released in v0.42.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
I'm now getting 1 type issue with [email protected]:
🤷♂️ |
FWIW we publish react-data-grid as both cjs and esm and it's been working well for us, maybe you can take inspiration from our rollup/package.json config: |
Thanks for the reference, @nstepien! We've been using Rollup in MSW for quite some time, and there were no issues with its ESM build (the |
@kettanaito Running into this with [email protected] in Nuxt Bridge as well:
Here's the code: |
Thanks for your patience, everyone. I'm looking into this issue, trying to wrap my head around what exactly is the root cause here. This is reliably reproducible on the The import path that causes the webpack warning is:
This comes down to the Previously, we solved this by importing the I think the correct solution here is to figure out what kind of output webpack wants. From what I can tell, it's a bit odd that an ESM import to Proposed solutionI confirm that if the entire import path of ESM contains modules referenced by So, what happens is that somewhere along the import chain of ESM resolution a CJS module gets imported. It contains |
The solution is implemented in https://github.com/mswjs/msw/blob/1f12ad9bef1808518ba9608143daf285403cea45/config/plugins/esbuild/forceEsmExtensionsPlugin.ts and will be published alongside the Fetch API primitives support in the next major version. Unfortunately, I don't have the time capacity to ship a backport for this because this requires a total library restructure and I'd pretty much like to do it just once. Thanks. |
Prerequisites
Environment check
msw
versionNode.js version
v16.15.0
Reproduction repository
https://github.com/akunzai/react-boilerplate
Reproduction steps
Current behavior
The CI pipeline failed with warnings:
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
.Expected behavior
Run the CI pipeline successfully.
The text was updated successfully, but these errors were encountered: