Skip to content

Commit a0d00ac

Browse files
authored
chore: cleanup types exports for all packages (#8434)
**Motivation** Make the types exports consistent for all packages. All modern runtimes support [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) and there are caveats when we have both conditional exports and normal exports present in a package.json. This PR tend to make all exports follow same consistent and modern pattern. **Description** - We were using subpath exports for some packages and module exports for other - Keep all the types export consistent as subpath exports. - Remove "types" and "exports` directive from package.json - Remove `typesVersions`, this is useful only if we have different version of types for different versions of Typescript. Or having different types files for different file paths. **Steps to test or reproduce** - Run all CI
1 parent f259361 commit a0d00ac

File tree

18 files changed

+65
-130
lines changed

18 files changed

+65
-130
lines changed

packages/api/package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,45 @@
1616
"exports": {
1717
".": {
1818
"bun": "./src/index.ts",
19+
"types": "./lib/index.d.ts",
1920
"import": "./lib/index.js"
2021
},
2122
"./server": {
2223
"bun": "./src/server/index.ts",
24+
"types": "./lib/server/index.d.ts",
2325
"import": "./lib/server/index.js"
2426
},
2527
"./beacon": {
2628
"bun": "./src/beacon/index.ts",
29+
"types": "./lib/beacon/index.d.ts",
2730
"import": "./lib/beacon/index.js"
2831
},
2932
"./beacon/server": {
3033
"bun": "./src/beacon/server/index.ts",
34+
"types": "./lib/beacon/server/index.d.ts",
3135
"import": "./lib/beacon/server/index.js"
3236
},
3337
"./builder": {
3438
"bun": "./src/builder/index.ts",
39+
"types": "./lib/builder/index.d.ts",
3540
"import": "./lib/builder/index.js"
3641
},
3742
"./builder/server": {
3843
"bun": "./src/builder/server/index.ts",
44+
"types": "./lib/builder/server/index.d.ts",
3945
"import": "./lib/builder/server/index.js"
4046
},
4147
"./keymanager": {
4248
"bun": "./src/keymanager/index.ts",
49+
"types": "./lib/keymanager/index.d.ts",
4350
"import": "./lib/keymanager/index.js"
4451
},
4552
"./keymanager/server": {
4653
"bun": "./src/keymanager/server/index.ts",
54+
"types": "./lib/keymanager/server/index.d.ts",
4755
"import": "./lib/keymanager/server/index.js"
4856
}
4957
},
50-
"typesVersions": {
51-
"*": {
52-
"*": [
53-
"*",
54-
"lib/*",
55-
"lib/*/index"
56-
]
57-
}
58-
},
59-
"types": "./lib/index.d.ts",
6058
"files": [
6159
"src",
6260
"lib",

packages/beacon-node/package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,62 @@
1616
"exports": {
1717
".": {
1818
"bun": "./src/index.ts",
19+
"types": "./lib/index.d.ts",
1920
"import": "./lib/index.js"
2021
},
2122
"./api": {
2223
"bun": "./src/api/index.ts",
24+
"types": "./lib/api/index.d.ts",
2325
"import": "./lib/api/index.js"
2426
},
2527
"./chain": {
2628
"bun": "./src/chain/index.ts",
29+
"types": "./lib/chain/index.d.ts",
2730
"import": "./lib/chain/index.js"
2831
},
2932
"./constants": {
3033
"bun": "./src/constants/index.ts",
34+
"types": "./lib/constants/index.d.ts",
3135
"import": "./lib/constants/index.js"
3236
},
3337
"./db": {
3438
"bun": "./src/db/index.ts",
39+
"types": "./lib/db/index.d.ts",
3540
"import": "./lib/db/index.js"
3641
},
3742
"./eth1": {
3843
"bun": "./src/eth1/index.ts",
44+
"types": "./lib/eth1/index.d.ts",
3945
"import": "./lib/eth1/index.js"
4046
},
4147
"./metrics": {
4248
"bun": "./src/metrics/index.ts",
49+
"types": "./lib/metrics/index.d.ts",
4350
"import": "./lib/metrics/index.js"
4451
},
4552
"./monitoring": {
4653
"bun": "./src/monitoring/index.ts",
54+
"types": "./lib/monitoring/index.d.ts",
4755
"import": "./lib/monitoring/index.js"
4856
},
4957
"./network": {
5058
"bun": "./src/network/index.ts",
59+
"types": "./lib/network/index.d.ts",
5160
"import": "./lib/network/index.js"
5261
},
5362
"./node": {
5463
"bun": "./src/node/index.ts",
64+
"types": "./lib/node/index.d.ts",
5565
"import": "./lib/node/index.js"
5666
},
5767
"./sync": {
5868
"bun": "./src/sync/index.ts",
69+
"types": "./lib/sync/index.d.ts",
5970
"import": "./lib/sync/index.js"
6071
},
6172
"./util": {
6273
"bun": "./src/util/index.ts",
74+
"types": "./lib/util/index.d.ts",
6375
"import": "./lib/util/index.js"
6476
}
6577
},
@@ -73,16 +85,6 @@
7385
"default": "datastore-level"
7486
}
7587
},
76-
"typesVersions": {
77-
"*": {
78-
"*": [
79-
"*",
80-
"lib/*",
81-
"lib/*/index"
82-
]
83-
}
84-
},
85-
"types": "./lib/index.d.ts",
8688
"files": [
8789
"src",
8890
"lib",

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"exports": {
1313
".": {
1414
"bun": "./src/index.ts",
15+
"types": "./lib/index.d.ts",
1516
"import": "./lib/index.js"
1617
}
1718
},

packages/config/package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,25 @@
1212
"exports": {
1313
".": {
1414
"bun": "./src/index.ts",
15+
"types": "./lib/index.d.ts",
1516
"import": "./lib/index.js"
1617
},
1718
"./default": {
1819
"bun": "./src/default.ts",
20+
"types": "./lib/default.d.ts",
1921
"import": "./lib/default.js"
2022
},
2123
"./networks": {
2224
"bun": "./src/networks.ts",
25+
"types": "./lib/networks.d.ts",
2326
"import": "./lib/networks.js"
2427
},
2528
"./configs": {
2629
"bun": "./src/configs.ts",
30+
"types": "./lib/configs.d.ts",
2731
"import": "./lib/configs.js"
2832
}
2933
},
30-
"typesVersions": {
31-
"*": {
32-
"*": [
33-
"*",
34-
"lib/*",
35-
"lib/*/index"
36-
]
37-
}
38-
},
39-
"types": "lib/index.d.ts",
4034
"files": [
4135
"src",
4236
"lib",

packages/db/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"exports": {
1616
".": {
1717
"bun": "./src/index.ts",
18+
"types": "./lib/index.d.ts",
1819
"import": "./lib/index.js"
1920
},
2021
"./controller/level": {
@@ -28,7 +29,6 @@
2829
"import": "./src/controller/level.js"
2930
}
3031
},
31-
"types": "./lib/index.d.ts",
3232
"files": [
3333
"src",
3434
"lib",

packages/flare/package.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,10 @@
1212
"exports": {
1313
".": {
1414
"bun": "./src/index.ts",
15+
"types": "./lib/index.d.ts",
1516
"import": "./lib/index.js"
1617
}
1718
},
18-
"typesVersions": {
19-
"*": {
20-
"*": [
21-
"*",
22-
"lib/*",
23-
"lib/*/index"
24-
]
25-
}
26-
},
27-
"types": "lib/index.d.ts",
2819
"files": [
2920
"src",
3021
"lib",

packages/fork-choice/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"exports": {
1717
".": {
1818
"bun": "./src/index.ts",
19+
"types": "./lib/index.d.ts",
1920
"import": "./lib/index.js"
2021
}
2122
},
22-
"types": "./lib/index.d.ts",
2323
"files": [
2424
"src",
2525
"lib",

packages/light-client/package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,30 @@
1616
"exports": {
1717
".": {
1818
"bun": "./src/index.ts",
19+
"types": "./lib/index.d.ts",
1920
"import": "./lib/index.js"
2021
},
2122
"./utils": {
2223
"bun": "./src/utils/index.ts",
24+
"types": "./lib/utils/index.d.ts",
2325
"import": "./lib/utils/index.js"
2426
},
2527
"./validation": {
2628
"bun": "./src/validation.ts",
29+
"types": "./lib/validation.d.ts",
2730
"import": "./lib/validation.js"
2831
},
2932
"./spec": {
3033
"bun": "./src/spec/index.ts",
34+
"types": "./lib/spec/index.d.ts",
3135
"import": "./lib/spec/index.js"
3236
},
3337
"./transport": {
3438
"bun": "./src/transport/index.ts",
39+
"types": "./lib/transport/index.d.ts",
3540
"import": "./lib/transport/index.js"
3641
}
3742
},
38-
"types": "./lib/index.d.ts",
39-
"typesVersions": {
40-
"*": {
41-
"*": [
42-
"*",
43-
"lib/*",
44-
"lib/*/index"
45-
]
46-
}
47-
},
4843
"files": [
4944
"src",
5045
"lib",

packages/logger/package.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,30 @@
1616
"exports": {
1717
".": {
1818
"bun": "./src/index.ts",
19+
"types": "./lib/index.d.ts",
1920
"import": "./lib/index.js"
2021
},
2122
"./browser": {
2223
"bun": "./src/browser.ts",
24+
"types": "./lib/browser.d.ts",
2325
"import": "./lib/browser.js"
2426
},
2527
"./env": {
2628
"bun": "./src/env.ts",
29+
"types": "./lib/env.d.ts",
2730
"import": "./lib/env.js"
2831
},
2932
"./node": {
3033
"bun": "./src/node.ts",
34+
"types": "./lib/node.d.ts",
3135
"import": "./lib/node.js"
3236
},
3337
"./empty": {
3438
"bun": "./src/empty.ts",
39+
"types": "./lib/empty.d.ts",
3540
"import": "./lib/empty.js"
3641
}
3742
},
38-
"typesVersions": {
39-
"*": {
40-
"*": [
41-
"*",
42-
"lib/*",
43-
"lib/*/index"
44-
]
45-
}
46-
},
4743
"files": [
4844
"src",
4945
"lib",

packages/params/package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,35 @@
1212
"exports": {
1313
".": {
1414
"bun": "./src/index.ts",
15+
"types": "./lib/index.d.ts",
1516
"import": "./lib/index.js"
1617
},
1718
"./presets/mainnet": {
1819
"bun": "./src/presets/mainnet.ts",
20+
"types": "./lib/presets/mainnet.d.ts",
1921
"import": "./lib/presets/mainnet.js"
2022
},
2123
"./presets/minimal": {
2224
"bun": "./src/presets/minimal.ts",
25+
"types": "./lib/presets/minimal.d.ts",
2326
"import": "./lib/presets/minimal.js"
2427
},
2528
"./presets/gnosis": {
2629
"bun": "./src/presets/gnosis.ts",
30+
"types": "./lib/presets/gnosis.d.ts",
2731
"import": "./lib/presets/gnosis.js"
2832
},
2933
"./setPreset": {
3034
"bun": "./src/setPreset.ts",
35+
"types": "./lib/setPreset.d.ts",
3136
"import": "./lib/setPreset.js"
3237
}
3338
},
34-
"types": "lib/index.d.ts",
3539
"files": [
3640
"src",
3741
"lib",
3842
"!**/*.tsbuildinfo"
3943
],
40-
"typesVersions": {
41-
"*": {
42-
"*": [
43-
"*",
44-
"lib/*",
45-
"lib/*/index"
46-
]
47-
}
48-
},
4944
"scripts": {
5045
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
5146
"build": "tsc -p tsconfig.build.json",

0 commit comments

Comments
 (0)