perf: optimize isGriffelCSSModule, add processAssets timing#826
Draft
layershifter wants to merge 11 commits intomicrosoft:mainfrom
Draft
perf: optimize isGriffelCSSModule, add processAssets timing#826layershifter wants to merge 11 commits intomicrosoft:mainfrom
layershifter wants to merge 11 commits intomicrosoft:mainfrom
Conversation
- Replace buffer content scanning with module.identifier() path check - Remove unused CSSModule type and isCSSModule function - Add timing for processAssets hook (CSS sorting) to stats output Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📊 Bundle size report✅ No changes found |
Adds per-phase timings to TransformResult (parsing, walking, evaluation, resolving, codeTransform) and per-operation timings in Module (transform/shaker, ESM→CJS, vm.runInContext, fs.readFileSync). Reported in stats output when collectStats is enabled. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace per-call vm.createContext() with a single shared context whose per-module bindings (module, exports, require, __filename, __dirname) are swapped before each script.runInContext(). This avoids the overhead of creating a new V8 sandbox for every module evaluation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…uild, dead code removal) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…en nested requires The shared VM context sandbox gets mutated by nested require() calls, causing earlier modules to see later modules' exports. Fix by passing module, exports, require, __filename, __dirname as function parameters to the wrapper IIFE, capturing them at call time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Cache getVisitors() by node type (avoids array allocations per AST node) - Replace forEach with for loops in baseVisit and callbacks - Inline addEdge resolution for non-PromisedNode (skip action queue) - Replace stack.unshift/shift with push/pop (O(1) instead of O(n)) - Replace stack.find() with reverse for loops (innermost-first) - Replace visitors.shift() with index-based iteration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove per-phase timings from transformSync, Module, and shaker. Keep only the existing processAssetsTime and per-file time/evaluationMode stats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
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.
Summary
Buffer.indexOf('/** @griffel:css-start')) withmodule.identifier().includes(virtualLoaderPath)— avoids reading CSS content for every moduleCSSModuletype andisCSSModulefunctionprocess.hrtime.bigint()timing around theprocessAssetshook (CSS parsing + sorting), reported in stats as "Time spent in processAssets (sort)"Test plan
🤖 Generated with Claude Code