angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.98k forks source link

Introduce different levels for the `optimization` build option #15761

Open filipesilva opened 5 years ago

filipesilva commented 5 years ago

πŸš€ Feature request

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

Introduce different levels for the optimization build option.

Describe the solution you'd like

We should have a way to disable unsafe optimizations, such as pure_getters.

Describe alternatives you've considered

Either having several levels (e.g. true > 'safe-only' > false) or having a per-option switch on a object.

Related issues: https://github.com/angular/angular-cli/pull/14187 https://github.com/angular/angular-cli/pull/14287 https://github.com/angular/angular-cli/issues/14316 https://github.com/angular/angular-cli/pull/15607 https://github.com/angular/angular-cli/pull/15751 https://github.com/angular/angular-cli/issues/17255 https://github.com/angular/angular-cli/issues/17494

cloakedninjas commented 4 years ago

Also related: #11439

dgp1130 commented 4 years ago

Terser discussion of working around pure_getters: https://github.com/terser/terser/issues/464

laurentgoudet commented 4 years ago

Originally posted by @alan-agius4 in https://github.com/angular/angular-cli/issues/17517#issuecomment-617137013

This was one of the changes in version 9 where server production code is minified, one of the main reasons behind this is to speed up server cold starts and reduce deployment times. What I suggest is to generate sourcemaps and attach them, which will provide a better debug experience.

This is what I'm doing for Sentry, which works reasonably well (shipping the source maps to Sentry in CI), but I'm also shipping server-side logs to an ELK stack - with minified code those would show meaningless stack traces.

One way around could be to embed the source maps into the prod container & apply those on the error stack traces, but I'd rather not have that kind of logic running on errors, in order to ensure those are properly reported (and not swallowed), plus that'd defeat a bit the goal of reducing deployment times.

Not sure how others have solve these problems as the cold starts time & memory usage are indeed quite large (especially when running a 30+ locales app), but for the moment I'd still be interested by a proper way to turn off server-side code minification (a rollup pass or anything that does not make the code unreadable is fine though).

angular-robot[bot] commented 2 years ago

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] commented 2 years ago

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.