@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,153 @@
|
|
|
1
|
+
# 插件介绍
|
|
2
|
+
|
|
3
|
+
Modern.js 提供了一套强大的插件体系,允许开发者通过编写插件来扩展框架功能、定制构建流程,以及满足各种个性化的开发需求。无论你是想添加一个自定义命令、优化构建产物,还是实现一套独特的部署方案,Modern.js 的插件系统都能为你提供强大的支持。
|
|
4
|
+
|
|
5
|
+
## 为什么需要插件?
|
|
6
|
+
|
|
7
|
+
在 Web 应用开发中,我们经常会遇到一些框架本身无法直接满足的需求,例如:
|
|
8
|
+
|
|
9
|
+
- **我想添加一个自定义的命令行工具,来帮助我自动化一些任务。**
|
|
10
|
+
- **我希望能够处理一种新的文件格式,比如 `.xyz`。**
|
|
11
|
+
- **我需要在应用启动前执行一些初始化的操作。**
|
|
12
|
+
- **我想对构建生成的 CSS 文件进行特殊的处理。**
|
|
13
|
+
- **我需要定制应用的路由逻辑,或者添加一些服务端中间件。**
|
|
14
|
+
|
|
15
|
+
在没有插件系统的情况下,这些需求可能需要修改框架源码,或者采用一些繁琐的 hack 手段。而 Modern.js 的插件系统提供了一种优雅、灵活且可维护的解决方案。
|
|
16
|
+
|
|
17
|
+
## 何时使用哪种插件?
|
|
18
|
+
|
|
19
|
+
Modern.js 提供了两种主要的插件类型:Modern.js 框架插件和 Rsbuild 构建插件。选择哪种插件取决于你的具体需求:
|
|
20
|
+
|
|
21
|
+
- **Rsbuild 构建插件:** 如果你的需求与构建过程密切相关,特别是涉及到 Rspack 配置的修改,那么你应该选择 Rsbuild 插件。例如:
|
|
22
|
+
|
|
23
|
+
- 修改 Rspack 的 `loader` 或 `plugin` 配置。
|
|
24
|
+
- 处理新的文件类型。
|
|
25
|
+
- 修改或编译文件内容。
|
|
26
|
+
- 对构建产物进行优化或处理。
|
|
27
|
+
|
|
28
|
+
- **Modern.js 框架插件:** 如果你的需求与 Modern.js 框架本身的功能扩展、运行时行为或服务端逻辑相关,那么你应该选择 Modern.js 插件。例如:
|
|
29
|
+
- 添加自定义的命令行命令。
|
|
30
|
+
- 修改运行时信息。
|
|
31
|
+
- 定制化应用的渲染过程(如 SSR)。
|
|
32
|
+
- 添加服务端中间件或处理函数。
|
|
33
|
+
|
|
34
|
+
简单来说,需要修改 Rspack 配置时,使用 Rsbuild 插件;其他与框架相关的功能扩展,使用 Modern.js 插件。
|
|
35
|
+
|
|
36
|
+
## Modern.js 框架插件
|
|
37
|
+
|
|
38
|
+
### 插件类型
|
|
39
|
+
|
|
40
|
+
Modern.js 框架插件可以细分为三类,分别是:
|
|
41
|
+
|
|
42
|
+
#### CLI 插件
|
|
43
|
+
|
|
44
|
+
CLI 插件用于在应用执行 `modern` 命令时提供额外功能,例如添加命令、修改配置、监听文件等。大部分构建相关能力均可通过 CLI 插件实现。
|
|
45
|
+
|
|
46
|
+
CLI 插件可通过 `modern.config.ts` 中的 `plugins` 字段进行配置。
|
|
47
|
+
|
|
48
|
+
```ts title="modern.config.ts"
|
|
49
|
+
// bff 的示例
|
|
50
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
51
|
+
import { bffPlugin } from '@modern-js/plugin-bff';
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
plugins: [appTools(), bffPlugin()],
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Runtime 插件
|
|
59
|
+
|
|
60
|
+
Runtime 插件用于在应用运行 React 代码时提供额外功能,例如执行初始化行为、实现 React 高阶组件(HOC)封装。
|
|
61
|
+
|
|
62
|
+
Runtime 插件通过 `src/modern.runtime.ts` 中的 `plugins` 字段配置。
|
|
63
|
+
|
|
64
|
+
```ts title="src/modern.runtime.ts"
|
|
65
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
|
66
|
+
import { routerPlugin } from '@modern-js/runtime/router';
|
|
67
|
+
|
|
68
|
+
export default defineRuntimeConfig({
|
|
69
|
+
plugins: [routerPlugin()],
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Server 插件
|
|
74
|
+
|
|
75
|
+
Server 插件用于在应用接受请求时提供额外功能,例如添加中间件、修改请求响应等。
|
|
76
|
+
|
|
77
|
+
Server 插件通过 `server/modern.server.ts` 中的 `plugins` 字段进行配置。
|
|
78
|
+
|
|
79
|
+
```ts title="server/modern.server.ts"
|
|
80
|
+
import { defineServerConfig } from '@modern-js/server-runtime';
|
|
81
|
+
|
|
82
|
+
export default defineServerConfig({
|
|
83
|
+
plugins: [
|
|
84
|
+
{
|
|
85
|
+
name: 'custom-plugin-in-config',
|
|
86
|
+
setup: api => {
|
|
87
|
+
api.onPrepare(() => {
|
|
88
|
+
const { middlewares } = api.getServerContext();
|
|
89
|
+
|
|
90
|
+
middlewares?.push({
|
|
91
|
+
name: 'server-plugin-middleware',
|
|
92
|
+
handler: async (c, next) => {
|
|
93
|
+
c.res.headers.set('x-render-middleware-plugin', 'ok');
|
|
94
|
+
await next();
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 开发插件
|
|
105
|
+
|
|
106
|
+
如果你需要开发 Modern.js 框架插件,请阅读 [Modern.js 插件系统](/plugin/plugin-system) 获取更多信息。
|
|
107
|
+
|
|
108
|
+
## Rsbuild 构建插件
|
|
109
|
+
|
|
110
|
+
Rsbuild 是 Modern.js 底层的构建工具,通过添加 Rsbuild 插件可修改默认的构建行为,添加各类额外功能,包括但不限于:
|
|
111
|
+
|
|
112
|
+
- 修改 Rsbuild 配置
|
|
113
|
+
- 处理新的文件类型
|
|
114
|
+
- 修改或编译文件
|
|
115
|
+
- 部署产物
|
|
116
|
+
|
|
117
|
+
你可以在 `modern.config.ts` 中通过 `builderPlugins` 选项注册 Rsbuild 插件,详见 [builderPlugins 构建插件](/configure/app/builder-plugins.html)。
|
|
118
|
+
|
|
119
|
+
:::info
|
|
120
|
+
可以阅读 [Rsbuild 官网 - 插件](https://v2.rsbuild.rs/plugins/list/index) 了解更多 Rsbuild 插件体系内容。
|
|
121
|
+
:::
|
|
122
|
+
|
|
123
|
+
### 官方插件
|
|
124
|
+
|
|
125
|
+
#### 内置插件
|
|
126
|
+
|
|
127
|
+
以下为已在 Modern.js 中内置的 Rsbuild 官方插件,无需安装,即可启用:
|
|
128
|
+
|
|
129
|
+
| 插件 | 介绍 | Modern.js 链接 |
|
|
130
|
+
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
+
| [React 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-react) | 提供对 React 的支持 | - |
|
|
132
|
+
| [SVGR 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-svgr) | 支持将 SVG 图片转换为一个 React 组件 | [output.disableSvgr](/configure/app/output/disable-svgr)<br />[output.svgDefaultExport](/configure/app/output/svg-default-export) |
|
|
133
|
+
| [Assets Retry 插件](https://github.com/rstackjs/rsbuild-plugin-assets-retry) | 用于在静态资源加载失败时自动发起重试请求 | [output.assetsRetry](/configure/app/output/assets-retry.html) |
|
|
134
|
+
| [Type Check 插件](https://github.com/rspack-contrib/rsbuild-plugin-type-check) | 用于在单独的进程中运行 TypeScript 类型检查 | [output.disableTsChecker](/configure/app/output/disable-ts-checker.html)<br />[tools.tsChecker](/configure/app/tools/ts-checker.html) |
|
|
135
|
+
| [Source Build 插件](https://github.com/rspack-contrib/rsbuild-plugin-source-build) | 用于 monorepo 场景,支持引用其他子目录的源代码,并完成构建和热更新 | [experiments.sourceBuild](/configure/app/experiments/source-build.html) |
|
|
136
|
+
| [Check Syntax 插件](https://github.com/rspack-contrib/rsbuild-plugin-check-syntax) | 用于分析产物的语法兼容性,判断是否存在导致兼容性问题的高级语法 | [security.checkSyntax](/configure/app/security/check-syntax.html) |
|
|
137
|
+
| [CSS Minimizer 插件](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) | 用于自定义 CSS 压缩工具,切换到 [cssnano](https://cssnano.co/) 或其他工具进行 CSS 压缩 | [tools.minifyCss](/configure/app/tools/minify-css.html) |
|
|
138
|
+
| [Rem 插件](https://github.com/rspack-contrib/rsbuild-plugin-rem) | 用于实现移动端页面的 rem 自适应布局 | [output.convertToRem](/configure/app/output/convert-to-rem.html) |
|
|
139
|
+
|
|
140
|
+
#### 未内置的插件
|
|
141
|
+
|
|
142
|
+
以下是未在 Modern.js 中内置的 Rsbuild 官方插件:
|
|
143
|
+
|
|
144
|
+
- [Image Compress 插件](https://github.com/rspack-contrib/rsbuild-plugin-image-compress):将项目中用到的图片资源进行压缩处理。
|
|
145
|
+
- [Stylus 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-stylus):使用 Stylus 作为 CSS 预处理器。
|
|
146
|
+
- [UMD 插件](https://github.com/rspack-contrib/rsbuild-plugin-umd):用于构建 UMD 格式的产物。
|
|
147
|
+
- [YAML 插件](https://github.com/rspack-contrib/rsbuild-plugin-yaml):用于引用 YAML 文件,并将其转换为 JavaScript 对象。
|
|
148
|
+
- [TOML 插件](https://github.com/rspack-contrib/rsbuild-plugin-toml):用于引用 TOML 文件,并将其转换为 JavaScript 对象。
|
|
149
|
+
|
|
150
|
+
import OtherPlugins from '@site-docs/components/other-plugins.mdx';
|
|
151
|
+
|
|
152
|
+
<OtherPlugins />
|
|
153
|
+
````
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["plugin-bff", "plugin-ssg", "plugin-styled-components"]
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# 插件系统
|
|
2
|
+
|
|
3
|
+
Modern.js 采用高度可扩展的插件化架构,其核心功能和扩展能力均通过插件实现。插件系统不仅保证了框架的灵活性,也为开发者提供了强大的定制化手段。本文将重点介绍如何编写 Modern.js 插件,帮助您快速上手插件开发。
|
|
4
|
+
|
|
5
|
+
## 核心理念:一切皆插件
|
|
6
|
+
|
|
7
|
+
Modern.js 秉承“一切皆插件”的设计哲学,将框架的各项功能模块化,通过插件的形式进行组装和扩展。这种设计带来了诸多优势,包括:
|
|
8
|
+
|
|
9
|
+
- **高内聚,低耦合**:各功能模块独立开发、测试和维护,降低系统复杂度。
|
|
10
|
+
- **灵活可扩展**:用户可通过编写或组合插件,轻松定制框架行为,无需修改核心代码。
|
|
11
|
+
- **易于复用**:插件可跨项目共享,提高开发效率。
|
|
12
|
+
- **渐进式增强**:按需引入插件,无需一开始就承载所有功能的复杂性。
|
|
13
|
+
|
|
14
|
+
## 插件类型与适用场景
|
|
15
|
+
|
|
16
|
+
**CLI 插件**:
|
|
17
|
+
- **作用阶段**:构建时(执行 `modern` 命令时)。
|
|
18
|
+
- **典型场景**:
|
|
19
|
+
- 扩展命令行工具。
|
|
20
|
+
- 修改构建配置。
|
|
21
|
+
- 监听文件变化。
|
|
22
|
+
- 控制构建流程。
|
|
23
|
+
- **配置方式**:`modern.config.ts` 中的 `plugins` 字段。
|
|
24
|
+
|
|
25
|
+
**Runtime 插件**:
|
|
26
|
+
- **作用阶段**:应用运行时(浏览器/Node.js 环境)。
|
|
27
|
+
- **典型场景**:
|
|
28
|
+
- 初始化全局状态或服务。
|
|
29
|
+
- 封装 React 高阶组件(HOC)。
|
|
30
|
+
- 拦截或修改路由行为。
|
|
31
|
+
- 控制渲染流程。
|
|
32
|
+
- **配置方式**:`src/modern.runtime.ts` 中的 `plugins` 字段。
|
|
33
|
+
|
|
34
|
+
{/* **Server 插件**:
|
|
35
|
+
- **作用阶段**:服务端请求处理阶段。
|
|
36
|
+
- **典型场景**:
|
|
37
|
+
- 添加自定义中间件。
|
|
38
|
+
- 扩展服务端 API。
|
|
39
|
+
- 定制化 SSR 逻辑。
|
|
40
|
+
- 与后端框架集成。
|
|
41
|
+
- **配置方式**:`server/modern.server.ts` 中的 `plugins` 字段。 */}
|
|
42
|
+
|
|
43
|
+
## 插件结构
|
|
44
|
+
|
|
45
|
+
一个典型的 Modern.js 插件包含以下几个关键部分:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import type { Plugin } from '@modern-js/plugin';
|
|
49
|
+
|
|
50
|
+
const myPlugin: Plugin = {
|
|
51
|
+
name: 'my-awesome-plugin', // 插件的唯一标识符(必需)
|
|
52
|
+
|
|
53
|
+
// 插件依赖和执行顺序(可选)
|
|
54
|
+
pre: [], // 在此插件之前执行的插件名列表,默认为空数组
|
|
55
|
+
post: [], // 在此插件之后执行的插件名列表,默认为空数组
|
|
56
|
+
required: [], // 必需的插件列表,若依赖的插件未注册,则会报错,默认为空数组
|
|
57
|
+
usePlugins: [], // 内部使用的插件实例列表,默认为空数组
|
|
58
|
+
|
|
59
|
+
// 注册新的 Hook (可选)
|
|
60
|
+
registryHooks: {},
|
|
61
|
+
|
|
62
|
+
// 插件的入口函数(必需)
|
|
63
|
+
setup(api) {
|
|
64
|
+
// 插件的核心逻辑,通过 api 对象调用插件 API
|
|
65
|
+
api.modifyRspackConfig(config => {
|
|
66
|
+
/* ... */
|
|
67
|
+
});
|
|
68
|
+
api.onPrepare(() => {
|
|
69
|
+
/* ... */
|
|
70
|
+
});
|
|
71
|
+
// ... 其他 API 调用
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default myPlugin;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**字段说明:**
|
|
79
|
+
|
|
80
|
+
##### `name`
|
|
81
|
+
|
|
82
|
+
- 类型: `string`
|
|
83
|
+
- 说明:标识插件的名称。在插件体系中,该名称必须唯一,否则将导致插件加载失败。
|
|
84
|
+
|
|
85
|
+
:::info
|
|
86
|
+
后续 `pre`, `post`, `required` 中声明的插件名称都是这里的 name 字段.
|
|
87
|
+
:::
|
|
88
|
+
|
|
89
|
+
##### `setup`
|
|
90
|
+
|
|
91
|
+
- 类型: `(api: PluginAPI) => MaybePromise<void>`
|
|
92
|
+
- 说明:插件逻辑的主要入口。
|
|
93
|
+
|
|
94
|
+
###### `api`
|
|
95
|
+
|
|
96
|
+
- 类型: `PluginAPI`
|
|
97
|
+
- 说明:插件的 API,包含插件支持的 Hooks 和工具函数。
|
|
98
|
+
|
|
99
|
+
##### `pre`
|
|
100
|
+
|
|
101
|
+
- 类型: `string[]`
|
|
102
|
+
- 说明:用于插入插件执行顺序。在 `pre` 中声明的插件会在此插件之前执行。
|
|
103
|
+
|
|
104
|
+
##### `post`
|
|
105
|
+
|
|
106
|
+
- 类型: `string[]`
|
|
107
|
+
- 说明:用于确定插件执行顺序。在 `post` 中声明的插件会在此插件之后执行。
|
|
108
|
+
|
|
109
|
+
##### `required`
|
|
110
|
+
|
|
111
|
+
- 类型: `string[]`
|
|
112
|
+
- 说明:该插件依赖的其它插件。在运行前,会校验依赖的插件是否已注册。
|
|
113
|
+
|
|
114
|
+
:::info
|
|
115
|
+
如果在 `pre` 或 `post` 中配置了未注册的插件名,这些插件名将被**自动忽略**,不会影响其他插件的执行。
|
|
116
|
+
|
|
117
|
+
如果需要明确声明当前插件依赖的插件必须存在,需要使用 `required` 字段。
|
|
118
|
+
:::
|
|
119
|
+
|
|
120
|
+
##### `usePlugins`
|
|
121
|
+
|
|
122
|
+
- 类型: `Plugin`
|
|
123
|
+
- 说明:主动在插件中注册其他相同类型的插件。
|
|
124
|
+
|
|
125
|
+
:::info
|
|
126
|
+
`usePlugins` 中声明的插件默认在当前插件之前执行。需要在其后执行,请使用 `post` 声明。
|
|
127
|
+
:::
|
|
128
|
+
|
|
129
|
+
##### `registryHooks`
|
|
130
|
+
|
|
131
|
+
- 类型: `Record<string, PluginHook<(...args: any[]) => any>>`
|
|
132
|
+
- 说明:扩展当前支持的 Hook 函数,以实现自定义功能。
|
|
133
|
+
|
|
134
|
+
## 插件 Hook 模型
|
|
135
|
+
|
|
136
|
+
Modern.js 插件系统的核心是其 Hook 模型,它定义了插件之间的通信机制。Modern.js 主要提供两种 Hook 类型:
|
|
137
|
+
|
|
138
|
+
### Async Hook(异步 Hook)
|
|
139
|
+
|
|
140
|
+
- **特点**:
|
|
141
|
+
- Hook 函数异步执行,支持 `async/await`。
|
|
142
|
+
- 前一个 Hook 函数的返回值会作为下一个 Hook 函数的第一个参数。
|
|
143
|
+
- 最终返回最后一个 Hook 函数的返回值。
|
|
144
|
+
- **适用场景**:涉及异步操作的场景(如网络请求、文件读写等)。
|
|
145
|
+
- **创建方式**:使用 `createAsyncHook` 创建。
|
|
146
|
+
|
|
147
|
+
示例:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// 定义 Hooks
|
|
151
|
+
import { createAsyncHook } from '@modern-js/plugin';
|
|
152
|
+
|
|
153
|
+
export type AfterPrepareFn = () => Promise<void> | void;
|
|
154
|
+
export const onAfterPrepare = createAsyncHook<AfterPrepareFn>();
|
|
155
|
+
|
|
156
|
+
// 插件中注册 Hooks
|
|
157
|
+
const myPlugin = () => ({
|
|
158
|
+
name: 'my-plugin',
|
|
159
|
+
registryHooks: {
|
|
160
|
+
onAfterPrepare,
|
|
161
|
+
},
|
|
162
|
+
setup: api => {
|
|
163
|
+
api.onPrepare(async () => {
|
|
164
|
+
// 插件中使用注册的 Hooks
|
|
165
|
+
const hooks = api.getHooks();
|
|
166
|
+
await hooks.onAfterPrepare.call();
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// 在其他插件中使用 Hook
|
|
172
|
+
const myPlugin2 = () => ({
|
|
173
|
+
name: 'my-plugin-2',
|
|
174
|
+
setup: api => {
|
|
175
|
+
api.onAfterPrepare(async () => {
|
|
176
|
+
// TODO
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Sync Hook(同步 Hook)
|
|
183
|
+
|
|
184
|
+
- **特点**:
|
|
185
|
+
- Hook 函数同步执行。
|
|
186
|
+
- 前一个 Hook 函数的返回值会作为下一个 Hook 函数的第一个参数。
|
|
187
|
+
- 最终返回最后一个 Hook 函数的返回值。
|
|
188
|
+
- **适用场景**:需要同步修改数据的场景(如修改配置、路由等)。
|
|
189
|
+
- **创建方式**:使用 `createSyncHook` 创建。
|
|
190
|
+
|
|
191
|
+
示例:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
// 定义 Hooks
|
|
195
|
+
import { createSyncHook } from '@modern-js/plugin';
|
|
196
|
+
|
|
197
|
+
type RouteObject = {
|
|
198
|
+
/** TODO **/
|
|
199
|
+
};
|
|
200
|
+
const modifyRoutes = createSyncHook<(routes: RouteObject[]) => RouteObject[]>();
|
|
201
|
+
|
|
202
|
+
// 插件中注册 Hooks
|
|
203
|
+
const myPlugin = () => ({
|
|
204
|
+
name: 'my-plugin',
|
|
205
|
+
registryHooks: {
|
|
206
|
+
modifyRoutes,
|
|
207
|
+
},
|
|
208
|
+
setup: api => {
|
|
209
|
+
api.onPrepare(async () => {
|
|
210
|
+
const routes = {};
|
|
211
|
+
// 在插件中使用注册的 Hooks
|
|
212
|
+
const hooks = api.getHooks();
|
|
213
|
+
const routesResult = hooks.modifyRoutes.call(routes);
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 插件开发最佳实践
|
|
220
|
+
|
|
221
|
+
- **单一职责**: 每个插件应该专注于实现一个特定的、内聚的功能。避免创建功能庞杂、职责不清的插件。
|
|
222
|
+
- **命名规范**: 插件名称应清晰、简洁, 并遵循一定的命名约定 (如 `plugin-xxx` 或 `@scope/plugin-xxx`).
|
|
223
|
+
- **类型安全**: 充分利用 TypeScript 的类型系统, 确保插件 API 的类型安全, 减少运行时错误。
|
|
224
|
+
- **文档完善**: 为插件编写清晰的文档, 包括 API 说明、使用示例、配置项解释以及变更日志。
|
|
225
|
+
- **测试充分**: 对插件进行单元测试和集成测试, 确保其稳定性、可靠性以及在各种场景下的兼容性。
|
|
226
|
+
- **减少副作用**: 插件应该尽可能地减少对外部环境的修改 (如全局变量、文件系统等), 保持插件的独立性和可移植性。
|
|
227
|
+
- **错误处理**: 插件内部应该妥善处理可能出现的错误, 避免因为插件的异常导致整个应用崩溃。
|
|
228
|
+
- **性能优化**: 注意插件的性能影响, 避免不必要的计算和资源消耗, 特别是在循环或频繁调用的 Hook 中。
|
|
229
|
+
- **版本控制**: 遵循语义化版本控制 (Semantic Versioning), 确保插件的向后兼容性, 方便用户升级。
|
|
230
|
+
|
|
231
|
+
遵循这些最佳实践, 可以帮助您开发出高质量、易维护、易使用的 Modern.js 插件。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["api", "life-cycle"]
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# 插件 API
|
|
2
|
+
|
|
3
|
+
Modern.js 的 Runtime 插件允许您在应用程序的 React 代码运行时扩展和修改其行为。通过 Runtime 插件,您可以轻松地执行初始化任务、实现 React 高阶组件(HOC)封装等功能。
|
|
4
|
+
|
|
5
|
+
:::info
|
|
6
|
+
|
|
7
|
+
Runtime 插件需要通过 `src/modern.runtime.ts` 中的 [`plugins`](/configure/app/runtime/plugins) 字段配置。
|
|
8
|
+
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
## 插件结构
|
|
12
|
+
|
|
13
|
+
一个典型的 Runtime 插件如下所示:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { RuntimePlugin } from '@modern-js/runtime';
|
|
17
|
+
|
|
18
|
+
const myRuntimePlugin = (): RuntimePlugin => ({
|
|
19
|
+
name: 'my-runtime-plugin',
|
|
20
|
+
setup: api => {
|
|
21
|
+
// 使用 api 注册钩子
|
|
22
|
+
api.onBeforeRender(context => {
|
|
23
|
+
console.log('Before rendering:', context);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
api.wrapRoot(App => {
|
|
27
|
+
return props => (
|
|
28
|
+
<MyContextProvider>
|
|
29
|
+
<App {...props} />
|
|
30
|
+
</MyContextProvider>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default myRuntimePlugin;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `name`: 插件的唯一标识符。
|
|
40
|
+
- `setup`: 函数接收一个 `api` 对象,该对象提供了所有可用的 Runtime 插件 API。
|
|
41
|
+
|
|
42
|
+
## API 概览
|
|
43
|
+
|
|
44
|
+
Runtime 插件 API 主要分为以下几类:
|
|
45
|
+
|
|
46
|
+
- **信息获取**:获取运行时配置和钩子函数。
|
|
47
|
+
- **生命周期钩子**:在应用渲染的不同阶段执行自定义逻辑。
|
|
48
|
+
|
|
49
|
+
### 信息获取
|
|
50
|
+
|
|
51
|
+
#### `api.getRuntimeConfig`
|
|
52
|
+
|
|
53
|
+
获取用户在 `modern.runtime.ts` 文件中定义的运行时配置。
|
|
54
|
+
|
|
55
|
+
- **用法**:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const config = api.getRuntimeConfig();
|
|
59
|
+
console.log(config.myCustomSetting);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
:::warning
|
|
63
|
+
|
|
64
|
+
此方法返回的是用户配置的副本,修改返回值不会影响原始配置。
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
#### `api.getHooks`
|
|
68
|
+
|
|
69
|
+
获取可用于手动触发的钩子函数。
|
|
70
|
+
|
|
71
|
+
- **类型:**
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
() => {
|
|
75
|
+
onBeforeRender: {
|
|
76
|
+
call: (context: any) => Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
// 其他钩子...
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- **用法:**
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const hooks = api.getHooks();
|
|
86
|
+
await hooks.onBeforeRender.call(myContext);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 生命周期钩子
|
|
90
|
+
|
|
91
|
+
#### `api.onBeforeRender`
|
|
92
|
+
|
|
93
|
+
在应用渲染(包括服务器端渲染和客户端渲染)之前执行。您可以在此钩子中执行数据预取、修改渲染上下文等操作。
|
|
94
|
+
|
|
95
|
+
- **类型:**
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
type OnBeforeRenderFn<RuntimeContext> = (
|
|
99
|
+
context: RuntimeContext,
|
|
100
|
+
) => Promise<void> | void;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`RuntimeContext` 包含当前请求的上下文信息,如请求对象、响应对象等。
|
|
104
|
+
|
|
105
|
+
- **用法:**
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
api.onBeforeRender(async context => {
|
|
109
|
+
const data = await fetchData(context.req);
|
|
110
|
+
context.data = data; // 将数据添加到上下文中
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
:::warning
|
|
115
|
+
|
|
116
|
+
- 此钩子在每次渲染前都会执行,因此应避免执行耗时过长的操作。
|
|
117
|
+
- 您可以在此钩子中修改 `context` 对象,并将修改后的 `context` 传递给后续的渲染过程。
|
|
118
|
+
|
|
119
|
+
:::
|
|
120
|
+
|
|
121
|
+
#### `api.wrapRoot`
|
|
122
|
+
|
|
123
|
+
允许您使用自定义的 React 组件包裹应用的根组件。常用于添加全局的 Provider、布局组件等。
|
|
124
|
+
|
|
125
|
+
- **类型:**
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
type WrapRootFn = (App: React.ComponentType<any>) => React.ComponentType<any>;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- **用法:**
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
api.wrapRoot(App => {
|
|
135
|
+
const AppWrapper = props => {
|
|
136
|
+
return (
|
|
137
|
+
<MyGlobalProvider>
|
|
138
|
+
<Layout>
|
|
139
|
+
<App {...props} /> {/* 确保传递 props */}
|
|
140
|
+
</Layout>
|
|
141
|
+
</MyGlobalProvider>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
return AppWrapper;
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
:::warning
|
|
149
|
+
|
|
150
|
+
- **务必将 `props` 传递给原始的 `App` 组件**,否则可能导致应用无法正常工作。
|
|
151
|
+
- `wrapRoot` 返回的组件会在每次渲染时重新创建,因此应避免在其中定义复杂的逻辑或状态。
|
|
152
|
+
|
|
153
|
+
:::
|
|
154
|
+
|
|
155
|
+
## 进阶用法
|
|
156
|
+
|
|
157
|
+
### 组合使用钩子
|
|
158
|
+
|
|
159
|
+
您可以组合使用多个钩子来实现更复杂的功能。例如,您可以使用 `onBeforeRender` 获取数据,然后使用 `wrapRoot` 将数据通过 Context 传递给整个应用:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { RuntimePlugin, RuntimeContext } from '@modern-js/runtime';
|
|
163
|
+
import { useContext, createContext } from 'react';
|
|
164
|
+
|
|
165
|
+
export const ThemeContext = createContext<{ theme: string } | null>(null);
|
|
166
|
+
|
|
167
|
+
export const themePlugin = (): RuntimePlugin => {
|
|
168
|
+
return {
|
|
169
|
+
name: 'theme-plugin',
|
|
170
|
+
setup: api => {
|
|
171
|
+
api.onBeforeRender(async context => {
|
|
172
|
+
const userPreference = await fetch('/api/user/theme-settings').then(
|
|
173
|
+
res => res.json(),
|
|
174
|
+
);
|
|
175
|
+
context.data = {
|
|
176
|
+
theme: userPreference.theme,
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
api.wrapRoot(App => {
|
|
181
|
+
return props => {
|
|
182
|
+
const context = useContext(RuntimeContext);
|
|
183
|
+
return (
|
|
184
|
+
<ThemeContext.Provider value={context.data}>
|
|
185
|
+
<App {...props} />
|
|
186
|
+
</ThemeContext.Provider>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 生命周期
|
|
2
|
+
|
|
3
|
+
import Mermaid from '@site/src/components/Mermaid';
|
|
4
|
+
|
|
5
|
+
<Mermaid>
|
|
6
|
+
{`
|
|
7
|
+
flowchart TD
|
|
8
|
+
init{{"Runtime 初始化"}}
|
|
9
|
+
load_config(加载用户配置文件)
|
|
10
|
+
runtime_plugin(加载 Runtime 插件<br><sub>配置文件中注册的插件<br>CLI 插件注册的 Runtime 插件<br>插件中使用的插件</sub>)
|
|
11
|
+
registry_hooks(注册 Hooks 函数<br><sub>执行插件 setup 函数,注册插件中定义的 Hook, 插件 setup 中逻辑也会在这里执行</sub>)
|
|
12
|
+
|
|
13
|
+
wrapRoot(wrapRoot<br><sub>wrapRoot 中返回组件中的逻辑会在组件渲染时执行</sub>)
|
|
14
|
+
onBeforeRender(onBeforeRender)
|
|
15
|
+
|
|
16
|
+
init --> load_config
|
|
17
|
+
load_config --> runtime_plugin
|
|
18
|
+
runtime_plugin --> registry_hooks
|
|
19
|
+
registry_hooks --> wrapRoot
|
|
20
|
+
wrapRoot --> onBeforeRender
|
|
21
|
+
|
|
22
|
+
style init fill:#FDE68A,font-size:10px;
|
|
23
|
+
style load_config stroke-dasharray:5 5,fill:#86EFAC,font-size:10px;
|
|
24
|
+
style runtime_plugin stroke-dasharray:5 5,fill:#86EFAC,font-size:10px;
|
|
25
|
+
style registry_hooks stroke-dasharray:5 5,fill:#9CA3AF,font-size:10px;
|
|
26
|
+
style wrapRoot font-size:10px;
|
|
27
|
+
style onBeforeRender font-size:10px;
|
|
28
|
+
`}
|
|
29
|
+
</Mermaid>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["api", "life-cycle"]
|