cli: `serve ` command errors when importing local files
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When running supabase functions serve, if a function imports a local file specified in the import_map.json file that is outside the function folder, the command fails. When running an edge-function using the deno run --allow-all ./supabase/functions/my-function/index.ts command, one is able to test and run the function.
...
Download https://deno.land/x/jose@v4.4.0/lib/check_p2s.ts
Download https://deno.land/x/jose@v4.4.0/runtime/bogus.ts
Download https://deno.land/x/jose@v4.4.0/runtime/subtle_rsaes.ts
error: Module not found "file:///home/deno/lib/cors.ts".
at file:///home/deno/functions/my-function/index.ts:9:29
2023/05/12 11:18:51 Sent Header: Host [docker]
2023/05/12 11:18:51 Sent Header: User-Agent [Go-http-client/1.1]
2023/05/12 11:18:51 Send Done
2023/05/12 11:18:51 Recv First Byte
To Reproduce
- Create a new edge function directory and
index.tsinside the./supabase/functionsdir. - Create a util file outside the new function directory. For example, inside
./supabase/lib/cors.ts. - Import
cors.tsinside theindex.tsfile.
// index.ts
import cors from '@backend/lib/cors.ts';
...
- Specify the path to the util file in
import_map.jsonrelative to the location of the import_map.json file
// this file is inside ./supabase
{
"imports": {
"@backend/": "./",
}
- Run
supabase functions serve my-function
Expected behavior
The local edge function runs successfully as it does in deno.
Screenshots
N/A
System information
- OS: [e.g. macOS, Windows]
- Browser (if applies) [e.g. chrome, safari]
- Version of supabase-js: [e.g. 2.21.0]
- Version of supabase cli: [e.g. 1.57.3]
- Version of Node.js: [e.g. 16]
Additional context
Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (10 by maintainers)
We have to keep deno relay for the time being while we iron out other issues with edge runtime. Once that’s completed, we will default
functions serve <name>to use the same runtime.Ah! ok that works! I do see the modules folder now! Still having trouble with some external does now that don’t download from CDN but seems like the local files issue is solved! Some notes though:
supabase functions server <FUNCTION_NAME>supabase_deno_relay, I expected it would be using the neweredge-runtimecontainer.Now that you mention docker, let me try deleting and recreating the stack…