Skip to content

fix(@angular/build): bundle polyfills to preserve execution order in dev server#32635

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:polyfills-bundle
Mar 2, 2026
Merged

fix(@angular/build): bundle polyfills to preserve execution order in dev server#32635
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:polyfills-bundle

Conversation

@alan-agius4
Copy link
Collaborator

When using the development server with ESM, polyfills were built as a mix of bundled local files and external package imports. Due to ESM hoisting behavior, all top-level import statements are executed before any other code in the module. This caused polyfills that modify global state (like zone-flags.js) to run after the polyfills they were intended to configure (like zone.js), rendering the flags ineffective.

This change ensures that all polyfills are bundled together into the single polyfills.js file when using the development server, matching the behavior of the production build and preserving the intended execution order.

Closes #32632

…dev server

When using the development server with ESM, polyfills were built as a mix of bundled local files and external package imports. Due to ESM hoisting behavior, all top-level import statements are executed before any other code in the module. This caused polyfills that modify global state (like zone-flags.js) to run after the polyfills they were intended to configure (like zone.js), rendering the flags ineffective.

This change ensures that all polyfills are bundled together into the single polyfills.js file when using the development server, matching the behavior of the production build and preserving the intended execution order.

Closes angular#32632
@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 labels Mar 2, 2026
@alan-agius4 alan-agius4 requested a review from clydin March 2, 2026 07:59
@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 Mar 2, 2026
@alan-agius4 alan-agius4 merged commit ec289c3 into angular:main Mar 2, 2026
37 of 38 checks passed
@alan-agius4 alan-agius4 deleted the polyfills-bundle branch March 2, 2026 13:57
@alan-agius4
Copy link
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.

Polyfills are improperly inlined and execute in the wrong order

2 participants