-
Notifications
You must be signed in to change notification settings - Fork 578
Description
Describe the bug
When using @supabase/supabase-js with Vite (or any Rollup-based bundler), the following warnings appear during build/dev:
WARN "PostgrestError" is imported from external module "@supabase/postgrest-js" but never used in "@supabase/supabase-js/dist/index.mjs"
WARN "FunctionRegion", "FunctionsError", "FunctionsFetchError", "FunctionsHttpError" and "FunctionsRelayError" are imported from external module "@supabase/functions-js" but never used in "@supabase/supabase-js/dist/index.mjs"
Previous Fix Attempt
PR #1979 correctly addressed this in the source TypeScript (src/index.ts) by using direct re-export syntax:
export { PostgrestError } from '@supabase/postgrest-js'
export { FunctionRegion, FunctionsError, ... } from '@supabase/functions-js'However, the warnings persist because the build output (dist/index.mjs) doesn't preserve this pattern. The bundler transforms it into:
// Built output (line 1-2)
import { FunctionRegion, FunctionsClient, FunctionsError, ... } from "@supabase/functions-js";
import { PostgrestClient, PostgrestError } from "@supabase/postgrest-js";
// ... 400 lines later (line 405) ...
export { FunctionRegion, FunctionsError, ..., PostgrestError, SupabaseClient, createClient };Rollup's tree-shaking analysis doesn't recognize that these imports are used solely for re-export, triggering the "imported but never used" warning.
Root Cause
The package uses tsdown for building (tsdown.config.ts), which transforms export { X } from "module" into separate import and export statements. The build configuration or tooling would need to preserve the original re-export syntax.
Environment
@supabase/supabase-js: 2.90.0- Bundler: Vite 6.x (Rollup-based)
- Framework: Nuxt 4
Workaround
Manually patching dist/index.mjs (via pnpm patch) to use direct re-exports eliminates the warnings:
Before (current build output):
import { FunctionRegion, FunctionsClient, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/functions-js";
import { PostgrestClient, PostgrestError } from "@supabase/postgrest-js";
// ... later ...
export { FunctionRegion, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError, PostgrestError, SupabaseClient, createClient };After (working fix):
import { FunctionsClient } from "@supabase/functions-js";
import { PostgrestClient } from "@supabase/postgrest-js";
export { FunctionRegion, FunctionsError, FunctionsFetchError, FunctionsHttpError, FunctionsRelayError } from "@supabase/functions-js";
export { PostgrestError } from "@supabase/postgrest-js";
// ... later ...
export { SupabaseClient, createClient };Library affected
supabase-js
Reproduction
No response
Steps to reproduce
No response
System Info
System:
OS: macOS 26.3
CPU: (12) arm64 Apple M2 Max
Memory: 2.81 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.9.0 - /Users/snake/.nvm/versions/node/v24.9.0/bin/node
npm: 11.6.0 - /Users/snake/.nvm/versions/node/v24.9.0/bin/npm
pnpm: 10.27.0 - /Users/snake/Library/pnpm/pnpm
Browsers:
Chrome: 143.0.7499.170
Safari: 26.3
npmPackages:
@supabase/supabase-js: ~2.90.0 => 2.90.0Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Supabase JS Library issue and not an issue with the Supabase platform. If it's a Supabase platform related bug, it should likely be reported to supabase/supabase instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.