Skip to content

fix(build): drop the esbuild CSS syntax warning in the drafts widget - #463

Merged
AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/drafts-widget-css-attr-selector-warning
Jul 31, 2026
Merged

fix(build): drop the esbuild CSS syntax warning in the drafts widget#463
AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/drafts-widget-css-attr-selector-warning

Conversation

@AllTerrainDeveloper

@AllTerrainDeveloper AllTerrainDeveloper commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Problem

Every production build printed a css-syntax-error warning:

vite v5.4.21 building for production...
✓ 19 modules transformed.
rendering chunks (1)...warnings when minifying css:
▲ [WARNING] Expected identifier but found whitespace [css-syntax-error]

    <stdin>:136:18:
      136 │ .dm-drafts__spark[ aria-expanded='true' ] {
          ╵                   ^

esbuild's CSS parser rejects whitespace inside attribute-selector brackets. It recovers by preserving the rule verbatim rather than minifying it, so the shipped CSS was always correct — but the rule was silently skipping the minifier, and the warning was noise on every single build.

Fix

Removed the inner spaces in src/plugins/drafts-widget/styles.css:136.

This is the only attribute selector in any bundled src/**/*.css, so nothing else in the tree is affected. The spaced WP-style form remains fine in assets/css/*.css (enqueued raw) and in the *.styles.ts shadow-DOM literals (JS template strings) — neither passes through esbuild's CSS pipeline.

Build-output diff

Now that esbuild parses the rule, it minifies it normally and applies its usual unquoted-value normalization:

-.dm-drafts__spark[aria-expanded="true"]{opacity:1;…}
+.dm-drafts__spark[aria-expanded=true]{opacity:1;…}

Equivalent CSS — true is a valid identifier, so quotes are optional. Diffed the rest of the minified bundle rule-by-rule; that line is the only change.

Verification

  • npm run build — clean, zero warnings across all targets
  • npm run lint — pass
  • npm run typecheck — pass
  • npm run test:js — 2744 tests / 272 files, all pass

No PHP touched.

🤖 Generated with Claude Code

https://claude.ai/code/session_015sKW1mu1SGg5k9oSHgxv5s

Open WordPress Playground Preview

`npm run build` emitted a `css-syntax-error` warning on every production
build of the drafts widget:

    ▲ [WARNING] Expected identifier but found whitespace [css-syntax-error]
        136 │ .dm-drafts__spark[ aria-expanded='true' ] {

esbuild's CSS parser rejects whitespace inside attribute-selector
brackets, so it bailed on the rule and preserved it verbatim instead of
minifying it. The emitted CSS was correct either way, but the rule was
skipping the minifier and the warning was noise on every build.

Removes the inner spaces. This is the only attribute selector in any
bundled `src/**/*.css`, so nothing else is affected — the spaced form
stays fine in `assets/css/*.css` and the `*.styles.ts` shadow-DOM
literals, neither of which passes through esbuild's CSS pipeline.

esbuild now minifies the rule normally, so the tracked build output
picks up the unquoted-value normalization (`[aria-expanded=true]`),
which is equivalent CSS — `true` is a valid identifier.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sKW1mu1SGg5k9oSHgxv5s
@AllTerrainDeveloper
AllTerrainDeveloper enabled auto-merge (squash) July 31, 2026 11:42
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 80701ca into trunk Jul 31, 2026
5 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the fix/drafts-widget-css-attr-selector-warning branch July 31, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant