Skip to content

Commit c55fb49

Browse files
committed
feat(universal-router-sdk): separate esm / cjs builds
1 parent 9311793 commit c55fb49

File tree

9 files changed

+64
-42
lines changed

9 files changed

+64
-42
lines changed

sdks/universal-router-sdk/package.json

Lines changed: 17 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ 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
1110
readonly wethAddress: string
1211
readonly amount: BigNumberish
12+
readonly permit2Data?: Permit2Permit
1313

1414
constructor(amount: BigNumberish, chainId: number, permit2?: Permit2Permit) {
1515
this.wethAddress = WETH_ADDRESS(chainId)
Lines changed: 6 additions & 18 deletions
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'
Lines changed: 18 additions & 0 deletions
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+
}
Lines changed: 7 additions & 0 deletions
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+
}
Lines changed: 7 additions & 0 deletions
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

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
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+
}

yarn.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4663,7 +4663,6 @@ __metadata:
46634663
hardhat: ^2.22.15
46644664
prettier: ^2.4.1
46654665
ts-node: ^10.9.1
4666-
tsdx: ^0.14.1
46674666
tslib: ^2.3.0
46684667
typedoc: ^0.21.2
46694668
typescript: ^4.3.3

0 commit comments

Comments
 (0)