{"id":22032,"library":"rollup-plugin-font-subsetter","title":"rollup-plugin-font-subsetter","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/kymok/rollup-plugin-font-subsetter","tags":["javascript","rollup","plugin","font","subset","subsetting","webfont","typescript"],"install":[{"cmd":"npm install rollup-plugin-font-subsetter","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-font-subsetter","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-font-subsetter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core font subsetting logic","package":"subset-font","optional":false},{"reason":"Peer dependency - plugin requires Rollup >=2.x or >=3.x","package":"rollup","optional":true}],"imports":[{"note":"ESM-only package; does not support CommonJS require().","wrong":"const fontSubsetter = require('rollup-plugin-font-subsetter')","symbol":"fontSubsetter","correct":"import { fontSubsetter } from 'rollup-plugin-font-subsetter'"},{"note":"TypeScript type export only; use type import for runtime-free code.","wrong":"import { FontSubsetterOptions } from 'rollup-plugin-font-subsetter' (wrong, it's a type)","symbol":"FontSubsetterOptions","correct":"import type { FontSubsetterOptions } from 'rollup-plugin-font-subsetter'"},{"note":"Only named export is available; no default export.","wrong":"import fontSubsetter from 'rollup-plugin-font-subsetter' (no default export)","symbol":"default import","correct":"import { fontSubsetter } from 'rollup-plugin-font-subsetter'"}],"quickstart":{"code":"import { defineConfig } from 'rollup';\nimport { fontSubsetter } from 'rollup-plugin-font-subsetter';\nexport default defineConfig({\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'es' },\n  plugins: [\n    fontSubsetter({\n      // Optional options\n    })\n  ]\n});","lang":"typescript","description":"Minimal Rollup configuration using the fontSubsetter plugin with TypeScript."},"warnings":[{"fix":"Ensure all possible characters are present in source files or manually specify a character set using plugin options.","message":"Does not subset fonts used in dynamic content (e.g., JavaScript string interpolation). Only static files in the bundle are analyzed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Convert fonts to .woff2 format before using this plugin, or use other tools for non-woff2 fonts.","message":"Only supports .woff2 font files. Other formats such as .woff, .ttf, .otf are ignored.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure source code is not obfuscated before build, or manually specify additional characters.","message":"Character set extraction may be incomplete for obfuscated or minified code (e.g., property names mangled).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Check for newer versions or alternative plugins if issues arise.","message":"This package has low release cadence and may not be actively maintained.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import syntax or set 'type': 'module' in package.json.","cause":"The package is ESM-only and cannot be required with require().","error":"Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/rollup-plugin-font-subsetter/index.js"},{"fix":"Use named import: import { fontSubsetter } from 'rollup-plugin-font-subsetter'","cause":"Improper import or no default export; referencing a non-existent export.","error":"TypeError: fontSubsetter is not a function"},{"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.","cause":"No .woff2 files were detected in the bundle output.","error":"rollup-plugin-font-subsetter: No font files found to subset"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}