Skip to content

fix(compiler-cli): avoid crash in isolated transform operations#59869

Closed
JoostK wants to merge 3 commits intoangular:mainfrom
JoostK:compiler/fix-isolated-transforms
Closed

fix(compiler-cli): avoid crash in isolated transform operations#59869
JoostK wants to merge 3 commits intoangular:mainfrom
JoostK:compiler/fix-isolated-transforms

Conversation

@JoostK
Copy link
Copy Markdown
Member

@JoostK JoostK commented Feb 6, 2025

The CLI uses the ts.transform API to apply the Angular compiler's transformers on the source files when isolatedModules is true (and various other constraints) instead of going through a full ts.Program.emit operation. This results in the transformers to operate in an environment where no emit resolver is available, which was not previously accounted for. This commit reflects the possibility for the emit resolver to be missing and handles this scenario accordingly.

Fixes #59837

@JoostK JoostK added the target: patch This PR is targeted for the next patch release label Feb 6, 2025
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Feb 6, 2025
@ngbot ngbot bot added this to the Backlog milestone Feb 6, 2025
@JoostK JoostK marked this pull request as ready for review February 6, 2025 20:09
@JoostK JoostK added the action: review The PR is still awaiting reviews from at least one requested reviewer label Feb 6, 2025
@JoostK JoostK requested a review from devversion February 6, 2025 20:09
@JoostK JoostK force-pushed the compiler/fix-isolated-transforms branch from dfb8554 to d934576 Compare February 6, 2025 20:12
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a risk meaning that sometimes we may not be able to properly preserve?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question; I'm not 100% certain. My reasoning for this change was that without an emit resolver, the set to build here would never be consumed. I should write a test specifically for this transformer to see if it behaves correctly.

@JoostK JoostK added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 6, 2025
@JoostK JoostK self-assigned this Feb 6, 2025
@JoostK JoostK added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Feb 6, 2025
The CLI uses the `ts.transform` API to apply the Angular compiler's transformers
on the source files when `isolatedModules` is true (and various other constraints)
instead of going through a full `ts.Program.emit` operation. This results in the
transformers to operate in an environment where no emit resolver is available, which
was not previously accounted for. This commit reflects the possibility for the emit
resolver to be missing and handles this scenario accordingly.

Fixes angular#59837
@JoostK JoostK force-pushed the compiler/fix-isolated-transforms branch from 3871a4f to 32cf5d7 Compare February 9, 2025 11:03
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 10, 2025
@thePunderWoman
Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit 973033a.

The changes were merged into the following branches: main, 19.1.x

thePunderWoman pushed a commit that referenced this pull request Feb 13, 2025
The CLI uses the `ts.transform` API to apply the Angular compiler's transformers
on the source files when `isolatedModules` is true (and various other constraints)
instead of going through a full `ts.Program.emit` operation. This results in the
transformers to operate in an environment where no emit resolver is available, which
was not previously accounted for. This commit reflects the possibility for the emit
resolver to be missing and handles this scenario accordingly.

Fixes #59837

PR Close #59869
@thePunderWoman thePunderWoman removed the action: presubmit The PR is in need of a google3 presubmit label Feb 13, 2025
@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 Mar 16, 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 area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng build fails after injecting Keycloak, but ng serve works fine

3 participants