{"id":21015,"library":"browserslist-to-esbuild","title":"Browserslist to esbuild target converter","description":"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.","status":"active","version":"2.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/marcofugaro/browserslist-to-esbuild","tags":["javascript","browserslist","browserlist","esbuild","browsers","typescript"],"install":[{"cmd":"npm install browserslist-to-esbuild","lang":"bash","label":"npm"},{"cmd":"yarn add browserslist-to-esbuild","lang":"bash","label":"yarn"},{"cmd":"pnpm add browserslist-to-esbuild","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; provides the browserslist resolution logic","package":"browserslist","optional":false}],"imports":[{"note":"Package is pure ESM since v2; CommonJS require() will fail. Use dynamic import or ESM.","wrong":"const { browserslistToEsbuild } = require('browserslist-to-esbuild')","symbol":"default (browserslistToEsbuild)","correct":"import browserslistToEsbuild from 'browserslist-to-esbuild'"},{"note":"Named export also exists; both default and named work with ESM.","wrong":"const browserslistToEsbuild = require('browserslist-to-esbuild').browserslistToEsbuild","symbol":"browserslistToEsbuild (named export)","correct":"import { browserslistToEsbuild } from 'browserslist-to-esbuild'"},{"note":"Types are bundled; no additional @types package needed.","wrong":null,"symbol":"TypeScript types","correct":"import type { Options } from 'browserslist-to-esbuild'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\n\nawait build({\n  entryPoints: ['src/index.js'],\n  outfile: 'dist/output.js',\n  bundle: true,\n  target: browserslistToEsbuild(['> 0.2%', 'not dead']),\n});","lang":"typescript","description":"Demonstrates converting a browserslist query (default config) into esbuild target array."},"warnings":[{"fix":"Use ESM imports (import) or dynamic import() in CommonJS projects.","message":"Package is pure ESM since v2.0.0; CommonJS require() throws Error.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Node.js to >=18 or use v1.x (v1.2.0 is last CommonJS-compatible).","message":"Node.js 18+ required since v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Install browserslist as a devDependency: npm install --save-dev browserslist","message":"browserslist became a peer dependency in v2.0.0. Missing it will cause runtime errors.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Always provide a browserslistConfig argument or ensure a .browserslistrc or package.json browserslist field exists.","message":"Calling browserslistToEsbuild() without arguments may throw if no browserslist config found in current directory.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to v2.0.0+ or filter out 'safari TP' manually.","message":"Safari Technology Preview (safari TP) is not supported and will cause esbuild to break; v2.0.0 fixed by ignoring it.","severity":"gotcha","affected_versions":"<2.0.0"},{"fix":"Upgrade to v2.0.0+ or handle IE/Opera manually.","message":"IE and Opera targets are supported since v2.0.0; earlier versions may produce invalid esbuild targets for those browsers.","severity":"gotcha","affected_versions":"<2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import('browserslist-to-esbuild') or migrate your project to ESM.","cause":"Package is pure ESM since v2; CommonJS require() fails.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/browserslist-to-esbuild/index.js not supported."},{"fix":"Import correctly: import browserslistToEsbuild from 'browserslist-to-esbuild' (ESM) or const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild') (dynamic import).","cause":"Default import misused in CommonJS context or wrong import style.","error":"TypeError: browserslistToEsbuild is not a function"},{"fix":"npm install --save-dev browserslist","cause":"browserslist is a peer dependency not installed.","error":"Cannot find module 'browserslist'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}