question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Require function is used in a way in which dependencies cannot be statically extracted

See original GitHub issue

Hi,

Firstly thank-you for all the hard work on msw, it really makes mocking end-points really easy. I have found that on latest Storybook (6.4.9), there’s a warning in the console:

./node_modules/msw-storybook-addon/dist/mswDecorator.js
25:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

It is referring to this line. I have found simply commenting it out directly in my node_modules resolves the issue. Is there a reason for assigning require to __non_webpack_require__? Doesn’t this overwrite the point of using __non_webpack_require__ in this instance? i.e.

  1. globalThis.__non_webpack_require__ = require is replaced by webpack to globalThis.__non_webpack_require__ = __webpack__require__
  2. Meaning the next line reads: const { setupServer } = __webpack_require__('msw/node')

I’m going to see if I can get this repo up and running in a fork and replicate the issue…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
will-stonecommented, Jan 25, 2022

Sure @kettanaito, will do 👍 Thanks.

0reactions
kettanaitocommented, Jan 25, 2022

That sounds like a great approach, @will-stone. Would you like to open a pull request so we could release it?

Read more comments on GitHub >

github_iconTop 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 >
Critical dependency: require function is used in a way ... - GitHub
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #1252 · Comments · Workarounds to ...
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
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted ; samueljbarrick May 4, 2020, 10:28pm ...
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 · Best Solution...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found