You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 11升级至16后构建耗时过长,寻求排查方案

问题:Angular 16项目使用本地库时构建速度极慢

原基于Angular 11的项目已升级至Angular 16,项目包含3个本地库,库自身构建速度正常,但在Angular应用中引入这些库后,构建耗时长达数小时。

当前使用的tsconfig配置如下:

{
  "compileOnSave": false,
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "alwaysStrict": true,
    "noImplicitAny": true,
    "noPropertyAccessFromIndexSignature": false, 
    "noUnusedLocals": true,
    "strictNullChecks": false, 
    "strictPropertyInitialization": false, 
    "exactOptionalPropertyTypes": false, 
    "noImplicitThis": true,
    "strictBindCallApply": true,
    "strictFunctionTypes": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "useUnknownInCatchVariables": true,
    "allowUnusedLabels": false,
    "allowUnreachableCode": false,

    "skipLibCheck": true,

    "baseUrl": "./",
    "outDir": "./dist/out-tsc",

    "allowSyntheticDefaultImports": true,

    "target": "ES2022",
    "module": "ES2022",
    "useDefineForClassFields": false,
    "lib": [ "ES2022", "dom" ],

    "paths": {
      "local/*": [ "./src/app/*" ]
    }

  },
  "angularCompilerOptions": {
    "compilationMode": "full",
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableI18nLegacyMessageIdFormat": false,
    "strictInputAccessModifiers": true,
    "strictTemplates": true,
    "enableIvy": true
  }
}

已尝试执行ng build --verbose命令排查构建慢的原因,但未得到有效信息。构建完成后出现以下提示:

√ Browser application bundle generation complete.
[webpack.cache.PackFileCacheStrategy] Pack got invalid because of write to: ResolverCachePlugin|normal|default|dependencyType=|esm|path=|C:\ProjetosGIT\SA\NgSaClient|request=|C:\ProjetosGIT\SA\NgSa\src\styles.scss?ngGlobalStyle

请问是否有其他命令或配置可以查看具体哪些文件编译耗时?附CPU性能分析截图:
CPU性能分析截图1
CPU性能分析截图2

内容的提问来源于stack exchange,提问作者Luiz Bicalho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 05:07:24