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
4 changes: 2 additions & 2 deletions packages/core/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from 'node:crypto';
import { posix } from 'node:path';
import { URL } from 'node:url';
import deepmerge from 'deepmerge';
Expand Down Expand Up @@ -366,7 +365,8 @@ export const addCompilationError = (
);
};

export function hash(data: string): string {
export async function hash(data: string): Promise<string> {
const crypto = await import('node:crypto');
// Available in Node.js v20.12.0
// faster than `crypto.createHash()` when hashing a smaller amount of data (<= 5MB)
if (crypto.hash) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const pluginCache = (): RsbuildPlugin => ({

// set cache name to avoid cache conflicts between different environments
const cacheVersion = useDigest
? `${environment.name}-${env}-${hash(JSON.stringify(cacheConfig.cacheDigest))}`
? `${environment.name}-${env}-${await hash(JSON.stringify(cacheConfig.cacheDigest))}`
: `${environment.name}-${env}`;

if (bundlerType === 'rspack') {
Expand Down
Loading