-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Using @ngtools/webpack with ContextReplacementPlugin plugin does not create lazy routes chunks #4431
Comments
I checked this in my current project - comment out As i understand it's due to this new webpack.optimize.CommonsChunkPlugin({
name: [ 'main', 'vendor' ]
}), For repo above
With this configuration any shared (between AppModule and FeatureModule) modules will be added both to new webpack.optimize.CommonsChunkPlugin({
name: [ 'main' ]
}), then SharedModule includes properly, only to I'l add final test repo link today. |
Added repo where both issues can be reproduced App contains 3 modules
For proper work there should be 3 bundles in
ContextReplacementPlugin issueUncomment this https://github.com/artaommahe/webpack-aot/blob/master/webpack.config.js#L21 and after CommonsChunkPlugin issueRun build as it is and see that new webpack.optimize.CommonsChunkPlugin({
name: [ 'main' ]
}), and |
https://github.com/AngularClass/resolve-angular-routes may help. On second look, it seems ancient and unmaintained. |
the problem is still present on v1.2.11, but the comment trick still works |
experiencing the same problem. Would be nice if we could have the app and vendor chuncks work together with lazy loading. |
@artaommahe I believe I found something that could help. In v2 of webpack there are other options for the CommonsChunks plugin and splitting the vendor stuff out. This config seemed to split out the vendor dependencies out and the extra chunck worked properly containing only the lazy modules. Here it is:
taken from: https://webpack.js.org/guides/code-splitting-libraries/#implicit-common-vendor-chunk |
@danielRadiceski it's wrong assumption. In real app my vendor bundle contains common libs from |
@artaommahe you should be able to tweak the function to your requirements. (i.e to include also any files that are under |
Perhaps this should be a separate issue, will leave here for now. The plugin ( |
watching... |
I have the same problem with version 1.3.1. Any news on this? |
Having the same issue with version 1.3.1 now, during dev builds I have to use this plugin, otherwise getting
If I use this plugin also for PROD build, the So far I do not include ContextReplacementPlugin into my PROD build and it seems to work. |
Importing from now-closed duplicate #6518, please consider it happens also with these specs:
|
@GeorgeKnap Thanks for workaround but if I remove ContextReplacementPlugin I receive this error:
It does not output chunks. Exact ContextReplacementPlugin line is: ngtools 1.4.0-rc.2 (tried also with 131 and 133) |
For completeness, here are current ContextReplacementPlugin config: new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,,
'D:\path\to\my\source\root',
{}
), and CommonsChunkPlugin config: new webpack.optimize.CommonsChunkPlugin({
name: ['main', 'vendor'],
'js/[name]-bundle.js',
minChunks: mod => /node_modules/.test(mod.resource),
}), |
@sumitarora all in all, I must say I'm not sure the two issues are really duplicate. Others here are reporting that they cannot build when commenting out that replacement plugin, while I can. Also, we don't even know if they share the same steps (e.g. does build fail? Does opening page fail? Does browsing to lazy module fail?) and the same stacktrace. Just my 2c |
@artaommahe maybe I missed that in the thread, could you please state whether the error shows up at compile time, or runtime and doing what? Also, could you please show the error or stacktrace you see? This is to better understand if present issue and #6518 are really duplicate or not. Tnx |
@GiuseppePiscopo what error? my issues #4431 (comment) about completely missed lazy loaded chunks on build and duplicated shared modules in different chunks. It's about build time, not runtime. |
I see. So I guess you can browse to the app at runtime, then there should be some error in developer console when you try to access a lazy module URL, or maybe right away when app shows up, don't know. Could you please post the stacktrace in that case? Just to compare to what happens in #6518 . Thank you |
Closing as the provided configuration code show below is both unnecessary when used with the
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Ubuntu 16.04
Versions.
@ngtools/webpack - 1.2.7
Repro steps.
@ngtools/webpack
usage and app with lazy routes (e.g. this example repo https://github.com/daniele-zurico/webpack-aot)ContextReplacementPlugin
usage like sonpm run build
dist
folderContextReplacementPlugin
in plugins, build, chunks createdMention any other details that might be useful.
this check never passes with
ContextReplacementPlugin
usageangular-cli/packages/@ngtools/webpack/src/plugin.ts
Line 247 in 29b134d
@hansl
The text was updated successfully, but these errors were encountered: