@modern-js/main-doc 2.69.7 → 3.0.0-alpha.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/docs/en/{_meta.json → _nav.json} +5 -1
- package/docs/en/apis/app/commands.mdx +8 -33
- package/docs/en/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/en/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/en/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/en/apis/app/runtime/_meta.json +0 -18
- package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/en/apis/app/runtime/router/router.mdx +1 -1
- package/docs/en/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/en/community/blog/v2-release-note.mdx +0 -2
- package/docs/en/community/contributing-guide.mdx +10 -12
- package/docs/en/components/bff-upload.mdx +19 -17
- package/docs/en/components/build-output.mdx +45 -0
- package/docs/en/components/bundler.mdx +1 -1
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/enable-bff-caution.mdx +2 -2
- package/docs/en/components/enable-bff.mdx +42 -8
- package/docs/en/components/enable-ssg.mdx +49 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/esbuild.mdx +2 -2
- package/docs/en/components/extend-bff-function.mdx +2 -4
- package/docs/en/components/hono.mdx +119 -0
- package/docs/en/components/init-app.mdx +40 -17
- package/docs/en/components/international/custom-instance-code.mdx +16 -0
- package/docs/en/components/international/init-options-desc.mdx +1 -0
- package/docs/en/components/international/install-command.mdx +23 -0
- package/docs/en/components/international/instance-code.mdx +26 -0
- package/docs/en/components/international/introduce.mdx +2 -0
- package/docs/en/components/module-federation.mdx +4 -4
- package/docs/en/components/nodeVersion.mdx +2 -6
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/components/ua-polyfill.mdx +16 -12
- package/docs/en/components/upgrade-config-deploy.mdx +0 -0
- package/docs/en/configure/_meta.json +7 -8
- package/docs/en/configure/app/bff/cross-project.mdx +24 -0
- package/docs/en/configure/app/builder-plugins.mdx +1 -2
- package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/server.mdx +211 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
- package/docs/en/configure/app/experiments/source-build.mdx +0 -1
- package/docs/en/configure/app/html/app-icon.mdx +1 -23
- package/docs/en/configure/app/output/assets-retry.mdx +1 -1
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/en/configure/app/output/filename.mdx +2 -4
- package/docs/en/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/en/configure/app/output/override-browserslist.mdx +6 -4
- package/docs/en/configure/app/output/source-map.mdx +6 -3
- package/docs/en/configure/app/output/ssg.mdx +12 -43
- package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
- package/docs/en/configure/app/output/temp-dir.mdx +3 -3
- package/docs/en/configure/app/performance/build-cache.mdx +1 -5
- package/docs/en/configure/app/performance/profile.mdx +1 -1
- package/docs/en/configure/app/plugins.mdx +1 -3
- package/docs/en/configure/app/resolve/alias-strategy.mdx +14 -0
- package/docs/en/configure/app/resolve/alias.mdx +13 -0
- package/docs/en/configure/app/resolve/condition-names.mdx +18 -0
- package/docs/en/configure/app/resolve/dedupe.mdx +13 -0
- package/docs/en/configure/app/resolve/extensions.mdx +18 -0
- package/docs/en/configure/app/runtime/0-intro.mdx +2 -51
- package/docs/en/configure/app/runtime/router.mdx +0 -4
- package/docs/en/configure/app/security/check-syntax.mdx +1 -1
- package/docs/en/configure/app/security/sri.mdx +0 -1
- package/docs/en/configure/app/server/port.mdx +1 -21
- package/docs/en/configure/app/server/rsc.mdx +30 -0
- package/docs/en/configure/app/server/ssr.mdx +20 -9
- package/docs/en/configure/app/source/alias.mdx +1 -1
- package/docs/en/configure/app/source/decorators.mdx +4 -2
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/entries.mdx +0 -2
- package/docs/en/configure/app/source/include.mdx +2 -14
- package/docs/en/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/en/configure/app/source/transform-import.mdx +1 -59
- package/docs/en/configure/app/tools/bundler-chain.mdx +5 -5
- package/docs/en/configure/app/tools/css-extract.mdx +1 -1
- package/docs/en/configure/app/tools/dev-server.mdx +22 -256
- package/docs/en/configure/app/tools/html-plugin.mdx +3 -3
- package/docs/en/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -43
- package/docs/en/configure/app/usage.mdx +5 -27
- package/docs/en/guides/_meta.json +5 -1
- package/docs/en/guides/advanced-features/_meta.json +6 -0
- package/docs/en/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +2 -8
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -15
- package/docs/en/guides/advanced-features/bff/function.mdx +6 -10
- package/docs/en/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/en/guides/advanced-features/bff/sdk.mdx +20 -12
- package/docs/en/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/en/guides/advanced-features/build-performance.mdx +23 -26
- package/docs/en/guides/advanced-features/compatibility.mdx +53 -9
- package/docs/en/guides/advanced-features/international/_meta.json +11 -0
- package/docs/en/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/en/guides/advanced-features/international/api.mdx +400 -0
- package/docs/en/guides/advanced-features/international/basic.mdx +417 -0
- package/docs/en/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/en/guides/advanced-features/international/configuration.mdx +428 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +126 -0
- package/docs/en/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/en/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/en/guides/advanced-features/international.mdx +37 -0
- package/docs/en/guides/advanced-features/low-level.mdx +21 -16
- package/docs/en/guides/advanced-features/page-performance/code-split.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +8 -22
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +19 -12
- package/docs/en/guides/advanced-features/rspack-start.mdx +3 -23
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +121 -36
- package/docs/en/guides/advanced-features/web-server.mdx +82 -299
- package/docs/en/guides/basic-features/_meta.json +6 -1
- package/docs/en/guides/basic-features/css/css-in-js.mdx +46 -11
- package/docs/en/guides/basic-features/css/css-modules.mdx +5 -17
- package/docs/en/guides/basic-features/css/css.mdx +3 -3
- package/docs/en/guides/basic-features/css/tailwindcss.mdx +5 -89
- package/docs/en/guides/basic-features/data/data-cache.mdx +65 -77
- package/docs/en/guides/basic-features/data/data-fetch.mdx +19 -18
- package/docs/en/guides/basic-features/data/data-write.mdx +2 -2
- package/docs/en/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/en/guides/basic-features/debug/proxy.mdx +6 -17
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +5 -5
- package/docs/en/guides/basic-features/deploy.mdx +25 -18
- package/docs/en/guides/basic-features/env-vars.mdx +1 -1
- package/docs/en/guides/basic-features/html.mdx +1 -1
- package/docs/en/guides/basic-features/output-files.mdx +3 -3
- package/docs/en/guides/basic-features/render/_meta.json +1 -1
- package/docs/en/guides/basic-features/render/before-render.mdx +16 -23
- package/docs/en/guides/basic-features/render/overview.mdx +51 -0
- package/docs/en/guides/basic-features/render/rsc.mdx +399 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +26 -67
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -10
- package/docs/en/guides/basic-features/render/ssr.mdx +31 -31
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +29 -9
- package/docs/en/guides/basic-features/routes/_meta.json +1 -0
- package/docs/en/guides/basic-features/routes/config-routes.mdx +427 -0
- package/docs/en/guides/basic-features/{routes.mdx → routes/routes.mdx} +7 -110
- package/docs/en/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/en/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/en/guides/basic-features/static-assets.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +27 -12
- package/docs/en/guides/concept/entries.mdx +139 -147
- package/docs/en/guides/get-started/glossary.mdx +0 -18
- package/docs/en/guides/get-started/introduction.mdx +1 -4
- package/docs/en/guides/get-started/quick-start.mdx +4 -71
- package/docs/en/guides/get-started/tech-stack.mdx +7 -27
- package/docs/en/guides/get-started/upgrade.mdx +30 -23
- package/docs/en/guides/topic-detail/_meta.json +0 -12
- package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/en/guides/topic-detail/module-federation/application.mdx +16 -15
- package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
- package/docs/en/guides/topic-detail/module-federation/introduce.mdx +5 -4
- package/docs/en/guides/topic-detail/module-federation/ssr.mdx +50 -2
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +10 -30
- package/docs/en/guides/troubleshooting/builder.mdx +3 -82
- package/docs/en/guides/troubleshooting/cli.mdx +6 -30
- package/docs/en/guides/troubleshooting/dependencies.mdx +22 -22
- package/docs/en/guides/upgrade/_meta.json +1 -0
- package/docs/en/guides/upgrade/config.mdx +936 -0
- package/docs/en/guides/upgrade/entry.mdx +463 -0
- package/docs/en/guides/upgrade/other.mdx +83 -0
- package/docs/en/guides/upgrade/overview.mdx +33 -0
- package/docs/en/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/en/guides/upgrade/web-server.mdx +91 -0
- package/docs/en/plugin/_meta.json +5 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/cli-plugins/api.mdx +17 -68
- package/docs/en/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/en/plugin/introduction.mdx +44 -44
- package/docs/en/plugin/official/_meta.json +0 -5
- package/docs/en/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins.mdx +0 -2
- package/docs/en/plugin/plugin-system.mdx +69 -62
- package/docs/en/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
- package/docs/en/plugin/server-plugins/_meta.json +1 -0
- package/docs/en/plugin/server-plugins/api.mdx +210 -1
- package/docs/en/plugin/server-plugins/life-cycle.mdx +41 -1
- package/docs/en/tutorials/_meta.json +0 -10
- package/docs/en/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/en/tutorials/foundations/introduction.mdx +9 -25
- package/docs/zh/{_meta.json → _nav.json} +10 -6
- package/docs/zh/apis/app/commands.mdx +8 -33
- package/docs/zh/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/zh/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/zh/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/zh/apis/app/runtime/_meta.json +0 -18
- package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/zh/community/blog/v2-release-note.mdx +0 -2
- package/docs/zh/community/contributing-guide.mdx +10 -12
- package/docs/zh/components/auto-upgrade.mdx +0 -0
- package/docs/zh/components/bff-operator-code.mdx +5 -0
- package/docs/zh/components/bff-upload.mdx +8 -7
- package/docs/zh/components/build-output.mdx +45 -0
- package/docs/zh/components/bundler.mdx +1 -1
- package/docs/zh/components/debug-app.mdx +1 -1
- package/docs/zh/components/enable-bff-caution.mdx +1 -1
- package/docs/zh/components/enable-bff.mdx +41 -8
- package/docs/zh/components/enable-ssg.mdx +49 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/esbuild.mdx +2 -2
- package/docs/zh/components/extend-bff-function.mdx +2 -4
- package/docs/zh/components/hono.mdx +119 -0
- package/docs/zh/components/init-app.mdx +40 -18
- package/docs/zh/components/international/custom-instance-code.mdx +16 -0
- package/docs/zh/components/international/init-options-desc.mdx +1 -0
- package/docs/zh/components/international/install-command.mdx +23 -0
- package/docs/zh/components/international/instance-code.mdx +26 -0
- package/docs/zh/components/international/introduce.mdx +2 -0
- package/docs/zh/components/international/platform-support.mdx +0 -0
- package/docs/zh/components/module-federation.mdx +4 -4
- package/docs/zh/components/new-entry-tooltip.mdx +0 -0
- package/docs/zh/components/nodeVersion.mdx +3 -7
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/components/self-route-example.mdx +3 -3
- package/docs/zh/components/ua-polyfill.mdx +11 -6
- package/docs/zh/components/upgrade-browserslist.mdx +0 -0
- package/docs/zh/components/upgrade-config-deploy.mdx +0 -0
- package/docs/zh/configure/_meta.json +7 -8
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/builder-plugins.mdx +1 -2
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/server.mdx +211 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
- package/docs/zh/configure/app/experiments/source-build.mdx +0 -1
- package/docs/zh/configure/app/html/app-icon.mdx +1 -23
- package/docs/zh/configure/app/output/assets-retry.mdx +1 -1
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/zh/configure/app/output/filename.mdx +2 -4
- package/docs/zh/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/zh/configure/app/output/override-browserslist.mdx +3 -3
- package/docs/zh/configure/app/output/source-map.mdx +10 -3
- package/docs/zh/configure/app/output/ssg.mdx +13 -45
- package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
- package/docs/zh/configure/app/output/temp-dir.mdx +3 -3
- package/docs/zh/configure/app/performance/build-cache.mdx +1 -5
- package/docs/zh/configure/app/performance/profile.mdx +1 -1
- package/docs/zh/configure/app/plugins.mdx +1 -2
- package/docs/zh/configure/app/resolve/alias-strategy.mdx +14 -0
- package/docs/zh/configure/app/resolve/alias.mdx +13 -0
- package/docs/zh/configure/app/resolve/condition-names.mdx +18 -0
- package/docs/zh/configure/app/resolve/dedupe.mdx +14 -0
- package/docs/zh/configure/app/resolve/extensions.mdx +18 -0
- package/docs/zh/configure/app/runtime/0-intro.mdx +2 -53
- package/docs/zh/configure/app/runtime/router.mdx +0 -4
- package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
- package/docs/zh/configure/app/security/sri.mdx +0 -1
- package/docs/zh/configure/app/server/port.mdx +2 -21
- package/docs/zh/configure/app/server/rsc.mdx +30 -0
- package/docs/zh/configure/app/server/ssr.mdx +21 -11
- package/docs/zh/configure/app/source/alias.mdx +1 -1
- package/docs/zh/configure/app/source/decorators.mdx +4 -4
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/configure/app/source/entries.mdx +0 -2
- package/docs/zh/configure/app/source/include.mdx +2 -16
- package/docs/zh/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/zh/configure/app/source/transform-import.mdx +1 -59
- package/docs/zh/configure/app/tools/bundler-chain.mdx +6 -6
- package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
- package/docs/zh/configure/app/tools/dev-server.mdx +14 -248
- package/docs/zh/configure/app/tools/html-plugin.mdx +3 -2
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -43
- package/docs/zh/configure/app/usage.mdx +6 -28
- package/docs/zh/guides/_meta.json +5 -1
- package/docs/zh/guides/advanced-features/_meta.json +6 -1
- package/docs/zh/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/zh/guides/advanced-features/bff/cross-project.mdx +8 -16
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +25 -8
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +2 -16
- package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
- package/docs/zh/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +23 -16
- package/docs/zh/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/zh/guides/advanced-features/build-performance.mdx +23 -30
- package/docs/zh/guides/advanced-features/compatibility.mdx +44 -0
- package/docs/zh/guides/advanced-features/international/_meta.json +11 -0
- package/docs/zh/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/zh/guides/advanced-features/international/api.mdx +400 -0
- package/docs/zh/guides/advanced-features/international/basic.mdx +416 -0
- package/docs/zh/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/zh/guides/advanced-features/international/configuration.mdx +432 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +126 -0
- package/docs/zh/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/zh/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/zh/guides/advanced-features/international.mdx +36 -0
- package/docs/zh/guides/advanced-features/low-level.mdx +21 -16
- package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +3 -3
- package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +8 -22
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +19 -12
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +120 -37
- package/docs/zh/guides/advanced-features/web-server.mdx +79 -300
- package/docs/zh/guides/basic-features/_meta.json +6 -1
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +40 -5
- package/docs/zh/guides/basic-features/css/css-modules.mdx +6 -17
- package/docs/zh/guides/basic-features/css/css.mdx +2 -2
- package/docs/zh/guides/basic-features/css/tailwindcss.mdx +6 -90
- package/docs/zh/guides/basic-features/data/data-cache.mdx +55 -59
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +14 -16
- package/docs/zh/guides/basic-features/data/data-write.mdx +4 -4
- package/docs/zh/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/zh/guides/basic-features/debug/proxy.mdx +4 -15
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +6 -6
- package/docs/zh/guides/basic-features/deploy.mdx +24 -20
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/html.mdx +2 -2
- package/docs/zh/guides/basic-features/output-files.mdx +3 -3
- package/docs/zh/guides/basic-features/render/_meta.json +1 -1
- package/docs/zh/guides/basic-features/render/before-render.mdx +17 -24
- package/docs/zh/guides/basic-features/render/overview.mdx +52 -0
- package/docs/zh/guides/basic-features/render/rsc.mdx +399 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -9
- package/docs/zh/guides/basic-features/render/ssr.mdx +34 -31
- package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +34 -14
- package/docs/zh/guides/basic-features/routes/_meta.json +1 -0
- package/docs/zh/guides/basic-features/routes/config-routes.mdx +426 -0
- package/docs/zh/guides/basic-features/{routes.mdx → routes/routes.mdx} +8 -114
- package/docs/zh/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/zh/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
- package/docs/zh/guides/basic-features/testing/cypress.mdx +5 -5
- package/docs/zh/guides/basic-features/testing/jest.mdx +12 -12
- package/docs/zh/guides/concept/builder.mdx +26 -11
- package/docs/zh/guides/concept/entries.mdx +95 -92
- package/docs/zh/guides/get-started/glossary.mdx +0 -18
- package/docs/zh/guides/get-started/introduction.mdx +1 -5
- package/docs/zh/guides/get-started/quick-start.mdx +5 -72
- package/docs/zh/guides/get-started/tech-stack.mdx +8 -28
- package/docs/zh/guides/get-started/upgrade.mdx +30 -23
- package/docs/zh/guides/topic-detail/_meta.json +0 -12
- package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +18 -16
- package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
- package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +4 -4
- package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +51 -5
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +11 -31
- package/docs/zh/guides/troubleshooting/builder.mdx +4 -85
- package/docs/zh/guides/troubleshooting/cli.mdx +6 -30
- package/docs/zh/guides/troubleshooting/dependencies.mdx +23 -23
- package/docs/zh/guides/upgrade/_meta.json +1 -0
- package/docs/zh/guides/upgrade/config.mdx +940 -0
- package/docs/zh/guides/upgrade/entry.mdx +463 -0
- package/docs/zh/guides/upgrade/other.md +90 -0
- package/docs/zh/guides/upgrade/overview.mdx +36 -0
- package/docs/zh/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/zh/guides/upgrade/web-server.md +93 -0
- package/docs/zh/plugin/_meta.json +5 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/cli-plugins/api.mdx +19 -70
- package/docs/zh/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/zh/plugin/introduction.mdx +40 -40
- package/docs/zh/plugin/official/_meta.json +0 -5
- package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins.mdx +0 -2
- package/docs/zh/plugin/plugin-system.mdx +43 -51
- package/docs/zh/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
- package/docs/zh/plugin/server-plugins/_meta.json +1 -0
- package/docs/zh/plugin/server-plugins/api.mdx +210 -1
- package/docs/zh/plugin/server-plugins/life-cycle.mdx +41 -1
- package/docs/zh/tutorials/_meta.json +0 -10
- package/docs/zh/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/zh/tutorials/foundations/introduction.mdx +8 -25
- package/i18n.json +0 -16
- package/package.json +12 -12
- package/rspress.config.ts +5 -8
- package/src/components/ContentCard/index.module.scss +11 -7
- package/src/components/ContentCard/index.tsx +1 -1
- package/src/components/FeatureLayout/index.module.css +1 -1
- package/src/components/Footer/index.tsx +2 -14
- package/src/components/Footer/styles.module.scss +5 -5
- package/src/components/FrameworkCode/index.tsx +605 -0
- package/src/components/ListCard/index.tsx +1 -1
- package/src/components/RandomMemberList/index.tsx +1 -1
- package/src/components/RsbuildLink/index.tsx +1 -1
- package/src/components/Sandpack/index.tsx +1 -1
- package/src/custom.scss +15 -0
- package/src/i18n/enUS.ts +2 -4
- package/src/i18n/index.ts +1 -1
- package/src/i18n/zhCN.ts +2 -4
- package/src/index.ts +2 -1
- package/src/pages/index.module.scss +59 -41
- package/src/pages/index.tsx +9 -24
- package/docs/en/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/en/apis/app/hooks/src/index_.mdx +0 -38
- package/docs/en/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/en/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/en/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/en/apis/app/runtime/core/create-app.mdx +0 -49
- package/docs/en/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/en/apis/app/runtime/core/use-module-apps.mdx +0 -140
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/en/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/en/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/en/apis/app/runtime/model/connect.mdx +0 -146
- package/docs/en/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/en/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/en/apis/app/runtime/model/handle-effect.mdx +0 -107
- package/docs/en/apis/app/runtime/model/model_.mdx +0 -198
- package/docs/en/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/en/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/en/apis/app/runtime/model/use-static-model.mdx +0 -51
- package/docs/en/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/en/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/en/apis/app/runtime/web-server/hook.mdx +0 -134
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +0 -113
- package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +0 -167
- package/docs/en/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/en/components/bff-proxy-principle.mdx +0 -1
- package/docs/en/components/builder.mdx +0 -3
- package/docs/en/components/create-bff-api-app.mdx +0 -25
- package/docs/en/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/en/components/enable-micro-frontend.mdx +0 -30
- package/docs/en/components/enableSwc.mdx +0 -17
- package/docs/en/components/global-proxy-config.mdx +0 -85
- package/docs/en/components/global-proxy.mdx +0 -29
- package/docs/en/components/package-manager.mdx +0 -11
- package/docs/en/components/reduck-notify.mdx +0 -27
- package/docs/en/components/reduck-tip.mdx +0 -8
- package/docs/en/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/en/configure/app/deploy/microFrontend.mdx +0 -53
- package/docs/en/configure/app/dev/port.mdx +0 -25
- package/docs/en/configure/app/dev/proxy.mdx +0 -9
- package/docs/en/configure/app/experiments/lazy-compilation.mdx +0 -106
- package/docs/en/configure/app/html/disable-html-folder.mdx +0 -46
- package/docs/en/configure/app/html/favicon-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/inject-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/en/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/en/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/en/configure/app/html/template-parameters-by-entries.mdx +0 -35
- package/docs/en/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/en/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/en/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/en/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/en/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/en/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/en/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/en/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/en/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/en/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/en/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/en/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/en/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/en/configure/app/runtime/master-app.mdx +0 -36
- package/docs/en/configure/app/runtime/state.mdx +0 -52
- package/docs/en/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/en/configure/app/source/enable-custom-entry.mdx +0 -68
- package/docs/en/configure/app/source/module-scopes.mdx +0 -72
- package/docs/en/configure/app/source/resolve-extension-prefix.mdx +0 -55
- package/docs/en/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/en/configure/app/tools/babel.mdx +0 -225
- package/docs/en/configure/app/tools/esbuild.mdx +0 -44
- package/docs/en/configure/app/tools/pug.mdx +0 -54
- package/docs/en/configure/app/tools/styled-components.mdx +0 -55
- package/docs/en/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/en/configure/app/tools/terser.mdx +0 -58
- package/docs/en/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/en/configure/app/tools/webpack-chain.mdx +0 -253
- package/docs/en/configure/app/tools/webpack.mdx +0 -309
- package/docs/en/guides/deprecated.md +0 -17
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -27
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +0 -290
- package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -298
- package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -26
- package/docs/en/guides/topic-detail/model/_meta.json +0 -14
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -85
- package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -148
- package/docs/en/guides/topic-detail/model/define-model.mdx +0 -62
- package/docs/en/guides/topic-detail/model/faq.mdx +0 -35
- package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -247
- package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/en/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/en/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -68
- package/docs/en/guides/topic-detail/model/use-model.mdx +0 -243
- package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/en/plugin/cli-plugins/migration.mdx +0 -98
- package/docs/en/plugin/official/cli-plugins/plugin-swc.mdx +0 -363
- package/docs/en/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/en/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/en/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -205
- package/docs/en/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/en/plugin/runtime-plugins/migration.mdx +0 -101
- package/docs/en/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/en/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/en/tutorials/first-app/c03-css.mdx +0 -324
- package/docs/en/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/en/tutorials/first-app/c05-loader.mdx +0 -87
- package/docs/en/tutorials/first-app/c06-model.mdx +0 -278
- package/docs/en/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/en/tutorials/first-app/c08-entries.mdx +0 -135
- package/docs/zh/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/zh/apis/app/hooks/src/index_.mdx +0 -39
- package/docs/zh/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/zh/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/zh/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/zh/apis/app/runtime/core/create-app.mdx +0 -35
- package/docs/zh/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/zh/apis/app/runtime/core/use-module-apps.mdx +0 -179
- package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/zh/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/zh/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/zh/apis/app/runtime/model/connect.mdx +0 -143
- package/docs/zh/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/zh/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/zh/apis/app/runtime/model/handle-effect.mdx +0 -108
- package/docs/zh/apis/app/runtime/model/model_.mdx +0 -201
- package/docs/zh/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/zh/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/zh/apis/app/runtime/model/use-static-model.mdx +0 -49
- package/docs/zh/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/zh/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/zh/apis/app/runtime/web-server/hook.mdx +0 -136
- package/docs/zh/apis/app/runtime/web-server/middleware.mdx +0 -114
- package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +0 -165
- package/docs/zh/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/zh/components/bff-proxy-principle.mdx +0 -1
- package/docs/zh/components/builder.mdx +0 -3
- package/docs/zh/components/create-bff-api-app.mdx +0 -25
- package/docs/zh/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/zh/components/default-mwa-generate.mdx +0 -4
- package/docs/zh/components/enable-micro-frontend.mdx +0 -30
- package/docs/zh/components/enableSwc.mdx +0 -17
- package/docs/zh/components/global-proxy-config.mdx +0 -85
- package/docs/zh/components/global-proxy.mdx +0 -29
- package/docs/zh/components/package-manager.mdx +0 -11
- package/docs/zh/components/reduck-notify.mdx +0 -27
- package/docs/zh/components/reduck-tip.mdx +0 -8
- package/docs/zh/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/zh/configure/app/deploy/microFrontend.mdx +0 -55
- package/docs/zh/configure/app/dev/port.mdx +0 -25
- package/docs/zh/configure/app/dev/proxy.mdx +0 -9
- package/docs/zh/configure/app/experiments/lazy-compilation.mdx +0 -105
- package/docs/zh/configure/app/html/disable-html-folder.mdx +0 -45
- package/docs/zh/configure/app/html/favicon-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/inject-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/zh/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/zh/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +0 -36
- package/docs/zh/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/zh/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/zh/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/zh/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/zh/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/zh/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/zh/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/zh/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/zh/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/zh/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/zh/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/zh/configure/app/runtime/master-app.mdx +0 -38
- package/docs/zh/configure/app/runtime/state.mdx +0 -52
- package/docs/zh/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/zh/configure/app/source/enable-custom-entry.mdx +0 -67
- package/docs/zh/configure/app/source/module-scopes.mdx +0 -72
- package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +0 -57
- package/docs/zh/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/zh/configure/app/tools/babel.mdx +0 -224
- package/docs/zh/configure/app/tools/esbuild.mdx +0 -44
- package/docs/zh/configure/app/tools/pug.mdx +0 -54
- package/docs/zh/configure/app/tools/styled-components.mdx +0 -54
- package/docs/zh/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/zh/configure/app/tools/terser.mdx +0 -58
- package/docs/zh/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/zh/configure/app/tools/webpack-chain.mdx +0 -257
- package/docs/zh/configure/app/tools/webpack.mdx +0 -309
- package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -154
- package/docs/zh/guides/deprecated.md +0 -19
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -26
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +0 -332
- package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -296
- package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -27
- package/docs/zh/guides/topic-detail/model/_meta.json +0 -14
- package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -88
- package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -147
- package/docs/zh/guides/topic-detail/model/define-model.mdx +0 -63
- package/docs/zh/guides/topic-detail/model/faq.mdx +0 -36
- package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -256
- package/docs/zh/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/zh/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -67
- package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -248
- package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/zh/plugin/cli-plugins/migration.mdx +0 -98
- package/docs/zh/plugin/official/cli-plugins/plugin-swc.mdx +0 -351
- package/docs/zh/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/zh/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/zh/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -201
- package/docs/zh/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/zh/plugin/runtime-plugins/migration.mdx +0 -101
- package/docs/zh/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/zh/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/zh/tutorials/first-app/c03-css.mdx +0 -323
- package/docs/zh/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/zh/tutorials/first-app/c05-loader.mdx +0 -89
- package/docs/zh/tutorials/first-app/c06-model.mdx +0 -274
- package/docs/zh/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/zh/tutorials/first-app/c08-entries.mdx +0 -135
- /package/docs/en/components/{reduck-migration.mdx → auto-upgrade.mdx} +0 -0
- /package/docs/en/components/{router-legacy-tip.mdx → international/platform-support.mdx} +0 -0
- /package/docs/{zh/components/reduck-migration.mdx → en/components/new-entry-tooltip.mdx} +0 -0
- /package/docs/{zh/components/router-legacy-tip.mdx → en/components/upgrade-browserslist.mdx} +0 -0
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Add Application Entry
|
|
3
|
-
---
|
|
4
|
-
# Add Application Entry
|
|
5
|
-
|
|
6
|
-
In the last chapter, we basically completed the development of the point of contact list application, introduced the usage of some functions in the Modern.js, and recommended best practices.
|
|
7
|
-
|
|
8
|
-
In this chapter, we will describe how to add a new entry to the application.
|
|
9
|
-
|
|
10
|
-
## New entry
|
|
11
|
-
|
|
12
|
-
A complete project may require multiple entries, Modern.js supports the automatic creation of new entries, as mentioned in the previous section, `pnpm run new` can enable optional features.
|
|
13
|
-
|
|
14
|
-
We can also use it to create new project elements and execute `pnpm run new` in the project root directory:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
? Please select the operation you want: Create Element
|
|
18
|
-
? Please select the type of element to create: New "entry"
|
|
19
|
-
? Please fill in the entry name: landing-page
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
When created, the project will look like this:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
.
|
|
26
|
-
├── README.md
|
|
27
|
-
├── modern.config.ts
|
|
28
|
-
├── node_modules
|
|
29
|
-
├── package.json
|
|
30
|
-
├── pnpm-lock.yaml
|
|
31
|
-
├── src
|
|
32
|
-
│ ├── modern-app-env.d.ts
|
|
33
|
-
│ ├── landing-page
|
|
34
|
-
│ │ └── routes
|
|
35
|
-
│ │ ├── index.css
|
|
36
|
-
│ │ ├── layout.tsx
|
|
37
|
-
│ │ └── page.tsx
|
|
38
|
-
│ └── myapp
|
|
39
|
-
│ ├── components
|
|
40
|
-
│ │ ├── Avatar
|
|
41
|
-
│ │ │ └── index.tsx
|
|
42
|
-
│ │ └── Item
|
|
43
|
-
│ │ └── index.tsx
|
|
44
|
-
│ ├── containers
|
|
45
|
-
│ │ └── Contacts.tsx
|
|
46
|
-
│ ├── models
|
|
47
|
-
│ │ └── contacts.ts
|
|
48
|
-
│ ├── routes
|
|
49
|
-
│ │ ├── archives
|
|
50
|
-
│ │ │ └── page.tsx
|
|
51
|
-
│ │ ├── layout.tsx
|
|
52
|
-
│ │ └── page.tsx
|
|
53
|
-
│ └── styles
|
|
54
|
-
│ └── utils.css
|
|
55
|
-
└── tsconfig.json
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
You can see that the files of the contact list application are automatically refactored into `src/myapp/`.
|
|
59
|
-
|
|
60
|
-
At the same time, a new `src/landing-page/` is created, which also has `routes/*` (the `pnpm run new` command only does these things, so you can also easily create new entries or modify entries manually).
|
|
61
|
-
|
|
62
|
-
Execute `pnpm run dev` to display:
|
|
63
|
-
|
|
64
|
-

|
|
65
|
-
|
|
66
|
-
Access `http://localhost:8080/` to see the application as before.
|
|
67
|
-
|
|
68
|
-
Visit `http://localhost:8080/landing-page` to see the landing-page for the new entry you just created (Modern.js automatically generated default page).
|
|
69
|
-
|
|
70
|
-
One of the design principles of the Modern.js framework is [[Convention over Configuration](https://en.wikipedia.org/wiki/Convention_over_configuration) ]. In most cases, you can write code directly by convention without any configuration. The directory structure in `src/` is a convention:
|
|
71
|
-
|
|
72
|
-
`src/myapp/` and `src/landing-page/` are automatically identified as two application portals: myapp and landing-page.
|
|
73
|
-
|
|
74
|
-
The directory name of `src/myapp/` is the same as the project name (`name` in `package.json`), which will be considered as the main entry of the project, and the root path of the project URL (the default in the development environment is `http://localhost:8080/`) will automatically point to the main entry.
|
|
75
|
-
|
|
76
|
-
The URL of other entries is to append the entry name after the root path, such as `http://localhost:8080/landing-page`.
|
|
77
|
-
|
|
78
|
-
Next, we rename `src/myapp/` to `src/contacts/`:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
mv src/myapp src/contacts
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Execute `pnpm run dev` again, the result becomes:
|
|
85
|
-
|
|
86
|
-

|
|
87
|
-
|
|
88
|
-
There is no longer a main entry, the point of contact list is now a normal entry that needs to be accessed with `http://localhost:8080/contacts`.
|
|
89
|
-
|
|
90
|
-
## Modify the configuration by entry
|
|
91
|
-
|
|
92
|
-
In the Modern.js configuration file, we can write our own code to control the configuration of the project.
|
|
93
|
-
|
|
94
|
-
Now, modify the `modern.config.ts` to add something:
|
|
95
|
-
|
|
96
|
-
```ts title="modern.config.ts"
|
|
97
|
-
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
98
|
-
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
|
99
|
-
|
|
100
|
-
export default defineConfig({
|
|
101
|
-
runtime: {
|
|
102
|
-
router: true,
|
|
103
|
-
state: true,
|
|
104
|
-
},
|
|
105
|
-
server: {
|
|
106
|
-
ssr: true,
|
|
107
|
-
ssrByEntries: {
|
|
108
|
-
'landing-page': false,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
plugins: [appTools(), tailwindcssPlugin()],
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Execute `pnpm run dev`, and then open `view-source: http://localhost:8080/landing-page` with the browser, you can see that the content of the `landing-page` web page is dynamically loaded through js, and the SSR function of this page is turned off.
|
|
116
|
-
|
|
117
|
-
If `ssrByEntries` and its value are annotated, the SSR function of landing-page is restored.
|
|
118
|
-
|
|
119
|
-
Other times, you need some more sophisticated logic to do the setup, such as JS variables, expressions, import modules, etc., for example, only in the development environment to enable SSR:
|
|
120
|
-
|
|
121
|
-
```js
|
|
122
|
-
export default defineConfig({
|
|
123
|
-
server: {
|
|
124
|
-
ssrByEntries: {
|
|
125
|
-
'landing-page': process.env.NODE_ENV !== 'production',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
So far, the prototype of our point of contact list application is almost complete 👏👏👏.
|
|
132
|
-
|
|
133
|
-
## Next step
|
|
134
|
-
|
|
135
|
-
Then you can further refine your application by following more tutorials like [Guides](/guides/get-started/quick-start), [configuration](/configure/app/usage), and more.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: index.[tj]s
|
|
3
|
-
sidebar_position: 1
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# index.[tj]s
|
|
7
|
-
|
|
8
|
-
扩展 Modern.js Web Server 的文件,在此文件中可以给 Modern.js 工程启动的 Web Server 添加 [Hook](/apis/app/runtime/web-server/hook) 或 [Middleware](/apis/app/runtime/web-server/middleware)。
|
|
9
|
-
|
|
10
|
-
可以对请求和响应进行拦截处理,鉴权与角色、请求预处理、异常兜底等。也可在内置处理逻辑(包括路由匹配、资源寻址、头部注入、页面渲染,静态 Web 托管)插入特定的业务逻辑。
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: index.[tj]s
|
|
3
|
-
sidebar_position: 4
|
|
4
|
-
---
|
|
5
|
-
# index.[tj]s
|
|
6
|
-
|
|
7
|
-
:::warning
|
|
8
|
-
即将废弃,推荐使用 [`entry.[tj]s`](/apis/app/hooks/src/entry)。
|
|
9
|
-
:::
|
|
10
|
-
|
|
11
|
-
应用使用自定义 `bootstrap` 时的入口标识。
|
|
12
|
-
|
|
13
|
-
通常情况下 [`App.[tj]sx`](/apis/app/hooks/src/app) 钩子文件已经能满足我们的需求,当我们需要在 `bootstrap` 之前添加自定义行为或者完全接管 webpack 打包入口时,可以在 `src` 或者入口目录下放置 `index.[tj]s`。 下面有分两种情况进行讨论:
|
|
14
|
-
|
|
15
|
-
## 在 bootstrap 之前添加自定义行为
|
|
16
|
-
|
|
17
|
-
只需要 `src/index.[tj]s` 默认导出函数:
|
|
18
|
-
|
|
19
|
-
```js title=src/index.js
|
|
20
|
-
import ReactDOM from 'react-dom/client';
|
|
21
|
-
import { bootstrap } from '@modern-js/runtime';
|
|
22
|
-
|
|
23
|
-
export default (App: React.ComponentType) => {
|
|
24
|
-
// do something before bootstrap...
|
|
25
|
-
bootstrap(App, 'root', undefined, ReactDOM);
|
|
26
|
-
};
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 完全接管 webpack 入口
|
|
30
|
-
|
|
31
|
-
当 `src/index.[tj]sx?` 下没有默认导出函数时,该文件即为真正的 webpack 打包入口文件, 可以直接像使用 create-react-app 等脚手架一样组织代码:
|
|
32
|
-
|
|
33
|
-
```js title=src/index.jsx
|
|
34
|
-
import React from 'react';
|
|
35
|
-
import ReactDOM from 'react-dom/client';
|
|
36
|
-
import App from './App';
|
|
37
|
-
|
|
38
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
|
|
39
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: '**/*.stories.[tj]sx'
|
|
3
|
-
sidebar_position: 7
|
|
4
|
-
---
|
|
5
|
-
# **/*.stories.[tj]sx
|
|
6
|
-
|
|
7
|
-
应用项目 Storybook 调试文件。
|
|
8
|
-
|
|
9
|
-
可以在项目源码目录 `src/` 下创建 `*.stories.(js|jsx|ts|tsx|mdx)` 格式的文件作为 Storybook 的调试文件。
|
|
10
|
-
|
|
11
|
-
在项目下执行 `npm run dev story` 命令,支持使用这些文件在 Storybook 中对相关内容进行调试。
|
|
12
|
-
|
|
13
|
-
:::info
|
|
14
|
-
使用 Storybook 需要提前在项目下执行 new 命令启用「Storybook」。
|
|
15
|
-
|
|
16
|
-
:::
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 1
|
|
3
|
-
title: defineConfig
|
|
4
|
-
---
|
|
5
|
-
# defineConfig
|
|
6
|
-
|
|
7
|
-
:::warning
|
|
8
|
-
|
|
9
|
-
该 API 即将废弃,推荐使用 `src/modern.runtime.ts` 定义 Runtime 配置,同时支持静态配置和动态配置,使用姿势请参考 [Runtime 配置](/configure/app/runtime/0-intro.html)
|
|
10
|
-
:::
|
|
11
|
-
|
|
12
|
-
用于动态配置应用。
|
|
13
|
-
|
|
14
|
-
## 使用姿势
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
import { defineConfig } from '@modern-js/runtime';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Runtime 配置通常可以在 `modern.config.js` 的 `runtime` 空间下配置,如 [router](/configure/app/runtime/router) 配置。
|
|
21
|
-
|
|
22
|
-
`modern.config.js` 中的配置是构建时确定的,如果一些配置参数是运行时获取的,或者配置参数是来自于源码中的一个模块(如组件),就需要使用 `defineConfig` API 进行运行时配置。
|
|
23
|
-
|
|
24
|
-
:::info
|
|
25
|
-
`@modern-js/app-tools` 拥有同名 API,用于为配置**提供 TS 类型**,请开发者加以区分。
|
|
26
|
-
|
|
27
|
-
:::
|
|
28
|
-
|
|
29
|
-
## 函数签名
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
function defineConfig(Component, config): any;
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 参数
|
|
36
|
-
|
|
37
|
-
- Component:`React.ComponentType<any>`,App 根组件。
|
|
38
|
-
- config:`Record<string, any>`,运行时的配置。
|
|
39
|
-
|
|
40
|
-
## 示例
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
function App () {
|
|
44
|
-
...
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
defineConfig(App, {
|
|
48
|
-
router: {
|
|
49
|
-
supportHtml5History: false
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
1. `defineConfig` 里可配置 [runtime.state](/configure/app/runtime/state)、[runtime.router](/configure/app/runtime/router) 等运行时配置。
|
|
55
|
-
|
|
56
|
-
2. `defineConfig` 在配置某个属性之前,如 `router`,需要确保 `modern.config.js` 已经配置开启了该功能。
|
|
57
|
-
|
|
58
|
-
3. `defineConfig` 传入的配置会和 `modern.config.js` 中的配置浅 merge,以 `router` 为例,最终应用的配置如下:
|
|
59
|
-
|
|
60
|
-
```json
|
|
61
|
-
{
|
|
62
|
-
// 来自 `modern.config.js` 配置
|
|
63
|
-
...runtime.router
|
|
64
|
-
// 来自 `defineConfig` 配置
|
|
65
|
-
...config.router
|
|
66
|
-
}
|
|
67
|
-
```
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: bootstrap
|
|
3
|
-
---
|
|
4
|
-
# bootstrap
|
|
5
|
-
|
|
6
|
-
:::warning
|
|
7
|
-
即将废弃,推荐使用 [`render`](/apis/app/runtime/core/render)。
|
|
8
|
-
:::
|
|
9
|
-
|
|
10
|
-
用于启动和挂载应用,通常情况下不做手动调用。只有在使用[自定义 Bootstrap](/guides/concept/entries#自定义-bootstrap) 时,才需要使用该 API。
|
|
11
|
-
|
|
12
|
-
## 使用姿势
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import ReactDOM from 'react-dom/client';
|
|
16
|
-
import { bootstrap } from '@modern-js/runtime';
|
|
17
|
-
|
|
18
|
-
bootstrap(App, 'root', undefined, ReactDOM);
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 函数签名
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
type BootStrap<T = unknown> = (
|
|
25
|
-
App: React.ComponentType,
|
|
26
|
-
id: string | HTMLElement | RuntimeContext,
|
|
27
|
-
root?: any,
|
|
28
|
-
ReactDOM?: {
|
|
29
|
-
render?: Renderer;
|
|
30
|
-
hydrate?: Renderer;
|
|
31
|
-
createRoot?: typeof createRoot;
|
|
32
|
-
hydrateRoot?: typeof hydrateRoot;
|
|
33
|
-
},
|
|
34
|
-
) => Promise<T>;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 参数
|
|
38
|
-
|
|
39
|
-
- `AppComponent`:通过 [`createApp`](./create-app) 创建的 ReactElement 实例。
|
|
40
|
-
- `id`:要挂载的 DOM 根元素 id,如 `"root"`。
|
|
41
|
-
- `root`: ReactDOM.createRoot 的返回值,用于 bootstrap 函数外需要 root 销毁组件的场景。
|
|
42
|
-
- `ReactDOM`: ReactDOM 对象,用于区分 React 18 和 React 17 API。
|
|
43
|
-
|
|
44
|
-
## 示例
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
import ReactDOM from 'react-dom/client';
|
|
48
|
-
import { createApp, bootstrap } from '@modern-js/runtime';
|
|
49
|
-
|
|
50
|
-
function App() {
|
|
51
|
-
return <div>Hello Modern.js</div>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const WrappedApp = createApp({
|
|
55
|
-
// 传入自定义插件
|
|
56
|
-
plugins: [customPlugin()],
|
|
57
|
-
})(App);
|
|
58
|
-
|
|
59
|
-
bootstrap(WrappedApp, 'root', undefined, ReactDOM);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
:::info
|
|
63
|
-
由于 `@modern-js/runtime/plugins` 是别名处理的,在 ts 项目中使用时需要声明其类型, 只需要在 `src/modern-app-env.d.ts` 添加以下类型声明即可:
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
declare module '@modern-js/runtime/plugins';
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
:::
|
|
70
|
-
|
|
71
|
-
:::warning
|
|
72
|
-
bootstrap 只支持在 CSR 场景下使用。
|
|
73
|
-
|
|
74
|
-
:::
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: createApp
|
|
3
|
-
---
|
|
4
|
-
# createApp
|
|
5
|
-
|
|
6
|
-
:::warning
|
|
7
|
-
即将废弃,推荐使用 [`createRoot`](/apis/app/runtime/core/create-root)。
|
|
8
|
-
:::
|
|
9
|
-
|
|
10
|
-
用于创建自定义入口,定制运行时插件。
|
|
11
|
-
|
|
12
|
-
## 使用姿势
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import { createApp } from '@modern-js/runtime';
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 函数签名
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import type { Plugin } from '@modern-js/runtime';
|
|
22
|
-
|
|
23
|
-
function createApp(options: { plugins: Plugin[] }): React.ComponentType<any>;
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### 参数
|
|
27
|
-
|
|
28
|
-
- `options`: 可选的参数。
|
|
29
|
-
- `plugins`:自定义的插件扩展。
|
|
30
|
-
|
|
31
|
-
## 示例
|
|
32
|
-
|
|
33
|
-
### 创建自定义入口
|
|
34
|
-
|
|
35
|
-
详见 [`bootstrap`](./bootstrap.mdx)。
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: useLoader
|
|
3
|
-
---
|
|
4
|
-
# useLoader
|
|
5
|
-
|
|
6
|
-
一个同构的 API,通常会用来做异步请求。当 SSR 的时候,服务端使用 `useLoader` 预加载数据,同时浏览器端也会复用这部分数据。
|
|
7
|
-
|
|
8
|
-
:::tip
|
|
9
|
-
在使用 Rspack 作为打包工具时,暂不支持使用 useLoader API。
|
|
10
|
-
:::
|
|
11
|
-
|
|
12
|
-
## 使用姿势
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
import { useLoader } from '@modern-js/runtime';
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 函数签名
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
type LoaderFn = (context: runtimeContext) => Promise<unknow>;
|
|
22
|
-
type Options = {
|
|
23
|
-
onSuccess: (data: Record<string, any>) => void;
|
|
24
|
-
onError: (error: Error) => void;
|
|
25
|
-
initialData: Record<string, any>;
|
|
26
|
-
skip: boolean;
|
|
27
|
-
params: Record<string, any>;
|
|
28
|
-
static: boolean;
|
|
29
|
-
};
|
|
30
|
-
type ReturnData = {
|
|
31
|
-
data: Record<string, any>;
|
|
32
|
-
loading: boolean;
|
|
33
|
-
error: Error;
|
|
34
|
-
reload: (params?: Record<string, any>) => Promise<any> | undefined;
|
|
35
|
-
reloading: boolean;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
:::info
|
|
42
|
-
`runtimeContext` 类型可以参考 [useRuntimeContext](/apis/app/runtime/core/use-runtime-context)。
|
|
43
|
-
|
|
44
|
-
:::
|
|
45
|
-
|
|
46
|
-
### 参数
|
|
47
|
-
|
|
48
|
-
- `loaderFn`:用于加载数据的函数,返回 Promise。
|
|
49
|
-
- `options`:可选配置项。
|
|
50
|
-
- `onSuccess`:执行成功的回调。
|
|
51
|
-
- `onError`:执行失败的回调。
|
|
52
|
-
- `initialData`:首次执行前的初始数据,对应返回值中的 `data` 字段。
|
|
53
|
-
- `skip`:当值为 `true` 时,函数不执行。
|
|
54
|
-
- `params`:当 `params` 序列化结果发生改变时,函数会重新执行。同时,`params` 也会作为函数的第二个参数被传入。
|
|
55
|
-
- `static`:当值为 `true` 时,`useLoader` 用于 [SSG](/guides/basic-features/render/ssg) 编译阶段数据的获取。
|
|
56
|
-
|
|
57
|
-
### 返回值
|
|
58
|
-
|
|
59
|
-
- `data`:执行成功时的返回数据。
|
|
60
|
-
- `loading`:表示函数是否处于执行过程中。
|
|
61
|
-
- `error`:函数执行失败时的错误信息。
|
|
62
|
-
- `reload`:调用后可以重新执行函数。
|
|
63
|
-
- `params`:当值为 `undefined` 时,函数执行时将复用上次的值;否则会使用新的值重新执行函数。
|
|
64
|
-
- `reloading`:调用 `reload` 的执行过程中,`reloading` 值为 `true`。
|
|
65
|
-
|
|
66
|
-
## 示例
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
function Container() {
|
|
70
|
-
const { data, error, loading } = useLoader(
|
|
71
|
-
async (context, params) => {
|
|
72
|
-
console.log(params) // nicole
|
|
73
|
-
return fetch(user);
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
onSuccess: data => {
|
|
77
|
-
console.log('I did success:(', data);
|
|
78
|
-
},
|
|
79
|
-
onError: error => {
|
|
80
|
-
console.log('I met error:)', error);
|
|
81
|
-
},
|
|
82
|
-
initialData: { name: 'nicole', gender: 'female' },
|
|
83
|
-
params: 'nicole'
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
return ...;
|
|
88
|
-
}
|
|
89
|
-
```
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: useModuleApps
|
|
3
|
-
---
|
|
4
|
-
# useModuleApps
|
|
5
|
-
|
|
6
|
-
返回所有微前端子应用的 React 组件,用于可自由控制路由。
|
|
7
|
-
|
|
8
|
-
## 使用姿势
|
|
9
|
-
|
|
10
|
-
```tsx
|
|
11
|
-
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## 函数签名
|
|
15
|
-
|
|
16
|
-
`function useModuleApps(): Record<string, React.FC<any>>`
|
|
17
|
-
|
|
18
|
-
分别返回包裹每个子应用后的 React 组件。
|
|
19
|
-
|
|
20
|
-
## 示例
|
|
21
|
-
|
|
22
|
-
需要先配置微前端子应用信息。
|
|
23
|
-
|
|
24
|
-
import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
|
|
25
|
-
|
|
26
|
-
<EnableMicroFrontend />
|
|
27
|
-
|
|
28
|
-
这里演示主应用为自控式路由的场景,全部场景参考 [体验微前端](/guides/topic-detail/micro-frontend/c02-development.html)
|
|
29
|
-
```tsx title=App.tsx
|
|
30
|
-
function App() {
|
|
31
|
-
const { apps, MApp, Table, Dashboard } = useModuleApps();
|
|
32
|
-
|
|
33
|
-
// 使用的不是 MApp 组件,需要使用 createBrowserRouter 来创建路由
|
|
34
|
-
const router = createBrowserRouter(
|
|
35
|
-
createRoutesFromElements(
|
|
36
|
-
<Route path="/" element={<AppLayout />}>
|
|
37
|
-
<Route key={'table'} path={'table/*'} element={<Table />} />
|
|
38
|
-
<Route key={'dashboard'} path={'dashboard/*'} element={<Dashboard />} />
|
|
39
|
-
</Route>
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
// 方法一:使用 MApp 自动根据配置的 activeWhen 参数加载子应用(本项目配置在 modern.config.ts 中)
|
|
45
|
-
// <BrowserRouter>
|
|
46
|
-
// <MApp />
|
|
47
|
-
// </BrowserRouter>
|
|
48
|
-
|
|
49
|
-
// 方法二:手动写 Route 组件方式加载子应用,方便于需要鉴权等需要前置操作的场景
|
|
50
|
-
<>
|
|
51
|
-
<RouterProvider router={router} />
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
defineConfig(App, {
|
|
57
|
-
masterApp: {
|
|
58
|
-
apps: [
|
|
59
|
-
{
|
|
60
|
-
// name 区分大小写,name 提供的是什么 useModuleApps 返回的就是什么
|
|
61
|
-
name: 'Table',
|
|
62
|
-
entry: 'http://127.0.0.1:8081/',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'Dashboard',
|
|
66
|
-
entry: 'http://localhost:8082',
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
通过 `useModuleApps()` 获取到 `Table` 和 `Dashboard` 子应用组件(名称和配置里的 `name` 字段对应),之后就可以像使用普通的 React 组件一样去加载子应用。
|
|
74
|
-
|
|
75
|
-
### 集中式路由
|
|
76
|
-
|
|
77
|
-
**集中式路由** 是将子应用的激活路由集中配置的方式。我们给子应用列表信息添加 `activeWhen` 字段来启用 **集中式路由**。
|
|
78
|
-
|
|
79
|
-
import MicroRuntimeConfig from "@site-docs/components/micro-runtime-config";
|
|
80
|
-
|
|
81
|
-
<MicroRuntimeConfig />
|
|
82
|
-
|
|
83
|
-
然后在主应用中使用 `useModuleApp` 方法获取 `MApp` 组件, 并在主应用渲染 `MApp`。
|
|
84
|
-
|
|
85
|
-
```tsx title=主应用:App.tsx
|
|
86
|
-
import { useModuleApp } from '@modern-js/plugin-runtime';
|
|
87
|
-
|
|
88
|
-
function App() {
|
|
89
|
-
const { MApp } = useModuleApps();
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<div>
|
|
93
|
-
<MApp />
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
defineConfig(App, {
|
|
99
|
-
masterApp: {
|
|
100
|
-
apps: [
|
|
101
|
-
{
|
|
102
|
-
// name 区分大小写,name 提供的是什么 useModuleApps 返回的就是什么
|
|
103
|
-
name: 'Table',
|
|
104
|
-
activeWhen: '/table',
|
|
105
|
-
entry: 'http://127.0.0.1:8081/',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'Dashboard',
|
|
109
|
-
activeWhen: '/dashboard',
|
|
110
|
-
entry: 'http://localhost:8082',
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
这样启动应用后,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用,访问 `/table` 路由,会渲染 `Table` 子应用。
|
|
118
|
-
|
|
119
|
-
## 加载动画
|
|
120
|
-
|
|
121
|
-
可以通过以下方式,自定义组件加载过程的过渡动画。
|
|
122
|
-
|
|
123
|
-
```js title="App.tsx"
|
|
124
|
-
import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
|
|
125
|
-
|
|
126
|
-
import { RouterProvider, Route, createBrowserRouter, createRoutesFromElements, BrowserRouter, Link, Outlet } from '@modern-js/runtime/router';
|
|
127
|
-
|
|
128
|
-
const AppLayout = () => (
|
|
129
|
-
<>
|
|
130
|
-
<div><Link to={'/table'}>加载约定式路由子应用</Link></div>
|
|
131
|
-
<div><Link to={'/dashboard'}>加载自控式路由子应用</Link></div>
|
|
132
|
-
<div><Link to={'/'}>卸载子应用</Link></div>
|
|
133
|
-
<Outlet />
|
|
134
|
-
</>
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
export default () => {
|
|
138
|
-
const { apps } = useModuleApps();
|
|
139
|
-
|
|
140
|
-
// 使用的不是 MApp 组件,需要使用 createBrowserRouter 来创建路由
|
|
141
|
-
const router = createBrowserRouter(
|
|
142
|
-
createRoutesFromElements(
|
|
143
|
-
<Route path="/" element={<AppLayout />}>
|
|
144
|
-
{apps.map(app => {
|
|
145
|
-
const { Component } = app;
|
|
146
|
-
// 模糊匹配,path 需要写成类似 abc/* 的模式
|
|
147
|
-
return (
|
|
148
|
-
<Route
|
|
149
|
-
key={app.name}
|
|
150
|
-
path={`${app.name.toLowerCase()}/*`}
|
|
151
|
-
element={
|
|
152
|
-
<Component
|
|
153
|
-
loadable={{
|
|
154
|
-
loading: ({ pastDelay, error }: any) => {
|
|
155
|
-
if (error) {
|
|
156
|
-
return <div>error: {error?.message}</div>;
|
|
157
|
-
} else if (pastDelay) {
|
|
158
|
-
return <div>loading</div>;
|
|
159
|
-
} else {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
}}
|
|
164
|
-
/>
|
|
165
|
-
}
|
|
166
|
-
/>
|
|
167
|
-
)
|
|
168
|
-
})}
|
|
169
|
-
</Route>
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<>
|
|
175
|
-
<RouterProvider router={router} />
|
|
176
|
-
</>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
```
|