Packages

@capsizecss/metrics

4.5.0 · 17 Nov 2026MIT472.5k / weekRepositorynpmAtom feed

Your version

2.0.0

major16 Feb 2024Where it was published

2.2.0 is the newest release of 2.x.

In short

1 breaking1 new

  • Breaking

    Precompile Capsize packages with [Crackle]

Release note

Major Changes

  • Breaking

    Precompile Capsize packages with [Crackle]

    Migrating Capsize packages to be precompiled with [Crackle], with a key change being Crackle now handles entry points instead of [Preconstruct].

    Other benefits include:

    • Modern module entry point syntax using the ["exports" field] with better tooling compatibility.

    • Improved types and better ESM and CJS compatibility

    • Better alignment between compiled code and module entry points

Breaking changes

API changes

While technically a breaking change, consumers of Capsize's public APIs are not affected by this change.  
If you are affected due to reaching into package internals, please get in touch and see if we can find a more maintainable approach.

TypeScript

TypeScript consumers should ensure they are using a compatible [`moduleResolution` strategy in TSConfig] — either `node16`, `nodenext` or `bundler`. This will ensure types are correctly resolved across the different module specifications.

[Crackle]: https://github.com/seek-oss/crackle?tab=readme-ov-file#-crackle-

[Preconstruct]: https://preconstruct.tools/

["exports" field]: https://nodejs.org/api/packages.html#exports

[`moduleResolution` strategy in tsconfig]: https://www.typescriptlang.org/tsconfig#moduleResolution

Minor Changes

  • xWidthAvg: Update character frequency weightings data source

    The character frequency weightings used to calculate the xWidthAvg metrics were previously hard coded internally, and were an adaption from a [frequency table] from Wikipedia.

    We now generate these weightings based on the abstracts from [WikiNews] articles.
    This makes it possible to add support for languages that use non-latin [unicode subsets], e.g. Thai, by adding the relevant abstract and generating the xAvgWidth based on the corresponding unicode subset range.

Will this change anything for consumers?

Given the updated `xWidthAvg` metrics are very close to the original hard coded values, we do not forsee any impact on consumers.  
Even our CSS snapshot tests were unchanged, and they contain values rounded to 4 decimal places!

The result is either no or extremely minor changes to the generated fallback font CSS, with the benefit being this lays the ground work to support additional language subsets in the near future.

[frequency table]: https://en.wikipedia.org/wiki/Letter_frequency#Relative_frequencies_of_letters_in_other_languages

[WikiNews]: https://wikinews.org/

[unicode subsets]: https://www.utf8icons.com/subsets

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.