From e84844767c7b5dee8455ab0600f54ccb5e1faa14 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 19:29:39 +0000 Subject: [PATCH] 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 --- apps/hermes/client/js/package.json | 19 +++++++++++++++---- apps/hermes/client/js/tsconfig.cjs.json | 7 +++++++ apps/hermes/client/js/tsconfig.json | 12 +++--------- apps/price_pusher/package.json | 19 +++++++++++++++---- apps/price_pusher/tsconfig.cjs.json | 7 +++++++ apps/price_pusher/tsconfig.json | 8 ++------ price_service/sdk/js/package.json | 17 ++++++++++++++--- price_service/sdk/js/src/index.ts | 4 ++-- price_service/sdk/js/tsconfig.cjs.json | 7 +++++++ price_service/sdk/js/tsconfig.json | 10 ++++++---- target_chains/aptos/sdk/js/package.json | 17 ++++++++++++++--- target_chains/aptos/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/aptos/sdk/js/tsconfig.json | 9 +++------ target_chains/ethereum/sdk/js/package.json | 17 ++++++++++++++--- .../ethereum/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/ethereum/sdk/js/tsconfig.json | 8 ++------ target_chains/fuel/sdk/js/package.json | 17 ++++++++++++++--- target_chains/fuel/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/fuel/sdk/js/tsconfig.json | 10 +++------- .../sdk/js/pyth_solana_receiver/package.json | 17 ++++++++++++++--- .../js/pyth_solana_receiver/tsconfig.cjs.json | 7 +++++++ .../sdk/js/pyth_solana_receiver/tsconfig.json | 10 ++++++---- .../solana/sdk/js/solana_utils/package.json | 17 ++++++++++++++--- .../sdk/js/solana_utils/tsconfig.cjs.json | 7 +++++++ .../solana/sdk/js/solana_utils/tsconfig.json | 10 ++++++---- target_chains/starknet/sdk/js/package.json | 17 ++++++++++++++--- .../starknet/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/starknet/sdk/js/tsconfig.json | 10 +++------- target_chains/sui/sdk/js/package.json | 17 ++++++++++++++--- target_chains/sui/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/sui/sdk/js/tsconfig.json | 9 +++------ target_chains/ton/sdk/js/package.json | 17 ++++++++++++++--- target_chains/ton/sdk/js/tsconfig.cjs.json | 7 +++++++ target_chains/ton/sdk/js/tsconfig.json | 10 +++------- tsconfig.base.json | 3 ++- 35 files changed, 277 insertions(+), 104 deletions(-) create mode 100644 apps/hermes/client/js/tsconfig.cjs.json create mode 100644 apps/price_pusher/tsconfig.cjs.json create mode 100644 price_service/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/aptos/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/ethereum/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/fuel/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json create mode 100644 target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json create mode 100644 target_chains/starknet/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/sui/sdk/js/tsconfig.cjs.json create mode 100644 target_chains/ton/sdk/js/tsconfig.cjs.json diff --git a/apps/hermes/client/js/package.json b/apps/hermes/client/js/package.json index 0527074b51..92da10a176 100644 --- a/apps/hermes/client/js/package.json +++ b/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" }, diff --git a/apps/hermes/client/js/tsconfig.cjs.json b/apps/hermes/client/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/apps/hermes/client/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/apps/hermes/client/js/tsconfig.json b/apps/hermes/client/js/tsconfig.json index 1b72ccf95f..bf5e5e7818 100644 --- a/apps/hermes/client/js/tsconfig.json +++ b/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"] diff --git a/apps/price_pusher/package.json b/apps/price_pusher/package.json index 3a858803f3..051ea64608 100644 --- a/apps/price_pusher/package.json +++ b/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", diff --git a/apps/price_pusher/tsconfig.cjs.json b/apps/price_pusher/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/apps/price_pusher/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/apps/price_pusher/tsconfig.json b/apps/price_pusher/tsconfig.json index 277aacdfce..9572ee0d06 100644 --- a/apps/price_pusher/tsconfig.json +++ b/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__/*"] diff --git a/price_service/sdk/js/package.json b/price_service/sdk/js/package.json index a6e0dad272..2bbf26946b 100644 --- a/price_service/sdk/js/package.json +++ b/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", diff --git a/price_service/sdk/js/src/index.ts b/price_service/sdk/js/src/index.ts index 27640f1114..6d2234bfd9 100644 --- a/price_service/sdk/js/src/index.ts +++ b/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`. diff --git a/price_service/sdk/js/tsconfig.cjs.json b/price_service/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/price_service/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/price_service/sdk/js/tsconfig.json b/price_service/sdk/js/tsconfig.json index be27cdded2..fa757eabd5 100644 --- a/price_service/sdk/js/tsconfig.json +++ b/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__/*"] } diff --git a/target_chains/aptos/sdk/js/package.json b/target_chains/aptos/sdk/js/package.json index 69f4c105c1..0fd952ce6d 100644 --- a/target_chains/aptos/sdk/js/package.json +++ b/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/", diff --git a/target_chains/aptos/sdk/js/tsconfig.cjs.json b/target_chains/aptos/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/aptos/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/aptos/sdk/js/tsconfig.json b/target_chains/aptos/sdk/js/tsconfig.json index 927049ab35..b9ad606f4f 100644 --- a/target_chains/aptos/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/target_chains/ethereum/sdk/js/package.json b/target_chains/ethereum/sdk/js/package.json index 6d92b7b037..1a64a5acf7 100644 --- a/target_chains/ethereum/sdk/js/package.json +++ b/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", diff --git a/target_chains/ethereum/sdk/js/tsconfig.cjs.json b/target_chains/ethereum/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/ethereum/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/ethereum/sdk/js/tsconfig.json b/target_chains/ethereum/sdk/js/tsconfig.json index 462f0d5983..b9ad606f4f 100644 --- a/target_chains/ethereum/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/target_chains/fuel/sdk/js/package.json b/target_chains/fuel/sdk/js/package.json index ec6431308a..9fd62b77ea 100644 --- a/target_chains/fuel/sdk/js/package.json +++ b/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/", diff --git a/target_chains/fuel/sdk/js/tsconfig.cjs.json b/target_chains/fuel/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/fuel/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/fuel/sdk/js/tsconfig.json b/target_chains/fuel/sdk/js/tsconfig.json index bae5d05cde..6a7798a42a 100644 --- a/target_chains/fuel/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/target_chains/solana/sdk/js/pyth_solana_receiver/package.json b/target_chains/solana/sdk/js/pyth_solana_receiver/package.json index ff826b26f4..3f4f6f2b7b 100644 --- a/target_chains/solana/sdk/js/pyth_solana_receiver/package.json +++ b/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", diff --git a/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json b/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.json b/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.json index 4a55b57b49..0ff1d3c98c 100644 --- a/target_chains/solana/sdk/js/pyth_solana_receiver/tsconfig.json +++ b/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__/*"] } diff --git a/target_chains/solana/sdk/js/solana_utils/package.json b/target_chains/solana/sdk/js/solana_utils/package.json index e2754ab9d6..6b48ff13f3 100644 --- a/target_chains/solana/sdk/js/solana_utils/package.json +++ b/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/", diff --git a/target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json b/target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/solana/sdk/js/solana_utils/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/solana/sdk/js/solana_utils/tsconfig.json b/target_chains/solana/sdk/js/solana_utils/tsconfig.json index 4a55b57b49..0ff1d3c98c 100644 --- a/target_chains/solana/sdk/js/solana_utils/tsconfig.json +++ b/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__/*"] } diff --git a/target_chains/starknet/sdk/js/package.json b/target_chains/starknet/sdk/js/package.json index 8f485a3e66..afe55443b7 100644 --- a/target_chains/starknet/sdk/js/package.json +++ b/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/", diff --git a/target_chains/starknet/sdk/js/tsconfig.cjs.json b/target_chains/starknet/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/starknet/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/starknet/sdk/js/tsconfig.json b/target_chains/starknet/sdk/js/tsconfig.json index bae5d05cde..6a7798a42a 100644 --- a/target_chains/starknet/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/target_chains/sui/sdk/js/package.json b/target_chains/sui/sdk/js/package.json index 5b0a77fb1f..43ef2748cd 100644 --- a/target_chains/sui/sdk/js/package.json +++ b/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/", diff --git a/target_chains/sui/sdk/js/tsconfig.cjs.json b/target_chains/sui/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/sui/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/sui/sdk/js/tsconfig.json b/target_chains/sui/sdk/js/tsconfig.json index 927049ab35..b9ad606f4f 100644 --- a/target_chains/sui/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/target_chains/ton/sdk/js/package.json b/target_chains/ton/sdk/js/package.json index afcf8c1f0c..085603fc7c 100644 --- a/target_chains/ton/sdk/js/package.json +++ b/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", diff --git a/target_chains/ton/sdk/js/tsconfig.cjs.json b/target_chains/ton/sdk/js/tsconfig.cjs.json new file mode 100644 index 0000000000..d944d7cfd5 --- /dev/null +++ b/target_chains/ton/sdk/js/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./lib/cjs" + } +} diff --git a/target_chains/ton/sdk/js/tsconfig.json b/target_chains/ton/sdk/js/tsconfig.json index bae5d05cde..6a7798a42a 100644 --- a/target_chains/ton/sdk/js/tsconfig.json +++ b/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__/*"] diff --git a/tsconfig.base.json b/tsconfig.base.json index 1192b913fb..6a83a195e7 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,7 +1,8 @@ { "compilerOptions": { "target": "esnext", - "module": "commonjs", + "module": "node16", + "moduleResolution": "node16", "declaration": true, "composite": true, "declarationMap": true,