cli: Failed to deploy edge-function which import parent directories

Bug report

  • I confirm this is a bug with Supabase, not my application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Hello. Locally, I can run Deno commands to compile, bundle and run functions without a problem.

However, when I run the Supabase CLI command deploy , I get errors. I am on the latest version of the CLI. If I run supabase functions deploy test I get the following error:

Deploying supabase function: test
Version 1.30.3 is already installed
Bundling test
Error: Error bundling function: exit status 1
file:///src/import_map.json
file:///src/index.ts
file:///_shared/supabase.client.ts
file:///services/users/user.service.ts
file:///util/format.types.ts
error: Uncaught (in promise) Error: NotFound: No such file or directory (os error 2)
      const ret = new Error(getStringFromWasm0(arg0, arg1));
                  ^
    at __wbg_new_8d2af00bc1e329ee (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:513:19)
    at <anonymous> (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1559899)
    at <anonymous> (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1398157)
    at <anonymous> (https://deno.land/x/eszip@v0.35.0/eszip_wasm_bg.wasm:1:1895031)
    at __wbg_adapter_40 (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:229:6)
    at real (https://deno.land/x/eszip@v0.35.0/eszip_wasm.generated.js:213:14)

If I use the --legacy-bundle flag though, I get a different error:

Deploying supabase function: test
Version 1.30.3 is already installed
Bundling test
Error: Error bundling function: exit status 1
error: Module not found "file:///services/users/user.service.ts".
    at file:///Users/code/supabase/functions/my_function/index.ts:4:28

services is a directory directly besides the functions folder inside the Supabase directory. My import_map.json file includes a path to the file. utils is a directory outside the supabase folder. Here is my import_map.json, which is inside the functions dir:

{
  "imports": {
    ...
    "/services/": "../services/",
    "/utils/": "../../src/utils/",
  }
}

Thanks!

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a folder inside the supabase folder next to functions. Add logic to be imported by your edge-function.
  2. Import the function from an edge-function.
  3. Add a path in the import_map.json to resolve the import.
  4. Run supabase functions deploy test

Expected behavior

Function deploys as normally expected.

Screenshots

N/A

System information

  • OS: [e.g. macOS, Windows] macOS
  • Version of supabase-js: [e.g. 2.21.0]
  • Version of Node.js: [e.g. v16.17.0]

Additional context

Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@sweatybridge its working now. i was using the wrong token. thanks

I had the same problem and when i filed a ticket with Supabase they asked me to only import external libraries in import_maps. I don’t like temporary fixes, but in the interest of time I removed references to project libraries from import maps.