Skip to content

Commit dbcd010

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 62c061c commit dbcd010

File tree

5 files changed

+65
-9
lines changed

5 files changed

+65
-9
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
coverageReporters: ['text', 'html'],
77
coverageThreshold: {
88
global: {
9-
branches: 75.52,
9+
branches: 74.65,
1010
functions: 92.5,
1111
lines: 92.52,
1212
statements: 92.51,

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"declaration": true,
5+
"declarationMap": true,
6+
"emitDeclarationOnly": true,
57
"inlineSources": true,
68
"noEmit": false,
79
"outDir": "dist",

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
@@ -1672,6 +1672,7 @@ __metadata:
16721672
"@metamask/network-controller": ^21.1.0
16731673
"@metamask/polling-controller": ^11.0.0
16741674
"@metamask/transaction-controller": ^37.3.0
1675+
"@ts-bridge/cli": ^0.6.0
16751676
"@types/jest": ^26.0.24
16761677
"@types/lodash": ^4.14.194
16771678
"@types/node": ^18.19.17
@@ -2065,6 +2066,30 @@ __metadata:
20652066
languageName: node
20662067
linkType: hard
20672068

2069+
"@ts-bridge/cli@npm:^0.6.0":
2070+
version: 0.6.0
2071+
resolution: "@ts-bridge/cli@npm:0.6.0"
2072+
dependencies:
2073+
"@ts-bridge/resolver": ^0.2.0
2074+
chalk: ^5.3.0
2075+
cjs-module-lexer: ^1.3.1
2076+
yargs: ^17.7.2
2077+
peerDependencies:
2078+
typescript: ">=4.8.0"
2079+
bin:
2080+
ts-bridge: ./dist/index.js
2081+
tsbridge: ./dist/index.js
2082+
checksum: b4ba624df897ac44d682d68ed281ca4a11d7d91321fd2728e1805a428c0c7c90fbaa5c59873706072232967f89a57a61aa63b49f738630b48c22b3abf5221c90
2083+
languageName: node
2084+
linkType: hard
2085+
2086+
"@ts-bridge/resolver@npm:^0.2.0":
2087+
version: 0.2.0
2088+
resolution: "@ts-bridge/resolver@npm:0.2.0"
2089+
checksum: 3d47ca4f0367a193ed6a19fe1ac36a056547e94e28377869e009a216b2f24a9e5efe90d90de22fd1cf22fa36b84e80f490f328d328cde7675795a19465bf98c4
2090+
languageName: node
2091+
linkType: hard
2092+
20682093
"@types/babel__core@npm:^7.1.14":
20692094
version: 7.20.5
20702095
resolution: "@types/babel__core@npm:7.20.5"
@@ -3030,6 +3055,13 @@ __metadata:
30303055
languageName: node
30313056
linkType: hard
30323057

3058+
"chalk@npm:^5.3.0":
3059+
version: 5.3.0
3060+
resolution: "chalk@npm:5.3.0"
3061+
checksum: 623922e077b7d1e9dedaea6f8b9e9352921f8ae3afe739132e0e00c275971bdd331268183b2628cf4ab1727c45ea1f28d7e24ac23ce1db1eb653c414ca8a5a80
3062+
languageName: node
3063+
linkType: hard
3064+
30333065
"char-regex@npm:^1.0.2":
30343066
version: 1.0.2
30353067
resolution: "char-regex@npm:1.0.2"
@@ -3058,6 +3090,13 @@ __metadata:
30583090
languageName: node
30593091
linkType: hard
30603092

3093+
"cjs-module-lexer@npm:^1.3.1":
3094+
version: 1.4.1
3095+
resolution: "cjs-module-lexer@npm:1.4.1"
3096+
checksum: 2556807a99aec1f9daac60741af96cd613a707f343174ae7967da46402c91dced411bf830d209f2e93be4cecea46fc75cecf1f17c799d7d8a9e1dd6204bfcd22
3097+
languageName: node
3098+
linkType: hard
3099+
30613100
"clean-stack@npm:^2.0.0":
30623101
version: 2.2.0
30633102
resolution: "clean-stack@npm:2.2.0"
@@ -8260,7 +8299,7 @@ __metadata:
82608299
languageName: node
82618300
linkType: hard
82628301

8263-
"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1":
8302+
"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1, yargs@npm:^17.7.2":
82648303
version: 17.7.2
82658304
resolution: "yargs@npm:17.7.2"
82668305
dependencies:

0 commit comments

Comments
 (0)