next.jsdeploymentvercelcloudflaresupabase

How to exclude a folder in Cloudflare deployment


I am trying to deploy my NextJs app on Cloudflare pages. The app has a connection to a Supabase backend and I have setup a few Edge functions on it which are in a separate folder named supabase. During deployment on cloudflare Pages, there seems to be something wrong with the Edge function of Supabase:

17:01:51.638    ▲  Creating an optimized production build ...
17:02:11.266    ▲  ✓ Compiled successfully
17:02:11.270    ▲  Linting and checking validity of types ...
17:02:14.705    ▲  Failed to compile.
17:02:14.706    ▲  ./supabase/functions/executeTrainings/index.ts:7:30
17:02:14.706    ▲  Type error: Cannot find module 'jsr:@supabase/supabase-js@2' or its corresponding type declarations.
17:02:14.706    ▲  
17:02:14.706    ▲     5 | // Setup type definitions for built-in Supabase Runtime APIs
17:02:14.706    ▲     6 | import "jsr:@supabase/functions-js/edge-runtime.d.ts";
17:02:14.706    ▲  >  7 | import { createClient } from "jsr:@supabase/supabase-js@2";
17:02:14.706    ▲       |                              ^
17:02:14.707    ▲     8 | import { DateTime } from "https://esm.sh/luxon";
17:02:14.707    ▲     9 |
17:02:14.707    ▲    10 | Deno.serve(async (req) => {
17:02:14.765    ▲  Error: Command "npm run build" exited with 1
17:02:14.806    
17:02:14.807    ⚡️ The Vercel build (`npx vercel build`) command failed. For more details see the Vercel logs above.

Is it possible to exclude this supabase folder so cloudflare does not look into it? IS there something else I can do to solve the problem? I have tried creating a .cfignore file but that does not work.

Any help is welcome!


Solution

  • I was able to exclude it by adding the directory name supabase to the values of the export key in `tsconfig.json.

    "exclude": ["node_modules", "supabase"]