From 00dfbdca0ad10de4b55394279fcbd4a20d42a56a Mon Sep 17 00:00:00 2001 From: Eric Kharitonashvili <33439489+ekhar@users.noreply.github.com> Date: Fri, 28 Feb 2025 10:43:58 -0500 Subject: [PATCH] Fix Wasm Edge Function Docs (#33910) * fixed docs bug: when importing wasm, you need to include the js and use this. Otherwise, there will be wasm instantiate errors * Update wasm.mdx Got rid of filename on top of markdown * Update index.ts got rid of filename comment at the top --- apps/docs/content/guides/functions/wasm.mdx | 2 +- .../supabase/functions/wasm-modules/index.ts | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/docs/content/guides/functions/wasm.mdx b/apps/docs/content/guides/functions/wasm.mdx index b1c26e34de2..024d585b210 100644 --- a/apps/docs/content/guides/functions/wasm.mdx +++ b/apps/docs/content/guides/functions/wasm.mdx @@ -77,7 +77,7 @@ Before deploying the Edge Function, we need to ensure it bundles the Wasm module ```toml [functions.wasm-add] -static_files = [ "./functions/wasm-add/add-wasm/pkg/*.wasm"] +static_files = [ "./functions/wasm-add/add-wasm/pkg/*"] ``` Deploy the function by running: diff --git a/examples/edge-functions/supabase/functions/wasm-modules/index.ts b/examples/edge-functions/supabase/functions/wasm-modules/index.ts index 66d5085cf24..12774ae77f8 100644 --- a/examples/edge-functions/supabase/functions/wasm-modules/index.ts +++ b/examples/edge-functions/supabase/functions/wasm-modules/index.ts @@ -1,11 +1,4 @@ -const wasmBuffer = await Deno.readFile( - new URL("./add-wasm/pkg/add_wasm_bg.wasm", import.meta.url), -); - -const { instance } = await WebAssembly.instantiate( - wasmBuffer, -); -const { add } = instance.exports; +import { add } from "./add-wasm/pkg/add_wasm.js"; Deno.serve(async (req) => { const { a, b } = await req.json();