Skip to content

Commit 2b2d1a1

Browse files
authored
build: use tsup instead of esbuild for packages (@fehmer) (monkeytypegame#6309)
1 parent 4a22c06 commit 2b2d1a1

File tree

14 files changed

+503
-238
lines changed

14 files changed

+503
-238
lines changed

packages/contracts/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
"name": "@monkeytype/contracts",
33
"private": true,
44
"scripts": {
5-
"dev": "rimraf ./dist && monkeytype-esbuild --watch",
6-
"build": "rimraf ./dist && npm run madge && monkeytype-esbuild",
5+
"dev": "tsup-node --watch",
6+
"build": "npm run madge && tsup-node",
77
"test": "vitest run",
88
"madge": " madge --circular --extensions ts ./src",
99
"ts-check": "tsc --noEmit",
1010
"lint": "eslint \"./**/*.ts\""
1111
},
12-
"dependencies": {
12+
"peerDependencies": {
1313
"@ts-rest/core": "3.51.0",
1414
"zod": "3.23.8"
1515
},
1616
"devDependencies": {
17-
"@monkeytype/esbuild": "workspace:*",
1817
"@monkeytype/eslint-config": "workspace:*",
18+
"@monkeytype/tsup-config": "workspace:*",
1919
"@monkeytype/typescript-config": "workspace:*",
2020
"chokidar": "3.6.0",
2121
"eslint": "8.57.1",
2222
"madge": "8.0.0",
23-
"rimraf": "6.0.1",
23+
"tsup": "8.4.0",
2424
"typescript": "5.5.4",
2525
"vitest": "2.1.9"
2626
},
2727
"exports": {
2828
".": {
2929
"types": "./src/index.ts",
3030
"import": "./dist/index.mjs",
31-
"require": "./dist/index.cjs"
31+
"require": "./dist/index.js"
3232
},
3333
"./*": {
3434
"types": "./src/*.ts",
3535
"import": "./dist/*.mjs",
36-
"require": "./dist/*.cjs"
36+
"require": "./dist/*.js"
3737
}
3838
}
3939
}

packages/contracts/tsup.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { extendConfig } from "@monkeytype/tsup-config";
2+
3+
export default extendConfig();

packages/esbuild-config/index.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

packages/esbuild-config/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/funbox/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"name": "@monkeytype/funbox",
33
"private": true,
44
"scripts": {
5-
"dev": "rimraf ./dist && monkeytype-esbuild --watch",
6-
"build": "rimraf ./dist && npm run madge && monkeytype-esbuild",
5+
"dev": "tsup-node --watch",
6+
"build": "npm run madge && tsup-node",
77
"madge": " madge --circular --extensions ts ./src",
88
"ts-check": "tsc --noEmit",
99
"lint": "eslint \"./**/*.ts\""
1010
},
1111
"devDependencies": {
12-
"@monkeytype/esbuild": "workspace:*",
1312
"@monkeytype/eslint-config": "workspace:*",
13+
"@monkeytype/tsup-config": "workspace:*",
1414
"@monkeytype/typescript-config": "workspace:*",
1515
"chokidar": "3.6.0",
1616
"eslint": "8.57.1",
1717
"madge": "8.0.0",
18-
"rimraf": "6.0.1",
18+
"tsup": "8.4.0",
1919
"typescript": "5.5.4",
2020
"vitest": "2.1.9"
2121
},
@@ -26,7 +26,7 @@
2626
".": {
2727
"types": "./src/index.ts",
2828
"import": "./dist/index.mjs",
29-
"require": "./dist/index.cjs"
29+
"require": "./dist/index.js"
3030
}
3131
}
3232
}

packages/funbox/tsup.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { extendConfig } from "@monkeytype/tsup-config";
2+
3+
export default extendConfig(() => ({ entry: ["src/index.ts"] }));

packages/tsup-config/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@monkeytype/tsup-config",
3+
"private": true,
4+
"scripts": {
5+
"dev": "tsup-node --watch",
6+
"build": "tsup-node",
7+
"ts-check": "tsc --noEmit"
8+
},
9+
"peerDependencies": {
10+
"tsup": "8.4.0"
11+
},
12+
"devDependencies": {
13+
"@monkeytype/typescript-config": "workspace:*",
14+
"eslint": "8.57.1",
15+
"typescript": "5.5.4"
16+
},
17+
"exports": {
18+
".": {
19+
"types": "./src/index.ts",
20+
"import": "./dist/index.mjs",
21+
"require": "./dist/index.js"
22+
}
23+
}
24+
}

packages/tsup-config/src/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defineConfig, Options } from "tsup";
2+
3+
export function extendConfig(
4+
customizer?: (options: Options) => Options
5+
// tsup uses MaybePromise which is not exported
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7+
): (options: Options) => any {
8+
return (options) => {
9+
const overrideOptions = customizer?.(options);
10+
const config: Options = {
11+
entry: ["src/**/*.ts"],
12+
splitting: false,
13+
sourcemap: true,
14+
clean: !(options.watch === true || options.watch === "true"),
15+
format: ["cjs", "esm"],
16+
dts: false,
17+
minify: true,
18+
...(overrideOptions || {}),
19+
};
20+
21+
return defineConfig(config);
22+
};
23+
}

packages/tsup-config/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "@monkeytype/typescript-config/base.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"rootDir": "./src",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"moduleResolution": "Node",
9+
"module": "ES6",
10+
"target": "ES2015",
11+
"lib": ["es2016"]
12+
},
13+
"include": ["src"],
14+
"exclude": ["node_modules", "dist"]
15+
}

0 commit comments

Comments
 (0)