Skip to content
Source
Sign inSign up
TanStack/router

fix(plugin): faster hashing #7338

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 6 commits intomain fromfix-plugin-faster-hashingopened

Yagiz said it was faster, let's see.

crypto.hash(algorithm, data[, options]) nodejs docs Added in: v21.7.0, v20.12.0 History: v25.4.0 | This API is no longer experimental.

Benchmarks

Isolation micro-benchmark (just comparing node native modules)

Screenshot 2026-05-04 at 20 59 20

Full benchmark (running full plugin with mocked filesystem)

Screenshot 2026-05-04 at 21 12 58 Screenshot 2026-05-04 at 21 12 50

Summary by CodeRabbit

  • Chores
    • Switched internal hash computation to use Node.js’ modern hashing API across packages and build tooling.
    • Added and published a reusable hash utility in the router utilities package.
  • Documentation
    • Updated examples and guides (ISR ETag generation and server-function ID examples) to reflect the new hashing approach.

Review Change Stack

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-generator

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core

    4. No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 56e5731f-533b-46f2-9329-a52284696268

      📥 Commits

      Reviewing files that changed from the base of the PR and between 0afbadb494866bf685e90ae2fe761318f052433c and 970a9579d87eefa7d2aee6dbe8bbe08d94d6c79c.

      📒 Files selected for processing (1)
      • docs/start/framework/react/guide/server-functions.md
      ✅ Files skipped from review due to trivial changes (1)
      • docs/start/framework/react/guide/server-functions.md

      📝 Walkthrough

      Walkthrough

      Replaces manual crypto.createHash(...).update(...).digest(...) usage with a new exported hash(algorithm, data, encoding) helper that prefers Node’s crypto.hash API; callers in start-plugin-core and router-generator plus docs/examples and the changeset are updated to use it.

      Changes

      Hash API Modernization

      Layer / File(s)Summary
      Utility implementation
      packages/router-utils/src/hash.ts, packages/router-utils/src/index.ts
      Adds export function hash(algorithm, data, outputEncoding='hex') using crypto.hash when available and re-exports it from the package index.
      Start plugin core update
      packages/start-plugin-core/src/start-compiler/compiler.ts
      Replaces production crypto.createHash('sha256')... with hash('sha256', entryId, 'hex') and adjusts imports accordingly.
      Router generator update
      packages/router-generator/src/generator.ts
      Imports hash as hashString and replaces crypto.createHash('md5')... with hashString('md5', absPath, 'hex') for temp filename hashing.
      Documentation examples
      docs/start/framework/react/guide/isr.md, docs/start/framework/react/guide/server-functions.md
      Examples updated to show `crypto.hash('md5'
      Release note
      .changeset/many-ads-smile.md
      Patch bumps and a note that single-string hashes now prefer node:crypto's hash API.

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~12 minutes

      Poem

      🐰 From chains of updates to one-call delight, a helper hops in to make hashing light. MD5, SHA1, SHA256 in a line, one gentle call — the code feels fine. ✨

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title accurately summarizes the main change: replacing createHash().update().digest() with the faster crypto.hash() API across multiple packages for improved hashing performance.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `fix-plugin-faster-hashing`

      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    5. View your CI Pipeline Execution ↗ for commit 970a9579d87eefa7d2aee6dbe8bbe08d94d6c79c

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded7m 49sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded2m 19sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-05-22 18:52:06 UTC

    6. 🚀 Changeset Version Preview

      3 package(s) bumped directly, 7 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/router-generator1.167.9 → 1.167.10Changeset
      @tanstack/router-utils1.162.1 → 1.162.2Changeset
      @tanstack/start-plugin-core1.171.3 → 1.171.4Changeset
      @tanstack/react-start1.168.10 → 1.168.11Dependent
      @tanstack/react-start-rsc0.1.10 → 0.1.11Dependent
      @tanstack/router-cli1.167.9 → 1.167.10Dependent
      @tanstack/router-plugin1.168.10 → 1.168.11Dependent
      @tanstack/router-vite-plugin1.167.10 → 1.167.11Dependent
      @tanstack/solid-start1.168.10 → 1.168.11Dependent
      @tanstack/vue-start1.168.10 → 1.168.11Dependent
    7. Bundle Size Benchmarks

      • Commit: dd246ca8bcf3
      • Measured at: 2026-05-22T18:45:15.116Z
      • Baseline source: history:b47b338d15de
      • Dashboard: bundle-size history
      ScenarioCurrent (gzip)Delta vs baselineInitial gzipRawBrotliTrend
      react-router.minimal87.29 KiB0 B (0.00%)87.16 KiB274.02 KiB75.93 KiB█████▁▁▁▁▁▁
      react-router.full90.82 KiB0 B (0.00%)90.69 KiB285.52 KiB78.75 KiB▆▆▆▆█▁▁▁▁▁▁
      solid-router.minimal35.53 KiB0 B (0.00%)35.41 KiB106.33 KiB31.95 KiB▅████▁▁▁▁▁▁
      solid-router.full40.28 KiB0 B (0.00%)40.15 KiB120.53 KiB36.20 KiB▁▂▂▂▃▄▄▄▄██
      vue-router.minimal53.33 KiB0 B (0.00%)53.20 KiB151.46 KiB47.88 KiB▇▇▇▇▁▅▅▅▅██
      vue-router.full58.45 KiB0 B (0.00%)58.32 KiB167.63 KiB52.35 KiB▆▆▆▆▁▆▆▆▆██
      react-start.minimal102.03 KiB0 B (0.00%)101.89 KiB322.47 KiB88.29 KiB▁▄▄▄▃▆▆▆▆██
      react-start.deferred-hydration103.07 KiB0 B (0.00%)102.20 KiB324.12 KiB89.21 KiB████▁▁▁▁▂▂
      react-start.full105.43 KiB0 B (0.00%)105.29 KiB332.79 KiB91.17 KiB▆████▁▁▁▁▃▃
      react-start.rsbuild.minimal99.64 KiB0 B (0.00%)99.46 KiB316.93 KiB85.73 KiB▆▆▆▆▁██████
      react-start.rsbuild.full102.93 KiB0 B (0.00%)102.76 KiB327.34 KiB88.59 KiB▇▇▇▇▁▂▂▂▂██
      solid-start.minimal49.67 KiB0 B (0.00%)49.54 KiB152.46 KiB43.87 KiB▁███▇▄▄▄▄▄▄
      solid-start.deferred-hydration53.74 KiB0 B (0.00%)50.40 KiB161.00 KiB47.74 KiB███▇▁▁▁▁▁▁
      solid-start.full55.46 KiB0 B (0.00%)55.33 KiB169.35 KiB48.80 KiB▁███▆▆▆▆▆▇▇

      Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

    8. More templates

      @tanstack/arktype-adapter

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

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

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

      @tanstack/history

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

      @tanstack/nitro-v2-vite-plugin

      npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7338

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

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

      @tanstack/react-start-client

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

      @tanstack/react-start-rsc

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

      @tanstack/react-start-server

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

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

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

      @tanstack/solid-start-client

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

      @tanstack/solid-start-server

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

      @tanstack/start-client-core

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

      @tanstack/start-fn-stubs

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

      @tanstack/start-plugin-core

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

      @tanstack/start-server-core

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

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

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

      @tanstack/valibot-adapter

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

      @tanstack/virtual-file-routes

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

      @tanstack/vue-router

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

      @tanstack/vue-router-devtools

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

      @tanstack/vue-router-ssr-query

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

      @tanstack/vue-start

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

      @tanstack/vue-start-client

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

      @tanstack/vue-start-server

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

      @tanstack/zod-adapter

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

      commit: 970a957

    9. Actionable comments posted: 1

      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Inline comments:
      In `@docs/start/framework/react/guide/server-functions.md`:
      - Line 382: The example calls crypto.hash in the snippet but never imports
      crypto; add an explicit import for Node's crypto module at the top of the
      example (e.g. import or require the 'crypto' module) so the return statement
      using crypto.hash(`${filename}--${functionName}`,'hex') is runnable; update the
      snippet surrounding the function that returns crypto.hash(...) to include that
      import.
      🪄 Autofix (Beta)

      Fix all unresolved CodeRabbit comments on this PR:

      • Push a commit to this branch (recommended)
      • Create a new PR with the fixes

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 121c8622-6a8f-47eb-9615-e026d715d414

      📥 Commits

      Reviewing files that changed from the base of the PR and between ed3152af205e00d99a262c0e283f7989894219ab and 1b97a1525dd9db2e49537ce4d806935455c3a9a4.

      📒 Files selected for processing (5)
      • .changeset/many-ads-smile.md
      • docs/start/framework/react/guide/isr.md
      • docs/start/framework/react/guide/server-functions.md
      • packages/router-generator/src/generator.ts
      • packages/start-plugin-core/src/start-compiler/compiler.ts
      Resolvedby Sheraff(GitHub profile, opens in a new tab)
    10. Merging this PR will not alter performance

      ✅ 4 untouched benchmarks ⏩ 2 skipped benchmarks1


      Comparing fix-plugin-faster-hashing (970a957) with main (b47b338)[^unexpected-base] Open in CodSpeed

      Footnotes

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

    11. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-utils

    12. Important

      At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

      Nx Cloud is proposing a fix for your failed CI:

      We rename the local exports Map variable in extractModuleInfo to namedExports to fix the five import/no-commonjs ESLint errors introduced when the PR removed the blanket /* eslint-disable import/no-commonjs */ comment from compiler.ts. The rule was incorrectly flagging exports.set(...) calls as CommonJS patterns because the identifier exports is reserved by the rule, even though the variable is a plain local Map<string, string>.

      Tip

      ✅ We verified this fix by re-running @tanstack/start-plugin-core:test:eslint, tanstack-router-e2e-vue-basepath-file-based:test:e2e.

      Suggested Fix changes
      diff --git a/packages/start-plugin-core/src/start-compiler/compiler.ts b/packages/start-plugin-core/src/start-compiler/compiler.ts
      index ed75e5be..f86a1b84 100644
      --- a/packages/start-plugin-core/src/start-compiler/compiler.ts
      +++ b/packages/start-plugin-core/src/start-compiler/compiler.ts
      @@ -764,7 +764,7 @@ export class StartCompiler {
           id: string,
         ): ModuleInfo {
           const bindings = new Map<string, Binding>()
      -    const exports = new Map<string, string>()
      +    const namedExports = new Map<string, string>()
           const reExportAllSources: Array<string> = []
       
           // we are only interested in top-level bindings, hence we don't traverse the AST
      @@ -807,7 +807,7 @@ export class StartCompiler {
                 if (t.isVariableDeclaration(node.declaration)) {
                   for (const d of node.declaration.declarations) {
                     if (t.isIdentifier(d.id)) {
      -                exports.set(d.id.name, d.id.name)
      +                namedExports.set(d.id.name, d.id.name)
                       bindings.set(d.id.name, { type: 'var', init: d.init ?? null })
                     }
                   }
      @@ -815,7 +815,7 @@ export class StartCompiler {
               }
               for (const sp of node.specifiers) {
                 if (t.isExportNamespaceSpecifier(sp)) {
      -            exports.set(sp.exported.name, sp.exported.name)
      +            namedExports.set(sp.exported.name, sp.exported.name)
                 }
                 // export { local as exported }
                 else if (t.isExportSpecifier(sp)) {
      @@ -823,7 +823,7 @@ export class StartCompiler {
                   const exported = t.isIdentifier(sp.exported)
                     ? sp.exported.name
                     : sp.exported.value
      -            exports.set(exported, local)
      +            namedExports.set(exported, local)
       
                   // When re-exporting from another module (export { foo } from './module'),
                   // create an import binding so the server function can be resolved
      @@ -839,11 +839,11 @@ export class StartCompiler {
             } else if (t.isExportDefaultDeclaration(node)) {
               const d = node.declaration
               if (t.isIdentifier(d)) {
      -          exports.set('default', d.name)
      +          namedExports.set('default', d.name)
               } else {
                 const synth = '__default_export__'
                 bindings.set(synth, { type: 'var', init: d as t.Expression })
      -          exports.set('default', synth)
      +          namedExports.set('default', synth)
               }
             } else if (t.isExportAllDeclaration(node)) {
               // Handle `export * from './module'` syntax
      @@ -855,7 +855,7 @@ export class StartCompiler {
           const info: ModuleInfo = {
             id,
             bindings,
      -      exports,
      +      exports: namedExports,
             reExportAllSources,
           }
           this.moduleCache.set(id, info)
      

      Apply fix via Nx Cloud  Reject fix via Nx Cloud


      Or Apply changes locally with:

      npx nx-cloud apply-locally 69ER-lBKK
      Apply fix locally with your editor ↗   View interactive diff ↗

      🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)
    13. packages/start-plugin-core/src/start-compiler/compiler.ts line 635
      @@ -600,4 +599,4 @@
      600599 })
      601600 }
      602601 if (!functionId) {
      603- functionId = crypto.createHash('sha256').update(entryId).digest('hex')
      602+ functionId = hash('sha256', entryId, 'hex')

      Since we're on a roll with modernizing things, what do you think about functionId ??= hash('sha256', entryId, 'hex')? I have a personal vendetta against the ! operator it looks like a tiny person shouting at my code 😂

Sign in to join this conversation.