Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

browserslist-to-esbuild

Package Overview
Dependencies
8
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    browserslist-to-esbuild

Get esbuild-compatible targets from a browserlist config


Version published
Weekly downloads
247K
increased by1.48%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

browserslist-to-esbuild

Use browserslist with esbuild.

Allows you to use use browserslist and pass the correct browsers to esbuild's target option.

Install

You have to install the browserslist package as well in your project:

npm install --save-dev browserslist browserslist-to-esbuild

or

yarn add --dev browserslist browserslist-to-esbuild

Usage

You can call browserslistToEsbuild() directly in your esbuild.mjs script, it will look for your browserslist config in either package.json or the .browserslistrc.

It will return an esbuild-compatible array of browsers.

import { build } from 'esbuild'
import browserslistToEsbuild from 'browserslist-to-esbuild'

await build({
  entryPoints: ['input.js'],
  outfile: 'output.js',
  bundle: true,
  target: browserslistToEsbuild(), // --> ["chrome79", "edge92", "firefox91", "safari13.1"]
})

Otherwise, you can pass yourself a browserslist array or string to the function.

browserslistToEsbuild(['>0.2%', 'not dead', 'not op_mini all'])

API

browserslistToEsbuild(browserslistConfig?, options?)

browserslistConfig

Type: array | string | undefined

An array of string of browsers compatible with browserslist. If none is passed, a browserslist config is searched in the script running directory.

options

Type: object | undefined

An object containing the options that will be forwarded to browserslist. You can check out the browserslist options documentation to see all the options available.

CLI

You can also use this package on the cli to test out the command in your project. If no argument is passed, the browserslist config is searched in the script running directory.

Here is some example usage:

$ npx browserslist-to-esbuild
chrome109 edge118 firefox115 ios15.6 opera102 safari15.6

$ npx browserslist-to-esbuild '>0.2%, not dead'
chrome103 edge87 firefox115 ios12.2 opera102 safari14.1

$ npx browserslist-to-esbuild '>0.2%' 'not dead'
chrome103 edge87 firefox115 ios12.2 opera102 safari14.1

Keywords

FAQs

Last updated on 08 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc