Conversation
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #5942 +/- ##
==========================================
- Coverage 85.21% 85.20% -0.01%
==========================================
Files 669 669
Lines 19304 19321 +17
Branches 3787 3792 +5
==========================================
+ Hits 16449 16463 +14
- Misses 2463 2466 +3
Partials 392 392 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Deploying egg-v3 with
|
| Latest commit: |
1b82c1e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://744eccb6.egg-v3.pages.dev |
| Branch Preview URL: | https://agent-egg-dev-c9b604fb.egg-v3.pages.dev |
Deploying egg with
|
| Latest commit: |
1b82c1e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2d605d18.egg-cci.pages.dev |
| Branch Preview URL: | https://agent-egg-dev-c9b604fb.egg-cci.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR extracts the loader-facing filesystem boundary (LoaderFS/RealLoaderFS) into a new workspace package @eggjs/loader-fs, then updates @eggjs/core to depend on and re-export that boundary while continuing to support loaderFS injection through loader options. It also migrates parity tests/docs to match the new package boundary.
Changes:
- Added new
packages/loader-fsworkspace package implementingLoaderFSandRealLoaderFS, with dedicated fixtures/tests. - Updated
@eggjs/coreto importRealLoaderFS/LoaderFSfrom@eggjs/loader-fsand re-export the new package from@eggjs/core. - Updated wiki pages and root TS project references to reflect the new package boundary.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wiki/packages/loader-fs.md | New wiki page documenting the new @eggjs/loader-fs package boundary. |
| wiki/packages/core.md | Adjusts Core docs to describe loader-fs as the home for LoaderFS (needs updated_at bump). |
| wiki/log.md | Adds a 2026-05-10 changelog entry describing the extraction. |
| wiki/index.md | Adds loader-fs to the wiki package index. |
| tsconfig.json | Adds packages/loader-fs to TS project references. |
| packages/loader-fs/tsdown.config.ts | New build config for the @eggjs/loader-fs package. |
| packages/loader-fs/tsconfig.json | New TS config extending the repo root config. |
| packages/loader-fs/test/index.test.ts | New/ported tests validating RealLoaderFS behavior and loadFile semantics. |
| packages/loader-fs/test/fixtures/loadfile/package.json | Fixture to force CJS semantics for loadFile test modules. |
| packages/loader-fs/test/fixtures/loadfile/object.js | Fixture module exporting an object for loadFile tests. |
| packages/loader-fs/test/fixtures/loadfile/null.js | Fixture module exporting null for glob negation/load tests. |
| packages/loader-fs/test/fixtures/loadfile/no-js.yml | Fixture non-JS file to validate Buffer-return behavior. |
| packages/loader-fs/src/index.ts | New LoaderFS interface + RealLoaderFS implementation (error prefix likely needs update). |
| packages/loader-fs/package.json | New workspace package manifest for @eggjs/loader-fs. |
| packages/core/test/loader/file_loader.test.ts | Updates tests to import RealLoaderFS types from @eggjs/loader-fs. |
| packages/core/src/loader/loader_fs.ts | Removes the in-core LoaderFS implementation (moved to @eggjs/loader-fs). |
| packages/core/src/loader/file_loader.ts | Switches FileLoader default loader FS wiring to @eggjs/loader-fs. |
| packages/core/src/loader/egg_loader.ts | Switches EggLoader default loader FS wiring to @eggjs/loader-fs. |
| packages/core/src/index.ts | Re-exports @eggjs/loader-fs from @eggjs/core. |
| packages/core/package.json | Adds @eggjs/loader-fs as a dependency. |
Comments suppressed due to low confidence (1)
wiki/packages/core.md:10
updated_atis still2026-05-07, but this page content was updated in this PR (LoaderFS section and source_files list). Please bumpupdated_atto match the current edit date (and wiki log entry).
- packages/core/src/index.ts
- packages/core/src/loader/file_loader.ts
- packages/core/src/loader/context_loader.ts
- packages/core/src/loader/egg_loader.ts
updated_at: 2026-05-07
There was a problem hiding this comment.
Code Review
This pull request extracts the LoaderFS boundary and its default implementation, RealLoaderFS, from the core package into a new standalone package, @eggjs/loader-fs. This architectural change allows other components to utilize the filesystem abstraction without a direct dependency on the core package. The review feedback suggests several improvements to the loadFile method in the new package, including the use of asynchronous file reading to avoid blocking the event loop, updating error prefixes to match the new package scope, and implementing more robust error handling for non-Error types.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/loader-fs/src/index.ts (1)
67-67: ⚡ Quick winUpdate error namespace to match extracted package boundary.
After extraction,
"[egg/core]"in the thrown error message is misleading for troubleshooting from@eggjs/loader-fs.Proposed patch
- const err = new Error(`[egg/core] load file: ${filepath}, error: ${e.message}`); + const err = new Error(`[egg/loader-fs] load file: ${filepath}, error: ${e.message}`);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/loader-fs/src/index.ts` at line 67, The error message uses the old namespace "[egg/core]" and should be updated to the extracted package namespace; update the Error construction in index.ts (where `const err = new Error(\`[egg/core] load file: ${filepath}, error: ${e.message}\`)`) to use the correct package identifier (e.g. `[`@eggjs/loader-fs`]` or `@eggjs/loader-fs`) so it reads like `const err = new Error(\`[`@eggjs/loader-fs`] load file: ${filepath}, error: ${e.message}\`)`, preserving `filepath` and `e.message` unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/loader-fs/src/index.ts`:
- Line 67: The error message uses the old namespace "[egg/core]" and should be
updated to the extracted package namespace; update the Error construction in
index.ts (where `const err = new Error(\`[egg/core] load file: ${filepath},
error: ${e.message}\`)`) to use the correct package identifier (e.g.
`[`@eggjs/loader-fs`]` or `@eggjs/loader-fs`) so it reads like `const err = new
Error(\`[`@eggjs/loader-fs`] load file: ${filepath}, error: ${e.message}\`)`,
preserving `filepath` and `e.message` unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c417823f-6a08-4ae1-b0b8-11ac7a018ce3
📒 Files selected for processing (20)
packages/core/package.jsonpackages/core/src/index.tspackages/core/src/loader/egg_loader.tspackages/core/src/loader/file_loader.tspackages/core/src/loader/loader_fs.tspackages/core/test/loader/file_loader.test.tspackages/loader-fs/package.jsonpackages/loader-fs/src/index.tspackages/loader-fs/test/fixtures/loadfile/no-js.ymlpackages/loader-fs/test/fixtures/loadfile/null.jspackages/loader-fs/test/fixtures/loadfile/object.jspackages/loader-fs/test/fixtures/loadfile/package.jsonpackages/loader-fs/test/index.test.tspackages/loader-fs/tsconfig.jsonpackages/loader-fs/tsdown.config.tstsconfig.jsonwiki/index.mdwiki/log.mdwiki/packages/core.mdwiki/packages/loader-fs.md
💤 Files with no reviewable changes (1)
- packages/core/src/loader/loader_fs.ts
Summary
@eggjs/loader-fsworkspace package@eggjs/coredepend on and re-export@eggjs/loader-fswhile continuing to passloaderFSthrough EggLoader/FileLoader/ContextLoader optionsTests
Follow-up for EGG-96 after #5936 was merged.
Summary by CodeRabbit
New Packages
@eggjs/loader-fspackage exposing a filesystem abstraction with operations for file existence checks, metadata retrieval, JSON reading, file globbing, and asynchronous module loading.Chores
@eggjs/loader-fsfor loader consumers.