@modern-js/main-doc 2.21.1 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/docs/en/apis/app/commands.mdx +5 -5
- package/docs/en/apis/app/hooks/api/api.mdx +80 -0
- package/docs/en/apis/app/hooks/api/app.mdx +12 -0
- package/docs/en/apis/app/hooks/api/lambda.mdx +57 -0
- package/docs/en/apis/app/hooks/api/test.mdx +1 -1
- package/docs/en/apis/app/hooks/config/html.mdx +2 -2
- package/docs/en/apis/app/hooks/config/icon.mdx +19 -19
- package/docs/en/apis/app/hooks/config/mock.mdx +1 -1
- package/docs/en/apis/app/hooks/config/public.mdx +10 -10
- package/docs/en/apis/app/hooks/config/storybook.mdx +3 -3
- package/docs/en/apis/app/hooks/config/upload.mdx +13 -13
- package/docs/en/apis/app/hooks/modern-config.mdx +4 -4
- package/docs/en/apis/app/hooks/server/index_.mdx +2 -9
- package/docs/en/apis/app/hooks/server/test.mdx +5 -2
- package/docs/en/apis/app/hooks/shared.mdx +1 -1
- package/docs/en/apis/app/hooks/src/app.mdx +17 -27
- package/docs/en/apis/app/hooks/src/index_.mdx +6 -6
- package/docs/en/apis/app/hooks/src/pages.mdx +41 -37
- package/docs/en/apis/app/hooks/src/routes.mdx +16 -36
- package/docs/en/apis/app/hooks/src/server.mdx +1 -1
- package/docs/en/apis/app/hooks/src/stories.mdx +6 -3
- package/docs/en/apis/app/hooks/src/test.mdx +4 -3
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +5 -1
- package/docs/en/apis/app/runtime/web-server/hook.mdx +2 -2
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +2 -2
- package/docs/en/components/init-app.mdx +3 -3
- package/docs/en/components/init-rspack-app.mdx +4 -4
- package/docs/en/components/language-config.mdx +9 -0
- package/docs/en/components/package-manager.mdx +11 -0
- package/docs/en/components/ua-polyfill.mdx +2 -2
- package/docs/en/configure/app/source/config-dir.mdx +1 -1
- package/docs/en/configure/app/source/design-system.mdx +67 -67
- package/docs/en/configure/app/source/disable-default-entries.mdx +6 -5
- package/docs/en/configure/app/source/disable-entry-dirs.mdx +5 -5
- package/docs/en/configure/app/source/enable-async-entry.mdx +9 -9
- package/docs/en/configure/app/source/entries-dir.mdx +3 -3
- package/docs/en/configure/app/source/entries.mdx +21 -19
- package/docs/en/configure/app/tools/swc.mdx +2 -2
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -2
- package/docs/en/guides/advanced-features/bff/function.mdx +4 -4
- package/docs/en/guides/advanced-features/bff/type.mdx +5 -5
- package/docs/en/guides/advanced-features/rspack-start.mdx +6 -6
- package/docs/en/guides/advanced-features/ssg.mdx +2 -2
- package/docs/en/guides/advanced-features/testing.mdx +2 -2
- package/docs/en/guides/advanced-features/web-server.mdx +2 -2
- package/docs/en/guides/basic-features/css.mdx +2 -2
- package/docs/en/guides/basic-features/mock.mdx +1 -1
- package/docs/en/guides/basic-features/routes.mdx +11 -7
- package/docs/en/guides/concept/entries.mdx +3 -3
- package/docs/en/guides/topic-detail/generator/create/_category_.json +4 -0
- package/docs/en/guides/topic-detail/generator/create/config.mdx +75 -0
- package/docs/en/guides/topic-detail/generator/create/option.md +151 -0
- package/docs/en/guides/topic-detail/generator/create/use.mdx +66 -0
- package/docs/en/guides/topic-detail/generator/new/_category_.json +4 -0
- package/docs/en/guides/topic-detail/generator/new/config.md +155 -0
- package/docs/en/guides/topic-detail/generator/new/option.md +67 -0
- package/docs/en/guides/topic-detail/generator/new/use.md +95 -0
- package/docs/en/guides/topic-detail/generator/plugin/_category_.json +2 -2
- package/docs/en/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/api/afterForged.md +49 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/context.md +184 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/input.md +124 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
- package/docs/en/guides/topic-detail/generator/plugin/category.md +88 -0
- package/docs/en/guides/topic-detail/generator/plugin/context.md +104 -0
- package/docs/en/guides/topic-detail/generator/plugin/structure.md +106 -0
- package/docs/en/guides/topic-detail/generator/plugin/use.md +33 -0
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +8 -8
- package/docs/en/tutorials/first-app/c03-css.mdx +2 -2
- package/docs/en/tutorials/first-app/c08-entries.mdx +3 -3
- package/docs/zh/apis/app/commands.mdx +3 -3
- package/docs/zh/apis/app/hooks/api/{functions/api.mdx → api.mdx} +4 -4
- package/docs/zh/apis/app/hooks/api/app.mdx +12 -0
- package/docs/zh/apis/app/hooks/api/{framework/lambda.mdx → lambda.mdx} +5 -5
- package/docs/zh/apis/app/hooks/api/test.mdx +3 -3
- package/docs/zh/apis/app/hooks/config/icon.mdx +15 -15
- package/docs/zh/apis/app/hooks/config/mock.mdx +1 -1
- package/docs/zh/apis/app/hooks/config/public.mdx +3 -3
- package/docs/zh/apis/app/hooks/config/upload.mdx +1 -1
- package/docs/zh/apis/app/hooks/modern-config.mdx +3 -3
- package/docs/zh/apis/app/hooks/server/index_.mdx +1 -6
- package/docs/zh/apis/app/hooks/shared.mdx +1 -1
- package/docs/zh/apis/app/hooks/src/app.mdx +15 -25
- package/docs/zh/apis/app/hooks/src/index_.mdx +6 -6
- package/docs/zh/apis/app/hooks/src/pages.mdx +7 -3
- package/docs/zh/apis/app/hooks/src/routes.mdx +4 -4
- package/docs/zh/apis/app/hooks/src/stories.mdx +1 -1
- package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +5 -1
- package/docs/zh/components/language-config.mdx +9 -0
- package/docs/zh/components/package-manager.mdx +11 -0
- package/docs/zh/components/ua-polyfill.mdx +1 -1
- package/docs/zh/configure/app/source/design-system.mdx +3 -4
- package/docs/zh/configure/app/source/enable-async-entry.mdx +2 -5
- package/docs/zh/configure/app/source/entries.mdx +2 -2
- package/docs/zh/configure/app/tools/swc.mdx +2 -2
- package/docs/zh/guides/advanced-features/rspack-start.mdx +6 -6
- package/docs/zh/guides/advanced-features/ssg.mdx +1 -1
- package/docs/zh/guides/advanced-features/testing.mdx +2 -2
- package/docs/zh/guides/advanced-features/web-server.mdx +1 -1
- package/docs/zh/guides/basic-features/css.mdx +1 -1
- package/docs/zh/guides/basic-features/mock.mdx +1 -1
- package/docs/zh/guides/basic-features/routes.mdx +7 -4
- package/docs/zh/guides/concept/entries.mdx +3 -3
- package/docs/zh/guides/topic-detail/generator/create/_category_.json +4 -0
- package/docs/zh/guides/topic-detail/generator/create/config.mdx +76 -0
- package/docs/zh/guides/topic-detail/generator/create/option.md +151 -0
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +66 -0
- package/docs/zh/guides/topic-detail/generator/new/_category_.json +4 -0
- package/docs/zh/guides/topic-detail/generator/new/config.md +153 -0
- package/docs/zh/guides/topic-detail/generator/new/option.md +67 -0
- package/docs/zh/guides/topic-detail/generator/new/use.md +94 -0
- package/docs/zh/guides/topic-detail/generator/plugin/_category_.json +2 -2
- package/docs/zh/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
- package/docs/zh/guides/topic-detail/generator/plugin/api/afterForged.md +50 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/context.md +184 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/input.md +124 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
- package/docs/zh/guides/topic-detail/generator/plugin/category.md +93 -0
- package/docs/zh/guides/topic-detail/generator/plugin/context.md +105 -0
- package/docs/zh/guides/topic-detail/generator/plugin/structure.md +106 -0
- package/docs/zh/guides/topic-detail/generator/plugin/use.md +33 -0
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +4 -4
- package/docs/zh/guides/topic-detail/model/test-model.mdx +1 -1
- package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/docs/zh/tutorials/first-app/c08-entries.mdx +1 -1
- package/package.json +5 -5
- package/docs/en/apis/app/hooks/api/framework/_category_.json +0 -4
- package/docs/en/apis/app/hooks/api/framework/lambda.mdx +0 -57
- package/docs/en/apis/app/hooks/api/functions/_category_.json +0 -4
- package/docs/en/apis/app/hooks/api/functions/api.mdx +0 -81
- package/docs/en/apis/app/hooks/api/functions/app.mdx +0 -12
- package/docs/en/apis/app/hooks/api/functions/common.mdx +0 -9
- package/docs/en/guides/topic-detail/generator/codesmith/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
- package/docs/en/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
- package/docs/en/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
- package/docs/en/guides/topic-detail/generator/codesmith/api/git.mdx +0 -50
- package/docs/en/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -57
- package/docs/en/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
- package/docs/en/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -48
- package/docs/en/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
- package/docs/en/guides/topic-detail/generator/codesmith/introduce.mdx +0 -47
- package/docs/en/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
- package/docs/en/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
- package/docs/en/guides/topic-detail/generator/config/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/config/app.mdx +0 -82
- package/docs/en/guides/topic-detail/generator/config/common.mdx +0 -100
- package/docs/en/guides/topic-detail/generator/config/module.mdx +0 -42
- package/docs/en/guides/topic-detail/generator/config/monorepo.mdx +0 -28
- package/docs/en/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
- package/docs/en/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -58
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
- package/docs/en/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
- package/docs/en/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
- package/docs/en/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
- package/docs/en/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
- package/docs/en/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
- package/docs/en/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
- package/docs/en/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
- package/docs/en/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
- package/docs/en/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -55
- package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -55
- package/docs/en/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
- package/docs/en/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -31
- package/docs/en/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
- package/docs/en/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -90
- package/docs/en/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
- package/docs/en/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
- package/docs/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
- package/docs/en/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -18
- package/docs/en/guides/topic-detail/generator/plugin/develop.mdx +0 -125
- package/docs/en/guides/topic-detail/generator/plugin/use.mdx +0 -61
- package/docs/en/guides/topic-detail/generator/project.mdx +0 -118
- package/docs/zh/apis/app/hooks/api/framework/_category_.json +0 -4
- package/docs/zh/apis/app/hooks/api/functions/_category_.json +0 -4
- package/docs/zh/apis/app/hooks/api/functions/app.mdx +0 -12
- package/docs/zh/apis/app/hooks/api/functions/common.mdx +0 -9
- package/docs/zh/guides/topic-detail/generator/codesmith/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
- package/docs/zh/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
- package/docs/zh/guides/topic-detail/generator/codesmith/api/git.mdx +0 -49
- package/docs/zh/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -47
- package/docs/zh/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
- package/docs/zh/guides/topic-detail/generator/codesmith/introduce.mdx +0 -59
- package/docs/zh/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
- package/docs/zh/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
- package/docs/zh/guides/topic-detail/generator/config/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/config/app.mdx +0 -82
- package/docs/zh/guides/topic-detail/generator/config/common.mdx +0 -100
- package/docs/zh/guides/topic-detail/generator/config/module.mdx +0 -42
- package/docs/zh/guides/topic-detail/generator/config/monorepo.mdx +0 -28
- package/docs/zh/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -55
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -57
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -29
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
- package/docs/zh/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -92
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
- package/docs/zh/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/develop.mdx +0 -125
- package/docs/zh/guides/topic-detail/generator/plugin/use.mdx +0 -61
- package/docs/zh/guides/topic-detail/generator/project.mdx +0 -118
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @modern-js/main-doc
|
2
2
|
|
3
|
+
## 2.22.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 7d1b96e: feat(changeset): optimize release note display
|
8
|
+
|
9
|
+
feat(changeset): 优化生成 Release Note 文案
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 3c3d1e2: docs: update project creation and new command text.
|
14
|
+
|
15
|
+
docs: 更新生成器创建项目和 new 命令文案。
|
16
|
+
|
17
|
+
- Updated dependencies [850cde6]
|
18
|
+
- Updated dependencies [e7a5f94]
|
19
|
+
- @modern-js/builder-doc@2.22.0
|
20
|
+
|
3
21
|
## 2.21.1
|
4
22
|
|
5
23
|
### Patch Changes
|
@@ -125,9 +125,9 @@ In the project, execute the `new` command to add entries as follows:
|
|
125
125
|
|
126
126
|
```bash
|
127
127
|
$ npx modern new
|
128
|
-
?
|
129
|
-
?
|
130
|
-
?
|
128
|
+
? Please select the operation you want: Create Element
|
129
|
+
? Please select the type of element to create: New "entry"
|
130
|
+
? Please fill in the entry name: entry
|
131
131
|
```
|
132
132
|
|
133
133
|
### Enable Features
|
@@ -136,8 +136,8 @@ In the project, execute the `new` command to enable features as follows:
|
|
136
136
|
|
137
137
|
```bash
|
138
138
|
$ npx modern new
|
139
|
-
?
|
140
|
-
?
|
139
|
+
? Please select the operation you want: Enable features
|
140
|
+
? Please select the feature name: (Use arrow keys)
|
141
141
|
❯ Enable Tailwind CSS
|
142
142
|
Enable BFF
|
143
143
|
Enable SSG
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
title: '**/*.[tj]s'
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
# **/*.[tj]s
|
6
|
+
|
7
|
+
Files that declare API routes in the [BFF Function Mode](/guides/advanced-features/bff/type.html#function-mode). Except for some [convention files](/apis/app/hooks/api/api#allow-list), files in the `api` directory will be registered as the routes.
|
8
|
+
|
9
|
+
:::info
|
10
|
+
Using the `api` directory requires enabling the BFF feature, and you need to run the `new` command in the project to enable the "BFF" feature.
|
11
|
+
|
12
|
+
This file supports using the `js` or `ts` language, but you must use `esm` syntax to export functions.
|
13
|
+
|
14
|
+
:::
|
15
|
+
|
16
|
+
## Routing File Convention
|
17
|
+
|
18
|
+
### Default Routing
|
19
|
+
|
20
|
+
The routing system will map files named `index` to the previous directory.
|
21
|
+
|
22
|
+
- `api/index.ts` -> `$BASENAME/`
|
23
|
+
- `api/user/index.ts` -> `$BASENAME/user`
|
24
|
+
|
25
|
+
### Nested Routing
|
26
|
+
|
27
|
+
The routing system also supports parsing nested files. If you create a nested folder structure, the files will still automatically resolve routes in the same way.
|
28
|
+
|
29
|
+
- `api/hello.ts` -> `$BASENAME/hello`
|
30
|
+
- `api/user/list.ts` -> `$BASENAME/user/list`
|
31
|
+
|
32
|
+
### Dynamic Routing
|
33
|
+
|
34
|
+
The routing system supports generating dynamic routes through file directories named with `[]`.
|
35
|
+
|
36
|
+
- `api/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
|
37
|
+
- `api/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
|
38
|
+
- `api/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
|
39
|
+
|
40
|
+
The `$BASENAME` can be configured in `modern.config.js`, and the default value is `/api`.
|
41
|
+
|
42
|
+
### Allow List
|
43
|
+
|
44
|
+
By default, all files in the `api` directory will be parsed as BFF function files, but we also set a white list for these files that are not parsed:
|
45
|
+
|
46
|
+
- Files whose names start with `_`. For example: `_utils.ts`.
|
47
|
+
- All files in folders whose names start with `_`. For example: `_utils/index.ts`, `_utils/cp.ts`.
|
48
|
+
- Test files. For example: `foo.test.ts`.
|
49
|
+
- TypeScript type files. For example: `hello.d.ts`.
|
50
|
+
- Files under `node_modules`.
|
51
|
+
|
52
|
+
## Function Definition
|
53
|
+
|
54
|
+
In addition to the routing rules above, there are also conventions for function definitions and exports in the code.
|
55
|
+
|
56
|
+
Functions are exported by name, and the name of the exported function is the HTTP method accepted by the corresponding interface, that is:
|
57
|
+
|
58
|
+
```ts
|
59
|
+
export const get = async () => {
|
60
|
+
return {
|
61
|
+
name: 'Modern.js',
|
62
|
+
desc: 'Modern web Solutions',
|
63
|
+
};
|
64
|
+
};
|
65
|
+
```
|
66
|
+
|
67
|
+
By exporting functions in this way, you will get a `GET` interface.
|
68
|
+
|
69
|
+
The application project supports 9 Method definitions, namely: `GET`, `POST`, `PUT`, `DELETE`, `CONNECT`, `TRACE`, `PATCH`, `OPTION`, `HEAD`, that is, these Methods can be used as the names of the exported functions.
|
70
|
+
|
71
|
+
The name is case-insensitive, that is, if it is `GET`, it can be written as `get`, `Get`, `GEt`, `GET`, all of which can be accurately recognized. The default export, that is, `export default xxx`, will be mapped to `Get`.
|
72
|
+
|
73
|
+
Because `delete` is a keyword in JavaScript, you can use `del` or `DELETE` instead.
|
74
|
+
|
75
|
+
Multiple functions with different Methods can be defined in one file, but if multiple functions with the same Method are defined, only the first one will take effect.
|
76
|
+
|
77
|
+
:::info
|
78
|
+
It should be noted that the defined functions should all be asynchronous, which is related to the type when calling the function.
|
79
|
+
|
80
|
+
:::
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
title: _app.[tj]s
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
# _app.[tj]s
|
6
|
+
|
7
|
+
In the [BFF Function Mode](/guides/advanced-features/bff/type.html#function-mode), this file can add pre-middleware for BFF functions.
|
8
|
+
|
9
|
+
:::note
|
10
|
+
For specific examples, please refer to [hook](/apis/app/runtime/bff/hook).
|
11
|
+
|
12
|
+
:::
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
title: lambda/*.[tj]s
|
3
|
+
sidebar_position: 3
|
4
|
+
---
|
5
|
+
# lambda/*.[tj]s
|
6
|
+
|
7
|
+
Files that declare API routes under the [BFF Framework Mode](/guides/advanced-features/bff/type.html#framework-mode). Except for [convention files](/apis/app/hooks/api/api#allow-list), files under the `lambda/` directory will be registered as the routes.
|
8
|
+
|
9
|
+
:::info
|
10
|
+
Using the `api` directory requires enabling the BFF function, and you need to run the new command to enable the "BFF" function under the project.
|
11
|
+
|
12
|
+
:::
|
13
|
+
|
14
|
+
:::tip
|
15
|
+
This file supports using `js` or `ts` language, but must export functions using `esm` syntax.
|
16
|
+
|
17
|
+
:::
|
18
|
+
|
19
|
+
## Routing File Convention
|
20
|
+
|
21
|
+
### Default Routing
|
22
|
+
|
23
|
+
The routing system will map files named `index` to the previous directory.
|
24
|
+
|
25
|
+
- `api/lambda/index.ts` -> `$BASENAME/`
|
26
|
+
- `api/lambda/user/index.ts` -> `$BASENAME/user`
|
27
|
+
|
28
|
+
### Nested Routing
|
29
|
+
|
30
|
+
The routing system also supports parsing nested files. If you create a nested folder structure, the files will still automatically resolve routes in the same way.
|
31
|
+
|
32
|
+
- `api/lambda/hello.ts` -> `$BASENAME/hello`
|
33
|
+
- `api/lambda/user/list.ts` -> `$BASENAME/user/list`
|
34
|
+
|
35
|
+
### Dynamic Routing
|
36
|
+
|
37
|
+
The routing system supports generating dynamic routes through file directories named with `[]`.
|
38
|
+
|
39
|
+
- `api/lambda/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
|
40
|
+
- `api/lambda/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
|
41
|
+
- `api/lambda/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
|
42
|
+
|
43
|
+
The `$BASENAME` can be configured in `modern.config.js`, and the default value is `/api`.
|
44
|
+
|
45
|
+
### Allow List
|
46
|
+
|
47
|
+
By default, all files in the `lambda` directory are parsed as BFF function files, but we also set up a whitelist so that these files are not parsed:
|
48
|
+
|
49
|
+
- Files named starting with `_`. For example: `_utils.ts`.
|
50
|
+
- All files in a folder named starting with `_`. For example: `_utils/index.ts`, `_utils/cp.ts`.
|
51
|
+
- Test files. For example: `foo.test.ts`.
|
52
|
+
- TypeScript type files. For example: `hello.d.ts`.
|
53
|
+
- Files under `node_module`.
|
54
|
+
|
55
|
+
## Function Definition
|
56
|
+
|
57
|
+
Completely consistent with the [Function Definition](/apis/app/hooks/api/api#function-definition) under the function mode.
|
@@ -4,6 +4,6 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# html/
|
6
6
|
|
7
|
-
|
7
|
+
You can inject custom HTML fragments at different locations of the default internal HTML template through the `config/html` directory.
|
8
8
|
|
9
|
-
For
|
9
|
+
For specific usage, please refer to: [Custom HTML](/guides/basic-features/html).
|
@@ -1,20 +1,20 @@
|
|
1
1
|
---
|
2
|
-
title: icon
|
2
|
+
title: icon/
|
3
3
|
sidebar_position: 2
|
4
4
|
---
|
5
5
|
|
6
|
-
#
|
6
|
+
# icon/
|
7
7
|
|
8
|
-
##
|
8
|
+
## Favicon
|
9
9
|
|
10
|
-
When there is a `favicon.*` file in the `config` directory of the project
|
10
|
+
When there is a `favicon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.favicon](/configure/app/html/favicon) configuration item for generating the favicon icon on the page:
|
11
11
|
|
12
12
|
```
|
13
13
|
./config
|
14
14
|
└── favicon.ico
|
15
15
|
```
|
16
16
|
|
17
|
-
After the build is
|
17
|
+
After the build is completed, you can see the following tags automatically generated in HTML:
|
18
18
|
|
19
19
|
```html
|
20
20
|
<link rel="icon" href="/favicon.ico" />
|
@@ -24,22 +24,22 @@ After the build is complete, you can see that the following tags are automatical
|
|
24
24
|
|
25
25
|
When setting up the favicon, Modern.js looks for files in the following order:
|
26
26
|
|
27
|
-
- favicon.png
|
28
|
-
- favicon.jpg
|
29
|
-
- favicon.jpeg
|
30
|
-
- favicon.svg
|
31
|
-
- favicon.ico
|
27
|
+
- `favicon.png`
|
28
|
+
- `favicon.jpg`
|
29
|
+
- `favicon.jpeg`
|
30
|
+
- `favicon.svg`
|
31
|
+
- `favicon.ico`
|
32
32
|
|
33
|
-
##
|
33
|
+
## Apple Touch Icon
|
34
34
|
|
35
|
-
When there is an `icon.*` file in the `config` directory of the project
|
35
|
+
When there is an `icon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.appIcon](/configure/app/html/app-icon) configuration item for generating the Apple Touch Icon icon under the iOS system.
|
36
36
|
|
37
37
|
```
|
38
38
|
./config
|
39
39
|
└── icon.png
|
40
40
|
```
|
41
41
|
|
42
|
-
After the build is
|
42
|
+
After the build is completed, you can see the following tags automatically generated in HTML:
|
43
43
|
|
44
44
|
```html
|
45
45
|
<link rel="apple-touch-icon" sizes="180*180" href="/static/image/icon.png" />
|
@@ -47,10 +47,10 @@ After the build is complete, you can see that the following tags are automatical
|
|
47
47
|
|
48
48
|
### Order
|
49
49
|
|
50
|
-
When setting the app icon, Modern.js looks for files in the following order:
|
50
|
+
When setting up the app icon, Modern.js looks for files in the following order:
|
51
51
|
|
52
|
-
- icon.png
|
53
|
-
- icon.jpg
|
54
|
-
- icon.jpeg
|
55
|
-
- icon.svg
|
56
|
-
- icon.ico
|
52
|
+
- `icon.png`
|
53
|
+
- `icon.jpg`
|
54
|
+
- `icon.jpeg`
|
55
|
+
- `icon.svg`
|
56
|
+
- `icon.ico`
|
@@ -4,4 +4,4 @@ sidebar_position: 5
|
|
4
4
|
---
|
5
5
|
# mock/
|
6
6
|
|
7
|
-
|
7
|
+
When there is a `config/mock/index.js` file in the project directory, Modern.js will automatically enable the Mock service during development.
|
@@ -4,27 +4,27 @@ sidebar_position: 3
|
|
4
4
|
---
|
5
5
|
# public/
|
6
6
|
|
7
|
-
|
7
|
+
Any static resource files can be placed in the `public/` directory, and the files will be deployed to the corresponding application domain by the server.
|
8
8
|
|
9
9
|
## Description
|
10
10
|
|
11
|
-
The routing
|
11
|
+
The file routing is based on the convention of the directory structure, where `public/` is the root directory corresponding to the root path of the Web application.
|
12
12
|
|
13
|
-
For example, the `config/public/sdk/index.js` file will be
|
13
|
+
For example, the `config/public/sdk/index.js` file will be deployed under `${domain}/sdk/index.js` after deployment.
|
14
14
|
|
15
|
-
##
|
15
|
+
## Scenarios
|
16
16
|
|
17
|
-
For example, `robots.txt
|
17
|
+
For example, authentication files required by third-party systems such as `robots.txt` and `auth.xml`.
|
18
18
|
|
19
|
-
|
19
|
+
Or SDKs for other business parties (requiring unchanged routing), or HTML files without entry.
|
20
20
|
|
21
21
|
:::info
|
22
|
-
For static resources (such as SVG
|
22
|
+
For static resources (such as SVG images) that need to be imported through import in the source code, it is recommended to manage them in the `src/assets` directory.
|
23
23
|
|
24
24
|
:::
|
25
25
|
|
26
|
-
## Compression
|
26
|
+
## Code Compression
|
27
27
|
|
28
|
-
If the file is a `.js` file, it will be automatically compressed
|
28
|
+
If the file in the directory is a `.js` file, it will be automatically compressed during production environment construction.
|
29
29
|
|
30
|
-
If the file ends with `.min.js`, it will not
|
30
|
+
If the file ends with `.min.js`, it will not be compressed.
|
@@ -4,11 +4,11 @@ sidebar_position: 7
|
|
4
4
|
---
|
5
5
|
# storybook/
|
6
6
|
|
7
|
-
Modern.js
|
7
|
+
Modern.js supports debugging using Storybook. When configuring Storybook, you need to configure it in the `config/storybook` directory of the project.
|
8
8
|
|
9
|
-
|
9
|
+
Please refer to [Storybook Configuration](https://storybook.js.org/docs/react/configure/overview) for Storybook configuration.
|
10
10
|
|
11
11
|
:::info
|
12
|
-
|
12
|
+
Enabling the Visual Testing (Storybook) mode function requires running the new command to enable it under the project first.
|
13
13
|
|
14
14
|
:::
|
@@ -4,29 +4,29 @@ sidebar_position: 4
|
|
4
4
|
---
|
5
5
|
# upload/
|
6
6
|
|
7
|
-
|
7
|
+
Any static resource files can be placed in the `upload/` directory.
|
8
8
|
|
9
9
|
## Description
|
10
10
|
|
11
|
-
In the development environment, the static resource files in this directory will be hosted
|
11
|
+
In the development environment, the static resource files in this directory will be hosted under the `/upload` path. After building the application, the files in this directory will be copied to the dist directory.
|
12
12
|
|
13
|
-
This file convention is mainly used for developers to use plugins to upload static resource files to the CDN.
|
13
|
+
This file convention is mainly used for developers to use plugins to proactively upload static resource files to the CDN.
|
14
14
|
|
15
|
-
##
|
15
|
+
## Scenarios
|
16
16
|
|
17
|
-
For example,
|
17
|
+
For example, SDKs for project use only, such as `google-analysis.js` (usually requires HTTP caching).
|
18
18
|
|
19
|
-
|
19
|
+
Pictures, font files, common CSS, etc.
|
20
20
|
|
21
|
-
## Compression
|
21
|
+
## Code Compression
|
22
22
|
|
23
|
-
If the file is a `.js` file, it will be automatically compressed
|
23
|
+
If the file in the directory is a `.js` file, it will be automatically compressed during production environment construction.
|
24
24
|
|
25
|
-
If the file ends with `.min.js`, it will not
|
25
|
+
If the file ends with `.min.js`, it will not be compressed.
|
26
26
|
|
27
27
|
## More Usage
|
28
28
|
|
29
|
-
In React components,
|
29
|
+
In React components, you can add this prefix through [Environment Variables](/guides/basic-features/env-vars.html#asset_prefix):
|
30
30
|
|
31
31
|
```tsx
|
32
32
|
export default () => {
|
@@ -36,19 +36,19 @@ export default () => {
|
|
36
36
|
};
|
37
37
|
```
|
38
38
|
|
39
|
-
|
39
|
+
In addition, whether it is in [Custom HTML](/guides/basic-features/html) or any HTML file under [`config/public/`](/apis/app/hooks/config/public), you can directly use HTML tags to reference resources in the `config/upload/` directory:
|
40
40
|
|
41
41
|
```html
|
42
42
|
<script src="/upload/index.js"></script>
|
43
43
|
```
|
44
44
|
|
45
|
-
|
45
|
+
If you set the [`dev.assetPrefix`](/configure/app/dev/asset-prefix) or [`output.assetPrefix`](/configure/app/output/asset-prefix) prefix, you can also use template syntax to add the prefix directly:
|
46
46
|
|
47
47
|
```html
|
48
48
|
<script src="<%=assetPrefix %>/upload/index.js"></script>
|
49
49
|
```
|
50
50
|
|
51
51
|
:::info
|
52
|
-
Modern.js does not support
|
52
|
+
Modern.js does not support using files under `config/upload/` through URLs in `config/public/*.css` (such as background-image).
|
53
53
|
|
54
54
|
:::
|
@@ -1,9 +1,9 @@
|
|
1
1
|
---
|
2
|
-
title: modern.config.
|
2
|
+
title: modern.config.[tj]s
|
3
3
|
sidebar_position: 8
|
4
4
|
---
|
5
|
-
# modern.config.
|
5
|
+
# modern.config.[tj]s
|
6
6
|
|
7
|
-
Modern.js
|
7
|
+
The Modern.js configuration file. Through this file, you can personalize the configuration of various aspects of the current project.
|
8
8
|
|
9
|
-
|
9
|
+
To learn more about how to use the configuration, please refer to [Configuration Usage](/configure/app/usage).
|
@@ -5,13 +5,6 @@ sidebar_position: 1
|
|
5
5
|
|
6
6
|
# index.[tj]s
|
7
7
|
|
8
|
-
A file that extends the Modern.js Web Server
|
8
|
+
A file that extends the Modern.js Web Server. You can add [Hooks](/apis/app/runtime/web-server/hook) or [Middleware](/apis/app/runtime/web-server/middleware) to the Web Server started by the application project in this file.
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
It can also be inserted logic into the built-in processing handler (including route matching, resource addressing, header injection, page rendering, static web hosting).
|
13
|
-
|
14
|
-
:::info
|
15
|
-
For detail, see [Hook](/apis/app/runtime/web-server/hook) & [Middleware](/apis/app/runtime/web-server/middleware).
|
16
|
-
|
17
|
-
:::
|
10
|
+
You can intercept and process requests and responses, perform authentication and role verification, preprocess requests, and catch exceptions. You can also insert specific business logic into the built-in processing logic (including route matching, resource addressing, header injection, page rendering, and static web hosting).
|
@@ -2,11 +2,14 @@
|
|
2
2
|
title: test.[tj]s
|
3
3
|
sidebar_position: 2
|
4
4
|
---
|
5
|
+
|
5
6
|
# test.[tj]s
|
6
7
|
|
7
|
-
|
8
|
+
Custom Web Server test directory.
|
9
|
+
|
10
|
+
The application supports testing custom Web Server. You can directly create files with the suffix `.test.[tj]s` under the `server/` directory of the project to write test cases.
|
8
11
|
|
9
12
|
:::info
|
10
|
-
|
13
|
+
Enabling unit testing and integration testing requires running the `new` command to enable the "Unit Testing/Integration Testing" function under the project first.
|
11
14
|
|
12
15
|
:::
|
@@ -4,4 +4,4 @@ sidebar_position: 5
|
|
4
4
|
---
|
5
5
|
# shared/
|
6
6
|
|
7
|
-
Shared directory. When
|
7
|
+
Shared source code directory. When there is common code in `api/`, `server/`, and `src/` in the project, you can put these codes in the `shared` directory instead of directly referencing them.
|
@@ -4,51 +4,41 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# App.[tj]sx
|
6
6
|
|
7
|
-
|
7
|
+
The identifier for the entry points when the application uses [Self-controlled Routing](/guides/basic-features/routes.html#self-controlled-routing).
|
8
8
|
|
9
|
-
`App.[tj]sx` is not the actual
|
9
|
+
`App.[tj]sx` is not the actual entry. Modern.js will generate the real entry for application. The content is roughly as follows:
|
10
10
|
|
11
11
|
```js
|
12
12
|
import React from 'react';
|
13
|
+
import ReactDOM from 'react-dom/client';
|
13
14
|
import { createApp, bootstrap } from '@modern-js/runtime';
|
14
15
|
// App.[jt]sx
|
15
16
|
import App from '@_modern_js_src/App';
|
16
|
-
|
17
|
-
import {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
} from '@modern-js/runtime/model';
|
23
|
-
|
24
|
-
const createStatePlugins = config => {
|
25
|
-
const plugins = [];
|
26
|
-
plugins.push(immer(config['immer']));
|
27
|
-
plugins.push(effects(config['effects']));
|
28
|
-
plugins.push(autoActions(config['autoActions']));
|
29
|
-
plugins.push(devtools(config['devtools']));
|
30
|
-
return plugins;
|
31
|
-
};
|
17
|
+
// runtime plugin
|
18
|
+
import { router } from '@modern-js/runtime/plugins';
|
19
|
+
|
20
|
+
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
21
|
+
const MOUNT_ID = 'root';
|
22
|
+
|
32
23
|
let AppWrapper = null;
|
24
|
+
|
33
25
|
function render() {
|
34
26
|
AppWrapper = createApp({
|
35
27
|
plugins: [
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}),
|
40
|
-
],
|
41
|
-
})(App);
|
28
|
+
router({...{"serverBase":["/"]}, ...App.config?.router}),
|
29
|
+
]
|
30
|
+
})(App)
|
42
31
|
if (IS_BROWSER) {
|
43
|
-
bootstrap(AppWrapper, MOUNT_ID);
|
32
|
+
bootstrap(AppWrapper, MOUNT_ID, null, ReactDOM);
|
44
33
|
}
|
45
|
-
return AppWrapper
|
34
|
+
return AppWrapper
|
46
35
|
}
|
36
|
+
|
47
37
|
AppWrapper = render();
|
48
38
|
export default AppWrapper;
|
49
39
|
```
|
50
40
|
|
51
41
|
:::note
|
52
|
-
In multi-entry
|
42
|
+
In the multi-entry scenario, each entry can have its own `App.[jt]sx`. See [Entries](/guides/concept/entries) for details.
|
53
43
|
|
54
44
|
:::
|
@@ -4,13 +4,13 @@ sidebar_position: 4
|
|
4
4
|
---
|
5
5
|
# index.[tj]s
|
6
6
|
|
7
|
-
|
7
|
+
The identifier for the entry point when the application uses custom `bootstrap`.
|
8
8
|
|
9
|
-
When we need to add custom behavior before `bootstrap` or completely take over the webpack entry, we can place `index.[tj]s` in `src
|
9
|
+
In general, the [`App.[tj]sx`](/apis/app/hooks/src/app) hook file can already meet our needs. When we need to add custom behavior before `bootstrap` or completely take over the webpack packaging entry, we can place `index.[tj]s` in the `src` or entry directory. There are two cases below:
|
10
10
|
|
11
|
-
|
11
|
+
## Add custom behavior before bootstrap
|
12
12
|
|
13
|
-
Just
|
13
|
+
Just export a function in `src/index.[tj]s`:
|
14
14
|
|
15
15
|
```js title=src/index.js
|
16
16
|
import { bootstrap } from '@modern-js/runtime';
|
@@ -21,9 +21,9 @@ export default App => {
|
|
21
21
|
};
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
## Completely take over the webpack entry
|
25
25
|
|
26
|
-
When there is no default export function
|
26
|
+
When there is no default export function in `src/index.[tj]sx?`, the file is the real webpack packaging entry file and the code can be organized directly as using create-react-app and other scaffolding tools:
|
27
27
|
|
28
28
|
```js title=src/index.jsx
|
29
29
|
import React from 'react';
|