-
Notifications
You must be signed in to change notification settings - Fork 12k
Javascript that should be in lazy loaded chunk is in the main chunk #19527
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
Comments
Duplicate of angular/angular#37576 (comment) |
@alan-agius4 Elaborating the example we gave in that comment, assume we have shared.js export function foo() { }
export function bar() { }
export function buz() { } lib.js import { foo, buz } from './shared';
export function faa() { }
export function ber() { foo(); buz() } main.js import { faa } from './lib';
faa(); lazy.js import { bar, buz } from './shared';
bar();
buz(); In this case, will the shared.js also be imported in the main chunk? Because this is exactly my use case. |
Yeah indeed that is the case. |
You can use the |
@alan-agius4 My use case is that I am using So, I am going to open an issue in the angular/material repository asking for spliting the For now, I am going to stop using Thanks for your attention. |
Creating a new The unused dependency on An alternatively to this would be to have different entry-point or using ESM bundles instead of FESM (#13635). |
But as you can see in my repository reproduction, |
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. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
I am not sure
Description
If we create a new app with
Router
generated byng new
, add@angular/material
to the project and we importMatListModule
into the mainNgModule
without using it,@angular/forms
will not be in the main bundle. If we add a lazy loaded route, and in that NgModule we importMatInputModule
, use MatInput in the lazy component and removeMatListModule
from the main module, than the@angular/forms
goes into the bundle of the lazy loaded module. Everything works great so far. Now, importMatListModule
again in the main NgModule. The@angular/forms
now goes to the main bundle.🔬 Minimal Reproduction
git clone https://github.com/csbenjamin/issue-with-tree-shake cd issue-with-tree-shake npm install ng buil --prod
you will see that
@angular/forms
goes to the main bundle, and it shouldn't.🌍 Your Environment
The text was updated successfully, but these errors were encountered: