Skip to content

Allow adding to the default conditions instead of replacing them #34838

Backlog

Description

@damienwebdev

Command

build, serve, test

Description

Setting conditions on @angular/build:application replaces the default ['module', 'development' | 'production'] (application-code-bundle.ts). This matches the option's documentation, but it means adding one condition also removes module and the development/production condition, and the replacement can't depend on the configuration's optimization setting without repeating the list in every configuration.

Packages such as @apollo/client select development or production code by condition. After adding a single custom condition, a production build no longer gets their production entry points, and a development build no longer gets their development ones.

Repository: https://github.com/damienwebdev/angular-cli-conditions-repro/tree/default-conditions

Steps:

  1. ng new repro-app --defaults
  2. Add a package whose exports have module, development and production conditions, and import it.
  3. ng build resolves module and production.
  4. Add "conditions": ["my-condition"] to the build target options and run ng build again. Neither module nor production is resolved.

Describe the solution you'd like

A way to add conditions while Angular keeps choosing module and development or production from the configuration. Potentially, a boolean such as keepDefaultConditions that keeps the defaults when conditions is set. It defaults to false, so existing projects keep today's behavior.

Describe alternatives you've considered

Repeating module and development or production in conditions for every configuration. This duplicates Angular's choice of development or production and goes stale if a configuration's optimization setting changes.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions