Wrap classes with decorators or static properties in an IIFE, even for ES2015+#32011
Merged
sandersn merged 2 commits intomicrosoft:masterfrom Feb 15, 2020
Merged
Wrap classes with decorators or static properties in an IIFE, even for ES2015+#32011sandersn merged 2 commits intomicrosoft:masterfrom
sandersn merged 2 commits intomicrosoft:masterfrom
Conversation
52eb471 to
7b5cbf6
Compare
sandersn
requested changes
Feb 3, 2020
Contributor
Author
|
@sandersn Issue #15857 was only partially fixed by #16120. That PR only fixed the issue when the tsconfig target was ES5. It did not fix the issue when the target was ES2015 or higher. |
Contributor
|
For ES5, we were asked to mark the IIFE with a |
Contributor
Author
|
Good question. I think that makes sense considering that the IIFE represents the totality of the Typescript class definition. |
Currently only script targets less than or equal to ES5 will wrap classes. However, the wrapping is also crucial to file size optimizations for ES2015+ as well. Without the IIFE wrapper, minification tools do not elide the class. This is due to references to the class being present within the downlevelled decorator and static property code. This change represents the full completion of issue microsoft#15857
Contributor
Author
|
Updated to add the |
rbuckton
approved these changes
Feb 15, 2020
sandersn
approved these changes
Feb 15, 2020
5 tasks
clydin
pushed a commit
to angular/angular-cli
that referenced
this pull request
May 11, 2020
With this change we "vendor" TypeScript 3.6 in build optimizer instead of using directly the npm package. Reasons: - We cannot update to a more recent version of TypeScript due to microsoft/TypeScript#38412 - Yarn workspace are not supported under Bazel. This means currently we are running unit testswhich uses a different TypeScript version at runtime. - In TypeScript 3.9, the shape of ES2015 classes changed microsoft/TypeScript#32011, this requires some changes in the UT expects, but this again will not be correct to change now.
IgorMinar
added a commit
to IgorMinar/angular
that referenced
this pull request
May 21, 2020
As of TypeScript 3.9, the tsc emit is not compatible with Closure Compiler due to microsoft/TypeScript#32011. There is some hope that this will be fixed by a solution like the one proposed in microsoft/TypeScript#38374 but currently it's unclear if / when that will happen. Since the Closure support has been somewhat already broken, and the tsickle pass has been a source of headaches for some time for Angular packages, we are removing it for now while we rethink our strategy to make Angular Closure compatible outside of Google. This change has no effect on our Closure compatibility within Google which work well because all the code is compiled from sources and passed through tsickle. This change only disables the tsickle pass but doesn't remove it. A follow up PR should either remove all the traces of tscikle or re-enable the fixed version. BREAKING CHANGE: Angular npm packages no longer contain jsdoc comments to support Closure Compiler's advanced optimizations The support for Closure compiler in Angular packages has been experimental and broken for quite some time. As of TS3.9 Closure is unusable with the JavaScript emit. Please follow microsoft/TypeScript#38374 for more information and updates. If you used Closure compiler with Angular in the past, you will likely be better off consuming Angular packages built from sources directly rather than consuming the version we publish on npm which is primarily optimized for Webpack/Rollup + Terser build pipeline. As a temporary workaround you might consider using your current build pipeline with Closure flag `--compilation_level=SIMPLE`. This flag will ensure that your build pipeline produces buildable and runnable artifacts, at the cost of increased payload size due to advanced optimizations being disabled. If you were affected by this change, please help us understand your needs by leaving a comment on angular#37234.
kara
pushed a commit
to angular/angular
that referenced
this pull request
May 21, 2020
As of TypeScript 3.9, the tsc emit is not compatible with Closure Compiler due to microsoft/TypeScript#32011. There is some hope that this will be fixed by a solution like the one proposed in microsoft/TypeScript#38374 but currently it's unclear if / when that will happen. Since the Closure support has been somewhat already broken, and the tsickle pass has been a source of headaches for some time for Angular packages, we are removing it for now while we rethink our strategy to make Angular Closure compatible outside of Google. This change has no effect on our Closure compatibility within Google which work well because all the code is compiled from sources and passed through tsickle. This change only disables the tsickle pass but doesn't remove it. A follow up PR should either remove all the traces of tscikle or re-enable the fixed version. BREAKING CHANGE: Angular npm packages no longer contain jsdoc comments to support Closure Compiler's advanced optimizations The support for Closure compiler in Angular packages has been experimental and broken for quite some time. As of TS3.9 Closure is unusable with the JavaScript emit. Please follow microsoft/TypeScript#38374 for more information and updates. If you used Closure compiler with Angular in the past, you will likely be better off consuming Angular packages built from sources directly rather than consuming the version we publish on npm which is primarily optimized for Webpack/Rollup + Terser build pipeline. As a temporary workaround you might consider using your current build pipeline with Closure flag `--compilation_level=SIMPLE`. This flag will ensure that your build pipeline produces buildable and runnable artifacts, at the cost of increased payload size due to advanced optimizations being disabled. If you were affected by this change, please help us understand your needs by leaving a comment on #37234. PR Close #37221
cangSDARM
added a commit
to cangSDARM/TypeScript
that referenced
this pull request
May 26, 2020
* upstream/master: LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. Fix relation between generic mapped types and types with index signatures (microsoft#38761) LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. LEGO: check in for master to temporary branch. Revert "Wrap classes with decorators or static properties in an IIFE, even for ES2015+ (microsoft#32011)" Preserve module marker in es2015+ module emit for tool compatability (microsoft#38712) Fix recently added test so it is cross-plat fix(33286): add outlining for arrow function with one parameter (microsoft#38631) fix(38463): show completions for index access properties
profanis
pushed a commit
to profanis/angular
that referenced
this pull request
Sep 5, 2020
…37221) As of TypeScript 3.9, the tsc emit is not compatible with Closure Compiler due to microsoft/TypeScript#32011. There is some hope that this will be fixed by a solution like the one proposed in microsoft/TypeScript#38374 but currently it's unclear if / when that will happen. Since the Closure support has been somewhat already broken, and the tsickle pass has been a source of headaches for some time for Angular packages, we are removing it for now while we rethink our strategy to make Angular Closure compatible outside of Google. This change has no effect on our Closure compatibility within Google which work well because all the code is compiled from sources and passed through tsickle. This change only disables the tsickle pass but doesn't remove it. A follow up PR should either remove all the traces of tscikle or re-enable the fixed version. BREAKING CHANGE: Angular npm packages no longer contain jsdoc comments to support Closure Compiler's advanced optimizations The support for Closure compiler in Angular packages has been experimental and broken for quite some time. As of TS3.9 Closure is unusable with the JavaScript emit. Please follow microsoft/TypeScript#38374 for more information and updates. If you used Closure compiler with Angular in the past, you will likely be better off consuming Angular packages built from sources directly rather than consuming the version we publish on npm which is primarily optimized for Webpack/Rollup + Terser build pipeline. As a temporary workaround you might consider using your current build pipeline with Closure flag `--compilation_level=SIMPLE`. This flag will ensure that your build pipeline produces buildable and runnable artifacts, at the cost of increased payload size due to advanced optimizations being disabled. If you were affected by this change, please help us understand your needs by leaving a comment on angular#37234. PR Close angular#37221
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently only script targets less than or equal to ES5 will wrap classes with decorators and/or static properties. However, the wrapping is also crucial to file size optimizations for ES2015+ as well. Without the IIFE wrapper, minification tools do not elide the class. This is due to references to the class being present within the downlevelled decorator and static property code.
This change represents the full completion of issue #15857