Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/rstack/src/fmt/cacheIdentity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createHash } from 'node:crypto';
import { hash } from 'node:crypto';
import { isAbsolute } from 'node:path';
import stableStringify from 'fast-json-stable-stringify';
import { fmtCacheVersion } from './cacheStore.ts';
Expand All @@ -12,8 +12,7 @@ type CacheKeyResolver = (filePath: string) => string | undefined;
type OptionsHasher = (options: ResolvedFmtOptions) => string | undefined;
type PluginFingerprints = ReadonlyMap<string, string>;

const sha256 = (content: string | Uint8Array): string =>
createHash('sha256').update(content).digest('hex');
const sha256 = (content: string | Uint8Array): string => hash('sha256', content, 'hex');

/** Identifies formatter behavior shared by all cache entries in this process. */
const cacheNamespace: string = JSON.stringify([fmtCacheVersion, RSTACK_VERSION, PRETTIER_VERSION]);
Expand Down
5 changes: 2 additions & 3 deletions packages/rstack/src/fmt/worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Derived from @prettier/cli, see THIRD_PARTY_NOTICES.md

import { createHash } from 'node:crypto';
import { hash } from 'node:crypto';
import { readFileSync, writeFileSync } from 'node:fs';
import type { FmtCacheEntry } from './cacheStore.ts';
import type { FmtFileCache, FmtFileRequest, FmtWorkerResult } from './types.ts';
Expand All @@ -11,8 +11,7 @@ interface FormatFileTask {
cache?: FmtFileCache;
}

const hashContent = (content: string | Uint8Array): string =>
createHash('sha256').update(content).digest('hex');
const hashContent = (content: string | Uint8Array): string => hash('sha256', content, 'hex');

/**
* Use synchronous direct I/O inside the dedicated worker to avoid libuv
Expand Down