Title: Build optimizer breaks third party libraries · Issue #12128 · angular/angular-cli · GitHub
Open Graph Title: Build optimizer breaks third party libraries · Issue #12128 · angular/angular-cli
X Title: Build optimizer breaks third party libraries · Issue #12128 · angular/angular-cli
Description: From @yGuy on April 3, 2018 11:56 Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Area - [x] devkit - [ ] schematics Versions all Repro steps Scaffold a proj...
Open Graph Description: From @yGuy on April 3, 2018 11:56 Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Area - [x] devkit - [ ] schematics ...
X Description: From @yGuy on April 3, 2018 11:56 Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Area - [x] devkit - [ ] schemati...
Opengraph URL: https://github.com/angular/angular-cli/issues/12128
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Build optimizer breaks third party libraries","articleBody":"_From @yGuy on April 3, 2018 11:56_\n\n\u003c!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION YOUR ISSUE MIGHT BE CLOSED WITHOUT INVESTIGATING\r\n-->\r\n### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [x] bug report -> please search issues before submitting\r\n- [ ] feature request\r\n```\r\n\r\n### Area\r\n```\r\n- [x] devkit\r\n- [ ] schematics\r\n```\r\n\r\n### Versions\r\n\u003c!--\r\nOutput from: `node --version` and `npm --version`.\r\n Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra? High Sierra?)\r\n-->\r\nall\r\n\r\n### Repro steps\r\n - Scaffold a project that uses code (e.g. a third party library) that contains code that cannot be properly \"optimized\" using uglifyjs. E.g. code that uses \"non-pure getters\" like this:\r\n```\r\nlet object = {};\r\nObject.defineProperty(object,\"nonSideEffectFreeGetterBasedMember\", \r\n {get: function(){ console.log(\"side effect\")}});\r\n\r\n(function () {\r\n object.nonSideEffectFreeGetterBasedMember;\r\n}());\r\n``` \r\n- Enable the angular build optimizer\r\n- Run the program with the build optimizer enabled and observe that the code does not work as expected anymore, because the non-pure getter has been removed and the side-effect does not happen anymore.\r\n\r\n### The log given by the failure\r\n\u003c!-- Normally this include a stack trace and some more information. -->\r\nn/a\r\n\r\n### Desired functionality\r\n\u003c!--\r\nWhat would like to see implemented?\r\nWhat is the usecase?\r\n-->\r\nIt 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.\r\n\r\n### Mention any other details that might be useful\r\n\u003c!-- Please include a link to the repo if this is related to an OSS project. -->\r\nRight 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. \r\n\r\nThe 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.\r\n\n\n_Copied from original issue: angular/devkit#612_","author":{"url":"https://github.com/alexeagle","@type":"Person","name":"alexeagle"},"datePublished":"2018-09-04T23:22:01Z","url":"https://github.com/angular/angular-cli/issues/12128"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:28fca511-6991-6967-404f-7c3ce78c5737 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8A8:20AA01:14514D2:19EC58F:6B011693 |
| html-safe-nonce | 9fdb1524120fc55f1a7a07a4cab03a40ea2050e7cef3a2b8674829e15407b47a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEE4OjIwQUEwMToxNDUxNEQyOjE5RUM1OEY6NkIwMTE2OTMiLCJ2aXNpdG9yX2lkIjoiODYxOTU3MDkwMzIyNDc1MTc2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4cb70f7851ede66934966c5987c7511a96886cc1f7e222530aad2a30e6091922 |
| hovercard-subject-tag | issue:357010814 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/12128/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ce6c031b990ab2c6c738e9f0a63d590e35dbc9526debdf32a68e968f7dd84044/angular/angular-cli/issues/12128 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ce6c031b990ab2c6c738e9f0a63d590e35dbc9526debdf32a68e968f7dd84044/angular/angular-cli/issues/12128 |
| og:image:alt | From @yGuy on April 3, 2018 11:56 Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Area - [x] devkit - [ ] schematics ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexeagle |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width