feat(utils): one compressor list and one removed-compressor check
Third PR of the v11.1.0 cleanup (R1–R3): one compressor list, and one way to reject a removed compressor.
Summary
packages/utils/src/compressor-registry.ts
COMPRESSOR_REGISTRY
+ exportName, cssOnly, aliases # moved in from the lists below
+ type CompressorName # non-removed names, new export
packages/utils/src/compressor-resolver.ts
- KNOWN_COMPRESSOR_EXPORTS { … } # hand-written
- COMPRESSOR_ALIASES { gcc: … } # hand-written
+ both derived from COMPRESSOR_REGISTRY
resolveCompressor(name)
+ removed? → throw "Compressor '<name>' was removed in v11. Use '<replacement>' instead."
packages/cli/src/
- config.ts (AVAILABLE_MINIFIER) # cssOnly now read from the registry
- removed-compressor check
packages/action/src/
- removed-compressor check ("has been removed from node-minify")
COMPRESSOR_MAP, default benchmark set, TYPE_REQUIRED_COMPRESSORS: CompressorName
packages/benchmark/src/
- loadCompressor(): null on any error → "Compressor not found or not installed"
+ the resolver's error goes into the result row
default compressor set: CompressorName
The Action's per-file-type defaults and the benchmark's default set stay in their own files, as the maintainer decided. They're typed CompressorName, so renaming or removing a registry entry fails typecheck. docs/.../custom-compressors.md and both AGENTS.md files now say to add one registry entry.
Evidence
Names resolve the same way (R3). I ran one script against the develop build (ac82445d) and this branch. It covers 44 resolver inputs: all 22 registry names, their @node-minify/<name> forms, gcc, @node-minify/gcc, unknown names, an existing local file and a missing one. For each it records the label, isBuiltIn, which exported function was returned, isBuiltInCompressor and getKnownExportName. It also runs 15 real CLI calls, including gcc, @node-minify/terser, a local compressor and the four CSS-only rejections with -t js. The only lines that differ are the 5 removed names and their 5 package names:
- "yui" => ERROR Could not resolve compressor 'yui'. Is it installed? …
+ "yui" => ERROR Compressor 'yui' was removed in v11. Use 'terser or lightningcss' instead.
These are identical between the two builds:
- the CLI
--helpoutput, which includes the compressor list by tier; doctoron a project depending on csso, jsonminify, yui and terser;- the real Action bundle with
terser,gccanddoes-not-exist.
One message everywhere (R2, AE1). scripts/__tests__/removed-compressor.test.ts calls the CLI, Action explicit mode and resolveCompressor with yui and @node-minify/yui, and asserts the messages are the same. Running the real Action bundle confirms it:
- ::error::Compressor 'yui' has been removed from node-minify. Use 'terser or lightningcss' instead.
+ ::error::Compressor 'yui' was removed in v11. Use 'terser or lightningcss' instead.
Typing bites. Changing COMPRESSOR_MAP.js to "terserx" fails typecheck with TS2820 … Did you mean '"terser"'?.
Gate: build, check-exports, lint, typecheck and both guards pass, and so do 1105 of 1105 tests (1086 before).
Merge Danger
Door: two-way. It's a revert away.
Blast Radius: small
resolveCompressorand removed names: it now rejects removed names, matched by name or@node-minify/<name>. Before, it tried to import them, andyuiexists on npm as an unrelated package. Anyone who deliberately used one of those 5 npm package names as a custom compressor would now get the removed message.- Benchmark failure rows: they show the resolver's real error instead of "Compressor not found or not installed".
- Action log: with a removed compressor, the Action now logs
Minifying … with yui...before it fails, because the check moved into resolution. - Public API: additions only. There's a new
CompressorNametype, andCompressorEntrygains optionalexportName,cssOnlyandaliases. Nothing is removed, renamed or deprecated, and no tier changes.
Summary by cubic
Consolidates the compressor list into COMPRESSOR_REGISTRY in @node-minify/utils; the CLI, Action, resolver, benchmark, and doctor now all read from that one list. Removed compressors now fail the same way everywhere: resolveCompressor rejects them with one consistent message naming the replacement, and the CLI's and Action's separate checks are gone.
Behavior changes
resolveCompressorrejects the five removed names (yui,sqwish,crass,babel-minify,uglify-es) and their@node-minify/<name>forms before any import attempt, so anyone who used those npm package names as custom compressors now gets the removed message.- Benchmark failure rows now show the resolver's actual error instead of "Compressor not found or not installed".
- The Action with a removed compressor now logs "Minifying … with yui..." before failing because the check moved into resolution.
- CLI, Action, and benchmark defaults are typed
CompressorName, derived from the registry, so renaming or removing an entry fails typecheck; aRegistryEntryunion also requires non-removed entries to declareexportNameand removed entries to declarereplacement. - The CLI's CSS-only check uses the resolved canonical name, so aliases of CSS-only compressors are caught too.