Skip to content

Commit

Permalink
feat(universal-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 c0a6a1d commit 2a00e31
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 42 deletions.
22 changes: 17 additions & 5 deletions sdks/universal-router-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +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"
],
"engines": {
"node": ">=14"
},
"scripts": {
"build": "tsdx build",
"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",
"docs": "typedoc",
"forge:fix": "forge fmt",
"lint": "yarn prettier",
Expand Down Expand Up @@ -53,7 +58,6 @@
"hardhat": "^2.22.15",
"prettier": "^2.4.1",
"ts-node": "^10.9.1",
"tsdx": "^0.14.1",
"tslib": "^2.3.0",
"typedoc": "^0.21.2",
"typescript": "^4.3.3"
Expand Down Expand Up @@ -99,5 +103,13 @@
},
"installConfig": {
"hoistingLimits": "workspaces"
}
},
"exports": {
".": {
"types": "./dist/types/src/index.d.ts",
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
}
},
"sideEffects": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { ROUTER_AS_RECIPIENT, WETH_ADDRESS } from '../../utils/constants'

export class UnwrapWETH implements Command {
readonly tradeType: RouterActionType = RouterActionType.UnwrapWETH
readonly permit2Data: Permit2Permit
readonly wethAddress: string
readonly amount: BigNumberish
readonly permit2Data?: Permit2Permit

constructor(amount: BigNumberish, chainId: number, permit2?: Permit2Permit) {
this.wethAddress = WETH_ADDRESS(chainId)
Expand Down
24 changes: 6 additions & 18 deletions sdks/universal-router-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
export { SwapRouter, MigrateV3ToV4Options } from './swapRouter'
export { SwapRouter } from './swapRouter'
export type { MigrateV3ToV4Options } from './swapRouter'
export * from './entities'
export * from './utils/routerTradeAdapter'
export {
RoutePlanner,
CommandType,
COMMAND_DEFINITION,
CommandDefinition,
Parser,
Subparser,
ParamType,
} from './utils/routerCommands'
export { RoutePlanner, CommandType, COMMAND_DEFINITION, Parser, Subparser } from './utils/routerCommands'
export type { CommandDefinition, ParamType } from './utils/routerCommands'
export {
UNIVERSAL_ROUTER_CREATION_BLOCK,
UNIVERSAL_ROUTER_ADDRESS,
ROUTER_AS_RECIPIENT,
WETH_ADDRESS,
UniversalRouterVersion,
} from './utils/constants'
export {
CommandParser,
GenericCommandParser,
UniversalRouterCommand,
UniversalRouterCall,
Param,
CommandsDefinition,
} from './utils/commandParser'
export { CommandParser, GenericCommandParser } from './utils/commandParser'
export type { UniversalRouterCommand, UniversalRouterCall, Param, CommandsDefinition } from './utils/commandParser'
18 changes: 18 additions & 0 deletions sdks/universal-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/universal-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/universal-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"
}
}
17 changes: 0 additions & 17 deletions sdks/universal-router-sdk/tsconfig.json

This file was deleted.

8 changes: 8 additions & 0 deletions sdks/universal-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"
}
}
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,6 @@ __metadata:
hardhat: ^2.22.15
prettier: ^2.4.1
ts-node: ^10.9.1
tsdx: ^0.14.1
tslib: ^2.3.0
typedoc: ^0.21.2
typescript: ^4.3.3
Expand Down

0 comments on commit 2a00e31

Please sign in to comment.