perf(build): the stylesheet minifier had never run

It looked for the tag written as `css` immediately followed by a
backtick. The plugin is a Rollup transform, so the module has already
been through TypeScript by the time it arrives, and the TS printer puts
a space there: `css `. The guard therefore returned null for every
stylesheet in the project, and minification never ran once — around
23 KB of explanatory comments went to every user in every release.

Matching the tag as a word with optional whitespace turns it on:

  chunk, raw       1 079 508 -> 1 021 115 B   (-58 393)
  initial view     300 111 -> 287 284 B gzip  (-12 816)
  room to the budget   955 -> 13 782 B

The ceiling moves down with the fact, as the tool asks when a graph
shrinks past the band.

The risk is not the two lines; it is that 23 KB of CSS is minified for
the first time. Two witnesses cover it: a browser smoke that puts the
original and the minified text into separate stylesheets and compares
the serialised rules — 1 049 of them, identical up to the whitespace
policy the minifier declares — and a test that takes real comment text
out of src/styles and requires it to be absent from dist, so a plugin
that silently stops working cannot pass again.

Issue: #526
User-Visible: yes
This commit is contained in:
Codex
2026-09-11 10:12:13 +03:00
parent 7e39c3715c
commit 0a0a9f0f4c
54 changed files with 697 additions and 11698 deletions
+26
View File
@@ -3611,6 +3611,32 @@ const MUTANT_DEFINITIONS = [
replace: " if (ledger.caught[mutant.id] === fingerprint || mutant.id in ledger.caught) skipped.push(mutant);",
}],
},
{
id: 'css-minifier-skips-typescript-output',
guard: 'node --test --test-name-pattern="#526 AC4|#526 AC2" test/bundle-assets.test.mjs',
because: '#526: плагин видит вывод TypeScript, где тег отделён от шаблона пробелом; '
+ 'строгий отсев `css` вплотную к бэктику молча выключает минификацию целиком — '
+ 'так 23 КБ комментариев и 12,8 КБ gzip уехали пользователю и никто не заметил',
patches: [{
file: 'scripts/css-template-minifier.mjs',
find: " if (!id.endsWith('.ts') || !CSS_TAG" + '.test(code)) return null;',
replace: " if (!id.endsWith('.ts') || !code.includes('css" + String.fromCharCode(96) + "')) return null;",
}],
},
{
id: 'css-minifier-eats-required-space',
guard: 'node demo/smoke_css_minifier_semantics.mjs',
because: '#526: минификация 23 КБ CSS включилась впервые — свидетель обязан ловить '
+ 'съеденный значащий пробел (потомковый комбинатор, аргумент calc), а не только '
+ 'считать сэкономленные байты',
patches: [{
file: 'scripts/css-template-minifier.mjs',
find: ' if (pendingSpace && out && !TIGHT_AFTER.has(out.at(-1))' + ' && !TIGHT_BEFORE.has(char)) {
out += ' ';
}',
replace: ' void pendingSpace; // mutant: значащий пробел больше не восстанавливается',
}],
},
{
id: 'marker-shadow-animates-again',
guard: 'node demo/smoke_marker_shadow_transitions.mjs',