fix: tsdown unbundle will cause types missing#5581
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a critical TypeScript type generation issue by disabling the unbundle option in tsdown configurations across the Eggjs monorepo. According to the referenced documentation, tsdown's unbundle feature causes missing types in the build output, affecting TypeScript consumers of these packages.
- Commented out
unbundle: trueacross all tsdown configuration files - Added explanatory comment in the main egg package referencing the issue
- Updated documentation example to reflect the change
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/egg/tsdown.config.ts | Main framework package with detailed FIXME comment explaining the issue |
| packages/*/tsdown.config.ts | All other package configs with unbundle commented out |
| plugins/*/tsdown.config.ts | All plugin configs with unbundle commented out |
| tools/*/tsdown.config.ts | Tool configs with unbundle commented out |
| examples/helloworld-typescript/tsdown.config.ts | Example app config updated |
| CLAUDE.md | Documentation example updated to match new pattern |
|
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. WalkthroughRepository-wide change: the tsdown config property Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant TD as tsdown
participant Bundler as Bundler/Resolver
participant Out as Build Output
Dev->>TD: Run build using configs (unbundle commented out)
TD->>Bundler: Resolve entries (default bundling path)
alt unbundle unspecified / disabled
Bundler->>Out: Emit bundled outputs (default)
Note right of Out: dts, exports, unused unchanged
else explicit unbundle (prior state)
Bundler->>Out: Emit unbundled outputs
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ 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). (17)
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 implements a crucial fix for a known problem within the Highlights
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
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where using unbundle: true with tsdown causes missing type definitions in the build output. The fix involves commenting out this option in all tsdown.config.ts files across the monorepo. This is a good workaround for the upstream bug. My review includes suggestions to add explanatory comments to all modified files for consistency and better maintainability, making it clear why this option is disabled.
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
In this documentation example, it would be beneficial to explain why unbundle: true is commented out. This will prevent users from copying the configuration and encountering the type generation issue. Adding a comment with a link to the issue would provide valuable context, consistent with the change in packages/egg/tsdown.config.ts.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| export default defineConfig({ | ||
| entry: ['app.ts', 'config/**/*.ts', 'app/**/*.ts'], | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| app_worker: 'src/app_worker.ts', | ||
| }, | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| index: 'src/index.ts', | ||
| }, | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| index: 'src/index.ts', | ||
| }, | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
| export default defineConfig({ | ||
| entry: ['src/index.ts', 'src/cli.ts'], | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
tools/egg-bin/tsdown.config.ts
Outdated
There was a problem hiding this comment.
For consistency and future maintainability, please add a comment explaining why unbundle is disabled, similar to the change in packages/egg/tsdown.config.ts. This helps other developers understand the reason for this temporary workaround and when it might be safe to re-enable.
| // unbundle: true, | |
| // FIXME: unbundle will cause types missing https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types | |
| // unbundle: true, |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #5581 +/- ##
=======================================
Coverage 81.06% 81.06%
=======================================
Files 209 209
Lines 5989 5989
Branches 875 876 +1
=======================================
Hits 4855 4855
Misses 1060 1060
Partials 74 74 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (9)
plugins/view/tsdown.config.ts (1)
5-5: Same configuration conflict as other plugins.This plugin exhibits the same conflict with the mandatory plugin configuration standard. See the review comment on
plugins/logrotator/tsdown.config.tsfor details.plugins/jsonp/tsdown.config.ts (1)
5-5: Same configuration conflict as other plugins.This plugin exhibits the same conflict with the mandatory plugin configuration standard. See the review comment on
plugins/logrotator/tsdown.config.tsfor details.plugins/mock/tsdown.config.ts (1)
10-10: Same configuration conflict as other plugins.This plugin exhibits the same conflict with the mandatory plugin configuration standard. See the review comment on
plugins/logrotator/tsdown.config.tsfor details.plugins/tracer/tsdown.config.ts (1)
5-5: Same configuration conflict as other plugins.This plugin exhibits the same conflict with the mandatory plugin configuration standard. See the review comment on
plugins/logrotator/tsdown.config.tsfor details.packages/cookies/tsdown.config.ts (1)
7-7: Same conflict with coding guidelines as other packages.This change has the same issues identified in packages/supertest/tsdown.config.ts regarding conflicts with the established coding guidelines for unbundled ESM builds.
Based on learnings.
plugins/session/tsdown.config.ts (1)
5-5: Same critical conflict with mandatory plugin guidelines.This change has the same critical issue identified in plugins/i18n/tsdown.config.ts regarding the mandatory requirement for plugins to use
unbundle: true.Based on learnings.
plugins/security/tsdown.config.ts (1)
5-5: Same critical conflict with mandatory plugin guidelines.This change has the same critical issue identified in plugins/i18n/tsdown.config.ts regarding the mandatory requirement for plugins to use
unbundle: true.Based on learnings.
plugins/static/tsdown.config.ts (1)
5-5: Same critical conflict with mandatory plugin guidelines.This change has the same critical issue identified in plugins/i18n/tsdown.config.ts regarding the mandatory requirement for plugins to use
unbundle: true.Based on learnings.
packages/utils/tsdown.config.ts (1)
7-7: Same conflict with coding guidelines as other packages.This change has the same issues identified in packages/supertest/tsdown.config.ts regarding conflicts with the established coding guidelines for unbundled ESM builds.
Based on learnings.
🧹 Nitpick comments (7)
plugins/onerror/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
plugins/multipart/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
plugins/watcher/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
packages/extend2/tsdown.config.ts (1)
7-7: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "Each package should be configured with tsdown for unbundled ESM builds", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
plugins/development/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
examples/helloworld-typescript/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change is necessary to fix the critical issue where unbundle causes TypeScript types to be missing.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,tools/create-egg/tsdown.config.ts (1)
5-5: Approve disabling unbundle to fix missing types.This change conflicts with the retrieved learning stating "Each package should be configured with tsdown for unbundled ESM builds", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
For consistency with
packages/egg/tsdown.config.ts, consider adding a FIXME comment with the issue link:- // unbundle: true, + // FIXME: unbundle will missing types https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types + // unbundle: true,Based on learnings
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
CLAUDE.md(1 hunks)examples/helloworld-typescript/tsdown.config.ts(1 hunks)packages/cluster/tsdown.config.ts(1 hunks)packages/cookies/tsdown.config.ts(1 hunks)packages/core/tsdown.config.ts(1 hunks)packages/egg/tsdown.config.ts(1 hunks)packages/extend2/tsdown.config.ts(1 hunks)packages/koa-static-cache/tsdown.config.ts(1 hunks)packages/koa/tsdown.config.ts(1 hunks)packages/router/tsdown.config.ts(1 hunks)packages/supertest/tsdown.config.ts(1 hunks)packages/utils/tsdown.config.ts(1 hunks)plugins/development/tsdown.config.ts(1 hunks)plugins/i18n/tsdown.config.ts(1 hunks)plugins/jsonp/tsdown.config.ts(1 hunks)plugins/logrotator/tsdown.config.ts(1 hunks)plugins/mock/tsdown.config.ts(1 hunks)plugins/multipart/tsdown.config.ts(1 hunks)plugins/onerror/tsdown.config.ts(1 hunks)plugins/schedule/tsdown.config.ts(1 hunks)plugins/security/tsdown.config.ts(1 hunks)plugins/session/tsdown.config.ts(1 hunks)plugins/static/tsdown.config.ts(1 hunks)plugins/tracer/tsdown.config.ts(1 hunks)plugins/view/tsdown.config.ts(1 hunks)plugins/watcher/tsdown.config.ts(1 hunks)tools/create-egg/tsdown.config.ts(1 hunks)tools/egg-bin/tsdown.config.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
packages/*/tsdown.config.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Each package must provide a tsdown.config.ts for unbundled ESM builds
Files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tspackages/koa-static-cache/tsdown.config.tspackages/cookies/tsdown.config.tspackages/egg/tsdown.config.tspackages/router/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tspackages/core/tsdown.config.tspackages/koa/tsdown.config.ts
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Prefer TypeScript and ESM: write sources and exports in .ts (ESM-first) rather than CommonJS
Use two-space indentation, trailing commas, and semicolons (Prettier/oxlint defaults)
Name files in lowercase with hyphens (e.g., loader-context.ts)
Name classes in PascalCase
Name functions and variables in camelCase
Re-export types thoughtfully to keep the public API stable
Files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tsplugins/security/tsdown.config.tspackages/koa-static-cache/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tstools/egg-bin/tsdown.config.tsexamples/helloworld-typescript/tsdown.config.tspackages/cookies/tsdown.config.tspackages/egg/tsdown.config.tsplugins/mock/tsdown.config.tsplugins/session/tsdown.config.tspackages/router/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tstools/create-egg/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tsplugins/logrotator/tsdown.config.tspackages/core/tsdown.config.tsplugins/tracer/tsdown.config.tspackages/koa/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
{packages,plugins,tools}/**/tsdown.config.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Each package should be configured with tsdown for unbundled ESM builds (have a tsdown.config.ts)
Files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tsplugins/security/tsdown.config.tspackages/koa-static-cache/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tstools/egg-bin/tsdown.config.tspackages/cookies/tsdown.config.tspackages/egg/tsdown.config.tsplugins/mock/tsdown.config.tsplugins/session/tsdown.config.tspackages/router/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tstools/create-egg/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tsplugins/logrotator/tsdown.config.tspackages/core/tsdown.config.tsplugins/tracer/tsdown.config.tspackages/koa/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
plugins/**/tsdown.config.ts
📄 CodeRabbit inference engine (CLAUDE.md)
All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Files:
plugins/security/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tsplugins/mock/tsdown.config.tsplugins/session/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tsplugins/logrotator/tsdown.config.tsplugins/tracer/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
plugins/**
📄 CodeRabbit inference engine (CLAUDE.md)
All Egg framework plugins must be located under the plugins/ directory and follow the standard plugin structure (src, test, package.json, tsdown.config.ts)
Files:
plugins/security/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tsplugins/mock/tsdown.config.tsplugins/session/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tsplugins/logrotator/tsdown.config.tsplugins/tracer/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.941Z
Learning: Applies to plugins/**/tsdown.config.ts : All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.941Z
Learning: Applies to {packages,plugins,tools}/**/tsdown.config.ts : Each package should be configured with tsdown for unbundled ESM builds (have a tsdown.config.ts)
📚 Learning: 2025-09-28T08:01:03.941Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.941Z
Learning: Applies to plugins/**/tsdown.config.ts : All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)
Applied to files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tsplugins/security/tsdown.config.tspackages/koa-static-cache/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tstools/egg-bin/tsdown.config.tsexamples/helloworld-typescript/tsdown.config.tsCLAUDE.mdpackages/cookies/tsdown.config.tspackages/egg/tsdown.config.tsplugins/mock/tsdown.config.tsplugins/session/tsdown.config.tspackages/router/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tstools/create-egg/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tsplugins/logrotator/tsdown.config.tspackages/core/tsdown.config.tsplugins/tracer/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
📚 Learning: 2025-09-28T08:01:03.941Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-28T08:01:03.941Z
Learning: Applies to {packages,plugins,tools}/**/tsdown.config.ts : Each package should be configured with tsdown for unbundled ESM builds (have a tsdown.config.ts)
Applied to files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tsplugins/security/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tstools/egg-bin/tsdown.config.tsexamples/helloworld-typescript/tsdown.config.tsCLAUDE.mdpackages/cookies/tsdown.config.tspackages/egg/tsdown.config.tsplugins/session/tsdown.config.tspackages/router/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tstools/create-egg/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tsplugins/logrotator/tsdown.config.tspackages/core/tsdown.config.tsplugins/tracer/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
📚 Learning: 2025-09-14T08:41:30.618Z
Learnt from: CR
PR: eggjs/egg#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T08:41:30.618Z
Learning: Applies to packages/*/tsdown.config.ts : Each package must provide a tsdown.config.ts for unbundled ESM builds
Applied to files:
packages/supertest/tsdown.config.tspackages/cluster/tsdown.config.tsplugins/security/tsdown.config.tspackages/koa-static-cache/tsdown.config.tsplugins/schedule/tsdown.config.tsplugins/view/tsdown.config.tstools/egg-bin/tsdown.config.tsexamples/helloworld-typescript/tsdown.config.tsCLAUDE.mdpackages/egg/tsdown.config.tsplugins/session/tsdown.config.tspackages/router/tsdown.config.tsplugins/watcher/tsdown.config.tsplugins/jsonp/tsdown.config.tsplugins/onerror/tsdown.config.tsplugins/i18n/tsdown.config.tstools/create-egg/tsdown.config.tspackages/utils/tsdown.config.tspackages/extend2/tsdown.config.tsplugins/logrotator/tsdown.config.tspackages/core/tsdown.config.tsplugins/tracer/tsdown.config.tsplugins/static/tsdown.config.tsplugins/development/tsdown.config.tsplugins/multipart/tsdown.config.ts
⏰ 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). (13)
- GitHub Check: Test (windows-latest, 22, plugins)
- GitHub Check: Test (macos-latest, 24, packages)
- GitHub Check: Test (ubuntu-latest, 22, plugins)
- GitHub Check: Test (ubuntu-latest, 22, packages)
- GitHub Check: Test (windows-latest, 24, packages)
- GitHub Check: Test (macos-latest, 24, plugins)
- GitHub Check: Test (ubuntu-latest, 24, packages)
- GitHub Check: Test (windows-latest, 24, plugins)
- GitHub Check: Test (macos-latest, 22, plugins)
- GitHub Check: Test (windows-latest, 22, packages)
- GitHub Check: Test (ubuntu-latest, 24, plugins)
- GitHub Check: Test (macos-latest, 22, packages)
- GitHub Check: typecheck
🔇 Additional comments (9)
plugins/schedule/tsdown.config.ts (1)
5-5: Reconcile with the plugin tsdown template before merging.Previous guidance for plugins (see long-term learning on the standard tsdown template) required
unbundle: trueto keep the unbundled ESM layout stable. Commenting this property out changes that contract; if unbundled outputs are expected by downstream consumers or the shared template, this could introduce regressions. Please either restoreunbundle: truewith an alternative fix for the DTS issue, or document and validate (e.g., by publishing a pre-release) that the new bundled output does not break consumers, then update the shared template accordingly.Based on learnings
packages/router/tsdown.config.ts (1)
5-5: Manual verification required: confirm.d.tsoutput and update guidelines.The sandbox couldn’t build the package or fetch the external tsdown docs, so please:
- Build
packages/routerlocally and verify that commenting outunbundle: trueproduces the expected.d.tsfiles underdist/.- Confirm how disabling
unbundleaffects module resolution for consumers.- If this change is valid, update our coding guidelines to reflect tsdown’s type-output behavior.
packages/koa/tsdown.config.ts (1)
7-7: Unbundle disabled here conflicts with guidelines
- Types still emit as a single
dist/index.d.ts, but disablingunbundlebreaks unbundled ESM and per-file type outputs.- Confirm that a bundled index.d.ts meets downstream needs.
- Document the reason for disabling
unbundle(link tsdown issue) and plan to re-enable when fixed, or update guidelines to reflect this change.packages/cluster/tsdown.config.ts (1)
9-9: Verify cluster package build and update documentation
- Install dependencies and run
npm run buildinpackages/cluster; confirm.d.tsfiles forindex,agent_worker, andapp_workerappear indist/.- Add an explanatory
// FIXME: unbundle disabled due to missing typescomment above// unbundle: true,.- Update the project’s tsdown configuration learnings to note disabling
unbundleuntil the types issue is resolved.packages/egg/tsdown.config.ts (1)
6-7: LGTM! Excellent documentation of the issue.The FIXME comment with the issue link clearly documents why unbundle is disabled. This change conflicts with the retrieved learning stating "Each package should be configured with tsdown for unbundled ESM builds", but it's necessary to fix the critical issue where unbundle causes TypeScript types to be missing. The learnings should be updated to reflect this new understanding.
This is the best approach among all the files in this PR—the explanatory comment helps future maintainers understand the reasoning.
Based on learnings
CLAUDE.md (1)
294-296: Good addition of unused code detection.Adding
unused: { level: 'error' }to the standard template is a beneficial improvement that will help catch dead code early in development.tools/egg-bin/tsdown.config.ts (1)
7-7: Install dependencies and verify type output
Install node modules in tools/egg-bin, rebuild and confirm .d.ts files:cd tools/egg-bin pnpm install --frozen-lockfile pnpm run build fd -e d.ts . dist/ cat dist/index.d.tsEnsure disabling
unbundleindeed fixes missing types before updating coding guidelines.packages/koa-static-cache/tsdown.config.ts (1)
5-5: Use tsdown’s DTS options instead of disablingunbundle
Tsdown’sunbundle: truecan prevent correct.d.tsoutput (handled by rolldown-plugin-dts). To fix this while keeping unbundle enabled, enableisolatedDeclarationsin your tsconfig and inpackages/koa-static-cache/tsdown.config.tsadd underdts:{ newContext: true, resolve: true }If you need a single merged declaration, leave
unbundle: falseinstead.⛔ Skipped due to learnings
Learnt from: CR PR: eggjs/egg#0 File: CLAUDE.md:0-0 Timestamp: 2025-09-28T08:01:03.941Z Learning: Applies to {packages,plugins,tools}/**/tsdown.config.ts : Each package should be configured with tsdown for unbundled ESM builds (have a tsdown.config.ts)Learnt from: CR PR: eggjs/egg#0 File: CLAUDE.md:0-0 Timestamp: 2025-09-28T08:01:03.941Z Learning: Applies to plugins/**/tsdown.config.ts : All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)Learnt from: CR PR: eggjs/egg#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-09-14T08:41:30.618Z Learning: Applies to packages/*/tsdown.config.ts : Each package must provide a tsdown.config.ts for unbundled ESM buildspackages/supertest/tsdown.config.ts (1)
7-7: Unbundle is disabled despite guideline requiring it
The tsdown config guideline requiresunbundle: true, but it’s commented out here (as in all other packages). If disabling unbundle is necessary due to missing types, update the guideline; otherwise re-enableunbundle: true. Consider removing the commented line entirely.
| // unbundle: true, | ||
| unused: { | ||
| level: 'error', | ||
| }, |
There was a problem hiding this comment.
Documentation inconsistency between template and explanation.
The template code now shows unbundle commented out (line 293), but line 307 in the explanation section still states: "unbundle: true - Creates unbundled output (preserves file structure)". This creates conflicting guidance.
Apply this diff to align the documentation with the template:
This configuration ensures:
- **`entry: 'src/**/\*.ts'`\*\* - Processes all TypeScript files in src directory
-- **`unbundle: true`** - Creates unbundled output (preserves file structure)
+- **`unbundle: true` (currently disabled)** - Creates unbundled output; disabled due to types generation issue (see PR #5581)
- **`dts: true`** - Generates TypeScript declaration files
- **`exports.devExports: true`** - Enables development-friendly exportsAdditionally, consider adding a note explaining why unbundle is now commented out in the standard template.
📝 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.
| // unbundle: true, | |
| unused: { | |
| level: 'error', | |
| }, | |
| This configuration ensures: | |
| - **`entry: 'src/**/*.ts'`** - Processes all TypeScript files in src directory | |
| - **`unbundle: true` (currently disabled)** - Creates unbundled output; disabled due to types generation issue (see PR #5581) | |
| - **`dts: true`** - Generates TypeScript declaration files | |
| - **`exports.devExports: true`** - Enables development-friendly exports |
🤖 Prompt for AI Agents
In CLAUDE.md around lines 293–296 (template) and line ~307 (explanation), the
template shows `unbundle` commented out while the explanation still describes
`unbundle: true`, causing a docs mismatch; update the explanation to match the
template by either removing the statement that `unbundle: true` is enabled or
changing it to indicate that `unbundle` is commented out by default, and add a
short note explaining why the standard template leaves `unbundle` commented out
(e.g., to prefer bundled output for smaller distribution, compatibility, or to
avoid file-structure-sensitive build issues), so the template and rationale are
consistent.
| index: 'src/index.ts', | ||
| }, | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
Guideline conflict in critical core package.
The core package is a critical component, and this change deviates from the established guideline for unbundled ESM builds. Given the package's importance, ensure this change is thoroughly tested and documented, especially regarding its impact on type definitions for downstream consumers.
Based on learnings.
| export default defineConfig({ | ||
| entry: ['src/index.ts'], | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
❓ Verification inconclusive
Package configuration conflicts with established standard.
This change conflicts with the coding guideline: "Each package must provide a tsdown.config.ts for unbundled ESM builds". While the file exists, disabling unbundle contradicts the "unbundled ESM builds" requirement.
See the review comment on plugins/logrotator/tsdown.config.ts for the broader context and verification needed. As per coding guidelines
Re-enable unbundle: true in tsdown.config.ts
Commenting out unbundle: true conflicts with the required unbundled ESM build configuration.
packages/koa-static-cache/tsdown.config.ts: uncomment unbundle: true
🤖 Prompt for AI Agents
In packages/koa-static-cache/tsdown.config.ts around line 5 the unbundle setting
was commented out; uncomment the line so that unbundle: true is enabled to
restore the required unbundled ESM build configuration, ensuring the config
exports the unbundle option as true.
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Critical conflict with coding guidelines.
This change directly contradicts the established coding guideline: "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)". Disabling unbundle across all plugins represents a significant deviation from the mandatory standard.
While the PR aims to fix types being missing with tsdown unbundle, please verify:
- Is this intended as a permanent fix or a temporary workaround?
- Should the coding guidelines be updated to reflect this new approach?
- Why is the line commented out rather than removed entirely?
Based on learnings.
🌐 Web query:
Does tsdown's unbundle option cause TypeScript declaration files (.d.ts) to be missing or incomplete? What is the recommended configuration to ensure type definitions are properly generated?
💡 Result:
Short answer: No — unbundle itself does not inherently remove or break .d.ts generation. tsdown's unbundle mode simply emits a one-to-one output file tree (transpile-only style); declaration generation is controlled by the dts option and your TypeScript config. (tsdown.dev)
Recommended configuration to ensure complete typings
- Enable d.ts generation: set dts: true (or ensure package.json has a types/typings field). (tsdown.dev)
- Keep/unbundle as you want: unbundle: true is fine (it will emit per-source output files). (tsdown.dev)
- Install typescript in the project (required). (tsdown.dev)
- Prefer enabling isolatedDeclarations in tsconfig for reliable/fast declaration generation (tsdown will use oxc-transform when present). Example tsconfig snippet:
- compilerOptions.isolatedDeclarations: true. (tsdown.dev)
- If your types depend on external packages and you want them bundled into your .d.ts, use dts.resolve (or adjust external/noExternal settings) so dependency types are included. (tsdown.dev)
Minimal example (tsdown.config.ts + tsconfig.json)
- tsdown.config.ts: { entry: 'src/index.ts', unbundle: true, dts: true }.
- tsconfig.json: { "compilerOptions": { "declaration": true, "isolatedDeclarations": true } }.
(Also ensure package.json has "types" or set dts explicitly.) (tsdown.dev)
If you still see missing/incomplete .d.ts files, check:
- that dts is enabled, typescript is installed, and your tsconfig has declaration settings;
- whether some dependencies were marked external (and need dts.resolve); and
- that you’re running the dts-enabled build (CJS may run a separate .d.ts build). (tsdown.dev)
Citations:
- 1: https://tsdown.dev/options/unbundle?utm_source=openai
- 2: https://tsdown.dev/guide/dts?utm_source=openai
- 3: https://tsdown.dev/options/unbundle?utm_source=openai
- 4: https://tsdown.dev/options/dts?utm_source=openai
- 5: https://tsdown.dev/options/dts?utm_source=openai
- 6: https://tsdown.dev/options/dependencies?utm_source=openai
- 7: https://tsdown.dev/options/config-file?utm_source=openai
- 8: https://tsdown.dev/options/dts?utm_source=openai
🏁 Script executed:
#!/bin/bash
rg -nP "dts\s*:" plugins/i18n/tsdown.config.ts -nLength of output: 14
🏁 Script executed:
#!/bin/bash
rg -nP "entry\s*:" -n plugins/i18n/tsdown.config.ts
rg -nP "exports\.devExports" -n plugins/i18n/tsdown.config.tsLength of output: 25
Restore mandatory tsdown configuration in plugins/i18n/tsdown.config.ts
- Re-enable
unbundle: true - Add
exports.devExports: true
🤖 Prompt for AI Agents
In plugins/i18n/tsdown.config.ts around line 5, the tsdown config was commented
out; restore the mandatory options by uncommenting or setting unbundle: true
inside the exported config object and also add exports.devExports = true (or add
devExports: true to the exported config depending on module shape). Ensure these
settings are exported from the module so the build uses unbundle: true and
devExports is enabled.
| export default defineConfig({ | ||
| entry: 'src/**/*.ts', | ||
| unbundle: true, | ||
| // unbundle: true, |
There was a problem hiding this comment.
🧩 Analysis chain
Critical conflict with plugin configuration standard.
This change violates the mandatory plugin configuration standard which explicitly states: "All future plugins MUST use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)".
If unbundle: true causes types to be missing (as stated in the PR description), then either:
- The tsdown tool has a defect that needs to be reported/fixed upstream
- The configuration standard needs to be revised and documented
Please clarify the long-term strategy. As per coding guidelines
🏁 Script executed:
#!/bin/bash
# Display the tsdown config for logrotator plugin
sed -n '1,50p' plugins/logrotator/tsdown.config.tsLength of output: 208
Enable unbundle: true in tsdown.config.ts (plugins/logrotator/tsdown.config.ts:4). Plugin configs must match the standard template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true).
🤖 Prompt for AI Agents
In plugins/logrotator/tsdown.config.ts around line 5, the config comment
currently has unbundle commented out; update the tsdown.config to match the
standard template by enabling unbundle: true (remove the comment and set it to
true) and ensure the config includes entry: 'src/**/*.ts', dts: true, and
exports: { devExports: true } so the plugin config matches the required
template.

https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores