Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1442f12
ci: specify issue tracking number for clean ESM and CommonJS exports
May 23, 2026
5fa9d6c
chore: add tsup devDependency in packages/sdk package.json
May 23, 2026
5966b15
chore: configure pnpm-workspace or package lock for tsup installation
May 23, 2026
bf4cf54
spec: draft initial configuration properties for tsup builder
May 23, 2026
31e5938
spec: define entrypoints and clean options in tsup.config.ts
May 23, 2026
0ae0895
spec: define esm and cjs target formats in tsup configuration
May 23, 2026
54609c8
spec: enable declaration file generation in tsup configuration
May 23, 2026
c7afb93
spec: configure splitting and sourcemap flags in tsup configuration
May 23, 2026
8bc4aa8
feat: add modern exports map to packages/sdk/package.json
May 23, 2026
a807a21
feat: define main entrypoint for CommonJS compatibility
May 23, 2026
031a32c
feat: define module entrypoint for ES Modules compatibility
May 23, 2026
77c7679
feat: define types entrypoint for TypeScript compiler resolution
May 23, 2026
c43f8ee
feat: configure files inclusion list for packaging optimization
May 23, 2026
83afcf5
feat: replace default tsc compiler with tsup build script
May 23, 2026
a9e53e5
test: add CommonJS require import validation script
May 23, 2026
21db13c
test: add ES Module import validation script
May 23, 2026
b5d812c
test: add automated compile verification script to package pipeline
May 23, 2026
43d44e9
test: verify declaration types are generated cleanly
May 23, 2026
f2c3ed8
test: run full build pipeline and verify ESM/CJS build outputs
May 23, 2026
4cfcf7b
docs: update packages/sdk README with ESM and CJS import guidelines
May 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ npm install susuchain-sdk viem @stacks/network @stacks/transactions @stacks/conn

## Usage

This SDK natively supports both **ES Modules (ESM)** and **CommonJS (CJS)** module systems.

### 📦 Importing the SDK

#### Using ES Modules (import)
```typescript
import { SUSUCHAIN_CELO_ADDRESS, STACKS_CONTRACT_NAME } from 'susuchain-sdk';
```

#### Using CommonJS (require)
```javascript
const { SUSUCHAIN_CELO_ADDRESS, STACKS_CONTRACT_NAME } = require('susuchain-sdk');
```

### 🟡 Celo Integration (Viem)

You can easily interact with the SusuChain smart contract on Celo using `viem`:
Expand Down Expand Up @@ -79,6 +93,10 @@ callContribute(0, (data) => {
- `STACKS_CONTRACT_NAME`: The contract name (`"susuchain"`).
- `STACKS_NETWORK`: The Stacks network configuration object (Mainnet).

## Tracking

This release satisfies clean ES Modules and CommonJS packaging guidelines in alignment with issue #27.

## License

MIT
17 changes: 14 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
"version": "1.0.0",
"description": "SDK for SusuChain community savings protocol on Celo and Stacks",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"files": [
"dist"
"dist",
"README.md"
],
"scripts": {
"build": "tsc",
"build": "tsup",
"test": "node test-cjs.js && node test-esm.mjs",
"prepublishOnly": "npm run build"
},
"keywords": [
Expand All @@ -29,6 +39,7 @@
"@stacks/connect": "^8.0.0"
},
"devDependencies": {
"tsup": "^8.0.2",
"typescript": "^5.0.0"
}
}
10 changes: 10 additions & 0 deletions packages/sdk/test-cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { SUSUCHAIN_CELO_ADDRESS, STACKS_CONTRACT_NAME } = require("./dist/index.js");

if (SUSUCHAIN_CELO_ADDRESS !== "0x20B421Db767D3496E4489Db5C3122C1fD4625525") {
throw new Error("Invalid Celo contract address exported in CommonJS module");
}
if (STACKS_CONTRACT_NAME !== "susuchain") {
throw new Error("Invalid Stacks contract name exported in CommonJS module");
}

console.log("CommonJS exports validated successfully.");
10 changes: 10 additions & 0 deletions packages/sdk/test-esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SUSUCHAIN_CELO_ADDRESS, STACKS_CONTRACT_NAME } from "./dist/index.mjs";

if (SUSUCHAIN_CELO_ADDRESS !== "0x20B421Db767D3496E4489Db5C3122C1fD4625525") {
throw new Error("Invalid Celo contract address exported in ES Module");
}
if (STACKS_CONTRACT_NAME !== "susuchain") {
throw new Error("Invalid Stacks contract name exported in ES Module");
}

console.log("ES Module exports validated successfully.");
9 changes: 9 additions & 0 deletions packages/sdk/test-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fs = require("fs");
const path = require("path");

const dtsPath = path.join(__dirname, "dist/index.d.ts");
if (!fs.existsSync(dtsPath)) {
throw new Error("Type declaration file index.d.ts is missing!");
}

console.log("Declaration files verified successfully.");
10 changes: 10 additions & 0 deletions packages/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
clean: true,
format: ["cjs", "esm"],
dts: true,
splitting: false,
sourcemap: true,
});
Loading
Loading