You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What does this warning mean? Can this warning give a little more information as to its significance and what you might want to do about it (or perhaps where to find more information about it)?
Reacted by AA, HyperSimon, Mishkin Faustini, Hinnerk, fisher, David Vuong, coderaiser, Aubrey Taylor, José Arzuaga, Yves M. and 288 more
Reacted by Eirik Lillebo, Arman Yeghiazaryan, Mika Busante, Dawson Botsford, Matt, taka, Adrian, Samuel Hurel, Giovanni Maciel, Felix Horvat and 39 more
Ah, so its a warning that one of the dependencies is an expression. Thanks Sokra!
I would suggest that calling it a "critical dependency" doesn't quite describe what it is. Critical dependency makes me think of a dependency that must exist for things to work. Instead, this is simply warning about a dependency written as an expression. I would leave out the words "Critical dependency" and just let "the request of a dependency is an expression" describe it. Its much more understandable now tho.
Reacted by Nathan Phillip Brink, Jacob Thomason, Yariv Gilad, Arman Mirkazemi, HyperSimon, Ulric Wilfred, Ethan Pailes, Peter Velkov, Dmitriy Pushkov, Christopher Meyer and 135 more
Reacted by Robinzon, Nick Steele, mimof9, Ian Sebastian, Hadrien TOMA, cartok and Artem
Would there be a way to suppress this warning for 3rd party libraries? I don't want to get this every time I build just because I have a dependency that does this.
Reacted by Adam Bowles, Kyle J. Kemp, Sigurd Svela, Squirrel Bob, Marcos Silva, Rubens Mariuzzo, Vitaliy Potapov, Fabian Eichenberger, Terence Hong, ellenc345 and 390 more
Reacted by Squirrel Bob, Yariv Gilad, Pedr Browne, Adam Rackis, Stefan Bauer, Matt Chandler, heleg, Jonathan Palma, Guillaume RODRIGUEZ, Felix Henninger and 42 more
Would there be a way to suppress this warning for 3rd party libraries? I don't want to get this every time I build just because I have a dependency that does this.
This error should not be ignored. It usually means that every file below a certain path will be included into the bundle (which should certainly not be ignored).
Reacted by Nathan Phillip Brink, Luminescent, Nicholas Wong, Matt Chandler, Matthew, lleaff, Pontus Alexander, Benjamin Gruenbaum, Swati Swoboda, Daniel Blanco and 32 more
Reacted by ldk18501, Mark Deazley, James Webb, Artem Kolomytsev, Zach Gollwitzer, billy rennekamp, Joe, Poliakov Maksym, Zsolt Rácz, Shalom Sam and 22 more
Reacted by Travis Clarke, Joe, Kevin Mui, Edwin Ting, Sami Koskimäki, Nick Steele, itLeeyw, Tal, Dmitriy Chernukho and Csaba-Gyozo
Can I then suggest the error points to these two links?
On Wednesday, January 28, 2015, Johannes Ewald [email protected]
wrote:
Would there be a way to suppress this warning for 3rd party libraries? I
don't want to get this every time I build just because I have a dependency
that does this.
This error should not be ignored. It usually means that every file
below a certain path will be included into the bundle (which should
certainly not be ignored).
Unfortunately these problems can not be solved all the same way. It heavily depends on what the library author is trying to achieve, but almost always it can be avoided at all. See #733 and ansman/validate.js#12 (comment)
But I have no direct influence in how a third party lib does things. Can
this be solved without touching their code? Else a way to supres individual
errors would be great
On Wednesday, January 28, 2015, Johannes Ewald [email protected]
wrote:
Unfortunately these problems can not be solved all the same way. It
heavily depends on what the library author is trying to achieve, but almost
always it can be avoided at all. See #733 #733 and ansman/validate.js#12
(comment) ansman/validate.js#12 (comment)
—
Reply to this email directly or view it on GitHub #196 (comment).
@MarkNijhof, I believe that's what @jhnns is saying. Using aliases, require contexts, or some other mechanism, there is a way to fix the issue. webpack is powerful.
and the warning disappeared when I did the following:
letClass=require(`${url}`);
Should I worry about this thing?
Thanks!
Reacted by Doğa Yüksel, Michael, Taylor Stine, Marco Rivadeneyra, Maciej Maciaszek, shanyue, Jorge Antunes, Akimyou, Bertrandmc, monsterooo and 158 more
Reacted by ldk18501, Matthew King, Joe, Onur Aslan, ronanmulvaney, Seph Soliman, yuan, Shane McDermed and EastwoodStudio
Reacted by Dariusz Rzepka, Nino Filiu, Vitor Carvalho, Iago Bruno, Alex Gusev, Tom Nielsen, Johannes Loewe, Andrew Orsich, Enzo Innocenzi, Franco Sarachu and 29 more
Reacted by Sandip B, zodiacrt, Norbert Nemeth, Joe, Markoz Peña, markokoskinen2037, Andrea Aloi, Maximilian, Ak Ram, superern and 6 more
Reacted by Paul Melero, Frangeris Peguero, WanderleyC, Samuel Hurel, Kiryl Berasneu and William Franklin
Reacted by zodiacrt, Joe, Markoz Peña, Andrea Aloi, Matheus dos Reis de Jesus, Amadeusz Winogrodzki, overcomer79, mohamedaymenkarmous, hatem ghozzi, Brany and 15 more
Reacted by Dan Strokirk, Jeremy Mack, jpiersol, Bernard and Michael Cole
Reacted by Davi Medeiros, YQuan, Artem Sapegin, Boulmane Anas, Lennard Berger, Mustafa Can Palaz, David Turbert, Aurelio, David Berry and Jorge Florian
"use strict";module.exports=function(moduleName){if(typeofmoduleName!=="string"){thrownewTypeError("Passed parameter must be a string.");}try{require.resolve(moduleName);}catch(error){if(error.code==="MODULE_NOT_FOUND"){returnfalse;}throwerror;}returntrue;};
It kind of seems a legitimate use case for this kind of requiring so I'm just wondering what the recommended way of handling this could be?
EDIT: Actually, I guess the issue in a 'bundled' app is that require.resolve will always return false. But still, I wonder how to therefore suppress the error using the ContextReplacementPlugin?
I've read the many comments on this issue and still can't work out how to get rid of the error. It's fine when it's your own code and you can use require contexts, but if it's in a third-party module that you don't control, then it's harder. In my case, bundling Mocha causes this error, but it still works fine because I don't use any of the functionality that's affected. So, I just want to suppress the warning.
In case it helps anyone else, here's the best I could come up with. It's a dirty hack that looks for the path that mocha is trying to load from (.) and then checks that it is indeed mocha that's trying to load from it, and if so tells it to look for things using a regex that should never match anything.
newwebpack.ContextReplacementPlugin(/^\.$/,(context)=>{if(/\/node_modules\/mocha\/lib/.test(context.context)){//ensure we're only doing this for modules we know aboutcontext.regExp=/this_should_never_exist/for(constdofcontext.dependencies){if(d.critical)d.critical=false;}}})
(add the above to plugins in your webpack config)
Reacted by Edmund Cape, Daniel Ferenc Balogh, Mo Doaie, Jordan Wallet, WTW's Frontend and acheron
I wanted to share my own findings in investigating these warnings. In my experience, even though they can be suppressed (e.g. with exprContextCritical: false or by tricking webpack with template literal strings), they are usually indicative of some real issue and should be addressed, especially if they appear suddenly. If you are doing things on the backend, try using webpack-node-externals to not bundle your node_modules. In my case, I switched to a monorepo setup (e.g. Lerna / Yarn workspaces / NPM workspaces) and was using webpack-node-externals, but ran into this issue.
Activity
allow to configure default RegExps for automatically created contexts
sokra commentedon Mar 11, 2014
added better warning message
fresheneesz commentedon Mar 11, 2014
Ah, so its a warning that one of the dependencies is an expression. Thanks Sokra!
I would suggest that calling it a "critical dependency" doesn't quite describe what it is. Critical dependency makes me think of a dependency that must exist for things to work. Instead, this is simply warning about a dependency written as an expression. I would leave out the words "Critical dependency" and just let "the request of a dependency is an expression" describe it. Its much more understandable now tho.
kentcdodds commentedon Jan 19, 2015
Would there be a way to suppress this warning for 3rd party libraries? I don't want to get this every time I build just because I have a dependency that does this.
MarkNijhof commentedon Jan 28, 2015
+1 on suppressing
jhnns commentedon Jan 28, 2015
This error should not be ignored. It usually means that every file below a certain path will be included into the bundle (which should certainly not be ignored).
It always needs to be resolved with aliasing or require contexts
MarkNijhof commentedon Jan 28, 2015
Can I then suggest the error points to these two links?
On Wednesday, January 28, 2015, Johannes Ewald [email protected]
wrote:
Mark Nijhof
t: @MarkNijhof https://twitter.com/MarkNijhof
s: marknijhof
jhnns commentedon Jan 28, 2015
The error message is confusing, yes @sokra.
Unfortunately these problems can not be solved all the same way. It heavily depends on what the library author is trying to achieve, but almost always it can be avoided at all. See #733 and ansman/validate.js#12 (comment)
MarkNijhof commentedon Jan 28, 2015
But I have no direct influence in how a third party lib does things. Can
this be solved without touching their code? Else a way to supres individual
errors would be great
On Wednesday, January 28, 2015, Johannes Ewald [email protected]
wrote:
Mark Nijhof
t: @MarkNijhof https://twitter.com/MarkNijhof
s: marknijhof
kentcdodds commentedon Jan 28, 2015
@MarkNijhof, I believe that's what @jhnns is saying. Using aliases, require contexts, or some other mechanism, there is a way to fix the issue. webpack is powerful.
MarkNijhof commentedon Jan 28, 2015
Ah misunderstood, and yes very happy with webpack
On Wednesday, January 28, 2015, Kent C. Dodds [email protected]
wrote:
Mark Nijhof
t: @MarkNijhof https://twitter.com/MarkNijhof
s: marknijhof
sokra commentedon Jan 28, 2015
Try the ContextReplacmentPlugin...
MarkNijhof commentedon Jan 28, 2015
Thanks will try tomorrow :-)
On Wednesday, January 28, 2015, Tobias Koppers [email protected]
wrote:
Mark Nijhof
t: @MarkNijhof https://twitter.com/MarkNijhof
s: marknijhof
ayozebarrera commentedon Jan 19, 2016
I had the same warning using:
and the warning disappeared when I did the following:
Should I worry about this thing?
Thanks!
101 remaining items
lchioukh commentedon Apr 16, 2020
This warning can be linked to packages injections in (dependancies or devDependencies).
If the problem suddenly appears, check the last modification in your package.json.
Consider removing package-lock.json if you plan to relaunch an
npm install.Ancientshield commentedon Apr 24, 2020
smac89 commentedon Apr 27, 2020
Such an annoying warning. I solved this by using the following in
webpack.config.js:ChrisSargent commentedon May 18, 2020
I'm working on a lambda application with AWS amplify, hence my need for bundling (so I can't exclude Node Externals for example). I am seeing this error from a package (https://github.com/Nike-Inc/lambda-logger-node) which includes the following code:
Also, looking at another npm module, I can see the code does a similar thing which produces this error: https://github.com/kownacki/module-available/blob/master/index.js
It kind of seems a legitimate use case for this kind of requiring so I'm just wondering what the recommended way of handling this could be?
EDIT: Actually, I guess the issue in a 'bundled' app is that require.resolve will always return false. But still, I wonder how to therefore suppress the error using the ContextReplacementPlugin?
tstibbs commentedon Aug 28, 2020
I've read the many comments on this issue and still can't work out how to get rid of the error. It's fine when it's your own code and you can use require contexts, but if it's in a third-party module that you don't control, then it's harder. In my case, bundling Mocha causes this error, but it still works fine because I don't use any of the functionality that's affected. So, I just want to suppress the warning.
In case it helps anyone else, here's the best I could come up with. It's a dirty hack that looks for the path that mocha is trying to load from (
.) and then checks that it is indeed mocha that's trying to load from it, and if so tells it to look for things using a regex that should never match anything.(add the above to
pluginsin your webpack config)quick hack: removed unnecessary imports to avoid webpack related warn…
quick hack: removed unnecessary imports to avoid webpack related warn…
quick hack: removed unnecessary imports to avoid webpack related warn…
quick hack: removed unnecessary imports to avoid webpack related warn…
quick hack: removed unnecessary imports to avoid webpack related warn…
Remove dynamic `require`s, for Webpack support
macrozone commentedon Feb 10, 2021
I also have this with this library https://github.com/jeanlescure/short-unique-id
i use it in another library and now this "warning" leaks into any consumer of my library, altough nothing seems to be wrong at all.
I have to do something about it, does someone have an idea how to supress it for any consumer of my library?
fix: Fix compile time issue with webpack/webpack#196 (comment)
johndiiorio commentedon Jul 30, 2021
I wanted to share my own findings in investigating these warnings. In my experience, even though they can be suppressed (e.g. with
exprContextCritical: falseor by tricking webpack with template literal strings), they are usually indicative of some real issue and should be addressed, especially if they appear suddenly. If you are doing things on the backend, try using webpack-node-externals to not bundle yournode_modules. In my case, I switched to a monorepo setup (e.g. Lerna / Yarn workspaces / NPM workspaces) and was usingwebpack-node-externals, but ran into this issue.Hide the `electron` import from Webpack