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 c6c87a9
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 39 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'
}
}
};

41 changes: 27 additions & 14 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,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": [
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"
}
}
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c6c87a9

Please sign in to comment.