perf(start-plugin-core): run the Rsbuild metadata loader right after the Start transform #8749
main fromrefs/pull/8749/head·opened 🎯 Changes#
Motivation#
- On Rsbuild, Start records the server functions it finds in each module in the module's
buildInfo, so modules restored from Rspack's persistent cache keep their server functions. - A small loader writes that metadata, and it ran in the post phase, after
builtin:swc-loader. - Rspack runs consecutive JavaScript loaders in one pass and returns to Rust at each builtin loader, so a JavaScript loader after SWC needs its own pass.
- Each pass converts the module source between Rust and JavaScript and runs the JavaScript loader runner.
Changes#
- The metadata loader rule is now the first rule and runs in the pre phase. Pre loaders run right to left, so it runs right after the Start transform and before normal loaders such as
builtin:swc-loader, in the same JavaScript loader pass as the transform. - The improvement only applies when import protection is disabled. Start's import-protection loader also runs after SWC, so with import protection enabled each module still needs a second pass. #8748 skips that loader when import protection is disabled. With both changes, such apps need one JavaScript loader pass instead of two for each module that SWC compiles.
- Production module ids and chunk hashes change once, because the loader chain is part of each module's identifier. The emitted code does not change: with named ids, every output file has the same lines, at most with modules in a different order.
COMPILER_ARCHITECTURE.mdnow says pre instead of post.
Tests#
@tanstack/start-plugin-coretest:unit,test:typesandtest:eslintpass. Thecustom-server-rsbuilde2e passes in dev and prod (it uses Rspack's persistent cache), theserver-functionse2e passes for Rsbuild SSR from a fresh build and for the Rsbuild cache spec, and thereact-start/rsbuilde2e passes.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
- I fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
- 1
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: TanStack/router/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
eab6833a-50f5-43a3-a493-ac38f08f6ae8
📥 Commits
-
Reviewing files that changed from the base of the PR and between 76cd9e178d2e2b8c08c9f101dc3e11887dc7d651 and c2c24a507d376e120e8bfa67682557c066b13edf.
📒 Files selected for processing: 6
-
.changeset/start-metadata-loader-pre-phase.mde2e/react-start/custom-server-rsbuild/src/functions/inline-loader-fn.jse2e/react-start/custom-server-rsbuild/src/routes/index.tsxe2e/react-start/custom-server-rsbuild/tests/server-fns.spec.tspackages/start-plugin-core/src/rsbuild/COMPILER_ARCHITECTURE.mdpackages/start-plugin-core/src/rsbuild/start-compiler-host.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
📝 Walkthrough
-
The Rsbuild metadata loader now runs in the pre phase. The custom-server example adds a server function imported with a
!prefix, and an end-to-end test checks its greeting.Changes: Rsbuild metadata loader
Layer / File(s) Summary Set the metadata loader phase
packages/start-plugin-core/src/rsbuild/start-compiler-host.ts,packages/start-plugin-core/src/rsbuild/COMPILER_ARCHITECTURE.md,.changeset/start-metadata-loader-pre-phase.mdThe metadata-loader rule is prepended to the module rules and uses enforce: 'pre'. The documentation and changeset describe the loader phase and related production module ID and chunk hash changes.Exercise an inline-loader server function
e2e/react-start/custom-server-rsbuild/src/functions/inline-loader-fn.js,e2e/react-start/custom-server-rsbuild/src/routes/index.tsx,e2e/react-start/custom-server-rsbuild/tests/server-fns.spec.tsThe example imports and calls getInlineLoaderGreetingthrough a!-prefixed path. The test checks that clicking the button displays the returned greeting.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Sequence Diagram(s)#
sequenceDiagram participant StartTransform participant MetadataLoader participant BuiltinSWC StartTransform->>MetadataLoader: transform completes MetadataLoader->>BuiltinSWC: loader processes module before builtin SWCSuggested reviewers:
schiller-manuel
Merge Risk: ⚪ Minimal · up to
c2c24-
The metadata loader runs after the Start transform and preserves metadata for the inline-loader server-function path. No actionable merge-blocking risk is established; the change is ready to merge subject to normal checks.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Description check The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, performance effect, production impact, documentation update, and test… Title check The title clearly and concisely describes the main performance change: moving the Rsbuild metadata loader after the Start transform. Full details: Description check
-
Explanation
The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, implementation, performance effect, production impact, documentation update, and test results. All checklist items are addressed, and a changeset is noted.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
- Fix all pre-merge checks with AI
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 `@coderabbitai help` to get the list of available commands.-
View your CI Pipeline Execution ↗ for commit bb24862e88b32b82f8920c570df2b31575e49c8e
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 20m 48s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 43s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-19 06:37:40UTCMore templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@8749@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8749@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8749@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@8749@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@8749@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@8749@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8749@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@8749@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@8749@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@8749@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@8749@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@8749@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@8749@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@8749@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@8749@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@8749@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@8749@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8749@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@8749@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8749@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@8749@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8749@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8749@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@8749@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@8749@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@8749@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@8749@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8749@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@8749@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@8749@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8749@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@8749@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@8749@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8749@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@8749@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8749@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8749@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@8749@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@8749@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@8749@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@8749commit:
bb24862Merging this PR will degrade performance by 0.65%#
:warning: 48 benchmarks spent significant time in system calls
System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.
ssr control-flow unmatched 404 (vue)ssr control-flow error 500 (react)client-link-churn navigation loop (react)ssr assets inline-css cdn (vue)client-link-churn navigation loop (vue)client-search-params navigation loop (solid)ssr rewrite passthrough (react)ssr request loop (vue)client-side navigation loop (vue)client-nested-params navigation loop (solid)- …and 38 more
:information_source: 3 benchmarks have no flame graph
The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.
:warning: Different runtime environments detected
Some benchmarks with significant performance changes were compared across different runtime environments, which may affect the accuracy of the results.
⚡ 1improved benchmark❌ 1regressed benchmark✅ 192untouched benchmarks⏩ 3skipped benchmarks1Warning
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes#
Mode Benchmark BASEHEADEfficiency ❌ Memory mem server error-paths redirect (solid)11.6 KB 12.3 KB -5.22% ⚡ Memory mem client navigation-churn (solid)113.8 KB 109.3 KB +4.15% Tip
Investigate this regression by commenting
@codspeedbot fix this regressionon this PR, or directly use the CodSpeed MCP with your agent.
Comparingguru-irl:perf/start-metadata-loader-pre-phase(bb24862) withmain(b1b1117)Footnotes#
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: bb24862e88b32b82f8920c570df2b31575e49c8e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR