Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

esbuild-plugin-browserslist

nihalgonsalves492kMIT1.0.1TypeScript support: included

Configure esbuild's target based on a browserslist query

readme

esbuild-plugin-browserslist

build status

Configure esbuild's target based on a browserslist query

Installation

yarn add esbuild-plugin-browserslist esbuild browserslist

Usage

import esbuild from "esbuild";
import browserslist from "browserslist";
import {
  esbuildPluginBrowserslist,
  resolveToEsbuildTarget,
} from "esbuild-plugin-browserslist";

await esbuild.build({
  entryPoints: ["./foo/bar.ts"],
  // ... other options (except `target`) ...
  plugins: [
    esbuildPluginBrowserslist(browserslist("defaults"), {
      printUnknownTargets: false,
    }),
  ],
});

// Or:

const target = resolveToEsbuildTarget(browserslist("defaults"), {
  printUnknownTargets: false,
});

await esbuild.build({
  entryPoints: ["./foo/bar.ts"],
  target,
});
<summary>:information_source: CJS usage instructions</summary>

Adjust the imports as follows:

const esbuild = require("esbuild");
const browserslist = require("browserslist");
const {
  esbuildPluginBrowserslist,
  resolveToEsbuildTarget,
} = require("esbuild-plugin-browserslist");

Caveats

  • Only edge, firefox, chrome, safari, ios_saf, and node have direct equivalents for esbuild targets.
  • android and and_chr are mapped to the chrome target, and and_ff is mapped to the firefox target.
  • All other browsers are ignored (and_qq, samsung, opera, op_mini, op_mob, ie, ie_mob, bb, baidu, and kaios)

Debugging

You can turn on debug logs (which will print all resolutions or failures) using DEBUG=esbuild-plugin-browserslist

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.1 (2025-05-20)

Bug Fixes

  • eslint-compat: add main field to package.json (#256) (d019d79)

1.0.0 (2025-03-19)

⚠ BREAKING CHANGES

  • This drops support for Node 18, and switches to a pure ESM package. This means that you either have to use "type": "module" in your package.json, or upgrade to a Node version that supports require(esm), i.e. >= v20.19.0, >= v22.12.0, or v23 and above.

Build System

0.16.0 (2025-02-10)

⚠ BREAKING CHANGES

  • update esbuild@~0.25.0 (#236)

Features

0.15.0 (2024-10-01)

⚠ BREAKING CHANGES

  • deps: bump all including esbuild 0.24.x (#215)

Features

  • deps: bump all including esbuild 0.24.x (#215) (9431519)

0.14.0 (2024-07-08)

⚠ BREAKING CHANGES

  • deps: support esbuild 0.23 (#198)

Features

0.13.0 (2024-07-02)

⚠ BREAKING CHANGES

  • deps: support esbuild 0.22

Features

  • deps: support esbuild 0.22 (e51e017)

0.12.1 (2024-06-04)

Bug Fixes

  • deps: bump the all group with 4 updates (#190) (a5380a6)

0.12.0 (2024-05-22)

⚠ BREAKING CHANGES

  • deps: esbuild v0.20.x

Features

  • deps: support esbuild v0.20.x and update deps (#187) (7b33f9b)

0.11.1 (2024-01-28)

Bug Fixes

  • ci: add missing corepack publish step (1743942)

0.11.0 (2024-01-28)

⚠ BREAKING CHANGES

Miscellaneous Chores

  • deps: bump the all group with 10 updates (#163) (20d6167)

0.10.0 (2023-10-23)

⚠ BREAKING CHANGES

  • Drops support for EoL Node 14 and 16

Miscellaneous Chores

0.9.1 (2023-10-05)

Bug Fixes

  • deps-security: bump zod from 3.22.2 to 3.22.3 (#137) (6b984e8)

0.9.0 (2023-08-17)

⚠ BREAKING CHANGES

  • peer-deps: This is the same breaking change as v0.8.0 and a fix for that release specifying the wrong peer dependency, but will make this install fail for users of esbuild <0.19.2.

Bug Fixes

  • peer-deps: upgrade esbuild peer dep to new major version ~19 (#125) (98d334a)

0.8.1 (2023-07-05)

0.8.0 (2023-06-14)

⚠ BREAKING CHANGES

  • deps: peerDep esbuild@~0.18.x. This is a breaking change as pre-v1 semver-minor versions of esbuild are not backwards compatible.

  • deps: update all incl. esbuild@~0.18.x (#102) (626416b)

0.7.2 (2023-05-31)

0.7.1 (2023-05-31)

0.7.0 (2023-01-31)

⚠ BREAKING CHANGES

  • deps: peerDep esbuild@~0.17.x. This is a breaking change as pre-v1 semver-minor versions of esbuild are not backwards compatible.

  • deps: update all incl. esbuild@~0.17.x (037e01b)

0.6.0 (2022-12-07)

⚠ BREAKING CHANGES

  • deps: esbuild v0.16.x upgrade

Co-authored-by: GitHub Actions actions@github.com

0.5.3 (2022-12-06)

Features

  • add support for new "opera" and "ie" esbuild targets (#74) (c4720bc)

0.5.2 (2022-10-26)

0.5.1 (2022-10-10)

0.5.0 (2022-08-23)

⚠ BREAKING CHANGES

  • Drops support for EOL Node 12. v16 LTS is recommended

Bug Fixes

  • update correct lockfile (fcbdd67)

  • drop support for node@12 (88b66cb)

0.4.13 (2022-08-03)

0.4.12 (2022-06-29)

0.4.11 (2022-06-14)

0.4.10 (2022-06-02)

0.4.9 (2022-04-07)

0.4.8 (2022-03-23)

Bug Fixes

0.4.7 (2022-03-23)

0.4.6 (2022-03-09)

0.4.5 (2022-03-02)

0.4.4 (2022-02-23)

0.4.3 (2022-01-26)

0.4.2 (2022-01-19)

0.4.1 (2022-01-05)

0.3.0 (2021-10-18)

⚠ BREAKING CHANGES

  • esbuild v0.13 peer dependency upgrade

  • upgrade esbuild (b89b379)

0.2.1 (2021-08-13)

0.2.0 (2021-08-08)

⚠ BREAKING CHANGES

  • deps: esbuild v0.12 peer dependency upgrade

Co-authored-by: Nihal Gonsalves nihal@nihalgonsalves.com

0.1.1 (2021-08-08)

0.1.0 (2021-04-28)

Features

  • add browserlist-to-esbuild mapping (0e0c383)
  • add resolveToEsbuildTarget (48b9930)
  • add target-applying esbuild plugin (8f8acca)
  • expose resolveToEsbuildTarget (f32bdba)
  • throw an error if no targets can be resolved (f77f911)