sindresorhus / import-fresh

Import a module while bypassing the cache
MIT License
284 stars 25 forks source link

Critical dependency warning when bundling with Webpack 5 #25

Open Poolshark opened 2 years ago

Poolshark commented 2 years ago

I've ran into an issue when trying to run a React application with Webpack 5. I receive the warning

WARNING in ../../../.yarn/cache/import-fresh-npm-3.3.0-3e34265ca9-2cacfad06e.zip/node_modules/import-fresh/index.js 32:31-48

Critical dependency: the request of a dependency is an expression

According to here this is caused by something like:

let var1 = someCall();
require(var1); // webpack can't determine var1 value

Here is the location in your source code which could be the problem.

https://github.com/sindresorhus/import-fresh/blob/main/index.js#L32 report there. ( not sure that this should work with webpack )

rishu605 commented 1 year ago

I also get a similar error when bundling with webpack. I am using webpack with swc

webpack version - 5.75 node - 18.12.1

Error: WARNING in ./node_modules/import-fresh/index.js 32:31-48 Critical dependency: the request of a dependency is an expression For me this error is coming through packages following packages: Screenshot from 2022-12-10 22-09-22

markdav-hpe commented 1 year ago

+1

Import trace for requested module:
./node_modules/import-fresh/index.js
./node_modules/cosmiconfig/dist/loaders.js
./node_modules/cosmiconfig/dist/index.js
./node_modules/@databases/pg-config/lib/index.js
./node_modules/@databases/pg/lib/index.js
./src/lib/database.tsx
./src/app/page.tsx
 ⚠ ./node_modules/cosmiconfig/dist/loaders.js
Critical dependency: the request of a dependency is an expression