Registry / devops / rollup-plugin-font-subsetter

rollup-plugin-font-subsetter

JSON →
library0.2.0jsnpmunverified

A Rollup plugin that subsets webfonts at build time based on the characters used in static source files (HTML, CSS, JavaScript/TypeScript) in the bundle. Current stable version: 0.2.0. Release cadence: low, experimental. Key differentiators: automatically extracts character set from bundled assets, uses subset-font under the hood, ships TypeScript types, supports only .woff2 format. Compared to alternatives like 'font-spider' or manual subsetting, it integrates directly into the Rollup build pipeline and requires no runtime overhead. Limitations: does not handle dynamic content or obfuscated code; character set extraction may be incomplete.

npm install rollup-plugin-font-subsetter
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-FONT
R
rollup-plugin-font-subsetter
devopsjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fontSubsetter
import { fontSubsetter } from 'rollup-plugin-font-subsetter'
const fontSubsetter = require('rollup-plugin-font-subsetter')
ESM-only package; does not support CommonJS require().
FontSubsetterOptions
import type { FontSubsetterOptions } from 'rollup-plugin-font-subsetter'
import { FontSubsetterOptions } from 'rollup-plugin-font-subsetter' (wrong, it's a type)
TypeScript type export only; use type import for runtime-free code.
default import
import { fontSubsetter } from 'rollup-plugin-font-subsetter'
import fontSubsetter from 'rollup-plugin-font-subsetter' (no default export)
Only named export is available; no default export.

Minimal Rollup configuration using the fontSubsetter plugin with TypeScript.

import { defineConfig } from 'rollup'; import { fontSubsetter } from 'rollup-plugin-font-subsetter'; export default defineConfig({ input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ fontSubsetter({ // Optional options }) ] });
Debug
Known issues
gotchaDoes not subset fonts used in dynamic content (e.g., JavaScript string interpolation). Only static files in the bundle are analyzed.
fix
Ensure all possible characters are present in source files or manually specify a character set using plugin options.
affects: >=0.0.0
gotchaOnly supports .woff2 font files. Other formats such as .woff, .ttf, .otf are ignored.
fix
Convert fonts to .woff2 format before using this plugin, or use other tools for non-woff2 fonts.
affects: >=0.0.0
gotchaCharacter set extraction may be incomplete for obfuscated or minified code (e.g., property names mangled).
fix
Ensure source code is not obfuscated before build, or manually specify additional characters.
affects: >=0.0.0
deprecatedThis package has low release cadence and may not be actively maintained.
fix
Check for newer versions or alternative plugins if issues arise.
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/rollup-plugin-font-subsetter/index.js
The package is ESM-only and cannot be required with require().
fix
Use import syntax or set 'type': 'module' in package.json.
TypeError: fontSubsetter is not a function
Improper import or no default export; referencing a non-existent export.
fix
Use named import: import { fontSubsetter } from 'rollup-plugin-font-subsetter'
rollup-plugin-font-subsetter: No font files found to subset
No .woff2 files were detected in the bundle output.
fix
Ensure that you have .woff2 font files referenced in your source code (e.g., via CSS @font-face) and that the plugin runs after CSS processing.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
subset-fontrequiredCore font subsetting logic
rollupoptionalPeer dependency - plugin requires Rollup >=2.x or >=3.x
Agent activity
8 hits · last 30 days
node
6
Resources
rollup-plugin-font-subsetter — npm install rollup-plugin-font-subsetter · libregistry