Skip to content

rspack-contrib/browserslist-to-es-version

Repository files navigation

browserslist-to-es-version

Convert browserslist query to ECMAScript version.

npm version license

Usage

Install:

npm add browserslist-to-es-version -D

Example:

import { browserslistToESVersion } from 'browserslist-to-es-version';

const esVersion = browserslistToESVersion([
  "chrome >= 87",
  "edge >= 88",
  "firefox >= 78",
  "safari >= 14",
]);

console.log(esVersion); // 2017

Type

// Only supports ES5 ~ ES2018
type ESVersion = 5 | 2015 | 2016 | 2017 | 2018;

function browserslistToESVersion(browsers: string[]): ESVersion;

License

MIT.