Skip to content

Commit

Permalink
feat(router-sdk): separate esm/cjs builds
Browse files Browse the repository at this point in the history
  • Loading branch information
just-toby committed Dec 16, 2024
1 parent 1950758 commit 9f045cc
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 38 deletions.
12 changes: 12 additions & 0 deletions sdks/router-sdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": [
"prettier",
"prettier/@typescript-eslint"
],
"ignorePatterns": ["dist/**"]
}
12 changes: 12 additions & 0 deletions sdks/router-sdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -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'
}
}
};

40 changes: 27 additions & 13 deletions sdks/router-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -29,18 +33,28 @@
},
"devDependencies": {
"@types/jest": "^24.0.25",
"@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",
"tsdx": "^0.14.1"
},
"prettier": {
"printWidth": 120,
"semi": false,
"singleQuote": true
"typescript": "^4.3.3"
},
"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": [
Expand Down
18 changes: 18 additions & 0 deletions sdks/router-sdk/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -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
}
}
7 changes: 7 additions & 0 deletions sdks/router-sdk/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs"
}
}
7 changes: 7 additions & 0 deletions sdks/router-sdk/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/esm"
}
}
24 changes: 0 additions & 24 deletions sdks/router-sdk/tsconfig.json

This file was deleted.

8 changes: 8 additions & 0 deletions sdks/router-sdk/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist/types"
}
}
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4529,13 +4529,21 @@ __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
typescript: ^4.3.3
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 9f045cc

Please sign in to comment.