Skip to content

Commit b089e99

Browse files
authored
feat(permit2-sdk): separate cjs and esm builds, remove tsdx (#220)
1 parent 8fbffe3 commit b089e99

15 files changed

+261
-2939
lines changed

sdks/permit2-sdk/package.json

+17-9
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@
77
"ethereum"
88
],
99
"license": "MIT",
10-
"main": "dist/index.js",
11-
"typings": "dist/index.d.ts",
10+
"main": "./dist/cjs/src/index.js",
11+
"module": "./dist/esm/src/index.js",
12+
"types": "./dist/types/src/index.d.ts",
13+
"exports": {
14+
".": {
15+
"types": "./dist/types/src/index.d.ts",
16+
"import": "./dist/esm/src/index.js",
17+
"require": "./dist/cjs/src/index.js"
18+
}
19+
},
20+
"sideEffects": false,
1221
"files": [
1322
"dist"
1423
],
1524
"scripts": {
16-
"build": "tsdx build",
17-
"interop": "yarn node writeInterop.js",
18-
"lint": "prettier --check src/",
19-
"release": "semantic-release",
20-
"start": "tsdx watch",
21-
"test": "tsdx test --testPathIgnorePatterns=/permit2/"
25+
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
26+
"build:cjs": "tsc -p tsconfig.cjs.json",
27+
"build:esm": "tsc -p tsconfig.esm.json",
28+
"build:types": "tsc -p tsconfig.types.json",
29+
"clean": "rm -rf ./dist"
2230
},
2331
"dependencies": {
2432
"ethers": "^5.7.0",
@@ -27,7 +35,7 @@
2735
"devDependencies": {
2836
"@types/jest": "^24.0.25",
2937
"prettier": "^2.4.1",
30-
"tsdx": "^0.14.1"
38+
"typescript": "^4.3.3"
3139
},
3240
"prettier": {
3341
"printWidth": 120,

sdks/permit2-sdk/tsconfig.base.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"include": ["src", "abis"],
3+
"compilerOptions": {
4+
"rootDir": ".",
5+
"baseUrl": ".",
6+
"target": "es6",
7+
"module": "esnext",
8+
"importHelpers": true,
9+
"declaration": true,
10+
"sourceMap": true,
11+
"strict": true,
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"esModuleInterop": true,
15+
"skipLibCheck": true,
16+
"isolatedModules": true
17+
}
18+
}

sdks/permit2-sdk/tsconfig.cjs.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "dist/cjs",
6+
"target": "es2015"
7+
},
8+
"include": ["src/**/*", "abis/**/*"]
9+
}

sdks/permit2-sdk/tsconfig.esm.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"outDir": "dist/esm",
6+
"target": "es2015"
7+
},
8+
"include": ["src/**/*", "abis/**/*"]
9+
}

sdks/permit2-sdk/tsconfig.json

-24
This file was deleted.

sdks/permit2-sdk/tsconfig.types.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"emitDeclarationOnly": true,
6+
"outDir": "dist/types"
7+
},
8+
"include": ["src", "abis"]
9+
}

sdks/universal-router-sdk/package.json

+17-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@
77
"ethereum"
88
],
99
"license": "MIT",
10-
"main": "dist/index.js",
11-
"typings": "dist/index.d.ts",
10+
"main": "./dist/cjs/src/index.js",
11+
"module": "./dist/esm/src/index.js",
12+
"types": "./dist/types/src/index.d.ts",
1213
"files": [
1314
"dist"
1415
],
1516
"engines": {
1617
"node": ">=14"
1718
},
1819
"scripts": {
19-
"build": "tsdx build",
20+
"clean": "rm -rf dist",
21+
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
22+
"build:cjs": "tsc -p tsconfig.cjs.json",
23+
"build:esm": "tsc -p tsconfig.esm.json",
24+
"build:types": "tsc -p tsconfig.types.json",
2025
"docs": "typedoc",
2126
"forge:fix": "forge fmt",
2227
"lint": "yarn prettier",
@@ -53,7 +58,6 @@
5358
"hardhat": "^2.22.15",
5459
"prettier": "^2.4.1",
5560
"ts-node": "^10.9.1",
56-
"tsdx": "^0.14.1",
5761
"tslib": "^2.3.0",
5862
"typedoc": "^0.21.2",
5963
"typescript": "^4.3.3"
@@ -99,5 +103,13 @@
99103
},
100104
"installConfig": {
101105
"hoistingLimits": "workspaces"
102-
}
106+
},
107+
"exports": {
108+
".": {
109+
"types": "./dist/types/src/index.d.ts",
110+
"import": "./dist/esm/src/index.js",
111+
"require": "./dist/cjs/src/index.js"
112+
}
113+
},
114+
"sideEffects": false
103115
}

sdks/universal-router-sdk/src/entities/actions/unwrapWETH.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ROUTER_AS_RECIPIENT, WETH_ADDRESS } from '../../utils/constants'
77

88
export class UnwrapWETH implements Command {
99
readonly tradeType: RouterActionType = RouterActionType.UnwrapWETH
10-
readonly permit2Data: Permit2Permit
10+
readonly permit2Data?: Permit2Permit
1111
readonly wethAddress: string
1212
readonly amount: BigNumberish
1313

+6-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
1-
export { SwapRouter, MigrateV3ToV4Options } from './swapRouter'
1+
export { SwapRouter } from './swapRouter'
2+
export type { MigrateV3ToV4Options } from './swapRouter'
23
export * from './entities'
34
export * from './utils/routerTradeAdapter'
4-
export {
5-
RoutePlanner,
6-
CommandType,
7-
COMMAND_DEFINITION,
8-
CommandDefinition,
9-
Parser,
10-
Subparser,
11-
ParamType,
12-
} from './utils/routerCommands'
5+
export { RoutePlanner, CommandType, COMMAND_DEFINITION, Parser, Subparser } from './utils/routerCommands'
6+
export type { CommandDefinition, ParamType } from './utils/routerCommands'
137
export {
148
UNIVERSAL_ROUTER_CREATION_BLOCK,
159
UNIVERSAL_ROUTER_ADDRESS,
1610
ROUTER_AS_RECIPIENT,
1711
WETH_ADDRESS,
1812
UniversalRouterVersion,
1913
} from './utils/constants'
20-
export {
21-
CommandParser,
22-
GenericCommandParser,
23-
UniversalRouterCommand,
24-
UniversalRouterCall,
25-
Param,
26-
CommandsDefinition,
27-
} from './utils/commandParser'
14+
export { CommandParser, GenericCommandParser } from './utils/commandParser'
15+
export type { UniversalRouterCommand, UniversalRouterCall, Param, CommandsDefinition } from './utils/commandParser'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"include": ["src"],
3+
"compilerOptions": {
4+
"rootDir": ".",
5+
"baseUrl": ".",
6+
"target": "es6",
7+
"module": "esnext",
8+
"importHelpers": true,
9+
"declaration": true,
10+
"sourceMap": true,
11+
"strict": true,
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"esModuleInterop": true,
15+
"skipLibCheck": true,
16+
"isolatedModules": true
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "dist/cjs"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"outDir": "dist/esm"
6+
}
7+
}

sdks/universal-router-sdk/tsconfig.json

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"emitDeclarationOnly": true,
6+
"outDir": "dist/types"
7+
}
8+
}

0 commit comments

Comments
 (0)