Open n-sviridenko opened 7 years ago
I get the same problem. @shlomiassaf, @n-sviridenko How do we tree shake the chunks to remove the common imports from Angular 2?
@n-sviridenko @jebuenga
This is a configuration related to the CommonsChunkPlugin
.
However, since I don't experience it and I don't have any special settings it might be related to the loader that you choose to implement.
I don't know the version you are using, so I will suggest you use the async-require loader:
{
loader: 'ng-router-loader',
options: {
loader: 'async-require',
genDir: 'compiled',
}
}
You can also use the async-import
which uses the new import()
syntax, but this requires the newest version and making the loader run after the ts loader.
See more here: https://shlomiassaf.github.io/ng-router-loader/interfaces/routerloaderoptions.html
Hello,
I have
AppModule
, few independent modules that are lazy-loaded andSharedModule
. Each module imports theSharedModule
.app.routing.ts
Before using this plugin, I did it this way:
With the plugin it's implemented this way:
It works perfect. But after I saw the difference between the chunk sizes:
without the plugin
with the plugin
By looking at the chunks I've found the same code of the
SharedModule
in all of them.Does somebody know how to resolve it?
Thanks