-
Notifications
You must be signed in to change notification settings - Fork 12k
externalPackagesPlugin
slows down ng serve
substantially
#27116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
…using custom loader loaders in esbuild aren't really custom code. You can only choose from the loaders that esbuild provides. So I doubt they require this `externalPackagesPlugin` which comes at a pretty steep cost of 1 second per 1500 imports your project has on every build and watch rebuild. fixes angular#27116
We still patch angular for this 😅 The |
I tested this with Angular version 19.2, and the timings appear to be quite consistent.
|
Thx for checking! 🙏 The slowness is still there as the problematic plugin ( I now made this angular.json change: "development": {
},
"development-slow": {
"loader": {
+ ".inline.svg": "text", // <- text will load createExternalPackagesPlugin
".webp": "file" // <- file alone wouldn't load createExternalPackagesPlugin
}
}, In our project, vite and build work fine without |
I now pushed a commit with working assets for And you'll see that both serve: I guess the trick why we don't need the
This is the commit sod/ng-serve-external-deps-slowdown@608ffbc that adds the working assets to the reproduction |
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
angular 17.1.1{ "loader": { ".webp": "file" } }
6.0 seconds
angular 17.2.0{ "loader": { ".webp": "file" } }
6.0 seconds
{ "loader": { ".webp": "file" } }
0.8 seconds
file
doesn't regress anymore{ "loader": { ".svg": "text" } }
6.0 seconds
text
still doesThose 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: