-
-
Notifications
You must be signed in to change notification settings - Fork 14
Replace css-tree with @projectwallace/css-parser #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bartveneman
wants to merge
19
commits into
main
Choose a base branch
from
pw-parser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 decrease total bundle size by 166.16kB (-59.35%) ⬇️. This is within the configured threshold ✅ Detailed changes
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.