Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR updates build configuration files across multiple packages in the monorepo. It adds new tsdown configuration files, modifies copy destination paths to target directories instead of specific files, reorganizes TypeScript compilation exclusions, bumps the tsdown dependency from ^0.18.0 to ^0.18.2, and adjusts root workspace configuration options. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining the build configuration, specifically targeting Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Deploying egg with
|
| Latest commit: |
8a000ee
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0c34d78f.egg-cci.pages.dev |
| Branch Preview URL: | https://fix-tsdown-unbundle.egg-cci.pages.dev |
Deploying egg-v3 with
|
| Latest commit: |
8a000ee
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0427fb38.egg-v3.pages.dev |
| Branch Preview URL: | https://fix-tsdown-unbundle.egg-v3.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request attempts to fix an issue with tsdown's unbundle mode by upgrading tsdown and switching to workspace.include: 'auto'. The changes look reasonable, primarily involving configuration updates in tsdown.config.ts and pnpm-workspace.yaml, and adding package-specific tsdown configs. My main feedback is to clean up the commented-out code in the main tsdown.config.ts file once the fix is confirmed to be working, which will improve the long-term maintainability of the configuration.
tsdown.config.ts
Outdated
There was a problem hiding this comment.
This block contains several pieces of commented-out configuration.
- The
FIXMEon line 7 is now slightly misplaced relative to theinclude: 'auto'on line 8. - The
excludeon lines 9-11 is now handled by the newpackages/tsconfig/tsdown.config.ts.
If the new include: 'auto' approach works as expected with the tsdown upgrade, it would be best to remove all of this commented-out code (lines 6-7 and 9-11) to improve the configuration file's clarity. The git history can be used to reference the old configuration if needed.
tsdown.config.ts
Outdated
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5746 +/- ##
=======================================
Coverage 87.60% 87.61%
=======================================
Files 563 563
Lines 10930 10930
Branches 1239 1239
=======================================
+ Hits 9575 9576 +1
+ Misses 1271 1270 -1
Partials 84 84 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
tools/create-egg/tsdown.config.ts (1)
3-12: Missing explicit type annotation for config export.Based on coding guidelines, configuration files for tsdown must use typed intermediate variables with explicit type annotations.
🔎 Proposed refactor to add explicit type annotation
-import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +const config: UserConfig = defineConfig({ -export default defineConfig({ unbundle: false, entry: ['src/index.ts', 'src/cli.ts'], copy: [ { from: 'src/templates', to: 'dist', }, ], }); +export default config;Based on learnings, config files must use explicit UserConfig type annotations.
packages/egg/tsdown.config.ts (1)
3-10: Missing explicit type annotation for config export.Based on coding guidelines, tsdown configuration files must use typed intermediate variables with explicit UserConfig type annotations.
🔎 Proposed refactor to add explicit type annotation
-import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +const config: UserConfig = defineConfig({ -export default defineConfig({ copy: [ { from: 'src/config/favicon.png', to: 'dist/config', }, ], }); +export default config;Based on learnings, config files must use explicit UserConfig type annotations.
tools/egg-bin/tsdown.config.ts (1)
3-15: Missing explicit type annotation for config export.Based on coding guidelines, tsdown configuration files must use typed intermediate variables with explicit UserConfig type annotations.
🔎 Proposed refactor to add explicit type annotation
-import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +const config: UserConfig = defineConfig({ -export default defineConfig({ // MEMO: @oclif/core only works in unbundle mode (already default) unused: { level: 'error', ignore: ['utility'], }, copy: [ { from: 'scripts', to: 'dist', }, ], }); +export default config;Based on learnings, config files must use explicit UserConfig type annotations.
tsdown.config.ts (1)
3-31: Use typed intermediate variable for config export.The configuration should follow the coding guideline requirement for typed intermediate variables with explicit type annotations.
🔎 Proposed refactor to use typed intermediate variable
+import type { UserConfig } from 'tsdown'; import { defineConfig } from 'tsdown'; -export default defineConfig({ +const config: UserConfig = defineConfig({ // Workspace configuration - builds all library packages from root workspace: { include: ['packages/*', 'plugins/*', 'tools/*', 'tegg/core/*', 'tegg/plugin/*', 'tegg/standalone/*'], exclude: [ 'packages/tsconfig', // Config-only package, no src to build 'dist', ], }, // Shared defaults unused: { level: 'error', }, exports: { devExports: true, }, fixedExtension: false, publint: { level: 'suggestion', strict: true, }, // Default entry pattern - glob to include all source files entry: 'src/**/*.ts', // should set unbundle and external together, avoid bundle @eggjs/* and egg packages unbundle: true, external: [/^@eggjs\//, 'egg'], }); + +export default config;As per coding guidelines: "Use typed intermediate variables for tsdown and vitest config exports with explicit UserConfig/UserWorkspaceConfig type annotations."
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
CLAUDE.md(1 hunks)packages/egg/tsdown.config.ts(1 hunks)packages/tsconfig/tsdown.config.ts(1 hunks)plugins/mock/tsdown.config.ts(1 hunks)pnpm-workspace.yaml(2 hunks)tools/create-egg/tsconfig.json(1 hunks)tools/create-egg/tsdown.config.ts(1 hunks)tools/egg-bin/tsdown.config.ts(1 hunks)tsdown.config.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
packages/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/**/*.ts: Use TypeScript throughout all packages in the Eggjs monorepo
Use strict TypeScript mode in all packages
Files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.ts
packages/*/tsdown.config.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use tsdown for unbundled ESM builds that preserves file structure; configure via tsdown.config.ts in each package
Files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.ts
**/*.{ts,tsx,js,mjs}
📄 CodeRabbit inference engine (AGENTS.md)
Use
.tssources over CommonJS and prefer ESM for exports
Files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstsdown.config.tsplugins/mock/tsdown.config.ts
{packages,plugins}/**/*.{ts,tsx,js,mjs}
📄 CodeRabbit inference engine (AGENTS.md)
Name files in lowercase with hyphens (e.g.
loader-context.ts)
Files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.tsplugins/mock/tsdown.config.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Name classes in PascalCase
Name functions and variables in camelCase
**/*.{ts,tsx}: Use explicit return types for all exported functions, methods, and getters to support TypeScript's--isolatedDeclarationsflag
Avoid computed property names with symbols in class declarations; use override methods instead for compatibility with--isolatedDeclarations
Add explicit type annotations for class properties, particularly for exported symbols which should useunique symboltype
Enable strict mode in all TypeScript packages and use explicit return types for public APIs
Prefer interfaces over type aliases for object shapes in TypeScript
Use readonly modifiers where appropriate in TypeScript classes and interfaces
Avoidanytype; useunknownwhen type is truly unknown
Files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstsdown.config.tsplugins/mock/tsdown.config.ts
pnpm-workspace.yaml
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Define dependencies in pnpm-workspace.yaml catalog section and reference catalog entries with 'package-name': 'catalog:' or internal workspace dependencies with 'package-name': 'workspace:*'
Files:
pnpm-workspace.yaml
**/tsconfig.json
📄 CodeRabbit inference engine (CLAUDE.md)
Always extend the root tsconfig.json in sub-project TypeScript configurations using the minimal
extendspattern
Files:
tools/create-egg/tsconfig.json
{tsdown,vitest}.config.ts
📄 CodeRabbit inference engine (CLAUDE.md)
{tsdown,vitest}.config.ts: Use typed intermediate variables for tsdown and vitest config exports with explicit UserConfig/UserWorkspaceConfig type annotations
Configuration files for tools (tsdown, vitest) must use typed intermediate variables with explicit type annotations for config objects
Files:
tsdown.config.ts
🧠 Learnings (40)
📓 Common learnings
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/package.json : Egg.js version must be >= 4.1.0
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/*/tsdown.config.ts : Use tsdown for unbundled ESM builds that preserves file structure; configure via tsdown.config.ts in each package
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: All packages in this monorepo require Node.js >= 22.18.0 - enforce this minimum version across all packages for compatibility with modern JavaScript features and optimal performance
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to packages/*/tsconfig.json : Create minimal tsconfig.json files in sub-packages containing only `{"extends": "../../tsconfig.json"}`
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/**/*.ts : Use TypeScript throughout all packages in the Eggjs monorepo
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/*/tsconfig.json : All sub-project tsconfig.json files MUST extend from root tsconfig.json using 'extends': '../../tsconfig.json'
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/package.json : Use `workspace:*` protocol for internal monorepo dependencies (both tegg and egg packages)
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to packages/*/tsconfig.json : Sub-project TypeScript configurations must be minimal with only an `extends` field pointing to the root `tsconfig.json`; no additional options should be added
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to {tsdown,vitest}.config.ts : Use typed intermediate variables for tsdown and vitest config exports with explicit UserConfig/UserWorkspaceConfig type annotations
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/pnpm-workspace.yaml : Centralize all shared dependency versions in the root `pnpm-workspace.yaml` rather than in individual tegg package files
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to **/tsconfig.json : Always extend the root tsconfig.json in sub-project TypeScript configurations using the minimal `extends` pattern
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/*/tsdown.config.ts : Use tsdown for unbundled ESM builds that preserves file structure; configure via tsdown.config.ts in each package
Applied to files:
packages/egg/tsdown.config.tspnpm-workspace.yamlpackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to packages/*/tsconfig.json : Create minimal tsconfig.json files in sub-packages containing only `{"extends": "../../tsconfig.json"}`
Applied to files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to {tsdown,vitest}.config.ts : Use typed intermediate variables for tsdown and vitest config exports with explicit UserConfig/UserWorkspaceConfig type annotations
Applied to files:
packages/egg/tsdown.config.tspnpm-workspace.yamlpackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Most plugins do NOT need a `tsdown.config.ts` file - only create one if you need custom options like copying assets or custom entry points
Applied to files:
packages/egg/tsdown.config.tspackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/pnpm-workspace.yaml : Use pnpm workspaces with `catalog:` protocol for shared external dependencies
Applied to files:
pnpm-workspace.yamltsdown.config.ts
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to pnpm-workspace.yaml : Define dependencies in pnpm-workspace.yaml catalog section and reference catalog entries with 'package-name': 'catalog:' or internal workspace dependencies with 'package-name': 'workspace:*'
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to package.json : Use `workspace:*` for internal package dependencies and `catalog:` for external dependencies defined in pnpm-workspace.yaml
Applied to files:
pnpm-workspace.yamltsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/pnpm-workspace.yaml : Centralize all shared dependency versions in the root `pnpm-workspace.yaml` rather than in individual tegg package files
Applied to files:
pnpm-workspace.yamltsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: All packages in this monorepo require Node.js >= 22.18.0 - enforce this minimum version across all packages for compatibility with modern JavaScript features and optimal performance
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-20T09:24:59.960Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T09:24:59.960Z
Learning: Run `pnpm install` to hydrate the workspace (Node.js ≥ 20.19.0 required)
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/package.json : Node.js version must be >= 22.18.0
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/package.json : Use `workspace:*` protocol for internal monorepo dependencies (both tegg and egg packages)
Applied to files:
pnpm-workspace.yamltsdown.config.ts
📚 Learning: 2025-12-20T09:24:59.960Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T09:24:59.960Z
Learning: Keep local Node.js and pnpm versions aligned with the repository's `packageManager` field
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to {tsdown,vitest}.config.ts : Configuration files for tools (tsdown, vitest) must use typed intermediate variables with explicit type annotations for config objects
Applied to files:
pnpm-workspace.yamlpackages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: All packages must include TypeScript type checking with `tsc --noEmit` in the `typecheck` script
Applied to files:
pnpm-workspace.yamlpackages/tsconfig/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Node.js >= 20.19.0 is required - this is a hard requirement
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to **/*.{ts,tsx} : Enable strict mode in all TypeScript packages and use explicit return types for public APIs
Applied to files:
pnpm-workspace.yamltools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/**/*.ts : Use TypeScript throughout all packages in the Eggjs monorepo
Applied to files:
pnpm-workspace.yamltools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/**/*.ts : Use strict TypeScript mode in all packages
Applied to files:
pnpm-workspace.yamltsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: All packages must use oxlint for linting with the `--type-aware` flag; remove any `.eslintrc` or `.eslintrc.js` files when migrating
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/.oxlintrc.json : Run oxlint with `--type-aware` flag for enhanced TypeScript checking on all packages
Applied to files:
pnpm-workspace.yaml
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to packages/*/tsconfig.json : Sub-project TypeScript configurations must be minimal with only an `extends` field pointing to the root `tsconfig.json`; no additional options should be added
Applied to files:
packages/tsconfig/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/core/*/tsconfig.json : Each new core package should include `tsconfig.json` extending `eggjs/tsconfig`
Applied to files:
packages/tsconfig/tsdown.config.tstools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.json
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Each package should include a `vitest.config.ts` file for test configuration and import test functions from vitest
Applied to files:
packages/tsconfig/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to **/tsconfig.json : Always extend the root tsconfig.json in sub-project TypeScript configurations using the minimal `extends` pattern
Applied to files:
packages/tsconfig/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: All packages must define a `src/types.ts` file that extends the Egg module declarations using `declare module 'egg'` pattern
Applied to files:
tools/egg-bin/tsdown.config.tstools/create-egg/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-12-20T09:24:59.960Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T09:24:59.960Z
Learning: Applies to **/*.{ts,tsx,js,mjs} : Use `.ts` sources over CommonJS and prefer ESM for exports
Applied to files:
tools/egg-bin/tsdown.config.tstools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to **/*.{ts,tsx} : Use explicit return types for all exported functions, methods, and getters to support TypeScript's `--isolatedDeclarations` flag
Applied to files:
tools/create-egg/tsconfig.jsonplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/tsconfig.json : Use `emitDecoratorMetadata` in TypeScript configuration for type inference in dependency injection
Applied to files:
tools/create-egg/tsconfig.jsonplugins/mock/tsdown.config.ts
📚 Learning: 2025-11-27T14:37:59.711Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T14:37:59.711Z
Learning: Applies to packages/*/tsconfig.json : All sub-project tsconfig.json files MUST extend from root tsconfig.json using 'extends': '../../tsconfig.json'
Applied to files:
tools/create-egg/tsconfig.jsontsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/vitest.config.ts : Configure test discovery through monorepo root `vitest.config.ts` which includes all tegg packages
Applied to files:
tools/create-egg/tsconfig.jsontsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/pnpm-workspace.yaml : Tegg packages should be defined in root pnpm-workspace.yaml with patterns `tegg/core/*`, `tegg/plugin/*`, `tegg/standalone/*`
Applied to files:
tsdown.config.ts
📚 Learning: 2025-12-20T09:24:59.960Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-20T09:24:59.960Z
Learning: Maintain Egg as a pnpm monorepo with core runtime code in `packages/egg`, supporting modules in `packages/core`, `packages/cluster`, and `packages/utils`, optional integrations under `plugins/`, examples in `examples/`, documentation site in `site/`, and unit tests beside packages under `test/` directories with fixtures in `test/fixtures/`
Applied to files:
tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/*.{js,ts,mjs,cjs} : Use ESM only (no CommonJS)
Applied to files:
tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to plugins/*/package.json : Plugin packages must configure exports in package.json with both development (`./src/*.ts`) and published (`./dist/*.js`) entry points
Applied to files:
tsdown.config.tsplugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to plugins/*/package.json : All plugins must include egg in peerDependencies and define `build`, `clean`, and `prepublishOnly` scripts in package.json
Applied to files:
tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/package.json : Egg.js version must be >= 4.1.0
Applied to files:
tsdown.config.ts
📚 Learning: 2025-12-21T03:05:13.313Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-12-21T03:05:13.313Z
Learning: Applies to tegg/**/__tests__/**/*.test.{ts,tsx} : Use `MockApplication` from `eggjs/mock` for testing with `mockModuleContextScope()` to create context scope
Applied to files:
plugins/mock/tsdown.config.ts
📚 Learning: 2025-12-21T03:04:53.982Z
Learnt from: CR
Repo: eggjs/egg PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T03:04:53.982Z
Learning: Applies to test/**/*.test.ts : Use standard assertions with Node.js built-in `assert` module in test files instead of external assertion libraries
Applied to files:
plugins/mock/tsdown.config.ts
🧬 Code graph analysis (2)
packages/tsconfig/tsdown.config.ts (1)
packages/egg/src/lib/define.ts (1)
defineConfig(29-31)
plugins/mock/tsdown.config.ts (1)
packages/egg/src/lib/define.ts (1)
defineConfig(29-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Test (macos-latest, 20, 3/3)
- GitHub Check: Test (macos-latest, 20, 1/3)
- GitHub Check: Test (ubuntu-latest, 22, 3/3)
- GitHub Check: Test (ubuntu-latest, 20, 1/3)
- GitHub Check: Test (ubuntu-latest, 24, 1/3)
- GitHub Check: Test (ubuntu-latest, 20, 3/3)
- GitHub Check: Test (windows-latest, 22, 3/3)
- GitHub Check: Test (windows-latest, 20, 2/3)
- GitHub Check: Test (macos-latest, 20, 2/3)
- GitHub Check: Test (windows-latest, 24, 3/3)
- GitHub Check: Test (ubuntu-latest, 22, 1/3)
- GitHub Check: Test (windows-latest, 20, 1/3)
- GitHub Check: Test (windows-latest, 24, 1/3)
- GitHub Check: Test (ubuntu-latest, 22, 2/3)
- GitHub Check: Test (macos-latest, 22, 3/3)
- GitHub Check: Test (ubuntu-latest, 20, 2/3)
- GitHub Check: Test bin (ubuntu-latest, 24, 1/3)
- GitHub Check: Test bin (windows-latest, 24, 1/3)
- GitHub Check: Test bin (ubuntu-latest, 24, 0/3)
- GitHub Check: Test bin (windows-latest, 24, 0/3)
- GitHub Check: Cloudflare Pages: egg-v3
🔇 Additional comments (7)
packages/egg/tsdown.config.ts (1)
4-9: Copy destination change looks good.Changing from 'dist/config/favicon.png' to 'dist/config' (directory) is correct and consistent with the broader pattern in this PR. The file will be copied with its original name preserved.
tools/create-egg/tsconfig.json (1)
3-3: LGTM! Excluding config files from TypeScript compilation.Adding "*.config.ts" to the exclude array is appropriate. Config files like tsdown.config.ts are for build tooling and don't need to be compiled or type-checked as part of the package's TypeScript compilation. The minimal config structure with extends correctly follows coding guidelines.
CLAUDE.md (1)
323-336: Documentation update aligns with PR changes.The documentation correctly reflects the pattern of changing copy destinations from file-level to directory-level targets. This matches the actual changes made across tsdown.config.ts files in this PR.
packages/tsconfig/tsdown.config.ts (1)
4-5: Empty entry array is appropriate for tsconfig package.Having
entry: []makes sense for the @eggjs/tsconfig package, which provides TypeScript configuration files rather than runtime JavaScript code. The comment clearly documents the intent.tools/create-egg/tsdown.config.ts (1)
6-11: The templates will be correctly placed indist/templates/regardless of this change.The code at line 206 in
src/index.tsreads:const templateDir = path.join(import.meta.dirname, `templates/${template}`);When built,
import.meta.dirnameresolves to thedist/directory, and tsdown's copy configuration without aflattenoption preserves directory structure—from: 'src/templates', to: 'dist'places templates atdist/templates/, which matches the code's expectations. This is functionally equivalent to the previous configuration.Likely an incorrect or invalid review comment.
tsdown.config.ts (2)
9-9: LGTM! Good addition to exclude dist directory.Excluding the 'dist' output directory from workspace processing prevents unnecessary processing of build artifacts and aligns with the project's centralized dist-based output strategy.
28-30: LGTM! Well-documented unbundle configuration.The
unbundle: truesetting is appropriately paired with theexternalarray, and the inline comment clearly explains the purpose of keeping @eggjs/* and egg packages unbundled. This configuration aligns with tsdown's unbundled ESM build approach.
| export default defineConfig({ | ||
| // export nothing | ||
| entry: [], | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Missing explicit type annotation for config export.
Based on coding guidelines, tsdown configuration files must use typed intermediate variables with explicit UserConfig type annotations.
🔎 Proposed refactor to add explicit type annotation
-import { defineConfig } from 'tsdown';
+import { defineConfig, type UserConfig } from 'tsdown';
+const config: UserConfig = defineConfig({
-export default defineConfig({
// export nothing
entry: [],
});
+export default config;Based on learnings, config files must use explicit UserConfig type annotations.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export default defineConfig({ | |
| // export nothing | |
| entry: [], | |
| }); | |
| import { defineConfig, type UserConfig } from 'tsdown'; | |
| const config: UserConfig = defineConfig({ | |
| // export nothing | |
| entry: [], | |
| }); | |
| export default config; |
🤖 Prompt for AI Agents
In packages/tsconfig/tsdown.config.ts around lines 3 to 6, the default export
uses an untyped object; per guidelines you must declare a typed intermediate
variable with the explicit UserConfig annotation. Fix by importing the
UserConfig type if needed, create a const (e.g. const config: UserConfig = {
entry: [] }); and then export that variable with export default config; ensure
the object shape matches UserConfig.
| export default defineConfig({ | ||
| external: ['mocha'], | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Missing explicit type annotation for config export.
Based on coding guidelines, tsdown configuration files must use typed intermediate variables with explicit UserConfig type annotations.
🔎 Proposed refactor to add explicit type annotation
-import { defineConfig } from 'tsdown';
+import { defineConfig, type UserConfig } from 'tsdown';
+const config: UserConfig = defineConfig({
-export default defineConfig({
external: ['mocha'],
});
+export default config;Based on learnings, config files must use explicit UserConfig type annotations.
🤖 Prompt for AI Agents
In plugins/mock/tsdown.config.ts around lines 3 to 5, the default export is
untyped; create a typed intermediate variable instead: import the UserConfig
type (e.g., add "import type { UserConfig } from 'tsdown';"), declare "const
config: UserConfig = { external: ['mocha'] }", and then export that variable
with "export default config;" so the config has an explicit UserConfig
annotation.
| import { defineConfig } from 'tsdown'; | ||
|
|
||
| export default defineConfig({ | ||
| external: ['mocha'], |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, let's check the structure of the mock plugin directory
find plugins/mock -type f -name "*.ts" -o -name "*.tsx" -o -name "*.json" | head -20Repository: eggjs/egg
Length of output: 765
🏁 Script executed:
#!/bin/bash
# Check for mocha imports/usage in the mock plugin
rg -n "import.*mocha|require.*mocha|from ['\"]mocha" plugins/mock/Repository: eggjs/egg
Length of output: 251
🏁 Script executed:
#!/bin/bash
# Check the tsdown.config.ts file in the mock plugin
cat plugins/mock/tsdown.config.tsRepository: eggjs/egg
Length of output: 149
🏁 Script executed:
#!/bin/bash
# Check the package.json of the mock plugin
cat plugins/mock/package.jsonRepository: eggjs/egg
Length of output: 4866
🏁 Script executed:
#!/bin/bash
cat plugins/mock/src/inject_mocha.tsRepository: eggjs/egg
Length of output: 970
Mocha must be declared as a peerDependency.
The mock plugin imports and uses mocha in src/inject_mocha.ts (line 32), which is exported as a public API (./inject_mocha). While marking mocha as external in tsdown.config.ts is correct, mocha is not declared in package.json dependencies, devDependencies, or peerDependencies. This will cause the library to fail for consumers who don't have mocha installed elsewhere. Add mocha to peerDependencies with an appropriate version constraint.
🤖 Prompt for AI Agents
In plugins/mock/tsdown.config.ts around line 4 and related files, Mocha is
marked external but not declared in package.json; add a peerDependencies entry
for mocha (e.g. "mocha": "^10") to package.json so consumers must provide it,
keep the existing external declaration in tsdown.config.ts, and update
package.json's version to a range compatible with your test/dev mocha (or match
the devDependency version if present) so the published package does not break
when consumers lack mocha.
| ts-node: ^10.9.2 | ||
| tsconfig-paths: ^4.2.0 | ||
| tsdown: ^0.18.0 | ||
| tsdown: ^0.18.2 |
There was a problem hiding this comment.
Incorrect tsdown version: 0.18.2 does not exist.
The latest version of tsdown is 0.18.1. Version 0.18.2 has not been released. Update the constraint to ^0.18.1 to reference the actual latest version.
🤖 Prompt for AI Agents
In pnpm-workspace.yaml around line 203, the tsdown dependency version is set to
^0.18.2 which does not exist; change the version constraint to ^0.18.1 so it
references the actual latest released version (update the line to use ^0.18.1).
| copy: [ | ||
| { | ||
| from: 'scripts', | ||
| to: 'dist/scripts', | ||
| to: 'dist', | ||
| }, | ||
| ], |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the actual tsdown.config.ts file
cat -n tools/egg-bin/tsdown.config.ts
echo "---"
# Look for script references
rg -n 'scripts' tools/egg-bin/ --type=ts --type=js --type=json -C2Repository: eggjs/egg
Length of output: 1604
🏁 Script executed:
#!/bin/bash
# Find getSourceFilename function definition
rg -n 'getSourceFilename|export.*getSourceFilename' tools/egg-bin/src --type=ts -B2 -A5Repository: eggjs/egg
Length of output: 1601
🏁 Script executed:
#!/bin/bash
# Find getSourceDirname function definition
rg -n 'getSourceDirname|export.*getSourceDirname' tools/egg-bin/src --type=ts -B2 -A10Repository: eggjs/egg
Length of output: 2767
🏁 Script executed:
#!/bin/bash
# Check what files are in the scripts directory
ls -la tools/egg-bin/scripts/
echo "---"
# Check package.json exports to see how scripts are expected to be packaged
cat -n tools/egg-bin/package.json | head -40Repository: eggjs/egg
Length of output: 1641
🏁 Script executed:
#!/bin/bash
# Let's verify the actual impact by tracing how the code works in both dev and dist modes
# First, let's see the current structure after build
echo "=== Checking if dist exists ==="
ls -la tools/egg-bin/dist/ 2>/dev/null | head -20 || echo "dist directory not found or empty"
echo "=== Checking git history for this file ==="
git log --oneline -n 5 -- tools/egg-bin/tsdown.config.ts 2>/dev/null || echo "No git history available"
echo "=== Checking if there are any other references to dist/scripts ==="
rg 'dist/scripts' tools/egg-bin/ --type=ts --type=jsRepository: eggjs/egg
Length of output: 209
🏁 Script executed:
#!/bin/bash
# Let's trace through the path resolution more carefully
# When running from dist/commands/dev.js, ../scripts/ would look for dist/scripts/
# Let's verify the actual structure by understanding the src layout
echo "=== Source structure ==="
find tools/egg-bin/src -type f -name "*.ts" | head -20
echo "=== Checking dev.ts relative path context ==="
cat -n tools/egg-bin/src/commands/dev.ts | grep -A2 -B2 "getSourceFilename"Repository: eggjs/egg
Length of output: 845
Update tsdown copy configuration to use 'dist/scripts' as the destination.
The copy configuration currently places script files directly in dist/ instead of dist/scripts/, breaking path resolution in the compiled code. The dev.ts command resolves scripts via getSourceFilename('../scripts/start-cluster.${ext}'), which produces dist/scripts/start-cluster.{cjs,mjs} when compiled. Change to: 'dist' to to: 'dist/scripts' to match this expected path structure and maintain functionality after publishing.
🤖 Prompt for AI Agents
In tools/egg-bin/tsdown.config.ts around lines 9 to 14, the tsdown copy
configuration currently copies the scripts directory into dist/ which causes
compiled script paths to be dist/scripts/* to mismatch; update the copy target
by changing the destination from 'dist' to 'dist/scripts' so files under
scripts/ are copied to dist/scripts/, ensuring
getSourceFilename('../scripts/start-cluster.${ext}') resolves correctly after
compilation.
There was a problem hiding this comment.
Pull request overview
This PR adds mocha to the external dependencies configuration for the mock plugin to prevent bundling, alongside upgrading tsdown to version 0.18.2 and adapting to its updated API.
Key changes:
- Added mocha to external configuration in plugins/mock to prevent bundling the mocha test framework
- Upgraded tsdown from ^0.18.0 to ^0.18.2 with corresponding dependency updates (hookable, import-without-cache)
- Simplified copy path configurations across multiple packages to use the updated tsdown 0.18.2 API
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/mock/tsdown.config.ts | New file - Adds mocha to external configuration to prevent bundling mocha when building the mock plugin |
| packages/tsconfig/tsdown.config.ts | New file - Adds empty entry configuration for config-only package (no source to build) |
| tsdown.config.ts | Removes commented code, reorganizes unbundle configuration with explanatory comment, adds 'dist' to workspace exclude list |
| tools/egg-bin/tsdown.config.ts | Simplifies copy destination path from 'dist/scripts' to 'dist' (tsdown 0.18.2 API update) |
| tools/create-egg/tsdown.config.ts | Simplifies copy destination path from 'dist/templates' to 'dist' (tsdown 0.18.2 API update) |
| packages/egg/tsdown.config.ts | Simplifies copy destination path from 'dist/config/favicon.png' to 'dist/config' (tsdown 0.18.2 API update) |
| tools/create-egg/tsconfig.json | Adds '*.config.ts' to exclude pattern to prevent TypeScript from processing config files |
| pnpm-workspace.yaml | Updates tsdown catalog version from ^0.18.0 to ^0.18.2, adds import-without-cache to minimumReleaseAgeExclude |
| pnpm-lock.yaml | Updates lockfile with new versions of tsdown (0.18.2), hookable (6.0.1), and import-without-cache (0.2.5) |
| CLAUDE.md | Updates documentation example to reflect simplified copy path syntax |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported

Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.