-
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
NG_VALUE_ACCESSOR as a separate variable retains dead code in Angular CLI 11 #19572
Comments
The |
@clydin Thanks for the detailed response. I've inlined all value accessors, but it still retains more code then it should. So I guess there is more to it. I'll continue the investigation tomorrow and post and update here once I have more information. |
To fix dead code elimination using Angular 11. See angular/angular-cli#19572 (comment) for more details. The *inline* option was chosen as ng-bootstrap does not needs to export these accessors and they're only used by a single component. This option appears the simplest to me, it is less likely to regress in the future and should work independently of whether consumer users Angular CLI or custom tooling to build their application. At the cost of slightly worse code readability. Fixes ng-bootstrap#3904
To fix dead code elimination in Angular 11. See angular/angular-cli#19572 (comment) for more details. The *inline* option was chosen as ng-bootstrap does not needs to export these providers and they're only used by a single component. This option appears the simplest to me, it is less likely to regress in the future and should work independently of whether consumer users Angular CLI or custom tooling to build their application. At the cost of slightly worse code readability. Fixes ng-bootstrap#3904
That was just one more |
To fix dead code elimination in Angular 11. See angular/angular-cli#19572 (comment) for more details. The *inline* option was chosen as ng-bootstrap does not needs to export these providers and they're only used by a single component. This option appears the simplest to me, it is less likely to regress in the future and should work independently of whether consumer users Angular CLI or custom tooling to build their application. At the cost of slightly worse code readability. Fixes #3904
To fix dead code elimination in Angular 11. See angular/angular-cli#19572 (comment) for more details. The *inline* option was chosen as ng-bootstrap does not needs to export these providers and they're only used by a single component. This option appears the simplest to me, it is less likely to regress in the future and should work independently of whether consumer users Angular CLI or custom tooling to build their application. At the cost of slightly worse code readability. Fixes ng-bootstrap#3904
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?
Yes. It is not present in the fresh project generated with Angular CLI 10.
Description
While debugging a size regression in ng-bootstrap (ng-bootstrap/ng-bootstrap#3904 (comment)) when used in Angular 11 application I've spotted that a lot of dead code is retained because
NG_VALUE_ACCESSOR
is declared as a separate variable. Such pattern retains a linked component and consequently a lot of extra code used by this component. E.g. below code in the library will retainMylibComponent
using Angular CLI 11, but will be removed as dead code using Angular CLI 10:Observations:
ngcc
is identical, so I guess something in the application bundling has changed.🔬 Minimal Reproduction
Clone the reproductions for Angular 10 and 11 (fresh project + fresh lib + minimal code reproducing the problem, each in a separate commit):
Build each repro:
Check
dist/va10/main.js
anddist/va11/main.js
respectively. Observe that in v10 projectMylibComponent
symbol is not present in the bundle, but in v11 project this symbol is retained in the bundle together with the value accessor.🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: