fix(sdk): add .js extensions to all ESM imports for Node.js compatibility#623
fix(sdk): add .js extensions to all ESM imports for Node.js compatibility#623
Conversation
…lity
Both @yellow-org/sdk and @yellow-org/sdk-compat declared "type": "module"
but used extensionless relative imports (e.g. from './client') in source.
TypeScript emits these as-is, and Node.js strict ESM resolution rejects
them. This forced consumers to use tsx, postinstall patches, or
--experimental-specifier-resolution=node.
Changes:
- Add .js extensions to all relative imports in sdk/ts/src (24 files)
- Add .js extensions to all relative imports in sdk/ts-compat/src (7 files)
- Switch moduleResolution from "bundler" to "Node16" in both tsconfig.json
files so TypeScript enforces correct ESM paths at compile time
- Switch module from "ESNext" to "Node16" to match
- Fix Decimal import: default import -> named import for Node16 compat
Verified: both packages build clean with tsc, dist output has .js
extensions, and `node -e "import('./dist/index.js')"` succeeds without
any flags or workarounds.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR updates TypeScript/JS module specifiers across the SDK to use explicit Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
This commit cleans up the utils.ts file by removing the unused import of RPCApp, streamlining the code and improving readability.
…lity (#623) Both `@yellow-org/sdk` and `@yellow-org/sdk-compat` declared `"type": "module"` but used extensionless relative imports in source (e.g. `from './client'`). TypeScript emits these as-is, and Node.js strict ESM resolution rejects them. This forced consumers to use `tsx`, postinstall patches, or `--experimental-specifier-resolution=node`. - Add `.js` extensions to all relative imports in `sdk/ts/src/` (24 files) and `sdk/ts-compat/src/` (7 files) - Switch `module` and `moduleResolution` from `ESNext`/`bundler` to `Node16` in both `tsconfig.json` files - Fix `Decimal` import: default import -> named import for Node16 compatibility - Both packages build clean with `tsc` - `node -e "import('./dist/index.js')"` succeeds in both packages without any flags - Bundler consumers (Vite, webpack) are unaffected since they handle `.js` extensions natively <!-- This is an auto-generated comment: release notes by coderabbit.ai --> * **Chores** * Refactor: Updated module imports across the SDK to use explicit .js extensions for ESM compatibility. * Refactor: Adjusted TypeScript config to Node16 module resolution. * Refactor: Replaced several default imports with named imports for improved interoperability. * Note: Public APIs and runtime behavior remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alessio Treglia <229356+alessio@users.noreply.github.com>
Summary
Both
@yellow-org/sdkand@yellow-org/sdk-compatdeclared"type": "module"but used extensionless relative imports in source (e.g.from './client'). TypeScript emits these as-is, and Node.js strict ESM resolution rejects them. This forced consumers to usetsx, postinstall patches, or--experimental-specifier-resolution=node.Changes
.jsextensions to all relative imports insdk/ts/src/(24 files) andsdk/ts-compat/src/(7 files)moduleandmoduleResolutionfromESNext/bundlertoNode16in bothtsconfig.jsonfilesDecimalimport: default import -> named import for Node16 compatibilityVerification
tscnode -e "import('./dist/index.js')"succeeds in both packages without any flags.jsextensions nativelySummary by CodeRabbit