Skip to content

Conversation

@mandarini
Copy link
Contributor

@mandarini mandarini commented Dec 15, 2025

Summary

Fixes jsDelivr CDN imports failing with Cannot read properties of null (reading 'AuthClient') since v2.86.1.

Problem

When jsDelivr bundles the CJS main build, it transforms require('@supabase/auth-js') to default imports. Since auth-js has export default null (added by Rollup for packages without default exports), destructuring fails.

Solution

  1. Changed wrapper to import from ESM module build instead of CJS main build
  2. Added post-build script to add .js extensions to relative imports in the module build

This fixes both:

  • jsDelivr CDN imports
  • Node.js direct ESM imports (.js extensions satisfy Node.js requirements)

Changes

  • wrapper.mjs - Import from ../module/index.js instead of ../main/index.js (thanks @7ttp)
  • scripts/fix-esm-extensions.cjs - Adds .js extensions to compiled ESM imports

Related

@github-actions github-actions bot added the supabase-js Related to the supabase-js library. label Dec 15, 2025
@mandarini mandarini force-pushed the fix/jsdelivr-issue branch 2 times, most recently from e6798b0 to 6cb7a96 Compare December 15, 2025 16:50
@mandarini mandarini marked this pull request as ready for review December 15, 2025 16:53
@mandarini mandarini requested a review from a team as a code owner December 15, 2025 16:53
@mandarini mandarini self-assigned this Dec 15, 2025
@mandarini mandarini requested a review from grdsdev December 15, 2025 16:55
@mandarini mandarini enabled auto-merge (squash) December 15, 2025 16:56
@mandarini mandarini merged commit 628e710 into master Dec 15, 2025
19 of 20 checks passed
@mandarini mandarini deleted the fix/jsdelivr-issue branch December 15, 2025 18:38
@juliangorge
Copy link

Hey, i'm still having problems after this fix

@jim-spr
Copy link

jim-spr commented Dec 15, 2025

Same here @mandarini

@mandarini
Copy link
Contributor Author

Can you please check again with latest? 2.87.3? The cached results should be gone by now. @juliangorge @jim-spr

@juliangorge
Copy link

Good morning @mandarini
I've cleaned my lock files and try to build my next project and I have:


./node_modules/@supabase/supabase-js/dist/esm/wrapper.mjs
Attempted import error: '../module/index.js' does not contain a default export (imported as 'index').

Import trace for requested module:
./node_modules/@supabase/supabase-js/dist/esm/wrapper.mjs
./node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/@supabase/ssr/dist/module/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

supabase-js Related to the supabase-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite dev regression after #1914: exports is not defined from CJS wrapper in @supabase/supabase-js@^2.86.0

5 participants