Repository navigation
feat(@angular/build): add keepDefaultConditions option - #34844
Open
damienwebdev wants to merge 7 commits into
Open
damienwebdev wants to merge 7 commits into
damienwebdev wants to merge 7 commits into
Conversation
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
The Vitest runner sets its own `resolve.conditions`, so packages resolved by Vite at test time ignored the build target's `conditions`. Use them in place of the default `module` condition, as the build does. Fixes angular#34835
…nner The Karma runner of the unit-test builder copies a fixed set of options from the build target, and `conditions` was not one of them. Pass it through to the Karma test build. Fixes angular#34836
The build, the dev server and the Vitest and Karma unit-test runners each read the build `conditions` on their own. Read them in one place, along with the default conditions of the build.
Setting `conditions` replaces the default `module` and `development`/`production` conditions. With `keepDefaultConditions`, the custom conditions are added to the defaults instead, and the `development`/`production` condition still follows the `optimization` setting. The option applies to the build, the dev server and the unit-test runners. Closes angular#34838
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'keepDefaultConditions' option to the application builder, allowing users to retain default package resolution conditions ('module' and 'development'/'production') when custom conditions are specified. The changes include a new utility for resolving these conditions, updates to the application, dev-server, and unit-test builders to support this configuration, and comprehensive test coverage for the new functionality. I have no feedback to provide as there were no review comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Setting
conditionsreplaces the defaultmoduleanddevelopment/productionconditions. Adding one custom condition also drops the defaults, and keeping them means repeatingmoduleanddevelopmentorproductionin every configuration, in sync with itsoptimizationsetting. It also means that if Angular changes its default conditions, then we have to track this change upstream, which is tedious.Fixes: #34838
What is the new behavior?
A new
keepDefaultConditionsapplication option,falseby default. When set, customconditionsare added to the defaults instead of replacing them, and thedevelopment/productioncondition still followsoptimization.The build, the dev server and the Vitest and Karma unit-test runners each read
conditionsseparately. A refactor commit moves that intoutils/resolve-conditions.ts, so the new option is handled in one place and applies to all of them.Does this PR introduce a breaking change?
Other information
This is stacked on
which make the dev server and the unit-test runners use
conditions. The last two commits are new here: the refactor and the feature.