Skip to content

Conversation

@mandarini
Copy link
Contributor

Summary

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

Problem

PR #1914 changed wrapper.mjs to import from the CJS build (../main/index.js) and manually destructure 46 exports. When jsDelivr bundles this:

  1. Rollup transforms CJS require('@supabase/auth-js')import default from '@supabase/auth-js'
  2. auth-js has no default export, so Rollup adds export default null
  3. Destructuring AuthClient from null throws

Solution

Rewrite wrapper.mjs to use direct package re-exports

This approach:

  • Uses export * for automatic sync (no manual maintenance)
  • Works with jsDelivr (bundles see named exports, not CJS default imports)
  • Works with Node.js, esm.sh, and all bundlers
  • Reduces wrapper from 95 lines to 22 lines

Related

@github-actions github-actions bot added the supabase-js Related to the supabase-js library. label Dec 15, 2025
@mandarini mandarini self-assigned this Dec 15, 2025
@mandarini mandarini marked this pull request as ready for review December 15, 2025 13:31
@mandarini mandarini requested review from a team as code owners December 15, 2025 13:31
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 15, 2025

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@1950

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@1950

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@1950

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@1950

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@1950

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@1950

commit: 1a9e980

@coveralls
Copy link

coveralls commented Dec 15, 2025

Coverage Status

coverage: 80.758% (-0.5%) from 81.237%
when pulling 1a9e980 on fix/esm-wrapper-issues
into 32d2187 on master.

@mandarini mandarini merged commit 2950186 into master Dec 15, 2025
36 of 39 checks passed
@mandarini mandarini deleted the fix/esm-wrapper-issues branch December 15, 2025 14:38
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. trigger: preview

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

4 participants