Skip to content
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

Webpack - Critical dependency: the request of a dependency is an expression with 2.25.0 #5489

Closed
lllopo opened this issue May 1, 2020 · 36 comments

Comments

@lllopo
Copy link

lllopo commented May 1, 2020

This morning I upgraded moment from 2.24.0 to 2.25.0 and started getting this warning from my Webpack build :
Critical dependency: the request of a dependency is an expression

Versions I'm using :
gulp - 4.0.2
webpack - 4.43.0
babel - 7.9.6

No other updates occurred in between. Only moment.js got updated and the warning appeared.

@chrisgiann44
Copy link

same issue

@mhabib555
Copy link

mhabib555 commented May 1, 2020

same issue
after installing moment in laravel vue app.
WARNING in ./node_modules/moment/src/lib/locale/locales.js 78:12-82:13 Critical dependency: the request of a dependency is an expression @ ./node_modules/moment/src/lib/locale/locale.js @ ./node_modules/moment/src/moment.js @ ./resources/js/app.js @ multi ./resources/js/app.js ./resources/sass/app.scss

@hebinet
Copy link

hebinet commented May 1, 2020

Same here, locking the package version to 2.24.0 helps for now...

@pwinkelm
Copy link

pwinkelm commented May 1, 2020

Same problem over here! Critical!

@joebentaylor1995
Copy link

I have had the same issue! Locked mine to 2.24.0 and fixed my build

@constlhq
Copy link

constlhq commented May 1, 2020

Seconded

@lykhvar
Copy link

lykhvar commented May 1, 2020

Same here. 2.25.0 gives this issue but not 2.24.0. Changes at 2092:16-2096:17 in moment.js is the root.

@dwsmart
Copy link

dwsmart commented May 1, 2020

Same issue, but strangely only when running as dev (this is a nuxt project) The issues seems to be in src/lib/locale/locales.js line 78 - 82,

Changing:

aliasedRequire(
                (typeof __dirname !== undefined ? __dirname : '.') +
                    '/locale/' +
                    name
            );

to:

aliasedRequire('../locale/' + name);

Fixes the issue for me

@lllopo
Copy link
Author

lllopo commented May 1, 2020

I get it both on dev and prod builds with my setup.

@lllopo
Copy link
Author

lllopo commented May 1, 2020

Same here, locking the package version to 2.24.0 helps for now...

Yeah, that's the obvious workaround, but not really a solution :-).

@kaustubhkhare19
Copy link

kaustubhkhare19 commented May 1, 2020

I am also getting the same warning and getting following console errors, in a web browser for angular application while calling moment.format().

ERROR TypeError: __WEBPACK_IMPORTED_MODULE_2_moment__ is not a function
(main.bundle.js:11539)
Show 102 more frames

@enrtama
Copy link

enrtama commented May 1, 2020

same here

@briangonzalezmia
Copy link

Confirmed as well

@ichernev
Copy link
Contributor

ichernev commented May 1, 2020

Wait a second -- this is warning, not an error. Does it still produce a bundle?

@ichernev
Copy link
Contributor

ichernev commented May 1, 2020

With moment 2.25.0:

% ./node_modules/.bin/webpack
Hash: 42b60d02778538c038dc
Version: webpack 4.43.0
Time: 497ms
Built at: 05/01/2020 4:56:43 PM
    Asset      Size  Chunks             Chunk Names
bundle.js  72.2 KiB       0  [emitted]  main
Entrypoint main = bundle.js
[13] ./node_modules/moment/src/lib/units/month.js + 1 modules 9.92 KiB {0} [built]
     |    2 modules
[26] ./node_modules/moment/src/lib/create/valid.js + 1 modules 1.88 KiB {0} [built]
     |    2 modules
[36] ./node_modules/moment/src/lib/create/from-anything.js + 8 modules 25.1 KiB {0} [built]
     |    9 modules
[46] (webpack)/buildin/harmony-module.js 573 bytes {0} [built]
[47] ./node_modules/moment/src/lib/locale sync 160 bytes {0} [optional] [built]
[48] ./src/index.js + 54 modules 84.6 KiB {0} [built]
     | ./src/index.js 62 bytes [built]
     |     + 54 hidden modules
    + 43 hidden modules

WARNING in ./node_modules/moment/src/lib/locale/locales.js 78:12-82:13
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/moment/src/lib/locale/locale.js
 @ ./node_modules/moment/src/moment.js
 @ ./src/index.js

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

And it works.

With moment@2.24.0:

% ./node_modules/.bin/webpack
Hash: c16dbd62d51ed42203b2
Version: webpack 4.43.0
Time: 559ms
Built at: 05/01/2020 4:58:27 PM
    Asset     Size  Chunks                    Chunk Names
bundle.js  263 KiB       0  [emitted]  [big]  main
Entrypoint main [big] = bundle.js
[128] ./src/index.js 62 bytes {0} [built]
[129] (webpack)/buildin/module.js 497 bytes {0} [built]
[130] ./node_modules/moment/locale sync ^\.\/.*$ 3 KiB {0} [optional] [built]
    + 128 hidden modules

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  bundle.js (263 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  main (263 KiB)
      bundle.js


WARNING in webpack performance recommendations: 
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

And it still works.

@lllopo
Copy link
Author

lllopo commented May 1, 2020

Wait a second -- this is warning, not an error. Does it still produce a bundle?

Yes, it does. Still - annoying, wrong and makes the build output full of crappy traces.

ViktorSoroka07 pushed a commit to folio-org/stripes-data-transfer-components that referenced this issue May 1, 2020
@jontybrook
Copy link

I'm also seeing this, but only in production builds via our CI.

@tsengorz
Copy link

tsengorz commented May 1, 2020

@jontybrook I was seeing the same behavior but after nuking node_modules folder, I was able to reproduce this locally.

@ichernev
Copy link
Contributor

ichernev commented May 1, 2020

The code with __dirname which was fixing an issue for react-native had to be reverted so that you (webpack users) can look at a better console output.

Fixed in 2.25.1

@ichernev ichernev closed this as completed May 1, 2020
@agrohs
Copy link

agrohs commented May 1, 2020

This has nothing to do with better console output...but rather less than ideally tested code breaking builds for MANY MANY people!

@agrohs
Copy link

agrohs commented May 1, 2020

Glad to hear its been fixed and published minutes ago though - spent the last many hours digging into on our end trying to find the cause

@lllopo
Copy link
Author

lllopo commented May 1, 2020

This has nothing to do with better console output...but rather less than ideally tested code breaking builds for MANY MANY people!

Exactly ! Warning today is a potential error tomorrow.

@agrohs
Copy link

agrohs commented May 1, 2020

It was much worse than a warning...if you by chance were running moment-timezone which dynamically pulls in latest version of moment, this caused a full breaking of code!

@agrohs
Copy link

agrohs commented May 1, 2020

Wait a second -- this is warning, not an error. Does it still produce a bundle?

If only producing a bundle was the only desired result...

@lllopo
Copy link
Author

lllopo commented May 1, 2020

The code with __dirname which was fixing an issue for react-native had to be reverted so that you (webpack users) can look at a better console output.

Fixed in 2.25.1

Why the sarcasm ?! Clean output is important. In my setup I’ve put stats and metrics which are important for me and flooding it with unnecessary stuff makes it tiresome to read and slows my work at the very least. Then it comes the fact that a warning is always something that should not be ignored in the long term. Last, but actually first - it turns out to be really breaking for some setups as @agrohs reported. So ... sarcasm is not well placed here I beleive. Thanks for fixing it, though.

zburke added a commit to folio-org/stripes-components that referenced this issue May 2, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489),
[5472](moment/moment#5472)).

The `resolutions` entry is necessary because `2.25` leaks in via transitive deps.

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
@dlong500
Copy link

dlong500 commented May 2, 2020

The code with __dirname which was fixing an issue for react-native had to be reverted so that you (webpack users) can look at a better console output.

Fixed in 2.25.1

Sarcasm aside, v2.25.1 doesn't actually fix anything (the Module not found warning is still there). I typically refrain from being critical of open source contributors who are volunteering their time, but please don't have an attitude towards users who are simply reporting issues. And yes, warnings are there for a reason. Ignoring them obscures all sorts of other info and usually leads to something broken down the road.

@agrohs
Copy link

agrohs commented May 2, 2020

This issue should not be closed...it is a breaking change for moment-timezone users who are using webpack, not just an issue of showing a warning (and affecting an enormously large number of people)

zburke added a commit to folio-org/stripes-core that referenced this issue May 2, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/stripes-smart-components that referenced this issue May 3, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0` 
([5489](moment/moment#5489), [5472](moment/moment#5472)).

The `resolutions` entry is necessary because `2.25` leaks in via transitive deps.

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-calendar that referenced this issue May 3, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-checkout that referenced this issue May 3, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-circulation that referenced this issue May 3, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-eholdings that referenced this issue May 3, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-users that referenced this issue May 4, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

The `resolutions` entry is necessary because `2.25` leaks in via
transitive deps. I don't know why it is necessary here when it isn't,
say, in ui-circulation, which pulls it in via the same route of
stripes-cli and stripes-core. That makes no sense. Alas.

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
@standard-software
Copy link

standard-software commented May 4, 2020

same problem
not fix 2.25.0
not fix 2.25.1
not fix 2.25.2

I want you to revert to the original version.

Operation check environment
https://github.com/standard-software/partsjs/tree/v5.0.0
package.json

@jasonwr
Copy link

jasonwr commented May 4, 2020

Guy this is not fixed! Can we not close defects until they are resolved especially when they break existing builds such as Webpack?! @ichernev please re-open this as it's not resolved! This is going to break many people who rely on MomentJS and use it with vanilla Webpack.

zburke added a commit to folio-org/ui-users that referenced this issue May 4, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

The `resolutions` entry is necessary because `2.25` leaks in via
transitive deps. 

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
zburke added a commit to folio-org/ui-checkout that referenced this issue May 5, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

The `resolutions` entry is necessary because `2.25` leaks in via
transitive deps.

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
@sicutdeux
Copy link

sicutdeux commented May 5, 2020

Hi, BUMP!, this is breaking my build also, not fixed!.

zburke added a commit to folio-org/ui-circulation that referenced this issue May 7, 2020
`moment` `v2.25` less than `v2.25.3` caused many webpack-related bugs
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs STRIPES-678
zburke added a commit to folio-org/ui-circulation that referenced this issue May 7, 2020
`moment` `v2.25` less than `v2.25.3` caused many webpack-related bugs
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs STRIPES-678
zburke added a commit to folio-org/ui-calendar that referenced this issue May 7, 2020
Pin `moment` at `~2.24.0` in light of multiple issues with `2.25.0`
([5489](moment/moment#5489), [5472](moment/moment#5472)).

Refs [STRIPES-678](https://issues.folio.org/browse/STRIPES-678)
@CesarAdan1
Copy link

I just update moment with npm i moment and it solved it

@angelobruch
Copy link

Same issue, but strangely only when running as dev (this is a nuxt project) The issues seems to be in src/lib/locale/locales.js line 78 - 82,

Changing:

aliasedRequire(
                (typeof __dirname !== undefined ? __dirname : '.') +
                    '/locale/' +
                    name
            );

to:

aliasedRequire('../locale/' + name);

Fixes the issue for me

Thanks, this really helped me!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests