Skip to content

refactor(workbench): share one Web Crypto hash helper#1577

Draft
gu-stav wants to merge 1 commit into
mainfrom
workbench-hash-dedup
Draft

refactor(workbench): share one Web Crypto hash helper#1577
gu-stav wants to merge 1 commit into
mainfrom
workbench-hash-dedup

Conversation

@gu-stav

@gu-stav gu-stav commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

Follow-up to #1575. Bugbot flagged that buildAppId (appId.ts) and deriveConfigs (deriveInterfaces.ts) each inlined the same Web Crypto SHA-256 hex digest — two copies that can drift on a future algorithm/encoding change.

Extracts a single contentHash helper both call, and hoists appId.ts's canonical interface-sort out of buildAppId (it closed over nothing). No behavior change — same SHA-256 hex.

What to review

  • contentHash.ts — the shared helper (Web Crypto, browser-safe).
  • appId.ts / deriveInterfaces.ts now delegate to it.

Testing

Existing appId.test.ts and deriveInterfaces.test.ts cover it; output is unchanged.

Notes for release

N/A

buildAppId and deriveConfigs each inlined the same SHA-256 hex digest. Extract
`contentHash` so a future algorithm or encoding change touches one place.
@gu-stav

gu-stav commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

This change is part of the following stack:

Change managed by git-spice.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (d3e59eb0)

@sanity/cli

Metric Value vs main (d3e59eb)
Internal (raw) 2.2 KB -
Internal (gzip) 838 B -
Bundled (raw) 11.20 MB -
Bundled (gzip) 2.11 MB -
Import time 873ms +4ms, +0.4%

bin:sanity

Metric Value vs main (d3e59eb)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.90 MB -
Bundled (gzip) 1.78 MB -
Import time 2.08s +15ms, +0.7%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (d3e59eb0)

Metric Value vs main (d3e59eb)
Internal (raw) 114.1 KB -
Internal (gzip) 29.2 KB -
Bundled (raw) 21.76 MB -
Bundled (gzip) 3.46 MB -
Import time 767ms -6ms, -0.8%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-build

Compared against main (d3e59eb0)

@sanity/cli-build/_internal/build

Metric Value vs main (d3e59eb)
Internal (raw) 113.8 KB -
Internal (gzip) 28.7 KB -
Bundled (raw) 17.76 MB -
Bundled (gzip) 3.56 MB -
Import time 1.12s -9ms, -0.8%

@sanity/cli-build/_internal/env

Metric Value vs main (d3e59eb)
Internal (raw) 1.8 KB -
Internal (gzip) 644 B -
Bundled (raw) 1.31 MB -
Bundled (gzip) 333.8 KB -
Import time 123ms +1ms, +0.9%

@sanity/cli-build/_internal/extract

Metric Value vs main (d3e59eb)
Internal (raw) 8.6 KB -
Internal (gzip) 2.7 KB -
Bundled (raw) 155.0 KB -
Bundled (gzip) 39.5 KB -
Import time 239ms -4ms, -1.6%

🗺️ ./_internal/env · ./_internal/extract · @sanity/cli-build:./_internal/build treemap too large to embed · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (d3e59eb0)

Metric Value vs main (d3e59eb)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/workbench-cli/src/actions/dev/deriveInterfaces.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/appId.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/contentHash.ts 100.0% (new)

Comparing 3 changed files against main @ d3e59eb08ac3746fc03db6ddedf60fef5f47244c

Overall Coverage

Metric Coverage
Statements 78.2% (- 0.0%)
Branches 69.5% (±0%)
Functions 74.0% (- 0.0%)
Lines 78.6% (- 0.0%)

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