Repository navigation
refactor(css,html): name token types, quotes and namespaces with enums - #22640
Conversation
CSS token types become TokenType, HTML quote kinds Quote and namespaces Namespace, like NodeType. Character codes and the minifier's list states the printers share become private exports; six unused ones are removed.
|
|
This PR is packaged and the instant preview is available (f899873). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@f899873
yarn add -D webpack@https://pkg.pr.new/webpack@f899873
pnpm add -D webpack@https://pkg.pr.new/webpack@f899873 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Change: Refactor Merge Risk: ⚪ Minimal · up to This is a behavior-preserving refactor that renames internal parser constants into enums. No concrete risk was identified, and it looks safe to merge after normal checks. Pre-merge checks |
|
Types CoverageCoverage after merging refactor/css-html-syntax-enums into main will be
Coverage Report |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22640 +/- ##
==========================================
- Coverage 96.28% 96.27% -0.01%
==========================================
Files 774 774
Lines 129982 129951 -31
Branches 43297 43297
==========================================
- Hits 125149 125114 -35
- Misses 4833 4837 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generated code sizeComparing base (
Read No asset changed size. No runtime gained or lost a runtime module. Built |
Reading TokenType, Quote and Namespace members on the hot paths cost CodSpeed's readToken benchmark 25% more instructions. The parsers read the TT_*, QUOTE_* and NS_* constants again and build the enums from them.
Summary
The CSS and HTML syntax modules still exported groups of bare constants where
NodeTypealready uses an enum. This PR turns those groups into enums too, so all three are read the same way.TT_*(26 constants)TokenType(Ident,BadString,LeftCurlyBracket, …, names matchingNodeType)QUOTE_NONE/DOUBLE/SINGLEQuote.None/Double/SingleNS_HTML/MATHML/SVGNamespace.HTML/MathML/SVGCC_*andLIST_*used only by the printers_) exportsCC_*nothing importsEvery value keeps its number, so output is unchanged. CSS tokenize and parse of the Tailwind fixture, 20 alternating processes per side: median 56.9 ms on this branch vs 58.5 ms on
main, inside run-to-run spread.What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
No new tests. The existing tests in
test/unitCases/CssSyntax.unittest.jsandtest/unitCases/HtmlSyntax.unittest.js, plus the spec helpers, now read the enums.Does this PR introduce a breaking change?
No. The renamed and removed exports belong to the experimental syntax API and were never in a release.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Claude Code made the renames, updated the call sites, tests and tooling scripts, and compared CPU time against
main. A maintainer reviewed the result.🤖 Generated with Claude Code
https://claude.ai/code/session_015gdnghKbLJ7VvJ5nNCNHhH
Generated by Claude Code
Summary by CodeRabbit