From be04d36f3fcd45b905b2d58deb54ffdbb1050a3e Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 1 Aug 2024 19:03:19 +0300 Subject: [PATCH] chore: esm build (#4) --- package.json | 16 +++++++++++++--- src/index.ts | 7 ++++++- tsconfig.cjs.json | 11 +++++++++++ tsconfig.esm.json | 11 +++++++++++ tsconfig.types.json | 15 +++++++++++++++ 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json create mode 100644 tsconfig.types.json diff --git a/package.json b/package.json index b9a152f..6d0ff8a 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,15 @@ "version": "0.0.6", "description": "Sdk for creating atomic swaps through 1inch", "author": "@1inch", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/types/src/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "node": "./dist/cjs/index.js", + "default": "./dist/cjs/index.js" + } + }, "files": [ "dist", "LICENSE", @@ -16,7 +23,10 @@ "url": "ssh://git@github.com:1inch/atomic-swap-sdk.git" }, "scripts": { - "build": "tsc", + "build": "npm run build:esm && npm run build:cjs && npm run build:types", + "build:esm": "tsc --project tsconfig.esm.json", + "build:cjs": "tsc --project tsconfig.cjs.json", + "build:types": "tsc --project tsconfig.types.json", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "lint:ci": "eslint \"{src,apps,libs,test}/**/*.ts\"", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --ignore-path .eslintignore --fix", diff --git a/src/index.ts b/src/index.ts index acd0d9e..2242b3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,12 @@ export { AmountMode, LimitOrderContract, calcTakingAmount, - calcMakingAmount + calcMakingAmount, + PrivateKeyProviderConnector, + Web3ProviderConnector, + BlockchainProviderConnector, + HttpProviderConnector, + WsProviderConnector } from '@1inch/fusion-sdk' export * from './cross-chain-order' export * from './escrow-factory' diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..7d49c98 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "outDir": "./dist/cjs", + "module": "CommonJS", + "declaration": false, + "composite": false, + "resolveJsonModule": true, + "importHelpers": true, + } +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..a544c7e --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "outDir": "./dist/esm", + "module": "ESNext", + "declaration": false, + "composite": false, + "resolveJsonModule": true, + "importHelpers": true + }, +} diff --git a/tsconfig.types.json b/tsconfig.types.json new file mode 100644 index 0000000..757d746 --- /dev/null +++ b/tsconfig.types.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/types", + "declaration": true, + "emitDeclarationOnly": true, + "composite": true + }, + "exclude": [ + "node_modules", + "test", + "dist", + "**/*spec.ts" + ] +}