Skip to content

Commit 704a646

Browse files
authored
Merge pull request #7534 from BitGo/BTC-2732.utxo-build-esm
feat(utxo): add ESM build support for UTXO modules
2 parents da3499f + b6671bc commit 704a646

File tree

10 files changed

+153
-30
lines changed

10 files changed

+153
-30
lines changed

modules/abstract-utxo/package.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,33 @@
22
"name": "@bitgo/abstract-utxo",
33
"version": "10.6.0",
44
"description": "BitGo SDK coin library for UTXO base implementation",
5-
"main": "./dist/src/index.js",
6-
"types": "./dist/src/index.d.ts",
5+
"main": "./dist/cjs/src/index.js",
6+
"module": "./dist/esm/index.js",
7+
"browser": "./dist/esm/index.js",
8+
"types": "./dist/cjs/src/index.d.ts",
9+
"exports": {
10+
".": {
11+
"import": {
12+
"types": "./dist/esm/index.d.ts",
13+
"default": "./dist/esm/index.js"
14+
},
15+
"require": {
16+
"types": "./dist/cjs/src/index.d.ts",
17+
"default": "./dist/cjs/src/index.js"
18+
}
19+
}
20+
},
721
"files": [
8-
"dist/src"
22+
"dist/cjs",
23+
"dist/esm"
924
],
1025
"scripts": {
11-
"build": "yarn tsc --build --incremental --verbose .",
26+
"build": "npm run build:cjs && npm run build:esm",
27+
"build:cjs": "yarn tsc --build --incremental --verbose .",
28+
"build:esm": "yarn tsc --project tsconfig.esm.json",
1229
"fmt": "prettier --write .",
1330
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
14-
"clean": "rm -r ./dist",
31+
"clean": "rm -rf ./dist",
1532
"lint": "eslint --quiet .",
1633
"prepare": "npm run build",
1734
"test": "npm run unit-test",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/esm",
5+
"rootDir": "./src",
6+
"module": "ES2020",
7+
"target": "ES2020",
8+
"moduleResolution": "bundler",
9+
"lib": ["ES2020", "DOM"],
10+
"declaration": true,
11+
"declarationMap": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["src/**/*"],
15+
"exclude": ["node_modules", "test", "dist"],
16+
"references": []
17+
}
18+

modules/abstract-utxo/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./dist",
4+
"outDir": "./dist/cjs",
55
"rootDir": "./",
66
"strictPropertyInitialization": false,
77
"esModuleInterop": true,

modules/babylonlabs-io-btc-staking-ts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"require": "./dist/index.cjs"
1212
},
1313
"scripts": {
14-
"generate-types": "dts-bundle-generator -o ./dist/index.d.cts ./src/index.ts --no-check",
14+
"generate-types:cjs": "dts-bundle-generator -o ./dist/index.d.cts ./src/index.ts --no-check",
15+
"generate-types:esm": "dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-check",
16+
"generate-types": "npm run generate-types:cjs && npm run generate-types:esm",
1517
"build": "node build.js && npm run generate-types",
1618
"prepare": "husky",
1719
"prepublishOnly": "npm run build",

modules/utxo-core/package.json

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,60 @@
22
"name": "@bitgo/utxo-core",
33
"version": "1.23.0",
44
"description": "BitGo UTXO Core types",
5-
"main": "./dist/src/index.js",
6-
"types": "./dist/src/index.d.ts",
5+
"main": "./dist/cjs/src/index.js",
6+
"module": "./dist/esm/index.js",
7+
"browser": "./dist/esm/index.js",
8+
"types": "./dist/cjs/src/index.d.ts",
79
"files": [
8-
"dist/src"
10+
"dist/cjs",
11+
"dist/esm"
912
],
1013
"exports": {
11-
".": "./dist/src/index.js",
12-
"./descriptor": "./dist/src/descriptor/index.js",
13-
"./testutil": "./dist/src/testutil/index.js",
14-
"./testutil/descriptor": "./dist/src/testutil/descriptor/index.js"
15-
},
16-
"browser": {
17-
".": "./dist/src/index.js",
18-
"./descriptor": "./dist/src/descriptor/index.js",
19-
"./testutil": "./dist/src/testutil/index.js",
20-
"./testutil/descriptor": "./dist/src/testutil/descriptor/index.js"
14+
".": {
15+
"import": {
16+
"types": "./dist/esm/index.d.ts",
17+
"default": "./dist/esm/index.js"
18+
},
19+
"require": {
20+
"types": "./dist/cjs/src/index.d.ts",
21+
"default": "./dist/cjs/src/index.js"
22+
}
23+
},
24+
"./descriptor": {
25+
"import": {
26+
"types": "./dist/esm/descriptor/index.d.ts",
27+
"default": "./dist/esm/descriptor/index.js"
28+
},
29+
"require": {
30+
"types": "./dist/cjs/src/descriptor/index.d.ts",
31+
"default": "./dist/cjs/src/descriptor/index.js"
32+
}
33+
},
34+
"./testutil": {
35+
"import": {
36+
"types": "./dist/esm/testutil/index.d.ts",
37+
"default": "./dist/esm/testutil/index.js"
38+
},
39+
"require": {
40+
"types": "./dist/cjs/src/testutil/index.d.ts",
41+
"default": "./dist/cjs/src/testutil/index.js"
42+
}
43+
},
44+
"./testutil/descriptor": {
45+
"import": {
46+
"types": "./dist/esm/testutil/descriptor/index.d.ts",
47+
"default": "./dist/esm/testutil/descriptor/index.js"
48+
},
49+
"require": {
50+
"types": "./dist/cjs/src/testutil/descriptor/index.d.ts",
51+
"default": "./dist/cjs/src/testutil/descriptor/index.js"
52+
}
53+
}
2154
},
2255
"scripts": {
23-
"build": "yarn tsc --build --incremental --verbose .",
56+
"build": "npm run build:cjs && npm run build:esm",
57+
"build:cjs": "yarn tsc --build --incremental --verbose .",
58+
"build:esm": "yarn tsc --project tsconfig.esm.json",
2459
"fmt": "prettier --write .",
2560
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
2661
"clean": "rm -r ./dist",
@@ -45,7 +80,6 @@
4580
"publishConfig": {
4681
"access": "public"
4782
},
48-
"type": "commonjs",
4983
"nyc": {
5084
"extension": [
5185
".ts"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/esm",
5+
"rootDir": "./src",
6+
"module": "ES2020",
7+
"target": "ES2020",
8+
"moduleResolution": "bundler",
9+
"lib": ["ES2020", "DOM"],
10+
"declaration": true,
11+
"declarationMap": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["src/**/*"],
15+
"exclude": ["node_modules", "test", "dist"],
16+
"references": []
17+
}

modules/utxo-core/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./dist",
4+
"outDir": "./dist/cjs",
55
"rootDir": "./",
66
"esModuleInterop": true,
77
"allowJs": false,
8-
"strict": true
8+
"strict": true,
9+
"moduleResolution": "node16",
10+
"module": "node16"
911
},
1012
"include": ["src/**/*", "test/**/*"],
1113
"exclude": ["node_modules"],

modules/utxo-staking/package.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22
"name": "@bitgo/utxo-staking",
33
"version": "1.25.0",
44
"description": "BitGo SDK for build UTXO staking transactions",
5-
"main": "./dist/src/index.js",
6-
"types": "./dist/src/index.d.ts",
5+
"main": "./dist/cjs/src/index.js",
6+
"module": "./dist/esm/index.js",
7+
"browser": "./dist/esm/index.js",
8+
"types": "./dist/cjs/src/index.d.ts",
79
"files": [
8-
"dist/src"
10+
"dist/cjs",
11+
"dist/esm"
912
],
13+
"exports": {
14+
".": {
15+
"import": {
16+
"types": "./dist/esm/index.d.ts",
17+
"default": "./dist/esm/index.js"
18+
},
19+
"require": {
20+
"types": "./dist/cjs/src/index.d.ts",
21+
"default": "./dist/cjs/src/index.js"
22+
}
23+
}
24+
},
1025
"scripts": {
11-
"build": "yarn tsc --build --incremental --verbose .",
26+
"build": "npm run build:cjs && npm run build:esm",
27+
"build:cjs": "yarn tsc --build --incremental --verbose .",
28+
"build:esm": "yarn tsc --project tsconfig.esm.json",
1229
"fmt": "prettier --write .",
1330
"check-fmt": "prettier --check '**/*.{ts,js,json}'",
1431
"clean": "rm -r ./dist",
@@ -41,7 +58,6 @@
4158
".ts"
4259
]
4360
},
44-
"type": "commonjs",
4561
"dependencies": {
4662
"@babylonlabs-io/babylon-proto-ts": "1.7.2",
4763
"@bitgo/babylonlabs-io-btc-staking-ts": "^3.1.0",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist/esm",
5+
"rootDir": "./src",
6+
"module": "ES2020",
7+
"target": "ES2020",
8+
"moduleResolution": "bundler",
9+
"lib": ["ES2020", "DOM"],
10+
"declaration": true,
11+
"declarationMap": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["src/**/*", "src/babylon/*.json"],
15+
"exclude": ["node_modules", "test", "dist", "scripts"],
16+
"references": []
17+
}

modules/utxo-staking/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "./dist",
4+
"outDir": "./dist/cjs",
55
"rootDir": ".",
66
"typeRoots": ["./node_modules/@types", "../../node_modules/@types"],
77
"allowJs": false,

0 commit comments

Comments
 (0)