supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.09k stars 212 forks source link

Custom path mapping for dependencies with deno.json seems to be broken #2846

Closed SanjoSolutions closed 3 weeks ago

SanjoSolutions commented 3 weeks ago

Describe the bug The custom path mapping for dependencies with deno.json as described in the documentation seems to be broken.

It works with the legacy import maps method.

System information

I hope the information is sufficient to reproduce it.

sweatybridge commented 3 weeks ago

Hi @SanjoSolutions, thanks for reporting this issue. Are you perhaps using relative path imports in deno.json? Could you give us a minimal reproducible example to illustrate what's broken?

SanjoSolutions commented 3 weeks ago

Are you perhaps using relative path imports in deno.json?

Yes.

In my case the content is:

{
  "imports": {
    "basejump/": "../../../../basejump-deno-packages/"
  }
}

With the legacy import maps this works. With the deno.json method with an import like import { billingFunctionsWrapper, stripeFunctionHandler, } from "basejump/billing-functions/mod.ts"; I receive the following error:

$ npx supabase functions serve
Setting up Edge Functions runtime...
Serving functions on http://127.0.0.1:54321/functions/v1/<function-name>
Using supabase-edge-runtime-1.60.1 (compatible with Deno v1.45.2)
serving the request with supabase/functions/billing-functions
worker boot error: failed to create the graph: Relative import path "basejump/billing-functions/mod.ts" not prefixed with / or ./ or ../
    at file:///Users/jonas/saas-template/supabase/functions/billing-functions/index.ts:5:8
worker boot error: failed to create the graph: Relative import path "basejump/billing-functions/mod.ts" not prefixed with / or ./ or ../
    at file:///Users/jonas/saas-template/supabase/functions/billing-functions/index.ts:5:8
InvalidWorkerCreation: worker boot error: failed to create the graph: Relative import path "basejump/billing-functions/mod.ts" not prefixed with / or ./ or ../
    at file:///Users/jonas/saas-template/supabase/functions/billing-functions/index.ts:5:8
    at async UserWorker.create (ext:sb_user_workers/user_workers.js:145:15)
    at async Object.handler (file:///root/index.ts:156:22)
    at async respond (ext:sb_core_main_js/js/http.js:163:14) {
  name: "InvalidWorkerCreation"
sweatybridge commented 3 weeks ago

Thank you. I managed to reproduce the issue and pushed a fix.

npx supabase@beta functions serve