Skip to content

Commit afca363

Browse files
committed
fix(pmxtjs): implement dual build (CJS/ESM) and fix default export interop
- Removed 'type: module' from package.json to support CJS by default - Added 'dist/esm/package.json' generation to support ESM loaders - Configured 'exports' field for proper CJS/ESM resolution - Maintained 'import pmxt from '\''pmxtjs'\''' syntax for ESM users - Updated tsconfig to output CommonJS and ESNext variants
1 parent 37a1b52 commit afca363

5 files changed

Lines changed: 9 additions & 10 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export { Exchange, Polymarket, Kalshi } from "./pmxt/client.js";
2727
export { ServerManager } from "./pmxt/server-manager.js";
2828
export type * from "./pmxt/models.js";
2929

30-
export const VERSION = "0.0.1";
3130

3231
const pmxt = {
3332
Exchange,

sdks/typescript/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"main": "./dist/index.js",
1111
"types": "./dist/index.d.ts",
1212
"module": "./dist/esm/index.js",
13-
"type": "module",
1413
"sideEffects": false,
1514
"exports": {
1615
".": {
@@ -30,7 +29,7 @@
3029
"clean": "rm -rf dist",
3130
"generate": "npm run generate:sdk:typescript --workspace=pmxt-core",
3231
"prebuild": "npm run clean",
33-
"build": "tsc && tsc -p tsconfig.esm.json",
32+
"build": "tsc && tsc -p tsconfig.esm.json && echo '{ \"type\": \"module\" }' > dist/esm/package.json",
3433
"prepack": "npm run build",
3534
"test": "jest"
3635
},
@@ -49,4 +48,4 @@
4948
"ts-jest": "^29.4.6",
5049
"typescript": "^5.0.0"
5150
}
52-
}
51+
}

sdks/typescript/tsconfig.esm.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"module": "NodeNext",
4+
"module": "ESNext",
5+
"moduleResolution": "Node",
56
"outDir": "dist/esm"
67
}
78
}

sdks/typescript/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
4-
"module": "NodeNext",
5-
"moduleResolution": "NodeNext",
3+
"target": "ES2022",
4+
"module": "CommonJS",
5+
"moduleResolution": "Node",
66
"declaration": true,
77
"outDir": "./dist",
88
"strict": true,

0 commit comments

Comments
 (0)