Skip to content

Commit

Permalink
Switch to ts-bridge; harden exports; target ES2020
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mcmire committed Nov 26, 2024
1 parent 62c061c commit dbcd010
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
coverageReporters: ['text', 'html'],
coverageThreshold: {
global: {
branches: 75.52,
branches: 74.65,
functions: 92.5,
lines: 92.52,
statements: 92.51,
Expand Down
26 changes: 20 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@
"url": "https://github.com/MetaMask/smart-transactions-controller.git"
},
"license": "SEE LICENSE IN LICENSE",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.cts",
"files": [
"dist/"
"dist"
],
"scripts": {
"build": "tsc --project tsconfig.build.json",
"build:clean": "rm -rf dist && yarn build",
"build:link": "yarn build && cd dist && yarn link && rm -rf node_modules && cd ..",
"build": "ts-bridge --project tsconfig.build.json --clean",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand All @@ -36,6 +49,7 @@
"@metamask/network-controller": "^21.1.0",
"@metamask/polling-controller": "^11.0.0",
"@metamask/transaction-controller": "^37.3.0",
"@ts-bridge/cli": "^0.6.0",
"bignumber.js": "^9.0.1",
"events": "^3.3.0",
"fast-json-patch": "^3.1.0",
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"inlineSources": true,
"noEmit": false,
"outDir": "dist",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"module": "CommonJS",
"moduleResolution": "node",
"noEmit": true,
"noErrorTruncation": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2017"
"target": "es2020"
},
"exclude": ["./dist", "**/node_modules"]
}
41 changes: 40 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,7 @@ __metadata:
"@metamask/network-controller": ^21.1.0
"@metamask/polling-controller": ^11.0.0
"@metamask/transaction-controller": ^37.3.0
"@ts-bridge/cli": ^0.6.0
"@types/jest": ^26.0.24
"@types/lodash": ^4.14.194
"@types/node": ^18.19.17
Expand Down Expand Up @@ -2065,6 +2066,30 @@ __metadata:
languageName: node
linkType: hard

"@ts-bridge/cli@npm:^0.6.0":
version: 0.6.0
resolution: "@ts-bridge/cli@npm:0.6.0"
dependencies:
"@ts-bridge/resolver": ^0.2.0
chalk: ^5.3.0
cjs-module-lexer: ^1.3.1
yargs: ^17.7.2
peerDependencies:
typescript: ">=4.8.0"
bin:
ts-bridge: ./dist/index.js
tsbridge: ./dist/index.js
checksum: b4ba624df897ac44d682d68ed281ca4a11d7d91321fd2728e1805a428c0c7c90fbaa5c59873706072232967f89a57a61aa63b49f738630b48c22b3abf5221c90
languageName: node
linkType: hard

"@ts-bridge/resolver@npm:^0.2.0":
version: 0.2.0
resolution: "@ts-bridge/resolver@npm:0.2.0"
checksum: 3d47ca4f0367a193ed6a19fe1ac36a056547e94e28377869e009a216b2f24a9e5efe90d90de22fd1cf22fa36b84e80f490f328d328cde7675795a19465bf98c4
languageName: node
linkType: hard

"@types/babel__core@npm:^7.1.14":
version: 7.20.5
resolution: "@types/babel__core@npm:7.20.5"
Expand Down Expand Up @@ -3030,6 +3055,13 @@ __metadata:
languageName: node
linkType: hard

"chalk@npm:^5.3.0":
version: 5.3.0
resolution: "chalk@npm:5.3.0"
checksum: 623922e077b7d1e9dedaea6f8b9e9352921f8ae3afe739132e0e00c275971bdd331268183b2628cf4ab1727c45ea1f28d7e24ac23ce1db1eb653c414ca8a5a80
languageName: node
linkType: hard

"char-regex@npm:^1.0.2":
version: 1.0.2
resolution: "char-regex@npm:1.0.2"
Expand Down Expand Up @@ -3058,6 +3090,13 @@ __metadata:
languageName: node
linkType: hard

"cjs-module-lexer@npm:^1.3.1":
version: 1.4.1
resolution: "cjs-module-lexer@npm:1.4.1"
checksum: 2556807a99aec1f9daac60741af96cd613a707f343174ae7967da46402c91dced411bf830d209f2e93be4cecea46fc75cecf1f17c799d7d8a9e1dd6204bfcd22
languageName: node
linkType: hard

"clean-stack@npm:^2.0.0":
version: 2.2.0
resolution: "clean-stack@npm:2.2.0"
Expand Down Expand Up @@ -8260,7 +8299,7 @@ __metadata:
languageName: node
linkType: hard

"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1":
"yargs@npm:17.7.2, yargs@npm:^17.0.1, yargs@npm:^17.3.1, yargs@npm:^17.7.2":
version: 17.7.2
resolution: "yargs@npm:17.7.2"
dependencies:
Expand Down

0 comments on commit dbcd010

Please sign in to comment.