Skip to content

perf(start-plugin-core): reduce Rspack N-API calls - #8784

Closed
SyMind wants to merge 1 commit into
TanStack:mainfrom
SyMind:codex/reduce-rspack-napi-calls
Closed

SyMind wants to merge 1 commit into
TanStack:mainfrom
SyMind:codex/reduce-rspack-napi-calls

Conversation

@SyMind

@SyMind SyMind commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Changes

Use ChunkGroup.getFiles() to collect dynamic imports in the Rsbuild client manifest. For a child group with N chunks, this replaces one chunks getter and N files getters with one N-API call, preserving filtering, deduplication, and file order.

Add a real Rspack compilation test covering shared chunks, CSS filtering, and nested dynamic imports. No wall-time speedup is claimed.

Validation:

  • pnpm test:unit
  • pnpm test:types
  • pnpm test:eslint
  • Targeted Rsbuild deferred-hydration E2E tests for preloading and nested boundary CSS.

AI-assisted implementation and PR preparation with Codex.

✅ 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).

Summary by CodeRabbit

  • Bug Fixes
    • Improved dynamic-import asset handling so shared JavaScript chunks appear in the appropriate import lists. CSS assets and nested lazy-loaded chunks are kept out of the entry’s direct dynamic-import list, while nested chunks remain associated with their importing chunk. This helps ensure client builds represent direct and nested imports accurately.

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bbb9908

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/start-plugin-core Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start Patch
@tanstack/solid-start Patch
@tanstack/vue-start Patch

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

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 8da6ad1e-0ea7-4c37-90be-69c1a257b557
📥 Commits

Reviewing files that changed from the base of the PR and between 08a419c and bbb9908.

📒 Files selected for processing: 3
  • .changeset/shy-boxes-think.md
  • packages/start-plugin-core/src/rsbuild/normalized-client-build.ts
  • packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

computeDynamicImports now reads emitted files from child chunk groups with getFiles(). A build test checks the resulting dynamic import lists for shared and nested chunks. A patch changeset records the update.

Changes: Dynamic import file collection

Layer / File(s) Summary
Collect and verify dynamic import files
packages/start-plugin-core/src/rsbuild/normalized-client-build.ts, packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts, .changeset/shy-boxes-think.md
computeDynamicImports now collects files with childGroup.getFiles() and retains the asset filter and deduplication. The build test checks shared, direct, and nested JavaScript chunks, and excludes CSS and the nested chunk from the entry list. A patch changeset describes the update.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: schiller-manuel, ladybluenotes

Merge Risk: ⚪ Minimal · up to bbb99

The dynamic-import collection change has no identified merge-blocking issue and is ready for normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main performance change: reducing Rspack N-API calls in start-plugin-core.
Description check Passed The description covers the change, motivation, validation, AI assistance, checklist, and release impact. It includes the required changeset information and relevant test details.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit bbb9908

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 22m 55s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 52s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-22 18:12:33 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8784

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8784

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8784

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8784

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8784

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8784

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8784

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8784

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8784

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8784

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8784

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8784

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8784

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8784

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8784

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8784

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8784

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8784

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8784

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8784

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8784

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8784

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8784

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8784

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8784

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8784

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8784

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8784

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8784

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8784

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8784

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8784

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8784

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8784

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8784

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8784

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8784

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8784

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8784

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8784

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8784

commit: bbb9908

@codspeed

codspeed Bot commented Oct 22, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

2 warnings

⚠️ 42 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 191 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory mem server error-paths redirect (solid) 11.2 KB 11.6 KB -3.36%
⚡ Memory mem client unique-location-churn (react) 80 KB 76.2 KB +5.04%
⚡ Memory mem client navigation-churn (solid) 112.7 KB 108.8 KB +3.58%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing SyMind:codex/reduce-rspack-napi-calls (bbb9908) with main (08a419c)

Open in CodSpeed

Footnotes

  1. 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. ↩

@SyMind SyMind closed this Oct 23, 2026
@SyMind
SyMind deleted the codex/reduce-rspack-napi-calls branch October 23, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant