Title: Build optimizer breaks third party libraries · Issue #612 · angular/devkit · GitHub
Open Graph Title: Build optimizer breaks third party libraries · Issue #612 · angular/devkit
X Title: Build optimizer breaks third party libraries · Issue #612 · angular/devkit
Description: 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 project that uses code (e.g. a third p...
Open Graph Description: 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 ...
X Description: 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 Scaffo...
Opengraph URL: https://github.com/angular/devkit/issues/612
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Build optimizer breaks third party libraries","articleBody":"\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","author":{"url":"https://github.com/yGuy","@type":"Person","name":"yGuy"},"datePublished":"2018-04-03T11:56:27Z","url":"https://github.com/angular/devkit/issues/612"}
| 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:20f23327-38dc-6400-10b1-5b67e35a7cf5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA4A:311640:FCE3BA:1420418:6B0111EB |
| html-safe-nonce | 4890ec8ed514fc18988d8ce2a2349bd67ae3ab7f9260ee79dd32e3a1d448da50 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTRBOjMxMTY0MDpGQ0UzQkE6MTQyMDQxODo2QjAxMTFFQiIsInZpc2l0b3JfaWQiOiI1MzE2NjkyMjgzMjQ3MTA0NDkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 88d84fe7709966bbe16773f4a3c052b66b3b82ec3c6b9ed8f30e02e68559b463 |
| hovercard-subject-tag | issue:310805825 |
| 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/devkit/612/issue_layout |
| twitter:image | https://opengraph.githubassets.com/10aec9eb475e2031d4200ed7871f0a957612d9adfd591db7d0507b667f731c91/angular/devkit/issues/612 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/10aec9eb475e2031d4200ed7871f0a957612d9adfd591db7d0507b667f731c91/angular/devkit/issues/612 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yGuy |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/devkit git https://github.com/angular/devkit.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 88288940 |
| octolytics-dimension-repository_nwo | angular/devkit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 88288940 |
| octolytics-dimension-repository_network_root_nwo | angular/devkit |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width