Registry / devops / browserslist-to-esbuild

browserslist-to-esbuild

JSON →
library2.1.1jsnpmunverified

Converts browserslist queries into esbuild-compatible target arrays (e.g., 'chrome79', 'firefox91'). Version 2.1.1 is current stable, pure ESM since v2.0.0, requiring Node >=18 and browserslist as a peer dependency. Unlike other approaches (manual mapping or build tool plugins), this package supports all browserslist config sources (package.json, .browserslistrc, inline strings) and handles edge cases like 'safari TP', IE, and Opera. TypeScript types included. Recommended for projects using esbuild with browserslist.

npm install browserslist-to-esbuild
INSTALL
IMPORT
SIG · BROWSERSLIST-TO-ES
B
browserslist-to-esbuild
devopsjavascriptv2.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (browserslistToEsbuild)
import browserslistToEsbuild from 'browserslist-to-esbuild'
const { browserslistToEsbuild } = require('browserslist-to-esbuild')
Package is pure ESM since v2; CommonJS require() will fail. Use dynamic import or ESM.
browserslistToEsbuild (named export)
import { browserslistToEsbuild } from 'browserslist-to-esbuild'
const browserslistToEsbuild = require('browserslist-to-esbuild').browserslistToEsbuild
Named export also exists; both default and named work with ESM.
TypeScript types
import type { Options } from 'browserslist-to-esbuild'
Types are bundled; no additional @types package needed.

Demonstrates converting a browserslist query (default config) into esbuild target array.

import { build } from 'esbuild'; import browserslistToEsbuild from 'browserslist-to-esbuild'; await build({ entryPoints: ['src/index.js'], outfile: 'dist/output.js', bundle: true, target: browserslistToEsbuild(['> 0.2%', 'not dead']), });
browserslist-to-esbuild --version
Debug
Known issues
breakingPackage is pure ESM since v2.0.0; CommonJS require() throws Error.
fix
Use ESM imports (import) or dynamic import() in CommonJS projects.
affects: >=2.0.0
breakingNode.js 18+ required since v2.0.0.
fix
Upgrade Node.js to >=18 or use v1.x (v1.2.0 is last CommonJS-compatible).
affects: >=2.0.0
deprecatedbrowserslist became a peer dependency in v2.0.0. Missing it will cause runtime errors.
fix
Install browserslist as a devDependency: npm install --save-dev browserslist
affects: >=2.0.0
gotchaCalling browserslistToEsbuild() without arguments may throw if no browserslist config found in current directory.
fix
Always provide a browserslistConfig argument or ensure a .browserslistrc or package.json browserslist field exists.
affects: >=1.0.0
gotchaSafari Technology Preview (safari TP) is not supported and will cause esbuild to break; v2.0.0 fixed by ignoring it.
fix
Upgrade to v2.0.0+ or filter out 'safari TP' manually.
affects: <2.0.0
gotchaIE and Opera targets are supported since v2.0.0; earlier versions may produce invalid esbuild targets for those browsers.
fix
Upgrade to v2.0.0+ or handle IE/Opera manually.
affects: <2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/browserslist-to-esbuild/index.js not supported.
Package is pure ESM since v2; CommonJS require() fails.
fix
Use import('browserslist-to-esbuild') or migrate your project to ESM.
TypeError: browserslistToEsbuild is not a function
Default import misused in CommonJS context or wrong import style.
fix
Import correctly: import browserslistToEsbuild from 'browserslist-to-esbuild' (ESM) or const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild') (dynamic import).
Cannot find module 'browserslist'
browserslist is a peer dependency not installed.
fix
npm install --save-dev browserslist
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
browserslistrequiredpeer dependency; provides the browserslist resolution logic
Agent activity
15 hits · last 30 days
node
14
Amazon
1
Resources
browserslist-to-esbuild — npm install browserslist-to-esbuild · libregistry