Skip to content

Commit 69fb5ec

Browse files
committed
Switch to ts-bridge; harden exports; target ES2020
Consequently, this fixes a problem where JavaScript files were not being properly emitted in `dist/`. This is a breaking change as consumers will no longer be allowed to import subpaths. The change to ES2020 may cause slight compatibility issues as well.
1 parent cf6c4ab commit 69fb5ec

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed

package.json

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@
77
"url": "https://github.com/MetaMask/smart-transactions-controller.git"
88
},
99
"license": "SEE LICENSE IN LICENSE",
10-
"main": "dist/index.js",
11-
"types": "dist/index.d.ts",
10+
"sideEffects": false,
11+
"exports": {
12+
".": {
13+
"import": {
14+
"types": "./dist/index.d.mts",
15+
"default": "./dist/index.mjs"
16+
},
17+
"require": {
18+
"types": "./dist/index.d.cts",
19+
"default": "./dist/index.cjs"
20+
}
21+
},
22+
"./package.json": "./package.json"
23+
},
24+
"main": "./dist/index.cjs",
25+
"module": "./dist/index.mjs",
26+
"types": "./dist/index.d.cts",
1227
"files": [
13-
"dist/"
28+
"dist"
1429
],
1530
"scripts": {
16-
"build": "tsc --project tsconfig.build.json",
17-
"build:clean": "rm -rf dist && yarn build",
18-
"build:link": "yarn build && cd dist && yarn link && rm -rf node_modules && cd ..",
31+
"build": "ts-bridge --project tsconfig.build.json --clean",
1932
"lint": "yarn lint:eslint && yarn lint:misc --check",
2033
"lint:eslint": "eslint . --cache --ext js,ts",
2134
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
@@ -36,6 +49,7 @@
3649
"@metamask/network-controller": "^21.1.0",
3750
"@metamask/polling-controller": "^11.0.0",
3851
"@metamask/transaction-controller": "^37.3.0",
52+
"@ts-bridge/cli": "^0.6.0",
3953
"bignumber.js": "^9.0.1",
4054
"events": "^3.3.0",
4155
"fast-json-patch": "^3.1.0",

tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"declaration": true,
5+
"declarationMap": true,
56
"emitDeclarationOnly": true,
67
"inlineSources": true,
78
"noEmit": false,

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"module": "CommonJS",
66
"moduleResolution": "node",
77
"noEmit": true,
8+
"noErrorTruncation": true,
89
"resolveJsonModule": true,
910
"skipLibCheck": true,
1011
"strict": true,
11-
"target": "es2017"
12+
"target": "es2020"
1213
},
1314
"exclude": ["./dist", "**/node_modules"]
1415
}

yarn.lock

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ __metadata:
16981698
"@metamask/network-controller": ^21.1.0
16991699
"@metamask/polling-controller": ^11.0.0
17001700
"@metamask/transaction-controller": ^37.3.0
1701+
"@ts-bridge/cli": ^0.6.0
17011702
"@types/jest": ^26.0.24
17021703
"@types/lodash": ^4.14.194
17031704
"@types/node": ^18.19.17
@@ -2091,6 +2092,30 @@ __metadata:
20912092
languageName: node
20922093
linkType: hard
20932094

2095+
"@ts-bridge/cli@npm:^0.6.0":
2096+
version: 0.6.0
2097+
resolution: "@ts-bridge/cli@npm:0.6.0"
2098+
dependencies:
2099+
"@ts-bridge/resolver": ^0.2.0
2100+
chalk: ^5.3.0
2101+
cjs-module-lexer: ^1.3.1
2102+
yargs: ^17.7.2
2103+
peerDependencies:
2104+
typescript: ">=4.8.0"
2105+
bin:
2106+
ts-bridge: ./dist/index.js
2107+
tsbridge: ./dist/index.js
2108+
checksum: b4ba624df897ac44d682d68ed281ca4a11d7d91321fd2728e1805a428c0c7c90fbaa5c59873706072232967f89a57a61aa63b49f738630b48c22b3abf5221c90
2109+
languageName: node
2110+
linkType: hard
2111+
2112+
"@ts-bridge/resolver@npm:^0.2.0":
2113+
version: 0.2.0
2114+
resolution: "@ts-bridge/resolver@npm:0.2.0"
2115+
checksum: 3d47ca4f0367a193ed6a19fe1ac36a056547e94e28377869e009a216b2f24a9e5efe90d90de22fd1cf22fa36b84e80f490f328d328cde7675795a19465bf98c4
2116+
languageName: node
2117+
linkType: hard
2118+
20942119
"@types/babel__core@npm:^7.1.14":
20952120
version: 7.20.5
20962121
resolution: "@types/babel__core@npm:7.20.5"
@@ -3051,6 +3076,13 @@ __metadata:
30513076
languageName: node
30523077
linkType: hard
30533078

3079+
"chalk@npm:^5.3.0":
3080+
version: 5.3.0
3081+
resolution: "chalk@npm:5.3.0"
3082+
checksum: 623922e077b7d1e9dedaea6f8b9e9352921f8ae3afe739132e0e00c275971bdd331268183b2628cf4ab1727c45ea1f28d7e24ac23ce1db1eb653c414ca8a5a80
3083+
languageName: node
3084+
linkType: hard
3085+
30543086
"char-regex@npm:^1.0.2":
30553087
version: 1.0.2
30563088
resolution: "char-regex@npm:1.0.2"
@@ -3079,6 +3111,13 @@ __metadata:
30793111
languageName: node
30803112
linkType: hard
30813113

3114+
"cjs-module-lexer@npm:^1.3.1":
3115+
version: 1.4.1
3116+
resolution: "cjs-module-lexer@npm:1.4.1"
3117+
checksum: 2556807a99aec1f9daac60741af96cd613a707f343174ae7967da46402c91dced411bf830d209f2e93be4cecea46fc75cecf1f17c799d7d8a9e1dd6204bfcd22
3118+
languageName: node
3119+
linkType: hard
3120+
30823121
"clean-stack@npm:^2.0.0":
30833122
version: 2.2.0
30843123
resolution: "clean-stack@npm:2.2.0"
@@ -8075,7 +8114,7 @@ __metadata:
80758114
languageName: node
80768115
linkType: hard
80778116

8078-
"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1":
8117+
"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1, yargs@npm:^17.7.2":
80798118
version: 17.7.2
80808119
resolution: "yargs@npm:17.7.2"
80818120
dependencies:

0 commit comments

Comments
 (0)