-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
docs(core): document loaderFS option #5950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 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 | | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve the grammar for the
Suggested change
|
||||||||||
| | loaderFS | `LoaderFS` | loader-facing filesystem abstraction used for discovery, file stats, JSON reads, and module loading | | ||||||||||
|
|
||||||||||
| ## Timing | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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, and module loading. | ||||||||||
| By default, Egg uses `RealLoaderFS`, which delegates to the local filesystem and keeps the existing runtime behavior. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description of
Suggested change
|
||||||||||
|
|
||||||||||
| ## CustomLoader | ||||||||||
|
|
||||||||||
| You can use `customLoader` instead of `loadToContext` and `loadToApp`. | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -500,6 +500,11 @@ app.loader.loadToApp(directory, 'model', { | |||||||||
| | app/middleware | false | | ||||||||||
| | app/service | true | | ||||||||||
|
|
||||||||||
| #### loaderFS [LoaderFS] | ||||||||||
|
|
||||||||||
| 自定义 `loadToApp` 和 `loadToContext` 使用的文件系统边界,用于文件发现、文件状态读取和模块加载。 | ||||||||||
| 默认使用 `RealLoaderFS`,它会委托给本地文件系统,以保持现有运行时行为。 | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议在
Suggested change
|
||||||||||
|
|
||||||||||
| ## CustomLoader | ||||||||||
|
|
||||||||||
| `loadToContext` 和 `loadToApp` 方法可以通过 `customLoader` 的配置来替代。 | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix grammar: "contain" should be "contains" when referring to the
optionsobject.