Skip to content

Commit 8e29b67

Browse files
fengmk2claude
andcommitted
chore(build): migrate to tsdown workspace mode
Replace per-package tsdown config spreading with native workspace mode: - Add root tsdown.config.ts with workspace configuration - Remove 60 standard tsdown.config.ts files that only spread base config - Keep 7 configs with custom options (copy, unbundle, unused.ignore) - Simplify root build script to just run tsdown once - Delete tsdown.config.json (old JSON base config) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6de1d54 commit 8e29b67

139 files changed

Lines changed: 790 additions & 344 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -305,35 +305,38 @@ All Egg framework plugins should be placed in the `plugins/` directory:
305305
- `src/` - TypeScript source code
306306
- `test/` - Test suite (use Vitest for new plugins)
307307
- `package.json` with `eggPlugin` configuration
308-
- `tsdown.config.ts` - Build configuration (see standard template below)
308+
- `tsdown.config.ts` - Only needed if custom build options required (see below)
309309

310-
#### Standard Plugin tsdown Configuration
310+
#### tsdown Workspace Configuration
311311

312-
**IMPORTANT: All future plugins MUST use this tsdown configuration template** (based on `plugins/development/tsdown.config.ts`):
312+
**This monorepo uses tsdown workspace mode** for build configuration. The root `/tsdown.config.ts` defines shared defaults for all packages:
313+
314+
- `entry: 'src/**/*.ts'` - Processes all TypeScript files in src directory
315+
- `unbundle: true` - Creates unbundled output (preserves file structure)
316+
- `dts: true` - Generates TypeScript declaration files
317+
- `exports.devExports: true` - Enables development-friendly exports
318+
- `unused.level: 'error'` - Error on unused dependencies
319+
- `publint` - Package linting enabled
320+
321+
**Most plugins do NOT need a `tsdown.config.ts` file** - they inherit all settings from the root workspace config.
322+
323+
**Only create a `tsdown.config.ts` if you need custom options** (e.g., copy assets, custom entry points, ignore unused deps):
313324

314325
```typescript
326+
// plugins/[plugin-name]/tsdown.config.ts - ONLY if custom options needed
315327
import { defineConfig } from 'tsdown';
316328

317329
export default defineConfig({
318-
entry: 'src/**/*.ts',
319-
unbundle: true,
320-
unused: {
321-
level: 'error',
322-
},
323-
dts: true,
324-
exports: {
325-
devExports: true,
326-
},
330+
// Only specify options that differ from workspace defaults
331+
copy: [
332+
{
333+
from: 'src/assets/template.html',
334+
to: 'dist/assets/template.html',
335+
},
336+
],
327337
});
328338
```
329339

330-
This configuration ensures:
331-
332-
- **`entry: 'src/**/\*.ts'`\*\* - Processes all TypeScript files in src directory
333-
- **`unbundle: true`** - Creates unbundled output (preserves file structure)
334-
- **`dts: true`** - Generates TypeScript declaration files
335-
- **`exports.devExports: true`** - Enables development-friendly exports
336-
337340
#### Standard Plugin TypeScript Types
338341

339342
**IMPORTANT: All plugins MUST define a `src/types.ts` file** that extends the Egg module declarations:

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "module",
1212
"scripts": {
1313
"clean": "pnpm -r --parallel run clean && rimraf packages/*/dist plugins/*/dist tools/*/dist examples/*/dist tegg/**/dist **/*/*.tsbuildinfo",
14-
"build": "pnpm clean && pnpm -r run build",
15-
"build:parallel": "pnpm clean && pnpm -r --parallel run build",
14+
"tsdown": "tsdown",
15+
"build": "pnpm clean && pnpm tsdown",
1616
"lint": "oxlint --type-aware --type-check --quiet",
1717
"fmt": "oxfmt",
1818
"typecheck": "pnpm clean && pnpm -r run typecheck",
@@ -60,6 +60,7 @@
6060
"publint": "catalog:",
6161
"rimraf": "catalog:",
6262
"semver": "catalog:",
63+
"tsdown": "catalog:",
6364
"tsx": "catalog:",
6465
"typescript": "catalog:",
6566
"urllib": "catalog:",

packages/cluster/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
}
4242
},
4343
"scripts": {
44-
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
4544
"lint": "oxlint",
4645
"typecheck": "tsgo --noEmit && tsc --noEmit",
4746
"test": "vitest run",

packages/cluster/tsdown.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { defineConfig, type UserConfig } from 'tsdown';
22

3-
import baseConfig from '../../tsdown.config.json' with { type: 'json' };
4-
53
const config: UserConfig = defineConfig({
6-
...(baseConfig as UserConfig),
74
entry: {
85
index: 'src/index.ts',
9-
agent_worker: 'src/agent_worker.ts',
10-
app_worker: 'src/app_worker.ts',
116
},
127
});
138

packages/cookies/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,24 @@
1919
"types": "./dist/index.d.ts",
2020
"exports": {
2121
".": "./src/index.ts",
22+
"./cookie": "./src/cookie.ts",
23+
"./cookies": "./src/cookies.ts",
24+
"./error": "./src/error.ts",
25+
"./keygrip": "./src/keygrip.ts",
2226
"./package.json": "./package.json"
2327
},
2428
"publishConfig": {
2529
"access": "public",
2630
"exports": {
2731
".": "./dist/index.js",
32+
"./cookie": "./dist/cookie.js",
33+
"./cookies": "./dist/cookies.js",
34+
"./error": "./dist/error.js",
35+
"./keygrip": "./dist/keygrip.js",
2836
"./package.json": "./package.json"
2937
}
3038
},
3139
"scripts": {
32-
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
3340
"typecheck": "tsgo --noEmit && tsc --noEmit",
3441
"lint": "oxlint --type-aware",
3542
"lint:fix": "npm run lint -- --fix",

packages/cookies/tsdown.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { defineConfig, type UserConfig } from 'tsdown';
22

3-
import baseConfig from '../../tsdown.config.json' with { type: 'json' };
4-
53
const config: UserConfig = defineConfig({
6-
...(baseConfig as UserConfig),
74
entry: {
85
index: 'src/index.ts',
96
},

packages/core/package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,38 @@
2626
"types": "./dist/index.d.ts",
2727
"exports": {
2828
".": "./src/index.ts",
29+
"./base_context_class": "./src/base_context_class.ts",
30+
"./egg": "./src/egg.ts",
31+
"./lifecycle": "./src/lifecycle.ts",
32+
"./loader/context_loader": "./src/loader/context_loader.ts",
33+
"./loader/egg_loader": "./src/loader/egg_loader.ts",
34+
"./loader/file_loader": "./src/loader/file_loader.ts",
35+
"./singleton": "./src/singleton.ts",
36+
"./types": "./src/types.ts",
37+
"./utils": "./src/utils/index.ts",
38+
"./utils/sequencify": "./src/utils/sequencify.ts",
39+
"./utils/timing": "./src/utils/timing.ts",
2940
"./package.json": "./package.json"
3041
},
3142
"publishConfig": {
3243
"access": "public",
3344
"exports": {
3445
".": "./dist/index.js",
46+
"./base_context_class": "./dist/base_context_class.js",
47+
"./egg": "./dist/egg.js",
48+
"./lifecycle": "./dist/lifecycle.js",
49+
"./loader/context_loader": "./dist/loader/context_loader.js",
50+
"./loader/egg_loader": "./dist/loader/egg_loader.js",
51+
"./loader/file_loader": "./dist/loader/file_loader.js",
52+
"./singleton": "./dist/singleton.js",
53+
"./types": "./dist/types.js",
54+
"./utils": "./dist/utils/index.js",
55+
"./utils/sequencify": "./dist/utils/sequencify.js",
56+
"./utils/timing": "./dist/utils/timing.js",
3557
"./package.json": "./package.json"
3658
}
3759
},
3860
"scripts": {
39-
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
4061
"lint": "oxlint",
4162
"typecheck": "tsgo --noEmit && tsc --noEmit",
4263
"test": "vitest run",

packages/core/tsdown.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { defineConfig, type UserConfig } from 'tsdown';
22

3-
import baseConfig from '../../tsdown.config.json' with { type: 'json' };
4-
53
const config: UserConfig = defineConfig({
6-
...(baseConfig as UserConfig),
74
entry: {
85
index: 'src/index.ts',
96
},

packages/egg/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
"scripts": {
140140
"lint": "oxlint",
141141
"typecheck": "tsgo --noEmit && tsc --noEmit",
142-
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json && cp src/config/favicon.png dist/config/favicon.png",
143142
"test": "vitest run",
144143
"prepublishOnly": "pnpm run build"
145144
},

packages/egg/tsdown.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { defineConfig, type UserConfig } from 'tsdown';
22

3-
import baseConfig from '../../tsdown.config.json' with { type: 'json' };
4-
53
const config: UserConfig = defineConfig({
6-
...(baseConfig as UserConfig),
7-
entry: 'src/**/*.ts',
84
copy: [
95
{
106
from: 'src/config/favicon.png',

0 commit comments

Comments
 (0)