I would like to use stablecoin studio sdk in my plugin but because of problems with ESM imports I have errors. @hashgraph/stablecoin-npm-sdk@4.2.0 cannot be imported in any Node.js ESM project ("type": "module"). The ESM build output (build/esm/) has three categories of bugs that prevent it from loading.
Environment
@hashgraph/stablecoin-npm-sdk: 4.2.0
- Node.js: v24.14.1 (also reproducible on v20+)
Minimal reproduction
mkdir repro && cd repro
echo '{ "type": "module", "dependencies": { "@hashgraph/stablecoin-npm-sdk": "^4.2.0" } }' > package.json
npm install
node -e "import('@hashgraph/stablecoin-npm-sdk').then(m => console.log(Object.keys(m)))"
Issue 1: Missing .js extensions in relative imports (162 occurrences)
Node.js ESM requires file extensions in relative import specifiers (Node.js docs).
Entry point — build/esm/src/index.js:23:
// ❌ Actual (missing .js extension)
export * from './port/in/index';
// ✅ Expected
export * from './port/in/index.js';
Error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../build/esm/src/port/in/index'
imported from .../build/esm/src/index.js
Issue 2: require() used inside ESM file
File: build/esm/src/port/out/hs/walletconnect/HederaWalletConnectTransactionAdapter.js:52
// ❌ require() is not available in ESM scope
const { SupportedWallets } = require('@hashgraph/stablecoin-npm-sdk');
Error:
ReferenceError: require is not defined in ES module scope, you can use import instead
This is also a circular self-import (the SDK requiring itself). It should use a regular ESM import:
// ✅ Expected
import { SupportedWallets } from '@hashgraph/stablecoin-npm-sdk';
Same file also has dynamic require() calls at lines 56-58:
const hwc = require('@hashgraph/hedera-wallet-connect');
const appkit = require('@reown/appkit');
These should use dynamic import() instead.
Issue 3: Directory import through package exports wildcard
File: build/esm/src/app/service/TransactionService.js:42
// ❌ Directory import — not supported through exports field
import * as Factories from '@hashgraph/stablecoin-npm-contracts/typechain-types/factories/contracts';
@hashgraph/stablecoin-npm-contracts/package.json exports map:
{
"exports": {
"./typechain-types/*": {
"import": "./build/typechain-types/*",
"require": "./build/typechain-types/*"
}
}
}
Error:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../factories/contracts' is not supported
resolving ES modules
The wildcard * in exports does not match directory paths. The import should include the explicit file:
// ✅ Expected
import * as Factories from '@hashgraph/stablecoin-npm-contracts/typechain-types/factories/contracts/index.js';
Note: This issue also exists in the CJS build (build/cjs/src/app/service/TransactionService.js:81).
Impact
- Any ESM project (
"type": "module" in package.json) cannot use @hashgraph/stablecoin-npm-sdk
- This affects all modern Node.js projects using ESM, Next.js apps, and any bundler that relies on Node.js ESM resolution
- The CJS build (
build/cjs/) works correctly (except for Issue 3)
Additional: @hashgraph/stablecoin-npm-contracts has simillar issues.
I would like to use stablecoin studio sdk in my plugin but because of problems with ESM imports I have errors.
@hashgraph/stablecoin-npm-sdk@4.2.0cannot be imported in any Node.js ESM project ("type": "module"). The ESM build output (build/esm/) has three categories of bugs that prevent it from loading.Environment
@hashgraph/stablecoin-npm-sdk: 4.2.0Minimal reproduction
Issue 1: Missing
.jsextensions in relative imports (162 occurrences)Node.js ESM requires file extensions in relative import specifiers (Node.js docs).
Entry point —
build/esm/src/index.js:23:Error:
Issue 2:
require()used inside ESM fileFile:
build/esm/src/port/out/hs/walletconnect/HederaWalletConnectTransactionAdapter.js:52Error:
This is also a circular self-import (the SDK requiring itself). It should use a regular ESM import:
Same file also has dynamic
require()calls at lines 56-58:These should use dynamic
import()instead.Issue 3: Directory import through package
exportswildcardFile:
build/esm/src/app/service/TransactionService.js:42@hashgraph/stablecoin-npm-contracts/package.jsonexports map:{ "exports": { "./typechain-types/*": { "import": "./build/typechain-types/*", "require": "./build/typechain-types/*" } } }Error:
The wildcard
*in exports does not match directory paths. The import should include the explicit file:Note: This issue also exists in the CJS build (
build/cjs/src/app/service/TransactionService.js:81).Impact
"type": "module"in package.json) cannot use@hashgraph/stablecoin-npm-sdkbuild/cjs/) works correctly (except for Issue 3)Additional:
@hashgraph/stablecoin-npm-contractshas simillar issues.