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

Ionic 3 and Webpack 2 warning #11072

Closed
ghaiat opened this issue Apr 5, 2017 · 25 comments
Closed

Ionic 3 and Webpack 2 warning #11072

ghaiat opened this issue Apr 5, 2017 · 25 comments

Comments

@ghaiat
Copy link

ghaiat commented Apr 5, 2017

Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[x] 3.0

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:
Since i ve upgraded to ionic 3, i get this error in my webpack build:

WARNING in /xxx/app/~/ionic-angular/util/ng-module-loader.js
54:11-36 Critical dependency: the request of a dependency is an expression
    at ImportContextDependency.getWarnings (/xxx/app/node_modules/webpack/lib/dependencies/ImportContextDependency.js:28:4)
    at Compilation.reportDependencyErrorsAndWarnings (/xxx/app/node_modules/webpack/lib/Compilation.js:668:24)
    at Compilation.finish (/xxx/app/node_modules/webpack/lib/Compilation.js:531:9)
    at /xxx/app/node_modules/webpack/lib/Compiler.js:486:16
    at /xxx/app/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/xxx/app/node_modules/webpack/lib/Compilation.js:477:11)
    at processModuleDependencies.err (/xxx/app/node_modules/webpack/lib/Compilation.js:448:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Any idea why ?

Cheers

@jgw96
Copy link
Contributor

jgw96 commented Apr 5, 2017

Hello! Thanks for opening an issue with us! As this seems like more of a support question i will urge that you ask this question on our forum or on our slack channel. Thanks for using Ionic!

@jgw96 jgw96 closed this as completed Apr 5, 2017
@marcoturi
Copy link

marcoturi commented Apr 11, 2017

I run to the same issue updating ionic2-boilerplate to ionic 3 during unit testing command. It looks similar to those issues
angular/angular#11580
webpack/webpack#196

I got:

WARNING in ./~/ionic-angular/util/ng-module-loader.js
54:11-36 Critical dependency: the request of a dependency is an expression

WARNING in ./~/ionic-angular/util/ng-module-loader.js
69:11-36 Critical dependency: the request of a dependency is an expression

@ghaiat Did you managed to resolve this issue ? Also could you provide a little more context about it?

@marcoturi
Copy link

marcoturi commented Apr 11, 2017

For anyone having this issue, the fix is to add in you webpack configuration:

 new ContextReplacementPlugin(
                /ionic-angular/,
                path.resolve('./src'),
                {}
            ),

@cryo243
Copy link

cryo243 commented Apr 12, 2017

And together with angular 4 warnings it becomes
new ContextReplacementPlugin( /(ionic-angular)|(angular(\\|\/)core(\\|\/)@angular)/, path.resolve('./src') , {} )

@maapteh
Copy link

maapteh commented Apr 15, 2017

Why is this issue closed? Since version 3 i also get these warnings

WARNING in ./~/ionic-angular/util/ng-module-loader.js
54:11-36 Critical dependency: the request of a dependency is an expression

WARNING in ./~/ionic-angular/util/ng-module-loader.js
69:11-36 Critical dependency: the request of a dependency is an expression

which basically says there is a dynamic import and dynamic imports should not be used.

Since im using angular/cli and not ionic/cli (i only like the framework for build i simply use cordova and angular cli running ng build --prod --base-href ./ --output-path www --output-hashing=none) . Can this issue be fixed on library side?

@schacki
Copy link

schacki commented May 3, 2017

@shanehughes3
Copy link

I'm getting this error when running karma/jasmine tests, and I don't have a webpack conf where I can add the aforementioned fix. The folks over at webpack seem to imply that this is an issue that shouldn't be suppressed, so shouldn't we be talking about a library fix?

@kamok
Copy link

kamok commented May 18, 2017

@jgw96 Can you please reopen? I'm getting the same issue as @shanehughes3. I also don't have a webpack config and I have the problem when running karma/jasmine tests. This surfaced after upgrading to ionic 3.1.1

@cryo243
Copy link

cryo243 commented May 18, 2017

I know this is not a final fix but both of you guys could have a different webpack config for your tests and implement the fix above(just so you can get rid of the warnings until ionic fixes it)' One issue is related to angular 4 the other one is from ionic native

@kamok
Copy link

kamok commented May 18, 2017

@cryo243 I can't find a webpack config in my app. I don't know where it is. Is it in the node_modules/angular folder?

@cryo243
Copy link

cryo243 commented May 18, 2017

@kamok if you are using karma/webpack to run your unit tests you should have created a webpack config.
in your karma.conf file you should have a webpack property that points to your custom webpack test file

@kamok
Copy link

kamok commented May 18, 2017

@cryo243 I use angular/cli. Same set up as this seeder project: https://github.com/lathonez/clicker

@cryo243
Copy link

cryo243 commented May 19, 2017

@kamok , that's because you are using angular cli together with karma. Angular cli uses webpack in the background but I'm not sure to what extent you can customize their Webpack config.
Rather use your own webpack config for unit tests and pass it to your karma.conf (you will need to install karma-webpack plugin though)
then in your karma.conf file replace
angularCli: { environment: 'dev' },
with
webpack: path/to/TestWebpackConfig,

@russcarver
Copy link

Can someone post the contents of just what such a "test" webpack config should look like?

@tinomen
Copy link

tinomen commented Sep 28, 2017

I get this warning twice. Is the current solution still to suppress them?

@jdnichollsc
Copy link

jdnichollsc commented Nov 3, 2017

@jgw96 Any news guys? thanks in advance, it's really neccesary without eject the webpack configuration of angular to fix the issue! 👍

WARNING in ./~/ionic-angular/util/ng-module-loader.js
54:11-36 Critical dependency: the request of a dependency is an expression

WARNING in ./~/ionic-angular/util/ng-module-loader.js
69:11-36 Critical dependency: the request of a dependency is an expression

@cryo243
Copy link

cryo243 commented Nov 3, 2017

Hi guys,
I thought I would create very basic example feel free to check https://github.com/cryo243/ionic-unit-tests

@jdnichollsc
Copy link

@jgw96 Justin, please reopen this issue. it's generated from the library because this is an incompatibility with the "ng serve" of the angular-cli.
Thanks guys in advance! ✌️

@jdnichollsc
Copy link

jdnichollsc commented Nov 23, 2017

@jgw96 @mlynch Any news about this item? it's very complicated? Any response from the Ionic team is really appreciated 🙏 (this would be like a Christmas gift)

@jdnichollsc
Copy link

Hi @danbucholtz, Is possible to create a new release of Ionic with the fix of the default webpack configuration with the following fix? https://github.com/ionic-team/ionic-unit-testing-example/pull/34/files
Thanks in advance guys!

@jdnichollsc
Copy link

Guys, what do you think about the following PR? ionic-team/ionic-app-scripts#1360

@damsorian
Copy link

this issue is not resolved ...

@jdnichollsc
Copy link

@damsorian I'm waiting for Ionic 4 due to this issue...

@edwinm
Copy link

edwinm commented Jul 2, 2018

July 2nd 2018 and still not resolved...

WARNING in ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
25:11-36 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/ionic-angular/es2015/util/ng-module-loader.js
 @ ./node_modules/ionic-angular/es2015/util/module-loader.js
 @ ./node_modules/ionic-angular/es2015/components/modal/modal-component.js
 @ ./node_modules/ionic-angular/es2015/index.js
 @ ./src/test.ts

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests