Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(universal-router-sdk): separate esm / cjs builds #221

Open
wants to merge 1 commit into
base: feat/permit2-sdk-build
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading