Skip to content

refactor: ensure tsurge migrations have clear ownership of files #61612

Closed
JeanMeche wants to merge 3 commits intoangular:19.2.xfrom
JeanMeche:patch-port-61421
Closed

refactor: ensure tsurge migrations have clear ownership of files #61612
JeanMeche wants to merge 3 commits intoangular:19.2.xfrom
JeanMeche:patch-port-61421

Conversation

@JeanMeche
Copy link
Copy Markdown
Member

This is a patch port of #61421

…ular#61421)

Currently there can be cases, exlusively in 3P, where multiple tsconfig
projects have overlap of source files. This is the default setup of new
CLI applications as well.

When this is the case, Tsurge will treat each tsconfig as an isolated
compilation unit (given the concepts and mental model to support
scalable batching). This is wrong though, and the same `.ts` source file
can appear in two migration invocations; resulting in duplicate
replacements or analysis (depending on the migration).

We've worked around this problem in the past by deduplicating
replacements, or migrating to an ID-based approach with natural
deduplication. This worked, but it's just working around the root cause.

This commit attempts to fix the root cause by adjusting Tsurge to ensure
that no source file ever appears in two compilation units. This is
naively achieved by not adding a source file to a migration unit, if it
was part of a previous one. This is expected to be fine given the nature
of Tsurge migrations that are built to operate on isolated pieces
anyway— so it shouldn't be problematic if e.g. `app.component.ts` ends
up being part of the test tsconfig compilation unit (we avoid this order
though by visiting build targets first).

PR Close angular#61421
…61421)

Since the duplication root-cause was solved by the previous commit, we
can revert/drop the logic that was added back then to overcome this
problem with Tsurge.

PR Close angular#61421
@JeanMeche JeanMeche marked this pull request as ready for review May 22, 2025 14:04
@JeanMeche JeanMeche added the target: patch This PR is targeted for the next patch release label May 22, 2025
@pullapprove pullapprove bot requested a review from kirjs May 22, 2025 14:04
@JeanMeche JeanMeche requested review from devversion and removed request for kirjs May 22, 2025 14:04
@devversion
Copy link
Copy Markdown
Member

Thanks @JeanMeche!

@JeanMeche JeanMeche added the action: merge The PR is ready for merge by the caretaker label May 22, 2025
@atscott
Copy link
Copy Markdown
Contributor

atscott commented May 22, 2025

This PR was merged into the repository by commit 2ae69f7.

The changes were merged into the following branches: 19.2.x

atscott pushed a commit that referenced this pull request May 22, 2025
) (#61612)

Currently there can be cases, exlusively in 3P, where multiple tsconfig
projects have overlap of source files. This is the default setup of new
CLI applications as well.

When this is the case, Tsurge will treat each tsconfig as an isolated
compilation unit (given the concepts and mental model to support
scalable batching). This is wrong though, and the same `.ts` source file
can appear in two migration invocations; resulting in duplicate
replacements or analysis (depending on the migration).

We've worked around this problem in the past by deduplicating
replacements, or migrating to an ID-based approach with natural
deduplication. This worked, but it's just working around the root cause.

This commit attempts to fix the root cause by adjusting Tsurge to ensure
that no source file ever appears in two compilation units. This is
naively achieved by not adding a source file to a migration unit, if it
was part of a previous one. This is expected to be fine given the nature
of Tsurge migrations that are built to operate on isolated pieces
anyway— so it shouldn't be problematic if e.g. `app.component.ts` ends
up being part of the test tsconfig compilation unit (we avoid this order
though by visiting build targets first).

PR Close #61421

PR Close #61612
atscott pushed a commit that referenced this pull request May 22, 2025
…61612)

Since the duplication root-cause was solved by the previous commit, we
can revert/drop the logic that was added back then to overcome this
problem with Tsurge.

PR Close #61421

PR Close #61612
atscott pushed a commit that referenced this pull request May 22, 2025
@atscott atscott closed this May 22, 2025
@JeanMeche JeanMeche deleted the patch-port-61421 branch June 2, 2025 20:12
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants