Skip to content

[Bug]: When unknown browser version used, all polyfills are added to the bundle #4070

Closed
@erykpiast

Description

@erykpiast

Version

System:
    OS: macOS 14.6.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 874.61 MB / 36.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Browsers:
    Chrome Canary: 133.0.6860.0
    Safari: 17.6
    Safari Technology Preview: 18.0
  npmPackages:
    @rsbuild/core: ^1.1.4 => 1.1.6

Details

First of all, I'm sorry if it's a bug in Rspack or SWC - I use RSBuild (and I love it ❤️), I didn't check if the issue occurs in these tools. A quick search across all three issue trackers doesn't reveal already known bug.

The issue is when I use a browser version unknown for RSBuild in my .browserlistrc, instead of adding no transipilation and polyfills (this is the default @babel/preset-env behavior), everything is transpilled and polyfilled. That's a bit unfortunate, as the browserslist-rs tool used under the hood recognizes only browsers released before June 2024. I've already submitted a PR updating the data in that repo. I'm afraid changing how to handle defaults it's beyond my Rust knowledge 😅

Reproduce link

https://github.com/erykpiast/rsbuild-test

Reproduce Steps

  1. Install the dependencies:

    pnpm install
  2. Build the app for production:

    pnpm build
  3. Observe the JavaScript output artifact contains the generator polyfill.

  4. Go to the .browserslistrc file and change the Chrome version to 125.

  5. Build the app for production:

    pnpm build
  6. Observe the JavaScript does not contain any polyfill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions