Skip to content

fix(tegg-loader): ignore non-runtime module files#6031

Closed
elrrrrrrr wants to merge 1 commit into
eggjs:nextfrom
elrrrrrrr:codex/tegg-loader-ignore-non-runtime
Closed

fix(tegg-loader): ignore non-runtime module files#6031
elrrrrrrr wants to merge 1 commit into
eggjs:nextfrom
elrrrrrrr:codex/tegg-loader-ignore-non-runtime

Conversation

@elrrrrrrr

@elrrrrrrr elrrrrrrr commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What changed

Exclude TypeScript declaration variants (.d.mts, .d.cts) and vitest.config.* from TEGG runtime module discovery.

Why

The extension-aware glob includes .mts/.cts/.mjs, so declaration files and package-local Vitest config can otherwise be imported as application modules. This currently requires a Chair-bin postinstall patch and can fail when a published TEGG module contains vitest.config.mjs.

Verification

  • vitest run --project @eggjs/tegg-loader tegg/core/loader/test/Loader.test.ts
  • 11 tests passed

Summary by CodeRabbit

  • Bug Fixes
    • Improved module loading to ignore TypeScript declaration entrypoints and Vitest configuration files, preventing them from being treated as application modules.

Copilot AI review requested due to automatic review settings July 12, 2026 14:35
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd69e2f8-d600-48d1-9ed9-baa3fd9eb975

📥 Commits

Reviewing files that changed from the base of the PR and between dfd102c and 2568e7a.

📒 Files selected for processing (2)
  • tegg/core/loader/src/LoaderUtil.ts
  • tegg/core/loader/test/Loader.test.ts

📝 Walkthrough

Walkthrough

LoaderUtil.filePattern() now excludes .d.mts, .d.cts, and vitest.config.* files, with a test verifying the expanded denylist.

Changes

Loader glob exclusions

Layer / File(s) Summary
Extend file-pattern exclusions
tegg/core/loader/src/LoaderUtil.ts, tegg/core/loader/test/Loader.test.ts
The loader excludes additional TypeScript declaration files and Vitest configuration files, with coverage for the resulting negated glob patterns.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • eggjs/egg#5974: Adjusts TypeScript extension handling in LoaderUtil.
  • eggjs/egg#6026: Extends LoaderUtil.filePattern() module extension and pattern handling.

Suggested reviewers: fengmk2, killagu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: excluding non-runtime module files from tegg-loader discovery.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

Copy link
Copy Markdown
Contributor

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 updates LoaderUtil.ts to exclude TypeScript declaration files (.d.mts, .d.cts) and Vitest configuration files (vitest.config.) from runtime module loading, and adds corresponding unit tests. The reviewer suggests also excluding Vitest workspace configuration files (vitest.workspace.) and adding a corresponding test assertion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +86 to +87
// test runner configuration is not an application module
'!**/vitest.config.*',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In addition to vitest.config.*, Vitest workspace configuration files (e.g., vitest.workspace.ts or vitest.workspace.mjs) are also common in monorepos and should be excluded from runtime module discovery to prevent similar loading failures.

Suggested change
// test runner configuration is not an application module
'!**/vitest.config.*',
// test runner configuration is not an application module
'!**/vitest.config.*',
'!**/vitest.workspace.*',

assert(patterns.includes('!**/*.d.ts'));
assert(patterns.includes('!**/*.d.mts'));
assert(patterns.includes('!**/*.d.cts'));
assert(patterns.includes('!**/vitest.config.*'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Add an assertion to verify that vitest.workspace.* is also excluded by the file pattern.

      assert(patterns.includes('!**/vitest.config.*'));
      assert(patterns.includes('!**/vitest.workspace.*'));

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.17%. Comparing base (3ddbbe4) to head (2568e7a).
⚠️ Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #6031      +/-   ##
==========================================
+ Coverage   81.98%   82.17%   +0.18%     
==========================================
  Files         678      678              
  Lines       20838    20842       +4     
  Branches     4154     4155       +1     
==========================================
+ Hits        17085    17127      +42     
+ Misses       3235     3207      -28     
+ Partials      518      508      -10     

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 hardens TEGG runtime module discovery by expanding the ignore glob patterns so that TypeScript declaration entrypoints (.d.mts, .d.cts) and package-local Vitest config files (vitest.config.*) are not treated as runtime application modules.

Changes:

  • Extend LoaderUtil.filePattern() to exclude **/*.d.mts, **/*.d.cts, and **/vitest.config.*.
  • Add a regression test asserting these exclusions are present in the generated file patterns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tegg/core/loader/src/LoaderUtil.ts Adds new exclude patterns for declaration variants and Vitest config files in runtime module globbing.
tegg/core/loader/test/Loader.test.ts Adds a test to assert the new exclude patterns are included in LoaderUtil.filePattern().

@elrrrrrrr

Copy link
Copy Markdown
Contributor Author

Superseded by #6033. This patch is already included in the beta.24 baseline branch (codex/release-beta24-patchless) and was published with v4.1.2-beta.24.

@elrrrrrrr elrrrrrrr closed this Jul 12, 2026
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.

2 participants