`externalPackagesPlugin` slows down `ng serve` substantially
@clydin 已经在做这个了。
开始于 2025年7月7日。
评估
这个 Issue 还没有评估数据。
描述
Command
serve
Is this a regression?
- Kinda, as the
externalPackagesPluginwas just added via https://github.com/angular/angular-cli/pull/26923
The previous version in which this bug was not present was
Before https://github.com/angular/angular-cli/pull/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 in angular.json like:
"loader": { ".webp": "file", ".svg": "text" },
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:
| angular version | watch rebuild time | note |
|---|---|---|
angular 17.1.0 { "loader": { ".webp": "file" } } |
0.8 seconds |
|
{ "loader": { ".webp": "file" } } |
6.0 seconds |
|
{ "loader": { ".webp": "file" } } |
6.0 seconds |
|
angular 19.2.1 { "loader": { ".webp": "file" } } |
0.8 seconds |
<- file doesn't regress anymore |
angular 19.2.1 { "loader": { ".svg": "text" } } |
6.0 seconds |
<- text still does |
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 and development-slow configurations in the angular.json are:
"development": {
},
"development-slow": {
"loader": {
".svg": "text"
}
},
Your Environment
@angular-devkit/architect 0.1702.0
@angular-devkit/build-angular 17.2.0
@angular-devkit/core 17.2.0
@angular-devkit/schematics 17.2.0
@angular/cli 17.2.0
@schematics/angular 17.2.0
rxjs 7.8.1
typescript 5.3.3
zone.js 0.14.4
- 主要语言
- TypeScript
- 星标
- 27k
- 派生
- 11.8k
- 平均合并
- 16 小时 35 分钟
- 30 天内合并 PR
- 176
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
angular/angular-cli 的其他 Issue
-
area: @angular/build gemini-triaged
难度 2/5 1-3 小时 新手友好度 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
难度 2/5 1-3 小时 新手友好度 72/100
angular/angular-cli#33055 · 1 条评论 · 3 个 reaction ·
-
area: @angular/build gemini-triaged
难度 4/5 3-5 天 新手友好度 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 已指派 1 人 ·
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
supermomonga/zcode-acp#24 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
growthbook/growthbook#7100 ·
-
triage
难度 1/5 1-3 小时 新手友好度 88/100