From bb5c9f85db0d1b99ad660ce49798e658153d6e43 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:38:52 -0500 Subject: [PATCH] feat(uniswapx): add esm build --- sdks/uniswapx-sdk/.eslintrc.json | 4 ++-- sdks/uniswapx-sdk/integration/package.json | 3 +-- sdks/uniswapx-sdk/jest.config.js | 7 +++++- sdks/uniswapx-sdk/package.json | 22 ++++++++++++++----- .../{tsconfig.json => tsconfig.base.json} | 15 ++++++------- sdks/uniswapx-sdk/tsconfig.cjs.json | 7 ++++++ sdks/uniswapx-sdk/tsconfig.esm.json | 7 ++++++ sdks/uniswapx-sdk/tsconfig.types.json | 8 +++++++ yarn.lock | 1 - 9 files changed, 55 insertions(+), 19 deletions(-) rename sdks/uniswapx-sdk/{tsconfig.json => tsconfig.base.json} (80%) create mode 100644 sdks/uniswapx-sdk/tsconfig.cjs.json create mode 100644 sdks/uniswapx-sdk/tsconfig.esm.json create mode 100644 sdks/uniswapx-sdk/tsconfig.types.json diff --git a/sdks/uniswapx-sdk/.eslintrc.json b/sdks/uniswapx-sdk/.eslintrc.json index e269c36f9..ff53fcae3 100644 --- a/sdks/uniswapx-sdk/.eslintrc.json +++ b/sdks/uniswapx-sdk/.eslintrc.json @@ -1,7 +1,7 @@ { "parser": "@typescript-eslint/parser", "parserOptions": { - "project": "./tsconfig.json" + "project": "./tsconfig.base.json" }, "env": { "es6": true @@ -60,4 +60,4 @@ "always-multiline" ] } -} \ No newline at end of file +} diff --git a/sdks/uniswapx-sdk/integration/package.json b/sdks/uniswapx-sdk/integration/package.json index 976c495f1..4205b6572 100644 --- a/sdks/uniswapx-sdk/integration/package.json +++ b/sdks/uniswapx-sdk/integration/package.json @@ -24,8 +24,7 @@ "chai": "^4.3.6", "hardhat": "^2.22.15", "husky": "^8.0.3", - "ts-node": "^10.9.1", - "tsdx": "^0.14.1" + "ts-node": "^10.9.1" }, "dependencies": { "@ethersproject/bytes": "^5.7.0", diff --git a/sdks/uniswapx-sdk/jest.config.js b/sdks/uniswapx-sdk/jest.config.js index 8cbf8940c..fb4a9bd76 100644 --- a/sdks/uniswapx-sdk/jest.config.js +++ b/sdks/uniswapx-sdk/jest.config.js @@ -2,4 +2,9 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', -}; \ No newline at end of file + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.base.json' + } + } +}; diff --git a/sdks/uniswapx-sdk/package.json b/sdks/uniswapx-sdk/package.json index 65970c7ea..d38279f09 100644 --- a/sdks/uniswapx-sdk/package.json +++ b/sdks/uniswapx-sdk/package.json @@ -7,9 +7,9 @@ "ethereum" ], "license": "MIT", - "main": "dist/src/index.js", - "typings": "dist/src/index.d.ts", - "module": "dist/uniswapx-sdk.esm.js", + "main": "./dist/cjs/src/index.js", + "typings": "./dist/types/src/index.d.ts", + "module": "./dist/esm/src/index.js", "files": [ "dist" ], @@ -17,7 +17,11 @@ "node": ">=10" }, "scripts": { - "build": "yarn run typechain && tsc -p tsconfig.json", + "clean": "rm -rf dist", + "build": "yarn clean && yarn run typechain && yarn build:cjs && yarn build:esm && yarn build:types", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build:esm": "tsc -p tsconfig.esm.json", + "build:types": "tsc -p tsconfig.types.json", "lint": "eslint src --ext .ts", "lint:fix": "eslint src --ext .ts --fix", "prettier": "prettier \"src/**/*.ts\" --list-different", @@ -96,5 +100,13 @@ } ] ] - } + }, + "exports": { + ".": { + "types": "./dist/types/src/index.d.ts", + "import": "./dist/esm/src/index.js", + "require": "./dist/cjs/src/index.js" + } + }, + "sideEffects": false } diff --git a/sdks/uniswapx-sdk/tsconfig.json b/sdks/uniswapx-sdk/tsconfig.base.json similarity index 80% rename from sdks/uniswapx-sdk/tsconfig.json rename to sdks/uniswapx-sdk/tsconfig.base.json index 24b80a37d..0971586f0 100644 --- a/sdks/uniswapx-sdk/tsconfig.json +++ b/sdks/uniswapx-sdk/tsconfig.base.json @@ -1,11 +1,9 @@ { - "include": [ - "src" - ], + "include": ["src", "abis"], "compilerOptions": { - "outDir": "dist", + "rootDir": ".", + "baseUrl": ".", "target": "es6", - "module": "commonjs", "importHelpers": true, "declaration": true, "sourceMap": true, @@ -23,6 +21,7 @@ "moduleResolution": "node", "resolveJsonModule": true, "esModuleInterop": true, - "skipLibCheck": true - }, -} \ No newline at end of file + "skipLibCheck": true, + "isolatedModules": true + } +} diff --git a/sdks/uniswapx-sdk/tsconfig.cjs.json b/sdks/uniswapx-sdk/tsconfig.cjs.json new file mode 100644 index 000000000..b868bc58d --- /dev/null +++ b/sdks/uniswapx-sdk/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist/cjs" + } +} diff --git a/sdks/uniswapx-sdk/tsconfig.esm.json b/sdks/uniswapx-sdk/tsconfig.esm.json new file mode 100644 index 000000000..eb2b70b1a --- /dev/null +++ b/sdks/uniswapx-sdk/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/sdks/uniswapx-sdk/tsconfig.types.json b/sdks/uniswapx-sdk/tsconfig.types.json new file mode 100644 index 000000000..5a850dbc4 --- /dev/null +++ b/sdks/uniswapx-sdk/tsconfig.types.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "dist/types" + } +} diff --git a/yarn.lock b/yarn.lock index 8a7d6211e..22646fac5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17616,7 +17616,6 @@ __metadata: hardhat: ^2.22.15 husky: ^8.0.3 ts-node: ^10.9.1 - tsdx: ^0.14.1 typechain: ^8.1.0 languageName: unknown linkType: soft