Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nihalgonsalves/esbuild-plugin-browserslist
Configure esbuild targets based on a browserslist query
https://github.com/nihalgonsalves/esbuild-plugin-browserslist
browserslist esbuild esbuild-plugin javascript typescript
Last synced: 12 days ago
JSON representation
Configure esbuild targets based on a browserslist query
- Host: GitHub
- URL: https://github.com/nihalgonsalves/esbuild-plugin-browserslist
- Owner: nihalgonsalves
- License: mit
- Created: 2021-04-27T21:34:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T13:11:14.000Z (7 months ago)
- Last Synced: 2024-04-14T09:49:04.535Z (7 months ago)
- Topics: browserslist, esbuild, esbuild-plugin, javascript, typescript
- Language: TypeScript
- Homepage:
- Size: 2.09 MB
- Stars: 41
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-browserslist
![build status](https://github.com/nihalgonsalves/esbuild-plugin-browserslist/workflows/build/badge.svg)
Configure [esbuild](https://github.com/evanw/esbuild)'s target based on a [browserslist](https://github.com/browserslist/browserslist) query
## Installation
```sh
yarn add esbuild-plugin-browserslist esbuild browserslist
```## Usage
```ts
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,
});
```:information_source: CJS usage instructions
Adjust the imports as follows:
```ts
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`