supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
3.25k stars 269 forks source link

[Deno] ESM.sh module not found - index.d.ts (types) #744

Open 5hee75 opened 1 year ago

5hee75 commented 1 year ago

Bug report

Describe the bug

Attempting to import @supabase/supabase-js type definitions through esm.sh, when included as a secondary package, fails with the following error:

Error: Module not found "https://esm.sh/v113/@supabase/supabase-js@2.12.1/dist/module/lib/types/dist/module/index.d.ts".

To Reproduce

This specific issue was found when trying to include the @supabase/auth-helpers-shared package via https://esm.sh/@supabase/auth-helpers-shared@0.3.0 in a Deno project (Edge Functions).

The following repo should be able to reproduce the error.

https://github.com/astor-tech/supabase-edge-trpc

Note: Functionality seems ok when serving locally. The only issue is the type imports, so just the supabase functions deploy fails.

Steps to reproduce

  1. Fork and clone the repo above
  2. Link to a Supabase project
  3. Run supabase functions deploy
  4. Note deployment error listed above

Expected behavior

Type definitions should be available for the @supabase/supabase-js SDK through the esm.sh module for Deno.

https://esm.sh/v113/@supabase/supabase-js@2.12.1/dist/module/lib/types/dist/module/index.d.ts

Additional context

I was able to get the deployment to work functionally by using the auth helpers package from this CDN:

https://cdn.jsdelivr.net/npm/@supabase/auth-helpers-shared/+esm

However, that CDN doesn't seem to provide any useful type info, so using it with tRPC (my use case) becomes somewhat limiting.

(Split from https://github.com/supabase/supabase-js/issues/739)

nalnir commented 1 year ago

@5hee75 Did you manage to resolve this? I have exactly the same problem with:

import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2?target=deno&no-check';

The edge function works just fine, but I am not able to build my next app because of this.

gjohnsx commented 1 year ago

@nalnir @5hee75 you can add supabase to the exclude section of tsconfig.json "exclude": ["node_modules", "supabase"],

Lucas-AVS commented 11 months ago

@5hee75 Did you manage to resolve this? I have exactly the same problem with:

import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2?target=deno&no-check';

The edge function works just fine, but I am not able to build my next app because of this.

Are you using docker? Since CLI 1.120.0, you do need to install docker as a prerequisite for deploying functions.