--- /** * What the package weighs, said in the two ways that are both true. * * The numbers come from `scripts/collect-package-size.mjs`, which runs a real * bundle and a real `npm pack`, and CI fails when the committed file has * drifted. Nothing here is typed in. * * The section deliberately gives the install size as well as the bundled one. * Quoting ninety kilobytes alone would be true and would still feel like a * trick to somebody who then looks in `node_modules` and finds eight megabytes. * Saying both, and saying what the difference is made of, costs one line and is * the reason to believe the first number. * * There is no budget meter here any more, and its absence is deliberate. A * percentage-of-budget reading tells a reader how close the authors are to a * line the authors drew themselves, which is a fact about this project's * housekeeping rather than about the package. What a reader wants to know is * what the kilobytes bought, and `WhatsInTheBox.astro` answers that in the band * immediately below this one. */ import sizes from "../data/packageSize.json"; import stats from "../data/testStats.json"; const kb = (bytes: number) => `${Math.round(bytes / 1000)} kB`; const mb = (bytes: number) => `${(bytes / 1_000_000).toFixed(1)} MB`; /** * The gap between importing one name and importing the whole entry. * * Taken as a magnitude, because it can fall either way: the two are within a * few dozen bytes and which one lands higher depends on how the bundler wraps * a named import. Either way the point being made is that there is no * meaningful difference, and rendering "-60 bytes" would just look like a bug. */ const importGap = Math.abs(sizes.importEverythingBrotli - sizes.importOneBrotli); ---
{kb(sizes.importOneBrotli)} minified and compressed with brotli
That is what reaches your users when you import the engine, measured by bundling it for real on every commit. It is a lot for a library, and this is not a library: it is a language and its runtime. What that buys is broken down directly below.
One thing worth being straight about: importing a single name costs {importGap === 0 ? " exactly the same as " : ` within ${importGap} bytes of `} importing everything, because every subpath reaches the engine core. The {stats.subpathExports} subpath exports exist so you can import from where a thing lives and so a bundler can resolve types correctly, not because they let you take a smaller slice. If that changes, this paragraph changes with it.