Repository navigation
fix(@angular/cli): skip components with a change detection strategy in the zoneless migration tool - #34167
Conversation
There was a problem hiding this comment.
Code Review
This pull request corrects the property name in the regular expression used to detect existing change detection strategies (from changeDetectionStrategy to changeDetection) and ensures that components already migrated are still analyzed for incompatible NgZone usage. It also introduces a comprehensive suite of unit tests. Feedback was provided to make the regular expression more robust by allowing optional whitespace before the colon, preventing unnecessary LLM sampling round-trips for differently formatted codebases.
…n the zoneless migration tool The pre-filter in the onpush_zoneless_migration MCP tool looked for a `changeDetectionStrategy:` property, but the @component metadata key is `changeDetection`, so it never matched. Every component was queued for migration, and with more than one the tool sent a sampling request to rank files that migrateSingleFile then skipped anyway. Components that are skipped but import NgZone are still analyzed for unsupported zone usages, so the tool keeps reporting those blockers.
dd0389f to
2014d2c
Compare
alan-agius4
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
What is the current behavior?
Issue Number: N/A
categorizeFilein theonpush_zoneless_migrationMCP tool is meant to skip components that already declare a change detection strategy (it logs "Component file already has change detection strategy ... Skipping migration."). Its pre-filter regex looks forchangeDetectionStrategy:, but the@Componentmetadata key ischangeDetection(the AST check inmigrate-single-file.tsalready useschangeDetection). The regex never matches, so that branch is dead: every component goes intofilesWithComponents, and when there is more than one the tool sends asampling/createMessagerequest to the client to rank files thatmigrateSingleFilethen drops by returningnull. The final answer is right, but it costs a sampling round-trip, which some clients ask the user to approve.What is the new behavior?
changeDetection:, so already-migrated components are skipped and no ranking request is sent for them.NgZoneis still added tozoneFiles. Today those components reachanalyzeForUnsupportedZoneUsesthroughmigrateSingleFile; without this, fixing the regex would have stopped the tool reporting NgZone blockers in OnPush components.New
zoneless-migration_spec.ts(first spec for this entry point) covers:NgZone.onMicrotaskEmpty: the unsupported NgZone response is still returned (fails if thezoneFilesrouting is removed).pnpm bazel test //packages/angular/cli:testpasses (272 specs).Does this PR introduce a breaking change?
Other information
Prepared with AI assistance (Claude Code), and reviewed with GitHub Copilot, which caught the NgZone case above. I checked each test fails without the change it covers.