Skip to content

Commit

Permalink
Replace tsup with ts-bridge as build tool (#336)
Browse files Browse the repository at this point in the history
* Replace `tsup` with `ts-bridge` as build tool

Export separate ESM and CJS type declarations

* Fix lockfile

* Remove redundant line from constraints.pro

Co-authored-by: Elliot Winkler <[email protected]>

---------

Co-authored-by: Elliot Winkler <[email protected]>
  • Loading branch information
MajorLift and mcmire authored Jun 26, 2024
1 parent c749bea commit 0b26cd1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 545 deletions.
15 changes: 8 additions & 7 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/MetaMask/
% The license for the package must be specified.
gen_enforced_field(WorkspaceCwd, 'license').

% The type definitions entrypoint the package must be `./dist/types/index.d.ts`.
gen_enforced_field(WorkspaceCwd, 'types', './dist/types/index.d.ts').
gen_enforced_field(WorkspaceCwd, 'exports["."].types', './dist/types/index.d.ts').
% The type definitions entrypoint the package must be `./dist/index.d.cts`.
gen_enforced_field(WorkspaceCwd, 'types', './dist/index.d.cts').

% The entrypoint for the package must be `./dist/index.js`.
gen_enforced_field(WorkspaceCwd, 'main', './dist/index.js').
gen_enforced_field(WorkspaceCwd, 'exports["."].require', './dist/index.js').
% The entrypoint for the package must be `./dist/index.cjs`.
gen_enforced_field(WorkspaceCwd, 'main', './dist/index.cjs').
gen_enforced_field(WorkspaceCwd, 'exports["."].require.types', './dist/index.d.cts').
gen_enforced_field(WorkspaceCwd, 'exports["."].require.default', './dist/index.cjs').

% The module entrypoint for the package must be `./dist/index.mjs`.
gen_enforced_field(WorkspaceCwd, 'module', './dist/index.mjs').
gen_enforced_field(WorkspaceCwd, 'exports["."].import', './dist/index.mjs').
gen_enforced_field(WorkspaceCwd, 'exports["."].import.types', './dist/index.d.mts').
gen_enforced_field(WorkspaceCwd, 'exports["."].import.default', './dist/index.mjs').

gen_enforced_field(WorkspaceCwd, 'exports["./package.json"]', './package.json').

Expand Down
36 changes: 23 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,35 @@
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/types/index.d.ts"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./dist/StreamProvider": {
"import": "./dist/StreamProvider.mjs",
"require": "./dist/StreamProvider.js",
"types": "./dist/types/StreamProvider.d.ts"
"import": {
"types": "./dist/StreamProvider.d.mts",
"default": "./dist/StreamProvider.mjs"
},
"require": {
"types": "./dist/StreamProvider.d.cts",
"default": "./dist/StreamProvider.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.cts",
"files": [
"dist"
],
"scripts": {
"build": "tsup --clean && yarn build:types",
"build": "ts-bridge --project tsconfig.build.json --clean",
"build:clean": "rimraf dist && yarn build",
"build:docs": "typedoc",
"build:types": "tsc --project tsconfig.build.json",
Expand Down Expand Up @@ -77,9 +87,11 @@
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@ts-bridge/cli": "^0.1.4",
"@ts-bridge/shims": "^0.1.1",
"@types/chrome": "^0.0.233",
"@types/jest": "^28.1.6",
"@types/node": "^17.0.23",
"@types/node": "^20.14.9",
"@types/uuid": "^9.0.1",
"@types/webextension-polyfill": "^0.10.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
Expand All @@ -102,7 +114,6 @@
"rimraf": "^3.0.2",
"ts-jest": "^28.0.7",
"ts-node": "^10.7.0",
"tsup": "^7.2.0",
"typedoc": "^0.23.15",
"typescript": "~4.8.4",
"webextension-polyfill": "^0.12.0"
Expand All @@ -120,8 +131,7 @@
},
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false,
"tsup>esbuild": true
"@lavamoat/preinstall-always-fail": false
}
}
}
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"emitDeclarationOnly": true,
"inlineSources": true,
"noEmit": false,
"outDir": "dist/types",
"outDir": "dist",
"rootDir": "src",
"sourceMap": true
},
Expand Down
40 changes: 0 additions & 40 deletions tsup.config.ts

This file was deleted.

Loading

0 comments on commit 0b26cd1

Please sign in to comment.