Skip to content

Conversation

@7ttp
Copy link
Contributor

@7ttp 7ttp commented Dec 16, 2025

Problem

The ESM wrapper (dist/esm/wrapper.mjs) uses index.default || index pattern which causes errors with modern bundlers:

Webpack (build failure):

ERROR in ./node_modules/@supabase/supabase-js/dist/esm/wrapper.mjs
export 'default' (imported as 'index') was not found in '../module/index.js'

Rollup/Vite (warnings):

"default" is not exported by "node_modules/@supabase/supabase-js/dist/module/index.js"

This affects users importing via @supabase/ssr and direct imports in Vite, Rollup, and Webpack projects.

Root Cause

dist/module/index.js only has named exports, no default export. The index.default || index pattern fails static analysis in bundlers.

Solution

Replace namespace import + destructuring with direct named imports:

- import * as index from '../module/index.js'
- const { createClient, ... } = index.default || index
- export default index.default || index
+ import { createClient, ... } from '../module/index.js'
+ export default { createClient, ... }

Testing

Verified with fresh @supabase/[email protected] install:

Bundler Before After
Webpack compiled with 2 errors compiled successfully
Rollup ⚠️ 3 warnings ✅ No warnings
Vite ✅ builds ✅ builds

Additionally verified:

  • All 46 named exports work correctly
  • Default export works correctly
  • Runtime execution works in all bundled outputs

Closes #1955
Adds up to #1953

cc @mandarini

@7ttp 7ttp requested a review from a team as a code owner December 16, 2025 13:44
@7ttp
Copy link
Contributor Author

7ttp commented Dec 16, 2025

Hey @mandarini 😅
I also considered using import * as allExports with export * pattern, but after testing locally,
the direct named imports approach is more explicit and better across bundlers.
Let me know which approach would u prefer :D

@mandarini
Copy link
Contributor

@7ttp I decided to work on a more robust solution. Thank you for your PR in any case.

@7ttp
Copy link
Contributor Author

7ttp commented Dec 16, 2025

@7ttp I decided to work on a more robust solution. Thank you for your PR in any case.

Sounds good!
lmk if I can help with anything. 💚

@mandarini
Copy link
Contributor

Closing in favor of #1961

@mandarini mandarini closed this Dec 16, 2025
@7ttp 7ttp deleted the wrap1 branch December 16, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module import/export mismatch

2 participants