Repository navigation
Replace css-tree with @projectwallace/css-parser - #488
Conversation
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>
Bundle ReportChanges will increase total bundle size by 59.51kB (21.25%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: analyzeCss-esmAssets Changed:
Files in
|
…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>
Key learnings from attempted property migration: - Wallace only parses valid CSS, skips hacks like *zoom - Properties with browser hacks must stay in css-tree - Block nodes appear in both children[] and block property - Walking both causes double-counting (walk children only) This blocks migration of property tracking since hack detection is needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
partially unblocks projectwallace/css-analyzer#488
Technically a breaking change:
/*and*/charactersmargin: 10px !iebrowser hacksselectorComplexityandisValuePrefixedwork the same but only on@projectwallace/css-parserAST, not CSSTree.New:
calculateSpecificityis now exportedTechnical considerations:
@bramus/specificitybecause I need it to work with the new AST, not CSSTree's. Planning to prose a 'fix' upstream, but I can see reasons to keep the main repo CSSTree based.