Skip to content

Switch codegen data source from caniuse-db to caniuse-lite#687

Merged
Boshen merged 1 commit into
mainfrom
switch-to-caniuse-lite
May 29, 2026
Merged

Switch codegen data source from caniuse-db to caniuse-lite#687
Boshen merged 1 commit into
mainfrom
switch-to-caniuse-lite

Conversation

@Boshen

@Boshen Boshen commented May 29, 2026

Copy link
Copy Markdown
Member

Summary

  • The Update browserslist cron has been failing (example) because the Rust codegen reads from caniuse-db while the parser tests shell out to the JS browserslist CLI, which reads from caniuse-lite. Both packages share a 1.0.30001NNN version number but their data snapshots drift, so a pnpm update --prod leaves the two data sources misaligned and the parser tests diff against a different Firefox/Chrome version set than the one baked into the generated Rust data.
  • Aligns both sides on caniuse-lite by porting caniuse-lite's three JS unpackers (agents, feature, region) to Rust under xtask/src/data/caniuse_lite.rs. The new loader reads the packed module.exports = {...} data files via JSON5, expands the single-letter browser/version codes, and produces the same Caniuse shape the existing generators consume — no Node spawning at codegen time.
  • Regions now flow through Caniuse instead of being read per-file from disk; the regions generator drops its fs::read_dir over caniuse-db/region-usage-json/.
  • package.json swaps caniuse-db for caniuse-lite as a peer dep; the cron's pnpm update --prod continues to keep the lockfile fresh.

Notes

  • caniuse-lite's F (release_date) map has null for some versions, so release_date is typed IndexMap<String, Option<i64>>.
  • A few feature files use D:undefined, which isn't JSON5, so the parser does body.replace("undefined", "null") before deserializing.
  • 583 feature files + 240 region files are read and parsed at codegen time; the full run completes in ~200ms locally.

The cron-driven `Update browserslist` workflow has been failing because
the Rust codegen read from `caniuse-db` while the parser tests shell out
to `node_modules/.bin/browserslist`, which reads from `caniuse-lite`.
The two packages share a `1.0.30001NNN` version number but their data
snapshots drift, so after a `pnpm update --prod` the parser tests diff
against a different Firefox/Chrome version set than the one baked into
the generated Rust data.

This commit aligns both sides on `caniuse-lite`: a new in-Rust port of
caniuse-lite's `agents`/`feature`/`region` unpackers (added under
`xtask/src/data/caniuse_lite.rs`) reads the packed `module.exports = {...}`
data files via JSON5, expands the single-letter browser/version codes
into full strings, and produces the same `Caniuse` shape the existing
generators consume. Regions are now passed through `Caniuse` instead of
being read per-file from disk, so the regions generator drops its
`fs::read_dir` over `caniuse-db/region-usage-json/`.

`package.json` swaps `caniuse-db` for `caniuse-lite` as a peer dep;
`pnpm update --prod` continues to keep the lockfile fresh.
@codspeed-hq

codspeed-hq Bot commented May 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing switch-to-caniuse-lite (fdcbe73) with main (596edb7)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (a73a87c) during the generation of this report, so 596edb7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.03%. Comparing base (596edb7) to head (fdcbe73).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #687   +/-   ##
=======================================
  Coverage   99.03%   99.03%           
=======================================
  Files          47       47           
  Lines        2374     2374           
=======================================
  Hits         2351     2351           
  Misses         23       23           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Boshen Boshen merged commit 50ded7c into main May 29, 2026
16 checks passed
@Boshen Boshen deleted the switch-to-caniuse-lite branch May 29, 2026 04:12
@oxc-guard oxc-guard Bot mentioned this pull request May 29, 2026
Boshen pushed a commit that referenced this pull request May 29, 2026
## 🤖 New release

* `oxc-browserslist`: 3.0.3 -> 3.0.4 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[3.0.4](oxc-browserslist-v3.0.3...oxc-browserslist-v3.0.4)
- 2026-05-29

### Other

- DRY up feature/region codegen with shared table + lookup helpers
([#694](#694))
- Consolidate bundled-data loading behind compression helpers
([#693](#693))
- Reduce binary size: run-length encode feature support versions
([#692](#692))
- Reduce binary size: Zopfli codegen compression + percentage byte-plane
([#691](#691))
- Reduce binary size: byte-plane (stream-split) compression for region
pair indices
([#690](#690))
- Update README binary size to 621K
([#689](#689))
- Reduce binary size of bundled caniuse/electron data
([#688](#688))
- Switch codegen data source from caniuse-db to caniuse-lite
([#687](#687))
- Update browserslist
([#685](#685))
- Update rust crates
([#682](#682))
- Update browserslist
([#679](#679))
- Update browserslist
([#678](#678))
- Update browserslist
([#677](#677))
- Update browserslist
([#673](#673))
- Update browserslist
([#671](#671))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant