Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deno import_map.json for supabase

I try to work with supabase edge functions in a Deno environment in IntelliJ Ultimate. The corresponding plugin is already installed but inside my supabase folder the functions I wanna create do not support Deno IntelliSense which makes things quite hard.

Folder Structure: enter image description here

I don't know why my IntelliSense breaks when working with Deno and/or how to retrieve the correct types from packages imported via import_map.json

import_map.json

{
  "imports": {
    "stripe": "https://esm.sh/[email protected]?target=deno",
    "std/server": "https://deno.land/[email protected]/http/server.ts"
  }
}

index.ts inside my 'get-ticket-information' function folder (The code is probably correct, but shows me errors because of missing types):

import { serve } from 'std/server'
import Stripe from 'stripe'

const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY') as string, {
  apiVersion: '2022-11-15',
  httpClient: Stripe.createFetchHttpClient(),
})

When trying to deploy to supabase via

 supabase functions deploy --no-verify-jwt get-ticket-information --debug

I do receive the following error too:

Uncaught (in promise) Error: Relative import path "http" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v108/@types/[email protected]/http.d.ts"
      const ret = new Error(getStringFromWasm0(arg0, arg1));

like image 319
Markus G. Avatar asked Aug 15 '26 22:08

Markus G.


1 Answers

Regarding the runtime error:

The Supabase CLI documentation for supabase functions deploy suggests that you must provide a path to the import map at the time of invocation:

supabase functions deploy

Deploy a Function to the linked Supabase project.

Basic usage:

supabase functions deploy <Function name> [flags]

Flags:

--import-map <string>

Path to import map file.

...cont.


Regarding import maps as they relate to IDE integration and types:

This has already been covered on Stack Overflow here, and is also covered in the manual in section 3.3: Import Maps.

like image 159
jsejcksn Avatar answered Aug 20 '26 03:08

jsejcksn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!