소스 검색

feat: add dual cjs/esm exports to all public packages

- Update build configuration to support both CJS and ESM
- Add dual export fields to package.json
- Maintain backward compatibility
- Update tsconfig for dual compilation

Co-Authored-By: Connor Prussin <connor@dourolabs.xyz>
Devin AI 9 달 전
부모
커밋
e84844767c
35개의 변경된 파일277개의 추가작업 그리고 104개의 파일을 삭제
  1. 15 4
      apps/hermes/client/js/package.json
  2. 7 0
      apps/hermes/client/js/tsconfig.cjs.json
  3. 3 9
      apps/hermes/client/js/tsconfig.json
  4. 15 4
      apps/price_pusher/package.json
  5. 7 0
      apps/price_pusher/tsconfig.cjs.json
  6. 2 6
      apps/price_pusher/tsconfig.json
  7. 14 3
      price_service/sdk/js/package.json
  8. 2 2
      price_service/sdk/js/src/index.ts
  9. 7 0
      price_service/sdk/js/tsconfig.cjs.json
  10. 6 4
      price_service/sdk/js/tsconfig.json
  11. 14 3
      target_chains/aptos/sdk/js/package.json
  12. 7 0
      target_chains/aptos/sdk/js/tsconfig.cjs.json
  13. 3 6
      target_chains/aptos/sdk/js/tsconfig.json
  14. 14 3
      target_chains/ethereum/sdk/js/package.json
  15. 7 0
      target_chains/ethereum/sdk/js/tsconfig.cjs.json
  16. 2 6
      target_chains/ethereum/sdk/js/tsconfig.json
  17. 14 3
      target_chains/fuel/sdk/js/package.json
  18. 7 0
      target_chains/fuel/sdk/js/tsconfig.cjs.json
  19. 3 7
      target_chains/fuel/sdk/js/tsconfig.json
  20. 14 3
      target_chains/solana/sdk/js/pyth_solana_receiver/package.json
  21. 7 0
      target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json
  22. 6 4
      target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.json
  23. 14 3
      target_chains/solana/sdk/js/solana_utils/package.json
  24. 7 0
      target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json
  25. 6 4
      target_chains/solana/sdk/js/solana_utils/tsconfig.json
  26. 14 3
      target_chains/starknet/sdk/js/package.json
  27. 7 0
      target_chains/starknet/sdk/js/tsconfig.cjs.json
  28. 3 7
      target_chains/starknet/sdk/js/tsconfig.json
  29. 14 3
      target_chains/sui/sdk/js/package.json
  30. 7 0
      target_chains/sui/sdk/js/tsconfig.cjs.json
  31. 3 6
      target_chains/sui/sdk/js/tsconfig.json
  32. 14 3
      target_chains/ton/sdk/js/package.json
  33. 7 0
      target_chains/ton/sdk/js/tsconfig.cjs.json
  34. 3 7
      target_chains/ton/sdk/js/tsconfig.json
  35. 2 1
      tsconfig.base.json

+ 15 - 4
apps/hermes/client/js/package.json

@@ -6,8 +6,17 @@
     "name": "Pyth Data Association"
   },
   "homepage": "https://pyth.network",
-  "main": "lib/HermesClient.js",
-  "types": "lib/HermesClient.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/HermesClient.js",
+      "require": "./lib/cjs/HermesClient.js",
+      "types": "./lib/HermesClient.d.ts"
+    }
+  },
+  "main": "./lib/cjs/HermesClient.js",
+  "module": "./lib/HermesClient.js",
+  "types": "./lib/HermesClient.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,13 +29,15 @@
     "access": "public"
   },
   "scripts": {
-    "build:typescript": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "build:schemas": "openapi-zod-client ./schema.json --output src/zodSchemas.ts",
     "pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
     "example": "node lib/examples/HermesClient.js",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",
-    "prepublishOnly": "pnpm run build:typescript && pnpm run test:lint",
+    "prepublishOnly": "pnpm run build && pnpm run test:lint",
     "preversion": "pnpm run test:lint",
     "version": "pnpm run format && git add -A src"
   },

+ 7 - 0
apps/hermes/client/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 9
apps/hermes/client/js/tsconfig.json

@@ -1,16 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "composite": true,
-    "declarationMap": true,
-    "incremental": true,
-    "outDir": "./lib",
-    "strict": true,
     "rootDir": "src/",
-    "esModuleInterop": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src"],
   "exclude": ["node_modules"]

+ 15 - 4
apps/price_pusher/package.json

@@ -3,8 +3,17 @@
   "version": "9.0.0",
   "description": "Pyth Price Pusher",
   "homepage": "https://pyth.network",
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,10 +29,12 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",
-    "start": "node lib/index.js",
+    "start": "node lib/cjs/index.js",
     "dev": "ts-node src/index.ts",
     "prepublishOnly": "pnpm run build && pnpm run test:lint",
     "preversion": "pnpm run test:lint",

+ 7 - 0
apps/price_pusher/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 2 - 6
apps/price_pusher/tsconfig.json

@@ -1,14 +1,10 @@
 {
   "extends": "../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
     "rootDir": "src/",
     "outDir": "./lib",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
price_service/sdk/js/package.json

@@ -3,8 +3,17 @@
   "version": "1.8.0",
   "description": "Pyth price service SDK",
   "homepage": "https://pyth.network",
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -17,7 +26,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "format": "prettier --write \"src/**/*.ts\"",
     "gen-ts-schema": "quicktype --src-lang schema src/schemas/price_feed.json -o src/schemas/PriceFeed.ts --raw-type any --converters all-objects && prettier --write \"src/schemas/*.ts\"",
     "test:unit": "jest",

+ 2 - 2
price_service/sdk/js/src/index.ts

@@ -3,7 +3,7 @@ import {
   Price as JsonPrice,
   PriceFeed as JsonPriceFeed,
   PriceFeedMetadata as JsonPriceFeedMetadata,
-} from "./schemas/PriceFeed";
+} from "./schemas/PriceFeed.js";
 
 export type UnixTimestamp = number;
 export type DurationInSeconds = number;
@@ -16,7 +16,7 @@ export {
   AccumulatorUpdateData,
   parsePriceFeedMessage,
   parseTwapMessage,
-} from "./AccumulatorUpdateData";
+} from "./AccumulatorUpdateData.js";
 
 /**
  * A Pyth Price represented as `${price} ± ${conf} * 10^${expo}` published at `publishTime`.

+ 7 - 0
price_service/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 6 - 4
price_service/sdk/js/tsconfig.json

@@ -1,9 +1,11 @@
 {
   "extends": "../../../tsconfig.base.json",
-  "include": ["src"],
-  "exclude": ["node_modules", "**/__tests__/*"],
   "compilerOptions": {
     "rootDir": "src/",
-    "outDir": "./lib"
-  }
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
+  },
+  "include": ["src"],
+  "exclude": ["node_modules", "**/__tests__/*"]
 }

+ 14 - 3
target_chains/aptos/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,7 +29,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "example-relay": "pnpm run build && node lib/examples/AptosRelay.js",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",

+ 7 - 0
target_chains/aptos/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 6
target_chains/aptos/sdk/js/tsconfig.json

@@ -1,13 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "outDir": "./lib",
     "rootDir": "src/",
-    "strict": true,
-    "esModuleInterop": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
target_chains/ethereum/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,7 +29,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "example-client": "pnpm run build && node lib/examples/EvmPriceServiceClient.js",
     "example-relay": "pnpm run build && node lib/examples/EvmRelay.js",
     "example-benchmark": "pnpm run build && node lib/examples/EvmBenchmark.js",

+ 7 - 0
target_chains/ethereum/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 2 - 6
target_chains/ethereum/sdk/js/tsconfig.json

@@ -1,14 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
     "rootDir": "src/",
     "outDir": "./lib",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
target_chains/fuel/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -21,7 +30,9 @@
   },
   "scripts": {
     "usage-example": "ts-node src/examples/usage.ts",
-    "build": "pnpm run generate-fuel-types && tsc && copyfiles -u 1 \"src/**/*.d.ts\" lib",
+    "build": "pnpm run generate-fuel-types && pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc && copyfiles -u 1 \"src/**/*.d.ts\" lib",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "test:format": "prettier --check \"src/**/*.ts\"",
     "fix:format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",

+ 7 - 0
target_chains/fuel/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 7
target_chains/fuel/sdk/js/tsconfig.json

@@ -1,14 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "outDir": "./lib",
     "rootDir": "src/",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src", "src/**/*.json"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
target_chains/solana/sdk/js/pyth_solana_receiver/package.json

@@ -3,8 +3,17 @@
   "version": "0.9.1",
   "description": "Pyth solana receiver SDK",
   "homepage": "https://pyth.network",
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -17,7 +26,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",
     "prepublishOnly": "pnpm run build && pnpm test:lint",

+ 7 - 0
target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 6 - 4
target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.json

@@ -1,9 +1,11 @@
 {
   "extends": "../../../../../tsconfig.base.json",
-  "include": ["src/**/*.ts", "src/**/*.json"],
-  "exclude": ["node_modules", "**/__tests__/*"],
   "compilerOptions": {
     "rootDir": "src/",
-    "outDir": "./lib"
-  }
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
+  },
+  "include": ["src/**/*.ts", "src/**/*.json"],
+  "exclude": ["node_modules", "**/__tests__/*"]
 }

+ 14 - 3
target_chains/solana/sdk/js/solana_utils/package.json

@@ -3,8 +3,17 @@
   "version": "0.4.4",
   "description": "Utility functions for Solana",
   "homepage": "https://pyth.network",
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -17,7 +26,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:unit": "jest",
     "test:lint": "eslint src/",

+ 7 - 0
target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 6 - 4
target_chains/solana/sdk/js/solana_utils/tsconfig.json

@@ -1,9 +1,11 @@
 {
   "extends": "../../../../../tsconfig.base.json",
-  "include": ["src/**/*.ts", "src/**/*.json"],
-  "exclude": ["node_modules", "**/__tests__/*"],
   "compilerOptions": {
     "rootDir": "src/",
-    "outDir": "./lib"
-  }
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
+  },
+  "include": ["src/**/*.ts", "src/**/*.json"],
+  "exclude": ["node_modules", "**/__tests__/*"]
 }

+ 14 - 3
target_chains/starknet/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,7 +29,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "usage-example": "ts-node src/examples/usage.ts",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",

+ 7 - 0
target_chains/starknet/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 7
target_chains/starknet/sdk/js/tsconfig.json

@@ -1,14 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "outDir": "./lib",
     "rootDir": "src/",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src", "src/**/*.json"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
target_chains/sui/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,7 +29,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "example-relay": "pnpm run build && node lib/examples/SuiRelay.js",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",

+ 7 - 0
target_chains/sui/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 6
target_chains/sui/sdk/js/tsconfig.json

@@ -1,13 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "outDir": "./lib",
     "rootDir": "src/",
-    "strict": true,
-    "esModuleInterop": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 14 - 3
target_chains/ton/sdk/js/package.json

@@ -6,8 +6,17 @@
   "author": {
     "name": "Pyth Data Association"
   },
-  "main": "lib/index.js",
-  "types": "lib/index.d.ts",
+  "type": "module",
+  "exports": {
+    ".": {
+      "import": "./lib/index.js",
+      "require": "./lib/cjs/index.js",
+      "types": "./lib/index.d.ts"
+    }
+  },
+  "main": "./lib/cjs/index.js",
+  "module": "./lib/index.js",
+  "types": "./lib/index.d.ts",
   "files": [
     "lib/**/*"
   ],
@@ -20,7 +29,9 @@
     "access": "public"
   },
   "scripts": {
-    "build": "tsc",
+    "build": "pnpm run build:esm && pnpm run build:cjs",
+    "build:esm": "tsc",
+    "build:cjs": "tsc --module commonjs --outDir lib/cjs",
     "format": "prettier --write \"src/**/*.ts\"",
     "test:lint": "eslint src/",
     "prepublishOnly": "pnpm run build && pnpm run test:lint",

+ 7 - 0
target_chains/ton/sdk/js/tsconfig.cjs.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "module": "commonjs",
+    "outDir": "./lib/cjs"
+  }
+}

+ 3 - 7
target_chains/ton/sdk/js/tsconfig.json

@@ -1,14 +1,10 @@
 {
   "extends": "../../../../tsconfig.base.json",
   "compilerOptions": {
-    "target": "esnext",
-    "module": "commonjs",
-    "declaration": true,
-    "outDir": "./lib",
     "rootDir": "src/",
-    "strict": true,
-    "esModuleInterop": true,
-    "resolveJsonModule": true
+    "outDir": "./lib",
+    "module": "node16",
+    "moduleResolution": "node16"
   },
   "include": ["src", "src/**/*.json"],
   "exclude": ["node_modules", "**/__tests__/*"]

+ 2 - 1
tsconfig.base.json

@@ -1,7 +1,8 @@
 {
   "compilerOptions": {
     "target": "esnext",
-    "module": "commonjs",
+    "module": "node16",
+    "moduleResolution": "node16",
     "declaration": true,
     "composite": true,
     "declarationMap": true,