Skip to content

Commit 9577a9b

Browse files
authored
Use ts-bridge instead of tsc; restrict imports (#226)
- Use `ts-bridge` instead of `tsc` to generate a JavaScript build. - This now produces two variants to cater to CommonJS-only and ESM-compatible bundlers. - Define exports in `package.json` - **BREAKING:** Custom, on-demand subpath imports are no longer supported.
1 parent 8eff000 commit 9577a9b

File tree

2 files changed

+356
-10
lines changed

2 files changed

+356
-10
lines changed

package.json

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,36 @@
77
"url": "https://github.com/MetaMask/auto-changelog.git"
88
},
99
"license": "(MIT OR Apache-2.0)",
10-
"main": "dist/index.js",
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",
1127
"bin": "dist/cli.js",
1228
"files": [
13-
"dist/"
29+
"dist"
1430
],
1531
"scripts": {
16-
"build": "tsc --project tsconfig.build.json",
17-
"build:clean": "rimraf dist && yarn build",
32+
"build": "ts-bridge --project tsconfig.build.json --clean",
1833
"changelog": "node dist/cli.js",
1934
"lint": "yarn lint:eslint && yarn lint:misc --check",
2035
"lint:eslint": "eslint . --cache --ext js,ts",
2136
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
2237
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore",
2338
"prepack": "./scripts/prepack.sh",
24-
"test": "jest",
39+
"test": "jest && attw --pack",
2540
"test:watch": "jest --watch"
2641
},
2742
"dependencies": {
@@ -31,11 +46,13 @@
3146
"yargs": "^17.0.1"
3247
},
3348
"devDependencies": {
49+
"@arethetypeswrong/cli": "^0.15.3",
3450
"@lavamoat/allow-scripts": "^2.1.0",
3551
"@metamask/eslint-config": "^11.1.0",
3652
"@metamask/eslint-config-jest": "^11.1.0",
3753
"@metamask/eslint-config-nodejs": "^11.1.0",
3854
"@metamask/eslint-config-typescript": "^11.1.0",
55+
"@ts-bridge/cli": "^0.6.3",
3956
"@types/cross-spawn": "^6.0.2",
4057
"@types/diff": "^5.0.0",
4158
"@types/jest": "^26.0.23",

0 commit comments

Comments
 (0)