Strip CSS comments from every shadow-style literal shape, not only useShadowStyles(…)

The build-time stripper matched only a literal passed directly to
useShadowStyles. Literals appended to shared styles (useShadowStyles(X + `…`))
and named literals (const NAME_CSS = `…`, export const NAME_STYLES = `…`)
shipped their comments verbatim; three plugins' comments reached public bundles
that way (check:public-hygiene). All three shapes are stripped now.
This commit is contained in:
Doxa Maps 2026-09-28 00:34:37 +00:00
parent 9ce04ffea0
commit 170febe2de

View file

@ -20,8 +20,13 @@ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const SOURCE_ROOTS = ['library', 'plugin-designs'].map(d => resolve(ROOT, d) + sep)
const TAG = '[strip-shadow-css-comments]'
// The call site: `useShadowStyles(` then optional whitespace then the opening backtick.
const CALL = /\buseShadowStyles\(\s*`/g
// The literals that ship as CSS, in the three shapes this tree writes them:
// useShadowStyles(`…`) the literal passed directly;
// useShadowStyles(PANE_GRID_STYLES + `…`) a literal appended to shared styles;
// const PS_SHADOW_CSS = `…` / export const PANE_GRID_STYLES = `…` a named literal passed later.
// Only the first shape was matched until 2026-09-28, and regions found three plugins' comments shipping
// from the other two (check:public-hygiene) — the same mistake written independently, i.e. a trap.
const CALL = /\buseShadowStyles\(\s*(?:[A-Za-z_$][\w$]*\s*\+\s*)*`|\b(?:export\s+)?const\s+[A-Z][A-Z0-9_]*(?:_CSS|_STYLES)\s*=\s*`/g
/**
* Find the end of a template literal whose opening backtick is just before `from`.