oxc-browserslist
Rust port of Browserslist, forked from browserslist-rs.
The original crate did not meet the criteria of oxc, the following changes are made:
- reduced compilation speed from one minute to a few seconds
- improved some runtime performance, e.g. improve sort method, precompute versions
- removed all unnecessary, heavy or slow dependencies:
nom,time,ahash,chrono,either,indexmap,itertools,once_cell,string_cache,serde_json - reduced binary size through data compression and removal of config file support. 717K (this crate) vs 3.2M (original crate).
Usage
Limitation
The following features are not supported, to align with Vite:
- Config file loading (
.browserslistrc,package.jsonbrowserslistfield) - Environment variables (
BROWSERSLIST,BROWSERSLIST_CONFIG,BROWSERSLIST_ENV) extendsquery (e.g.extends browserslist-config-google)- Custom usage (
> 0.5% in my statsorcover 99.5% in my stats)
Example
Inspect query result by running the example:
You can also specify additional options, for example:
Testing
Unit and Integration Tests
Property-Based Testing
Property-based tests generate random queries and compare results with the npm browserslist CLI.
# Install npm browserslist first
# Run property-based tests
Fuzzing
Fuzzing tests use libFuzzer to find edge cases.
# Install cargo-fuzz
# Run the fuzzer