diff --git a/packages/core/README.md b/packages/core/README.md index 72f6768feb..8da1cf2126 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -224,18 +224,19 @@ await this.loadExtend('application', app); ### LoaderOptions -| Param | Type | Description | -| ----------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- | -| directory | `String/Array` | directories to be loaded | -| target | `Object` | attach the target object from loaded files | -| match | `String/Array` | match the files when load, default to `**/*.js`(if process.env.EGG\*TYPESCRIPT was true, default to `[ '\*\*/\_.(js | ts)', '!\*_/_.d.ts' ]`) | -| ignore | `String/Array` | ignore the files when load | -| initializer | `Function` | custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an `options` object that contain `path` | -| caseStyle | `String/Function` | set property's case when converting a filepath to property list. | -| override | `Boolean` | determine whether override the property when get the same name | -| call | `Boolean` | determine whether invoke when exports is function | -| inject | `Object` | an object that be the argument when invoke the function | -| filter | `Function` | a function that filter the exports which can be loaded | +| Param | Type | Description | +| ----------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| directory | `String/Array` | directories to be loaded | +| target | `Object` | attach the target object from loaded files | +| match | `String/Array` | match the files when load, default to `**/*.js` (if `process.env.EGG_TYPESCRIPT` is true, default to `[ '**/*.(js\|ts)', '!**/*.d.ts' ]`) | +| ignore | `String/Array` | ignore the files when load | +| initializer | `Function` | custom file exports, receive two parameters, first is the inject object (if not js file, will be content buffer), second is an `options` object that contains `path` | +| caseStyle | `String/Function` | set property's case when converting a filepath to property list | +| override | `Boolean` | determine whether override the property when get the same name | +| call | `Boolean` | determine whether invoke when exports is function | +| inject | `Object` | an object that is the argument when invoking the function | +| filter | `Function` | a function that filters the exports which can be loaded | +| loaderFS | `LoaderFS` | loader-facing filesystem abstraction used for discovery, file stats, JSON reads, and module loading | ## Timing diff --git a/site/docs/advanced/loader.md b/site/docs/advanced/loader.md index 81857636ce..430feca550 100644 --- a/site/docs/advanced/loader.md +++ b/site/docs/advanced/loader.md @@ -495,6 +495,11 @@ Loading different files uses different configurations: | app/middleware | false | | app/service | true | +#### `loaderFS [LoaderFS]` + +Customize the filesystem boundary used by `loadToApp` and `loadToContext` for file discovery, file stats, JSON reads, and module loading. +By default, Egg uses `RealLoaderFS`, which delegates to the local filesystem and keeps the existing runtime behavior. + ## CustomLoader You can use `customLoader` instead of `loadToContext` and `loadToApp`. diff --git a/site/docs/zh-CN/advanced/loader.md b/site/docs/zh-CN/advanced/loader.md index 8afec3f6a7..d357b0d79b 100644 --- a/site/docs/zh-CN/advanced/loader.md +++ b/site/docs/zh-CN/advanced/loader.md @@ -500,6 +500,11 @@ app.loader.loadToApp(directory, 'model', { | app/middleware | false | | app/service | true | +#### loaderFS [LoaderFS] + +自定义 `loadToApp` 和 `loadToContext` 使用的文件系统边界,用于文件发现、文件状态读取、JSON 读取和模块加载。 +默认使用 `RealLoaderFS`,它会委托给本地文件系统,以保持现有运行时行为。 + ## CustomLoader `loadToContext` 和 `loadToApp` 方法可以通过 `customLoader` 的配置来替代。 diff --git a/wiki/log.md b/wiki/log.md index 50d72d6823..c2357dfbe7 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -2,6 +2,12 @@ Dates use the workspace-local Asia/Shanghai calendar date. +## [2026-05-13] docs | sync LoaderFS loader option docs + +- sources referenced: `packages/core/src/loader/loader_fs.ts`, `packages/core/src/loader/file_loader.ts`, `packages/core/src/loader/egg_loader.ts` +- pages updated: `packages/core/README.md`, `site/docs/advanced/loader.md`, `site/docs/zh-CN/advanced/loader.md`, `wiki/packages/core.md`, `wiki/log.md` +- note: Added the public `loaderFS` LoaderOptions entry to core and site loader docs, and refreshed the core wiki page to point at those docs. + ## [2026-05-07] package | document core LoaderFS boundary - sources touched: `packages/core/src/index.ts`, `packages/core/src/loader/loader_fs.ts`, `packages/core/src/loader/file_loader.ts`, `packages/core/src/loader/context_loader.ts`, `packages/core/src/loader/egg_loader.ts` diff --git a/wiki/packages/core.md b/wiki/packages/core.md index 4bf8ae0332..d102a081d3 100644 --- a/wiki/packages/core.md +++ b/wiki/packages/core.md @@ -3,12 +3,15 @@ title: Core Package type: package summary: Loader, lifecycle, and application core primitives used by Egg runtime packages. source_files: + - packages/core/README.md - packages/core/src/index.ts - packages/core/src/loader/loader_fs.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 + - site/docs/advanced/loader.md + - site/docs/zh-CN/advanced/loader.md +updated_at: 2026-05-13 status: active --- @@ -33,3 +36,6 @@ runtime behavior by delegating to `fs.existsSync`, `fs.statSync`, custom `loaderFS`. `EggLoader` passes its loader FS into `loadToApp()` and `loadToContext()` so later bundled loaders can replace file discovery and module loading without changing the public loader call sites. + +The public loader docs now list `loaderFS` with the other `LoaderOptions` so +custom loader filesystem implementations are discoverable for advanced users.