Reputation: 506
I have two edge functions namely create-payment-link
and retrieve-payment-link
but the import map they're using is /home/deno/flag_import_map.json
, and not the import_map.json
file in the functions
folder. Thus they're having a x was not mapped in import map.
where x is a particular package they're using.
Both functions have these imports:
import { serve } from "server"
import * as cryptojs from "crypto-js";
import { config } from "dotenv";
And the contents of import_map.json
is:
{
"imports": {
"server": "https://deno.land/[email protected]/http/server.ts",
"crypto-js": "https://cdn.skypack.dev/crypto-js",
"dotenv": "https://deno.land/x/dotenv/mod.ts"
}
}
This happens when trying to serve them both locally with: npx supabase functions serve --debug --env-file ./supabase/.env --import-map ./supabase/functions/import_map.json
Serving them one at a time with npx supabase functions serve function-name --debug --env-file ./supabase/.env
works though
Upvotes: 1
Views: 1647
Reputation: 523
In file config.toml
Add import_map
path as well.
[functions.tenant-permission-groups-identity]
verify_jwt = false
import_map = './import_map.json'
Upvotes: 0
Reputation: 9845
The setting is taken in account at:
https://github.com/supabase/cli/blob/55192fe878c77fa347bb00ba102eadc88d738a3b/internal/functions/serve/serve.go#L27-L28
The code shows that flag_import_map.json
is the one passed via --import-map
flag.
I don't understand why they copy it in /home/deno/
rather than /home/deno/functions/
. If one uses relative paths into the import-map, then those dependencies would get broken.
For what I understand the logic used by Supabase would work correctly only for remote Deno dependencies.
I suggest to keep your import_map.json
where it is and let Deno resolve it, without trying to help it with the Supabase config-map
flag.
Upvotes: 1