Skip to content

fix(@angular/build): apply build conditions to dev server prebundling - #34839

Open
damienwebdev wants to merge 2 commits into
angular:mainfrom
damienwebdev:fix/dev-server-prebundle-conditions
Open

damienwebdev wants to merge 2 commits into
angular:mainfrom
damienwebdev:fix/dev-server-prebundle-conditions

Conversation

@damienwebdev

Copy link
Copy Markdown

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

The dev server doesn't pass the build conditions to Vite. With prebundling enabled (the default), Vite's dependency optimizer resolves packages with its default conditions, so ng serve can run different code than ng build for packages with conditional exports. This affects both the browser and SSR.

Fixes #34834

What is the new behavior?

Pass the build conditions to Vite's client and SSR resolve.conditions. Without them, prebundled packages resolve with Vite's default conditions and ng serve runs different code than ng build.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Pass the build `conditions` to Vite's client and SSR `resolve.conditions`.
Without them, prebundled packages resolve with Vite's default conditions and
`ng serve` runs different code than `ng build`.

Fixes angular#34834

@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 Angular dev-server Vite integration to support custom resolve conditions for both browser and SSR prebundling, and adds a new test suite to verify this behavior. The review feedback recommends checking for non-empty arrays (conditions?.length) instead of just truthiness to avoid applying empty resolve conditions, and suggests extending the tests to cover this empty array scenario.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng serve resolves prebundled packages without the build conditions

1 participant