-
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
ClassExpression in ES2015 builds produces larger bundles #14577
Comments
alan-agius4
changed the title
CallExpressions in ES2015 builds produces larger bundles
ClassExpression in ES2015 builds produces larger bundles
May 30, 2019
This was referenced May 31, 2019
HI @alan-agius4 , Any update in this? |
alexeagle
pushed a commit
that referenced
this issue
Jun 6, 2019
…or better tree-shaking ClassExpressions such as the below are not treeshakable unless we wrap them in an IIFE ```js let AggregateColumnDirective = class AggregateColumnDirective { constructor(viewContainerRef) { } }; AggregateColumnDirective = __decorate([ Directive({}), __metadata("design:paramtypes", [ViewContainerRef]) ], AggregateColumnDirective); ``` With this change we wrap the above in an IIFE and mark it as a PURE function. ```js const AggregateColumnDirective = /*@__PURE__*/ (() => { let AggregateColumnDirective = class AggregateColumnDirective { constructor(viewContainerRef) { } }; AggregateColumnDirective = __decorate([ Directive({}), __metadata("design:paramtypes", [ViewContainerRef]) ], AggregateColumnDirective); return AggregateColumnDirective; })(); ``` With this pattern if the class is unused it will be dropped. Note: In future we should rename `wrap-enums` to something more generic, and combine class-fold with this transformer especially considering the future fix that needs to be done for #14610 Fixes #14577
alexeagle
pushed a commit
that referenced
this issue
Jun 6, 2019
…or better tree-shaking ClassExpressions such as the below are not treeshakable unless we wrap them in an IIFE ```js let AggregateColumnDirective = class AggregateColumnDirective { constructor(viewContainerRef) { } }; AggregateColumnDirective = __decorate([ Directive({}), __metadata("design:paramtypes", [ViewContainerRef]) ], AggregateColumnDirective); ``` With this change we wrap the above in an IIFE and mark it as a PURE function. ```js const AggregateColumnDirective = /*@__PURE__*/ (() => { let AggregateColumnDirective = class AggregateColumnDirective { constructor(viewContainerRef) { } }; AggregateColumnDirective = __decorate([ Directive({}), __metadata("design:paramtypes", [ViewContainerRef]) ], AggregateColumnDirective); return AggregateColumnDirective; })(); ``` With this pattern if the class is unused it will be dropped. Note: In future we should rename `wrap-enums` to something more generic, and combine class-fold with this transformer especially considering the future fix that needs to be done for #14610 Fixes #14577
HI @alan-agius4 Which version of the angular-build-optimizer package do I need to update? |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
🐞 Bug report
Command (mark with an
x
)Is this a regression?
No, but now it effects more users as differential loading is on by default.
Description
TypeScript ClassExpression are not being treeshaken away.
Example codes:
🌍 Your Environment
Anything else relevant?
#14263
The text was updated successfully, but these errors were encountered: