supabase / functions-js

MIT License
62 stars 22 forks source link

Docker build failed with Type Error #58

Open jainvaibhav671 opened 1 year ago

jainvaibhav671 commented 1 year ago

Bug report

Describe the bug

It is a Typescript syntax error with isolatedModules on

To Reproduce

I was building a docker image for my application using this template on NextJS docs

Building a NextJS app with supabase should raise this error This is my code My Code.

Expected behavior

Expected it to build when the Dockerfile ran next build

Screenshots

This is the error I got from docker build https://drive.google.com/file/d/1HRU_2bOrK5zQPGKvxAIPZ52_TPAv9NO9/view?usp=sharing

System information

Additional context

I am using NextJS with TypeScript+SWC. I tried setting isolatedModules to false, but when I ran npm run build it set it back to true

Gwened commented 4 months ago

I also have this error when I try to build my Next.js app:

./node_modules/.pnpm/@supabase+supabase-js@2.42.0_bufferutil@4.0.8_utf-8-validate@6.0.3/node_modules/@supabase/supabase-js/src/index.ts:17:3
Type error: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'.

  15 |   FunctionsRelayError,
  16 |   FunctionsError,
> 17 |   FunctionInvokeOptions,
     |   ^
  18 |   FunctionRegion,
  19 | } from '@supabase/functions-js'
  20 | export * from '@supabase/realtime-js'

FunctionInvokeOptions is exported both in functions-js and supabase-js (note: I don't use functions-js directly).

Setting isolatedModules to false isn't possible at the moment, because next build forces it to true:

   We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default.
   The following mandatory changes were made to your tsconfig.json:

        - isolatedModules was set to true (requirement for SWC / Babel)

(see also Next.js issue)

For now, the workaround is to add this in next.config:

typescript: {
    // !! WARN !!
    // Dangerously allow production builds to successfully complete even if
    // your project has type errors.
    // This is to workaround the supabase-js error, see isolatedModule in tsconfig.json
    // !! WARN !!
    ignoreBuildErrors: true,
  },

Could you merge jainvaibhav671's PR to fix it?