feat(build)!: shrink bundle, ship ESM only#62
Merged
Conversation
Add size-limit + @size-limit/preset-small-lib with a 2 KB budget for the dist file and a 100 KB ceiling for the consumer cost (dist + cheerio, brotlied). Enable tsdown report, minify, publint, and attw on every build for visibility into output size and package correctness. Bump biome, @types/node, ultracite, vite, vitest, and packageManager. Repin domhandler to ^5.0.3 to match cheerio's transitive resolution and remove the duplicate install.
Drop the CJS build. The package now publishes a single ESM entry; the
exports map, main, and tsdown formats collapse accordingly. attw runs
with the esm-only profile to ignore the expected node10/CJS-resolution
warnings.
BREAKING CHANGE: consumers using require('xscrape') must migrate to
import. Node 18+ supports ESM natively; CJS callers can use dynamic
import().
🦋 Changeset detectedLatest commit: 82fcbe6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
size-limit+@size-limit/preset-small-lib, enabled on everypnpm run ci.tsdownminify, report,publint, andattwso every build prints sizes and validates the package shape.domhandlerto^5.0.3to match cheerio's transitive and remove duplicate install.Why
Bundle output was effectively unmeasured. tsdown's default behavior already externalizes deps, so the shipped dist is small (~1 KB) — but nothing was gating regressions, and CJS was carrying weight (extra files, dual-package hazard, two attw resolution modes to keep green) for negligible upside. Modern Node has supported ESM natively for years, and the only meaningful bundle-size lever for consumers is cheerio, which a CJS/ESM split doesn't affect.
How
.size-limit.jsondefines two budgets: 2 KB for the dist file alone, 100 KB for the consumer-facing cost (xscrape + cheerio, brotlied). Today: 402 B dist, 88.23 KB consumer.tsdown.config.tsswitches toformat: ['esm']withattw: { profile: 'esm-only' }to ignore the expectednode10/ CJS-resolution warnings.package.jsoncollapses theexportsmap to a single conditionless entry, pointsmainatdist/index.mjs, and adds--profile esm-onlytocheck-exports.Changes
feat(build)!: ship ESM only— drop CJS, collapse exports, update attw profile.chore(build): add bundle size tooling and bump dev deps— size-limit, publint, tsdown report/minify, domhandler dedup, dev-dep bumps.Deployment
Breaking change for consumers using
require('xscrape')— must migrate toimport(Node 18+) or use dynamicimport(). A.changeset/esm-only.mdmajor bump is included; the next changesets release will publish v4.