From 28e9a624641da3e753e77acf95ae375239cb29f2 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:22:34 -0500 Subject: [PATCH] feat(v3-sdk): separate esm / cjs builds --- sdks/v3-sdk/.eslintrc.json | 12 ++++++++++ sdks/v3-sdk/jest.config.js | 11 +++++++++ sdks/v3-sdk/package.json | 42 ++++++++++++++++++++------------- sdks/v3-sdk/tsconfig.base.json | 18 ++++++++++++++ sdks/v3-sdk/tsconfig.cjs.json | 7 ++++++ sdks/v3-sdk/tsconfig.esm.json | 7 ++++++ sdks/v3-sdk/tsconfig.json | 24 ------------------- sdks/v3-sdk/tsconfig.test.json | 8 +++++++ sdks/v3-sdk/tsconfig.types.json | 8 +++++++ yarn.lock | 12 +++++++--- 10 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 sdks/v3-sdk/.eslintrc.json create mode 100644 sdks/v3-sdk/jest.config.js create mode 100644 sdks/v3-sdk/tsconfig.base.json create mode 100644 sdks/v3-sdk/tsconfig.cjs.json create mode 100644 sdks/v3-sdk/tsconfig.esm.json delete mode 100644 sdks/v3-sdk/tsconfig.json create mode 100644 sdks/v3-sdk/tsconfig.test.json create mode 100644 sdks/v3-sdk/tsconfig.types.json diff --git a/sdks/v3-sdk/.eslintrc.json b/sdks/v3-sdk/.eslintrc.json new file mode 100644 index 000000000..bbdfe264e --- /dev/null +++ b/sdks/v3-sdk/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "extends": [ + "prettier", + "prettier/@typescript-eslint" + ], + "ignorePatterns": ["dist/**"] +} diff --git a/sdks/v3-sdk/jest.config.js b/sdks/v3-sdk/jest.config.js new file mode 100644 index 000000000..d584c8991 --- /dev/null +++ b/sdks/v3-sdk/jest.config.js @@ -0,0 +1,11 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + rootDir: 'src', + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.base.json', + }, + }, +} diff --git a/sdks/v3-sdk/package.json b/sdks/v3-sdk/package.json index 2f876f49e..59debf605 100644 --- a/sdks/v3-sdk/package.json +++ b/sdks/v3-sdk/package.json @@ -7,9 +7,9 @@ "ethereum" ], "license": "MIT", - "main": "dist/index.js", - "typings": "dist/index.d.ts", - "module": "dist/v3-sdk.esm.js", + "main": "./dist/cjs/src/index.js", + "module": "./dist/esm/src/index.js", + "types": "./dist/types/src/index.d.ts", "files": [ "dist" ], @@ -17,12 +17,22 @@ "node": ">=10" }, "scripts": { - "build": "tsdx build", - "lint": "tsdx lint src", - "release": "semantic-release", - "start": "tsdx watch", - "test": "tsdx test" + "clean": "rm -rf dist", + "build": "yarn clean && 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", + "test": "jest" }, + "exports": { + ".": { + "types": "./dist/types/src/index.d.ts", + "import": "./dist/esm/src/index.js", + "require": "./dist/cjs/src/index.js" + } + }, + "sideEffects": false, "dependencies": { "@ethersproject/abi": "^5.5.0", "@ethersproject/solidity": "^5.0.9", @@ -36,14 +46,14 @@ "devDependencies": { "@types/jest": "^24.0.25", "@uniswap/v3-core": "1.0.0", - "babel-jest": "25.5.1", - "tsdx": "^0.14.1" - }, - "resolutions": { - "regenerator-runtime": "^0.14.1" - }, - "resolutionsComments": { - "regenerator-runtime": "Fixes https://github.com/facebook/regenerator/pull/480. It can be removed when `tsdx` updates their dependencies." + "eslint": "^7.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^3.0.2", + "eslint-plugin-import": "^2.22.0", + "jest": "25.5.0", + "prettier": "^2.4.1", + "typescript": "^4.3.3" }, "prettier": { "printWidth": 120, diff --git a/sdks/v3-sdk/tsconfig.base.json b/sdks/v3-sdk/tsconfig.base.json new file mode 100644 index 000000000..70ee6af6e --- /dev/null +++ b/sdks/v3-sdk/tsconfig.base.json @@ -0,0 +1,18 @@ +{ + "include": ["src"], + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "target": "es2018", + "module": "esnext", + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "isolatedModules": true + } +} diff --git a/sdks/v3-sdk/tsconfig.cjs.json b/sdks/v3-sdk/tsconfig.cjs.json new file mode 100644 index 000000000..b868bc58d --- /dev/null +++ b/sdks/v3-sdk/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist/cjs" + } +} diff --git a/sdks/v3-sdk/tsconfig.esm.json b/sdks/v3-sdk/tsconfig.esm.json new file mode 100644 index 000000000..eb2b70b1a --- /dev/null +++ b/sdks/v3-sdk/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/sdks/v3-sdk/tsconfig.json b/sdks/v3-sdk/tsconfig.json deleted file mode 100644 index 008638425..000000000 --- a/sdks/v3-sdk/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "include": ["src"], - "compilerOptions": { - "target": "es2018", - "module": "esnext", - "importHelpers": true, - "declaration": true, - "sourceMap": true, - "strict": true, - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "esModuleInterop": true, - "resolveJsonModule": true - } -} diff --git a/sdks/v3-sdk/tsconfig.test.json b/sdks/v3-sdk/tsconfig.test.json new file mode 100644 index 000000000..ad72d520f --- /dev/null +++ b/sdks/v3-sdk/tsconfig.test.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "moduleResolution": "node", + "types": ["jest", "node"] + }, + "include": ["src/**/*.ts", "src/**/*.test.ts"] +} diff --git a/sdks/v3-sdk/tsconfig.types.json b/sdks/v3-sdk/tsconfig.types.json new file mode 100644 index 000000000..5a850dbc4 --- /dev/null +++ b/sdks/v3-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 05b65e0d3..b8a5bea8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4503,10 +4503,16 @@ __metadata: "@uniswap/v3-core": 1.0.0 "@uniswap/v3-periphery": ^1.1.1 "@uniswap/v3-staker": 1.0.0 - babel-jest: 25.5.1 + eslint: ^7.8.0 + eslint-config-prettier: ^6.11.0 + eslint-plugin-eslint-comments: ^3.2.0 + eslint-plugin-functional: ^3.0.2 + eslint-plugin-import: ^2.22.0 + jest: 25.5.0 + prettier: ^2.4.1 tiny-invariant: ^1.1.0 tiny-warning: ^1.0.3 - tsdx: ^0.14.1 + typescript: ^4.3.3 languageName: unknown linkType: soft @@ -5249,7 +5255,7 @@ __metadata: languageName: node linkType: hard -"babel-jest@npm:25.5.1, babel-jest@npm:^25.5.1": +"babel-jest@npm:^25.5.1": version: 25.5.1 resolution: "babel-jest@npm:25.5.1" dependencies: