Skip to content

fix: tsdown unbundle will cause types missing#5581

Merged
fengmk2 merged 3 commits intonextfrom
disable-unbundle
Oct 4, 2025
Merged

fix: tsdown unbundle will cause types missing#5581
fengmk2 merged 3 commits intonextfrom
disable-unbundle

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Oct 4, 2025

https://github.com/fengmk2/tsdown-vs-tsc/blob/main/README.md#tsdown-build-output-missing-types

Summary by CodeRabbit

  • New Features

    • None
  • Bug Fixes

    • None
  • Documentation

    • Updated build/config notes to reflect current defaults and linting expectations.
  • Chores

    • Disabled unbundled build output across examples, packages, plugins, and tooling to align with defaults.
    • Enabled stricter unused-variable reporting to improve code quality.
    • No changes to public APIs or runtime behavior expected.

@fengmk2 fengmk2 requested a review from Copilot October 4, 2025 15:43
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 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: true across 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 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

Repository-wide change: the tsdown config property unbundle: true was commented out across examples, packages, plugins, and tools. A docs snippet (CLAUDE.md) now shows unused: { level: 'error' }. No public API signatures or other tsdown options (dts, exports) were altered.

Changes

Cohort / File(s) Summary
Docs snippet
CLAUDE.md
Commented out unbundle: true in tsdown snippet; added unused: { level: 'error' }.
Example config
examples/helloworld-typescript/tsdown.config.ts
Commented out unbundle: true; other fields unchanged.
Packages tsdown configs
packages/*/tsdown.config.ts
packages/cluster/tsdown.config.ts, packages/cookies/tsdown.config.ts, packages/core/tsdown.config.ts, packages/egg/tsdown.config.ts, packages/extend2/tsdown.config.ts, packages/koa-static-cache/tsdown.config.ts, packages/koa/tsdown.config.ts, packages/router/tsdown.config.ts, packages/supertest/tsdown.config.ts, packages/utils/tsdown.config.ts
Commented out unbundle: true in each listed config; other options (dts, exports, unused) unchanged.
Plugins tsdown configs
plugins/*/tsdown.config.ts
plugins/development/tsdown.config.ts, plugins/i18n/tsdown.config.ts, plugins/jsonp/tsdown.config.ts, plugins/logrotator/tsdown.config.ts, plugins/mock/tsdown.config.ts, plugins/multipart/tsdown.config.ts, plugins/onerror/tsdown.config.ts, plugins/schedule/tsdown.config.ts, plugins/security/tsdown.config.ts, plugins/session/tsdown.config.ts, plugins/static/tsdown.config.ts, plugins/tracer/tsdown.config.ts, plugins/view/tsdown.config.ts, plugins/watcher/tsdown.config.ts
Commented out unbundle: true across all listed plugin configs; other options unchanged.
Tools tsdown configs
tools/*/tsdown.config.ts
tools/create-egg/tsdown.config.ts, tools/egg-bin/tsdown.config.ts
Commented out unbundle: true (added a MEMO comment in egg-bin); other config fields unchanged.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I nibble lines with fluffy care,
Unbundle sleeps, now commented there.
DTS and exports hum along,
Unused now sings a stricter song.
Thump-thump — carrot-built and fair. 🥕🫧

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that the pull request fixes the issue where tsdown unbundle causes missing types, which matches the change disabling unbundle flags across multiple tsdown configurations. It is specific and on-topic, so a reviewer scanning history will understand the primary purpose. The conventional commit prefix “fix:” further clarifies the nature of the change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 disable-unbundle

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80c6705 and d8dc744.

📒 Files selected for processing (1)
  • tools/egg-bin/tsdown.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tools/egg-bin/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). (17)
  • GitHub Check: Test (macos-latest, 24, tools)
  • GitHub Check: Test (windows-latest, 24, packages)
  • GitHub Check: Test (ubuntu-latest, 24, packages)
  • GitHub Check: Test (ubuntu-latest, 22, plugins)
  • GitHub Check: Test (windows-latest, 24, plugins)
  • GitHub Check: Test (macos-latest, 24, packages)
  • GitHub Check: Test (ubuntu-latest, 24, plugins)
  • GitHub Check: Test (ubuntu-latest, 22, packages)
  • GitHub Check: Test (windows-latest, 22, plugins)
  • GitHub Check: Test (windows-latest, 22, tools)
  • GitHub Check: Test (windows-latest, 22, packages)
  • GitHub Check: Test (macos-latest, 24, plugins)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test (macos-latest, 22, packages)
  • GitHub Check: typecheck
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Cloudflare Pages: egg-v3

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 implements a crucial fix for a known problem within the tsdown build system where the unbundle configuration option inadvertently causes TypeScript type definitions to be omitted from the build output. By commenting out this option across multiple project configurations, the PR ensures that type generation functions as expected, thereby preventing potential compilation errors and improving the reliability of type usage in dependent modules. This change is a direct response to the documented issue of missing types when unbundling is enabled.

Highlights

  • Type Definition Fix: The primary change addresses an issue where enabling the unbundle option in tsdown configurations leads to missing TypeScript type definitions.
  • Configuration Adjustment: The unbundle: true setting has been commented out in numerous tsdown.config.ts files across various packages and plugins to prevent the type missing issue.
  • Documentation/Comment: A FIXME comment has been added to packages/egg/tsdown.config.ts explicitly linking to the GitHub issue that details the problem with unbundle causing missing types.
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 Oct 4, 2025

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8dc744
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 4, 2025

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8dc744
Status:🚫  Build failed.

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 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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,

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
// 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
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.06%. Comparing base (5be8a53) to head (d8dc744).
⚠️ Report is 1 commits behind head on next.

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.
📢 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 added a commit to eggjs/tegg that referenced this pull request Oct 4, 2025
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

♻️ 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.ts for 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.ts for 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.ts for 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.ts for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5be8a53 and 80c6705.

📒 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.ts
  • packages/cluster/tsdown.config.ts
  • packages/koa-static-cache/tsdown.config.ts
  • packages/cookies/tsdown.config.ts
  • packages/egg/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • packages/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.ts
  • packages/cluster/tsdown.config.ts
  • plugins/security/tsdown.config.ts
  • packages/koa-static-cache/tsdown.config.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • packages/cookies/tsdown.config.ts
  • packages/egg/tsdown.config.ts
  • plugins/mock/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • packages/koa/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • packages/cluster/tsdown.config.ts
  • plugins/security/tsdown.config.ts
  • packages/koa-static-cache/tsdown.config.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • packages/cookies/tsdown.config.ts
  • packages/egg/tsdown.config.ts
  • plugins/mock/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • packages/koa/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • plugins/mock/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • plugins/mock/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • packages/cluster/tsdown.config.ts
  • plugins/security/tsdown.config.ts
  • packages/koa-static-cache/tsdown.config.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • CLAUDE.md
  • packages/cookies/tsdown.config.ts
  • packages/egg/tsdown.config.ts
  • plugins/mock/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • packages/cluster/tsdown.config.ts
  • plugins/security/tsdown.config.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • CLAUDE.md
  • packages/cookies/tsdown.config.ts
  • packages/egg/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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.ts
  • packages/cluster/tsdown.config.ts
  • plugins/security/tsdown.config.ts
  • packages/koa-static-cache/tsdown.config.ts
  • plugins/schedule/tsdown.config.ts
  • plugins/view/tsdown.config.ts
  • tools/egg-bin/tsdown.config.ts
  • examples/helloworld-typescript/tsdown.config.ts
  • CLAUDE.md
  • packages/egg/tsdown.config.ts
  • plugins/session/tsdown.config.ts
  • packages/router/tsdown.config.ts
  • plugins/watcher/tsdown.config.ts
  • plugins/jsonp/tsdown.config.ts
  • plugins/onerror/tsdown.config.ts
  • plugins/i18n/tsdown.config.ts
  • tools/create-egg/tsdown.config.ts
  • packages/utils/tsdown.config.ts
  • packages/extend2/tsdown.config.ts
  • plugins/logrotator/tsdown.config.ts
  • packages/core/tsdown.config.ts
  • plugins/tracer/tsdown.config.ts
  • plugins/static/tsdown.config.ts
  • plugins/development/tsdown.config.ts
  • plugins/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: true to 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 restore unbundle: true with 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.ts output and update guidelines.

The sandbox couldn’t build the package or fetch the external tsdown docs, so please:

  • Build packages/router locally and verify that commenting out unbundle: true produces the expected .d.ts files under dist/.
  • Confirm how disabling unbundle affects 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 disabling unbundle breaks 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 build in packages/cluster; confirm .d.ts files for index, agent_worker, and app_worker appear in dist/.
  • Add an explanatory // FIXME: unbundle disabled due to missing types comment above // unbundle: true,.
  • Update the project’s tsdown configuration learnings to note disabling unbundle until 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.ts

Ensure disabling unbundle indeed fixes missing types before updating coding guidelines.

packages/koa-static-cache/tsdown.config.ts (1)

5-5: Use tsdown’s DTS options instead of disabling unbundle
Tsdown’s unbundle: true can prevent correct .d.ts output (handled by rolldown-plugin-dts). To fix this while keeping unbundle enabled, enable isolatedDeclarations in your tsconfig and in packages/koa-static-cache/tsdown.config.ts add under dts:

{
  newContext: true,
  resolve: true
}

If you need a single merged declaration, leave unbundle: false instead.

⛔ 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 builds
packages/supertest/tsdown.config.ts (1)

7-7: Unbundle is disabled despite guideline requiring it
The tsdown config guideline requires unbundle: 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-enable unbundle: true. Consider removing the commented line entirely.

Comment on lines +293 to +296
// unbundle: true,
unused: {
level: 'error',
},
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 | 🟠 Major

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 exports

Additionally, 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.

Suggested change
// 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,
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 | 🟠 Major

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,
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

❓ 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,
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

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

  1. Is this intended as a permanent fix or a temporary workaround?
  2. Should the coding guidelines be updated to reflect this new approach?
  3. 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:


🏁 Script executed:

#!/bin/bash
rg -nP "dts\s*:" plugins/i18n/tsdown.config.ts -n

Length 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.ts

Length 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,
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

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:

  1. The tsdown tool has a defect that needs to be reported/fixed upstream
  2. 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.ts

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

fengmk2 added a commit to eggjs/tegg that referenced this pull request Oct 4, 2025
@fengmk2 fengmk2 merged commit 803284e into next Oct 4, 2025
31 of 34 checks passed
@fengmk2 fengmk2 deleted the disable-unbundle branch October 4, 2025 16:03
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