-
Notifications
You must be signed in to change notification settings - Fork 12
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
Lazy loading chunks not emitted when using DllBundlesPlugin #21
Comments
What do you mean by not emitted as chunks? They are part of the bundle? FYI this plugin is not to be used in a production build. |
They are neither admitted as a "0.chunk.js" nor are they a part of the bundle so it just doesnt work at all. But it appears that the issue is due to How come this plugin shouldn't be used in a production build, and what do you recommend to use for production DLLs build instead? |
This plugin creates a webpack bundle that represent the output after all loaders/plugins did their thing. Webpack then consumes the bundle and every require/import that is known to exists in the bundle is taken from there without running it through the loader/plugin chain. So it's like a cache thing, creating pre-built bundle that can be used by webpack. In theory you can use this in production but it does not make sense, in production you have other webpack tools built for that purpose, e.g. CommonChunksPlugin and more... Remember that webpack treats the DLL as a fully built bundle so it will not run minification on it and other stuff when doing prod build. |
@shlomiassaf The way I use DLLS in production is for Angular and RxJS. Since I have no benefit to recompile them every time i load webpack dev server or do a production build, I pre-build all angular and rxjs using DLLS and I do so with uglifyjs, so basically the dlls are always in "production" mode even when used for Dev, QA, Production etc. I don't see in which way CommonChunksPlugin would help with this use case? basically to save time on rebuilding. |
It make a huge difference. If we take RXJS, the plugin will include the whole package. Regardless of the operators you use. Furthermore if we take angular, the plugin will create a bundle with the compiler code included, a prod build will omit it via the CommonChunksPlugin and UglifyJS plugin since that code is not being used... |
@IAMtheIAM you were using AOT huh? I just figured out, through great sacrifice, that the @ngtools/webpack AOT plugin(which is now the standard way of doing AOT) is not compatible with the DLL plugin, which this plugin wraps. Rather than throw some error or a clean behavior, angular just fails to emit the lazy bundles. This is not mentioned in any Angular docs. angular/angular-cli#4431 |
Yea, recently though, I just stopped using DLL bundles plugin, because it really doesn't make sense now that I compared. It does not allow for minification or code shaking and @shlomiassaf said. It is much better to use CommonsChunkPlugin and UglifyJsPlugin properly. Use with Doing this I reduced my angular total bundles size from 7MB down to 2MB. Major improvement. Here is my loader for TS files, example:
plugins
With |
When using this plugin, it will not emit lazy loaded modules as chunks. When I disable this plugin in the webpack config
plugins: []
array, then immediately my lazy loaded modules are emitted as chunks. When I re-enable this plugin, the chunks do not get emitted.plugin config
App routes
The text was updated successfully, but these errors were encountered: