Skip to content

Commit

Permalink
feat(v2-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 ffb3c74 commit 6faef94
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 454 deletions.
12 changes: 12 additions & 0 deletions sdks/v2-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/**"]
}
11 changes: 11 additions & 0 deletions sdks/v2-sdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: 'src',
globals: {
'ts-jest': {
tsconfig: 'tsconfig.base.json',
},
},
}
36 changes: 26 additions & 10 deletions sdks/v2-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
"ethereum"
],
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"module": "dist/v2-sdk.esm.js",
"main": "./dist/cjs/src/index.js",
"module": "./dist/esm/src/index.js",
"types": "./dist/types/src/index.d.ts",
"files": [
"dist"
],
"engines": {
"node": ">=10"
},
"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/address": "^5.0.2",
Expand All @@ -34,8 +37,14 @@
"@types/big.js": "^4.0.5",
"@types/jest": "^24.0.25",
"@uniswap/v2-core": "^1.0.1",
"eslint-config-react-app": "7.0.1",
"tsdx": "^0.14.1"
"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",
"typescript": "^4.3.3"
},
"prettier": {
"printWidth": 120,
Expand All @@ -46,6 +55,13 @@
"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/v2-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/v2-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/v2-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"
}
}
8 changes: 8 additions & 0 deletions sdks/v2-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"
}
}
Loading

0 comments on commit 6faef94

Please sign in to comment.