-
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
fix(@angular-devkit/build-optimizer): increase safety of code removal #19049
Conversation
d381593
to
9722bd1
Compare
getTransforms.push( | ||
// getPrefixFunctionsTransformer is rather dangerous, apply only to known pure es5 modules. | ||
// It will mark both `require()` calls and `console.log(stuff)` as pure. | ||
// We only apply it to modules known to be side effect free, since we know they are safe. | ||
// getPrefixFunctionsTransformer needs to be before getFoldFileTransformer. | ||
getPrefixFunctionsTransformer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know for which cases the prefix function transformer is needed in Angular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View Engine factory files need it and were already included in the safe side effect check.
Additionally, there are a variety call/new expressions in @angular/*
involving the following:
[
"ComponentFactoryResolver$1",
"InjectionToken",
"KeyRegistry",
"Optional",
"ObservableStrategy",
"PromiseStrategy",
"ReflectionCapabilities",
"Reflector",
"Version",
"core_merge",
"getClosureSafeProperty",
"makeDecorator",
"makeParamDecorator",
"makePropDecorator",
"tagSet",
"tokenKey",
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 questions mainly.
And from the code changes, I am confident that this change also fixes #18621
This change lowers the potential for code to be errantly removed by the prefix functions and scrub file transformers. Only known safe modules are used with the prefix functions transformer as it can easily remove required module level side effects (as opposed to global level side effects) such as `__decorate` calls. The scrub file transformer will now keep metadata if non-Angular decorators are present. This allows libraries that use that information to continue to function. Closes angular#14033 Closes angular#18621
… tests The experimental Webpack Rollup pass no longer produces smaller sizes than the standard production build.
9722bd1
to
6bfa224
Compare
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. |
This change lowers the potential for code to be errantly removed by the prefix functions and scrub file transformers. Only known safe modules are used with the prefix functions transformer as it can easily remove required module level side effects (as opposed to global level side effects) such as
__decorate
calls.The scrub file transformer will now keep parameter metadata if non-Angular decorators are present. This allows libraries that use that information to continue to function.
Closes #14033
Closes #18621