Skip to content

Commit

Permalink
fix(@angular/build): use sha256 instead of sha-256 as hash algori…
Browse files Browse the repository at this point in the history
…thm 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.

(cherry picked from commit 1ded0b7)
  • Loading branch information
clydin committed Nov 21, 2024
1 parent b63123f commit 1b4dced
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '')
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/tools/esbuild/wasm-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)`;
Expand Down

0 comments on commit 1b4dced

Please sign in to comment.