Repository navigation
perf(bundler): reduce unplugin transform overhead - #782
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds shared transform helpers, updates bundler unplugin transforms to use them, wraps server-side plugins with code filters, adds head-composable early exits in streaming plugins, and introduces a benchmark suite plus matching test updates. ChangesTransform parsing helpers, plugin filters, and streaming guards
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle Size Analysis
|
Benchmark notesRan locally with: pnpm vitest bench bench/unplugin-transform.bench.ts --runVitest bench reports mean time per sample. Latest run on
Headline before/after from the initial baseline in this branch work:
The biggest practical win is on skip paths: native transform filters avoid entering JS handlers for unrelated modules, and React/Solid streaming avoids AST parsing on JSX files without head composables. |
🔗 Linked issue
None
❓ Type of change
📚 Description
Speeds up the unplugin hot paths by replacing URL parsing in
transformIncludewith simple id/query parsing and skipping React/Solid/Svelte streaming AST work when files have no head composables.Adds native code filters for the remaining server-composable and
head.ssrtransforms, while keeping the existing in-handler guards for bundlers that do not apply transform filters. Includes a Vitest benchmark for the transform filters, create-head wrapping, minify transform, SSR replacement, and streaming skip paths.📊 Benchmarks
Ran locally with:
Vitest bench reports mean time per sample. Latest run on
perf/unplugin-cpu:transformInclude mixed ids0.1281msuseSeoMetaTransform static calls1.4683msminifyTransform inline script/style0.2526mstreeshakeServerComposables many calls1.3443mstreeshakeServerComposables skip unrelated code0.0009msssrStaticReplace many head.ssr reads0.1709msssrStaticReplace skip unrelated code0.0009mscreateHeadTransform many createHead calls0.3197msreact streaming skip JSX without head calls0.0106msreact streaming transform JSX with head calls0.8371mssolid streaming skip JSX without head calls0.0107msHeadline before/after from the initial baseline in this branch work:
transformInclude mixed ids4.6990ms0.1281ms36.7xfasterreact streaming skip JSX without head calls0.9437ms0.0106ms89.0xfastersolid streaming skip JSX without head calls0.9346ms0.0107ms87.3xfastercreateHeadTransform many createHead calls0.3569ms0.3197ms1.1xfaster