Skip to content

Commit a88115f

Browse files
committed
fix(@angular/build): set es2016 target for Rolldown prebundling in Zone.js apps
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. Fixes #33770
1 parent fffec59 commit a88115f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • packages/angular/build/src/builders/dev-server/vite

packages/angular/build/src/builders/dev-server/vite/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,13 @@ export async function* serveWithVite(
389389
? browserOptions.polyfills
390390
: [browserOptions.polyfills];
391391

392-
const target = transformSupportedBrowsersToTargets(browsers);
393-
if (!isZonelessApp(polyfills)) {
394-
// Rolldown doesn't have an option to support Zone.js/async-await, so we need to support es2016.
395-
target.push('es2016');
396-
}
392+
// Rolldown does not support selective feature downleveling for Zone.js async/await syntax.
393+
// For applications using Zone.js, we target 'es2016' to force downleveling.
394+
// The target array is replaced rather than appended to avoid Rolldown initialization errors when mixing browser targets.
395+
// [BUNDLER_INITIALIZE_ERROR] 'chrome149.0' is already specified.
396+
const target = isZonelessApp(polyfills)
397+
? transformSupportedBrowsersToTargets(browsers)
398+
: ['es2016'];
397399

398400
let ssrMode: ServerSsrMode = ServerSsrMode.NoSsr;
399401
if (

0 commit comments

Comments
 (0)