Skip to content

Commit 08bc965

Browse files
OttoAllmendingerllm-git
andcommitted
feat(utxo-core): add ESM build support
Update package.json and add ESM-specific tsconfig to support both CJS and ESM module formats. Adjust output paths and package exports accordingly. Issue: BTC-2732 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent c11cdc9 commit 08bc965

File tree

3 files changed

+71
-17
lines changed

3 files changed

+71
-17
lines changed

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: 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/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"],

0 commit comments

Comments
 (0)