Skip to content

fix(@angular/build): set es2016 target for Rolldown prebundling in Zone.js apps - #33772

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-vite-rolldown-zonejs-target
Aug 5, 2026
Merged

fix(@angular/build): set es2016 target for Rolldown prebundling in Zone.js apps#33772
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-vite-rolldown-zonejs-target

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Rolldown dependency prebundling in Vite dev server was not receiving target options, leaving native async/await intact in prebundled dependencies (such as @angular/common/http's FetchBackend). When an application uses Zone.js, native async/await causes Zone.js context loss across native await ticks.

This PR passes target to rolldownOptions.transform.target during dependency optimization. For non-zoneless applications (apps using Zone.js), target is set to ['es2016'] to downlevel native async/await in prebundled dependencies.

Fixes #33770

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Vite dev-server builder to pass the target option to Rolldown's dependency optimization configuration. Specifically, it avoids Rolldown initialization errors by replacing the target array with ['es2016'] for applications using Zone.js, rather than appending to it. The target is now correctly propagated through getDepOptimizationConfig and a new unit test has been added to verify this behavior. I have no feedback to provide as there are no review comments.

@alan-agius4
alan-agius4 force-pushed the fix-vite-rolldown-zonejs-target branch 2 times, most recently from edd81a2 to a88115f Compare August 5, 2026 12:43
@alan-agius4
alan-agius4 marked this pull request as draft August 5, 2026 12:43
@alan-agius4
alan-agius4 force-pushed the fix-vite-rolldown-zonejs-target branch from a88115f to e6841cd Compare August 5, 2026 13:05
@alan-agius4

alan-agius4 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Workaround for rolldown/rolldown#10633

@alan-agius4
alan-agius4 force-pushed the fix-vite-rolldown-zonejs-target branch from e6841cd to 0cc1b63 Compare August 5, 2026 13:19
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release and removed state: blocked on upstream labels Aug 5, 2026
@alan-agius4
alan-agius4 requested a review from clydin August 5, 2026 13:20
@alan-agius4
alan-agius4 marked this pull request as ready for review August 5, 2026 13:20

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements a workaround for a Rolldown issue by explicitly setting the compilation target to ['es2022'] for zoneless applications and ['es2016'] otherwise. This target is then propagated through the Vite dev-server configuration to getDepOptimizationConfig. The only feedback is to correct a minor typo in the workaround comment.

Comment thread packages/angular/build/src/builders/dev-server/vite/index.ts Outdated
@alan-agius4
alan-agius4 force-pushed the fix-vite-rolldown-zonejs-target branch from 0cc1b63 to 2af78cb Compare August 5, 2026 13:23
…n Vite dev server

Rolldown dependency prebundling in Vite dev server did not receive target options, leaving native async/await in prebundled dependencies. When an application uses Zone.js, native async/await causes Zone.js context loss across await ticks.

Additionally, passed target options are set as a single target string array as a temporary workaround for Rolldown issue angular#10633 (where multiple browser targets cause initialization errors).

Fixes angular#33770
@alan-agius4
alan-agius4 force-pushed the fix-vite-rolldown-zonejs-target branch from 2af78cb to 3d3c113 Compare August 5, 2026 13:27
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 5, 2026
@alan-agius4
alan-agius4 merged commit 3e9fed9 into angular:main Aug 5, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-vite-rolldown-zonejs-target branch August 5, 2026 15:29
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev-server: Vite-prebundled dependencies keep native async/await, so every HttpClient response resumes outside the Angular zone

2 participants