fix(@angular/build): use sha256 instead of sha-256 as hash algorithm name

Stackblitz appears to fail when attempting to use `crypto.createHash` with
an algorithm value of `sha-256`. Since Node.js supports both the hyphenated
and unhyphenated values, the later is now used to avoid issues when running
on Stackblitz.
This commit is contained in:
Charles Lyding 2024-11-21 11:39:11 -05:00 committed by Charles
parent a9a871c414
commit 1ded0b756b
2 changed files with 2 additions and 2 deletions

View File

@ -198,7 +198,7 @@ export function createCompilerPlugin(
// invalid the output and force a full page reload for HMR cases. The containing file and order
// of the style within the containing file is used.
pluginOptions.externalRuntimeStyles
? createHash('sha-256')
? createHash('sha256')
.update(containingFile)
.update((order ?? 0).toString())
.update(className ?? '')

View File

@ -231,7 +231,7 @@ function generateInitHelper(streaming: boolean, wasmContents: Uint8Array) {
let resultContents;
if (streaming) {
const fetchOptions = {
integrity: 'sha256-' + createHash('sha-256').update(wasmContents).digest('base64'),
integrity: 'sha256-' + createHash('sha256').update(wasmContents).digest('base64'),
};
const fetchContents = `fetch(new URL(wasmPath, import.meta.url), ${JSON.stringify(fetchOptions)})`;
resultContents = `await WebAssembly.instantiateStreaming(${fetchContents}, imports)`;