Import Map Issues (relative path) for supabase package for functions deploy
I use edge functions a lot for my app and up until this morning I haven't had any issues with calling
supabase functions deploy <function-name>
supabase functions deploy <function-name>
. Yesterday I deployed multiple different EFs with no problems.
Today, I ran into an error:
Bundling test-endpointError: Error bundling function: exit status 1file:///src/import_map.jsonfile:///src/index.tserror: Uncaught (in promise) Error: Relative import path "events" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@types/node@18.16.19/events.d.ts" const ret = new Error(getStringFromWasm0(arg0, arg1)); ^ at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894) at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6) at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)Try rerunning the command with --debug to troubleshoot the error.
Bundling test-endpointError: Error bundling function: exit status 1file:///src/import_map.jsonfile:///src/index.tserror: Uncaught (in promise) Error: Relative import path "events" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/@types/node@18.16.19/events.d.ts" const ret = new Error(getStringFromWasm0(arg0, arg1)); ^ at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:312:19) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:79439) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1388039) at <anonymous> (https://deno.land/x/eszip@v0.30.0/eszip_wasm_bg.wasm:1:1862894) at __wbg_adapter_18 (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:146:6) at real (https://deno.land/x/eszip@v0.30.0/eszip_wasm.generated.js:130:14)Try rerunning the command with --debug to troubleshoot the error.
I was able to determine this was happening when I imported the supabase package with a hello world EF
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' // IF YOU COMMENT THIS OUT, `supabase functions deploy` WORKSconsole.log("Hello from Functions!")serve(async (req) => { return new Response( JSON.stringify({hello : 'world'}), { headers: { "Content-Type": "application/json; charset=utf-8" } }, )})
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' // IF YOU COMMENT THIS OUT, `supabase functions deploy` WORKSconsole.log("Hello from Functions!")serve(async (req) => { return new Response( JSON.stringify({hello : 'world'}), { headers: { "Content-Type": "application/json; charset=utf-8" } }, )})
If I don't import the supabase package, the deploy runs just fine. Did something change recently with how imports work? I've never had to mess with the import map directly before because I don't import 3rd party libraries yet.
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.