fix(core): explicit ESM specifiers so plain-Node ESM can import @sundaeswap/core#160
fix(core): explicit ESM specifiers so plain-Node ESM can import @sundaeswap/core#160rasheedja wants to merge 1 commit into
Conversation
Plain-Node ESM consumers fail with ERR_UNSUPPORTED_DIR_IMPORT: the ESM build emits import specifiers verbatim, and Node's ESM resolver does no directory or extension resolution. StrategyConfig.class.ts is loaded transitively by the main entry, so any 'type: module' import of @sundaeswap/core throws; mocks.ts is the same class of issue on the ./testing entry. Matches the explicit /index.js style used everywhere else in the package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
This PR fixes plain-Node ESM compatibility for @sundaeswap/core by making two relative import specifiers explicit (no directory imports, no extensionless imports), aligning with the package’s existing ESM import style so Node’s ESM resolver can load the built dist/esm output correctly.
Changes:
- Update
StrategyConfig.class.tsto import types via../@types/index.jsinstead of the directory../@types. - Update
TestUtilities/mocks.tsto import core exports via../exports/core.jsinstead of the extensionless../exports/core.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/TestUtilities/mocks.ts | Makes the relative import specifier explicit (core.js) to avoid Node ESM extension guessing. |
| packages/core/src/Configs/StrategyConfig.class.ts | Replaces a directory import with an explicit index.js specifier to prevent ERR_UNSUPPORTED_DIR_IMPORT in Node ESM. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Local verification (fork PRs won't run CI until approved, so ran the toolchain locally):
|
|
Companion fix for the next failure in the same Node-ESM chain: after these import specifiers are fixed, plain-Node ESM consumers hit |
Importing
@sundaeswap/coreunder plain Node ESM ("type": "module", no bundler) currently fails:Cause: the ESM build emits import specifiers verbatim, and Node's ESM resolver does no directory resolution or extension guessing. Two files use directory/extensionless relative imports, while the rest of the package consistently writes explicit
/index.js/.jsspecifiers:Configs/StrategyConfig.class.ts—from "../@types". This breaks the main entry:dist/esm/exports/core.jstransitively loadsStrategyConfig.class.js, so any plain-Node ESM import of the package throws.TestUtilities/mocks.ts—from "../exports/core". Same class of issue, latent on the./testingentry (ERR_MODULE_NOT_FOUND).CJS, Bun, and bundlers all do their own directory/extension resolution, which is why this has gone unnoticed.
Fix: make both specifiers explicit, matching the existing style everywhere else in the package (e.g.
SundaeSDK.class.ts,Configs/SwapConfig.class.ts). No behavior change for any currently-working consumer.Left to maintainers: version bump/changeset as you prefer, and optionally
"moduleResolution": "node16"/"nodenext"in the core tsconfig would maketsccatch this class of specifier at build time.Found while integrating
@sundaeswap/coredownstream in RealFi's partner SDK, where plain-Node ESM is currently documented as a known-broken runtime because of this.🤖 Generated with Claude Code