@bleedingdev/modern-js-main-doc 3.2.0-ultramodern.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/LICENSE +21 -0
- package/README.md +23 -0
- package/builder-doc/docs/en/config/performance/rsdoctor.md +37 -0
- package/builder-doc/docs/zh/config/performance/rsdoctor.md +37 -0
- package/docs/en/_nav.json +36 -0
- package/docs/en/apis/_meta.json +13 -0
- package/docs/en/apis/app/commands.mdx +215 -0
- package/docs/en/apis/app/hooks/_meta.json +28 -0
- package/docs/en/apis/app/hooks/api/lambda.mdx +13 -0
- package/docs/en/apis/app/hooks/config/_meta.json +1 -0
- package/docs/en/apis/app/hooks/config/favicon.mdx +29 -0
- package/docs/en/apis/app/hooks/config/html.mdx +9 -0
- package/docs/en/apis/app/hooks/config/icon.mdx +29 -0
- package/docs/en/apis/app/hooks/config/mock.mdx +7 -0
- package/docs/en/apis/app/hooks/config/public.mdx +30 -0
- package/docs/en/apis/app/hooks/config/upload.mdx +54 -0
- package/docs/en/apis/app/hooks/modern-config.mdx +9 -0
- package/docs/en/apis/app/hooks/server/server.mdx +10 -0
- package/docs/en/apis/app/hooks/shared.mdx +7 -0
- package/docs/en/apis/app/hooks/src/app.mdx +30 -0
- package/docs/en/apis/app/hooks/src/entry.mdx +39 -0
- package/docs/en/apis/app/hooks/src/entry.server.mdx +56 -0
- package/docs/en/apis/app/hooks/src/modern.runtime.mdx +9 -0
- package/docs/en/apis/app/hooks/src/routes.mdx +90 -0
- package/docs/en/apis/app/hooks/src/server.mdx +7 -0
- package/docs/en/apis/app/runtime/_meta.json +32 -0
- package/docs/en/apis/app/runtime/bff/use-backend-context.mdx +30 -0
- package/docs/en/apis/app/runtime/core/create-root.mdx +22 -0
- package/docs/en/apis/app/runtime/core/render.mdx +42 -0
- package/docs/en/apis/app/runtime/core/runtime-context.mdx +160 -0
- package/docs/en/apis/app/runtime/router/router.mdx +288 -0
- package/docs/en/apis/app/runtime/ssr/no-ssr.mdx +38 -0
- package/docs/en/apis/app/runtime/ssr/renderStreaming.mdx +71 -0
- package/docs/en/apis/app/runtime/ssr/renderString.mdx +64 -0
- package/docs/en/apis/app/runtime/ssr/requestHandler.mdx +48 -0
- package/docs/en/apis/app/runtime/utility/css-in-js.mdx +44 -0
- package/docs/en/apis/app/runtime/utility/head.mdx +38 -0
- package/docs/en/apis/app/runtime/utility/loadable.mdx +85 -0
- package/docs/en/community/_meta.json +11 -0
- package/docs/en/community/blog/2022-0708-updates.md +95 -0
- package/docs/en/community/blog/2022-0910-updates.md +80 -0
- package/docs/en/community/blog/_meta.json +7 -0
- package/docs/en/community/blog/overview.md +67 -0
- package/docs/en/community/blog/v2-release-note.mdx +244 -0
- package/docs/en/community/blog/v3-release-note.mdx +628 -0
- package/docs/en/community/contributing-guide.mdx +257 -0
- package/docs/en/community/releases.mdx +31 -0
- package/docs/en/community/showcase.mdx +15 -0
- package/docs/en/community/team.mdx +29 -0
- package/docs/en/components/auto-upgrade.mdx +0 -0
- package/docs/en/components/bff-upload.mdx +97 -0
- package/docs/en/components/build-output.mdx +45 -0
- package/docs/en/components/bundler.mdx +3 -0
- package/docs/en/components/convention-routing-motivation.mdx +0 -0
- package/docs/en/components/debug-app.mdx +15 -0
- package/docs/en/components/default-browserslist.mdx +7 -0
- package/docs/en/components/deploy-command.mdx +14 -0
- package/docs/en/components/deploy.mdx +1 -0
- package/docs/en/components/enable-bff-caution.mdx +3 -0
- package/docs/en/components/enable-bff.mdx +56 -0
- package/docs/en/components/enable-ssg.mdx +49 -0
- package/docs/en/components/entry-mode.mdx +0 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/extend-bff-function.mdx +3 -0
- package/docs/en/components/hono.mdx +120 -0
- package/docs/en/components/init-app.mdx +111 -0
- package/docs/en/components/init-rspack-app.mdx +5 -0
- package/docs/en/components/internal-logger.mdx +25 -0
- package/docs/en/components/internal-metrics.mdx +20 -0
- 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 +10 -0
- package/docs/en/components/international/instance-code.mdx +16 -0
- package/docs/en/components/international/introduce.mdx +5 -0
- package/docs/en/components/international/platform-support.mdx +0 -0
- package/docs/en/components/language-config.mdx +9 -0
- package/docs/en/components/micro-frontend.mdx +6 -0
- package/docs/en/components/micro-master-manifest-config.mdx +15 -0
- package/docs/en/components/micro-runtime-config.mdx +17 -0
- package/docs/en/components/module-federation.mdx +7 -0
- package/docs/en/components/new-entry-tooltip.mdx +0 -0
- package/docs/en/components/nodeVersion.mdx +28 -0
- package/docs/en/components/other-plugins.mdx +0 -0
- package/docs/en/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/en/components/output-distpath-warning.mdx +0 -0
- package/docs/en/components/output-polyfill-extend.mdx +1 -0
- package/docs/en/components/prerequisites.mdx +18 -0
- package/docs/en/components/release-note.mdx +1 -0
- package/docs/en/components/routes-practice.mdx +0 -0
- package/docs/en/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/en/components/rsbuild.mdx +3 -0
- package/docs/en/components/rsc-deploy-tip.mdx +1 -0
- package/docs/en/components/rspack.mdx +3 -0
- package/docs/en/components/rspackTip.mdx +7 -0
- package/docs/en/components/runtime-cli-config.mdx +0 -0
- package/docs/en/components/serve-command.mdx +22 -0
- package/docs/en/components/ssr-monitor.mdx +3 -0
- package/docs/en/components/stream-ssr-performance.mdx +0 -0
- package/docs/en/components/swc.mdx +3 -0
- package/docs/en/components/tech-stack-node-framework.mdx +1 -0
- package/docs/en/components/turtorials-example-list.mdx +2 -0
- package/docs/en/components/ua-polyfill.mdx +44 -0
- package/docs/en/components/upgrade-browserslist.mdx +0 -0
- package/docs/en/components/upgrade-config-deploy.mdx +0 -0
- package/docs/en/components/upgrade-faq.mdx +0 -0
- package/docs/en/configure/_meta.json +78 -0
- package/docs/en/configure/app/bff/cross-project.mdx +24 -0
- package/docs/en/configure/app/bff/effect.mdx +152 -0
- package/docs/en/configure/app/bff/prefix.mdx +33 -0
- package/docs/en/configure/app/bff/runtime-framework.mdx +28 -0
- package/docs/en/configure/app/builder-plugins.mdx +70 -0
- package/docs/en/configure/app/dev/asset-prefix.mdx +18 -0
- package/docs/en/configure/app/dev/before-start-url.mdx +21 -0
- package/docs/en/configure/app/dev/client.mdx +45 -0
- package/docs/en/configure/app/dev/hmr.mdx +14 -0
- package/docs/en/configure/app/dev/host.mdx +22 -0
- package/docs/en/configure/app/dev/https.mdx +81 -0
- package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/live-reload.mdx +14 -0
- package/docs/en/configure/app/dev/progress-bar.mdx +23 -0
- package/docs/en/configure/app/dev/server.mdx +128 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +36 -0
- package/docs/en/configure/app/dev/start-url.mdx +53 -0
- package/docs/en/configure/app/dev/watch-files.mdx +31 -0
- package/docs/en/configure/app/dev/write-to-disk.mdx +14 -0
- package/docs/en/configure/app/experiments/source-build.mdx +33 -0
- package/docs/en/configure/app/html/app-icon.mdx +32 -0
- package/docs/en/configure/app/html/crossorigin.mdx +14 -0
- package/docs/en/configure/app/html/favicon.mdx +20 -0
- package/docs/en/configure/app/html/inject.mdx +14 -0
- package/docs/en/configure/app/html/meta.mdx +28 -0
- package/docs/en/configure/app/html/mount-id.mdx +14 -0
- package/docs/en/configure/app/html/output-structure.mdx +14 -0
- package/docs/en/configure/app/html/script-loading.mdx +14 -0
- package/docs/en/configure/app/html/tags.mdx +19 -0
- package/docs/en/configure/app/html/template-parameters.mdx +37 -0
- package/docs/en/configure/app/html/template.mdx +14 -0
- package/docs/en/configure/app/html/title.mdx +22 -0
- package/docs/en/configure/app/output/asset-prefix.mdx +18 -0
- package/docs/en/configure/app/output/assets-retry.mdx +81 -0
- package/docs/en/configure/app/output/charset.mdx +14 -0
- package/docs/en/configure/app/output/clean-dist-path.mdx +20 -0
- package/docs/en/configure/app/output/convert-to-rem.mdx +83 -0
- package/docs/en/configure/app/output/copy.mdx +14 -0
- package/docs/en/configure/app/output/css-modules.mdx +52 -0
- package/docs/en/configure/app/output/data-uri-limit.mdx +30 -0
- package/docs/en/configure/app/output/disable-css-module-extension.mdx +59 -0
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +45 -0
- package/docs/en/configure/app/output/disable-svgr.mdx +20 -0
- package/docs/en/configure/app/output/disable-ts-checker.mdx +53 -0
- package/docs/en/configure/app/output/dist-path.mdx +51 -0
- package/docs/en/configure/app/output/enable-asset-manifest.mdx +40 -0
- package/docs/en/configure/app/output/enable-css-module-tsdeclaration.mdx +32 -0
- package/docs/en/configure/app/output/enable-inline-route-manifests.mdx +20 -0
- package/docs/en/configure/app/output/externals.mdx +24 -0
- package/docs/en/configure/app/output/filename-hash.mdx +14 -0
- package/docs/en/configure/app/output/filename.mdx +59 -0
- package/docs/en/configure/app/output/inject-styles.mdx +14 -0
- package/docs/en/configure/app/output/inline-scripts.mdx +33 -0
- package/docs/en/configure/app/output/inline-styles.mdx +33 -0
- package/docs/en/configure/app/output/legal-comments.mdx +22 -0
- package/docs/en/configure/app/output/minify.mdx +26 -0
- package/docs/en/configure/app/output/override-browserslist.mdx +26 -0
- package/docs/en/configure/app/output/polyfill.mdx +18 -0
- package/docs/en/configure/app/output/source-map.mdx +34 -0
- package/docs/en/configure/app/output/split-route-chunks.mdx +20 -0
- package/docs/en/configure/app/output/ssg.mdx +85 -0
- package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
- package/docs/en/configure/app/output/svg-default-export.mdx +34 -0
- package/docs/en/configure/app/output/temp-dir.mdx +24 -0
- package/docs/en/configure/app/performance/build-cache.mdx +43 -0
- package/docs/en/configure/app/performance/chunk-split.mdx +44 -0
- package/docs/en/configure/app/performance/dns-prefetch.mdx +19 -0
- package/docs/en/configure/app/performance/preconnect.mdx +20 -0
- package/docs/en/configure/app/performance/prefetch.mdx +25 -0
- package/docs/en/configure/app/performance/preload.mdx +27 -0
- package/docs/en/configure/app/performance/print-file-size.mdx +44 -0
- package/docs/en/configure/app/performance/profile.mdx +14 -0
- package/docs/en/configure/app/performance/remove-console.mdx +14 -0
- package/docs/en/configure/app/performance/remove-moment-locale.mdx +14 -0
- package/docs/en/configure/app/performance/rsdoctor.mdx +39 -0
- package/docs/en/configure/app/plugins.mdx +59 -0
- 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 +61 -0
- package/docs/en/configure/app/runtime/plugins.mdx +58 -0
- package/docs/en/configure/app/runtime/router.mdx +39 -0
- package/docs/en/configure/app/security/check-syntax.mdx +73 -0
- package/docs/en/configure/app/security/nonce.mdx +19 -0
- package/docs/en/configure/app/security/sri.mdx +24 -0
- package/docs/en/configure/app/server/base-url.mdx +30 -0
- package/docs/en/configure/app/server/port.mdx +22 -0
- package/docs/en/configure/app/server/public-routes.mdx +26 -0
- package/docs/en/configure/app/server/routes.mdx +90 -0
- package/docs/en/configure/app/server/rsc.mdx +30 -0
- package/docs/en/configure/app/server/ssr-by-entries.mdx +29 -0
- package/docs/en/configure/app/server/ssr.mdx +85 -0
- package/docs/en/configure/app/server/tsconfig-path.mdx +63 -0
- package/docs/en/configure/app/source/alias-strategy.mdx +18 -0
- package/docs/en/configure/app/source/alias.mdx +27 -0
- package/docs/en/configure/app/source/config-dir.mdx +24 -0
- package/docs/en/configure/app/source/decorators.mdx +29 -0
- package/docs/en/configure/app/source/define.mdx +20 -0
- package/docs/en/configure/app/source/disable-default-entries.mdx +32 -0
- package/docs/en/configure/app/source/enable-async-entry.mdx +54 -0
- package/docs/en/configure/app/source/enable-async-pre-entry.mdx +30 -0
- package/docs/en/configure/app/source/entries-dir.mdx +39 -0
- package/docs/en/configure/app/source/entries.mdx +183 -0
- package/docs/en/configure/app/source/exclude.mdx +14 -0
- package/docs/en/configure/app/source/global-vars.mdx +110 -0
- package/docs/en/configure/app/source/include.mdx +40 -0
- package/docs/en/configure/app/source/main-entry-name.mdx +28 -0
- package/docs/en/configure/app/source/pre-entry.mdx +14 -0
- package/docs/en/configure/app/source/transform-import.mdx +31 -0
- package/docs/en/configure/app/split-chunks.mdx +17 -0
- package/docs/en/configure/app/tools/autoprefixer.mdx +48 -0
- package/docs/en/configure/app/tools/bundler-chain.mdx +30 -0
- package/docs/en/configure/app/tools/css-extract.mdx +37 -0
- package/docs/en/configure/app/tools/css-loader.mdx +21 -0
- package/docs/en/configure/app/tools/dev-server.mdx +117 -0
- package/docs/en/configure/app/tools/html-plugin.mdx +45 -0
- package/docs/en/configure/app/tools/less.mdx +85 -0
- package/docs/en/configure/app/tools/lightningcss-loader.mdx +39 -0
- package/docs/en/configure/app/tools/minify-css.mdx +57 -0
- package/docs/en/configure/app/tools/postcss.mdx +38 -0
- package/docs/en/configure/app/tools/rspack.mdx +14 -0
- package/docs/en/configure/app/tools/sass.mdx +82 -0
- package/docs/en/configure/app/tools/style-loader.mdx +14 -0
- package/docs/en/configure/app/tools/swc.mdx +69 -0
- package/docs/en/configure/app/tools/ts-checker.mdx +56 -0
- package/docs/en/configure/app/usage.mdx +276 -0
- package/docs/en/guides/_meta.json +37 -0
- package/docs/en/guides/advanced-features/_meta.json +32 -0
- package/docs/en/guides/advanced-features/bff/_meta.json +10 -0
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +110 -0
- package/docs/en/guides/advanced-features/bff/data-platform.mdx +118 -0
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +120 -0
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +118 -0
- package/docs/en/guides/advanced-features/bff/function.mdx +261 -0
- package/docs/en/guides/advanced-features/bff/operators.mdx +629 -0
- package/docs/en/guides/advanced-features/bff/sdk.mdx +116 -0
- package/docs/en/guides/advanced-features/bff/upload.mdx +7 -0
- package/docs/en/guides/advanced-features/bff.mdx +22 -0
- package/docs/en/guides/advanced-features/build-performance.mdx +134 -0
- package/docs/en/guides/advanced-features/compatibility.mdx +81 -0
- package/docs/en/guides/advanced-features/international/_meta.json +10 -0
- package/docs/en/guides/advanced-features/international/advanced.mdx +132 -0
- package/docs/en/guides/advanced-features/international/api.mdx +235 -0
- package/docs/en/guides/advanced-features/international/best-practices.mdx +290 -0
- package/docs/en/guides/advanced-features/international/configuration.mdx +221 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +130 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +112 -0
- package/docs/en/guides/advanced-features/international/resource-loading.mdx +158 -0
- package/docs/en/guides/advanced-features/international/routing.mdx +134 -0
- package/docs/en/guides/advanced-features/international.mdx +29 -0
- package/docs/en/guides/advanced-features/low-level.mdx +50 -0
- package/docs/en/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/en/guides/advanced-features/page-performance/code-split.mdx +81 -0
- package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +163 -0
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +101 -0
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +54 -0
- package/docs/en/guides/advanced-features/server-monitor/_meta.json +1 -0
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +19 -0
- package/docs/en/guides/advanced-features/server-monitor/metrics.mdx +41 -0
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +242 -0
- package/docs/en/guides/advanced-features/source-build.mdx +168 -0
- package/docs/en/guides/advanced-features/web-server.mdx +284 -0
- package/docs/en/guides/basic-features/_meta.json +49 -0
- package/docs/en/guides/basic-features/alias.mdx +106 -0
- package/docs/en/guides/basic-features/css/_meta.json +1 -0
- package/docs/en/guides/basic-features/css/css-in-js.mdx +69 -0
- package/docs/en/guides/basic-features/css/css-modules.mdx +212 -0
- package/docs/en/guides/basic-features/css/css.mdx +31 -0
- package/docs/en/guides/basic-features/css/tailwindcss.mdx +27 -0
- package/docs/en/guides/basic-features/data/_meta.json +1 -0
- package/docs/en/guides/basic-features/data/data-cache.mdx +515 -0
- package/docs/en/guides/basic-features/data/data-fetch.mdx +419 -0
- package/docs/en/guides/basic-features/data/data-write.mdx +230 -0
- package/docs/en/guides/basic-features/debug/_meta.json +1 -0
- package/docs/en/guides/basic-features/debug/mock.mdx +102 -0
- package/docs/en/guides/basic-features/debug/proxy.mdx +25 -0
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +48 -0
- package/docs/en/guides/basic-features/debug/using-storybook.mdx +100 -0
- package/docs/en/guides/basic-features/deploy.mdx +448 -0
- package/docs/en/guides/basic-features/env-vars.mdx +181 -0
- package/docs/en/guides/basic-features/html.mdx +259 -0
- package/docs/en/guides/basic-features/output-files.mdx +145 -0
- package/docs/en/guides/basic-features/render/_meta.json +10 -0
- package/docs/en/guides/basic-features/render/before-render.mdx +108 -0
- package/docs/en/guides/basic-features/render/overview.mdx +52 -0
- package/docs/en/guides/basic-features/render/rsc.mdx +534 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +167 -0
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +201 -0
- package/docs/en/guides/basic-features/render/ssr.mdx +323 -0
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +267 -0
- package/docs/en/guides/basic-features/render/tanstack-rsc.mdx +226 -0
- 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/routes.mdx +517 -0
- package/docs/en/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/en/guides/basic-features/static-assets/json-files.mdx +124 -0
- package/docs/en/guides/basic-features/static-assets/svg-assets.mdx +172 -0
- package/docs/en/guides/basic-features/static-assets/wasm-assets.mdx +66 -0
- package/docs/en/guides/basic-features/static-assets.mdx +164 -0
- package/docs/en/guides/basic-features/testing/_meta.json +1 -0
- package/docs/en/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/en/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/en/guides/basic-features/testing/playwright.mdx +111 -0
- package/docs/en/guides/basic-features/testing/rstest.mdx +163 -0
- package/docs/en/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/en/guides/concept/_meta.json +1 -0
- package/docs/en/guides/concept/builder.mdx +60 -0
- package/docs/en/guides/concept/entries.mdx +325 -0
- package/docs/en/guides/concept/server.mdx +35 -0
- package/docs/en/guides/get-started/_meta.json +8 -0
- package/docs/en/guides/get-started/glossary.mdx +63 -0
- package/docs/en/guides/get-started/introduction.mdx +45 -0
- package/docs/en/guides/get-started/quick-start.mdx +92 -0
- package/docs/en/guides/get-started/tech-stack.mdx +91 -0
- package/docs/en/guides/get-started/ultramodern.mdx +98 -0
- package/docs/en/guides/get-started/upgrade.mdx +114 -0
- package/docs/en/guides/topic-detail/_meta.json +8 -0
- package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -0
- package/docs/en/guides/topic-detail/module-federation/application.mdx +116 -0
- package/docs/en/guides/topic-detail/module-federation/deploy.mdx +104 -0
- package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
- package/docs/en/guides/topic-detail/module-federation/introduce.mdx +36 -0
- package/docs/en/guides/topic-detail/module-federation/ssr.mdx +170 -0
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +202 -0
- package/docs/en/guides/troubleshooting/_meta.json +1 -0
- package/docs/en/guides/troubleshooting/builder.mdx +114 -0
- package/docs/en/guides/troubleshooting/cli.mdx +39 -0
- package/docs/en/guides/troubleshooting/dependencies.mdx +123 -0
- package/docs/en/guides/troubleshooting/hmr.mdx +148 -0
- package/docs/en/guides/upgrade/_meta.json +1 -0
- package/docs/en/guides/upgrade/config.mdx +949 -0
- package/docs/en/guides/upgrade/entry.mdx +463 -0
- package/docs/en/guides/upgrade/other.mdx +183 -0
- package/docs/en/guides/upgrade/overview.mdx +33 -0
- package/docs/en/guides/upgrade/tailwindcss.mdx +92 -0
- package/docs/en/guides/upgrade/web-server.md +109 -0
- package/docs/en/index.md +4 -0
- package/docs/en/plugin/_meta.json +25 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -0
- package/docs/en/plugin/cli-plugins/api.mdx +573 -0
- package/docs/en/plugin/cli-plugins/life-cycle.mdx +135 -0
- package/docs/en/plugin/introduction.mdx +153 -0
- package/docs/en/plugin/official/_meta.json +7 -0
- package/docs/en/plugin/official/cli-plugins/_meta.json +1 -0
- package/docs/en/plugin/official/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins.mdx +4 -0
- package/docs/en/plugin/plugin-system.mdx +244 -0
- package/docs/en/plugin/runtime-plugins/_meta.json +1 -0
- package/docs/en/plugin/runtime-plugins/api.mdx +193 -0
- package/docs/en/plugin/runtime-plugins/life-cycle.mdx +29 -0
- package/docs/en/plugin/server-plugins/_meta.json +1 -0
- package/docs/en/plugin/server-plugins/api.mdx +212 -0
- package/docs/en/plugin/server-plugins/life-cycle.mdx +43 -0
- package/docs/en/tutorials/_meta.json +7 -0
- package/docs/en/tutorials/examples/csr-auth.mdx +31 -0
- package/docs/en/tutorials/foundations/introduction.mdx +22 -0
- package/docs/zh/_nav.json +36 -0
- package/docs/zh/apis/_meta.json +13 -0
- package/docs/zh/apis/app/commands.mdx +215 -0
- package/docs/zh/apis/app/hooks/_meta.json +28 -0
- package/docs/zh/apis/app/hooks/api/lambda.mdx +14 -0
- package/docs/zh/apis/app/hooks/config/_meta.json +1 -0
- package/docs/zh/apis/app/hooks/config/favicon.mdx +29 -0
- package/docs/zh/apis/app/hooks/config/html.mdx +9 -0
- package/docs/zh/apis/app/hooks/config/icon.mdx +29 -0
- package/docs/zh/apis/app/hooks/config/mock.mdx +7 -0
- package/docs/zh/apis/app/hooks/config/public.mdx +30 -0
- package/docs/zh/apis/app/hooks/config/upload.mdx +54 -0
- package/docs/zh/apis/app/hooks/modern-config.mdx +9 -0
- package/docs/zh/apis/app/hooks/server/server.mdx +10 -0
- package/docs/zh/apis/app/hooks/shared.mdx +7 -0
- package/docs/zh/apis/app/hooks/src/app.mdx +36 -0
- package/docs/zh/apis/app/hooks/src/entry.mdx +39 -0
- package/docs/zh/apis/app/hooks/src/entry.server.mdx +56 -0
- package/docs/zh/apis/app/hooks/src/modern.runtime.mdx +9 -0
- package/docs/zh/apis/app/hooks/src/routes.mdx +90 -0
- package/docs/zh/apis/app/hooks/src/server.mdx +7 -0
- package/docs/zh/apis/app/runtime/_meta.json +32 -0
- package/docs/zh/apis/app/runtime/bff/use-backend-context.mdx +31 -0
- package/docs/zh/apis/app/runtime/core/create-root.mdx +22 -0
- package/docs/zh/apis/app/runtime/core/render.mdx +43 -0
- package/docs/zh/apis/app/runtime/core/runtime-context.mdx +160 -0
- package/docs/zh/apis/app/runtime/router/router.mdx +287 -0
- package/docs/zh/apis/app/runtime/ssr/no-ssr.mdx +38 -0
- package/docs/zh/apis/app/runtime/ssr/renderStreaming.mdx +71 -0
- package/docs/zh/apis/app/runtime/ssr/renderString.mdx +64 -0
- package/docs/zh/apis/app/runtime/ssr/requestHandler.mdx +48 -0
- package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +44 -0
- package/docs/zh/apis/app/runtime/utility/head.mdx +38 -0
- package/docs/zh/apis/app/runtime/utility/loadable.mdx +83 -0
- package/docs/zh/community/_meta.json +11 -0
- package/docs/zh/community/blog/2022-0708-updates.md +95 -0
- package/docs/zh/community/blog/2022-0910-updates.md +80 -0
- package/docs/zh/community/blog/_meta.json +7 -0
- package/docs/zh/community/blog/overview.md +74 -0
- package/docs/zh/community/blog/v2-release-note.mdx +244 -0
- package/docs/zh/community/blog/v3-release-note.mdx +628 -0
- package/docs/zh/community/contributing-guide.mdx +256 -0
- package/docs/zh/community/releases.mdx +31 -0
- package/docs/zh/community/showcase.mdx +15 -0
- package/docs/zh/community/team.mdx +29 -0
- 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 +98 -0
- package/docs/zh/components/build-output.mdx +45 -0
- package/docs/zh/components/bundler.mdx +3 -0
- package/docs/zh/components/convention-routing-motivation.mdx +0 -0
- package/docs/zh/components/debug-app.mdx +16 -0
- package/docs/zh/components/default-browserslist.mdx +7 -0
- package/docs/zh/components/deploy-command.mdx +14 -0
- package/docs/zh/components/deploy.mdx +1 -0
- package/docs/zh/components/enable-bff-caution.mdx +4 -0
- package/docs/zh/components/enable-bff.mdx +56 -0
- package/docs/zh/components/enable-ssg.mdx +49 -0
- package/docs/zh/components/entry-mode.mdx +0 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/extend-bff-function.mdx +3 -0
- package/docs/zh/components/hono.mdx +120 -0
- package/docs/zh/components/init-app.mdx +111 -0
- package/docs/zh/components/init-rspack-app.mdx +5 -0
- package/docs/zh/components/internal-logger.mdx +25 -0
- package/docs/zh/components/internal-metrics.mdx +20 -0
- 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 +11 -0
- package/docs/zh/components/international/instance-code.mdx +16 -0
- package/docs/zh/components/international/introduce.mdx +5 -0
- package/docs/zh/components/international/platform-support.mdx +0 -0
- package/docs/zh/components/language-config.mdx +9 -0
- package/docs/zh/components/micro-frontend.mdx +6 -0
- package/docs/zh/components/micro-master-manifest-config.mdx +15 -0
- package/docs/zh/components/micro-runtime-config.mdx +17 -0
- package/docs/zh/components/module-federation.mdx +7 -0
- package/docs/zh/components/new-entry-tooltip.mdx +0 -0
- package/docs/zh/components/nodeVersion.mdx +28 -0
- package/docs/zh/components/other-plugins.mdx +0 -0
- package/docs/zh/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/zh/components/output-distpath-warning.mdx +0 -0
- package/docs/zh/components/output-polyfill-extend.mdx +1 -0
- package/docs/zh/components/prerequisites.mdx +18 -0
- package/docs/zh/components/release-note.mdx +1 -0
- package/docs/zh/components/routes-practice.mdx +0 -0
- package/docs/zh/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/zh/components/rsbuild.mdx +3 -0
- package/docs/zh/components/rsc-deploy-tip.mdx +1 -0
- package/docs/zh/components/rspack.mdx +3 -0
- package/docs/zh/components/rspackTip.mdx +7 -0
- package/docs/zh/components/runtime-cli-config.mdx +0 -0
- package/docs/zh/components/self-route-example.mdx +21 -0
- package/docs/zh/components/serve-command.mdx +22 -0
- package/docs/zh/components/ssr-monitor.mdx +3 -0
- package/docs/zh/components/stream-ssr-performance.mdx +0 -0
- package/docs/zh/components/swc.mdx +3 -0
- package/docs/zh/components/tech-stack-node-framework.mdx +1 -0
- package/docs/zh/components/turtorials-example-list.mdx +2 -0
- package/docs/zh/components/ua-polyfill.mdx +44 -0
- package/docs/zh/components/upgrade-browserslist.mdx +0 -0
- package/docs/zh/components/upgrade-config-deploy.mdx +0 -0
- package/docs/zh/components/upgrade-faq.mdx +0 -0
- package/docs/zh/configure/_meta.json +78 -0
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/bff/effect.mdx +152 -0
- package/docs/zh/configure/app/bff/prefix.mdx +33 -0
- package/docs/zh/configure/app/bff/runtime-framework.mdx +28 -0
- package/docs/zh/configure/app/builder-plugins.mdx +72 -0
- package/docs/zh/configure/app/dev/asset-prefix.mdx +18 -0
- package/docs/zh/configure/app/dev/before-start-url.mdx +21 -0
- package/docs/zh/configure/app/dev/client.mdx +45 -0
- package/docs/zh/configure/app/dev/hmr.mdx +14 -0
- package/docs/zh/configure/app/dev/host.mdx +22 -0
- package/docs/zh/configure/app/dev/https.mdx +82 -0
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/live-reload.mdx +14 -0
- package/docs/zh/configure/app/dev/progress-bar.mdx +23 -0
- package/docs/zh/configure/app/dev/server.mdx +128 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +36 -0
- package/docs/zh/configure/app/dev/start-url.mdx +54 -0
- package/docs/zh/configure/app/dev/watch-files.mdx +31 -0
- package/docs/zh/configure/app/dev/write-to-disk.mdx +14 -0
- package/docs/zh/configure/app/experiments/source-build.mdx +35 -0
- package/docs/zh/configure/app/html/app-icon.mdx +32 -0
- package/docs/zh/configure/app/html/crossorigin.mdx +15 -0
- package/docs/zh/configure/app/html/favicon.mdx +21 -0
- package/docs/zh/configure/app/html/inject.mdx +14 -0
- package/docs/zh/configure/app/html/meta.mdx +28 -0
- package/docs/zh/configure/app/html/mount-id.mdx +14 -0
- package/docs/zh/configure/app/html/output-structure.mdx +14 -0
- package/docs/zh/configure/app/html/script-loading.mdx +14 -0
- package/docs/zh/configure/app/html/tags.mdx +19 -0
- package/docs/zh/configure/app/html/template-parameters.mdx +37 -0
- package/docs/zh/configure/app/html/template.mdx +14 -0
- package/docs/zh/configure/app/html/title.mdx +22 -0
- package/docs/zh/configure/app/output/asset-prefix.mdx +18 -0
- package/docs/zh/configure/app/output/assets-retry.mdx +81 -0
- package/docs/zh/configure/app/output/charset.mdx +14 -0
- package/docs/zh/configure/app/output/clean-dist-path.mdx +20 -0
- package/docs/zh/configure/app/output/convert-to-rem.mdx +84 -0
- package/docs/zh/configure/app/output/copy.mdx +14 -0
- package/docs/zh/configure/app/output/css-modules.mdx +52 -0
- package/docs/zh/configure/app/output/data-uri-limit.mdx +30 -0
- package/docs/zh/configure/app/output/disable-css-module-extension.mdx +59 -0
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +45 -0
- package/docs/zh/configure/app/output/disable-svgr.mdx +21 -0
- package/docs/zh/configure/app/output/disable-ts-checker.mdx +53 -0
- package/docs/zh/configure/app/output/dist-path.mdx +50 -0
- package/docs/zh/configure/app/output/enable-asset-manifest.mdx +40 -0
- package/docs/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +32 -0
- package/docs/zh/configure/app/output/enable-inline-route-manifests.mdx +21 -0
- package/docs/zh/configure/app/output/externals.mdx +24 -0
- package/docs/zh/configure/app/output/filename-hash.mdx +14 -0
- package/docs/zh/configure/app/output/filename.mdx +62 -0
- package/docs/zh/configure/app/output/inject-styles.mdx +14 -0
- package/docs/zh/configure/app/output/inline-scripts.mdx +33 -0
- package/docs/zh/configure/app/output/inline-styles.mdx +33 -0
- package/docs/zh/configure/app/output/legal-comments.mdx +22 -0
- package/docs/zh/configure/app/output/minify.mdx +26 -0
- package/docs/zh/configure/app/output/override-browserslist.mdx +26 -0
- package/docs/zh/configure/app/output/polyfill.mdx +18 -0
- package/docs/zh/configure/app/output/source-map.mdx +38 -0
- package/docs/zh/configure/app/output/split-route-chunks.mdx +20 -0
- package/docs/zh/configure/app/output/ssg.mdx +84 -0
- package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
- package/docs/zh/configure/app/output/svg-default-export.mdx +34 -0
- package/docs/zh/configure/app/output/temp-dir.mdx +22 -0
- package/docs/zh/configure/app/performance/build-cache.mdx +43 -0
- package/docs/zh/configure/app/performance/chunk-split.mdx +44 -0
- package/docs/zh/configure/app/performance/dns-prefetch.mdx +19 -0
- package/docs/zh/configure/app/performance/preconnect.mdx +20 -0
- package/docs/zh/configure/app/performance/prefetch.mdx +25 -0
- package/docs/zh/configure/app/performance/preload.mdx +27 -0
- package/docs/zh/configure/app/performance/print-file-size.mdx +44 -0
- package/docs/zh/configure/app/performance/profile.mdx +14 -0
- package/docs/zh/configure/app/performance/remove-console.mdx +14 -0
- package/docs/zh/configure/app/performance/remove-moment-locale.mdx +14 -0
- package/docs/zh/configure/app/performance/rsdoctor.mdx +39 -0
- package/docs/zh/configure/app/plugins.mdx +59 -0
- 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 +58 -0
- package/docs/zh/configure/app/runtime/plugins.mdx +58 -0
- package/docs/zh/configure/app/runtime/router.mdx +39 -0
- package/docs/zh/configure/app/security/check-syntax.mdx +73 -0
- package/docs/zh/configure/app/security/nonce.mdx +19 -0
- package/docs/zh/configure/app/security/sri.mdx +24 -0
- package/docs/zh/configure/app/server/base-url.mdx +30 -0
- package/docs/zh/configure/app/server/port.mdx +23 -0
- package/docs/zh/configure/app/server/public-routes.mdx +26 -0
- package/docs/zh/configure/app/server/routes.mdx +90 -0
- package/docs/zh/configure/app/server/rsc.mdx +30 -0
- package/docs/zh/configure/app/server/ssr-by-entries.mdx +29 -0
- package/docs/zh/configure/app/server/ssr.mdx +85 -0
- package/docs/zh/configure/app/server/tsconfig-path.mdx +63 -0
- package/docs/zh/configure/app/source/alias-strategy.mdx +18 -0
- package/docs/zh/configure/app/source/alias.mdx +27 -0
- package/docs/zh/configure/app/source/config-dir.mdx +24 -0
- package/docs/zh/configure/app/source/decorators.mdx +27 -0
- package/docs/zh/configure/app/source/define.mdx +20 -0
- package/docs/zh/configure/app/source/disable-default-entries.mdx +32 -0
- package/docs/zh/configure/app/source/enable-async-entry.mdx +54 -0
- package/docs/zh/configure/app/source/enable-async-pre-entry.mdx +77 -0
- package/docs/zh/configure/app/source/entries-dir.mdx +39 -0
- package/docs/zh/configure/app/source/entries.mdx +185 -0
- package/docs/zh/configure/app/source/exclude.mdx +14 -0
- package/docs/zh/configure/app/source/global-vars.mdx +109 -0
- package/docs/zh/configure/app/source/include.mdx +40 -0
- package/docs/zh/configure/app/source/main-entry-name.mdx +28 -0
- package/docs/zh/configure/app/source/pre-entry.mdx +14 -0
- package/docs/zh/configure/app/source/transform-import.mdx +31 -0
- package/docs/zh/configure/app/split-chunks.mdx +17 -0
- package/docs/zh/configure/app/tools/autoprefixer.mdx +48 -0
- package/docs/zh/configure/app/tools/bundler-chain.mdx +33 -0
- package/docs/zh/configure/app/tools/css-extract.mdx +34 -0
- package/docs/zh/configure/app/tools/css-loader.mdx +21 -0
- package/docs/zh/configure/app/tools/dev-server.mdx +117 -0
- package/docs/zh/configure/app/tools/html-plugin.mdx +45 -0
- package/docs/zh/configure/app/tools/less.mdx +86 -0
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +39 -0
- package/docs/zh/configure/app/tools/minify-css.mdx +57 -0
- package/docs/zh/configure/app/tools/postcss.mdx +39 -0
- package/docs/zh/configure/app/tools/rspack.mdx +14 -0
- package/docs/zh/configure/app/tools/sass.mdx +80 -0
- package/docs/zh/configure/app/tools/style-loader.mdx +14 -0
- package/docs/zh/configure/app/tools/swc.mdx +69 -0
- package/docs/zh/configure/app/tools/ts-checker.mdx +56 -0
- package/docs/zh/configure/app/usage.mdx +276 -0
- package/docs/zh/guides/_meta.json +37 -0
- package/docs/zh/guides/advanced-features/_meta.json +32 -0
- package/docs/zh/guides/advanced-features/bff/_meta.json +10 -0
- package/docs/zh/guides/advanced-features/bff/cross-project.mdx +112 -0
- package/docs/zh/guides/advanced-features/bff/data-platform.mdx +118 -0
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +125 -0
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +118 -0
- package/docs/zh/guides/advanced-features/bff/function.mdx +262 -0
- package/docs/zh/guides/advanced-features/bff/operators.mdx +629 -0
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +117 -0
- package/docs/zh/guides/advanced-features/bff/upload.mdx +7 -0
- package/docs/zh/guides/advanced-features/bff.mdx +21 -0
- package/docs/zh/guides/advanced-features/build-performance.mdx +134 -0
- package/docs/zh/guides/advanced-features/compatibility.mdx +80 -0
- package/docs/zh/guides/advanced-features/international/_meta.json +10 -0
- package/docs/zh/guides/advanced-features/international/advanced.mdx +132 -0
- package/docs/zh/guides/advanced-features/international/api.mdx +234 -0
- package/docs/zh/guides/advanced-features/international/best-practices.mdx +290 -0
- package/docs/zh/guides/advanced-features/international/configuration.mdx +219 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +130 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +112 -0
- package/docs/zh/guides/advanced-features/international/resource-loading.mdx +155 -0
- package/docs/zh/guides/advanced-features/international/routing.mdx +134 -0
- package/docs/zh/guides/advanced-features/international.mdx +29 -0
- package/docs/zh/guides/advanced-features/low-level.mdx +48 -0
- package/docs/zh/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +81 -0
- package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +162 -0
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +101 -0
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +54 -0
- package/docs/zh/guides/advanced-features/server-monitor/_meta.json +1 -0
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +21 -0
- package/docs/zh/guides/advanced-features/server-monitor/metrics.mdx +42 -0
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +240 -0
- package/docs/zh/guides/advanced-features/source-build.mdx +168 -0
- package/docs/zh/guides/advanced-features/web-server.mdx +281 -0
- package/docs/zh/guides/basic-features/_meta.json +49 -0
- package/docs/zh/guides/basic-features/alias.mdx +100 -0
- package/docs/zh/guides/basic-features/css/_meta.json +1 -0
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +69 -0
- package/docs/zh/guides/basic-features/css/css-modules.mdx +218 -0
- package/docs/zh/guides/basic-features/css/css.mdx +31 -0
- package/docs/zh/guides/basic-features/css/tailwindcss.mdx +27 -0
- package/docs/zh/guides/basic-features/data/_meta.json +1 -0
- package/docs/zh/guides/basic-features/data/data-cache.mdx +498 -0
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +421 -0
- package/docs/zh/guides/basic-features/data/data-write.mdx +234 -0
- package/docs/zh/guides/basic-features/debug/_meta.json +1 -0
- package/docs/zh/guides/basic-features/debug/mock.mdx +102 -0
- package/docs/zh/guides/basic-features/debug/proxy.mdx +25 -0
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +48 -0
- package/docs/zh/guides/basic-features/debug/using-storybook.mdx +92 -0
- package/docs/zh/guides/basic-features/deploy.mdx +432 -0
- package/docs/zh/guides/basic-features/env-vars.mdx +180 -0
- package/docs/zh/guides/basic-features/html.mdx +262 -0
- package/docs/zh/guides/basic-features/output-files.mdx +145 -0
- package/docs/zh/guides/basic-features/render/_meta.json +10 -0
- package/docs/zh/guides/basic-features/render/before-render.mdx +108 -0
- package/docs/zh/guides/basic-features/render/overview.mdx +53 -0
- package/docs/zh/guides/basic-features/render/rsc.mdx +619 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +168 -0
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +205 -0
- package/docs/zh/guides/basic-features/render/ssr.mdx +334 -0
- package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +276 -0
- package/docs/zh/guides/basic-features/render/tanstack-rsc.mdx +226 -0
- 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/routes.mdx +521 -0
- package/docs/zh/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/zh/guides/basic-features/static-assets/json-files.mdx +124 -0
- package/docs/zh/guides/basic-features/static-assets/svg-assets.mdx +174 -0
- package/docs/zh/guides/basic-features/static-assets/wasm-assets.mdx +66 -0
- package/docs/zh/guides/basic-features/static-assets.mdx +160 -0
- package/docs/zh/guides/basic-features/testing/_meta.json +1 -0
- package/docs/zh/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/zh/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/zh/guides/basic-features/testing/playwright.mdx +112 -0
- package/docs/zh/guides/basic-features/testing/rstest.mdx +163 -0
- package/docs/zh/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/zh/guides/concept/_meta.json +1 -0
- package/docs/zh/guides/concept/builder.mdx +60 -0
- package/docs/zh/guides/concept/entries.mdx +323 -0
- package/docs/zh/guides/concept/server.mdx +35 -0
- package/docs/zh/guides/get-started/_meta.json +8 -0
- package/docs/zh/guides/get-started/glossary.mdx +63 -0
- package/docs/zh/guides/get-started/introduction.mdx +45 -0
- package/docs/zh/guides/get-started/quick-start.mdx +90 -0
- package/docs/zh/guides/get-started/tech-stack.mdx +91 -0
- package/docs/zh/guides/get-started/ultramodern.mdx +80 -0
- package/docs/zh/guides/get-started/upgrade.mdx +114 -0
- package/docs/zh/guides/topic-detail/_meta.json +8 -0
- package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -0
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +117 -0
- package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +104 -0
- package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
- package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +35 -0
- package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +168 -0
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +200 -0
- package/docs/zh/guides/troubleshooting/_meta.json +1 -0
- package/docs/zh/guides/troubleshooting/builder.mdx +134 -0
- package/docs/zh/guides/troubleshooting/cli.mdx +39 -0
- package/docs/zh/guides/troubleshooting/dependencies.mdx +123 -0
- package/docs/zh/guides/troubleshooting/hmr.mdx +148 -0
- package/docs/zh/guides/upgrade/_meta.json +1 -0
- package/docs/zh/guides/upgrade/config.mdx +953 -0
- package/docs/zh/guides/upgrade/entry.mdx +463 -0
- package/docs/zh/guides/upgrade/other.md +190 -0
- package/docs/zh/guides/upgrade/overview.mdx +36 -0
- package/docs/zh/guides/upgrade/tailwindcss.mdx +92 -0
- package/docs/zh/guides/upgrade/web-server.md +111 -0
- package/docs/zh/index.md +4 -0
- package/docs/zh/plugin/_meta.json +25 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -0
- package/docs/zh/plugin/cli-plugins/api.mdx +569 -0
- package/docs/zh/plugin/cli-plugins/life-cycle.mdx +135 -0
- package/docs/zh/plugin/introduction.mdx +153 -0
- package/docs/zh/plugin/official/_meta.json +7 -0
- package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -0
- package/docs/zh/plugin/official/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins.mdx +4 -0
- package/docs/zh/plugin/plugin-system.mdx +231 -0
- package/docs/zh/plugin/runtime-plugins/_meta.json +1 -0
- package/docs/zh/plugin/runtime-plugins/api.mdx +193 -0
- package/docs/zh/plugin/runtime-plugins/life-cycle.mdx +29 -0
- package/docs/zh/plugin/server-plugins/_meta.json +1 -0
- package/docs/zh/plugin/server-plugins/api.mdx +212 -0
- package/docs/zh/plugin/server-plugins/life-cycle.mdx +43 -0
- package/docs/zh/tutorials/_meta.json +7 -0
- package/docs/zh/tutorials/examples/csr-auth.mdx +31 -0
- package/docs/zh/tutorials/foundations/introduction.mdx +22 -0
- package/i18n.json +142 -0
- package/main-doc/docs/en/guides/get-started/ultramodern.mdx +320 -0
- package/main-doc/docs/zh/guides/get-started/ultramodern.mdx +304 -0
- package/package.json +52 -0
- package/rspress.config.ts +153 -0
- package/src/components/ContentCard/index.module.scss +65 -0
- package/src/components/ContentCard/index.tsx +24 -0
- package/src/components/FeatureLayout/index.module.css +8 -0
- package/src/components/FeatureLayout/index.tsx +8 -0
- package/src/components/Footer/index.tsx +118 -0
- package/src/components/Footer/styles.module.scss +49 -0
- package/src/components/FrameworkCode/index.tsx +605 -0
- package/src/components/ListCard/index.module.css +57 -0
- package/src/components/ListCard/index.tsx +26 -0
- package/src/components/Mermaid/index.tsx +64 -0
- package/src/components/Mermaid/style.scss +221 -0
- package/src/components/RandomMemberList/index.module.scss +35 -0
- package/src/components/RandomMemberList/index.tsx +122 -0
- package/src/components/RsbuildLink/index.tsx +19 -0
- package/src/components/Sandpack/index.css +10 -0
- package/src/components/Sandpack/index.tsx +22 -0
- package/src/components/SecondaryTitle/index.module.css +14 -0
- package/src/components/SecondaryTitle/index.tsx +15 -0
- package/src/components/ShowcaseList/index.module.scss +80 -0
- package/src/components/ShowcaseList/index.tsx +39 -0
- package/src/components/ShowcaseList/useShowcases.ts +101 -0
- package/src/components/SolutionCards/index.module.scss +73 -0
- package/src/components/SolutionCards/index.tsx +30 -0
- package/src/custom.scss +15 -0
- package/src/global.d.ts +28 -0
- package/src/i18n/enUS.ts +54 -0
- package/src/i18n/index.ts +18 -0
- package/src/i18n/zhCN.ts +54 -0
- package/src/index.ts +5 -0
- package/src/pages/index.module.scss +349 -0
- package/src/pages/index.tsx +133 -0
- package/src/sandbox/csr-auth/src/routes/Auth-tsx.txt +74 -0
- package/src/sandbox/csr-auth/src/routes/fakeAuth-ts.txt +16 -0
- package/src/sandbox/csr-auth/src/routes/layout-tsx.txt +21 -0
- package/src/sandbox/csr-auth/src/routes/login/page-tsx.txt +40 -0
- package/src/sandbox/csr-auth/src/routes/page-tsx.txt +17 -0
- package/src/sandbox/csr-auth/src/routes/protected/page-tsx.txt +11 -0
- package/static/img/favicon.ico +0 -0
- package/static/img/features/ai.svg +1 -0
- package/static/img/features/api.svg +1 -0
- package/static/img/features/app.svg +1 -0
- package/static/img/features/blocks.svg +1 -0
- package/static/img/features/browser.svg +12 -0
- package/static/img/features/cloud.svg +1 -0
- package/static/img/features/coding-backend.svg +1 -0
- package/static/img/features/compiler.svg +1 -0
- package/static/img/features/css-file.svg +1 -0
- package/static/img/features/customize.svg +1 -0
- package/static/img/features/developer.svg +1 -0
- package/static/img/features/dynamic.svg +1 -0
- package/static/img/features/editor.svg +1 -0
- package/static/img/features/framework-config.svg +1 -0
- package/static/img/features/framework.svg +1 -0
- package/static/img/features/frameworks.svg +1 -0
- package/static/img/features/html.svg +1 -0
- package/static/img/features/icon2.svg +1 -0
- package/static/img/features/javascript.svg +1 -0
- package/static/img/features/monorepo.svg +1 -0
- package/static/img/features/product.svg +1 -0
- package/static/img/features/server-network.svg +1 -0
- package/static/img/features/serverless.svg +1 -0
- package/static/img/features/test.svg +1 -0
- package/static/img/features/trinity.svg +1 -0
- package/static/img/features/unity.svg +1 -0
- package/static/img/features/url.svg +1 -0
- package/static/img/features/visual.svg +1 -0
- package/static/img/features/web-server.svg +1 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Modern.js v3 发布
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Modern.js v3 发布:聚焦 Web 框架,拥抱生态发展
|
|
6
|
+
|
|
7
|
+
> 发表于 2025.02.06
|
|
8
|
+
|
|
9
|
+
## 前言
|
|
10
|
+
|
|
11
|
+
[Modern.js 2.0 发布](./v2-release-note.mdx) 至今,已过去三年时间,感谢社区开发者们对 Modern.js 的使用和信任。Modern.js 一直保持稳定的迭代,累计发布了超过 100 个版本。
|
|
12
|
+
|
|
13
|
+
在字节内部,基于 Modern.js 开发的 Web 开发框架已经成为主流。在全公司活跃的 Web 项目中,占比从 2025 年初的 43% 增长到目前近 70%。
|
|
14
|
+
|
|
15
|
+
在这三年中,我们不断扩充新特性,持续进行代码重构与优化,也收到了非常多的社区反馈,这些经验成为了 3.0 版本改进的重要参考。经过慎重考虑,我们决定发布 Modern.js 3.0,对框架进行一次全面的升级。
|
|
16
|
+
|
|
17
|
+
## Modern.js 2.0 到 3.0 的演变
|
|
18
|
+
|
|
19
|
+
从 Modern.js 2.0 到 3.0,有两个核心转变:
|
|
20
|
+
|
|
21
|
+
**更聚焦,专注于 Web 框架**
|
|
22
|
+
|
|
23
|
+
- Modern.js 2.0:包含 Modern.js App、Modern.js Module、Modern.js Doc
|
|
24
|
+
- Modern.js 3.0:只代表 Modern.js App,Modern.js Module 和 Modern.js Doc 已孵化为 [Rslib](https://rslib.rs) 与 [Rspress](https://rspress.dev)
|
|
25
|
+
|
|
26
|
+
**更开放,积极面向社区工具**
|
|
27
|
+
|
|
28
|
+
- Modern.js 2.0:内置各类工具、框架独特的 API 设计
|
|
29
|
+
- Modern.js 3.0:强化插件体系,完善接入能力,推荐社区优质方案
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Modern.js 3.0 新特性
|
|
34
|
+
|
|
35
|
+
### React Server Component
|
|
36
|
+
|
|
37
|
+
:::tip TL;DR
|
|
38
|
+
Modern.js 3.0 集成 React Server Component,支持 CSR 和 SSR 项目,并支持渐进式迁移。
|
|
39
|
+
:::
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
#### 什么是 React Server Component
|
|
44
|
+
|
|
45
|
+
React Server Components(服务端组件)是一种新的组件类型,它允许**组件逻辑完全在服务端执行**,并直接将渲染后的 UI 流式传输到客户端。与传统的客户端组件相比,服务端组件带来了以下特性:
|
|
46
|
+
|
|
47
|
+
| 特性 | 说明 |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| 零客户端包体积 | 组件代码不包含在客户端 JS Bundle 中,仅在服务端执行,加快首屏加载与渲染速度 |
|
|
50
|
+
| 更高的内聚性 | 组件可直接连接数据库、调用内部 API、读取本地文件,提高开发效率 |
|
|
51
|
+
| 渐进增强 | 可与客户端组件无缝混合使用,按需下放交互逻辑到客户端,在保持高性能的同时,支持复杂交互体验 |
|
|
52
|
+
|
|
53
|
+
需要明确的是,RSC 和 SSR 是**截然不同的概念**:
|
|
54
|
+
|
|
55
|
+
- **RSC**:描述的是**组件类型**,即组件在哪里执行(服务端 vs 客户端)
|
|
56
|
+
- **SSR**:描述的是**渲染模式**,即 HTML 在哪里生成(服务端 vs 客户端)
|
|
57
|
+
|
|
58
|
+
两者可以组合使用:Server Component 可以在 SSR 项目下使用,也可以在 CSR 项目下使用。在 Modern.js 3.0 中,我们同时支持这两种模式,开发者可以根据需求选择。
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
#### 开箱即用
|
|
63
|
+
|
|
64
|
+
在 Modern.js 3.0 中,只需在配置中启用 RSC 能力:
|
|
65
|
+
|
|
66
|
+
```ts title="modern.config.ts"
|
|
67
|
+
export default defineConfig({
|
|
68
|
+
server: {
|
|
69
|
+
rsc: true,
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
:::info
|
|
75
|
+
配置启用后,所有的路由组件都会默认成为 Server Component。项目中可能存在无法在服务端运行的组件,你可以先为这些组件添加 `'use client'` 标记,以保持原有行为,再逐步迁移。
|
|
76
|
+
:::
|
|
77
|
+
|
|
78
|
+
<video src="https://lf3-static.bytednsdoc.com/obj/eden-cn/nuvjhpqnuvr/rsc.mp4" controls autoplay loop muted style={{ width: '100%', borderRadius: 8 }} />
|
|
79
|
+
|
|
80
|
+
#### Modern.js 3.0 的 RSC 特性
|
|
81
|
+
|
|
82
|
+
Modern.js 一直选择 React Router 作为路由解决方案。去年,React Router v7 [宣布支持](https://remix.run/blog/rsc-preview) React Server Component,这为 Modern.js 提供了在 SPA 应用下实现 RSC 的基础。
|
|
83
|
+
|
|
84
|
+
相比于社区其他框架,Modern.js 对 RSC 做了几点优化:
|
|
85
|
+
|
|
86
|
+
- 使用 Rspack 最新的 RSC 插件构建,显著提升 RSC 项目构建速度;并进一步优化了产物体积。
|
|
87
|
+
- 不同于社区主流框架只支持 RSC + SSR,Modern.js 3.0 的 RSC 同样支持 CSR 项目
|
|
88
|
+
- 在路由跳转时,框架会自动将多个 Data Loader 和 Server Component 的请求合并为单个请求,并流式返回,提升页面性能
|
|
89
|
+
- 在嵌套路由场景下,路由组件类型不受父路由组件类型的影响,开发者可以从任意路由层级开始采用 Server Component
|
|
90
|
+
|
|
91
|
+
#### 渐进式迁移
|
|
92
|
+
|
|
93
|
+
基于灵活的组件边界控制能力,Modern.js 3.0 提供了渐进式的迁移方式。Modern.js 3.0 允许基于**路由组件维度**的 Server Component 迁移,无需迁移整条组件树链路。
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
:::info
|
|
98
|
+
更多 React Server Component 的详细内容,可以参考:[React Server Component](/guides/basic-features/render/rsc)
|
|
99
|
+
:::
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### 拥抱 Rspack
|
|
104
|
+
|
|
105
|
+
:::tip TL;DR
|
|
106
|
+
Modern.js 3.0 移除了对 webpack 的支持,全面拥抱 Rspack,并升级到最新的 Rspack & Rsbuild 2.0。
|
|
107
|
+
:::
|
|
108
|
+
|
|
109
|
+
在 2023 年,我们开源了 Rspack,并在 Modern.js 中支持将 Rspack 作为可选的打包工具。在字节内部,超过 60% 的 Modern.js 项目已经切换到 Rspack 构建。
|
|
110
|
+
|
|
111
|
+
经过两年多发展,Rspack 在社区中的月下载量已超过 1000 万次,成长为行业内被广泛使用的打包工具;同时,Modern.js 的 Rspack 构建模式也得到持续完善。
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
在 Modern.js 3.0 中,我们决定移除对 webpack 的支持,从而使 Modern.js 变得更加轻量和高效,并能更充分地利用 Rspack 的新特性。
|
|
116
|
+
|
|
117
|
+
#### 更顺畅的开发体验
|
|
118
|
+
|
|
119
|
+
Modern.js 3.0 在移除 webpack 后,能够更好地遵循 Rspack 最佳实践,在构建性能、安装速度等方面均有提升:
|
|
120
|
+
|
|
121
|
+
**底层依赖升级**
|
|
122
|
+
|
|
123
|
+
Modern.js 3.0 将底层依赖的 Rspack 和 Rsbuild 升级至 2.0 版本,并基于新版本优化了默认构建配置,使整体行为更加一致。
|
|
124
|
+
|
|
125
|
+
参考以下文档了解底层行为变化:
|
|
126
|
+
|
|
127
|
+
- [Rsbuild 2.0 升级指南](https://v2.rsbuild.rs/zh/guide/upgrade/v1-to-v2)
|
|
128
|
+
- [Rspack 2.0 不兼容更新](https://github.com/web-infra-dev/rspack/discussions/9270)
|
|
129
|
+
|
|
130
|
+
**更快的构建速度**
|
|
131
|
+
|
|
132
|
+
Modern.js 通过 Rspack 的多项特性来减少构建耗时:
|
|
133
|
+
|
|
134
|
+
- 默认启用 Barrel 文件优化:构建组件库速度提升 20%
|
|
135
|
+
- 默认启用持久化缓存:非首次构建的速度提升 50%+
|
|
136
|
+
|
|
137
|
+
**更快的安装速度**
|
|
138
|
+
|
|
139
|
+
移除 webpack 相关依赖后,Modern.js 3.0 的构建依赖数量和体积均明显减少:
|
|
140
|
+
|
|
141
|
+
- npm 依赖数量减少 40%
|
|
142
|
+
- 安装体积减少 31 MB
|
|
143
|
+
|
|
144
|
+
#### 更小的构建产物
|
|
145
|
+
|
|
146
|
+
Modern.js 现在默认启用 Rspack 的多项产物优化策略,能够比 webpack 生成更小的产物体积,例如:
|
|
147
|
+
|
|
148
|
+
**增强 Tree shaking**
|
|
149
|
+
|
|
150
|
+
增强了 tree shaking 分析能力,可以处理更多动态导入语法,例如解构赋值:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
// 参数中的解构访问
|
|
154
|
+
import('./module').then(({ value }) => {
|
|
155
|
+
console.log(value);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// 函数体内的解构访问
|
|
159
|
+
import('./module').then((mod) => {
|
|
160
|
+
const { value } = mod;
|
|
161
|
+
console.log(value);
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**常量内联**
|
|
166
|
+
|
|
167
|
+
对常量进行跨模块内联,有助于压缩工具进行更准确的静态分析,从而消除无用的代码分支:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
// constants.js
|
|
171
|
+
export const ENABLED = true;
|
|
172
|
+
|
|
173
|
+
// index.js
|
|
174
|
+
import { ENABLED } from './constants';
|
|
175
|
+
if (ENABLED) {
|
|
176
|
+
doSomething();
|
|
177
|
+
} else {
|
|
178
|
+
doSomethingElse();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 构建产物 - 无用分支被消除
|
|
182
|
+
doSomething();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### 全链路可扩展
|
|
188
|
+
|
|
189
|
+
:::tip TL;DR
|
|
190
|
+
Modern.js 3.0 正式开放完整插件体系,提供运行时、服务端插件,同时支持灵活处理应用入口。
|
|
191
|
+
:::
|
|
192
|
+
|
|
193
|
+
Modern.js 2.0 提供了 CLI 插件与内测版本的运行时插件,允许开发者对项目进行扩展。但在实践过程中,我们发现现有的能力不足以支撑复杂的业务场景。
|
|
194
|
+
|
|
195
|
+
Modern.js 3.0 提供了更灵活的定制能力,允许为应用编写全流程的插件,帮助团队统一业务逻辑、减少重复代码:
|
|
196
|
+
|
|
197
|
+
- **CLI 插件**:在构建阶段扩展功能,如添加命令、修改配置
|
|
198
|
+
- **Runtime 插件**:在渲染阶段扩展功能,如数据预取、组件封装
|
|
199
|
+
- **Server 插件**:在服务端扩展功能,如添加中间件、修改请求响应
|
|
200
|
+
|
|
201
|
+
#### 运行时插件
|
|
202
|
+
|
|
203
|
+
运行时插件在 CSR 与 SSR 过程中都会运行,新版本提供了两个核心钩子:
|
|
204
|
+
|
|
205
|
+
- `onBeforeRender`:在渲染前执行逻辑,可用于数据预取、注入全局数据
|
|
206
|
+
- `wrapRoot`:封装根组件,添加全局 Provider、布局组件等
|
|
207
|
+
|
|
208
|
+
你可以在 `src/modern.runtime.ts` 中注册插件,相比在入口手动引入高阶组件,运行时插件可插拔、易更新,在多入口场景下无需重复引入:
|
|
209
|
+
|
|
210
|
+
```ts title="src/modern.runtime.tsx"
|
|
211
|
+
import { defineRuntimeConfig } from "@modern-js/runtime";
|
|
212
|
+
|
|
213
|
+
export default defineRuntimeConfig({
|
|
214
|
+
plugins: [
|
|
215
|
+
{
|
|
216
|
+
name: "my-runtime-plugin",
|
|
217
|
+
setup: (api) => {
|
|
218
|
+
api.onBeforeRender((context) => {
|
|
219
|
+
context.globalData = { theme: "dark" };
|
|
220
|
+
});
|
|
221
|
+
api.wrapRoot((App) => (props) => <App {...props} />);
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
:::info
|
|
229
|
+
更多 Runtime 插件使用方式,请查看文档:[Runtime 插件](/plugin/runtime-plugins/api)
|
|
230
|
+
:::
|
|
231
|
+
|
|
232
|
+
#### 服务端中间件
|
|
233
|
+
|
|
234
|
+
在实践过程中我们发现,部分项目需要扩展 Web Server,例如鉴权、数据预取、降级处理、动态 HTML 脚本注入等。
|
|
235
|
+
|
|
236
|
+
在 Modern.js 3.0 中,我们使用 [Hono](https://hono.dev) 重构了 Web Server,并正式开放了服务端中间件与插件的能力。开发者可以使用 Hono 的中间件来完成需求:
|
|
237
|
+
|
|
238
|
+
```ts title="server/modern.server.ts"
|
|
239
|
+
import { defineServerConfig, type MiddlewareHandler } from "@modern-js/server-runtime";
|
|
240
|
+
|
|
241
|
+
const timingMiddleware: MiddlewareHandler = async (c, next) => {
|
|
242
|
+
const start = Date.now();
|
|
243
|
+
await next();
|
|
244
|
+
const duration = Date.now() - start;
|
|
245
|
+
c.header('X-Response-Time', `${duration}ms`);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const htmlMiddleware: MiddlewareHandler = async (c, next) => {
|
|
249
|
+
await next();
|
|
250
|
+
const html = await c.res.text();
|
|
251
|
+
const modified = html.replace(
|
|
252
|
+
"<head>",
|
|
253
|
+
'<head><meta name="generator" content="Modern.js">'
|
|
254
|
+
);
|
|
255
|
+
c.res = c.body(modified, { status: c.res.status, headers: c.res.headers });
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export default defineServerConfig({
|
|
259
|
+
middlewares: [timingMiddleware],
|
|
260
|
+
renderMiddlewares: [htmlMiddleware],
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
:::info
|
|
265
|
+
更多服务端插件使用方式,可以查看文档:[自定义 Web Server](/guides/advanced-features/web-server)
|
|
266
|
+
:::
|
|
267
|
+
|
|
268
|
+
#### 自定义入口
|
|
269
|
+
|
|
270
|
+
在 Modern.js 3.0 中,我们重构了自定义入口,相比于旧版 API 更加清晰灵活:
|
|
271
|
+
|
|
272
|
+
```ts title="src/entry.tsx"
|
|
273
|
+
import { createRoot } from '@modern-js/runtime/react';
|
|
274
|
+
import { render } from '@modern-js/runtime/browser';
|
|
275
|
+
|
|
276
|
+
const ModernRoot = createRoot();
|
|
277
|
+
|
|
278
|
+
async function beforeRender() {
|
|
279
|
+
// 渲染前的异步操作,如初始化 SDK、获取用户信息等
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
beforeRender().then(() => {
|
|
283
|
+
render(<ModernRoot />);
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
:::info
|
|
288
|
+
更多入口使用方式,请查看文档:[入口](/guides/concept/entries)
|
|
289
|
+
:::
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
### 路由优化
|
|
294
|
+
|
|
295
|
+
:::tip TL;DR
|
|
296
|
+
Modern.js 3.0 内置 React Router v7,提供配置式路由能力与 AI 友好的调试方式。
|
|
297
|
+
:::
|
|
298
|
+
|
|
299
|
+
#### 内置 React Router v7
|
|
300
|
+
|
|
301
|
+
在 Modern.js 3.0 中,我们统一升级到 React Router v7,并废弃了对 v5 和 v6 的内置支持。这一决策基于以下考虑:
|
|
302
|
+
|
|
303
|
+
**版本演进与稳定性**
|
|
304
|
+
|
|
305
|
+
React Router v6 是一个重要的过渡版本,它引入了许多新特性(如数据加载、错误边界等)。而 v7 在保持 v6 API 兼容性的基础上,进一步优化了性能、稳定性和开发体验。随着 React Router 团队将 Remix 定位为独立框架,React Router 核心库可能会在 v7 版本上长期维护,使其成为更可靠的选择。
|
|
306
|
+
|
|
307
|
+
**升级路径**
|
|
308
|
+
|
|
309
|
+
- **从 v6 升级**:React Router v7 对 v6 开发者来说是无破坏性变更的升级。在 Modern.js 2.0 中,我们已提供了 React Router v7 插件支持,你可以通过插件方式渐进式升级,验证兼容性后再迁移到 Modern.js 3.0。
|
|
310
|
+
- **从 v5 升级**:v5 到 v7 存在较大的 API 变化,建议参考 [React Router 官方迁移指南](https://reactrouter.com/upgrading/v5) 进行迁移。
|
|
311
|
+
|
|
312
|
+
#### 配置式路由
|
|
313
|
+
|
|
314
|
+
在 Modern.js 中,我们推荐使用约定式路由来组织代码。但在实际业务中,开发者偶尔遇到以下场景:
|
|
315
|
+
|
|
316
|
+
- 多路径指向同一组件
|
|
317
|
+
- 灵活的路由控制
|
|
318
|
+
- 条件性路由
|
|
319
|
+
- 遗留项目迁移
|
|
320
|
+
|
|
321
|
+
因此,Modern.js 3.0 提供了完整的配置式路由支持,可以与约定式路由一起使用,或两者分别单独使用。
|
|
322
|
+
|
|
323
|
+
```ts title="src/modern.routes.ts"
|
|
324
|
+
import { defineRoutes } from "@modern-js/runtime/config-routes";
|
|
325
|
+
|
|
326
|
+
export default defineRoutes(({ route, layout, page }) => {
|
|
327
|
+
return [
|
|
328
|
+
route("home.tsx", "/"),
|
|
329
|
+
route("about.tsx", "about"),
|
|
330
|
+
route("blog.tsx", "blog/:id"),
|
|
331
|
+
];
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
:::info
|
|
336
|
+
更多配置式路由使用方式,请查看文档:[配置式路由](/guides/basic-features/routes/config-routes)
|
|
337
|
+
:::
|
|
338
|
+
|
|
339
|
+
#### 路由调试
|
|
340
|
+
|
|
341
|
+
运行 `npx modern routes` 命令即可在 `dist/routes-inspect.json` 文件中生成完整的路由结构分析报告。
|
|
342
|
+
|
|
343
|
+
报告中会显示每个路由的路径、组件文件、数据加载器、错误边界、Loading 组件等完整信息,帮助开发者快速了解项目的路由配置,快速定位和排查路由相关问题。结构化的 JSON 格式也便于 AI agent 理解和分析路由结构,提升 AI 辅助开发的效率。
|
|
344
|
+
|
|
345
|
+
:::info
|
|
346
|
+
具体使用方式,请查看文档:[路由调试](/guides/basic-features/routes/config-routes#调试路由)
|
|
347
|
+
:::
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
### 服务端渲染
|
|
352
|
+
|
|
353
|
+
:::tip TL;DR
|
|
354
|
+
Modern.js 3.0 重做了 SSG 能力,提供了灵活的缓存能力,对降级策略也进行了进一步的完善。
|
|
355
|
+
:::
|
|
356
|
+
|
|
357
|
+
#### 静态站点生成(SSG)
|
|
358
|
+
|
|
359
|
+
在 Modern.js 2.0 中,我们提供了静态站点生成的能力。这个能力非常适合用在可以静态渲染的页面中,能极大的提升页面首屏性能。
|
|
360
|
+
|
|
361
|
+
在新版本中,我们对 SSG 进行了重新设计:
|
|
362
|
+
|
|
363
|
+
- 数据获取使用 Data Loader,与非 SSG 场景保持一致
|
|
364
|
+
- 简化了 API,降低理解成本
|
|
365
|
+
- 与约定式路由更好地结合
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
在新版本中,你可以通过 data loader 进行数据获取,与非 SSG 场景保持一致。然后在 ssg.routes 配置中即可直接指定要渲染的路由:
|
|
369
|
+
|
|
370
|
+
```ts title="modern.config.ts"
|
|
371
|
+
export default defineConfig({
|
|
372
|
+
output: {
|
|
373
|
+
ssg: {
|
|
374
|
+
routes: ['/blog'],
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
```ts title="routes/blog/page.data.ts"
|
|
381
|
+
export const loader = async () => {
|
|
382
|
+
const articles = await fetchArticles();
|
|
383
|
+
return { articles };
|
|
384
|
+
};
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
:::info
|
|
388
|
+
更多 SSG 的使用方式,请查看文档:[SSG](/guides/basic-features/render/ssg)
|
|
389
|
+
:::
|
|
390
|
+
|
|
391
|
+
#### 缓存机制
|
|
392
|
+
|
|
393
|
+
Modern.js 3.0 中提供了不同维度的缓存机制,帮助项目提升首屏性能。所有缓存均支持灵活配置,比如可以支持类似 HTTP 的 `stale-while-revalidate` 策略:
|
|
394
|
+
|
|
395
|
+
**渲染缓存**
|
|
396
|
+
|
|
397
|
+
支持将 SSR 结果进行整页的缓存,在 `server/cache.ts` 中配置:
|
|
398
|
+
|
|
399
|
+
```ts title="server/cache.ts"
|
|
400
|
+
import type { CacheOption } from '@modern-js/server-runtime';
|
|
401
|
+
|
|
402
|
+
export const cacheOption: CacheOption = {
|
|
403
|
+
maxAge: 500, // ms
|
|
404
|
+
staleWhileRevalidate: 1000, // ms
|
|
405
|
+
};
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
:::info
|
|
409
|
+
使用渲染缓存,请查看文档:[渲染缓存](/guides/basic-features/render/ssr-cache)
|
|
410
|
+
:::
|
|
411
|
+
|
|
412
|
+
**数据缓存**
|
|
413
|
+
|
|
414
|
+
我们在新版本中提供了 `cache` 函数,相比渲染缓存它提供了更精细的数据粒度控制。当多个数据请求依赖同一份数据时,`cache` 可以避免重复请求:
|
|
415
|
+
|
|
416
|
+
```ts title="server/loader.ts"
|
|
417
|
+
import { cache } from "@modern-js/runtime/cache";
|
|
418
|
+
import { fetchUserData, fetchUserProjects, fetchUserTeam } from "./api";
|
|
419
|
+
|
|
420
|
+
// 缓存用户数据,避免重复请求
|
|
421
|
+
const getUser = cache(fetchUserData);
|
|
422
|
+
|
|
423
|
+
const getProjects = async () => {
|
|
424
|
+
const user = await getUser("test-user");
|
|
425
|
+
return fetchUserProjects(user.id);
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const getTeam = async () => {
|
|
429
|
+
const user = await getUser("test-user"); // 复用缓存,不会重复请求
|
|
430
|
+
return fetchUserTeam(user.id);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export const loader = async () => {
|
|
434
|
+
// getProjects 和 getTeam 都依赖 getUser,但 getUser 只会执行一次
|
|
435
|
+
const [projects, team] = await Promise.all([getProjects(), getTeam()]);
|
|
436
|
+
return { projects, team };
|
|
437
|
+
};
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
:::info
|
|
441
|
+
更多数据缓存的使用方式,请查看文档:[数据缓存](/guides/basic-features/data/data-cache)
|
|
442
|
+
:::
|
|
443
|
+
|
|
444
|
+
#### 灵活的降级策略
|
|
445
|
+
|
|
446
|
+
在实践过程中,我们沉淀了多维度的降级策略:
|
|
447
|
+
|
|
448
|
+
| 类型 | 触发方式 | 降级行为 | 使用场景 |
|
|
449
|
+
| --- | --- | --- | --- |
|
|
450
|
+
| 异常降级 | Data Loader 执行报错 | 触发 ErrorBoundary | 数据请求异常兜底 |
|
|
451
|
+
| 组件渲染报错 | 服务端渲染异常 | 降级到 CSR,复用已有数据渲染 | 服务端渲染异常兜底 |
|
|
452
|
+
| 业务降级 | Loader 抛出 `throw Response` | 触发 ErrorBoundary,返回对应 HTTP 状态码 | 404、权限校验等业务场景 |
|
|
453
|
+
| 配置 Client Loader | 配置 Client Loader | 绕过 SSR,直接请求数据源 | 需要在客户端直接获取数据的场景 |
|
|
454
|
+
| 强制降级 | Query 参数 `?__csr=true` | 跳过 SSR,返回 CSR 页面 | 调试、临时降级 |
|
|
455
|
+
| 强制降级 | 请求头 `x-modern-ssr-fallback` | 跳过 SSR,返回 CSR 页面 | 网关层控制降级 |
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
### 轻量 BFF
|
|
460
|
+
|
|
461
|
+
:::tip TL;DR
|
|
462
|
+
Modern.js 3.0 基于 Hono 重构了 Web Server,提供基于 Hono 的一体化函数,同时支持跨项目调用。
|
|
463
|
+
:::
|
|
464
|
+
|
|
465
|
+
#### Hono 一体化函数
|
|
466
|
+
|
|
467
|
+
在 Modern.js 3.0 中,我们使用 [Hono](https://hono.dev) 作为 BFF 的运行时框架,开发者可以基于 Hono 生态扩展 BFF Server,享受 Hono 轻量、高性能的优势。
|
|
468
|
+
|
|
469
|
+
通过 `useHonoContext` 可以获取完整的 Hono 上下文,访问请求信息、设置响应头等:
|
|
470
|
+
|
|
471
|
+
```ts title="api/lambda/user.ts"
|
|
472
|
+
import { useHonoContext } from '@modern-js/server-runtime';
|
|
473
|
+
|
|
474
|
+
export const get = async () => {
|
|
475
|
+
const c = useHonoContext();
|
|
476
|
+
const token = c.req.header('Authorization');
|
|
477
|
+
c.header('X-Custom-Header', 'modern-js');
|
|
478
|
+
const id = c.req.query('id');
|
|
479
|
+
|
|
480
|
+
return { userId: id, authenticated: !!token };
|
|
481
|
+
};
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
#### 跨项目调用
|
|
485
|
+
|
|
486
|
+
在过去,Modern.js BFF 只能在当前项目中使用,而我们陆续收到开发者反馈,希望能够在不同项目中使用。这多数情况是由于开发者的迁移成本、运维成本造成的,相比于抽出原有代码再部署一个,显然复用已有服务更加合理。
|
|
487
|
+
|
|
488
|
+
为了保证开发者能得到与当前项目一体化调用类似的体验,我们提供了跨项目调用的能力。
|
|
489
|
+
|
|
490
|
+
:::info
|
|
491
|
+
更多 BFF 的使用方式,请查看文档:[BFF](/guides/advanced-features/bff)
|
|
492
|
+
:::
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
### Module Federation 深度集成
|
|
497
|
+
|
|
498
|
+
:::tip TL;DR
|
|
499
|
+
Modern.js 3.0 与 [Module Federation 2.0](https://module-federation.io) 深度集成,支持 MF SSR 和应用级别模块导出。
|
|
500
|
+
:::
|
|
501
|
+
|
|
502
|
+
#### MF SSR
|
|
503
|
+
|
|
504
|
+
Modern.js 3.0 支持在 SSR 应用中使用 Module Federation,组合使用模块联邦和服务端渲染能力,为用户提供更好的首屏性能体验。
|
|
505
|
+
|
|
506
|
+
```ts title="modern.config.ts"
|
|
507
|
+
export default defineConfig({
|
|
508
|
+
server: {
|
|
509
|
+
ssr: {
|
|
510
|
+
mode: 'stream',
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
});
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
配合 Module Federation 的[数据获取](https://module-federation.io/zh/guide/basic/data-fetch/index.html)能力,每个远程模块都可以定义自己的数据获取逻辑:
|
|
517
|
+
|
|
518
|
+
```ts title="src/components/Button.data.ts"
|
|
519
|
+
export const fetchData = async () => {
|
|
520
|
+
return {
|
|
521
|
+
data: `Server time: ${new Date().toISOString()}`,
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
```tsx title="src/components/Button.tsx"
|
|
527
|
+
export const Button = (props: { mfData: { data: string } }) => {
|
|
528
|
+
return <button>{props.mfData?.data}</button>;
|
|
529
|
+
};
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
#### 应用级别模块
|
|
533
|
+
|
|
534
|
+
不同于传统的组件级别共享,Modern.js 3.0 支持导出**应用级别模块**——具备完整路由能力、可以像独立应用一样运行的模块。这是微前端场景中的重要能力。
|
|
535
|
+
|
|
536
|
+
**生产者导出应用**
|
|
537
|
+
|
|
538
|
+
```ts title="src/export-App.tsx"
|
|
539
|
+
import '@modern-js/runtime/registry/index';
|
|
540
|
+
import { render } from '@modern-js/runtime/browser';
|
|
541
|
+
import { createRoot } from '@modern-js/runtime/react';
|
|
542
|
+
import { createBridgeComponent } from '@module-federation/modern-js/react';
|
|
543
|
+
|
|
544
|
+
const ModernRoot = createRoot();
|
|
545
|
+
export const provider = createBridgeComponent({
|
|
546
|
+
rootComponent: ModernRoot,
|
|
547
|
+
render: (Component, dom) => render(Component, dom),
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
export default provider;
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
**消费者加载应用**
|
|
554
|
+
|
|
555
|
+
```tsx title="src/routes/remote/$.tsx"
|
|
556
|
+
import { createRemoteAppComponent } from '@module-federation/modern-js/react';
|
|
557
|
+
import { loadRemote } from '@module-federation/modern-js/runtime';
|
|
558
|
+
|
|
559
|
+
const RemoteApp = createRemoteAppComponent({
|
|
560
|
+
loader: () => loadRemote('remote/app'),
|
|
561
|
+
fallback: ({ error }) => <div>Error: {error.message}</div>,
|
|
562
|
+
loading: <div>Loading...</div>,
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
export default RemoteApp;
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
通过通配路由 `$.tsx`,所有访问 `/remote/*` 的请求都会进入远程应用,远程应用内部的路由也能正常工作。
|
|
569
|
+
|
|
570
|
+
:::info
|
|
571
|
+
更多 Module Federation 的使用方式,请查看文档:[Module Federation](/guides/topic-detail/module-federation/introduce)
|
|
572
|
+
:::
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
### 技术栈更新
|
|
577
|
+
|
|
578
|
+
:::tip TL;DR
|
|
579
|
+
Modern.js 3.0 升级 React 19,最低支持 Node.js 20。
|
|
580
|
+
:::
|
|
581
|
+
|
|
582
|
+
#### React 19
|
|
583
|
+
|
|
584
|
+
Modern.js 3.0 新项目默认使用 React 19,最低支持 React 18。
|
|
585
|
+
|
|
586
|
+
如果你的项目仍在使用 React 16 或 React 17,请先参考 [React 19 官方升级指南](https://react.dev/blog/2024/04/25/react-19-upgrade-guide) 完成版本升级。
|
|
587
|
+
|
|
588
|
+
#### Node.js 20
|
|
589
|
+
|
|
590
|
+
随着 Node.js 不断推进版本演进,Node.js 18 已经 EOL。在 Modern.js 3.0 中,推荐使用 Node.js 22 LTS,不再保证对 Node.js 18 的支持。
|
|
591
|
+
|
|
592
|
+
#### Storybook Rsbuild
|
|
593
|
+
|
|
594
|
+
在 Modern.js 3.0 中,我们基于 [Storybook Rsbuild](https://github.com/rspack-contrib/storybook-rsbuild) 实现了使用 Storybook 构建 Modern.js 应用。
|
|
595
|
+
|
|
596
|
+
通过 Storybook Addon,我们将 Modern.js 配置转换合并为 Rsbuild 配置,并通过 Storybook Rsbuild 驱动构建,让 Storybook 调试与开发命令保持配置对齐。
|
|
597
|
+
|
|
598
|
+
:::info
|
|
599
|
+
更多 Storybook 使用方式,请查看文档:[使用 Storybook](/guides/basic-features/debug/using-storybook)
|
|
600
|
+
:::
|
|
601
|
+
|
|
602
|
+
#### 使用 Biome
|
|
603
|
+
|
|
604
|
+
随着社区技术不断发展,更快、更简洁的工具链已经成熟。在 Modern.js 3.0 中,新项目默认使用 [Biome](https://biomejs.dev/) 作为代码检查和格式化工具。
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
## 从 Modern.js 2.0 升级到 3.0
|
|
609
|
+
|
|
610
|
+
### 主要变更
|
|
611
|
+
|
|
612
|
+
升级 Modern.js 3.0 意味着拥抱更轻量、更标准的现代化开发范式。通过全面对齐 Rspack 与 React 19 等主流生态,彻底解决历史包袱带来的维护痛点,显著提升构建与运行性能。
|
|
613
|
+
|
|
614
|
+
未来,我们也会基于 Modern.js 3.0 提供更多的 AI 集成与最佳实践,配合灵活的全栈插件系统,让开发者能以极低的学习成本复用社区经验,实现开发效率的质变与应用架构的现代化升级。
|
|
615
|
+
|
|
616
|
+
:::info
|
|
617
|
+
更多改进与变更,请查看文档:[升级指南](/guides/upgrade/overview)
|
|
618
|
+
:::
|
|
619
|
+
|
|
620
|
+
## 反馈和社区
|
|
621
|
+
|
|
622
|
+
最后,再次感谢每一位给予我们反馈和支持的开发者,我们将继续与大家保持沟通,在相互支持中共同成长。
|
|
623
|
+
|
|
624
|
+
如果你在使用过程中遇到问题,欢迎通过以下方式反馈:
|
|
625
|
+
|
|
626
|
+
- [GitHub Issues](https://github.com/web-infra-dev/modern.js/issues)
|
|
627
|
+
- [Discord](https://discord.gg/qPCqYg38De)
|
|
628
|
+
- [Lark](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=d21hc667-9403-48a9-ba32-bc1440a80279)
|