Skip to content

fix(cluster): add missing exports for agent_worker and app_worker#5536

Merged
fengmk2 merged 3 commits intonextfrom
fix-cluster
Sep 25, 2025
Merged

fix(cluster): add missing exports for agent_worker and app_worker#5536
fengmk2 merged 3 commits intonextfrom
fix-cluster

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Sep 25, 2025

  • Export agent_worker and app_worker modules in cluster package.json
  • Add corresponding entries in tsdown.config.ts for build process
  • Update TypeScript config templates to use PartialEggConfig type
  • Simplify config.local.ts and config.prod.ts templates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added public entry points for agent_worker and app_worker to make those workers easier to consume.
  • Refactor

    • Build configuration updated to include the new worker entry points.
    • Egg app templates simplified to export plain config objects with clearer typings, reducing boilerplate.
  • Chores

    • Updated oxlint dependency to a newer patch release.

- Export agent_worker and app_worker modules in cluster package.json
- Add corresponding entries in tsdown.config.ts for build process
- Update TypeScript config templates to use PartialEggConfig type
- Simplify config.local.ts and config.prod.ts templates

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Caution

Review failed

The pull request is closed.

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

Adds two new worker entry points to the cluster package (exports and tsdown entries). Refactors Egg template configs from factory functions to static object exports typed as PartialEggConfig. Also updates the pnpm workspace catalog to bump oxlint from ^1.16.0 to ^1.17.0.

Changes

Cohort / File(s) Summary of Changes
Cluster exports and build entries
packages/cluster/package.json, packages/cluster/tsdown.config.ts
Added public exports ./agent_worker and ./app_worker mapping to src/*.ts (top-level exports) and dist/*.js (publishConfig.exports). Added tsdown entry points: agent_worker: 'src/agent_worker.ts', app_worker: 'src/app_worker.ts'.
Egg template config typing/export refactor
tools/create-egg/src/templates/simple-ts/config/config.default.ts, tools/create-egg/src/templates/simple-ts/config/config.local.ts, tools/create-egg/src/templates/simple-ts/config/config.prod.ts
Replaced exported factory functions that returned PowerPartial<EggAppConfig> with static object exports cast as PartialEggConfig. Updated imports and function signatures to use PartialEggConfig and removed explicit EggAppInfo typing where applicable.
Workspace catalog dependency bump
pnpm-workspace.yaml
Updated catalog entry for oxlint from ^1.16.0 to ^1.17.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers, nibble keys,
Two workers sprout beneath the trees.
Configs now sit like careful hens,
Static nests instead of pens.
A hop, a build, the carrots sing—🥕

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 concisely captures the core change by specifying that missing exports for agent_worker and app_worker are being added to the cluster package, uses conventional commit syntax, and clearly conveys the purpose of the pull request for anyone scanning the repository history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 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 c9dbb58 and fb55617.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • pnpm-workspace.yaml (1 hunks)
  • tools/create-egg/src/templates/simple-ts/config/config.default.ts (1 hunks)

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 addresses an issue in the cluster package by ensuring that agent_worker and app_worker modules are correctly exported and included in the build process. Concurrently, it refines the TypeScript configuration templates used by create-egg projects, leading to improved type safety and a more streamlined structure for configuration files, ultimately enhancing developer experience and code maintainability.

Highlights

  • Module Exports: The agent_worker and app_worker modules are now explicitly exported in packages/cluster/package.json for both compiled (dist) and source (src) paths, making them properly discoverable and importable.
  • Build Configuration: The tsdown.config.ts file for the cluster package has been updated to include agent_worker.ts and app_worker.ts in its entry points, ensuring these files are correctly processed during the build.
  • TypeScript Config Templates: The create-egg templates for config.default.ts, config.local.ts, and config.prod.ts now utilize the PartialEggConfig type, enhancing type safety and providing better autocompletion for configuration objects.
  • Configuration Simplification: The config.local.ts and config.prod.ts templates have been simplified by directly exporting a PartialEggConfig object, removing the need for a function wrapper and PowerPartial type.
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.

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 correctly adds the missing exports for agent_worker and app_worker in the @eggjs/cluster package. The changes to package.json and tsdown.config.ts are appropriate to expose these modules. The PR also includes beneficial refactoring of the TypeScript configuration templates, simplifying them and adopting the PartialEggConfig type for better type safety. I've suggested a further improvement to use the defineConfig helper for consistency and better type safety across all configuration files.

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #5536   +/-   ##
=======================================
  Coverage   75.87%   75.87%           
=======================================
  Files         114      114           
  Lines        5770     5770           
  Branches     1149     1149           
=======================================
  Hits         4378     4378           
  Misses       1212     1212           
  Partials      180      180           

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

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

🧹 Nitpick comments (3)
tools/create-egg/src/templates/simple-ts/config/config.default.ts (1)

10-10: Cast the final return to PartialEggConfig (and drop the interim cast)

Avoids potential excess property checks from bizConfig.sourceUrl and is clearer.

-  } as PartialEggConfig;
+  };
@@
-  return {
-    ...config,
-    ...bizConfig,
-  };
+  return {
+    ...config,
+    ...bizConfig,
+  } as PartialEggConfig;

Also applies to: 18-21

packages/cluster/tsdown.config.ts (1)

6-7: Optional: prefer hyphenated filenames for consistency

Repo guidelines favor lowercase with hyphens. Consider agent-worker.ts and app-worker.ts in a future major/minor if compatibility allows.

packages/cluster/package.json (1)

8-9: Consider adding explicit types mappings for subpath exports

Improves TS resolution for ./agent_worker and ./app_worker without relying on heuristic .d.ts lookup.

       ".": "./dist/index.js",
-      "./agent_worker": "./dist/agent_worker.js",
-      "./app_worker": "./dist/app_worker.js",
+      "./agent_worker": { "types": "./dist/agent_worker.d.ts", "default": "./dist/agent_worker.js" },
+      "./app_worker": { "types": "./dist/app_worker.d.ts", "default": "./dist/app_worker.js" },
@@
     ".": "./src/index.ts",
-    "./agent_worker": "./src/agent_worker.ts",
-    "./app_worker": "./src/app_worker.ts",
+    "./agent_worker": { "types": "./src/agent_worker.ts", "default": "./src/agent_worker.ts" },
+    "./app_worker": { "types": "./src/app_worker.ts", "default": "./src/app_worker.ts" },

Also applies to: 16-17

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f36f865 and c9dbb58.

📒 Files selected for processing (5)
  • packages/cluster/package.json (1 hunks)
  • packages/cluster/tsdown.config.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/config/config.default.ts (2 hunks)
  • tools/create-egg/src/templates/simple-ts/config/config.local.ts (1 hunks)
  • tools/create-egg/src/templates/simple-ts/config/config.prod.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.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:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
  • packages/cluster/tsdown.config.ts
  • tools/create-egg/src/templates/simple-ts/config/config.local.ts
  • tools/create-egg/src/templates/simple-ts/config/config.prod.ts
packages/*/package.json

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use "workspace:*" for internal workspace dependencies in package.json

Files:

  • packages/cluster/package.json
{packages,plugins,tools}/**/package.json

📄 CodeRabbit inference engine (CLAUDE.md)

{packages,plugins,tools}/**/package.json: Individual packages must reference external dependencies via "catalog:" from pnpm-workspace.yaml
Use "workspace:*" for internal monorepo dependencies between packages

Files:

  • packages/cluster/package.json
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/cluster/tsdown.config.ts
{packages,plugins,tools}/**/tsdown.config.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Each package must use tsdown for unbundled ESM builds with type declarations (unbundle: true, dts: true)

Files:

  • packages/cluster/tsdown.config.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsdown.config.ts : packages/egg must use tsdown configured for unbundled ESM output

Applied to files:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
  • packages/cluster/tsdown.config.ts
  • tools/create-egg/src/templates/simple-ts/config/config.local.ts
  • tools/create-egg/src/templates/simple-ts/config/config.prod.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to packages/egg/tsconfig.json : packages/egg/tsconfig.json must extend eggjs/tsconfig and enable strict mode

Applied to files:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to tools/egg-bin/tsdown.config.ts : egg-bin tool must use tsdown for TypeScript compilation

Applied to files:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
  • packages/cluster/tsdown.config.ts
📚 Learning: 2025-09-18T07:56:17.417Z
Learnt from: CR
PR: eggjs/egg#0
File: AGENTS.md:0-0
Timestamp: 2025-09-18T07:56:17.417Z
Learning: Applies to **/*.ts : Re-export types thoughtfully to keep the public API stable

Applied to files:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must include an eggPlugin configuration field

Applied to files:

  • tools/create-egg/src/templates/simple-ts/config/config.default.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must export TS sources in development ("exports": { ".": "./src/index.ts", "./agent": "./src/agent.ts", "./app": "./src/app.ts", "./package.json": "./package.json" })

Applied to files:

  • packages/cluster/package.json
  • packages/cluster/tsdown.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/*/package.json : Plugin package.json must mirror exports for publish via publishConfig.exports pointing to compiled JS in dist (e.g., "./dist/index.js")

Applied to files:

  • packages/cluster/package.json
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to plugins/**/tsdown.config.ts : All plugins must use the standard tsdown configuration template (entry: 'src/**/*.ts', unbundle: true, dts: true, exports.devExports: true)

Applied to files:

  • packages/cluster/tsdown.config.ts
📚 Learning: 2025-09-15T01:56:16.297Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-15T01:56:16.297Z
Learning: Applies to {packages,plugins,tools}/**/tsdown.config.ts : Each package must use tsdown for unbundled ESM builds with type declarations (unbundle: true, dts: true)

Applied to files:

  • packages/cluster/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/cluster/tsdown.config.ts
🧬 Code graph analysis (3)
tools/create-egg/src/templates/simple-ts/config/config.default.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
tools/create-egg/src/templates/simple-ts/config/config.local.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
tools/create-egg/src/templates/simple-ts/config/config.prod.ts (1)
packages/egg/src/lib/types.ts (1)
  • PartialEggConfig (97-97)
⏰ 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). (12)
  • GitHub Check: Test egg-bin (macos-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 24)
  • GitHub Check: Test egg-bin (ubuntu-latest, 22)
  • GitHub Check: Test egg-bin (windows-latest, 22)
  • GitHub Check: Test egg-bin (macos-latest, 24)
  • GitHub Check: Test egg-bin (ubuntu-latest, 24)
  • GitHub Check: Test packages (macos-latest, 24)
  • GitHub Check: Test packages (macos-latest, 22)
  • GitHub Check: Test packages (ubuntu-latest, 22)
  • GitHub Check: Test packages (windows-latest, 24)
  • GitHub Check: Test packages (ubuntu-latest, 24)
  • GitHub Check: Test packages (windows-latest, 22)
🔇 Additional comments (5)
tools/create-egg/src/templates/simple-ts/config/config.default.ts (1)

1-1: Importing PartialEggConfig is correct

Matches the new typing direction.

packages/cluster/tsdown.config.ts (1)

6-7: LGTM: added agent_worker and app_worker entries

Entries align with new subpath exports.

tools/create-egg/src/templates/simple-ts/config/config.local.ts (1)

1-5: LGTM: static object export with PartialEggConfig

Template matches the new typing approach.

tools/create-egg/src/templates/simple-ts/config/config.prod.ts (1)

1-5: LGTM: static object export with PartialEggConfig

Consistent with the updated template suite.

packages/cluster/package.json (1)

8-9: Approve: agent_worker & app_worker subpath exports verified
Matches tsdown entries; dev → ./src/.ts, publish → ./dist/.js.

@cloudflare-workers-and-pages
Copy link

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: fb55617
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: fb55617
Status:🚫  Build failed.

View logs

@fengmk2 fengmk2 merged commit cd8e398 into next Sep 25, 2025
19 of 23 checks passed
@fengmk2 fengmk2 deleted the fix-cluster branch September 25, 2025 08:26
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