返回提示词目录第 1183 页

规划并逐步升级 Angular 主版本

检查项目依赖与兼容要求,制定逐个主版本升级步骤,并安排迁移、测试和发布前验证。

完整提示词

<context>
Angular's update tooling is good, which is why the failures come from what surrounds it. What experienced people know: `ng update` is meant to move one major version at a time, running each version's automatic migrations; skipping versions skips migrations. Each major has a minimum Node.js and TypeScript range and an RxJS range, so the runtime may need to move first. Angular Material and the CDK update with their own `ng update` step, and some majors changed component internals and styling (the MDC-based components changed DOM and CSS, breaking custom overrides). The build system moved from the webpack-based browser builder to the esbuild-based application builder, which changes some behaviours (CommonJS warnings, global styles, environment file replacements). Third-party libraries pin peer dependencies to Angular majors; one unmaintained library can block the whole path, and libraries built for the old View Engine no longer work at all. Nx workspaces upgrade through Nx's own migrate command, not `ng update`. Using `--force` to get past peer conflicts hides exactly the problems you need to see.
</context>

<task>
Upgrade this Angular app to {{target_version}}.
{{#notes}}
Notes:
{{notes}}
{{/notes}}

1. Read `package.json`, `angular.json` (or Nx project config), the Node version used in development and CI, and the lockfile. List every Angular-ecosystem dependency and third-party library with an Angular peer dependency.
2. Build the upgrade path: each major from current to target, with the Node, TypeScript and RxJS range each needs. Use the official update guide for the from-to pair and note its manual steps.
3. Check blockers: for each third-party library, the version that supports each step, or that none exists. Propose replacements or forks for blockers and stop for a decision on any library with no path.
4. Record the baseline: build, unit tests, end-to-end tests and bundle sizes.
5. For each major step: run `ng update` for core and CLI, then Material and CDK and other libraries with schematics, review the migration diff, apply the guide's manual steps, fix build and test failures, and commit before the next step.
6. Handle builder changes deliberately: if moving to the application builder, check styles, assets, environment replacements, SSR and bundle output.
7. After the final step, run the full test suite and end-to-end tests, compare bundle sizes, and smoke test the main user flows.
</task>

<constraints>
- One major version per step, each committed separately; no skipping versions.
- Do not use `--force` or legacy peer dependency flags to get past conflicts without listing what they hide.
- Do not adopt new optional patterns (signals, standalone, new control flow) in the same change unless the user asks; keep the upgrade reviewable.
- Do not guess version requirements; read them from the official compatibility table or the packages' metadata.

{{> guardrails/verify-before-done}}
{{> guardrails/scope-discipline}}
</constraints>

<output_format>
## Starting point
Versions of Angular, Node, TypeScript, RxJS, key libraries; baseline results.
## Upgrade path
Table: step, Angular version, Node, TypeScript, RxJS, manual steps.
## Blockers
Libraries without support and the decision for each.
## Changes per step
What the migrations did, manual fixes, commit per step.
## Verification
Tests, end-to-end, bundle sizes, flows checked.
</output_format>

可替换内容

  • {{target_version}}
  • {{#notes}}
  • {{notes}}
  • {{/notes}}
  • {{> guardrails/verify-before-done}}
  • {{> guardrails/scope-discipline}}

分类与标签

编程开发、Angular升级、依赖兼容、代码迁移

前往 AI 图片创作