@modern-js/main-doc 2.69.4 → 3.0.0-alpha.0
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 +2 -3
- 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 +16 -12
- package/docs/en/components/build-output.mdx +45 -0
- 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 +38 -8
- package/docs/en/components/enable-ssg.mdx +48 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/init-app.mdx +40 -17
- package/docs/en/components/international/install-command.mdx +9 -0
- package/docs/en/components/international/introduce.mdx +2 -0
- package/docs/en/components/module-federation.mdx +4 -4
- package/docs/en/components/new-entry-tooltip.mdx +0 -0
- 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-browserslist.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/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/server.mdx +103 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
- package/docs/en/configure/app/html/app-icon.mdx +1 -23
- 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/performance/build-cache.mdx +0 -4
- 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/security/check-syntax.mdx +1 -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/decorators.mdx +4 -2
- package/docs/en/configure/app/source/entries.mdx +0 -2
- 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 +14 -248
- 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 +7 -17
- package/docs/en/guides/_meta.json +1 -2
- package/docs/en/guides/advanced-features/_meta.json +6 -0
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -7
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/docs/en/guides/advanced-features/bff/function.mdx +2 -6
- package/docs/en/guides/advanced-features/bff/sdk.mdx +3 -3
- 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 +437 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +154 -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 +7 -21
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/en/guides/advanced-features/rspack-start.mdx +2 -22
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -34
- 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 +5 -1
- package/docs/en/guides/basic-features/data/data-fetch.mdx +4 -4
- 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 +0 -8
- 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 +394 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +26 -62
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -6
- 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.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +24 -9
- 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 +8 -73
- package/docs/en/guides/get-started/tech-stack.mdx +7 -25
- 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/plugin/cli-plugins/api.mdx +4 -5
- package/docs/en/plugin/cli-plugins/migration.mdx +33 -48
- package/docs/en/plugin/introduction.mdx +39 -27
- 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 +68 -61
- package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
- package/docs/en/plugin/runtime-plugins/migration.mdx +29 -20
- 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 +2 -3
- 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-upload.mdx +8 -5
- package/docs/zh/components/build-output.mdx +45 -0
- 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 +37 -8
- package/docs/zh/components/enable-ssg.mdx +47 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/init-app.mdx +40 -18
- package/docs/zh/components/international/install-command.mdx +8 -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/configure/_meta.json +7 -8
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/server.mdx +104 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
- package/docs/zh/configure/app/html/app-icon.mdx +1 -23
- 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/performance/build-cache.mdx +0 -4
- 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/security/check-syntax.mdx +1 -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/decorators.mdx +4 -4
- package/docs/zh/configure/app/source/entries.mdx +0 -2
- 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 +8 -18
- 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/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 +1 -1
- package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +4 -4
- 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 +441 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +149 -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 +7 -21
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +63 -35
- 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 +8 -5
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +6 -5
- 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 +0 -8
- 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 +413 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -5
- 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.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 +24 -9
- 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 -26
- 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 -32
- package/docs/zh/guides/troubleshooting/builder.mdx +3 -84
- 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 +809 -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/cli-plugins/api.mdx +4 -5
- package/docs/zh/plugin/cli-plugins/migration.mdx +30 -45
- package/docs/zh/plugin/introduction.mdx +36 -24
- 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 +45 -42
- package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
- package/docs/zh/plugin/runtime-plugins/migration.mdx +26 -17
- 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/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/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/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 -249
- package/docs/en/configure/app/tools/webpack.mdx +0 -305
- 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/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/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/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/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/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 -253
- package/docs/zh/configure/app/tools/webpack.mdx +0 -305
- 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/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/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/{zh/components/reduck-migration.mdx → en/components/international/platform-support.mdx} +0 -0
|
@@ -30,15 +30,44 @@ Modern.js 初始化的应用是单入口的,应用结构如下:
|
|
|
30
30
|
└── tsconfig.json
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
在 Modern.js
|
|
33
|
+
在 Modern.js 应用中,你可以很方便的将单入口切换成多入口。手动创建多入口需要以下步骤:
|
|
34
|
+
|
|
35
|
+
import NewEntryTooltip from '@site-docs/components/new-entry-tooltip.mdx';
|
|
36
|
+
|
|
37
|
+
<NewEntryTooltip />
|
|
38
|
+
|
|
39
|
+
1. **将原入口代码移动到以 `package.json` 中 `name` 命名的目录下**
|
|
40
|
+
|
|
41
|
+
假设 `package.json` 中的 `name` 为 `myapp`,需要将 `src/routes/` 目录移动到 `src/myapp/routes/`:
|
|
34
42
|
|
|
35
43
|
```bash
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
# 创建新目录
|
|
45
|
+
mkdir -p src/myapp
|
|
46
|
+
# 移动原入口代码
|
|
47
|
+
mv src/routes src/myapp/routes
|
|
39
48
|
```
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
2. **创建新的入口目录**
|
|
51
|
+
|
|
52
|
+
创建新的入口目录,例如 `new-entry`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 创建新入口目录
|
|
56
|
+
mkdir -p src/new-entry/routes
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
3. **在新入口目录下创建必要的文件**
|
|
60
|
+
|
|
61
|
+
在新入口的 `routes/` 目录下创建基础文件:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 创建基础文件(可根据需要调整内容)
|
|
65
|
+
touch src/new-entry/routes/index.css
|
|
66
|
+
touch src/new-entry/routes/layout.tsx
|
|
67
|
+
touch src/new-entry/routes/page.tsx
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
完成上述步骤后,`src/` 目录结构如下:
|
|
42
71
|
|
|
43
72
|
```bash
|
|
44
73
|
.
|
|
@@ -54,8 +83,6 @@ Modern.js 初始化的应用是单入口的,应用结构如下:
|
|
|
54
83
|
└── page.tsx
|
|
55
84
|
```
|
|
56
85
|
|
|
57
|
-
原本的入口代码被移动到了和 `package.json` 中 `name` 同名的目录下,并创建了 `new-entry` 入口目录。
|
|
58
|
-
|
|
59
86
|
Modern.js 会将与 `package.json` 文件中 `name` 字段同名的入口作为主入口,主入口的路由为 `/`,其他入口的路由为 `/{entryName}`。比如,`package.json` 中的 `name` 为 `myapp` 时,`src/myapp` 会作为应用的主入口。
|
|
60
87
|
|
|
61
88
|
你可以执行 `pnpm run dev` 启动开发服务,此时可以看到新增了一条名为 `/new-entry` 的路由,并且原有页面的路由并未发生变化。
|
|
@@ -66,54 +93,62 @@ Modern.js 会将与 `package.json` 文件中 `name` 字段同名的入口作为
|
|
|
66
93
|
|
|
67
94
|
## 入口类型
|
|
68
95
|
|
|
69
|
-
|
|
96
|
+
Modern.js 支持三种入口类型,每种类型都有不同的使用场景和特点。选择合适的入口类型可以帮助你更好地组织代码。
|
|
70
97
|
|
|
71
|
-
|
|
98
|
+
### 如何识别入口
|
|
72
99
|
|
|
73
|
-
|
|
100
|
+
Modern.js 会自动扫描目录,识别符合条件的入口。一个目录被认定为入口需要满足以下**三个条件之一**:
|
|
74
101
|
|
|
75
|
-
|
|
102
|
+
1. **具有 `routes/` 目录** → 约定式路由入口
|
|
103
|
+
2. **具有 `App.[jt]sx?` 文件** → 自控式路由入口
|
|
104
|
+
3. **具有 `entry.[jt]sx?` 文件** → 自定义入口
|
|
76
105
|
|
|
77
|
-
|
|
78
|
-
你可以通过 [source.entriesDir](/configure/app/source/entries-dir) 修改识别入口的目录。
|
|
79
|
-
:::
|
|
80
|
-
|
|
81
|
-
入口所在目录必须满足以下三个条件之一:
|
|
106
|
+
import EntryScanLogic from '@site-docs/components/entry-scan-logic.mdx';
|
|
82
107
|
|
|
83
|
-
|
|
84
|
-
2. 具有 `App.[jt]sx?` 文件。
|
|
85
|
-
3. 具有 `entry.[jt]sx?` 文件(需要开启 [source.enableCustomEntry](/configure/app/source/enable-custom-entry) 使用)。
|
|
108
|
+
<EntryScanLogic />
|
|
86
109
|
|
|
110
|
+
:::tip 自定义扫描目录
|
|
111
|
+
你可以通过 [source.entriesDir](/configure/app/source/entries-dir) 修改识别入口的目录。
|
|
87
112
|
|
|
88
|
-
当 `src/` 目录满足入口特征时,Modern.js 会认为当前应用为单入口应用。否则,Modern.js 会扫描 `src/` 下的一级目录,并进一步判断是否为入口,此时应用通常为多入口应用。
|
|
89
|
-
|
|
90
|
-
:::tip
|
|
91
|
-
在单入口应用中,默认的入口名为 `main`。
|
|
92
113
|
:::
|
|
93
114
|
|
|
94
|
-
|
|
115
|
+
import EntryMode from '@site-docs/components/entry-mode.mdx';
|
|
116
|
+
|
|
117
|
+
<EntryMode />
|
|
95
118
|
|
|
96
|
-
|
|
119
|
+
接下来我们详细介绍每种入口类型的使用方法。
|
|
97
120
|
|
|
98
|
-
|
|
121
|
+
### 约定式路由
|
|
99
122
|
|
|
100
123
|
如果入口中存在 `routes/` 目录,我们称该入口为约定式路由。Modern.js 会在启动时扫描 `routes/` 下的文件,基于文件约定,自动生成客户端路由(react-router)。例如:
|
|
101
124
|
|
|
102
125
|
```bash
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
src/
|
|
127
|
+
└── routes/
|
|
128
|
+
├── layout.tsx # 布局组件(可选)
|
|
129
|
+
├── page.tsx # 首页组件(/ 路由)
|
|
130
|
+
├── about/
|
|
131
|
+
│ └── page.tsx # 关于页面(/about 路由)
|
|
132
|
+
└── blog/
|
|
133
|
+
├── page.tsx # 博客列表页(/blog 路由)
|
|
134
|
+
└── [id]/
|
|
135
|
+
└── page.tsx # 博客详情页(/blog/:id 路由)
|
|
108
136
|
```
|
|
109
137
|
|
|
110
|
-
|
|
138
|
+
组件对应关系
|
|
139
|
+
|
|
140
|
+
| 文件 | 路由 | 说明 |
|
|
141
|
+
| --------------------------- | ----------- | ------------------ |
|
|
142
|
+
| `routes/layout.tsx` | 全局布局 | 所有页面的外层容器 |
|
|
143
|
+
| `routes/page.tsx` | `/` | 首页 |
|
|
144
|
+
| `routes/about/page.tsx` | `/about` | 关于页面 |
|
|
145
|
+
| `routes/blog/[id]/page.tsx` | `/blog/:id` | 动态路由页面 |
|
|
111
146
|
|
|
112
|
-
详细内容可以参考[路由方案](/guides/basic-features/routes#约定式路由)。
|
|
147
|
+
详细内容可以参考[路由方案](/guides/basic-features/routes/routes#约定式路由)。
|
|
113
148
|
|
|
114
|
-
|
|
149
|
+
### 自控式路由
|
|
115
150
|
|
|
116
|
-
如果入口中存在 `App.[jt]sx?`
|
|
151
|
+
如果入口中存在 `App.[jt]sx?` 文件,该入口就是自控式路由。这种方式给开发者完全的路由控制权。
|
|
117
152
|
|
|
118
153
|
```bash
|
|
119
154
|
.
|
|
@@ -121,8 +156,7 @@ import EntryMode from '@site-docs/components/entry-mode.mdx';
|
|
|
121
156
|
│ └── App.tsx
|
|
122
157
|
```
|
|
123
158
|
|
|
124
|
-
|
|
125
|
-
以 `src/App.tsx` 为约定的入口,Modern.js 不会对路由做额外的操作,开发者可以使用 [React Router 6](https://reactrouter.com/en/main) 的 API 设置客户端路由,或不设置客户端路由。例如以下代码,在应用中自行设置了客户端路由:
|
|
159
|
+
以 `src/App.tsx` 为约定的入口,Modern.js 不会对路由做额外的操作,开发者可以使用 [React Router v7](https://reactrouter.com/en/main) 的 API 设置客户端路由,或不设置客户端路由。例如以下代码,在应用中自行设置了客户端路由:
|
|
126
160
|
|
|
127
161
|
```tsx title="src/App.tsx"
|
|
128
162
|
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
|
@@ -143,24 +177,26 @@ export default () => {
|
|
|
143
177
|
我们推荐开发者使用约定式路由,Modern.js 默认对约定式路由做了一系列资源加载及渲染上的优化,并且提供了开箱即用的 SSR 能力。而在使用自控路由时,这些能力都需要开发者自行封装。
|
|
144
178
|
:::
|
|
145
179
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
:::info
|
|
149
|
-
使用该功能需要开启 [source.enableCustomEntry](/configure/app/source/enable-custom-entry)。
|
|
150
|
-
:::
|
|
180
|
+
### 自定义入口
|
|
151
181
|
|
|
152
182
|
默认情况下,使用约定式路由或自控式路由时,Modern.js 会自动完成渲染。如果你希望自定义这个行为,可以通过自定义入口文件的方式来实现。
|
|
153
183
|
|
|
184
|
+
:::tip
|
|
185
|
+
自定义入口可以和约定式路由及自控式路由入口共存,自定义项目初始化的逻辑。
|
|
186
|
+
|
|
187
|
+
:::
|
|
188
|
+
|
|
154
189
|
如果入口中存在 `entry.[jt]sx` 文件,则 Modern.js 不再控制应用的渲染流程,你可以在 `entry.[jt]sx` 文件中调用 `createRoot` 和 `render` 函数,完成应用入口逻辑。
|
|
155
190
|
|
|
156
|
-
```tsx
|
|
191
|
+
```tsx title="src/entry.tsx"
|
|
157
192
|
import { createRoot } from '@modern-js/runtime/react';
|
|
158
193
|
import { render } from '@modern-js/runtime/browser';
|
|
159
194
|
|
|
195
|
+
// 创建根组件
|
|
160
196
|
const ModernRoot = createRoot();
|
|
161
197
|
|
|
198
|
+
// 渲染到 DOM
|
|
162
199
|
render(<ModernRoot />);
|
|
163
|
-
|
|
164
200
|
```
|
|
165
201
|
|
|
166
202
|
上述代码中,`createRoot` 函数返回的组件为 `routes/` 目录生成或 `App.tsx` 导出的组件,`render` 函数用于处理渲染与挂载组件。例如,你希望在渲染前执行某些异步任务,可以这样实现:
|
|
@@ -172,7 +208,7 @@ import { render } from '@modern-js/runtime/browser';
|
|
|
172
208
|
const ModernRoot = createRoot();
|
|
173
209
|
|
|
174
210
|
async function beforeRender() {
|
|
175
|
-
|
|
211
|
+
// some async request
|
|
176
212
|
}
|
|
177
213
|
|
|
178
214
|
beforeRender().then(() => {
|
|
@@ -180,28 +216,27 @@ beforeRender().then(() => {
|
|
|
180
216
|
});
|
|
181
217
|
```
|
|
182
218
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
:::info
|
|
186
|
-
使用该功能需要开启需要开启 [source.enableCustomEntry](/configure/app/source/enable-custom-entry)。
|
|
187
|
-
:::
|
|
188
|
-
|
|
189
|
-
构建模式指的是不使用 Modern.js 提供的 Runtime 能力,只使用 Modern.js 构建能力的开发模式。当应用中未安装 `@modern-js/runtime` 依赖时,Modern.js 会认为当前应用所有的入口都是构建模式入口。
|
|
190
|
-
|
|
191
|
-
此时,如果入口中存在 `entry.[jt]sx`,则该文件会被识别为 webpack 或 Rspack 的构建入口。此时,Modern.js 不会自动生成入口代码,你需要自行将组件挂载到 DOM 节点上,例如:
|
|
219
|
+
如果你不想使用 Modern.js 任何运行时能力,也可以自行将组件挂载到 DOM 节点上,例如:
|
|
192
220
|
|
|
193
221
|
```js title=src/entry.tsx
|
|
194
222
|
import React from 'react';
|
|
195
|
-
import
|
|
223
|
+
import { createRoot } from 'react-dom/client';
|
|
196
224
|
import App from './App';
|
|
197
225
|
|
|
198
|
-
|
|
226
|
+
const container = document.getElementById('root');
|
|
227
|
+
|
|
228
|
+
if (container) {
|
|
229
|
+
const root = createRoot(container);
|
|
230
|
+
root.render(<App />);
|
|
231
|
+
}
|
|
199
232
|
```
|
|
200
233
|
|
|
201
|
-
|
|
234
|
+
在该模式下,**将无法使用 Modern.js 框架的运行时能力**,比如:
|
|
235
|
+
|
|
202
236
|
- 约定式路由,即基于 `src/routes` 下文件的路由
|
|
203
237
|
- 服务端渲染(SSR)
|
|
204
|
-
-
|
|
238
|
+
- 国际化能力(i18n)
|
|
239
|
+
- 模块联邦能力(Module Federation)
|
|
205
240
|
|
|
206
241
|
## 在配置文件中指定入口
|
|
207
242
|
|
|
@@ -236,9 +271,6 @@ export default defineConfig({
|
|
|
236
271
|
});
|
|
237
272
|
```
|
|
238
273
|
|
|
239
|
-
值得注意的是,默认情况下,Modern.js 认为通过配置指定的入口是**框架模式入口**,将自动生成真正的编译入口。如果你的应用是从 Webpack 或 Vite 等构建工具迁移到 Modern.js 框架时,你通常需要在入口配置中开启 `disableMount` 选项,此时 Modern.js 认为该入口是**构建模式入口**。
|
|
240
|
-
|
|
241
|
-
|
|
242
274
|
## 深入了解
|
|
243
275
|
|
|
244
276
|
页面入口的概念衍生自 webpack 的入口(Entrypoint)概念,其主要用于配置 JavaScript 或其他模块在应用启动时加载和执行。webpack 对于网页应用的 [最佳实践](https://webpack.docschina.org/concepts/entry-points/#multi-page-application) 通常将入口与 HTML 产物对应,即每增加一个入口最终就会在产物中生成一份对应的 HTML 文件。入口引入的模块会在编译打包后生成多个 Chunk 产物,例如对于 JavaScript 模块最终可能会生成数个类似 `dist/static/js/index.ea39u8.js` 的文件产物。
|
|
@@ -251,7 +283,7 @@ export default defineConfig({
|
|
|
251
283
|
|
|
252
284
|
它们的对应关系如下:
|
|
253
285
|
|
|
254
|
-
-
|
|
286
|
+
- 每个网站项目可以包含多个入口
|
|
255
287
|
- 每个入口包含若干个模块(源码文件)
|
|
256
288
|
- 每个入口通常对应一个 HTML 文件产物和若干其它产物。
|
|
257
289
|
- 每个 HTML 文件可以包含多个客户端路由方案(比如在页面中同时使用 `react-router` 和 `@tanstack/react-router`)。
|
|
@@ -274,7 +306,7 @@ export default defineConfig({
|
|
|
274
306
|
|
|
275
307
|
而 Modern.js 在编译时仍会为每个入口生成包含 HTML 文件的完整的客户端产物,用于在服务端渲染失败时降级为客户端渲染使用。
|
|
276
308
|
|
|
277
|
-
另一个特殊情况是使用静态站点生成(SSG)的项目,即使是使用约定式路由搭建的单入口 SSG 应用,Modern.js 也会在
|
|
309
|
+
另一个特殊情况是使用静态站点生成(SSG)的项目,即使是使用约定式路由搭建的单入口 SSG 应用,Modern.js 也会在 Rspack 的流程外为每个 `page.tsx` 文件生成一份单独的 HTML 文件。
|
|
278
310
|
|
|
279
311
|
需要注意的是即使开启服务端渲染,React 通常仍需要执行水合阶段并在前端执行 `react-router` 的路由。
|
|
280
312
|
|
|
@@ -289,32 +321,3 @@ export default defineConfig({
|
|
|
289
321
|
狭义的多页应用可能不包含客户端路由、仅通过 `<a>` 之类的标签元素进行 HTML 静态页面之间的跳转,但实践中上多页应用也经常需要为其入口配置客户端路由以满足不同需求。
|
|
290
322
|
|
|
291
323
|
相反地,通过 `react-router` 定义多个路由的单入口应用因为只生成一个 HTML 文件产物,所以被称为单页应用(Single Page Application)。
|
|
292
|
-
|
|
293
|
-
## 弃用功能
|
|
294
|
-
|
|
295
|
-
目前,如果入口所在的目录满足以下条件,也会成为应用入口。
|
|
296
|
-
|
|
297
|
-
1. 具有 `index.[jt]sx?` 文件。
|
|
298
|
-
2. 具有 `pages/` 目录。
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
`pages/` 目录为 Modern.js 旧版本中的约定式路由,新版本中推荐使用 `routes/` 目录。
|
|
302
|
-
|
|
303
|
-
`index.[jt]sx?` 在旧版本中支持应用自定义 Bootstrap 逻辑和构建模式入口,新版本中推荐使用 `entry.[jt]sx?` 代替。
|
|
304
|
-
|
|
305
|
-
### 自定义 Bootstrap
|
|
306
|
-
|
|
307
|
-
当入口中存在 `index.[jt]sx` 文件,并且当文件默认导出函数时,Modern.js 会将默认的 `bootstrap` 函数作为入参传入,并用导出的函数替代默认的 `bootstrap`,这样开发者可以自定义将组件挂载到 DOM 节点上,或在挂载前添加自定义行为。例如:
|
|
308
|
-
|
|
309
|
-
```tsx
|
|
310
|
-
export default (App: React.ComponentType, bootstrap: () => void) => {
|
|
311
|
-
// do something before bootstrap...
|
|
312
|
-
initSomething().then(() => {
|
|
313
|
-
bootstrap();
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### 构建模式入口
|
|
319
|
-
|
|
320
|
-
当入口目录中存在 `index.[jt]sx`(即将废弃) 并且没有通过 `export default` 导出函数时,该入口也将被认为是构建模式入口。
|
|
@@ -16,30 +16,12 @@ import Bundler from '@site-docs/components/bundler.mdx';
|
|
|
16
16
|
|
|
17
17
|
<Bundler />
|
|
18
18
|
|
|
19
|
-
## Builder
|
|
20
|
-
|
|
21
|
-
import Builder from '@site-docs/components/builder.mdx';
|
|
22
|
-
|
|
23
|
-
<Builder />
|
|
24
|
-
|
|
25
19
|
## CSR
|
|
26
20
|
|
|
27
21
|
CSR 是 "Client-Side Rendering"(客户端渲染)的缩写。它表示页面是在浏览器中通过 JavaScript 渲染的,数据获取、模板和路由等逻辑都在浏览器端完成,而不是在服务器上。
|
|
28
22
|
|
|
29
23
|
在 CSR 中,服务器会向浏览器端发送一个空的 HTML 外壳和一些 JavaScript 脚本,然后由浏览器端从服务器的 API 中拉取数据,并将动态内容渲染到页面中。
|
|
30
24
|
|
|
31
|
-
## Garfish
|
|
32
|
-
|
|
33
|
-
[Garfish](https://garfishjs.org/) 是一套微前端解决方案,主要用于解决 web 应用的跨团队协作、技术体系多样化等问题。
|
|
34
|
-
|
|
35
|
-
它从架构层面出发,将多个独立交付的前端应用组成整体,这些前端应用能够独立开发、独立测试、独立部署,但是在用户视角仍然是内聚的单个产品。
|
|
36
|
-
|
|
37
|
-
## Micro-frontend
|
|
38
|
-
|
|
39
|
-
import MicroFrontend from '@site-docs/components/micro-frontend.mdx';
|
|
40
|
-
|
|
41
|
-
<MicroFrontend />
|
|
42
|
-
|
|
43
25
|
## Module Federation
|
|
44
26
|
|
|
45
27
|
import ModuleFederation from '@site-docs/components/module-federation.mdx';
|
|
@@ -13,7 +13,7 @@ Modern.js 能为开发者提供极致的**开发体验(Development Experience
|
|
|
13
13
|
|
|
14
14
|
它主要包含以下特性:
|
|
15
15
|
|
|
16
|
-
- 🚀 **Rust
|
|
16
|
+
- 🚀 **Rust 构建**:Modern.js 使用 Rsbuild/Rspack 作为构建工具,编译飞快。
|
|
17
17
|
- 🪜 **渐进式**:使用最精简的模板创建项目,通过生成器逐步开启插件功能,定制解决方案。
|
|
18
18
|
- 🏠 **一体化**:开发与生产环境 Web Server 逻辑一致,CSR 和 SSR 同构开发,函数即接口的 API 服务调用。
|
|
19
19
|
- 📦 **开箱即用**:默认 TS 支持,内置构建、ESLint、调试工具,全功能可测试。
|
|
@@ -43,7 +43,3 @@ Umi 是中文社区中非常流行的 React 框架,也是蚂蚁集团的底层
|
|
|
43
43
|
### Remix
|
|
44
44
|
|
|
45
45
|
请参考 [Modern.js vs Remix](https://github.com/web-infra-dev/modern.js/discussions/4872)。
|
|
46
|
-
|
|
47
|
-
## 下一步
|
|
48
|
-
|
|
49
|
-
如果你希望了解如何使用 Modern.js 框架,可以尝试 [创建第一个应用](/tutorials/first-app/c01-start),或是阅读 [快速上手](/guides/get-started/quick-start)。
|
|
@@ -11,24 +11,7 @@ import Prerequisites from '@site-docs/components/prerequisites';
|
|
|
11
11
|
|
|
12
12
|
<Prerequisites />
|
|
13
13
|
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
Modern.js 提供了 `@modern-js/create` 工具来创建项目,不需要全局安装,直接使用 `npx` 按需运行即可。
|
|
17
|
-
|
|
18
|
-
你可以在已有的空目录来创建项目:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
mkdir myapp && cd myapp
|
|
22
|
-
npx @modern-js/create@latest
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
也可以直接用新目录创建项目:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npx @modern-js/create@latest myapp
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## 初始化项目
|
|
14
|
+
## 创建项目
|
|
32
15
|
|
|
33
16
|
import InitApp from '@site-docs/components/init-app';
|
|
34
17
|
|
|
@@ -50,17 +33,10 @@ import DebugApp from '@site-docs/components/debug-app';
|
|
|
50
33
|
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
51
34
|
|
|
52
35
|
export default defineConfig({
|
|
53
|
-
runtime: {
|
|
54
|
-
router: true,
|
|
55
|
-
},
|
|
56
36
|
server: {
|
|
57
37
|
ssr: true,
|
|
58
38
|
},
|
|
59
|
-
plugins: [
|
|
60
|
-
appTools({
|
|
61
|
-
bundler: 'rspack', // Set to 'webpack' to enable webpack
|
|
62
|
-
}),
|
|
63
|
-
],
|
|
39
|
+
plugins: [appTools()],
|
|
64
40
|
});
|
|
65
41
|
```
|
|
66
42
|
|
|
@@ -71,7 +47,6 @@ export default defineConfig({
|
|
|
71
47
|
在新创建的工程中,默认会安装 `@modern-js/app-tools` npm 包,它是 Modern.js 框架的核心包,主要提供以下能力:
|
|
72
48
|
|
|
73
49
|
- 提供 `modern dev`, `modern build` 等常用的 CLI 命令。
|
|
74
|
-
- 集成 Modern.js Core,提供配置解析、插件加载等能力。
|
|
75
50
|
- 集成 Rsbuild,提供构建能力。
|
|
76
51
|
- 集成 Modern.js Server,提供开发和生产服务器相关能力。
|
|
77
52
|
|
|
@@ -87,51 +62,9 @@ export default defineConfig({
|
|
|
87
62
|
|
|
88
63
|
## 构建项目
|
|
89
64
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
$ pnpm run build
|
|
94
|
-
|
|
95
|
-
> modern build
|
|
96
|
-
|
|
97
|
-
Modern.js Framework
|
|
98
|
-
|
|
99
|
-
info Starting production build...
|
|
100
|
-
info Type checker is enabled. It may take some time.
|
|
101
|
-
ready Client compiled in 6.19 s
|
|
102
|
-
info Production file sizes:
|
|
103
|
-
|
|
104
|
-
File Size Gzipped
|
|
105
|
-
dist/routes-manifest.json 0.74 kB 0.28 kB
|
|
106
|
-
dist/static/css/async/page.d7915515.css 1.4 kB 0.69 kB
|
|
107
|
-
dist/static/js/main.5ae469e7.js 3.0 kB 1.3 kB
|
|
108
|
-
dist/html/main/index.html 6.0 kB 2.6 kB
|
|
109
|
-
dist/static/js/async/page.ddc8a4c1.js 19.2 kB 6.7 kB
|
|
110
|
-
dist/static/js/34.171fffdb.js 21.3 kB 7.1 kB
|
|
111
|
-
dist/static/js/lib-router.8995a55e.js 55.3 kB 18.1 kB
|
|
112
|
-
dist/static/js/lib-lodash.53ec3384.js 71.4 kB 24.8 kB
|
|
113
|
-
dist/static/js/lib-react.b5856db9.js 140.0 kB 45.2 kB
|
|
114
|
-
dist/static/js/lib-polyfill.86c452b3.js 213.3 kB 69.9 kB
|
|
115
|
-
|
|
116
|
-
Total size: 531.8 kB
|
|
117
|
-
Gzipped size: 176.7 kB
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
构建产物默认生成到 `dist/`,目录结构如下:
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
dist
|
|
124
|
-
├── html
|
|
125
|
-
│ └── main
|
|
126
|
-
├── modern.config.json
|
|
127
|
-
├── route.json
|
|
128
|
-
├── routes-manifest.json
|
|
129
|
-
└── static
|
|
130
|
-
├── css
|
|
131
|
-
└── js
|
|
132
|
-
```
|
|
65
|
+
import BuildOutput from '@site-docs/components/build-output';
|
|
133
66
|
|
|
134
|
-
|
|
67
|
+
<BuildOutput />
|
|
135
68
|
|
|
136
69
|
## 本地验证
|
|
137
70
|
|
|
@@ -148,7 +81,7 @@ info Starting production server...
|
|
|
148
81
|
> Network: http://192.168.0.1:8080/
|
|
149
82
|
```
|
|
150
83
|
|
|
151
|
-
在浏览器中打开 `http://localhost:
|
|
84
|
+
在浏览器中打开 `http://localhost:8080/`,内容应该和 `pnpm run dev` 时一致。
|
|
152
85
|
|
|
153
86
|
## 部署
|
|
154
87
|
|
|
@@ -10,25 +10,15 @@ Modern.js 框架默认集成了一些社区中流行的库和开发工具。
|
|
|
10
10
|
|
|
11
11
|
## UI 库
|
|
12
12
|
|
|
13
|
-
Modern.js 使用 [React
|
|
13
|
+
Modern.js 使用 [React 19](https://react.dev/) 来构建用户界面,同时也兼容 React 18。
|
|
14
14
|
|
|
15
15
|
Modern.js 底层的 Rsbuild 支持构建 Vue 应用,如果你需要使用 Vue,可以参考 [Rsbuild - Vue](https://rsbuild.rs/zh/guide/framework/vue)。
|
|
16
16
|
|
|
17
17
|
## 路由
|
|
18
18
|
|
|
19
|
-
Modern.js 的路由基于 [React Router
|
|
19
|
+
Modern.js 的路由基于 [React Router 7](https://reactrouter.com/en/main)。
|
|
20
20
|
|
|
21
|
-
Modern.js 支持约定式路由、自控式路由或其他路由方案,请参考 [
|
|
22
|
-
|
|
23
|
-
## 微前端
|
|
24
|
-
|
|
25
|
-
Modern.js 提供对 [Garfish](https://www.garfishjs.org/) 微前端框架开箱即用的支持。
|
|
26
|
-
|
|
27
|
-
同时,我们也正在与 [Module Federation](https://webpack.js.org/concepts/module-federation/) 的作者 Zack Jackson 合作,以提供更完整的解决方案。
|
|
28
|
-
|
|
29
|
-
## 状态管理
|
|
30
|
-
|
|
31
|
-
Modern.js 可以与社区中任意的状态管理库搭配使用,比如 [Redux](https://redux.js.org/)、[Jotai](https://jotai.org/)、[Zustand](https://docs.pmnd.rs/zustand)、[Valtio](https://valtio.pmnd.rs/) 等。
|
|
21
|
+
Modern.js 支持约定式路由、自控式路由或其他路由方案,请参考 [页面入口](/guides/concept/entries) 进行选择。
|
|
32
22
|
|
|
33
23
|
## 包管理器
|
|
34
24
|
|
|
@@ -38,23 +28,17 @@ Modern.js 可以与社区中任意的包管理器搭配使用,比如 [npm](htt
|
|
|
38
28
|
|
|
39
29
|
## 打包工具
|
|
40
30
|
|
|
41
|
-
Modern.js 使用 [
|
|
42
|
-
|
|
43
|
-
默认使用的打包工具为 Webpack 5,你可以参考 [使用 Rspack](/guides/advanced-features/rspack-start) 来切换到更快的 Rspack。
|
|
31
|
+
Modern.js 使用 [Rspack](https://rspack.rs/) 来打包你的 Web 应用。
|
|
44
32
|
|
|
45
33
|
## 转译工具
|
|
46
34
|
|
|
47
|
-
Modern.js 使用 [
|
|
35
|
+
Modern.js 使用 [SWC](https://swc.rs/) 作为 JS 转译工具,将 TypeScript 或 JSX 转义为可以在浏览器上运行的 JavaScript 代码,并进行语法降级。
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
- 使用 Rspack 打包时,默认为 SWC,支持切换到 Babel。
|
|
37
|
+
在启用 Rspack 构建时,`babel-loader` 默认不会被启用。如需添加 [Babel](https://babeljs.io/) 插件,可通过 `tools.babel` 配置,此时会产生额外的编译开销,在一定程度上拖慢 Rspack 构建速度。
|
|
51
38
|
|
|
52
39
|
## 压缩工具
|
|
53
40
|
|
|
54
|
-
在生产环境构建时,Modern.js 使用 [
|
|
55
|
-
|
|
56
|
-
- 使用 Webpack 打包时,默认使用 Terser 压缩 JS 代码,支持切换到 SWC 或 esbuild。
|
|
57
|
-
- 使用 Rspack 打包时,默认使用 SWC 压缩 JS 代码,暂不支持切换到其他工具。
|
|
41
|
+
在生产环境构建时,Modern.js 使用 [SWC](https://swc.rs/) 压缩 JS 代码。
|
|
58
42
|
|
|
59
43
|
## CSS 转换
|
|
60
44
|
|
|
@@ -62,7 +46,7 @@ Modern.js 使用 [PostCSS](https://postcss.org/) 来转换 CSS 代码,并默
|
|
|
62
46
|
|
|
63
47
|
Modern.js 支持 [启用 Lightning CSS](/configure/app/tools/lightningcss-loader),使用 Lightning CSS 降级 CSS 语法。
|
|
64
48
|
|
|
65
|
-
Modern.js 支持 [启用 Tailwind CSS](/guides/basic-features/css/tailwindcss),并同时兼容 Tailwind CSS
|
|
49
|
+
Modern.js 支持 [启用 Tailwind CSS](/guides/basic-features/css/tailwindcss),并同时兼容 Tailwind CSS v3 和 v4 版本。
|
|
66
50
|
|
|
67
51
|
## CSS 预处理器
|
|
68
52
|
|
|
@@ -87,8 +71,6 @@ Modern.js 支持使用 [styled-components](https://styled-components.com/),请
|
|
|
87
71
|
|
|
88
72
|
Modern.js 可以与社区中任意的 React 组件库搭配使用,比如 [MUI](https://mui.com/)、[Ant Design](https://ant.design/)、[Arco Design](https://github.com/arco-design/arco-design)、[Semi Design](https://semi.design/)、[Radix UI](https://www.radix-ui.com/) 等。
|
|
89
73
|
|
|
90
|
-
同时,Modern.js 内置了对 Ant Design 和 Arco Design 的 [按需引入](/configure/app/source/transform-import) 支持。
|
|
91
|
-
|
|
92
74
|
## 组件开发
|
|
93
75
|
|
|
94
76
|
Modern.js 支持使用 [Storybook](https://storybook.js.org/) 来开发 UI 组件。该功能为可选功能,请参考 [使用 Storybook](/guides/basic-features/debug/using-storybook) 启用。
|
|
@@ -2,46 +2,54 @@
|
|
|
2
2
|
sidebar_position: 3
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { PackageManagerTabs } from '@theme';
|
|
6
|
+
import ReleaseNote from '@site-docs/components/release-note';
|
|
7
|
+
|
|
5
8
|
# 版本升级
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
import Upgrade from '@site-docs/components/auto-upgrade';
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
<Upgrade />
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
## 手动升级
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
Modern.js 所有的官方包使用**统一版本号**进行发布,因此升级时需要将所有 `@modern-js/**` 包的版本统一更新到目标版本。
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
### 升级步骤
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
> modern upgrade
|
|
20
|
+
1. **查看最新版本**
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
[INFO] [Modern.js 最新版本]: x.y.z
|
|
22
|
-
[INFO] 已更新 Modern.js 依赖至最新版本!
|
|
23
|
-
```
|
|
22
|
+
你可以通过以下方式查看 Modern.js 的最新版本:
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
- 访问 [npm](https://www.npmjs.com/package/@modern-js/app-tools) 查看 `@modern-js/app-tools` 的最新版本
|
|
25
|
+
- 查看 [GitHub Releases](https://github.com/web-infra-dev/modern.js/releases)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
如果项目的 package.json 中没有声明 upgrade 命令,你可以执行 `npx modern upgrade`,效果是等价的。
|
|
29
|
-
:::
|
|
27
|
+
<ReleaseNote />
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
2. **更新 package.json**
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
在项目的 `package.json` 中,将所有 `@modern-js/**` 包的版本更新到目标版本。例如:
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
```json title="package.json"
|
|
34
|
+
{
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@modern-js/app-tools": "3.0.0",
|
|
37
|
+
"@modern-js/runtime": "3.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@modern-js/types": "3.0.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
3. **重新安装依赖**
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
更新完 `package.json` 后,重新安装依赖:
|
|
40
48
|
|
|
41
|
-
<
|
|
49
|
+
<PackageManagerTabs command="install" />
|
|
42
50
|
|
|
43
51
|
:::tip
|
|
44
|
-
当升级时,需要对 Modern.js
|
|
52
|
+
当升级时,需要对 Modern.js 官方提供的所有包做统一升级,而不是升级单个依赖。确保所有 `@modern-js/**` 包的版本号保持一致。
|
|
45
53
|
:::
|
|
46
54
|
|
|
47
55
|
## 版本管理策略
|
|
@@ -58,7 +66,6 @@ import ReleaseNote from '@site-docs/components/release-note';
|
|
|
58
66
|
|
|
59
67
|
这样可以确保依赖的版本是完全确定的,从而保证构建的一致性和可预测性。
|
|
60
68
|
|
|
61
|
-
|
|
62
69
|
## 锁定子依赖
|
|
63
70
|
|
|
64
71
|
当项目某个子依赖出现问题,而 Modern.js 无法立即更新时,可以使用包管理器锁定子依赖版本。
|
|
@@ -4,17 +4,5 @@
|
|
|
4
4
|
"name": "module-federation",
|
|
5
5
|
"label": "module-federation",
|
|
6
6
|
"collapsed": true
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"type": "dir",
|
|
10
|
-
"name": "micro-frontend",
|
|
11
|
-
"label": "micro-frontend",
|
|
12
|
-
"collapsed": true
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"type": "dir",
|
|
16
|
-
"name": "model",
|
|
17
|
-
"label": "reduck",
|
|
18
|
-
"collapsed": true
|
|
19
7
|
}
|
|
20
8
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
["introduce", "usage", "application", "ssr", "deploy"]
|
|
1
|
+
["introduce", "usage", "application", "ssr", "deploy", "i18n"]
|