Skip to content

perf: shrink published package by ~3% (216.5 kB to 209.3 kB) - #322

Merged
bartveneman merged 2 commits into
mainfrom
claude/zealous-hopper-dygnig
Oct 21, 2026
Merged

bartveneman merged 2 commits into
mainfrom
claude/zealous-hopper-dygnig

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

0.19.0 grew from 0.18.4 mostly because of new features (if() support via parse-condition.ts, a bigger value-node-parser, nested @supports/style() groups) and the new node-types, string-utils and token-types subpath entry points. This PR trims what can be trimmed without minifying and without touching hot paths.

dist size (unpacked, pnpm build): 216.5 kB → 209.3 kB (about -3.3%), plus about 4 kB less README.

Changes

  • Convert JSDoc (/** */) on internal CSSNode, Lexer and CSSDataArena members to // comments. JSDoc survives the build and was shipping in both the .js and .d.ts files; line comments are stripped. Same idea as perf: make comments terser #273 and Convert JSDoc comments to line comments for internal APIs #298. CloneOptions and other public types keep their JSDoc.
  • Condense the long JSDoc on IfCondition and IfBranch in node-types.ts.
  • Condense the README API section (10.8 kB → 6.5 kB): the entry points table becomes a list, the sub-parser examples are merged, and the "kB kB" typo is fixed.

Not included

  • Minification. Whitespace-only minify would save about 12% and full minify about 33%, but that was ruled out here.
  • stripInternal for the .d.ts files. The dts build fails because public types reference CSSDataArena.
  • Deduplicating scan_matching_paren (identical in AtRulePreludeParser and ConditionParser). It saves only about 0.4 kB, so it can land separately. An earlier commit on this branch did it and a later one reverts it.

Test plan

  • pnpm exec vitest run (1496 tests pass)
  • pnpm run check
  • pnpm run lint
  • pnpm knip
  • pnpm run build (publint passes)
  • pnpm run test-build finds no test files in test/build, with and without this change

Generated by Claude Code

- Turn JSDoc on internal CSSNode/Lexer/arena/parser members into line comments so they no longer ship in dist
- Share scan_matching_paren between AtRulePreludeParser and ConditionParser
- Condense if() node type docs
- Condense README API section (10.8 kB to 6.5 kB)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep the paren-matching dedupe out of the size-trimming work; it can land separately.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Package Size Decrease

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/css-parser 47.5 kB 43.8 kB -3.7 kB

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@projectwallace/css-parser@f6b79aa

commit: f6b79aa

@bartveneman
bartveneman merged commit 4720a50 into main Oct 21, 2026
16 checks passed
@bartveneman
bartveneman deleted the claude/zealous-hopper-dygnig branch October 21, 2026 19:13
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.

2 participants