Skip to content

Conversation

@bartveneman
Copy link
Member

No description provided.

bartveneman and others added 7 commits December 26, 2025 11:47
Create tracking documents for css-tree → @projectwallace/css-parser migration:
- MIGRATION-PLAN.md: Complete migration plan with 5 phases
- parser-improvements.md: Track API issues discovered during migration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual implementation with Wallace parser's is_vendor_prefixed.
Both implementations are functionally identical but Wallace's is battle-tested.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual implementation with Wallace parser's is_custom function.
Both check for -- prefix but Wallace's is battle-tested.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual case-insensitive comparison with Wallace parser's str_equals.
Both provide identical case-insensitive comparison but Wallace's is optimized.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual case-insensitive prefix matching with Wallace parser's
str_starts_with. Note: parameter order is reversed (string, prefix)
compared to our internal implementation (prefix, string).

Documented parameter order difference in parser-improvements.md.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Phase 1 Complete (String Utilities):
- hasVendorPrefix → is_vendor_prefixed ✅
- isCustom → is_custom ✅
- strEquals → str_equals ✅
- startsWith → str_starts_with ✅

Discovered Migration Challenges:
- Wallace and css-tree have incompatible AST structures
- Files cannot be migrated independently (parse-first requirement)
- Wallace's walk() only works with Wallace nodes, not css-tree nodes
- No built-in compatibility adapter provided

Documented three migration strategy options:
A) All-at-once (high risk)
B) Compatibility adapter (recommended)
C) Dual parser approach

Parser improvements documented:
- str_starts_with parameter order difference
- Missing css-tree compatibility mode
- Structural differences in children, location, and types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2025

Bundle Report

Changes will decrease total bundle size by 166.16kB (-59.35%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
analyzeCss-esm 113.81kB 81.19kB (248.87%) ⬆️
analyzeCss-analyzeCss-esm (removed) -106.03kB (-100.0%) ⬇️
analyzeCss-analyzeCss-esm-analyzeCss-umd (removed) -70.52kB (-100.0%) ⬇️
analyzeCss-analyzeCss-umd (removed) -70.8kB (-100.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: analyzeCss-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
css-*.js 81.19kB 113.81kB 248.87% ⚠️

Files in css-*.js:

  • ./src/index.ts → Total Size: 31.4kB

  • ./src/properties/property-utils.ts → Total Size: 623 bytes

  • ./src/string-utils.ts → Total Size: 652 bytes

  • ./src/vendor-prefix.ts → Total Size: 75 bytes

bartveneman and others added 12 commits December 26, 2025 12:56
…idation

Implement dual parser approach (Phase 2 of migration plan):
- Import Wallace parser alongside css-tree
- Create analyzeWithWallace() function counting basic metrics
- Add WALLACE_COMPARE env flag for side-by-side validation
- Compare stylesheet size, rules count, declarations count

All metrics match perfectly between parsers:
✅ Stylesheet size
✅ Rules count
✅ Declarations count

This validates Wallace parser accuracy and enables gradual migration.
Next steps: Migrate additional metrics one by one.

Related: MIGRATION-PLAN.md Phase 2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Move rule and declaration counting from css-tree to Wallace parser:
- Wallace walks AST and updates totalRules and totalDeclarations directly
- Removed totalRules++ from css-tree Rule handler
- Removed totalDeclarations++ from css-tree Declaration handler

This is actual incremental migration - Wallace now owns this functionality.
Both parsers run (double parse+walk), but Wallace handles what it can.

All 228 tests pass - results are identical.

Next: Migrate more metrics from css-tree to Wallace.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Discovered parser bug: comments in selector lists cause Wallace to stop
parsing remaining selectors. Attempted selector counting migration but
had to revert due to this bug.

Details:
- Wallace stops parsing at comment in comma-separated selector list
- Example: 6 selectors expected, Wallace only parses 4
- Documented in parser-improvements.md under "Parser Bugs"
- Updated MIGRATION-PLAN.md with attempted migration and blocker

Selector counting remains with css-tree until Wallace bug is fixed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reverted selector counting migration back to css-tree approach after
discovering Wallace parser bug with comments in selector lists.

Changes:
- Removed totalSelectors early declaration (duplicate)
- Simplified wallaceWalk to only count Rules and Declarations
- Selector counting uses css-tree: totalSelectors = selectorComplexities.size()
- All 228 tests passing

Wallace parser successfully handling:
- ✅ Rules counting
- ✅ Declarations counting

Remaining with css-tree:
- Selectors (blocked by parser bug with comments)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Migrated empty rules detection from css-tree to Wallace parser.

Implementation:
- Wallace checks if Rule node's block has no Declaration children
- Uses node.block.children.some() to detect declarations
- Removed emptyRules++ from css-tree walk

All 228 tests passing - Wallace now handles:
- ✅ Rules counting
- ✅ Declarations counting
- ✅ Empty rules counting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Migrated important declarations counting from css-tree to Wallace parser.

Implementation:
- Wallace checks Declaration node's is_important property
- Simple boolean flag check, no context needed
- Removed importantDeclarations++ from css-tree walk
- Kept importantsInKeyframes with css-tree (requires atrule context)

All 228 tests passing - Wallace now handles:
- ✅ Rules counting
- ✅ Declarations counting
- ✅ Empty rules counting
- ✅ Important declarations counting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace manual check for declarations with Wallace's built-in is_empty flag.
This is a cleaner API than manually iterating children to check emptiness.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Wallace now handles all nesting depth tracking for aggregate collections:
- atruleNesting (depth when entering atrule)
- ruleNesting (depth when entering rule)
- selectorNesting (depth - 1 for selectors)
- declarationNesting (depth - 1 for declarations)

css-tree walk still maintains nestingDepth for location-based unique collections
which will be migrated once location format is unified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document that Wallace now handles nesting depth tracking for aggregate
collections. Update next migration targets to focus on simple metrics
like ruleSizes, selectorsPerRule, and declarationsPerRule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Wallace now handles:
- ruleSizes (selectors + declarations per rule)
- selectorsPerRule (count Selector nodes in SelectorList)
- declarationsPerRule (count Declaration nodes in Block)

Learned Wallace AST structure:
- Rule has children: [SelectorList, Block]
- SelectorList contains Selector nodes
- Block contains Declaration nodes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document Wallace now handles rule metrics (ruleSizes, selectorsPerRule,
declarationsPerRule). Add AST structure learnings about Rule/SelectorList/Block
hierarchy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

3 participants