Skip to content

fix: enable tree-shaking for browser bundles#216

Merged
mandarini merged 1 commit intomainfrom
fix/bundler-tree-shaking
May 7, 2026
Merged

fix: enable tree-shaking for browser bundles#216
mandarini merged 1 commit intomainfrom
fix/bundler-tree-shaking

Conversation

@mandarini
Copy link
Copy Markdown
Contributor

@mandarini mandarini commented May 7, 2026

What kind of change does this PR introduce?

Bug fix. Closes #92.

What is the current behavior?

@supabase/ssr is not tree-shakeable. A browser bundle that imports only createBrowserClient still carries createServerClient because (a) package.json does not declare "sideEffects": false and (b) src/index.ts runs a top-level process.env.npm_package_name check at module load, which is a real side effect.

What is the new behavior?

  • package.json declares "sideEffects": false (and adds an explicit "types" field).
  • The deprecated-auth-helpers warning moves into src/warnDeprecatedPackage.ts as a function called from createBrowserClient and createServerClient on first construction, with a once-per-process guard.
  • src/index.ts is reduced to pure re-exports.

No API changes. The only behavioral shift is the warning timing: first construction instead of module import.

Verified: 81 tests pass, createServerClient drops out of an esbuild browser bundle that imports only createBrowserClient, the warning fires once and only after a client is constructed.

Additional context

Subpath exports (@supabase/ssr/client, /server) were considered and left out: they would be largely cosmetic on top of "sideEffects": false, and an "exports" map breaks deep imports into internal paths. Worth a deliberate design pass for a future major. The ws and crypto symbols in the original screenshot come from @supabase/supabase-js transitives and node-polyfill bundler plugins, neither of which this PR touches.

@mandarini mandarini marked this pull request as ready for review May 7, 2026 15:00
@mandarini mandarini self-assigned this May 7, 2026
@mandarini mandarini merged commit f009d71 into main May 7, 2026
7 checks passed
@mandarini mandarini deleted the fix/bundler-tree-shaking branch May 7, 2026 16:26
mandarini pushed a commit that referenced this pull request May 7, 2026
🤖 I have created a release *beep* *boop*
---


## [0.10.3](v0.10.2...v0.10.3)
(2026-05-07)


### Bug Fixes

* allow cookies encode without getAll/setAll on browser client
([#213](#213))
([89f3f28](89f3f28)),
closes [#170](#170)
* enable tree-shaking for browser bundles
([#216](#216))
([f009d71](f009d71))
* **tsconfig:** set explicit rootDir to silence TS6059 in consumer IDEs
([#211](#211))
([a77ee8a](a77ee8a)),
closes [#209](#209)
* validate base64-prefixed chunked cookies decode to valid JSON
([#210](#210))
([302cc0e](302cc0e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
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.

createBrowserClient brings in a bunch of server deps to the client

2 participants