Skip to content

Specifying multiple targets for the same engine is order-dependent rather than taking the lowest version #4509

Closed

Description

@alan-agius4

Context

When multiple targets for the same environment/engine are specified (e.g. via --target=chrome47,chrome147 or when passing a list from tooling like browserslist), esbuild overwrites the target version with the last one specified in the list instead of taking the lowest version (minimum common denominator).

Reproduction

Case 1: --target=chrome47,chrome147

a ?? b

Output:

a ?? b

(Nullish coalescing is NOT downleveled, even though Chrome 47 does not support ??, because chrome147 overwrote chrome47)

REPL Reproduction 1


Case 2: --target=chrome147,chrome47

a ?? b

Output:

a != null ? a : b;

(Downleveled as expected because chrome47 was evaluated last)

REPL Reproduction 2

Expected behavior

Target resolution should be order-independent when multiple targets for the same environment/engine are provided. esbuild should pick the minimum version for each target environment so that the generated output is compatible with all specified targets.

Additional context

Originally mentioned in oxc-project/oxc#10618 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions