externalPackagesPlugin
slows down ng serve
substantially
#27116
Labels
angular/build:application
angular/build:dev-server
area: angular/build
freq1: low
Only reported by a handful of users who observe it rarely
severity4: memory/performance
type: bug/fix
Command
serve
Is this a regression?
externalPackagesPlugin
was just added via fix(@angular-devkit/build-angular): allow package file loader option with Vite prebundling #26923The previous version in which this bug was not present was
Before #26923 existed, which was part of 17.1.1, so I guess angular 17.1.0
Description
angular 17.2.0
vite/esbuild powered application builder
Using the
loader
option inangular.json
like:to support images as ecmascript imports or svgs as inline. This causes angular-cli to add the
externalPackagesPlugin
which is a giant hit on build performance. For our apps:{ "loader": { ".webp": "file" } }
0.8 seconds
{ "loader": { ".webp": "file" } }
6.0 seconds
{ "loader": { ".webp": "file" } }
6.0 seconds
Those additional 5.2 seconds are also added to the initial build.
My rough idea of the issue is, that the
externalPackagesPlugin
looks at every single import that doesn't start with.
or/
and doesn't cache the results. So tons of@angular/...
,rxjs
,@ngrx/...
and similar imports are resolved over and over again. Even if this function only needs 2ms to run, this quickly adds up.Minimal Reproduction
https://github.com/sod/ng-serve-external-deps-slowdown
The only difference between the
development
anddevelopment-slow
configurations in the angular.json are:Your Environment
The text was updated successfully, but these errors were encountered: