@modern-js/main-doc 2.21.1 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -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/debug-app.mdx +1 -1
- package/docs/en/components/deploy.mdx +1 -0
- package/docs/en/components/entry-mode.mdx +0 -0
- package/docs/en/components/init-app.mdx +6 -10
- 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/release-note.mdx +1 -0
- package/docs/en/components/ua-polyfill.mdx +2 -2
- package/docs/en/configure/app/output/css-modules.mdx +13 -0
- 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 -16
- 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 +7 -8
- 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/builder.mdx +15 -15
- package/docs/en/guides/concept/entries.mdx +50 -49
- package/docs/en/guides/get-started/glossary.mdx +12 -12
- package/docs/en/guides/get-started/introduction.mdx +17 -20
- package/docs/en/guides/get-started/quick-start.mdx +21 -37
- package/docs/en/guides/get-started/upgrade.mdx +15 -13
- package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
- package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
- package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
- package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
- package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
- package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
- package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
- package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
- package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
- package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
- 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/guides/troubleshooting/builder.mdx +8 -0
- 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/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/community/contributing-guide.mdx +1 -1
- package/docs/zh/components/entry-mode.mdx +0 -0
- package/docs/zh/components/init-app.mdx +5 -9
- 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/output/css-modules.mdx +13 -0
- 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 -16
- package/docs/zh/guides/advanced-features/rspack-start.mdx +7 -8
- 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/builder.mdx +1 -1
- package/docs/zh/guides/concept/entries.mdx +21 -17
- package/docs/zh/guides/get-started/quick-start.mdx +7 -10
- package/docs/zh/guides/get-started/upgrade.mdx +1 -1
- package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
- package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
- package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
- package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
- package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
- package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
- package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
- package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
- package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
- 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/guides/troubleshooting/builder.mdx +8 -0
- 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
|
@@ -19,23 +19,9 @@ When using Rspack as the bundler, SWC will be used for transpiling and compressi
|
|
|
19
19
|
|
|
20
20
|
## Install
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
import EnableSWC from '@modern-js/builder-doc/docs/en/shared/enable-swc.md';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
? Action: Enable features
|
|
26
|
-
? Enable features: Enable SWC Compile
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
After the installation, please register the SWC plugin in the `modern.config.ts` file, then the SWC compilation and compression will be enabled.
|
|
30
|
-
|
|
31
|
-
```ts title="modern.config.ts"
|
|
32
|
-
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
33
|
-
import swcPlugin from '@modern-js/plugin-swc';
|
|
34
|
-
|
|
35
|
-
export default defineConfig({
|
|
36
|
-
plugins: [appTools(), swcPlugin()],
|
|
37
|
-
});
|
|
38
|
-
```
|
|
24
|
+
<EnableSWC />
|
|
39
25
|
|
|
40
26
|
## Config
|
|
41
27
|
|
|
@@ -6,7 +6,7 @@ title: Frameworks
|
|
|
6
6
|
|
|
7
7
|
Modern.js's BFF supports different runtime frameworks, currently Modern.js's BFF supports two runtime frameworks[Express.js](https://expressjs.com/) 和 [Koa.js](https://koajs.com/).
|
|
8
8
|
|
|
9
|
-
## Function
|
|
9
|
+
## Function Mode
|
|
10
10
|
|
|
11
11
|
Under the function writing, only the middleware writing method of various runtime frameworks is different, and other implementations are basically the same. Take Express as an example to introduce how to write a middleware by hand in the `api/_ app.ts` and add permission verification:
|
|
12
12
|
|
|
@@ -96,7 +96,7 @@ Refresh the page and you can see that `/api/hello` was accessed successfully:
|
|
|
96
96
|
|
|
97
97
|
The above code simulates the way to add middleware to the `/api/_app.ts` to achieve an easy login function. Also, other functions can be implemented in this hook file to extend BFF Server.
|
|
98
98
|
|
|
99
|
-
## Framework
|
|
99
|
+
## Framework Mode
|
|
100
100
|
|
|
101
101
|
Under the framework writing, Modern.js does not collect middleware in the `api/_app.ts`, and the running process is controlled by the plugin itself.
|
|
102
102
|
|
|
@@ -51,10 +51,10 @@ Execute `pnpm run dev`, then open `http://localhost:8080/` to see that the page
|
|
|
51
51
|
|
|
52
52
|
In Modern.js, the BFF function routing system is implemented based on the file system, and it is also a conventional routing system.
|
|
53
53
|
|
|
54
|
-
In **Function
|
|
54
|
+
In **Function Mode**, All files under `api/` will map to an interface. In **Framework Mode**, All files under `api/lambda` will map to an interface
|
|
55
55
|
|
|
56
56
|
:::note
|
|
57
|
-
Function
|
|
57
|
+
Function Mode & Framework Mode will introduce soon.
|
|
58
58
|
|
|
59
59
|
:::
|
|
60
60
|
|
|
@@ -69,14 +69,14 @@ Files named `index.[jt]s` are mapped to the previous directory.
|
|
|
69
69
|
- `api/index.ts` -> `{prefix}/`
|
|
70
70
|
- `api/user/index.ts` -> `{prefix}/user`
|
|
71
71
|
|
|
72
|
-
### Multi-layer
|
|
72
|
+
### Multi-layer Routing
|
|
73
73
|
|
|
74
74
|
Supports parsing nested files, if you create a nested folder structure, the files will still automatically parse routes in the same way.
|
|
75
75
|
|
|
76
76
|
- `api/hello.ts` -> `{prefix}/hello`
|
|
77
77
|
- `api/user/list.ts` -> `{prefix}/user/list`
|
|
78
78
|
|
|
79
|
-
### Dynamic
|
|
79
|
+
### Dynamic Routing
|
|
80
80
|
|
|
81
81
|
Create folders or files named with `[xxx]` to support dynamic named routing parameters.
|
|
82
82
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
sidebar_position: 2
|
|
3
|
-
title:
|
|
3
|
+
title: BFF Type
|
|
4
4
|
---
|
|
5
|
-
#
|
|
5
|
+
# BFF Type
|
|
6
6
|
|
|
7
7
|
Runtime framework support is also an important part of **BFF**. Modern.js supports extending BFF's runtime framework through plugins, and provides a series of built-in plugins, developers can directly use the conventions and ecology of the framework.
|
|
8
8
|
|
|
9
|
-
The plugin is compatible with most of the specifications of these frameworks, and each framework needs to provide two types of ways to extend the writing of BFF functions, namely **Function
|
|
9
|
+
The plugin is compatible with most of the specifications of these frameworks, and each framework needs to provide two types of ways to extend the writing of BFF functions, namely **Function Mode** and **Framework Mode**.
|
|
10
10
|
|
|
11
11
|
:::note
|
|
12
12
|
Whether the current `api/` directory structure is written as a framework is determined by the corresponding plugin, Modern.js don't care.
|
|
13
13
|
|
|
14
14
|
:::
|
|
15
15
|
|
|
16
|
-
## Function
|
|
16
|
+
## Function Mode
|
|
17
17
|
|
|
18
18
|
When the plugin considers that it is currently written as a function, it must support writing middleware in the `api/_ app.ts` to extend the BFF function.
|
|
19
19
|
|
|
@@ -32,7 +32,7 @@ The writing of middleware for different plugins is not the same, see [Runtime Fr
|
|
|
32
32
|
|
|
33
33
|
:::
|
|
34
34
|
|
|
35
|
-
## Framework
|
|
35
|
+
## Framework Mode
|
|
36
36
|
|
|
37
37
|
Framework writing is a way of using frame structure to extend BFF functions. Compared with function writing, although frame writing can use more frame structure and make the entire BFF Server clearer in complex scenarios, it is also more complex and requires more attention to the content at the framework level.
|
|
38
38
|
|
|
@@ -30,14 +30,14 @@ When using Rspack as the bundler, the following Features are temporarily unavail
|
|
|
30
30
|
|
|
31
31
|
:::
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Enable Rspack build
|
|
34
34
|
|
|
35
35
|
You can enable Rspack build by running `pnpm run new`:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
$ pnpm run new
|
|
39
|
-
?
|
|
40
|
-
?
|
|
39
|
+
? Please select the operation you want: Enable features
|
|
40
|
+
? Please select the feature name: Enable Rspack Build
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
After executing the command, enable the Rspack build in `modern.config.ts`:
|
|
@@ -54,9 +54,9 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
## Migrating configuration
|
|
58
|
+
|
|
59
|
+
After enabling Rspack building capability, further configuration migration is needed by referring to the [Configuration Differences](https://modernjs.dev/builder/en/guide/advanced/rspack-start.html#migrating-from-webpack-to-rspack).
|
|
60
60
|
|
|
61
61
|
## The relationship between Rspack and Modern.js versions
|
|
62
62
|
|
|
@@ -81,8 +81,7 @@ For example, if you are using pnpm, you can update the Rspack version with `over
|
|
|
81
81
|
"@rspack/core": "nightly",
|
|
82
82
|
"@rspack/dev-client": "nightly",
|
|
83
83
|
"@rspack/dev-middleware": "nightly",
|
|
84
|
-
"@rspack/plugin-html": "nightly"
|
|
85
|
-
"@rspack/postcss-loader": "nightly"
|
|
84
|
+
"@rspack/plugin-html": "nightly"
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -9,8 +9,8 @@ Static Site Generation is a solution for rendering complete static web pages at
|
|
|
9
9
|
First need to execute `pnpm run new` to enable the SSG features:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
?
|
|
13
|
-
?
|
|
12
|
+
? Please select the operation you want: Enable features
|
|
13
|
+
? Please select the feature name: Enable SSG
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
After execute script, register SSG plugin in `modern.config.ts`:
|
|
@@ -9,8 +9,8 @@ Modern.js integrates the testing capabilities of [Jest](https://jestjs.io/) by d
|
|
|
9
9
|
First need to execute `pnpm run new` enable [unit test/integration test] features:
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
?
|
|
13
|
-
?
|
|
12
|
+
? Please select the operation you want: Enable features
|
|
13
|
+
? Please select the feature name: Enable Unit Test / Integration Test
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
After executing the above command, the `"test": "modern test"` command will be automatically generated in package.json.
|
|
@@ -27,8 +27,8 @@ Because the full web server cannot be controlled this way, and the extension log
|
|
|
27
27
|
You can execute the'pnpm run new 'command in the project root directory to enable the "Custom Web Serve" function:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
?
|
|
31
|
-
? New "Custom Web Server" source code directory
|
|
30
|
+
? Please select the operation you want: Create Element
|
|
31
|
+
? Please select the type of element to create: New "Custom Web Server" source code directory
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
After executing the command, register the `@modern-js/plugin-server` plugin in `modern.config.ts`:
|
|
@@ -66,8 +66,8 @@ If you need to use other CSS-in-JS libraries such as [styled-jsx](https://www.np
|
|
|
66
66
|
Follow the steps below to make a selection:
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
?
|
|
70
|
-
?
|
|
69
|
+
? Please select the operation you want: Enable features
|
|
70
|
+
? Please select the feature name: Enable Tailwind CSS
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Register the Tailwind plugin in `modern.config.ts`:
|
|
@@ -32,7 +32,7 @@ export default {
|
|
|
32
32
|
/* the default method is GET */
|
|
33
33
|
'/api/getExample': { id: 1 },
|
|
34
34
|
|
|
35
|
-
/* You can use custom functions to dynamically return data */
|
|
35
|
+
/* You can use custom functions to dynamically return data, req and res are both Node.js HTTP objects. */
|
|
36
36
|
'POST /api/addInfo': (req, res, next) => {
|
|
37
37
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
38
38
|
res.end('200');
|
|
@@ -182,7 +182,7 @@ Routes generated from file directories named with `[$]` will be treated as dynam
|
|
|
182
182
|
|
|
183
183
|
The `routes/user/[id$]/page.tsx` file will be converted to the `/user/:id?` route. All routes under `/user` will match this route, and the `id` parameter is optional. This route is usually used to distinguish between **creation** and **editing**.
|
|
184
184
|
|
|
185
|
-
In the component, you can use [useParams](/apis/app/runtime/router/router#useparams) to
|
|
185
|
+
In the component, you can use [useParams](/apis/app/runtime/router/router#useparams) to get the corresponding named parameter.
|
|
186
186
|
|
|
187
187
|
In the loader, params will be passed as the input parameter of the [loader function](/guides/basic-features/data-fetch#loader-function), and you can get the parameter value through `params.xxx`.
|
|
188
188
|
|
|
@@ -191,7 +191,7 @@ In the loader, params will be passed as the input parameter of the [loader funct
|
|
|
191
191
|
If you create a `$.tsx` file under the routes directory, it will be treated as the catch-all routing component. When there is no matching route, this component will be rendered.
|
|
192
192
|
|
|
193
193
|
:::note
|
|
194
|
-
`$.tsx` can be considered as a special `page` route component. When there is a `layout`
|
|
194
|
+
`$.tsx` can be considered as a special `page` route component. When there is a `layout.tsx` file in the current directory, `$.tsx` will be rendered as a child component of `layout`.
|
|
195
195
|
:::
|
|
196
196
|
|
|
197
197
|
For example, the following directory structure:
|
|
@@ -215,7 +215,7 @@ params['*']; // => 'aaa/bbb'
|
|
|
215
215
|
|
|
216
216
|
### No-path Layout
|
|
217
217
|
|
|
218
|
-
When the directory name starts with `__`, the
|
|
218
|
+
When the directory name starts with `__`, the directory name will not be converted to an actual route path. For example, the following file directory:
|
|
219
219
|
|
|
220
220
|
```bash
|
|
221
221
|
.
|
|
@@ -449,7 +449,7 @@ However, this also brings a problem: if the chunk corresponding to the route has
|
|
|
449
449
|
|
|
450
450
|
In this case, you can define a `Loading` component to display a custom `Loading` component before the static resources are loaded.
|
|
451
451
|
|
|
452
|
-
To further improve the user experience and reduce loading time, Modern.js supports defining the `prefetch` attribute on the Link component to preload static resources and data.
|
|
452
|
+
To further improve the user experience and reduce loading time, Modern.js supports defining the `prefetch` attribute on the Link component to preload static resources and data.
|
|
453
453
|
|
|
454
454
|
```tsx
|
|
455
455
|
<Link prefetch="intent" to="page">
|
|
@@ -461,6 +461,8 @@ To further improve the user experience and reduce loading time, Modern.js suppor
|
|
|
461
461
|
|
|
462
462
|
:::
|
|
463
463
|
|
|
464
|
+
The `prefetch` attribute has three optional values:
|
|
465
|
+
|
|
464
466
|
- `none`: default value, no prefetching, no additional behavior.
|
|
465
467
|
- `intent`: This is the value we recommend for most scenarios. When you hover over the Link, the corresponding chunk and data defined in the data loader will be loaded automatically. When you move the mouse away, the loading will be cancelled automatically. In our tests, even fast clicks can reduce loading time by about 200ms.
|
|
466
468
|
- `render`: The corresponding chunk and data defined in the Data Loader will be loaded when the Link component is rendered.
|
|
@@ -504,8 +506,6 @@ export default () => {
|
|
|
504
506
|
Modern.js provides a series of optimizations for resource loading and rendering for conventional routing by default, and provides out-of-the-box SSR capabilities. When using self-controlled routing, developers need to encapsulate these capabilities themselves. It is recommended to use conventional routing.
|
|
505
507
|
:::
|
|
506
508
|
|
|
507
|
-
When using self-controlled routing, if the developer turns off the [`runtime.router`](/configure/app/runtime/router) configuration and uses `react-router-dom` directly, they also need to wrap it according to the React Router documentation.
|
|
508
|
-
|
|
509
509
|
## Other
|
|
510
510
|
|
|
511
511
|
By default, Modern.js will enable the built-in routing scheme, which is React Router.
|
|
@@ -518,7 +518,9 @@ export default defineConfig({
|
|
|
518
518
|
});
|
|
519
519
|
```
|
|
520
520
|
|
|
521
|
-
Modern.js
|
|
521
|
+
As mentioned above, when the [`runtime.router`](/configure/app/runtime/router) configuration is enabled, Modern.js will export the API of React Router from the `@modern-js/runtime/router` namespace for developers to use, ensuring that developers and Modern.js are using the same code, and automatically wrapping the `Provider` component according to the router configuration. In addition, in this case, the code of React Router will be packed into the JS output.
|
|
522
|
+
|
|
523
|
+
If the project already has its own routing plan or does not need to use client-side routing, this feature can be disabled.
|
|
522
524
|
|
|
523
525
|
```js
|
|
524
526
|
export default defineConfig({
|
|
@@ -527,3 +529,5 @@ export default defineConfig({
|
|
|
527
529
|
},
|
|
528
530
|
});
|
|
529
531
|
```
|
|
532
|
+
|
|
533
|
+
As mentioned above, if the [`runtime.router`](/configure/app/runtime/router) configuration is disabled and `react-router-dom` is used directly for project routing management, the `Provider` needs to be wrapped according to the React Router documentation.
|
|
@@ -4,31 +4,31 @@ sidebar_position: 2
|
|
|
4
4
|
|
|
5
5
|
# Builder
|
|
6
6
|
|
|
7
|
-
**Modern.js uses [Modern.js Builder](https://modernjs.dev/builder) to build your Web App.**
|
|
7
|
+
**Modern.js uses [Modern.js Builder](https://modernjs.dev/builder/en) to build your Web App.**
|
|
8
8
|
|
|
9
|
-
Modern.js Builder is one of the core components of Modern.js. It is
|
|
9
|
+
Modern.js Builder is one of the core components of the Modern.js system. It is a build engine for web development scenarios that can be used independently of Modern.js. Modern.js Builder supports multiple bundlers such as webpack and Rspack, and by default uses the most mature webpack for bundling.
|
|
10
10
|
|
|
11
11
|
## Build Architecture
|
|
12
12
|
|
|
13
|
-
From
|
|
13
|
+
From a building perspective, Modern.js is divided into three layers, from top to bottom:
|
|
14
14
|
|
|
15
|
-
- Upper-
|
|
16
|
-
-
|
|
17
|
-
- Low-level
|
|
15
|
+
- Upper-level development framework: Modern.js.
|
|
16
|
+
- Common build engine: Modern.js Builder.
|
|
17
|
+
- Low-level bundler: webpack and Rspack.
|
|
18
18
|
|
|
19
19
|
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-1117.png" style={{ width: '100%', maxWidth: '540px' }} />
|
|
20
20
|
|
|
21
21
|
## Builder Documentation
|
|
22
22
|
|
|
23
|
-
Since Modern.js Builder is a module that can be used independently, we
|
|
23
|
+
Since Modern.js Builder is a module that can be used independently, we have provided separate documentation for it, which can be found at [modernjs.dev/builder](https://modernjs.dev/builder/en).
|
|
24
24
|
|
|
25
|
-
In this
|
|
25
|
+
In this documentation, you can learn about the detailed introduction of Modern.js Builder, and you can also find complete usage guides for various building capabilities. If you have any building needs or problems, it is recommended that you read the Modern.js Builder documentation first to solve them.
|
|
26
26
|
|
|
27
|
-
## Builder
|
|
27
|
+
## Builder Configuration
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Modern.js's configuration inherits from Modern.js Builder, so you can use all the build configurations provided by Modern.js Builder in Modern.js.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Taking the `html.title` config option of Modern.js Builder as an example, you can directly use this option in the `modern.config.ts` file, and it will be automatically passed to Modern.js Builder.
|
|
32
32
|
|
|
33
33
|
```ts title="modern.config.js"
|
|
34
34
|
export default defineConfig({
|
|
@@ -38,10 +38,10 @@ export default defineConfig({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
For
|
|
41
|
+
For detailed information about build configuration, please refer to [「Modern.js Builder - Builder Config」](https://modernjs.dev/builder/en/guide/basic/builder-config.html).
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Builder Capabilities
|
|
44
44
|
|
|
45
|
-
Modern.js Builder provides
|
|
45
|
+
Modern.js Builder provides rich build capabilities, including JavaScript compilation, CSS compilation, static resource processing, code hot update, code compression, TS type checking, and dozens of other capabilities.
|
|
46
46
|
|
|
47
|
-
We recommend you
|
|
47
|
+
We recommend that you read [「Modern.js Builder - All Features」](https://modernjs.dev/builder/en/guide/features.html) to learn about all the features provided by Modern.js Builder.
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
sidebar_position: 1
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Entry
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
In this chapter, you will learn about the entry convention in Modern.js and how to customize it.
|
|
8
8
|
|
|
9
|
-
## What is
|
|
9
|
+
## What is Entry?
|
|
10
10
|
|
|
11
|
-
**Entry
|
|
11
|
+
**Entry refers to the starting module of a page.**
|
|
12
12
|
|
|
13
|
-
In
|
|
13
|
+
In a Modern.js project, each entry corresponds to an independent page and a server-side route. By default, Modern.js automatically determines the entry of a page based on directory conventions, but also supports customizing the entry through configuration options.
|
|
14
14
|
|
|
15
|
-
Many configuration
|
|
15
|
+
Many configuration options provided by Modern.js are divided by entry, such as page title, HTML template, page meta information, whether to enable SSR/SSG, server-side routing rules, etc.
|
|
16
16
|
|
|
17
17
|
## Single Entry and Multiple Entries
|
|
18
18
|
|
|
19
|
-
The project initialized by Modern.js is single
|
|
19
|
+
The project initialized by Modern.js is a single entry (SPA) project, with the following structure:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
.
|
|
@@ -30,15 +30,15 @@ The project initialized by Modern.js is single-entry (SPA), and the project stru
|
|
|
30
30
|
└── tsconfig.json
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Modern.js can easily switch from single entry to multiple
|
|
33
|
+
In a Modern.js project, you can easily switch from single entry to multiple entries by running `pnpm run new` in the project directory and creating an entry:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
?
|
|
37
|
-
?
|
|
38
|
-
?
|
|
36
|
+
? Please select the operation you want: Create Element
|
|
37
|
+
? Please select the type of element to create: New "entry"
|
|
38
|
+
? Please fill in the entry name: new-entry
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
After
|
|
41
|
+
After running the command, Modern.js will automatically generate a new entry directory. At this point, you can see that the `src/` directory has the following structure:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
.
|
|
@@ -54,51 +54,55 @@ After execution, Modern.js will automatically generate a new entry directory, an
|
|
|
54
54
|
└── page.tsx
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
The original code
|
|
57
|
+
The original entry code has been moved to a directory with the same name as the `name` field in `package.json`, and a `new-entry` entry directory has been created.
|
|
58
58
|
|
|
59
|
-
After
|
|
59
|
+
After running `pnpm run dev`, you can see a new route named `/new-entry` has been added, and the migrated code route has not changed.
|
|
60
60
|
|
|
61
61
|
:::tip
|
|
62
|
-
Modern.js will use the entry with the same name as the `name` field in
|
|
62
|
+
Modern.js will use the entry with the same name as the `name` field in `package.json` as the main entry. The route of the main entry is `/`, and the route of other entries is `/{entryName}`.
|
|
63
63
|
|
|
64
|
-
For example, when `name` in package.json is `myapp`, `src/myapp` will be
|
|
64
|
+
For example, when the `name` field in `package.json` is `myapp`, `src/myapp` will be the main entry of the project.
|
|
65
65
|
|
|
66
66
|
:::
|
|
67
67
|
|
|
68
|
-
## Entry
|
|
68
|
+
## Entry Types
|
|
69
69
|
|
|
70
|
-
Different entry types have different
|
|
70
|
+
Different entry types have different compilation and runtime behaviors.
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
import EntryMode from '@site-docs-en/components/entry-mode.mdx';
|
|
73
|
+
|
|
74
|
+
<EntryMode />
|
|
75
|
+
|
|
76
|
+
By default, Modern.js scans the files under `src/` before starting the project, identifies the entry, and generates the corresponding server-side route.
|
|
73
77
|
|
|
74
78
|
:::tip
|
|
75
|
-
You can
|
|
79
|
+
You can modify the directory for entry identification by using the [source.entriesDir](/configure/app/source/entries-dir) config.
|
|
76
80
|
|
|
77
81
|
:::
|
|
78
82
|
|
|
79
|
-
Not all
|
|
83
|
+
Not all top-level directories under `src/` become project entries. The directory where the entry is located must meet one of the following four conditions:
|
|
80
84
|
|
|
81
|
-
1.
|
|
82
|
-
2. Has `App.[jt]sx?` file
|
|
83
|
-
3. Has `index.[jt]sx?` file
|
|
84
|
-
4. Has a `pages/` directory (Modern.js 1.0
|
|
85
|
+
1. Has a `routes/` directory.
|
|
86
|
+
2. Has an `App.[jt]sx?` file.
|
|
87
|
+
3. Has an `index.[jt]sx?` file.
|
|
88
|
+
4. Has a `pages/` directory (compatible with Modern.js 1.0).
|
|
85
89
|
|
|
86
|
-
When the `src/` directory meets the entry
|
|
90
|
+
When the `src/` directory meets the entry requirements, Modern.js considers the current project as a single entry application.
|
|
87
91
|
|
|
88
92
|
:::tip
|
|
89
|
-
In single
|
|
93
|
+
In a single entry application, the default entry name is `main`.
|
|
90
94
|
|
|
91
95
|
:::
|
|
92
96
|
|
|
93
|
-
When the project is not a single
|
|
97
|
+
When the project is not a single entry application, Modern.js will further look at the top-level directories under `src/`.
|
|
94
98
|
|
|
95
99
|
### Framework Mode Entry
|
|
96
100
|
|
|
97
|
-
Framework mode refers to the need to use
|
|
101
|
+
Framework mode refers to the need to use Modern.js framework capabilities, such as Router, SSR, integrated calls, etc. Under this type of entry convention, the entry defined by the developer is not a real webpack compilation entry. Modern.js will generate a wrapped entry during startup, and you can find the real entry in `node_modules/.modern/{entryName}/index.js`.
|
|
98
102
|
|
|
99
103
|
#### Conventional Routing
|
|
100
104
|
|
|
101
|
-
If there is a `routes/` directory in the entry, Modern.js will scan the files under `routes/`
|
|
105
|
+
If there is a `routes/` directory in the entry, Modern.js will scan the files under `routes/` during startup, and automatically generate client-side routes (react-router) based on file conventions. For example:
|
|
102
106
|
|
|
103
107
|
```bash
|
|
104
108
|
.
|
|
@@ -108,11 +112,13 @@ If there is a `routes/` directory in the entry, Modern.js will scan the files un
|
|
|
108
112
|
│ └── page.tsx
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
In the above directory, the component exported in `layout.tsx` will be the outermost component, and the component exported in `page.tsx` will be the component of the `/` route.
|
|
116
|
+
|
|
117
|
+
For more information, please refer to [Conventional Routing](/guides/basic-features/routes.html#conventional-routing).
|
|
112
118
|
|
|
113
119
|
#### Self-controlled Routing
|
|
114
120
|
|
|
115
|
-
If there is an `App.[jt]sx?` file in the entry,
|
|
121
|
+
If there is an `App.[jt]sx?` file in the entry, developers can set the client-side route in this file through code, or not set the client-side route.
|
|
116
122
|
|
|
117
123
|
```tsx
|
|
118
124
|
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
|
@@ -129,11 +135,11 @@ export default () => {
|
|
|
129
135
|
};
|
|
130
136
|
```
|
|
131
137
|
|
|
132
|
-
For
|
|
138
|
+
For more information, please refer to [Self-controlled Routing](/guides/basic-features/routes.html#self-controlled-routing).
|
|
133
139
|
|
|
134
140
|
#### Custom Bootstrap
|
|
135
141
|
|
|
136
|
-
If there is an `index.[jt]sx` file in the entry, and
|
|
142
|
+
If there is an `index.[jt]sx` file in the entry, and the file exports a function by default, Modern.js will pass the default `bootstrap` function as a parameter and use the exported function to replace the default `bootstrap`. This way, developers can customize how components are mounted to DOM nodes or add custom behavior before mounting. For example:
|
|
137
143
|
|
|
138
144
|
```tsx
|
|
139
145
|
export default (App: React.ComponentType, bootstrap: () => void) => {
|
|
@@ -144,12 +150,7 @@ export default (App: React.ComponentType, bootstrap: () => void) => {
|
|
|
144
150
|
};
|
|
145
151
|
```
|
|
146
152
|
|
|
147
|
-
|
|
148
|
-
Since the bootstrap function needs to be compatible with React17 and React18, you need to manually pass in ReactDOM parameters when calling the bootstrap function.
|
|
149
|
-
|
|
150
|
-
:::
|
|
151
|
-
|
|
152
|
-
The content of the file generated by Modern.js is as follows:
|
|
153
|
+
At this point, the generated file content of Modern.js is as follows:
|
|
153
154
|
|
|
154
155
|
```js
|
|
155
156
|
import React from 'react';
|
|
@@ -180,9 +181,9 @@ export default AppWrapper;
|
|
|
180
181
|
|
|
181
182
|
### Build Mode Entry
|
|
182
183
|
|
|
183
|
-
Build mode refers to
|
|
184
|
+
Build mode refers to not using any Modern.js runtime capabilities and completely defining the project's webpack entry by the developer.
|
|
184
185
|
|
|
185
|
-
If `index.[jt]sx`
|
|
186
|
+
If there is an `index.[jt]sx` file in the entry and it does not export a default function, then this file is the real webpack entry file. Similar to [Create React App](https://github.com/facebook/create-react-app), you need to mount the component to the DOM node by yourself, add hot update code, etc. For example:
|
|
186
187
|
|
|
187
188
|
```js title=src/index.jsx
|
|
188
189
|
import React from 'react';
|
|
@@ -192,13 +193,13 @@ import App from './App';
|
|
|
192
193
|
ReactDOM.render(<App />, document.getElementById('root'));
|
|
193
194
|
```
|
|
194
195
|
|
|
195
|
-
Modern.js **not
|
|
196
|
+
Modern.js **does not recommend** using this method for new projects, as it loses some of the framework's capabilities, such as the `runtime` configuration in the `modern.config.js` file will no longer take effect. However, this method can be very useful when migrating projects from other frameworks to Modern.js, such as CRA, or manually building webpack.
|
|
196
197
|
|
|
197
|
-
##
|
|
198
|
+
## Specifying Entry Using Configuration
|
|
198
199
|
|
|
199
|
-
Most existing projects are not built according to the directory
|
|
200
|
+
Most existing projects are not built according to the directory structure of Modern.js. If you want to change to the directory structure of Modern.js, there will be certain migration costs.
|
|
200
201
|
|
|
201
|
-
In this case,
|
|
202
|
+
In this case, in addition to using file conventions to generate entries, you can manually configure the entry in `modern.config.[jt]s`.
|
|
202
203
|
|
|
203
204
|
```ts title="modern.config.ts"
|
|
204
205
|
export default defineConfig({
|
|
@@ -213,11 +214,11 @@ export default defineConfig({
|
|
|
213
214
|
});
|
|
214
215
|
```
|
|
215
216
|
|
|
216
|
-
### Disable Default
|
|
217
|
+
### Disable Default Entry Scanning
|
|
217
218
|
|
|
218
|
-
When using
|
|
219
|
+
When using custom entries, part of the project structure may coincidentally hit the directory conventions of Modern.js, but in fact, this part of the directory is not the real entry.
|
|
219
220
|
|
|
220
|
-
Modern.js provides `disableDefaultEntries`
|
|
221
|
+
Modern.js provides the `disableDefaultEntries` configuration to disable the default entry scanning rules. When you need to customize the entry, you generally need to use `disableDefaultEntries` in combination with `entries`. This way, some existing projects can be quickly migrated without modifying the directory structure.
|
|
221
222
|
|
|
222
223
|
```ts title="modern.config.ts"
|
|
223
224
|
export default defineConfig({
|
|
@@ -6,9 +6,9 @@ sidebar_position: 4
|
|
|
6
6
|
|
|
7
7
|
## BFF
|
|
8
8
|
|
|
9
|
-
BFF
|
|
9
|
+
BFF is short for "Backend For Frontend". It is an architecture pattern that involves creating a backend service for frontend applications.
|
|
10
10
|
|
|
11
|
-
The BFF service acts as an intermediary between the frontend application and the
|
|
11
|
+
The BFF service acts as an intermediary between the frontend application and the server API, and can provide customized APIs for the frontend to use. This allows frontend developers to have more control over the data and functionality they need, without relying on the backend service to provide the corresponding capabilities.
|
|
12
12
|
|
|
13
13
|
## Bundler
|
|
14
14
|
|
|
@@ -24,15 +24,15 @@ import Builder from '@modern-js/builder-doc/docs/en/shared/builder.md';
|
|
|
24
24
|
|
|
25
25
|
## CSR
|
|
26
26
|
|
|
27
|
-
CSR stands for "Client-Side Rendering". It means that
|
|
27
|
+
CSR stands for "Client-Side Rendering". It means that the page is rendered in the browser using JavaScript, and logic such as data fetching, templates, and routing is completed on the client side rather than the server.
|
|
28
28
|
|
|
29
|
-
In CSR, the server sends an empty HTML shell
|
|
29
|
+
In CSR, the server sends an empty HTML shell and some JavaScript scripts to the browser, and the browser fetching data from the server's API and renders dynamic content to the page.
|
|
30
30
|
|
|
31
31
|
## Garfish
|
|
32
32
|
|
|
33
|
-
[Garfish](https://garfish.bytedance.net/) is a
|
|
33
|
+
[Garfish](https://garfish.bytedance.net/) is a micro-frontend solution mainly used to solve problems such as cross-team collaboration and diversified technology systems in web applications.
|
|
34
34
|
|
|
35
|
-
Starting from the
|
|
35
|
+
Starting from the architecture level, it combines multiple independently delivered frontend applications into a whole. These frontend applications can be developed, tested, and deployed independently, but in the user's perspective, they are still cohesive single products.
|
|
36
36
|
|
|
37
37
|
## Rspack
|
|
38
38
|
|
|
@@ -42,19 +42,19 @@ import Rspack from '@modern-js/builder-doc/docs/en/shared/rspack.md';
|
|
|
42
42
|
|
|
43
43
|
## SSR
|
|
44
44
|
|
|
45
|
-
SSR stands for "Server-Side Rendering". It
|
|
45
|
+
SSR stands for "Server-Side Rendering". It means that the HTML of the web page is generated by the server and sent to the client, rather than sending only an empty HTML shell and relying on JavaScript to generate the page content.
|
|
46
46
|
|
|
47
|
-
In traditional client-side rendering, the server sends an empty HTML shell
|
|
47
|
+
In traditional client-side rendering, the server sends an empty HTML shell and some JavaScript scripts to the client, and then fetching data from the server's API and fills the page with dynamic content. This leads to slow initial page loading times and is not conducive to user experience and SEO.
|
|
48
48
|
|
|
49
|
-
With SSR, the server generates
|
|
49
|
+
With SSR, the server generates HTML that already contains dynamic content and sends it to the client. This makes the initial page loading faster and more SEO-friendly, as search engines can crawl the rendered page.
|
|
50
50
|
|
|
51
51
|
## SSG
|
|
52
52
|
|
|
53
|
-
SSG stands for "Static Site Generation". It
|
|
53
|
+
SSG stands for "Static Site Generation". It means that web pages are pre-rendered as static HTML and served directly to the client, without the need for the server to generate HTML in real-time.
|
|
54
54
|
|
|
55
|
-
In traditional SSR, the server generates
|
|
55
|
+
In traditional SSR, the server generates HTML in real-time every time a user requests a page. With SSG, HTML can be generated in advance during the build process and hosted on a CDN or other static resource service.
|
|
56
56
|
|
|
57
|
-
SSG can provide faster
|
|
57
|
+
Compared to traditional SSR, SSG can provide faster loading speeds and less server-side overhead, as there is no need to maintain a server to generate HTML in real-time. However, SSG is not suitable for websites that require dynamic content, as the HTML is generated during the build process and does not support real-time updates.
|
|
58
58
|
|
|
59
59
|
## SWC
|
|
60
60
|
|