Skip to content

fix(plugin): faster hashing#7338

Open
Sheraff wants to merge 5 commits intomainfrom
fix-plugin-faster-hashing
Open

fix(plugin): faster hashing#7338
Sheraff wants to merge 5 commits intomainfrom
fix-plugin-faster-hashing

Conversation

@Sheraff
Copy link
Copy Markdown
Contributor

@Sheraff Sheraff commented May 4, 2026

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.
  • Documentation
    • Updated examples and guides (ISR ETag generation and server-function IDs) to reflect the new hashing approach.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 46580d7d-93c8-460c-8dfa-d5895c47215f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b97a15 and 0afbadb.

📒 Files selected for processing (5)
  • .changeset/many-ads-smile.md
  • packages/router-generator/src/generator.ts
  • packages/router-utils/src/hash.ts
  • packages/router-utils/src/index.ts
  • packages/start-plugin-core/src/start-compiler/compiler.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/router-utils/src/hash.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/router-generator/src/generator.ts
  • packages/start-plugin-core/src/start-compiler/compiler.ts

📝 Walkthrough

Walkthrough

Replaces manual crypto.createHash(...).update(...).digest(...) usage with a new hash(algorithm, data, encoding) helper that prefers Node’s crypto.hash API when available. The helper is added and exported from @tanstack/router-utils, and callers in start-plugin-core and router-generator plus docs/examples are updated accordingly.

Changes

Hash API Modernization

Layer / File(s) Summary
Utility Implementation
packages/router-utils/src/hash.ts
Adds export function hash(algorithm, data, outputEncoding='hex') that uses crypto.hash if available, falling back to crypto.createHash(...).update(...).digest(...).
Public API
packages/router-utils/src/index.ts
Re-exports the new hash utility (export { hash } from './hash').
Implementation Updates
packages/start-plugin-core/src/start-compiler/compiler.ts, packages/router-generator/src/generator.ts
Replaces in-module crypto.createHash(...).update(...).digest(...) calls with the shared hash(...) helper for SHA256 and MD5 filename/ID generation; imports updated to use the helper.
Documentation Examples
docs/start/framework/react/guide/isr.md, docs/start/framework/react/guide/server-functions.md
Examples for ISR ETag generation and server function ID generation updated to show crypto.hash(...) usage instead of the older createHash().update().digest() pattern.
Release Note
.changeset/many-ads-smile.md
Changeset updated to mark patch releases and note the switch to the node:crypto hash API for single-string hashes.

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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing the old createHash pattern with the faster crypto.hash API for improved performance across hashing operations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-plugin-faster-hashing

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 4, 2026

View your CI Pipeline Execution ↗ for commit 2c9651c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 8m 59s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 53s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-04 20:07:32 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Changeset Version Preview

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

🟩 Patch bumps

Package Version Reason
@tanstack/router-generator 1.166.39 → 1.166.40 Changeset
@tanstack/router-utils 1.161.7 → 1.161.8 Changeset
@tanstack/start-plugin-core 1.169.17 → 1.169.18 Changeset
@tanstack/react-start 1.167.62 → 1.167.63 Dependent
@tanstack/react-start-rsc 0.0.41 → 0.0.42 Dependent
@tanstack/router-cli 1.166.40 → 1.166.41 Dependent
@tanstack/router-plugin 1.167.32 → 1.167.33 Dependent
@tanstack/router-vite-plugin 1.166.47 → 1.166.48 Dependent
@tanstack/solid-start 1.167.59 → 1.167.60 Dependent
@tanstack/vue-start 1.167.55 → 1.167.56 Dependent

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Bundle Size Benchmarks

  • Commit: ed3152af205e
  • Measured at: 2026-05-04T19:59:52.187Z
  • Baseline source: history:ed3152af205e
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.15 KiB 0 B (0.00%) 273.94 KiB 75.70 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-router.full 90.68 KiB 0 B (0.00%) 285.45 KiB 78.71 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-router.minimal 35.38 KiB 0 B (0.00%) 106.25 KiB 31.81 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-router.full 40.10 KiB 0 B (0.00%) 120.46 KiB 36.04 KiB ▅▅▅▅▅▅▅▅▅▅▅
vue-router.minimal 53.15 KiB 0 B (0.00%) 151.39 KiB 47.73 KiB ▅▅▅▅▅▅▅▅▅▅▅
vue-router.full 58.28 KiB 0 B (0.00%) 167.56 KiB 52.18 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-start.minimal 101.76 KiB 0 B (0.00%) 322.10 KiB 87.97 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-start.full 105.19 KiB 0 B (0.00%) 332.43 KiB 90.96 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-start.rsbuild.minimal 99.33 KiB 0 B (0.00%) 316.47 KiB 85.46 KiB ▅▅▅▅▅▅▅▅▅▅▅
react-start.rsbuild.full 102.63 KiB 0 B (0.00%) 326.90 KiB 88.28 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-start.minimal 49.40 KiB 0 B (0.00%) 152.08 KiB 43.60 KiB ▅▅▅▅▅▅▅▅▅▅▅
solid-start.full 55.20 KiB 0 B (0.00%) 168.98 KiB 48.51 KiB ▅▅▅▅▅▅▅▅▅▅▅

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 4, 2026

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: 0afbadb

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ed3152a and 1b97a15.

📒 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

Comment thread docs/start/framework/react/guide/server-functions.md
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 4, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix-plugin-faster-hashing (0afbadb) with main (ed3152a)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant