Tee Ming 9 hours ago committed by GitHub
commit fa13a448cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: avoid Cloudflare warnings about not having the "node:crypto" module

@ -12,7 +12,8 @@ export async function sha256(data) {
crypto ??= globalThis.crypto?.subtle?.digest
? globalThis.crypto
: // @ts-ignore - we don't install node types in the prod build
(await import('node:crypto')).webcrypto;
// don't use 'node:crypto' because static analysers will think we rely on node when we don't
(await import('node:' + 'crypto')).webcrypto;
const hash_buffer = await crypto.subtle.digest('SHA-256', text_encoder.encode(data));

Loading…
Cancel
Save