Skip to content

Commit

Permalink
feat(v3-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 6faef94 commit 28e9a62
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 43 deletions.
12 changes: 12 additions & 0 deletions sdks/v3-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/v3-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',
},
},
}
42 changes: 26 additions & 16 deletions sdks/v3-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,32 @@
"ethereum"
],
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"module": "dist/v3-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",
"test": "jest"
},
"exports": {
".": {
"types": "./dist/types/src/index.d.ts",
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
}
},
"sideEffects": false,
"dependencies": {
"@ethersproject/abi": "^5.5.0",
"@ethersproject/solidity": "^5.0.9",
Expand All @@ -36,14 +46,14 @@
"devDependencies": {
"@types/jest": "^24.0.25",
"@uniswap/v3-core": "1.0.0",
"babel-jest": "25.5.1",
"tsdx": "^0.14.1"
},
"resolutions": {
"regenerator-runtime": "^0.14.1"
},
"resolutionsComments": {
"regenerator-runtime": "Fixes https://github.com/facebook/regenerator/pull/480. It can be removed when `tsdx` updates their dependencies."
"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 Down
18 changes: 18 additions & 0 deletions sdks/v3-sdk/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"include": ["src"],
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"target": "es2018",
"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/v3-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/v3-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"
}
}
24 changes: 0 additions & 24 deletions sdks/v3-sdk/tsconfig.json

This file was deleted.

8 changes: 8 additions & 0 deletions sdks/v3-sdk/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"moduleResolution": "node",
"types": ["jest", "node"]
},
"include": ["src/**/*.ts", "src/**/*.test.ts"]
}
8 changes: 8 additions & 0 deletions sdks/v3-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"
}
}
12 changes: 9 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4503,10 +4503,16 @@ __metadata:
"@uniswap/v3-core": 1.0.0
"@uniswap/v3-periphery": ^1.1.1
"@uniswap/v3-staker": 1.0.0
babel-jest: 25.5.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
tiny-invariant: ^1.1.0
tiny-warning: ^1.0.3
tsdx: ^0.14.1
typescript: ^4.3.3
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -5249,7 +5255,7 @@ __metadata:
languageName: node
linkType: hard

"babel-jest@npm:25.5.1, babel-jest@npm:^25.5.1":
"babel-jest@npm:^25.5.1":
version: 25.5.1
resolution: "babel-jest@npm:25.5.1"
dependencies:
Expand Down

0 comments on commit 28e9a62

Please sign in to comment.