Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ jobs:

- name: Run example tests
if: ${{ matrix.node != '20' && matrix.os != 'windows-latest' }}
run: pnpm run example:test:all
run: |
pnpm run example:test:all

- name: Code Coverage
# skip on windows, it will hangup on codecov
Expand All @@ -176,9 +177,8 @@ jobs:
strategy:
fail-fast: false
matrix:
# os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
os: ['ubuntu-latest', 'windows-latest']
node: ['22']
node: ['24']
# 0-based index
shardIndex: [0, 1, 2]
shardTotal: [3]
Expand Down Expand Up @@ -207,7 +207,9 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm run --filter=./tools/egg-bin ci
run: |
pnpm build --workspace ./tools/egg-bin
pnpm run --filter ./tools/egg-bin ci
env:
# https://github.com/jamiebuilds/ci-parallel-vars
CI_NODE_INDEX: ${{ matrix.shardIndex }}
Expand Down Expand Up @@ -251,7 +253,9 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm run --filter=./tools/scripts ci
run: |
pnpm build
pnpm run --filter=./tools/scripts ci

- name: Code Coverage
if: ${{ matrix.os != 'windows-latest' }}
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ jobs:
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Re-install npm
# TODO: OIDC requires npm >=11.5.1.
# Until Node.js v24 is LTS (with npm 11 as the default), we need to bump.
run: npm install -g npm@11

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run build
run: pnpm build

- name: Configure Git
run: |
git config --local user.email "action@github.com"
Expand Down
65 changes: 26 additions & 39 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ The framework follows a specific loading order:
- **`pnpm-workspace.yaml`** - pnpm workspace configuration with catalog dependencies
- **`package.json`** - Root monorepo configuration with pnpm scripts
- **`tsconfig.json`** - Root TypeScript configuration for all packages (extends @eggjs/tsconfig)
- **`tsconfig.build.json`** - Root build configuration (extends tsconfig.json)
- **`packages/egg/package.json`** - Main egg package with hybrid CommonJS/ESM exports
- **`packages/egg/tsconfig.json`** - Extends workspace root tsconfig.json
- **`packages/egg/tsdown.config.ts`** - tsdown build configuration for unbundled ESM output
Expand Down Expand Up @@ -288,7 +287,6 @@ The framework extends Koa's context with Egg-specific features:
2. Add package.json with workspace dependencies using `workspace:*`
3. Create minimal TypeScript config files:
- `tsconfig.json` → `{"extends": "../../tsconfig.json"}`
- `tsconfig.build.json` → `{"extends": "../../tsconfig.build.json"}`
4. Add package reference to root tsconfig.json `references` array
5. Update root pnpm-workspace.yaml if needed (plugins/\* is already included)
6. Use `pnpm --filter=<package>` for package-specific commands
Expand All @@ -305,35 +303,38 @@ All Egg framework plugins should be placed in the `plugins/` directory:
- `src/` - TypeScript source code
- `test/` - Test suite (use Vitest for new plugins)
- `package.json` with `eggPlugin` configuration
- `tsdown.config.ts` - Build configuration (see standard template below)
- `tsdown.config.ts` - Only needed if custom build options required (see below)

#### Standard Plugin tsdown Configuration
#### tsdown Workspace Configuration

**IMPORTANT: All future plugins MUST use this tsdown configuration template** (based on `plugins/development/tsdown.config.ts`):
**This monorepo uses tsdown workspace mode** for build configuration. The root `/tsdown.config.ts` defines shared defaults for all packages:

- `entry: 'src/**/*.ts'` - Processes all TypeScript files in src directory
- `unbundle: true` - Creates unbundled output (preserves file structure)
- `dts: true` - Generates TypeScript declaration files
- `exports.devExports: true` - Enables development-friendly exports
- `unused.level: 'error'` - Error on unused dependencies
- `publint` - Package linting enabled

**Most plugins do NOT need a `tsdown.config.ts` file** - they inherit all settings from the root workspace config.

**Only create a `tsdown.config.ts` if you need custom options** (e.g., copy assets, custom entry points, ignore unused deps):

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

export default defineConfig({
entry: 'src/**/*.ts',
unbundle: true,
unused: {
level: 'error',
},
dts: true,
exports: {
devExports: true,
},
// Only specify options that differ from workspace defaults
copy: [
{
from: 'src/assets/template.html',
to: 'dist/assets/template.html',
},
],
});
```

This configuration ensures:

- **`entry: 'src/**/\*.ts'`\*\* - Processes all TypeScript files in src directory
- **`unbundle: true`** - Creates unbundled output (preserves file structure)
- **`dts: true`** - Generates TypeScript declaration files
- **`exports.devExports: true`** - Enables development-friendly exports

#### Standard Plugin TypeScript Types

**IMPORTANT: All plugins MUST define a `src/types.ts` file** that extends the Egg module declarations:
Expand Down Expand Up @@ -427,11 +428,8 @@ Plugins should configure their package.json following this pattern:
},
"files": ["dist"],
"scripts": {
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"lint": "oxlint --type-aware",
"test": "vitest run",
"prepublishOnly": "pnpm run build"
"typecheck": "tsgo --noEmit",
"test": "vitest run"
}
}
```
Expand Down Expand Up @@ -471,7 +469,7 @@ Tool packages (like egg-bin) should be placed in the `tools/` directory:
- Use `oxlint --type-aware` for enhanced TypeScript checking
- oxlint automatically respects `.gitignore` patterns for file exclusion
- Package-specific scripts:
- `"typecheck": "tsgo --noEmit && tsc --noEmit"` - Pure TypeScript type checking
- `"typecheck": "tsgo --noEmit"` - Pure TypeScript type checking
- `"lint": "oxlint --type-aware"` - Linting with type awareness
- Remove any `.eslintrc` or `.eslintrc.js` files when migrating packages

Expand Down Expand Up @@ -509,10 +507,6 @@ Tool packages (like egg-bin) should be placed in the `tools/` directory:
- Uses `${configDir}` variable for dynamic path resolution
- Includes project `references` array listing all sub-packages
- Sets `composite: true` and `incremental: true` for project references
- `tsconfig.build.json` - Build-specific configuration
- Extends from root `tsconfig.json`
- Defines `rootDir` as `${configDir}/src` and `outDir` as `${configDir}/dist`
- Excludes test files, dist directories, and config files

**Sub-Project Configuration Pattern:**

Expand All @@ -525,13 +519,6 @@ All packages, plugins, and tools MUST follow this minimal pattern:
}
```

```json
// packages/*/tsconfig.build.json, plugins/*/tsconfig.build.json
{
"extends": "../../tsconfig.build.json"
}
```

**Key Requirements:**

- **Keep it minimal** - Sub-project configs should ONLY contain the `extends` field
Expand Down Expand Up @@ -852,7 +839,7 @@ NODE_OPTIONS='--inspect-brk' pnpm --filter=egg run test
- Add `"oxlint": "catalog:"` to devDependencies
2. Delete `.eslintrc`, `.eslintrc.js`, or `.eslintrc.json` files
3. Update scripts in package.json:
- Add `"typecheck": "tsgo --noEmit && tsc --noEmit"` for TypeScript type checking
- Add `"typecheck": "tsgo --noEmit"` for TypeScript type checking
- Change `"lint": "eslint ..."` to `"lint": "oxlint --type-aware"`
- Add `"lint:fix": "npm run lint -- --fix"`
4. Ensure both type checking and linting are run:
Expand Down
6 changes: 1 addition & 5 deletions examples/helloworld-commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"scripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test": "egg-bin test",
"cov": "egg-bin cov",
"lint": "oxlint",
"ci": "pnpm run lint && pnpm run cov",
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop"
Expand All @@ -18,8 +15,7 @@
"egg": "workspace:*"
},
"devDependencies": {
"@eggjs/bin": "workspace:*",
"oxlint": "catalog:"
"@eggjs/bin": "workspace:*"
},
"engines": {
"node": ">=22.18.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-tegg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"prepublishOnly": "pnpm run build",
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"typecheck": "tsgo --noEmit",
"build": "tsdown"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prepublishOnly": "pnpm run build",
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"typecheck": "tsgo --noEmit",
"build": "tsdown"
},
"dependencies": {
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
},
"type": "module",
"scripts": {
"clean": "pnpm -r --parallel run clean && rimraf packages/*/dist plugins/*/dist tools/*/dist examples/*/dist tegg/**/dist **/*/*.tsbuildinfo",
"build": "pnpm clean && pnpm -r run build",
"build:parallel": "pnpm clean && pnpm -r --parallel run build",
"clean-dist": "pnpm -r --parallel exec rimraf dist",
"clean": "pnpm -r --parallel run clean && pnpm clean-dist",
"build": "tsdown",
"prelint": "pnpm clean-dist",
"lint": "oxlint --type-aware --type-check --quiet",
"fmt": "oxfmt",
"typecheck": "pnpm clean && pnpm -r run typecheck",
"typecheck:parallel": "pnpm clean && pnpm -r --parallel run typecheck",
"fmtcheck": "oxfmt --check .",
"pretest": "pnpm run clean && pnpm -r run pretest",
"test": "vitest run --bail 1 --retry 2",
"test": "vitest run --bail 1 --retry 2 --testTimeout 20000 --hookTimeout 20000",
"test:cov": "pnpm run test --coverage",
"preci": "pnpm -r --parallel run pretest",
"ci": "vitest run --bail 1 --retry 2 --coverage --testTimeout 20000 --hookTimeout 20000",
"ci": "pnpm run test --coverage",
"site:dev": "pnpm --filter=site run dev",
"site:build": "pnpm --filter=site run build",
"puml": "puml . --dest ./site",
Expand Down Expand Up @@ -60,14 +60,15 @@
"publint": "catalog:",
"rimraf": "catalog:",
"semver": "catalog:",
"tsdown": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:",
"urllib": "catalog:",
"vitest": "catalog:"
},
"lint-staged": {
"*": [
"oxfmt",
"oxfmt --no-error-on-unmatched-pattern",
"oxlint --type-aware --fix"
]
},
Expand Down
6 changes: 2 additions & 4 deletions packages/cluster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@
}
},
"scripts": {
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
"lint": "oxlint",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"test": "vitest run",
"prepublishOnly": "pnpm run build"
"typecheck": "tsgo --noEmit",
"test": "vitest run"
},
"dependencies": {
"@eggjs/utils": "workspace:*",
Expand Down
3 changes: 0 additions & 3 deletions packages/cluster/tsconfig.build.json

This file was deleted.

9 changes: 2 additions & 7 deletions packages/cluster/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { defineConfig, type UserConfig } from 'tsdown';
import { defineConfig } from 'tsdown';

import baseConfig from '../../tsdown.config.json' with { type: 'json' };

const config: UserConfig = defineConfig({
...(baseConfig as UserConfig),
export default defineConfig({
entry: {
index: 'src/index.ts',
agent_worker: 'src/agent_worker.ts',
app_worker: 'src/app_worker.ts',
},
});

export default config;
6 changes: 2 additions & 4 deletions packages/cluster/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { defineProject, type UserWorkspaceConfig } from 'vitest/config';
import { defineProject } from 'vitest/config';

const config: UserWorkspaceConfig = defineProject({
export default defineProject({
test: {
include: ['test/**/*.test.ts'],
exclude: ['test/fixtures/**', '**/node_modules/**', '**/dist/**'],
testTimeout: 25000,
hookTimeout: 25000,
},
});

export default config;
10 changes: 1 addition & 9 deletions packages/cookies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@
}
},
"scripts": {
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"lint": "oxlint --type-aware",
"lint:fix": "npm run lint -- --fix",
"test": "npm run lint:fix && vitest run",
"ci": "vitest run --coverage",
"prepublishOnly": "pnpm run build"
"typecheck": "tsgo --noEmit"
},
"dependencies": {
"should-send-same-site-none": "catalog:",
Expand All @@ -47,8 +41,6 @@
"benchmark": "catalog:",
"cookies": "catalog:",
"keygrip": "catalog:",
"oxlint": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:"
},
"engines": {
Expand Down
3 changes: 0 additions & 3 deletions packages/cookies/tsconfig.build.json

This file was deleted.

9 changes: 2 additions & 7 deletions packages/cookies/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { defineConfig, type UserConfig } from 'tsdown';
import { defineConfig } from 'tsdown';

import baseConfig from '../../tsdown.config.json' with { type: 'json' };

const config: UserConfig = defineConfig({
...(baseConfig as UserConfig),
export default defineConfig({
entry: {
index: 'src/index.ts',
},
});

export default config;
9 changes: 0 additions & 9 deletions packages/cookies/vitest.config.ts

This file was deleted.

7 changes: 1 addition & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@
}
},
"scripts": {
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
"lint": "oxlint",
"typecheck": "tsgo --noEmit && tsc --noEmit",
"test": "vitest run",
"prepublishOnly": "pnpm run build"
"typecheck": "tsgo --noEmit"
},
"dependencies": {
"@eggjs/extend2": "workspace:*",
Expand Down Expand Up @@ -69,7 +65,6 @@
"husky": "catalog:",
"js-yaml": "catalog:",
"mm": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:",
"urllib": "catalog:"
},
Expand Down
Loading
Loading