supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
962 stars 128 forks source link

The requested module './../../../node-fetch/lib/index.js' does not provide an export named 'default' (at PostgrestBuilder.js:1:8) #518

Closed kjhughes closed 4 months ago

kjhughes commented 4 months ago

Bug report

Describe the bug

Adding a component that uses Supabase to Shoelace components produces the following error:

SyntaxError: The requested module './../../../node-fetch/lib/index.js' does not provide an export named 'default' (at PostgrestBuilder.js:1:8)

Which references this line in PostgrestBuild.js:

// @ts-ignore
import nodeFetch from '@supabase/node-fetch';

To Reproduce

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

  1. git clone https://github.com/shoelace-style/shoelace
  2. cd shoelace
  3. npm install @supabase/supabase-js
  4. npm install
  5. npm run build
  6. npm run test => All tests pass, check.
  7. Add Supabase to one of the components such as src/components/alert/alert.component.ts by adding the following two lines after the existing import statements:
    import { createClient } from '@supabase/supabase-js'
    createClient('https://xyzcompany.supabase.co', 'public-anon-key')
  8. npm run test
  9. Observe that now all tests fail to even load, each giving an error of the following form:

    src/components/alert/alert.test.ts:
    
    🚧 Browser logs on Chromium:
      SyntaxError: The requested module './../../../node-fetch/lib/index.js' does not provide an export named 'default'
    🚧 Browser logs on Webkit:
      SyntaxError: Importing binding name 'default' cannot be resolved by star export entries.
    
    ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information. 

    Expected behavior

Adding Supabase to a component should not cause its test and the tests of all other components in the package to fail to load.

System information

Related report

This open issue appears to be related, but since it did not include a detailed means to reproduce, I thought I'd create a new issue to facilitate reproduction in hopes to resolve this more quickly:

kjhughes commented 4 months ago

I've closed this issue and posted instead to https://github.com/supabase/supabase/issues/21261 because is more pervasive as it prevents any Supabase functions from working as supabase-js cannot even load.