@@ -138,14 +138,14 @@ nx test supabase-js --coverage # Test with coverage
138138
139139** Docker Requirements:**
140140
141- | Package | Docker Required | Infrastructure | Special Commands |
142- | ------------ | --------------- | ------------------------------- | ---------------- |
143- | auth-js | ✅ Yes | Auth Server + Postgres | May use ` nx test:auth auth-js ` |
144- | functions-js | ✅ Yes | Deno relay (testcontainers) | Standard ` nx test functions-js ` |
145- | postgrest-js | ✅ Yes | PostgREST + PostgreSQL | Standard ` nx test postgrest-js ` |
141+ | Package | Docker Required | Infrastructure | Special Commands |
142+ | ------------ | --------------- | ------------------------------- | ------------------------------------ |
143+ | auth-js | ✅ Yes | Auth Server + Postgres | May use ` nx test:auth auth-js ` |
144+ | functions-js | ✅ Yes | Deno relay (testcontainers) | Standard ` nx test functions-js ` |
145+ | postgrest-js | ✅ Yes | PostgREST + PostgreSQL | Standard ` nx test postgrest-js ` |
146146| storage-js | ✅ Yes | Storage API + PostgreSQL + Kong | May use ` nx test:storage storage-js ` |
147- | realtime-js | ❌ No | Mock WebSockets | Standard ` nx test realtime-js ` |
148- | supabase-js | ❌ No | Unit tests only | Standard ` nx test supabase-js ` |
147+ | realtime-js | ❌ No | Mock WebSockets | Standard ` nx test realtime-js ` |
148+ | supabase-js | ❌ No | Unit tests only | Standard ` nx test supabase-js ` |
149149
150150> ** 📖 See [ TESTING.md] ( docs/TESTING.md ) for complete testing guide and troubleshooting**
151151
@@ -216,6 +216,68 @@ nx release --tag=latest --yes # Promotes to stable with same version for ALL pa
216216
217217Each library has its own ` tsconfig.json ` extending the base configuration, allowing for library-specific adjustments while maintaining consistency.
218218
219+ ### TypeScript Project References Setup
220+
221+ This repository uses TypeScript project references for incremental builds and better type checking across packages.
222+
223+ ** What's Configured:**
224+
225+ 1 . ** tsconfig.base.json** - Base configuration inherited by all projects:
226+ - ` composite: true ` - Enables project references
227+ - ` declaration: true ` - Required by composite
228+ - ` moduleResolution: "bundler" ` - Works with workspaces
229+ - ` isolatedModules: true ` - Inherited but overridden in core packages
230+ - ` noImplicitOverride: true ` - Inherited but overridden in core packages
231+ - ** No ` customConditions ` ** - Removed to avoid conflicts with CommonJS packages
232+
233+ 2 . ** Root tsconfig.json** - References all projects in the monorepo:
234+
235+ ``` json
236+ {
237+ "extends" : " ./tsconfig.base.json" ,
238+ "files" : [],
239+ "references" : [
240+ { "path" : " ./packages/core/auth-js" },
241+ { "path" : " ./packages/core/realtime-js" }
242+ // ... all other packages
243+ ]
244+ }
245+ ```
246+
247+ 3 . ** Core packages** (auth-js, realtime-js, postgrest-js, functions-js, storage-js):
248+ - Keep ` module: "CommonJS" ` for backward compatibility
249+ - Override ` moduleResolution: "Node" ` (required for CommonJS)
250+ - Override ` isolatedModules: false ` (existing code doesn't use ` export type ` )
251+ - Override ` noImplicitOverride: false ` (existing code doesn't use ` override ` keyword)
252+ - Add ` references ` array pointing to dependencies (managed by ` nx sync ` )
253+
254+ 4 . ** Utils packages** (utils-fetch):
255+ - Inherit ` moduleResolution: "bundler" ` from base
256+ - Can optionally add ` customConditions: ["@supabase-js/source"] ` for source preference
257+
258+ ** Key Principles:**
259+
260+ - ✅ ** No Breaking Changes** : Build output is identical - only type-checking is affected
261+ - ✅ ** Incremental Builds** : TypeScript only recompiles changed projects
262+ - ✅ ** Better Performance** : Reduced memory usage during builds
263+ - ✅ ** Automatic References** : Nx sync automatically maintains project references
264+ - ⚠️ ** No ` customConditions ` in base** : Would conflict with ` moduleResolution: "Node" `
265+
266+ ** When Adding New Packages:**
267+
268+ 1 . Ensure ` composite: true ` and ` declaration: true ` are set
269+ 2 . Add ` references ` array pointing to dependencies
270+ 3 . If using CommonJS, override ` moduleResolution: "Node" ` and disable strict options
271+ 4 . Run ` nx sync ` to update root tsconfig.json automatically
272+
273+ ** Important Notes:**
274+
275+ - TypeScript project references work WITHOUT ` customConditions ` - it's optional
276+ - ` customConditions ` only optimizes source file resolution during development
277+ - Core packages use ` moduleResolution: "Node" ` which is incompatible with ` customConditions `
278+ - The ` isolatedModules: false ` override avoids requiring ` export type ` for type re-exports
279+ - All build outputs remain identical to pre-project-references setup
280+
219281## Testing Infrastructure
220282
221283### Unit Tests (Jest)
@@ -314,10 +376,12 @@ Tests run against multiple environments:
314376### Branch Information
315377
316378** Current Repository:**
379+
317380- ** Default branch** : ` master ` (confirmed current default)
318381- ** Repository URL** : ` github.com/supabase/supabase-js `
319382
320383** Original Repository Branches** (for historical reference):
384+
321385- ** master** : auth-js, postgrest-js, realtime-js, supabase-js
322386- ** main** : functions-js, storage-js
323387
0 commit comments