@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,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 路由集成
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 路由集成
|
|
6
|
+
|
|
7
|
+
## 启用语言路径前缀
|
|
8
|
+
|
|
9
|
+
设置 `localePathRedirect: true` 后,插件会接管 URL 中的语言识别和跳转,具体做以下四件事:
|
|
10
|
+
|
|
11
|
+
1. **识别 URL 里的语言前缀**:访问 `/zh/detail` 时,插件从路径中提取 `zh` 作为当前语言
|
|
12
|
+
2. **无前缀路径自动重定向**:访问 `/detail` 时,先通过 detector 检测语言,检测不到则用 `fallbackLanguage`,然后重定向到 `/en/detail` 或 `/zh/detail`
|
|
13
|
+
3. **切换语言时同步更新 URL**:当前在 `/en/detail`,调用 `changeLanguage('zh')` 后 URL 自动变为 `/zh/detail`,而不只是改 i18next 内部的语言状态
|
|
14
|
+
4. **避免路径被重复检测**:插件会自动从 i18next detector 的 `order` 中移除 `path`,因为路径语言识别已由插件自己处理,不需要 i18next 再检测一遍
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// modern.config.ts
|
|
18
|
+
i18nPlugin({
|
|
19
|
+
localeDetection: {
|
|
20
|
+
localePathRedirect: true,
|
|
21
|
+
languages: ['zh', 'en'],
|
|
22
|
+
fallbackLanguage: 'en',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**效果:**
|
|
28
|
+
|
|
29
|
+
| 访问路径 | 结果 |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `/about` | 重定向到 `/en/about` |
|
|
32
|
+
| `/en/about` | 正常访问,语言为 `en` |
|
|
33
|
+
| `/zh/about` | 正常访问,语言为 `zh` |
|
|
34
|
+
|
|
35
|
+
某些路径(如 API 路由、静态资源)不需要语言前缀,可以通过 `ignoreRedirectRoutes` 跳过重定向,详见[语言检测 → ignoreRedirectRoutes](./locale-detection.md#ignoreredirectroutes)。
|
|
36
|
+
|
|
37
|
+
## 路由配置
|
|
38
|
+
|
|
39
|
+
启用 `localePathRedirect` 后,需要在路由中添加 `[lang]` 动态参数来接收语言前缀。
|
|
40
|
+
|
|
41
|
+
### 约定式路由
|
|
42
|
+
|
|
43
|
+
在 `routes/` 目录下创建 `[lang]` 目录:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
routes/
|
|
47
|
+
└── [lang]/
|
|
48
|
+
├── layout.tsx ← 可在此读取 params.lang
|
|
49
|
+
├── page.tsx
|
|
50
|
+
└── about/
|
|
51
|
+
└── page.tsx
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
生成的路由结构:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
/:lang → page.tsx
|
|
58
|
+
/:lang/about → about/page.tsx
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
如果需要在布局或页面中读取当前语言参数:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// routes/[lang]/layout.tsx
|
|
65
|
+
import { Outlet, useParams } from '@modern-js/runtime/router';
|
|
66
|
+
|
|
67
|
+
export default function Layout() {
|
|
68
|
+
const { lang } = useParams();
|
|
69
|
+
// lang 为当前 URL 中的语言代码,如 'en'、'zh'
|
|
70
|
+
// 通常不需要手动使用,useModernI18n() 会自动管理
|
|
71
|
+
return <Outlet />;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 自定义路由
|
|
76
|
+
|
|
77
|
+
:::info
|
|
78
|
+
自定义路由仅在不使用 Modern.js 约定路由系统时才需要。大多数项目推荐使用约定式路由。
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
如果使用自定义路由文件(`modern.routes.ts`),需要手动添加 `:lang` 参数:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// modern.routes.ts
|
|
85
|
+
import { Route, Routes, Outlet } from '@modern-js/runtime/router';
|
|
86
|
+
|
|
87
|
+
export default function App() {
|
|
88
|
+
return (
|
|
89
|
+
<Routes>
|
|
90
|
+
<Route path=":lang" element={<Outlet />}>
|
|
91
|
+
<Route index element={<Home />} />
|
|
92
|
+
<Route path="about" element={<About />} />
|
|
93
|
+
</Route>
|
|
94
|
+
</Routes>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## I18nLink 组件
|
|
100
|
+
|
|
101
|
+
`I18nLink` 是语言感知的链接组件,会自动在目标路径前添加当前语言前缀,无需手动拼接。
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { I18nLink } from '@modern-js/plugin-i18n/runtime';
|
|
105
|
+
|
|
106
|
+
function Navigation() {
|
|
107
|
+
return (
|
|
108
|
+
<nav>
|
|
109
|
+
<I18nLink to="/">首页</I18nLink>
|
|
110
|
+
<I18nLink to="/about">关于</I18nLink>
|
|
111
|
+
<I18nLink to="/contact" replace>联系</I18nLink>
|
|
112
|
+
</nav>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**当前语言为 `en` 时:**
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
<I18nLink to="/about"> → 实际链接:/en/about
|
|
121
|
+
<I18nLink to="/"> → 实际链接:/en
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**注意事项:**
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
// ✅ 正确:不需要手动添加语言前缀
|
|
128
|
+
<I18nLink to="/about">关于</I18nLink>
|
|
129
|
+
|
|
130
|
+
// ❌ 错误:不要手动添加语言前缀,会导致 /en/en/about
|
|
131
|
+
<I18nLink to="/en/about">关于</I18nLink>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`I18nLink` 继承自 `@modern-js/runtime/router` 的 `Link` 组件,支持 `replace`、`state`、`className` 等所有标准 Link props,完整 Props 类型见 [API 参考](./api.md#i18nlink-组件)。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 国际化
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 国际化
|
|
6
|
+
|
|
7
|
+
import I18nPluginIntroduce from '@site-docs/components/international/introduce';
|
|
8
|
+
|
|
9
|
+
<I18nPluginIntroduce />
|
|
10
|
+
|
|
11
|
+
## 从哪里开始?
|
|
12
|
+
|
|
13
|
+
| 想做的事 | 文档 |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| 首次接入,跑通示例 | [快速开始](./international/quick-start.md) |
|
|
16
|
+
| 了解完整的配置选项 | [配置说明](./international/configuration.md) |
|
|
17
|
+
| 根据 URL / Cookie / Header 自动判断语言 | [语言检测](./international/locale-detection.md) |
|
|
18
|
+
| 实现 `/en/about` 这类带语言前缀的路径 | [路由集成](./international/routing.md) |
|
|
19
|
+
| 从远程服务或平台加载翻译资源 | [资源加载 → 自定义后端](./international/resource-loading.md#sdk-后端) |
|
|
20
|
+
| SSR 场景、多入口、自定义实例 | [高级用法](./international/advanced.md) |
|
|
21
|
+
| 查询 Hook / 组件 / 类型定义 | [API 参考](./international/api.md) |
|
|
22
|
+
|
|
23
|
+
## 核心能力
|
|
24
|
+
|
|
25
|
+
- **语言检测**:支持 URL 路径、Cookie、LocalStorage、请求头、浏览器设置等多种检测方式,可自由组合优先级
|
|
26
|
+
- **资源加载**:支持 HTTP 静态文件、文件系统(SSR)、SDK 自定义函数三种后端,以及链式后端渐进加载
|
|
27
|
+
- **路由集成**:自动添加语言路径前缀(`/en/about`),提供 `I18nLink` 组件处理语言感知导航
|
|
28
|
+
- **SSR 支持**:服务端检测语言并注入到页面,客户端直接使用,避免语言闪烁
|
|
29
|
+
- **TypeScript 支持**:完整类型定义,支持翻译键类型安全检查
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 10
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 配置底层工具
|
|
6
|
+
|
|
7
|
+
## 使用方式
|
|
8
|
+
|
|
9
|
+
Modern.js 内部默认集成了 [TypeScript](https://www.typescriptlang.org/)、[Rspack](https://rspack.rs/)、[PostCSS](https://postcss.org/)、[SWC](https://swc.rs/) 等工具。通常情况下,默认配置能够满足大多业务开发需求。当有特殊需求时,可以通过底层配置来实现。
|
|
10
|
+
|
|
11
|
+
以配置 Rspack 为例,只需要在 `modern.config.ts` 中添加 [`tools.rspack`](/configure/app/tools/rspack) 即可:
|
|
12
|
+
|
|
13
|
+
```ts title="modern.config.ts"
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
tools: {
|
|
16
|
+
rspack: config => {
|
|
17
|
+
// 修改 Rspack 配置
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`tools` 命名空间下的配置都可以设置为 `Object` 或者 `Function`。
|
|
24
|
+
|
|
25
|
+
值为 `Object` 时,会与内部默认配置进行合并,具体合并策略参考对应的配置选项文档(见下表)。
|
|
26
|
+
|
|
27
|
+
值为 `Function` 时,第一个参数为内部的默认配置对象,可以直接修改这个对象不做返回,也可以返回一个新的对象或者合并后的对象作为最终结果。
|
|
28
|
+
|
|
29
|
+
## 底层配置明细
|
|
30
|
+
|
|
31
|
+
目前提供的底层配置如下表:
|
|
32
|
+
|
|
33
|
+
| 底层工具 | 配置 |
|
|
34
|
+
| ------------------ | -------------------------------------------------------------------- |
|
|
35
|
+
| Rspack | [tools.rspack](/configure/app/tools/rspack) |
|
|
36
|
+
| Bundler Chain | [tools.bundlerChain](/configure/app/tools/bundler-chain) |
|
|
37
|
+
| SWC | [tools.swc](/configure/app/tools/swc) |
|
|
38
|
+
| TypeScript Checker | [tools.tsChecker](/configure/app/tools/ts-checker) |
|
|
39
|
+
| PostCSS | [tools.postcss](/configure/app/tools/postcss) |
|
|
40
|
+
| Less | [tools.less](/configure/app/tools/less) |
|
|
41
|
+
| Sass | [tools.sass](/configure/app/tools/sass) |
|
|
42
|
+
| CSS Extract | [tools.cssExtract](/configure/app/tools/css-extract) |
|
|
43
|
+
| CSS Loader | [tools.cssLoader](/configure/app/tools/css-loader) |
|
|
44
|
+
| Style Loader | [tools.styleLoader](/configure/app/tools/style-loader) |
|
|
45
|
+
| Lightning CSS | [tools.lightningcssLoader](/configure/app/tools/lightningcss-loader) |
|
|
46
|
+
| Minify CSS | [tools.minifyCss](/configure/app/tools/minify-css) |
|
|
47
|
+
| Autoprefixer | [tools.autoprefixer](/configure/app/tools/autoprefixer) |
|
|
48
|
+
| HTML Plugin | [tools.htmlPlugin](/configure/app/tools/html-plugin) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["code-split", "inline-assets", "optimize-bundle", "react-compiler"]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 代码分割
|
|
6
|
+
|
|
7
|
+
代码分割(code splitting)是优化前端资源加载的一种常用手段,本文将介绍 Modern.js 支持的三种代码分割方式:
|
|
8
|
+
|
|
9
|
+
:::info
|
|
10
|
+
使用 Modern.js [约定式路由](/guides/basic-features/routes/routes#约定式路由)时,默认会根据路由组件做代码分割,无需自行进行代码分割。
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
- 动态 `import`
|
|
14
|
+
- `React.lazy`
|
|
15
|
+
- `loadable`
|
|
16
|
+
|
|
17
|
+
## 动态 import
|
|
18
|
+
|
|
19
|
+
使用动态 `import()` 语法,传入的 JS 模块将会被打包到单独的 JS 文件中。例如:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import('./math').then(math => {
|
|
23
|
+
console.log(math.add(16, 26));
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## React.lazy
|
|
28
|
+
|
|
29
|
+
React 官方提供的组件代码分割的方式。
|
|
30
|
+
|
|
31
|
+
:::caution
|
|
32
|
+
`React.lazy` 通常配合 `<Suspense>` 使用,因此仅在 CSR 或 React 18+ 的 Streaming SSR 中可用。
|
|
33
|
+
|
|
34
|
+
对于使用传统 SSR(字符串渲染)的项目,不支持 `React.lazy`,请使用 Loadable API。
|
|
35
|
+
:::
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import React, { Suspense } from 'react';
|
|
39
|
+
|
|
40
|
+
const OtherComponent = React.lazy(() => import('./OtherComponent'));
|
|
41
|
+
const AnotherComponent = React.lazy(() => import('./AnotherComponent'));
|
|
42
|
+
|
|
43
|
+
function MyComponent() {
|
|
44
|
+
return (
|
|
45
|
+
<div>
|
|
46
|
+
<Suspense fallback={<div>Loading...</div>}>
|
|
47
|
+
<section>
|
|
48
|
+
<OtherComponent />
|
|
49
|
+
<AnotherComponent />
|
|
50
|
+
</section>
|
|
51
|
+
</Suspense>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`React.lazy` 更多用法请见 [React 官网文档](https://zh-hans.react.dev/reference/react/lazy)。
|
|
58
|
+
|
|
59
|
+
## Loadable
|
|
60
|
+
|
|
61
|
+
在 Modern.js 中,可以从 `@modern-js/runtime/loadable` 中导出使用 Loadable API,示例如下:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import loadable from '@modern-js/runtime/loadable';
|
|
65
|
+
|
|
66
|
+
const OtherComponent = loadable(() => import('./OtherComponent'));
|
|
67
|
+
|
|
68
|
+
function MyComponent() {
|
|
69
|
+
return <OtherComponent />;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Modern.js 开箱即用的支持在 SSR 中使用 `loadable`,无需再添加 Babel 插件,或是在 SSR 时向 HTML 中注入脚本。
|
|
74
|
+
|
|
75
|
+
但需要注意的是,任何 Loadable API 在 SSR 中都不支持配合 `<Suspense>` 使用。
|
|
76
|
+
|
|
77
|
+
:::info
|
|
78
|
+
如果希望在 React 17 及以下的 CSR 项目中使用 `<Suspense>`,可以用 [loadable.lazy](https://loadable-components.com/docs/suspense/) 代替 `React.lazy`。
|
|
79
|
+
:::
|
|
80
|
+
|
|
81
|
+
更多用法请见 [Loadable API](/apis/app/runtime/utility/loadable)。
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 13
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 静态资源内联
|
|
6
|
+
|
|
7
|
+
静态资源内联是一种优化网页性能的方法,它指的是将静态资源直接内联到 HTML 或 JS 文件中,而不是使用外部文件引用的方式。这样做的好处是减少了浏览器发起的请求数,从而提高页面的加载速度。
|
|
8
|
+
|
|
9
|
+
不过,静态资源内联也有一些缺点,比如增加了单个文件的体积,可能会导致加载变慢。所以在实际应用中,需要根据具体情况来决定是否使用静态资源内联。
|
|
10
|
+
|
|
11
|
+
Modern.js 默认会自动内联体积小于 10KB 的静态资源,但有时候你可能需要手动控制某些特殊资源,让其强制内联或者强制不内联,这篇文档阐述了如何进行精确地控制静态资源内联行为。
|
|
12
|
+
|
|
13
|
+
## 自动内联
|
|
14
|
+
|
|
15
|
+
默认情况下,当图片、字体、媒体等类型的文件体积小于阈值(默认为 10KB)时,Modern.js 会将资源进行内联处理,资源内联后,会被转换成一个 Base64 编码的字符串,不再会发送独立的 HTTP 请求。当文件体积大于或等于该阈值时,则会被作为单独的资源文件,通过独立的 HTTP 请求来加载。
|
|
16
|
+
|
|
17
|
+
自动内联的体积阈值可以通过 [output.dataUriLimit](/configure/app/output/data-uri-limit) 配置项修改。例如,修改图片资源的阈值为 5000 字节,设置视频资源不内联:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
export default {
|
|
21
|
+
output: {
|
|
22
|
+
dataUriLimit: {
|
|
23
|
+
image: 5000,
|
|
24
|
+
media: 0,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 强制内联
|
|
31
|
+
|
|
32
|
+
你可以通过在引入资源时添加 `inline` URL 参数来强制内联该资源,无论该资源的体积是否小于阈值。
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import React from 'react';
|
|
36
|
+
import img from './foo.png?inline';
|
|
37
|
+
|
|
38
|
+
export default function Foo() {
|
|
39
|
+
return <img src={img} />;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
在上面这个例子中,`foo.png` 图片将始终被内联,无论该图片的大小是否大于阈值。
|
|
44
|
+
|
|
45
|
+
除了 `inline` 参数以外,你也可以使用 `__inline` 参数来强制内联该资源:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import img from './foo.png?__inline';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 从 CSS 文件中引用
|
|
52
|
+
|
|
53
|
+
当你在 CSS 文件中引用静态资源时,同样可以通过 `inline` 或 `__inline` 参数来强制内联资源。
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
.foo {
|
|
57
|
+
background-image: url('./icon.png?inline');
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
:::tip 你真的需要强制内联吗?
|
|
62
|
+
内联体积过大的资源时,会显著增加页面的白屏时间或首次可交互时间,这会损害用户体验。并且当你将一个静态资源多次内联到 CSS 文件中时,base64 内容会重复注入,导致产物体积增大。因此,请酌情使用强制内联。
|
|
63
|
+
:::
|
|
64
|
+
|
|
65
|
+
## 强制不内联
|
|
66
|
+
|
|
67
|
+
当你想把一些资源始终作为单独的资源文件来处理,无论该资源的体积多小时,你可以添加 `url` URL 参数来强制不内联该资源。
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import React from 'react';
|
|
71
|
+
import img from './foo.png?url';
|
|
72
|
+
|
|
73
|
+
export default function Foo() {
|
|
74
|
+
return <img src={img} />;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
在上面这个例子中,`foo.png` 图片将始终通过单独的资源文件加载,无论该图片的大小是否小于阈值。
|
|
79
|
+
|
|
80
|
+
除了 `url` 参数以外,你也可以使用 `__inline=false` 参数来强制不内联该资源:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import img from './foo.png?__inline=false';
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 从 CSS 文件中引用
|
|
87
|
+
|
|
88
|
+
当你在 CSS 文件中引用静态资源时,同样可以通过 `url` 或 `__inline=false` 参数来强制不内联资源。
|
|
89
|
+
|
|
90
|
+
```css
|
|
91
|
+
.foo {
|
|
92
|
+
background-image: url('./icon.png?url');
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
:::tip 你真的需要把资源排除内联吗?
|
|
97
|
+
将资源排除内联将增加 Web App 需要加载的资源数量,这对于弱网环境,或是未开启 HTTP2 的场景下,将会降低资源加载效率,因此,请酌情使用强制不内联。
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
## 内联 JS 文件
|
|
101
|
+
|
|
102
|
+
除了将静态资源文件内联到 JS 文件里,Modern.js 也支持将 JS 文件内联到 HTML 文件中。
|
|
103
|
+
|
|
104
|
+
只需要开启 [output.inlineScripts](/configure/app/output/inline-scripts) 配置项,构建生成的 JS 文件将不会被写入产物目录下,而是会直接内联到对应的 HTML 文件中。
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
export default {
|
|
108
|
+
output: {
|
|
109
|
+
inlineScripts: true,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
:::tip
|
|
115
|
+
内联 JS 文件可能会导致 HTML 单文件体积过大,并且不利于静态资源缓存,请酌情使用。
|
|
116
|
+
:::
|
|
117
|
+
|
|
118
|
+
## 内联 CSS 文件
|
|
119
|
+
|
|
120
|
+
你也可以将 CSS 文件内联到 HTML 文件中。
|
|
121
|
+
|
|
122
|
+
只需要开启 [output.inlineStyles](/configure/app/output/inline-styles) 配置项,构建生成的 CSS 文件将不会被写入产物目录下,而是会直接内联到对应的 HTML 文件中。
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
export default {
|
|
126
|
+
output: {
|
|
127
|
+
inlineStyles: true,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 添加类型声明
|
|
133
|
+
|
|
134
|
+
当你在 TypeScript 代码中使用 `?inline` 和 `?url` 等 URL 参数时,TypeScript 可能会提示该模块缺少类型定义:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
TS2307: Cannot find module './logo.png?inline' or its corresponding type declarations.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
此时你需要为这些 URL 参数添加类型声明,请在项目中创建 `src/global.d.ts` 文件,并添加以下类型声明:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
declare module '*?inline' {
|
|
144
|
+
const content: string;
|
|
145
|
+
export default content;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare module '*?inline' {
|
|
149
|
+
const content: string;
|
|
150
|
+
export default content;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare module '*?__inline' {
|
|
154
|
+
const content: string;
|
|
155
|
+
export default content;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare module '*?inline=false' {
|
|
159
|
+
const content: string;
|
|
160
|
+
export default content;
|
|
161
|
+
}
|
|
162
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 13
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 产物体积优化
|
|
6
|
+
|
|
7
|
+
产物体积的优化在生产环境中是非常重要的,因为它直接影响到了线上的用户体验。在这篇文档中,我们将介绍在 Modern.js 中一些常见的产物体积优化方式。
|
|
8
|
+
|
|
9
|
+
## 减少重复依赖
|
|
10
|
+
|
|
11
|
+
在业务项目中,会存在某些第三方依赖被安装了多个版本的现象。重复依赖会导致包体积变大、构建速度变慢。
|
|
12
|
+
|
|
13
|
+
我们可以通过社区中的一些工具来检测或消除重复依赖。
|
|
14
|
+
|
|
15
|
+
- 如果你在使用 `pnpm >= 7.26.0`,可以使用 pnpm 自带的 [pnpm dedupe](https://pnpm.io/cli/dedupe) 命令来升级和消除其中的重复依赖。
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm dedupe
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- 如果你在使用 `pnpm < 7.26.0` 版本,可以使用 [pnpm-deduplicate](https://github.com/ocavue/pnpm-deduplicate) 来分析出所有的重复依赖,并通过升级依赖或声明 [pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) 进行版本合并。
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx pnpm-deduplicate --list
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- 如果你在使用 `yarn`,可以使用 [yarn-deduplicate](https://github.com/scinos/yarn-deduplicate) 来自动合并重复依赖:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx yarn-deduplicate && yarn
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 使用更轻量的库
|
|
34
|
+
|
|
35
|
+
建议将项目中体积较大的三方库替换为更轻量的库,比如将 [moment](https://momentjs.com/) 替换为 [day.js](https://day.js.org/)。
|
|
36
|
+
|
|
37
|
+
如果你需要找出项目中体积较大的三方库,可以在执行构建时添加 `BUNDLE_ANALYZE=true` 环境变量:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
BUNDLE_ANALYZE=true pnpm build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
这将生成一个打包分析报告,帮助你识别体积较大的依赖。
|
|
44
|
+
|
|
45
|
+
## 提升 Browserslist 范围
|
|
46
|
+
|
|
47
|
+
Modern.js 会根据项目的 Browserslist 配置范围进行代码编译,并注入相应的 Polyfill。如果项目不需要兼容旧版浏览器,可以根据实际情况来提升 Browserslist 范围,从而减少在语法和 Polyfill 上的编译开销。
|
|
48
|
+
|
|
49
|
+
Modern.js 默认的 [`output.overrideBrowserslist`](/configure/app/output/override-browserslist.html) 配置为:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14'];
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
比如只兼容 Chrome 100 以上的浏览器,可以改成:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
['Chrome >= 100'];
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
:::tip
|
|
62
|
+
请阅读 [Browserslist 配置](/guides/advanced-features/compatibility.html) 章节来了解更多关于 Browserslist 的用法。
|
|
63
|
+
:::
|
|
64
|
+
|
|
65
|
+
## 按需引入 polyfill
|
|
66
|
+
|
|
67
|
+
在明确第三方依赖不需要额外 polyfill 的情况下,你可以将 [output.polyfill](/configure/app/output/polyfill.html) 设置为 `usage`。
|
|
68
|
+
|
|
69
|
+
在 `usage` 模式下,Modern.js 会分析源代码中使用的语法,按需注入所需的 polyfill 代码,从而减少 polyfill 的代码量。
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
export default {
|
|
73
|
+
output: {
|
|
74
|
+
polyfill: 'usage',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
:::tip
|
|
80
|
+
请阅读 [浏览器兼容性](/guides/advanced-features/compatibility) 章节来了解更多关于 polyfill 的用法。
|
|
81
|
+
:::
|
|
82
|
+
|
|
83
|
+
## 使用图片压缩
|
|
84
|
+
|
|
85
|
+
在一般的前端项目中,图片资源的体积往往是项目产物体积的大头,因此如果能尽可能精简图片的体积,那么将会对项目的打包产物体积起到明显的优化效果。你可以在 Modern.js 中注册插件来启用图片压缩功能:
|
|
86
|
+
|
|
87
|
+
```js title="modern.config.ts"
|
|
88
|
+
import { pluginImageCompress } from '@rsbuild/plugin-image-compress';
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
builderPlugins: [pluginImageCompress()],
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
详见 [Image Compress 插件](https://github.com/rspack-contrib/rsbuild-plugin-image-compress)。
|
|
96
|
+
|
|
97
|
+
## 代码拆包
|
|
98
|
+
|
|
99
|
+
良好的拆包策略对于提升应用的加载性能是十分重要的,可以充分利用浏览器的缓存机制,减少请求数量,加快页面加载速度。
|
|
100
|
+
|
|
101
|
+
在 Modern.js 中内置了[多种拆包策略](https://v2.rsbuild.rs/zh/guide/optimization/code-splitting),可以满足大部分应用的需求,你也可以根据自己的业务场景,自定义拆包配置。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# React Compiler
|
|
2
|
+
|
|
3
|
+
React Compiler 是 React 19 引入的一个实验性编译器,它可以自动优化你的 React 代码。
|
|
4
|
+
|
|
5
|
+
在开始使用 React Compiler 之前,建议阅读 [React Compiler 文档](https://zh-hans.react.dev/learn/react-compiler),以了解 React Compiler 的功能、当前状态和使用方法。
|
|
6
|
+
|
|
7
|
+
## 如何使用
|
|
8
|
+
|
|
9
|
+
### React 19
|
|
10
|
+
|
|
11
|
+
如果你使用的是 React 19,Modern.js 已内置支持 React Compiler,无需额外配置即可使用。
|
|
12
|
+
|
|
13
|
+
### React 18
|
|
14
|
+
|
|
15
|
+
如果你使用的是 React 18,需要按照以下步骤配置:
|
|
16
|
+
|
|
17
|
+
1. 安装 `react-compiler-runtime`,以允许编译后的代码在 19 之前的版本上运行:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install react-compiler-runtime
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. 安装 `babel-plugin-react-compiler`:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install babel-plugin-react-compiler
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. 在你的 Modern.js 配置文件中注册 Babel 插件:
|
|
30
|
+
|
|
31
|
+
```ts title="modern.config.ts"
|
|
32
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
33
|
+
import { pluginBabel } from '@rsbuild/plugin-babel';
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
builderPlugins: [
|
|
37
|
+
pluginBabel({
|
|
38
|
+
babelLoaderOptions: (config, { addPlugins }) => {
|
|
39
|
+
addPlugins([
|
|
40
|
+
[
|
|
41
|
+
'babel-plugin-react-compiler',
|
|
42
|
+
{
|
|
43
|
+
target: '18', // 或 '17',根据你使用的 React 版本
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
]);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
];
|
|
50
|
+
plugins: [appTools()],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
> 详细代码可以参考:[Modern.js & React Compiler 示例项目](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/react-compiler)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["monitors", "logger", "metrics"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 日志事件
|
|
2
|
+
|
|
3
|
+
日志事件是由 Modern.js 分发的,类型为 `log` 的事件。
|
|
4
|
+
|
|
5
|
+
## 内置事件
|
|
6
|
+
|
|
7
|
+
基于服务端运行逻辑,Modern.js 在内部提供了以下日志事件:
|
|
8
|
+
|
|
9
|
+
| 阶段 | 消息 | Level |
|
|
10
|
+
| ------------- | -------------------------------------------- | ----- |
|
|
11
|
+
| RENDER_HTML | App Render To HTML | error |
|
|
12
|
+
| RENDER_STREAM | An error occurs during streaming SSR | error |
|
|
13
|
+
| RENDER_SHELL | An error occurs during streaming render shell | error |
|
|
14
|
+
|
|
15
|
+
## 内置 Monitor
|
|
16
|
+
|
|
17
|
+
import InternalLogger from '@site-docs/components/internal-logger.mdx';
|
|
18
|
+
|
|
19
|
+
<InternalLogger />
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 指标事件
|
|
2
|
+
|
|
3
|
+
指标事件是由 Monitors 分发,类型为 `timing` 或 `counter` 的事件。
|
|
4
|
+
|
|
5
|
+
## 内置事件
|
|
6
|
+
|
|
7
|
+
当项目开启 SSR 时,我们需要关注 Server 端各阶段耗时,并且有能力对 Server 端的问题进行定位。
|
|
8
|
+
|
|
9
|
+
基于服务端运行逻辑,Modern.js 在内部提供了以下指标事件:
|
|
10
|
+
|
|
11
|
+
| Key | 描述 |
|
|
12
|
+
| ------------------------ | --------------- |
|
|
13
|
+
| server-handle-request | Modern.js Server 处理请求单次耗时 |
|
|
14
|
+
| ssr-render-shell | [SSR]在使用 Streaming SSR 时, React 将渲染一个套壳(shell)优先传输。这里表明套壳渲染完成时间 |
|
|
15
|
+
| ssr-render-html | [SSR] React 将组件树渲染成 html 所消耗的时间,通常不会超过 50ms |
|
|
16
|
+
| server-middleware | Modern.js 自定义 Server `Middleware` 执行总时 |
|
|
17
|
+
| server-loader | Server 端整体 Data Loader 耗时 |
|
|
18
|
+
| server-loader-#id | Server 端各个 Data Loader 耗时 |
|
|
19
|
+
| server-loader-navigation | 前端导航时,服务端 Data Loader 的整体耗时 |
|
|
20
|
+
|
|
21
|
+
Modern.js 服务端流程如图所示:
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 内置 Monitor
|
|
27
|
+
|
|
28
|
+
import InternalMetrics from '@site-docs/components/internal-metrics.mdx';
|
|
29
|
+
|
|
30
|
+
<InternalMetrics />
|
|
31
|
+
|
|
32
|
+
## Server-Timing
|
|
33
|
+
|
|
34
|
+
在 Modern.js 中,服务端还会额外将各阶段指标作为 Server-Timing 注入到 HTML 响应头中。
|
|
35
|
+
|
|
36
|
+
在浏览器中,开发者可以通过 [Performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance) 获取:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const navigation = performance.getEntriesByType('navigation')[0];
|
|
40
|
+
const serverTiming = navigation.serverTiming;
|
|
41
|
+
console.log(serverTiming);
|
|
42
|
+
```
|