@cogs/browserslist-config
v0.1.0
Published
Shareable Browserslist config, plus a utility for computing the lowest supported browser version across a set of Browserslist queries
Readme
@cogs/browserslist-config
Shareable Browserslist config, plus a utility for computing the lowest supported browser version across a set of Browserslist queries.
Why
Every project that cares about "which browsers do we actually support" ends
up needing the same two things: one canonical list of Browserslist queries
shared across all of a project's tooling (Babel, Autoprefixer, ESLint,
PostCSS, etc.), and a way to turn resolved Browserslist query results (e.g.
"chrome 90", "ios_saf 10.0-10.2") into a single lowest-supported-semver
floor per browser — useful for anything that needs to target its output at
the actual minimum version a build needs to run on, rather than re-deriving
that floor ad hoc.
Usage
Shareable config
Add this to your package.json:
"browserslist": [
"extends @cogs/browserslist-config"
]Or to a .browserslistrc file:
extends @cogs/browserslist-configThe config exposes production, development, legacy, and modern query
sets. You can also import it directly:
import { browserslistConfig } from '@cogs/browserslist-config'
browserslistConfig.production // => ['>1%', 'last 2 Chrome major versions', ...]getLowestVersions — compute a version floor per browser
import { getLowestVersions } from '@cogs/browserslist-config/utils'
import browserslist from '@cogs/browserslist-config/browserslist'
const queries = browserslist(browserslistConfig.production)
const floors = getLowestVersions(queries)
// => { chrome: '90.0.0', firefox: '88.0.0', ios: '10.0.0', ... }getLowestVersions walks a list of resolved Browserslist query strings,
normalizes browser identifiers (e.g. and_chr -> chrome, ie_mob -> ie),
and reduces them to the lowest semver version seen per browser — handling
version ranges ("10.0-10.2") and unreleased preview labels (e.g. Safari
Technology Preview, "tp") along the way.
cogs-browserslist — run the Browserslist CLI in a monorepo
"scripts": {
"supported": "cogs-browserslist"
}cogs-browserslist proxies to the real browserslist CLI binary via
@cogs/node-pkg, so it resolves correctly no matter how far
pnpm/turbo hoists browserslist's node_modules/.bin entry away from this
package.
