chore: drop gzip-size and chalk in favor of node built-ins
Second PR of the v11.1.0 cleanup (R13, R14). It replaces two dependencies with Node built-ins, and reported sizes and terminal output stay the same.
Summary
@node-minify/utils
- gzip-size → zlib.gzip at level 9, as gzip-size did
@node-minify/cli
- chalk → util.styleText (INFO/DONE badges, spinner text)
@node-minify/benchmark
- chalk → util.styleText (console reporter)
__tests__/benchmark.test.ts
- chalk.level = 1
+ vi.stubEnv("FORCE_COLOR", "1")
The PR also adds a patch changeset for utils, cli and benchmark. In bun.lock, gzip-size@7.0.0 and duplexer@0.1.2 are removed and nothing is added. chalk stays in the lockfile because ora and update-notifier still use it.
Evidence
Sizes (R13): I measured 349 files (tests/fixtures, packages/, docs/src and an empty file) with the develop build and with this branch. Every gzip and brotli byte count is identical, including 20 bytes for the empty file.
Output (R14): I ran the real CLI from develop (df15d356) and from this branch on Node 22.23, then compared the text and the rendered screenshots:
| Run | Text | Rendered pixels that differ |
|---|---|---|
| minify, success, color | identical | 0 |
| minify, syntax error, color | identical | 0 |
| benchmark (terser, esbuild, missing compressor; gzip, brotli, verbose), color | identical | 0 |
| benchmark, color off | identical | 0 |
piped output with CI / GITHUB_ACTIONS set | identical | n/a |
- Masking: timings, absolute paths, the bundle hash and the process ID were masked before comparing.
- Rendering: I rendered the output in xterm.js and compared screenshots with ImageMagick (
compare -metric AE). - Sensitivity: recoloring one "OK" from green to yellow makes 113 pixels differ, so a 0 means the two look the same.
Tests: the two benchmark tests that check color codes get stripped still fail when the stripping is removed. The full suite passes, 1086 of 1086, along with build, check-exports, lint, typecheck and both guards.
Merge Danger
Door: two-way. It's a revert away.
Blast Radius: small
NO_COLOR=1in a terminal: the CLI used to print color anyway. Now it prints plain text, becausestyleTexthonorsNO_COLOR.- Node 22.0 to 22.7: on those versions,
styleTextdoesn't check for a terminal, so CLI output redirected to a file would contain color codes.enginesis still>=22.0.0. The benchmark's--outputfile is unaffected, because it strips color codes itself. - Not covered: the spinner animation in a live terminal. Its final line is identical, and the spinner still comes from the same
oralibrary.
Summary by cubic
Drops gzip-size and chalk in favor of Node built-ins (zlib and util.styleText) across @node-minify/utils, @node-minify/cli, and @node-minify/benchmark. Reported gzip sizes and terminal output are unchanged, and gzip-size plus its transitive duplexer dependency are removed from the lockfile.
Behavior changes
NO_COLOR=1now disables colors;chalkused to print color regardless.- On Node 22.0-22.7,
styleTextdoesn't detect a terminal, so CLI output redirected to a file can contain color codes. chalkstays in the lockfile becauseoraandupdate-notifierstill depend on it.- The benchmark ANSI tests now assert the reporter emits color before checking the written file strips it, so they fail if that color ever stops being produced.