diff --git a/sdks/router-sdk/.eslintrc.json b/sdks/router-sdk/.eslintrc.json new file mode 100644 index 000000000..bbdfe264e --- /dev/null +++ b/sdks/router-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/router-sdk/jest.config.js b/sdks/router-sdk/jest.config.js new file mode 100644 index 000000000..876eab7f6 --- /dev/null +++ b/sdks/router-sdk/jest.config.js @@ -0,0 +1,12 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + rootDir: 'src', + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.base.json' + } + } + }; + \ No newline at end of file diff --git a/sdks/router-sdk/package.json b/sdks/router-sdk/package.json index 91721f6e4..404587a64 100644 --- a/sdks/router-sdk/package.json +++ b/sdks/router-sdk/package.json @@ -7,17 +7,21 @@ "ethereum" ], "license": "MIT", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "main": "./dist/cjs/src/index.js", + "module": "./dist/esm/src/index.js", + "types": "./dist/types/src/index.d.ts", "files": [ "dist" ], "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", + "lint:fix": "eslint src --ext .ts --fix", + "test": "jest" }, "dependencies": { "@ethersproject/abi": "^5.5.0", @@ -29,18 +33,27 @@ }, "devDependencies": { "@types/jest": "^24.0.25", - "prettier": "^2.4.1", - "tsdx": "^0.14.1" - }, - "prettier": { - "printWidth": 120, - "semi": false, - "singleQuote": true + "@typescript-eslint/eslint-plugin": "^5.62", + "@typescript-eslint/parser": "^5.62", + "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" }, "publishConfig": { "access": "public", "provenance": true }, + "exports": { + ".": { + "types": "./dist/types/src/index.d.ts", + "import": "./dist/esm/src/index.js", + "require": "./dist/cjs/src/index.js" + } + }, "release": { "extends": "semantic-release-monorepo", "branches": [ diff --git a/sdks/router-sdk/tsconfig.base.json b/sdks/router-sdk/tsconfig.base.json new file mode 100644 index 000000000..98b309169 --- /dev/null +++ b/sdks/router-sdk/tsconfig.base.json @@ -0,0 +1,18 @@ +{ + "include": ["src"], + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "target": "es6", + "module": "esnext", + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "isolatedModules": true + } +} diff --git a/sdks/router-sdk/tsconfig.cjs.json b/sdks/router-sdk/tsconfig.cjs.json new file mode 100644 index 000000000..6dd12e73e --- /dev/null +++ b/sdks/router-sdk/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist/cjs" + } +} diff --git a/sdks/router-sdk/tsconfig.esm.json b/sdks/router-sdk/tsconfig.esm.json new file mode 100644 index 000000000..d714016a5 --- /dev/null +++ b/sdks/router-sdk/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/sdks/router-sdk/tsconfig.json b/sdks/router-sdk/tsconfig.json deleted file mode 100644 index 008638425..000000000 --- a/sdks/router-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/router-sdk/tsconfig.types.json b/sdks/router-sdk/tsconfig.types.json new file mode 100644 index 000000000..71c5d16ed --- /dev/null +++ b/sdks/router-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 1f63328fd..142043348 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4529,13 +4529,20 @@ __metadata: dependencies: "@ethersproject/abi": ^5.5.0 "@types/jest": ^24.0.25 + "@typescript-eslint/eslint-plugin": ^5.62 + "@typescript-eslint/parser": ^5.62 "@uniswap/sdk-core": ^6.0.0 "@uniswap/swap-router-contracts": ^1.3.0 "@uniswap/v2-sdk": ^4.7.0 "@uniswap/v3-sdk": ^3.19.0 "@uniswap/v4-sdk": ^1.12.0 + 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 - tsdx: ^0.14.1 languageName: unknown linkType: soft