Issue
I've just migrated an app from Angular 11.2.7 to Angular 12. Everything runs fine, except that when I am developing and using 'ng serve', rebuild times are much, much slower now, to the point where it's frustrating.
I'm on an M1 iMac, using node 16.1.0, for what it's worth.
The machine was lightning fast at dev rebuilds (sub-second) before I moved to Angular 12. Now if I change just one line of code, even if I just change one letter in a console log, build times are 23 seconds, roughly 22 seconds of which are taken up with "phase: sealing".
I've also noticed that everything now runs from a minified 'main.js" even when ng serving. I seem to recall version 11 didn't do that, but ran individual un-minified components during dev. Which is to say, ng serve now seems to be doing something like full a production build every time I change anything. I think that's the root cause of the slowness, but I'm not sure.
So . . .
Should I still be using 'ng serve' for development in Angular 12?
Is there an option that needs to be set when you migrate, perhaps to turn off full minified rebuilds, to maintain the old build speed?
What is this 'sealing phase', anyway? It sounds like a production build term to me!
thanks
John
Solution
The angular cli got updated with v12 to have the development environment be more like production.
Or as they like to call it:
The aim of these changes is to reduce the configuration complexity and support the new "production builds by default" initiative.
Judging by what they've changed, you should update your angular.json
and update the projects.{PROJECT_NAME}.architect.build.defaultConfiguration
path:
"defaultConfiguration": "development"
Read more here
If you did not use the ng update
command, but manually updated using npm
, you need to run migrations. Specifically the material styling had some changes which can cause long build times if not migrated. To trigger these migrations run:
ng update @angular/cli --migrate-only --from 11 --to 12
Answered By - Poul Kruijt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.