Skip to content

fix: don't load ts files on production start#5664

Merged
fengmk2 merged 7 commits intonextfrom
disable-ts-file-loader
Oct 29, 2025
Merged

fix: don't load ts files on production start#5664
fengmk2 merged 7 commits intonextfrom
disable-ts-file-loader

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Oct 29, 2025

use EGG_TS_ENABLE=false

Summary by CodeRabbit

  • New Features

    • Added a sample HTTP controller and a /hello-tegg endpoint returning a versioned greeting.
  • Chores

    • Streamlined build scripts: added build/predev and replaced manual compile steps.
    • TypeScript support can be toggled via EGG_TS_ENABLE (startup now respects this).
    • Config templates now use defineConfig and tracer plugin integration simplified.
    • Removed redundant TypeScript flags from package templates.

@fengmk2 fengmk2 requested a review from Copilot October 29, 2025 12:38
@coderabbitai
Copy link
Contributor

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

Adds an environment gate for TypeScript support (EGG_TS_ENABLE), updates utils and tests to respect it, sets the env in the start script, tightens worker path matching in stop, migrates tegg templates to use defineConfig and plugin factory patterns, adds tegg benchmark controller files and related TypeScript declarations, and adjusts template package and README.

Changes

Cohort / File(s) Summary
TypeScript support guard
packages/utils/src/import.ts, packages/utils/test/import.test.ts
isSupportTypeScript() now returns false early when process.env.EGG_TS_ENABLE === 'false'; debug logs extension keys; tests added/updated to stub EGG_TS_ENABLE and assert behavior.
Start/Stop scripts
tools/scripts/src/commands/start.ts, tools/scripts/src/commands/stop.ts
start now sets EGG_TS_ENABLE='false' in the spawned env; stop narrows worker path regexes to only dist/app_worker.js and dist/agent_worker.js.
Tegg benchmark controllers & declarations
tegg/benchmark/http/app/controller/FooTeggController.js, tegg/benchmark/http/app/controller/FooTeggController.d.ts, tegg/benchmark/http/app/controller/template/egg_controller_1.d.ts, tegg/benchmark/http/app/router.d.ts, tegg/benchmark/http/config/config.default.d.ts
Adds FooTeggController with async hello() method and corresponding .d.ts files plus router/config declaration files for the tegg benchmark.
Tegg template config migration
tools/create-egg/src/templates/tegg/config/config.local.ts, .../config.prod.ts, .../config.unittest.ts
Replace export default { ... } as PartialEggConfig with export default defineConfig({ ... }) and import defineConfig from 'egg'.
Tegg template plugin change
tools/create-egg/src/templates/tegg/config/plugin.ts
Replace explicit tracer plugin object with import tracerPlugin from '@eggjs/tracer' and export default that spreads ...tracerPlugin().
Tegg template package & docs
tools/create-egg/src/templates/tegg/package.json, tools/create-egg/src/templates/tegg/README.md
Remove egg.typescript flag; add predev and build scripts; change prepublishOnly to use build; update README to reflect controller usage and replace tsc deploy step with build.
Test invocation style
tools/create-egg/test/cli.test.ts
Change conditional test skip invocation from chained .skipIf(...).skip(...) to curried test.skipIf(...)(...) style.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant StartCmd as start.ts
  participant ProcEnv as ProcessEnv
  participant Utils as packages/utils/import.ts
  participant App as Application

  rect rgb(239,246,255)
    StartCmd->>ProcEnv: spawn process with EGG_TS_ENABLE='false'
  end

  App->>Utils: call isSupportTypeScript()
  Note right of Utils: check process.env.EGG_TS_ENABLE
  alt EGG_TS_ENABLE === 'false'
    Utils-->>App: return false (TS disabled)
  else not 'false'
    Utils->>Utils: perform Node version & extensions checks
    Utils-->>App: return boolean (computed)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to: isSupportTypeScript gating and debug output changes.
  • Verify start.ts environment behavior for downstream tools.
  • Review stop.ts regex narrowing for potential missed processes.
  • Confirm template migrations (defineConfig, plugin default export) preserve intended typing/runtime semantics.
  • Inspect new controller for correct decorator usage and package version lookup.

Possibly related PRs

Poem

🐰 I nudged a flag and hopped away,
EGG_TS_ENABLE keeps TypeScript at bay,
Templates now wrapped in defineConfig bright,
New controllers say hello with delight,
A little rabbit cheers the build tonight ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix: don't load ts files on production start" accurately and directly describes the primary objective of this pull request. The changes across multiple files—particularly the environment variable EGG_TS_ENABLE=false added in tools/scripts/src/commands/start.ts and the corresponding check in packages/utils/src/import.ts—all work together to implement exactly this fix: preventing TypeScript file loading during production startup. The title is concise, specific, and clearly conveys the main change without unnecessary detail or vague phrasing.
✨ 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-ts-file-loader

📜 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 e81c99a and a75857e.

📒 Files selected for processing (1)
  • packages/utils/src/import.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/**/src/**/*.{ts,tsx}

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

Use TypeScript for all source files in packages (no JavaScript source files)

Files:

  • packages/utils/src/import.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/utils/src/import.ts
{packages/**,plugins/**,tools/!(egg-bin)/**}/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

{packages/**,plugins/**,tools/!(egg-bin)/**}/**/*.ts: For isolatedDeclarations support, all exported functions/methods/getters must have explicit return type annotations
Avoid computed property names with symbols in class declarations (no get SYM)
Add explicit type annotations for class properties when needed (no inferred exported property types)
Exported symbols must use unique symbol type (e.g., export const X: unique symbol = Symbol('x'))

Files:

  • packages/utils/src/import.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). (6)
  • GitHub Check: Test (macos-latest, 24, 1/5)
  • GitHub Check: Test bin (windows-latest, 22, 0/3)
  • GitHub Check: Test bin (windows-latest, 22, 1/3)
  • GitHub Check: Test bin (windows-latest, 22, 2/3)
  • GitHub Check: typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/utils/src/import.ts (1)

69-69: LGTM!

Using Object.keys(extensions) improves debug output readability by showing only the registered extensions (e.g., ['.js', '.json', '.ts']) instead of the full object with function references.


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 streamlines the production startup process for Egg.js applications by ensuring that TypeScript files are not loaded or processed when EGG_TS_ENABLE is explicitly set to false. This change, primarily implemented in the isSupportTypeScript utility function and enforced by the eggctl start command in production, aims to improve performance and reduce overhead. Additionally, the tegg project template has received several updates to align with best practices, including simplified configuration, updated build scripts, and clearer documentation.

Highlights

  • TypeScript Loading Control: Introduced a mechanism to explicitly disable TypeScript file loading in production environments by checking process.env.EGG_TS_ENABLE === 'false' within the isSupportTypeScript utility function.
  • Production Start Optimization: The eggctl start command now automatically sets EGG_TS_ENABLE='false' when running in production mode, preventing unnecessary TypeScript compilation or loading during application startup.
  • Tegg Template Updates: The tegg project template has been refined, including updates to README.md for build instructions, migration of configuration files to use defineConfig, simplification of plugin declarations, and adjustments to package.json scripts (renaming tsc to build, removing egg.typescript field).
  • Test Enhancements: A new test case was added to packages/utils/test/import.test.ts to ensure the EGG_TS_ENABLE=false logic functions correctly.
  • Script Refinements: Minor updates were made to tools/scripts/src/commands/stop.ts to refine worker path regexes and to tools/create-egg/test/cli.test.ts by cleaning up test code.
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 29, 2025

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: adf65c4
Status: ✅  Deploy successful!
Preview URL: https://4816d559.egg-cci.pages.dev
Branch Preview URL: https://disable-ts-file-loader.egg-cci.pages.dev

View logs

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.59%. Comparing base (1d9cb88) to head (adf65c4).
⚠️ Report is 2 commits behind head on next.

Files with missing lines Patch % Lines
packages/utils/src/import.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5664      +/-   ##
==========================================
+ Coverage   87.58%   87.59%   +0.01%     
==========================================
  Files         561      561              
  Lines       10911    10912       +1     
  Branches     1231     1231              
==========================================
+ Hits         9556     9558       +2     
+ Misses       1274     1273       -1     
  Partials       81       81              

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

@cloudflare-workers-and-pages
Copy link

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

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: adf65c4
Status: ✅  Deploy successful!
Preview URL: https://2ace671a.egg-v3.pages.dev
Branch Preview URL: https://disable-ts-file-loader.egg-v3.pages.dev

View logs

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This pull request effectively disables loading of TypeScript files in production by introducing and using the EGG_TS_ENABLE=false environment variable. The implementation is clean, with the necessary logic added to isSupportTypeScript and the variable set in the start command. The PR also includes valuable housekeeping tasks, such as updating create-egg templates to use modern configuration helpers, renaming the tsc script to build for clarity, and fixing worker process detection in the stop command. The changes are well-rounded and improve both functionality and maintainability. I have one suggestion to improve the robustness of the new test case.

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 refactors TypeScript configuration and build processes across the Eggjs monorepo to simplify the development workflow and align with modern practices. The changes remove CommonJS/ESM dual-build complexity from the cluster package, disable TypeScript file loading in production mode, and modernize template configurations.

Key changes:

  • Simplifies @eggjs/cluster build output paths by removing dual CommonJS/ESM format distinction
  • Adds EGG_TS_ENABLE=false environment variable to disable TypeScript loading in production mode
  • Modernizes tegg template configuration to use defineConfig and tracerPlugin factory patterns
  • Adds generated TypeScript declaration files for the tegg benchmark application

Reviewed Changes

Copilot reviewed 12 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/scripts/src/commands/stop.ts Updated regex patterns to match simplified cluster package paths without CommonJS/ESM distinction
tools/scripts/src/commands/start.ts Sets EGG_TS_ENABLE=false in production to disable TypeScript file loader
tools/create-egg/test/cli.test.ts Reformatted test structure and removed commented-out code blocks
tools/create-egg/src/templates/tegg/package.json Removed egg.typescript config, renamed tsc script to build, added predev script
tools/create-egg/src/templates/tegg/config/plugin.ts Refactored to use modern tracerPlugin() factory pattern instead of manual plugin definition
tools/create-egg/src/templates/tegg/config/config.*.ts Replaced type assertions with defineConfig helper for type-safe configuration
tools/create-egg/src/templates/tegg/README.md Updated commands and documentation links, removed outdated development notes
tegg/benchmark/http/**/*.d.ts Added generated TypeScript declaration files for benchmark application
tegg/benchmark/http/app/controller/FooTeggController.js Added compiled JavaScript output for benchmark controller
packages/utils/test/import.test.ts Added test coverage for EGG_TS_ENABLE=false environment variable behavior
packages/utils/src/import.ts Added early return when EGG_TS_ENABLE=false to disable TypeScript support
Comments suppressed due to low confidence (1)

tools/create-egg/src/templates/tegg/README.md:26

  • Corrected spelling of 'se' to 'Use' at the beginning of the list item.
- se `npm run clean` to clean compiled js at development mode once

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/scripts/src/commands/stop.ts (1)

75-75: Update the comment to reflect the new path structure.

The comment example still references the old path structure with dist/commonjs/agent_worker.js, which is inconsistent with the updated regex patterns that now match only dist/agent_worker.js.

Apply this diff to update the comment:

-    // ~/bin/node --no-deprecation --trace-warnings ~/eggjs/examples/helloworld/node_modules/@eggjs/cluster/dist/commonjs/agent_worker.js {"baseDir":"~/eggjs/examples/helloworld","startMode":"process","framework":"~/eggjs/examples/helloworld/node_modules/egg","title":"egg-server-helloworld","workers":10,"clusterPort":58977}
+    // ~/bin/node --no-deprecation --trace-warnings ~/eggjs/examples/helloworld/node_modules/@eggjs/cluster/dist/agent_worker.js {"baseDir":"~/eggjs/examples/helloworld","startMode":"process","framework":"~/eggjs/examples/helloworld/node_modules/egg","title":"egg-server-helloworld","workers":10,"clusterPort":58977}
🧹 Nitpick comments (9)
tools/scripts/src/commands/start.ts (1)

148-149: Default-disable TS; don’t override a pre-set EGG_TS_ENABLE.

Avoid surprising overrides. Only set the flag when the env doesn’t already define it.

-    // disable ts file loader
-    this.env.EGG_TS_ENABLE = 'false';
+    // disable ts file loader by default; respect explicit env
+    if (typeof this.env.EGG_TS_ENABLE === 'undefined') {
+      this.env.EGG_TS_ENABLE = 'false';
+    }
tools/create-egg/test/cli.test.ts (1)

159-203: Make skipIf boolean-safe; verify snapshot matcher.

  • Coerce CI to boolean for TS type-safety/readability.
  • Vitest uses toMatchSnapshot(); if matchSnapshot() isn’t a custom matcher, switch to the canonical name.
-test.skipIf(process.platform === 'win32' || process.env.CI)(
+test.skipIf(process.platform === 'win32' || Boolean(process.env.CI))(
   'successfully scaffolds a project based on tegg starter template',
   () => {
@@
-    expect(generatedFiles).matchSnapshot();
+    // If no custom matcher is registered, prefer Vitest's `toMatchSnapshot`
+    expect(generatedFiles).toMatchSnapshot();

If you intentionally added a custom matchSnapshot(), ignore the second hunk.

packages/utils/test/import.test.ts (1)

440-446: Use Node assert in packages/ tests; keep env stubbing.**

Guideline prefers Node’s assert for assertions in packages/** tests. Update the new test block accordingly.

As per coding guidelines.

   describe('isSupportTypeScript()', () => {
     it('should be false when EGG_TS_ENABLE is false', () => {
       vi.stubEnv('EGG_TS_ENABLE', 'false');
-      expect(isSupportTypeScript()).toBe(false);
+      assert.strictEqual(isSupportTypeScript(), false);
       vi.unstubAllEnvs();
     });
   });
tools/create-egg/src/templates/tegg/README.md (2)

18-18: Nice: build before start. Add a short note about TS being disabled in prod.

To avoid confusion when running uncompiled TS in production, consider noting the new default.

 ### Deploy
 
 ```bash
 npm run build
 npm start

+Note: Production start disables loading .ts files by default (EGG_TS_ENABLE=false). Always build before starting, or use dev mode when running TS directly.


---

`3-3`: **Link tweak (optional).**

If there’s a dedicated tegg HTTPController doc, link it; otherwise this is fine.

</blockquote></details>
<details>
<summary>tegg/benchmark/http/app/router.d.ts (1)</summary><blockquote>

`1-3`: **Prefer explicit default function in d.ts for clarity**

Avoid the `_default` alias; declare the default export directly.


```diff
-import type { Application } from 'egg';
-declare const _default: (app: Application) => void;
-export default _default;
+import type { Application } from 'egg';
+export default function router(app: Application): void;
tegg/benchmark/http/app/controller/template/egg_controller_1.d.ts (1)

1-4: Use import type for clarity in declarations

Make the import explicitly type-only.

-import { Controller } from 'egg';
+import type { Controller } from 'egg';
 export default class EggController1 extends Controller {
   hello(): Promise<void>;
 }
tegg/benchmark/http/app/controller/FooTeggController.js (1)

20-20: JSON import attribute requires Node ≥ 22 — confirm engines or use fallback

with { type: 'json' } needs modern Node. If Node 18/20 must remain supported in benches/CI, prefer createRequire.

-import pkg from 'egg/package.json' with { type: 'json' };
+import { createRequire } from 'node:module';
+const require = createRequire(import.meta.url);
+const pkg = require('egg/package.json');
packages/utils/src/import.ts (1)

52-56: Environment flag is correctly used; flexible parsing is an optional enhancement

The current strict string-based checks (=== 'false' / === 'true') work correctly and are consistently used:

  • Start script sets 'false' explicitly
  • Test validates this behavior
  • No usage of alternative forms ('0', 'off', 'no') found in the codebase

The suggested helper function would add defensive robustness for future use, but is not required given the current consistent practice. If added, update both the early return and the "true" branch as specified in the original suggestion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9cb88 and e81c99a.

📒 Files selected for processing (16)
  • packages/utils/src/import.ts (1 hunks)
  • packages/utils/test/import.test.ts (2 hunks)
  • tegg/benchmark/http/app/controller/FooTeggController.d.ts (1 hunks)
  • tegg/benchmark/http/app/controller/FooTeggController.js (1 hunks)
  • tegg/benchmark/http/app/controller/template/egg_controller_1.d.ts (1 hunks)
  • tegg/benchmark/http/app/router.d.ts (1 hunks)
  • tegg/benchmark/http/config/config.default.d.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/README.md (2 hunks)
  • tools/create-egg/src/templates/tegg/config/config.local.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.prod.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/config.unittest.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/config/plugin.ts (1 hunks)
  • tools/create-egg/src/templates/tegg/package.json (2 hunks)
  • tools/create-egg/test/cli.test.ts (3 hunks)
  • tools/scripts/src/commands/start.ts (1 hunks)
  • tools/scripts/src/commands/stop.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.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/tegg/config/config.unittest.ts
  • packages/utils/src/import.ts
  • tegg/benchmark/http/app/router.d.ts
  • packages/utils/test/import.test.ts
  • tools/create-egg/src/templates/tegg/config/plugin.ts
  • tegg/benchmark/http/app/controller/FooTeggController.d.ts
  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/scripts/src/commands/start.ts
  • tools/create-egg/src/templates/tegg/config/config.prod.ts
  • tools/scripts/src/commands/stop.ts
  • tegg/benchmark/http/config/config.default.d.ts
  • tegg/benchmark/http/app/controller/template/egg_controller_1.d.ts
  • tools/create-egg/test/cli.test.ts
{packages/**,plugins/**,tools/!(egg-bin)/**}/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

{packages/**,plugins/**,tools/!(egg-bin)/**}/**/*.ts: For isolatedDeclarations support, all exported functions/methods/getters must have explicit return type annotations
Avoid computed property names with symbols in class declarations (no get SYM)
Add explicit type annotations for class properties when needed (no inferred exported property types)
Exported symbols must use unique symbol type (e.g., export const X: unique symbol = Symbol('x'))

Files:

  • tools/create-egg/src/templates/tegg/config/config.unittest.ts
  • packages/utils/src/import.ts
  • packages/utils/test/import.test.ts
  • tools/create-egg/src/templates/tegg/config/plugin.ts
  • tools/create-egg/src/templates/tegg/config/config.local.ts
  • tools/scripts/src/commands/start.ts
  • tools/create-egg/src/templates/tegg/config/config.prod.ts
  • tools/scripts/src/commands/stop.ts
  • tools/create-egg/test/cli.test.ts
packages/**/src/**/*.{ts,tsx}

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

Use TypeScript for all source files in packages (no JavaScript source files)

Files:

  • packages/utils/src/import.ts
packages/**/test/**/*.test.ts

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

packages/**/test/**/*.test.ts: Name test files as test/**/*.test.ts and run them with Vitest
Use import { describe, it } from 'vitest' in tests
Use Node.js built-in assert module for test assertions

Files:

  • packages/utils/test/import.test.ts
**/test/**/*.test.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.test.ts: Place test suites following Vitest discovery: /test//*.test.ts
Mirror the repository test pattern when adding new suites

Files:

  • packages/utils/test/import.test.ts
  • tools/create-egg/test/cli.test.ts
{packages/!(cookies)/**/test/**/*.test.ts,plugins/**/test/**/*.test.ts}

📄 CodeRabbit inference engine (CLAUDE.md)

Vitest test files must follow the naming pattern test/**/*.test.ts

Files:

  • packages/utils/test/import.test.ts
{packages/**/test/**,plugins/**/test/**}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Node.js assert for assertions in Vitest tests

Files:

  • packages/utils/test/import.test.ts
{package.json,packages/**/package.json,plugins/**/package.json,tools/**/package.json}

📄 CodeRabbit inference engine (CLAUDE.md)

All packages must require Node.js >= 22.18.0 (set engines.node to ">=22.18.0")

Files:

  • tools/create-egg/src/templates/tegg/package.json
{packages/**/package.json,plugins/**/package.json,tools/**/package.json}

📄 CodeRabbit inference engine (CLAUDE.md)

{packages/**/package.json,plugins/**/package.json,tools/**/package.json}: Use workspace:* for internal dependencies between monorepo packages
Use catalog: versions for external dependencies defined in pnpm-workspace.yaml
Include script "typecheck": "tsc --noEmit" in all packages
Include script "lint": "oxlint --type-aware" in all packages
Include script "lint:fix" that runs oxlint with --fix (e.g., "pnpm run lint -- --fix")

Files:

  • tools/create-egg/src/templates/tegg/package.json
🧠 Learnings (10)
📚 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:

  • packages/utils/test/import.test.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/**/test/**/*.test.ts : Use import { describe, it } from 'vitest' in tests

Applied to files:

  • packages/utils/test/import.test.ts
📚 Learning: 2025-10-18T11:59:58.226Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-18T11:59:58.226Z
Learning: Applies to {packages/**/vitest.config.ts,plugins/**/vitest.config.ts} : Packages using Vitest must include a vitest.config.ts and import test functions from vitest

Applied to files:

  • packages/utils/test/import.test.ts
📚 Learning: 2025-10-18T11:59:58.226Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-18T11:59:58.226Z
Learning: Applies to {packages/**/test/**,plugins/**/test/**} : Use Node.js assert for assertions in Vitest tests

Applied to files:

  • packages/utils/test/import.test.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/**/test/**/*.test.ts : Use Node.js built-in assert module for test assertions

Applied to files:

  • packages/utils/test/import.test.ts
📚 Learning: 2025-10-23T17:37:37.549Z
Learnt from: CR
PR: eggjs/egg#0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-10-23T17:37:37.549Z
Learning: Applies to tegg/core/*/package.json : Core packages should include scripts: typecheck, clean, build (tsc --noEmit, rimraf, build pipeline)

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-10-23T17:37:37.549Z
Learnt from: CR
PR: eggjs/egg#0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-10-23T17:37:37.549Z
Learning: Applies to tegg/plugin/*/package.json : Plugin packages must define eggPlugin in package.json with dependencies

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-10-18T11:59:58.226Z
Learnt from: CR
PR: eggjs/egg#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-18T11:59:58.226Z
Learning: Applies to plugins/*/package.json : Plugins must include scripts: build (tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json), typecheck (tsc --noEmit), lint (oxlint --type-aware), test (vitest run), prepublishOnly (pnpm run build)

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-10-23T17:37:37.549Z
Learnt from: CR
PR: eggjs/egg#0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-10-23T17:37:37.549Z
Learning: Applies to tegg/{core,plugin,standalone}/*/package.json : Set package.json "type": "module" (ESM only; no CommonJS) in all tegg packages

Applied to files:

  • tools/create-egg/src/templates/tegg/package.json
📚 Learning: 2025-10-23T17:37:37.549Z
Learnt from: CR
PR: eggjs/egg#0
File: tegg/CLAUDE.md:0-0
Timestamp: 2025-10-23T17:37:37.549Z
Learning: Run build, test, and versioning commands from the monorepo root (Egg.js repo), not from tegg/

Applied to files:

  • tools/create-egg/test/cli.test.ts
🧬 Code graph analysis (6)
tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)
packages/egg/src/lib/define.ts (1)
  • defineConfig (29-31)
packages/utils/test/import.test.ts (1)
packages/utils/src/import.ts (1)
  • isSupportTypeScript (51-76)
tegg/benchmark/http/app/controller/FooTeggController.js (2)
tegg/benchmark/http/app/controller/FooTeggController.d.ts (1)
  • FooTeggController (1-3)
packages/egg/src/index.ts (2)
  • HTTPMethod (157-157)
  • HTTPMethodEnum (158-158)
tegg/benchmark/http/app/controller/FooTeggController.d.ts (1)
tegg/benchmark/http/app/controller/FooTeggController.js (1)
  • FooTeggController (21-25)
tools/create-egg/src/templates/tegg/config/config.local.ts (1)
packages/egg/src/lib/define.ts (1)
  • defineConfig (29-31)
tools/create-egg/src/templates/tegg/config/config.prod.ts (1)
packages/egg/src/lib/define.ts (1)
  • defineConfig (29-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Test (macos-latest, 24, 1/5)
  • GitHub Check: Test (windows-latest, 24, 4/5)
  • GitHub Check: Test (macos-latest, 24, 2/5)
  • GitHub Check: Test (windows-latest, 22, 4/5)
  • GitHub Check: Test (macos-latest, 22, 5/5)
  • GitHub Check: Test (macos-latest, 22, 4/5)
  • GitHub Check: Test (windows-latest, 22, 2/5)
  • GitHub Check: Test (windows-latest, 24, 2/5)
  • GitHub Check: Test (macos-latest, 24, 4/5)
  • GitHub Check: Test bin (windows-latest, 22, 2/3)
  • GitHub Check: Test bin (windows-latest, 22, 0/3)
  • GitHub Check: Test bin (ubuntu-latest, 22, 2/3)
  • GitHub Check: Test bin (windows-latest, 22, 1/3)
  • GitHub Check: Test bin (ubuntu-latest, 22, 1/3)
  • GitHub Check: Test bin (ubuntu-latest, 22, 0/3)
  • GitHub Check: typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (11)
tools/create-egg/src/templates/tegg/package.json (1)

9-9: LGTM!

The script updates align well with the PR objectives and maintain best practices. The new build script consolidates the TypeScript compilation step, and predev ensures a clean state before development. The updated prepublishOnly properly delegates to the new build script. All required scripts (typecheck, lint, build, clean) are present and follow the established patterns. Node.js engine requirement is correctly set to >=22.18.0 as per coding guidelines.

Also applies to: 19-19, 21-21

tools/create-egg/src/templates/tegg/config/config.unittest.ts (1)

1-5: LGTM! Improved idiomatic TypeScript pattern.

The refactoring from type assertion (as PartialEggConfig) to the defineConfig helper function is a cleaner, more maintainable approach that still provides full type safety. This change is consistent across all config templates.

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

1-5: LGTM! Consistent refactoring across templates.

The production config now uses the same defineConfig pattern as the other environment configs, ensuring consistency across all configuration templates.

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

1-5: LGTM! Completes the consistent refactoring.

The local config now matches the pattern used in production and unittest configs. This unified approach using defineConfig improves maintainability and provides a better developer experience for projects created from these templates.

tools/scripts/src/commands/stop.ts (1)

13-16: Remove the review comment — the path structure change is correct and necessary.

The original review incorrectly warns about breaking existing deployments with old path structures. However, the @eggjs/cluster package exports files directly from ./dist/agent_worker.js and ./dist/app_worker.js, with no commonjs/ or esm/ subdirectories. The regex patterns in this PR are being corrected to match the actual current package structure, not narrowed to break backward compatibility. The old paths referenced in the original comments never existed in the published package distribution—this is a necessary fix to align the detection logic with reality.

Likely an incorrect or invalid review comment.

tegg/benchmark/http/config/config.default.d.ts (1)

1-3: Minimal d.ts looks good.

Default export typed as PartialEggConfig is appropriate here.

packages/utils/test/import.test.ts (2)

4-4: Adding vi import is fine.

Needed for env stubbing; no issues.


7-7: Public API surface change: isSupportTypeScript export.

Confirm this is intended to be public and covered by semver docs/changelog. If it’s internal-only, consider not exporting from index.

Based on learnings.

tegg/benchmark/http/app/controller/FooTeggController.d.ts (1)

1-3: Typings match runtime implementation

The declaration aligns with FooTeggController.js (hello(): Promise). LGTM.

packages/utils/src/import.ts (2)

64-65: Confirm Node-version heuristic for TS support

nodeMajorVersion >= 22 enabling TS may be misleading since Node doesn’t natively execute .ts without a loader. Verify this is intentional and safe (no accidental TS resolution when no loader is present).


67-73: Debug log improvement acknowledged

Logging Object.keys(extensions) avoids noisy dumps. Good change.

@fengmk2 fengmk2 merged commit 9e05322 into next Oct 29, 2025
50 of 52 checks passed
@fengmk2 fengmk2 deleted the disable-ts-file-loader branch October 29, 2025 13:28
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