-
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
Build optimizer breaks third party libraries #12128
Comments
From @seanbright on May 14, 2018 21:39 I'm experiencing this as well with https://github.com/onsip/SIP.js as a dependency. Building with Angular CLI without the |
The issue with https://github.com/onsip/SIP.js was resolved by replacing their hand-rolled MD5 implementation with crypto-js: |
Hi, the problem with the above, is that a getter value is not being used and hence it is being dropped. If a library is non side effect free, the library author needs to specify this in their If the problem persists please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. |
That's wrong - it should be: "If a library is side effect free it may specify this in its Node module authors should not be forced to indicate that they are using valid ecmascript features. As an optimization, if they are not using a specific feature, they could indicate this to help tools that may optimize for this specific situation, but having to list valid features from the spec that you are using and assuming that they are not being used if they are not listed is just plain stupid and ignorant. It's still JavaScript in NPM, not AngularScript or GoogleScript. Feel free to make the build optimizer require AngularScript instead, but then clearly document this and tell the world that this is not a JavaScript tool, but an AngularScript tool which only works with AngularScript. |
When we first started using Build Optimizer, we saw a lot of the savings were tied to using the Uglify/Terser `pure_getters` option. This was intimately related with the structure and shape of the Angular codebase. The measurements we did at the time on angular.io showed a significant size reduction, from 1mb to about 600kb. Of these roughly 150kb were tied to using `pure_getters` if I remember correctly. Meanwhile the Angular codebase has changed significantly and I don't really see these savings anymore, so I don't think it makes sense to keep it on given that it is known to cause problems with some libraries. Closes angular#9231, angular#11439, angular#12096, angular#12128.
When we first started using Build Optimizer, we saw a lot of the savings were tied to using the Uglify/Terser `pure_getters` option. This was intimately related with the structure and shape of the Angular codebase. The measurements we did at the time on angular.io showed a significant size reduction, from 1mb to about 600kb. Of these roughly 150kb were tied to using `pure_getters` if I remember correctly. Meanwhile the Angular codebase has changed significantly and I don't really see these savings anymore, so I don't think it makes sense to keep it on given that it is known to cause problems with some libraries. Closes angular#9231, angular#11439, angular#12096, angular#12128.
When we first started using Build Optimizer, we saw a lot of the savings were tied to using the Uglify/Terser `pure_getters` option. This was intimately related with the structure and shape of the Angular codebase. The measurements we did at the time on angular.io showed a significant size reduction, from 1mb to about 600kb. Of these roughly 150kb were tied to using `pure_getters` if I remember correctly. Meanwhile the Angular codebase has changed significantly and I don't really see these savings anymore, so I don't think it makes sense to keep it on given that it is known to cause problems with some libraries. Closes #9231, #11439, #12096, #12128.
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. |
From @yGuy on April 3, 2018 11:56
Bug Report or Feature Request (mark with an
x
)Area
Versions
all
Repro steps
The log given by the failure
n/a
Desired functionality
It should be possible to either configure the build optimizer and disable possibly logic-breaking optimizations altogether or at least on a per dependency basis. Especially if the third party library is already optimized/minified/preprocessed the danger of breaking things is higher than the benefits of possibly saving a few more bytes.
Mention any other details that might be useful
Right now it is an either/or - either the code runs and you can rely on it, or it may be "optimized" but broken in some cases.
The tool-chain makes it easy to include all kind of packages from third parties via npm, etc. The "build-optimizer" cannot dictate how the code of all of these packages needs to be written in order to work with the "optimization" step. It's OK to forbid non-pure getters in the angular code base, but not in any third party code. Either add an option to only apply safe code transformations for third party code or make this an opt-in. The binary API right now is not sufficient.
Copied from original issue: angular/devkit#612
The text was updated successfully, but these errors were encountered: