Skip to content

Bare-major browserslist target (e.g. safari 10) reports features supported at <major>.0 as unsupported #22278

Closed

Description

@Eshiv-Pandey

Have you used AI?

Yes

Which part of webpack is affected?

config (options, defaults, validation)

Bug Description

When a browserslist target is given at a bare major version (no minor component, e.g. safari 10), webpack's browserslist target handler treats the environment as not supporting a feature whose first supported version is expressed as a [major, minor] pair (e.g. const/let, first supported at safari [10, 0]). The target actually supports the feature, so the runtime capabilities webpack derives from target: "browserslist" are more conservative than they should be.

The cause is in lib/config/browserslistTargetHandler.js. When the resolved version has no minor component, the minor coerces to NaN, and the equal-major comparison Number(parserMinor) >= requiredVersion[1] becomes NaN >= 0, which is false. So safari 10 fails the check that safari 10.0 passes.

Note that browserslist itself emits bare-major strings such as safari 10 (not safari 10.0) for several queries, so this is reachable from ordinary configuration.

Link to Minimal Reproduction and steps to reproduce

No separate repo needed — this is reproducible directly against the target handler:

const { resolve } = require("webpack/lib/config/browserslistTargetHandler");

console.log(resolve(["safari 10"]).const);   // false  (bug)
console.log(resolve(["safari 10.0"]).const);  // true

Steps:

  1. resolve(["safari 10"]) and resolve(["safari 10.0"]).
  2. Compare the const (or let, arrow function, etc.) capability.
  3. The bare-major form reports const: false while the .0 form reports const: true, even though they denote the same browser version.

Expected Behavior

A bare-major target is equivalent to <major>.0, so resolve(["safari 10"]) should equal resolve(["safari 10.0"]), and const/let should be reported supported at the exact major where support begins.

Actual Behavior

resolve(["safari 10"]).const === false, disagreeing with resolve(["safari 10.0"]).const === true. Features first supported at <major>.0 are wrongly reported unsupported whenever the target omits the minor.

Environment

webpack: 5.111.1 (also present on current main; the file was relocated but the logic is unchanged)
Node: 20.20.0
OS: Windows 11

Is this a regression?

No

Last Working Version

Additional Context

Fix: treat a missing minor as 0 in the equal-major branch. A PR follows.

Activity

  1. alexander-akait commented on Sep 24, 2026

    @alexander-akait
    Member

    No need to create an issue if you already sent a PR, it creates more spam than fix real bugs/problems

  2. Eshiv-Pandey commented on Sep 24, 2026

    @Eshiv-Pandey
    ContributorAuthor

    would keep tht in mind from next time

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configOptions, defaults, validation (lib/config, schemas/)

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions