Skip to content

Commit e25d4af

Browse files
authored
fix: use entrypoint which embeds the wasm instead of requiring it to be fetched over the network when deployed as a Netlify Edge Function (#118)
Netlify Edge Functions are not able to read the file-system, which means we can't read the generated .wasm file during execution, we currently fetch the wasm file over the network but this request could fail or have an incorrect response, leading to a runtime error when attempting to instantiate the WebAssembly Module. To work-around this, the library was updated to include a .ts file which includes the exact same bytes as the wasm file, but within a JavaScript UInt8Array, which we can then instantiate as a WebAssembly Module.
1 parent d3ba543 commit e25d4af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/__csp-nonce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// @ts-ignore
33
import type { Config, Context } from "netlify:edge";
44
// @ts-ignore
5-
import { csp } from "https://deno.land/x/csp_nonce_html_transformer@v2.1.5/src/index.ts";
5+
import { csp } from "https://deno.land/x/csp_nonce_html_transformer@v2.2.0/src/index-embedded-wasm.ts";
66
// @ts-ignore
77
import inputs from "./__csp-nonce-inputs.json" assert { type: "json" };
88

0 commit comments

Comments
 (0)