Skip to content

perf(start): reduce Rspack N-API calls for dynamic imports - #8785

Open
SyMind wants to merge 3 commits into
TanStack:mainfrom
SyMind:codex/reuse-rspack-client-build-reads
Open

SyMind wants to merge 3 commits into
TanStack:mainfrom
SyMind:codex/reuse-rspack-client-build-reads

Conversation

@SyMind

@SyMind SyMind commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Changes

Collect dynamic-import files with ChunkGroup.getFiles() instead of traversing childGroup.chunks and reading each chunk.files. This reduces N-API calls while preserving file order, deduplication, and JS/HMR filtering.

Validation: affected ESLint, type checks, and unit tests passed locally.

Implemented with AI assistance.

✅ 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

  • Improvements
    • Client dynamic-import collection now processes chunk-group files in bulk, reducing calls to the build system and streamlining client build processing.
    • Unique JavaScript assets continue to be included, while hot-update assets remain excluded.

@changeset-bot

changeset-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67b8c1c

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: 7afef0f8-0de1-4911-b29a-c23487ff25eb
📥 Commits

Reviewing files that changed from the base of the PR and between 13c2696 and 67b8c1c.

📒 Files selected for processing: 2
  • .changeset/shy-boxes-think.md
  • packages/start-plugin-core/src/rsbuild/normalized-client-build.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • .changeset/shy-boxes-think.md

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

The client build normalizer now reads files from each child chunk group when collecting dynamic imports. It retains manifest JavaScript filtering and deduplication. A patch changeset records the update.

Changes: Client Asset Collection

Layer / File(s) Summary
Chunk-group file collection
packages/start-plugin-core/src/rsbuild/normalized-client-build.ts, .changeset/shy-boxes-think.md
computeDynamicImports now reads files from each child chunk group with getFiles() instead of traversing chunk files. Manifest JavaScript filtering and deduplication remain. The changeset records the patch.

Priority: ⬇️ Low

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

Change: Refactor

Suggested reviewers: schiller-manuel

Merge Risk: ⚪ Minimal · up to 67b8c

The optimization reads the same dynamic-import assets, and the within-chunk ordering difference does not alter the hydration stylesheet list in the verified path. No actionable merge risk remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the performance change and its scope: reducing Rspack N-API calls during dynamic-import collection.
Description check Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains the implementation and motivation, reports validation, discloses AI assistance, and confirms that a c…
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 1 functions across 1 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: Description check

Explanation

The description includes the required Changes, Checklist, and Release Impact sections. It explains the implementation and motivation, reports validation, discloses AI assistance, and confirms that a changeset was generated. Two checklist items remain unchecked, but the description is otherwise complete.

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 1 functions across 1 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.

@SyMind SyMind changed the title perf(start): reduce Rspack client build API reads perf(start): reduce Rspack N-API calls in client manifest generation Oct 22, 2026
@SyMind
SyMind marked this pull request as draft October 22, 2026 04:08
@SyMind SyMind closed this Oct 22, 2026
@SyMind SyMind reopened this Oct 22, 2026
@SyMind SyMind changed the title perf(start): reduce Rspack N-API calls in client manifest generation perf(start): reduce Rspack N-API calls for dynamic imports Oct 22, 2026
@SyMind
SyMind marked this pull request as ready for review October 22, 2026 05:55
@nx-cloud

nx-cloud Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 67b8c1c

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

☁️ Nx Cloud last updated this comment at 2026-10-22 18:14:42 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@8785

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 67b8c1c

@codspeed

codspeed Bot commented Oct 22, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.76%

2 warnings

⚠️ 39 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

⚡ 3 improved benchmarks
✅ 191 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory mem client unique-location-churn (react) 80 KB 74.2 KB +7.93%
⚡ Memory mem client interrupted-navigations (react) 93.4 KB 90.4 KB +3.42%
⚡ Memory mem client interrupted-navigations (vue) 97 KB 94.2 KB +3%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing SyMind:codex/reuse-rspack-client-build-reads (67b8c1c) 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. ↩

This branch has not been deployed

No deployments
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