Skip to content

chore: add mocha to external#5746

Merged
fengmk2 merged 3 commits intonextfrom
fix-tsdown-unbundle
Dec 21, 2025
Merged

chore: add mocha to external#5746
fengmk2 merged 3 commits intonextfrom
fix-tsdown-unbundle

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 21, 2025

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated build configuration files across packages to refine output paths and bundling behavior.
    • Bumped tsdown dependency to version 0.18.2.
    • Added configuration exclusions to optimize the build compilation process.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 21, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

This 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

Cohort / File(s) Summary
New tsdown configuration files
packages/tsconfig/tsdown.config.ts, plugins/mock/tsdown.config.ts
Introduces two new tsdown config files. packages/tsconfig exports empty entry configuration; plugins/mock specifies mocha as external dependency.
Copy destination path updates
CLAUDE.md, packages/egg/tsdown.config.ts, tools/create-egg/tsdown.config.ts, tools/egg-bin/tsdown.config.ts
Standardizes copy operations to target directories instead of specific files. Changes: template copy target to dist/assets, favicon to dist/assets, templates to dist, and scripts to dist.
TypeScript compilation configuration
tools/create-egg/tsconfig.json
Adds *.config.ts glob pattern to exclude array, preventing TypeScript config files from compilation.
Workspace and root configuration
pnpm-workspace.yaml, tsdown.config.ts
Updates dependency catalog with tsdown ^0.18.2, adds import-without-cache to minimumReleaseAgeExclude, adds dist to workspace exclude list, removes skipNodeModulesBundle option, and reintroduces unbundle: true setting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that directory-level copy destinations don't cause unintended file structure changes
  • Confirm the tsdown version bump (^0.18.0 → ^0.18.2) is compatible with all configs
  • Ensure the unbundle reintroduction aligns with the dependency behavior

Possibly related PRs

Poem

🐰 Building configs, hop by hop,
Paths grow shorter, files move up,
Bundling rules and workspace care—
Organized code beyond compare! 📦✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'chore: add mocha to external' refers to only one minor change (adding mocha to external in plugins/mock/tsdown.config.ts), but the changeset includes numerous substantial modifications across multiple configuration files including tsdown configurations, tsconfig changes, and workspace configuration adjustments. Revise the title to reflect the main objective of the changes, such as 'chore: refactor tsdown configurations and workspace setup' or similar, to accurately represent the broader scope of modifications.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-tsdown-unbundle

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 tsdown's unbundle mode. It updates the tsdown dependency to its latest version and introduces more granular configuration files for specific sub-packages. The changes also simplify the root tsdown configuration by enabling automatic workspace inclusion and removing some redundant or experimental settings, aiming to improve the overall build stability and efficiency.

Highlights

  • tsdown Configuration for Sub-packages: New tsdown.config.ts files have been introduced for the packages/tsconfig and plugins/mock directories, providing specific build configurations for these modules. The tsconfig package is configured with an empty entry array, indicating it's a config-only package, while the mock plugin explicitly lists mocha as an external dependency.
  • Dependency Updates: The pnpm-lock.yaml and pnpm-workspace.yaml files have been updated to reflect an upgrade of the tsdown dependency from version 0.18.1 to 0.18.2. Additionally, hookable has been updated from 5.5.3 to 6.0.1, and import-without-cache from 0.2.4 to 0.2.5.
  • Root tsdown Configuration Refinement: The main tsdown.config.ts file has been adjusted to utilize workspace.include: 'auto' for automatic detection of workspace packages. Several previously explicit or commented-out configurations, such as workspace.exclude for packages/tsconfig, skipNodeModulesBundle, and the general external array, have been commented out or removed, streamlining the build process.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 21, 2025

Deploying egg with  Cloudflare Pages  Cloudflare Pages

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

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 21, 2025

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Comment on lines 6 to 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block contains several pieces of commented-out configuration.

  • The FIXME on line 7 is now slightly misplaced relative to the include: 'auto' on line 8.
  • The exclude on lines 9-11 is now handled by the new packages/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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This external option is now commented out, and skipNodeModulesBundle has been removed. This is likely correct since unbundle: true is set globally. If this is confirmed to work, please remove this commented-out line to keep the configuration clean.

@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.61%. Comparing base (a0cd3bb) to head (8a000ee).
⚠️ Report is 1 commits behind head on next.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fengmk2 fengmk2 changed the title chore: try to fix tsdown unbundle mode chore: add mocha to external Dec 21, 2025
@fengmk2 fengmk2 marked this pull request as ready for review December 21, 2025 13:44
Copilot AI review requested due to automatic review settings December 21, 2025 13:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a0cd3bb and 8a000ee.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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.ts
  • packages/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.ts
  • packages/tsconfig/tsdown.config.ts
**/*.{ts,tsx,js,mjs}

📄 CodeRabbit inference engine (AGENTS.md)

Use .ts sources over CommonJS and prefer ESM for exports

Files:

  • packages/egg/tsdown.config.ts
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tsdown.config.ts
  • plugins/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.ts
  • packages/tsconfig/tsdown.config.ts
  • plugins/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 --isolatedDeclarations flag
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 use unique symbol type
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
Avoid any type; use unknown when type is truly unknown

Files:

  • packages/egg/tsdown.config.ts
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tsdown.config.ts
  • plugins/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 extends pattern

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.ts
  • pnpm-workspace.yaml
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • 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 packages/*/tsconfig.json : Create minimal tsconfig.json files in sub-packages containing only `{"extends": "../../tsconfig.json"}`

Applied to files:

  • packages/egg/tsdown.config.ts
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • 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 {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.ts
  • pnpm-workspace.yaml
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tsdown.config.ts
  • 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: 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.ts
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tsdown.config.ts
  • plugins/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.yaml
  • 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 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.yaml
  • 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 : Centralize all shared dependency versions in the root `pnpm-workspace.yaml` rather than in individual tegg package files

Applied to files:

  • pnpm-workspace.yaml
  • 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 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.yaml
  • 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: 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.yaml
  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • 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: All packages must include TypeScript type checking with `tsc --noEmit` in the `typecheck` script

Applied to files:

  • pnpm-workspace.yaml
  • packages/tsconfig/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • 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: 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.yaml
  • tools/create-egg/tsconfig.json
  • 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/**/*.ts : Use TypeScript throughout all packages in the Eggjs monorepo

Applied to files:

  • pnpm-workspace.yaml
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • 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/**/*.ts : Use strict TypeScript mode in all packages

Applied to files:

  • pnpm-workspace.yaml
  • 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 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.ts
  • tools/create-egg/tsconfig.json
  • 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/core/*/tsconfig.json : Each new core package should include `tsconfig.json` extending `eggjs/tsconfig`

Applied to files:

  • packages/tsconfig/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • tools/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.ts
  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • 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 **/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.ts
  • tools/create-egg/tsconfig.json
  • 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 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.ts
  • tools/create-egg/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • 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: Applies to **/*.{ts,tsx,js,mjs} : Use `.ts` sources over CommonJS and prefer ESM for exports

Applied to files:

  • tools/egg-bin/tsdown.config.ts
  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • 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 **/*.{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.json
  • plugins/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.json
  • plugins/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.json
  • 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/**/vitest.config.ts : Configure test discovery through monorepo root `vitest.config.ts` which includes all tegg packages

Applied to files:

  • tools/create-egg/tsconfig.json
  • tsdown.config.ts
  • plugins/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.ts
  • 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 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 in dist/templates/ regardless of this change.

The code at line 206 in src/index.ts reads:

const templateDir = path.join(import.meta.dirname, `templates/${template}`);

When built, import.meta.dirname resolves to the dist/ directory, and tsdown's copy configuration without a flatten option preserves directory structure—from: 'src/templates', to: 'dist' places templates at dist/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: true setting is appropriately paired with the external array, 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.

Comment on lines +3 to +6
export default defineConfig({
// export nothing
entry: [],
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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.

Suggested change
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.

Comment on lines +3 to +5
export default defineConfig({
external: ['mocha'],
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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 -20

Repository: 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.ts

Repository: eggjs/egg

Length of output: 149


🏁 Script executed:

#!/bin/bash
# Check the package.json of the mock plugin
cat plugins/mock/package.json

Repository: eggjs/egg

Length of output: 4866


🏁 Script executed:

#!/bin/bash
cat plugins/mock/src/inject_mocha.ts

Repository: 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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).

Comment on lines 9 to 14
copy: [
{
from: 'scripts',
to: 'dist/scripts',
to: 'dist',
},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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 -C2

Repository: 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 -A5

Repository: 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 -A10

Repository: 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 -40

Repository: 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=js

Repository: 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@fengmk2 fengmk2 merged commit caa505a into next Dec 21, 2025
54 of 57 checks passed
@fengmk2 fengmk2 deleted the fix-tsdown-unbundle branch December 21, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments