@@ -263,59 +263,57 @@ bun -e "console.log('Bun:', require('./lib/cjs/index.cjs').WorkOS.name)"
263263- ` tsx@^4.19.0 ` - TypeScript execution for ecosystem check script
264264- ` miniflare@^3.20250408.2 ` - Worker environment testing (optional)
265265
266- ### Phase 3: Enhanced Package.json Configuration
266+ ### Phase 3: Enhanced Package.json Configuration ✅ COMPLETE
267267
268- #### 3.1 Improved Exports
268+ #### 3.1 Implemented Export Conditions
269269
270- Ensure optimal runtime selection :
270+ Added runtime-specific export conditions for optimal module resolution :
271271
272272``` json
273273{
274- "type" : " module" ,
275- "main" : " ./lib/index.cjs" ,
276- "module" : " ./lib/index.js" ,
277- "types" : " ./lib/index.d.ts" ,
278274 "exports" : {
279275 "." : {
280276 "types" : {
281- "require" : " ./lib/index.d.cts" ,
282- "import" : " ./lib/index.d.ts"
277+ "require" : " ./lib/cjs/ index.d.cts" ,
278+ "import" : " ./lib/esm/ index.d.ts"
283279 },
284280 "workerd" : {
285- "import" : " ./lib/index.worker.js" ,
286- "require" : " ./lib/index.worker.cjs"
281+ "import" : " ./lib/esm/ index.worker.js" ,
282+ "require" : " ./lib/cjs/ index.worker.cjs"
287283 },
288284 "edge-light" : {
289- "import" : " ./lib/index.worker.js" ,
290- "require" : " ./lib/index.worker.cjs"
285+ "import" : " ./lib/esm/ index.worker.js" ,
286+ "require" : " ./lib/cjs/ index.worker.cjs"
291287 },
292- "deno" : " ./lib/index.js" ,
288+ "deno" : " ./lib/esm/ index.js" ,
293289 "bun" : {
294- "import" : " ./lib/index.js" ,
295- "require" : " ./lib/index.cjs"
290+ "import" : " ./lib/esm/ index.js" ,
291+ "require" : " ./lib/cjs/ index.cjs"
296292 },
297293 "node" : {
298- "import" : " ./lib/index.js" ,
299- "require" : " ./lib/index.cjs"
294+ "import" : " ./lib/esm/ index.js" ,
295+ "require" : " ./lib/cjs/ index.cjs"
300296 },
301- "import" : " ./lib/index.js" ,
302- "require" : " ./lib/index.cjs" ,
303- "default" : " ./lib/index.js"
304- },
305- "./worker" : {
306- "types" : {
307- "require" : " ./lib/index.worker.d.cts" ,
308- "import" : " ./lib/index.worker.d.ts"
309- },
310- "import" : " ./lib/index.worker.js" ,
311- "require" : " ./lib/index.worker.cjs" ,
312- "default" : " ./lib/index.worker.js"
313- },
314- "./package.json" : " ./package.json"
297+ "import" : " ./lib/esm/index.js" ,
298+ "require" : " ./lib/cjs/index.cjs" ,
299+ "default" : " ./lib/esm/index.js"
300+ }
315301 }
316302}
317303```
318304
305+ ** Key Improvements** :
306+ - ** Runtime-specific conditions** : Direct ` deno ` , ` bun ` , ` node ` mappings for optimal resolution
307+ - ** Enhanced TypeScript support** : Separate type paths for CJS (` .d.cts ` ) and ESM (` .d.ts ` )
308+ - ** Worker environment optimization** : Dedicated worker builds for edge runtimes
309+ - ** Performance-ordered conditions** : Most specific to least specific for faster resolution
310+
311+ ** Test Results** (Post-Phase 3):
312+ - ✅ All 6 runtime tests still passing
313+ - ✅ Runtime-specific export resolution working correctly
314+ - ✅ TypeScript type resolution optimized
315+ - ✅ No regressions in existing functionality
316+
319317### Phase 4: CI/CD Integration (Industry Best Practices)
320318
321319#### 4.1 GitHub Actions Workflow (Based on OpenAI SDK Pattern)
@@ -426,10 +424,11 @@ jobs:
426424- [x] Test core runtimes : Node.js, Deno, Bun (5/5 passing)
427425- [x] Install and configure testing dependencies (tsx, miniflare)
428426
429- # ## Phase 3: Enhanced Package.json
427+ # ## Phase 3: Enhanced Package.json ✅ COMPLETE
430428- [x] Basic dual-build exports structure
431- - [ ] Add runtime-specific export conditions (`deno`, `bun`, `node`)
432- - [ ] Optimize export map for performance
429+ - [x] Add runtime-specific export conditions (`deno`, `bun`, `node`)
430+ - [x] Optimize export map for performance
431+ - [x] Enhanced TypeScript type resolution with separate CJS/ESM type paths
433432
434433# ## Phase 4: Automated CI (Future)
435434- [ ] Implement GitHub Actions matrix workflow
@@ -469,4 +468,4 @@ If issues arise:
4694683. **Validate** that existing bundler usage continues to work
4704694. **Deploy** with confidence that universal compatibility is achieved
471470
472- This plan ensures the WorkOS Node.js SDK v8 will work seamlessly across all modern JavaScript runtimes while maintaining the benefits of the current architecture.
471+ This plan ensures the WorkOS Node.js SDK v8 will work seamlessly across all modern JavaScript runtimes while maintaining the benefits of the current architecture.
0 commit comments