@modern-js/main-doc 2.59.0 → 2.60.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/_meta.json +10 -5
- package/docs/en/apis/app/hooks/api/lambda.mdx +4 -48
- package/docs/en/apis/app/hooks/api/middleware.mdx +11 -0
- package/docs/en/community/blog/v2-release-note.mdx +1 -1
- package/docs/en/community/contributing-guide.mdx +0 -1
- package/docs/en/components/builder.mdx +3 -0
- package/docs/en/components/bundler.mdx +3 -0
- package/docs/en/components/enable-bff.mdx +19 -2
- package/docs/en/components/enableSwc.mdx +17 -0
- package/docs/en/components/esbuild.mdx +3 -0
- package/docs/en/components/extend-bff-function.mdx +5 -0
- package/docs/en/components/micro-frontend.mdx +6 -0
- package/docs/en/components/module-federation.mdx +7 -0
- package/docs/en/components/nodeVersion.mdx +26 -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-polyfill-extend.mdx +0 -0
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/en/components/rsbuild.mdx +3 -0
- package/docs/en/components/rspack.mdx +3 -0
- package/docs/en/components/rspackPrecautions.mdx +6 -0
- package/docs/en/components/rspackTip.mdx +7 -0
- package/docs/en/components/swc.mdx +3 -0
- package/docs/en/configure/app/auto-load-plugin.mdx +4 -0
- package/docs/en/configure/app/dev/asset-prefix.mdx +12 -2
- package/docs/en/configure/app/dev/before-start-url.mdx +14 -2
- package/docs/en/configure/app/dev/client.mdx +20 -16
- package/docs/en/configure/app/dev/hmr.mdx +8 -2
- package/docs/en/configure/app/dev/host.mdx +15 -2
- package/docs/en/configure/app/dev/https.mdx +71 -2
- package/docs/en/configure/app/dev/live-reload.mdx +3 -15
- package/docs/en/configure/app/dev/port.mdx +18 -2
- package/docs/en/configure/app/dev/progress-bar.mdx +17 -2
- package/docs/en/configure/app/dev/setup-middlewares.mdx +25 -39
- package/docs/en/configure/app/dev/start-url.mdx +46 -2
- package/docs/en/configure/app/dev/watch-files.mdx +5 -39
- package/docs/en/configure/app/dev/write-to-disk.mdx +4 -27
- package/docs/en/configure/app/experiments/lazy-compilation.mdx +84 -2
- package/docs/en/configure/app/experiments/source-build.mdx +28 -3
- package/docs/en/configure/app/html/app-icon.mdx +48 -2
- package/docs/en/configure/app/html/crossorigin.mdx +8 -2
- package/docs/en/configure/app/html/disable-html-folder.mdx +35 -2
- package/docs/en/configure/app/html/favicon-by-entries.mdx +29 -2
- package/docs/en/configure/app/html/favicon.mdx +14 -2
- package/docs/en/configure/app/html/inject-by-entries.mdx +29 -2
- package/docs/en/configure/app/html/inject.mdx +8 -2
- package/docs/en/configure/app/html/meta-by-entries.mdx +41 -2
- package/docs/en/configure/app/html/meta.mdx +22 -2
- package/docs/en/configure/app/html/mount-id.mdx +8 -2
- package/docs/en/configure/app/html/script-loading.mdx +8 -2
- package/docs/en/configure/app/html/tags-by-entries.mdx +37 -2
- package/docs/en/configure/app/html/tags.mdx +13 -2
- package/docs/en/configure/app/html/template-by-entries.mdx +26 -2
- package/docs/en/configure/app/html/template-parameters-by-entries.mdx +28 -2
- package/docs/en/configure/app/html/template-parameters.mdx +31 -2
- package/docs/en/configure/app/html/template.mdx +8 -2
- package/docs/en/configure/app/html/title-by-entries.mdx +30 -2
- package/docs/en/configure/app/html/title.mdx +16 -2
- package/docs/en/configure/app/output/asset-prefix.mdx +12 -2
- package/docs/en/configure/app/output/assets-retry.mdx +72 -2
- package/docs/en/configure/app/output/charset.mdx +8 -2
- package/docs/en/configure/app/output/clean-dist-path.mdx +13 -2
- package/docs/en/configure/app/output/convert-to-rem.mdx +76 -2
- package/docs/en/configure/app/output/copy.mdx +5 -2
- package/docs/en/configure/app/output/css-module-local-ident-name.mdx +14 -2
- package/docs/en/configure/app/output/css-modules.mdx +46 -2
- package/docs/en/configure/app/output/data-uri-limit.mdx +24 -2
- package/docs/en/configure/app/output/disable-css-extract.mdx +9 -2
- package/docs/en/configure/app/output/disable-css-module-extension.mdx +52 -2
- package/docs/en/configure/app/output/disable-filename-hash.mdx +9 -2
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +38 -2
- package/docs/en/configure/app/output/disable-minimize.mdx +7 -2
- package/docs/en/configure/app/output/disable-source-map.mdx +24 -2
- package/docs/en/configure/app/output/disable-svgr.mdx +13 -2
- package/docs/en/configure/app/output/disable-ts-checker.mdx +46 -2
- package/docs/en/configure/app/output/dist-path.mdx +39 -2
- package/docs/en/configure/app/output/enable-asset-fallback.mdx +29 -2
- package/docs/en/configure/app/output/enable-asset-manifest.mdx +33 -2
- package/docs/en/configure/app/output/enable-css-module-tsdeclaration.mdx +25 -2
- package/docs/en/configure/app/output/enable-inline-scripts.mdx +15 -2
- package/docs/en/configure/app/output/enable-inline-styles.mdx +15 -2
- package/docs/en/configure/app/output/enable-latest-decorators.mdx +7 -2
- package/docs/en/configure/app/output/externals.mdx +18 -2
- package/docs/en/configure/app/output/filename-hash.mdx +3 -27
- package/docs/en/configure/app/output/filename.mdx +47 -2
- package/docs/en/configure/app/output/inject-styles.mdx +15 -0
- package/docs/en/configure/app/output/inline-scripts.mdx +34 -0
- package/docs/en/configure/app/output/inline-styles.mdx +34 -0
- package/docs/en/configure/app/output/legal-comments.mdx +16 -2
- package/docs/en/configure/app/output/minify.mdx +27 -0
- package/docs/en/configure/app/output/override-browserslist.mdx +18 -2
- package/docs/en/configure/app/output/polyfill.mdx +12 -2
- package/docs/en/configure/app/output/source-map.mdx +30 -0
- package/docs/en/configure/app/output/ssg.mdx +20 -17
- package/docs/en/configure/app/output/svg-default-export.mdx +27 -2
- package/docs/en/configure/app/performance/build-cache.mdx +78 -2
- package/docs/en/configure/app/performance/bundle-analyze.mdx +18 -2
- package/docs/en/configure/app/performance/chunk-split.mdx +38 -2
- package/docs/en/configure/app/performance/dns-prefetch.mdx +13 -2
- package/docs/en/configure/app/performance/preconnect.mdx +14 -2
- package/docs/en/configure/app/performance/prefetch.mdx +19 -2
- package/docs/en/configure/app/performance/preload.mdx +21 -2
- package/docs/en/configure/app/performance/print-file-size.mdx +38 -2
- package/docs/en/configure/app/performance/profile.mdx +8 -2
- package/docs/en/configure/app/performance/remove-console.mdx +8 -2
- package/docs/en/configure/app/performance/remove-moment-locale.mdx +8 -2
- package/docs/en/configure/app/performance/transform-lodash.mdx +42 -2
- package/docs/en/configure/app/plugins.mdx +3 -3
- package/docs/en/configure/app/security/check-syntax.mdx +66 -2
- package/docs/en/configure/app/security/nonce.mdx +13 -2
- package/docs/en/configure/app/security/sri.mdx +19 -2
- package/docs/en/configure/app/server/port.mdx +5 -0
- package/docs/en/configure/app/server/ssr.mdx +10 -9
- package/docs/en/configure/app/source/alias-strategy.mdx +8 -2
- package/docs/en/configure/app/source/alias.mdx +17 -2
- package/docs/en/configure/app/source/config-dir.mdx +1 -1
- package/docs/en/configure/app/source/decorators.mdx +8 -21
- package/docs/en/configure/app/source/define.mdx +14 -2
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/entries-dir.mdx +1 -1
- package/docs/en/configure/app/source/exclude.mdx +8 -2
- package/docs/en/configure/app/source/global-vars.mdx +103 -2
- package/docs/en/configure/app/source/include.mdx +19 -2
- package/docs/en/configure/app/source/mainEntryName.mdx +1 -1
- package/docs/en/configure/app/source/module-scopes.mdx +62 -2
- package/docs/en/configure/app/source/pre-entry.mdx +8 -2
- package/docs/en/configure/app/source/resolve-extension-prefix.mdx +48 -2
- package/docs/en/configure/app/source/resolve-main-fields.mdx +39 -2
- package/docs/en/configure/app/source/transform-import.mdx +56 -2
- package/docs/en/configure/app/tools/autoprefixer.mdx +41 -2
- package/docs/en/configure/app/tools/babel.mdx +218 -2
- package/docs/en/configure/app/tools/bundler-chain.mdx +23 -2
- package/docs/en/configure/app/tools/css-extract.mdx +31 -2
- package/docs/en/configure/app/tools/css-loader.mdx +14 -2
- package/docs/en/configure/app/tools/dev-server.mdx +435 -2
- package/docs/en/configure/app/tools/esbuild.mdx +2 -2
- package/docs/en/configure/app/tools/html-plugin.mdx +21 -2
- package/docs/en/configure/app/tools/less.mdx +78 -2
- package/docs/en/configure/app/tools/minify-css.mdx +50 -2
- package/docs/en/configure/app/tools/postcss.mdx +30 -2
- package/docs/en/configure/app/tools/pug.mdx +47 -2
- package/docs/en/configure/app/tools/rspack.mdx +8 -2
- package/docs/en/configure/app/tools/sass.mdx +75 -2
- package/docs/en/configure/app/tools/style-loader.mdx +8 -2
- package/docs/en/configure/app/tools/styled-components.mdx +48 -2
- package/docs/en/configure/app/tools/swc.mdx +34 -3
- package/docs/en/configure/app/tools/terser.mdx +49 -2
- package/docs/en/configure/app/tools/ts-checker.mdx +49 -2
- package/docs/en/configure/app/tools/ts-loader.mdx +63 -2
- package/docs/en/configure/app/tools/webpack-chain.mdx +239 -2
- package/docs/en/configure/app/tools/webpack.mdx +295 -2
- package/docs/en/guides/_meta.json +0 -5
- package/docs/en/guides/advanced-features/_meta.json +7 -5
- package/docs/en/guides/advanced-features/bff/_meta.json +1 -1
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +154 -0
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +52 -123
- package/docs/en/guides/advanced-features/bff/function.mdx +108 -80
- package/docs/en/guides/advanced-features/bff/sdk.mdx +40 -51
- package/docs/en/guides/advanced-features/build-performance.mdx +6 -21
- package/docs/en/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/en/guides/advanced-features/rspack-start.mdx +2 -2
- package/docs/en/guides/basic-features/css/css-modules.mdx +2 -2
- package/docs/en/guides/basic-features/output-files.mdx +1 -1
- package/docs/en/guides/basic-features/render/ssg.mdx +1 -1
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +1 -1
- package/docs/en/guides/basic-features/routes.mdx +2 -3
- package/docs/en/guides/basic-features/static-assets.mdx +1 -1
- package/docs/en/guides/concept/builder.mdx +1 -1
- package/docs/en/guides/deprecated.md +2 -0
- package/docs/en/guides/get-started/glossary.mdx +7 -7
- package/docs/en/guides/get-started/quick-start.mdx +1 -1
- package/docs/en/guides/topic-detail/_meta.json +0 -6
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -1
- package/docs/en/guides/troubleshooting/builder.mdx +2 -2
- package/docs/en/plugin/_meta.json +19 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -0
- package/docs/en/plugin/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/en/plugin/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/en/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +11 -4
- package/docs/en/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
- package/docs/en/plugin/cli-plugins.mdx +6 -0
- package/docs/en/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +34 -9
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
- package/docs/en/plugin/rsbuild-plugins/_meta.json +1 -0
- package/docs/en/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +4 -4
- package/docs/en/plugin/rsbuild-plugins.mdx +3 -0
- package/docs/zh/_meta.json +10 -5
- package/docs/zh/apis/app/hooks/api/lambda.mdx +5 -48
- package/docs/zh/apis/app/hooks/api/middleware.mdx +11 -0
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/community/contributing-guide.mdx +0 -1
- package/docs/zh/components/builder.mdx +3 -0
- package/docs/zh/components/bundler.mdx +4 -0
- package/docs/zh/components/enable-bff.mdx +19 -2
- package/docs/zh/components/enableSwc.mdx +17 -0
- package/docs/zh/components/esbuild.mdx +3 -0
- package/docs/zh/components/extend-bff-function.mdx +5 -0
- package/docs/zh/components/micro-frontend.mdx +6 -0
- package/docs/zh/components/module-federation.mdx +7 -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-polyfill-extend.mdx +0 -0
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/zh/components/rsbuild.mdx +3 -0
- package/docs/zh/components/rspack.mdx +3 -0
- package/docs/zh/components/rspackPrecautions.mdx +6 -0
- package/docs/zh/components/rspackTip.mdx +7 -0
- package/docs/zh/components/swc.mdx +3 -0
- package/docs/zh/configure/app/auto-load-plugin.mdx +4 -0
- package/docs/zh/configure/app/dev/asset-prefix.mdx +12 -2
- package/docs/zh/configure/app/dev/before-start-url.mdx +14 -2
- package/docs/zh/configure/app/dev/client.mdx +20 -16
- package/docs/zh/configure/app/dev/hmr.mdx +8 -2
- package/docs/zh/configure/app/dev/host.mdx +15 -2
- package/docs/zh/configure/app/dev/https.mdx +72 -2
- package/docs/zh/configure/app/dev/live-reload.mdx +3 -15
- package/docs/zh/configure/app/dev/port.mdx +18 -2
- package/docs/zh/configure/app/dev/progress-bar.mdx +17 -2
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +26 -39
- package/docs/zh/configure/app/dev/start-url.mdx +47 -2
- package/docs/zh/configure/app/dev/watch-files.mdx +5 -39
- package/docs/zh/configure/app/dev/write-to-disk.mdx +3 -26
- package/docs/zh/configure/app/experiments/lazy-compilation.mdx +84 -2
- package/docs/zh/configure/app/experiments/source-build.mdx +29 -2
- package/docs/zh/configure/app/html/app-icon.mdx +48 -2
- package/docs/zh/configure/app/html/crossorigin.mdx +9 -2
- package/docs/zh/configure/app/html/disable-html-folder.mdx +34 -2
- package/docs/zh/configure/app/html/favicon-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/favicon.mdx +15 -2
- package/docs/zh/configure/app/html/inject-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/inject.mdx +8 -2
- package/docs/zh/configure/app/html/meta-by-entries.mdx +41 -2
- package/docs/zh/configure/app/html/meta.mdx +22 -2
- package/docs/zh/configure/app/html/mount-id.mdx +8 -2
- package/docs/zh/configure/app/html/script-loading.mdx +8 -2
- package/docs/zh/configure/app/html/tags-by-entries.mdx +37 -2
- package/docs/zh/configure/app/html/tags.mdx +13 -2
- package/docs/zh/configure/app/html/template-by-entries.mdx +26 -2
- package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +29 -2
- package/docs/zh/configure/app/html/template-parameters.mdx +31 -2
- package/docs/zh/configure/app/html/template.mdx +8 -2
- package/docs/zh/configure/app/html/title-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/title.mdx +16 -2
- package/docs/zh/configure/app/output/asset-prefix.mdx +12 -2
- package/docs/zh/configure/app/output/assets-retry.mdx +72 -2
- package/docs/zh/configure/app/output/charset.mdx +8 -2
- package/docs/zh/configure/app/output/clean-dist-path.mdx +13 -2
- package/docs/zh/configure/app/output/convert-to-rem.mdx +77 -2
- package/docs/zh/configure/app/output/copy.mdx +6 -2
- package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +14 -2
- package/docs/zh/configure/app/output/css-modules.mdx +46 -2
- package/docs/zh/configure/app/output/data-uri-limit.mdx +24 -2
- package/docs/zh/configure/app/output/disable-css-extract.mdx +9 -2
- package/docs/zh/configure/app/output/disable-css-module-extension.mdx +52 -2
- package/docs/zh/configure/app/output/disable-filename-hash.mdx +9 -2
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +38 -2
- package/docs/zh/configure/app/output/disable-minimize.mdx +7 -2
- package/docs/zh/configure/app/output/disable-source-map.mdx +24 -2
- package/docs/zh/configure/app/output/disable-svgr.mdx +14 -2
- package/docs/zh/configure/app/output/disable-ts-checker.mdx +46 -2
- package/docs/zh/configure/app/output/dist-path.mdx +39 -2
- package/docs/zh/configure/app/output/enable-asset-fallback.mdx +29 -2
- package/docs/zh/configure/app/output/enable-asset-manifest.mdx +33 -2
- package/docs/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +25 -2
- package/docs/zh/configure/app/output/enable-inline-scripts.mdx +15 -2
- package/docs/zh/configure/app/output/enable-inline-styles.mdx +15 -2
- package/docs/zh/configure/app/output/enable-latest-decorators.mdx +7 -2
- package/docs/zh/configure/app/output/externals.mdx +18 -2
- package/docs/zh/configure/app/output/filename-hash.mdx +4 -27
- package/docs/zh/configure/app/output/filename.mdx +47 -2
- package/docs/zh/configure/app/output/inject-styles.mdx +15 -0
- package/docs/zh/configure/app/output/inline-scripts.mdx +34 -0
- package/docs/zh/configure/app/output/inline-styles.mdx +34 -0
- package/docs/zh/configure/app/output/legal-comments.mdx +16 -2
- package/docs/zh/configure/app/output/minify.mdx +27 -0
- package/docs/zh/configure/app/output/override-browserslist.mdx +20 -2
- package/docs/zh/configure/app/output/polyfill.mdx +12 -2
- package/docs/zh/configure/app/output/source-map.mdx +30 -0
- package/docs/zh/configure/app/output/ssg.mdx +19 -15
- package/docs/zh/configure/app/output/svg-default-export.mdx +27 -2
- package/docs/zh/configure/app/performance/build-cache.mdx +77 -2
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +18 -2
- package/docs/zh/configure/app/performance/chunk-split.mdx +38 -2
- package/docs/zh/configure/app/performance/dns-prefetch.mdx +13 -2
- package/docs/zh/configure/app/performance/preconnect.mdx +14 -2
- package/docs/zh/configure/app/performance/prefetch.mdx +19 -2
- package/docs/zh/configure/app/performance/preload.mdx +21 -2
- package/docs/zh/configure/app/performance/print-file-size.mdx +38 -2
- package/docs/zh/configure/app/performance/profile.mdx +8 -2
- package/docs/zh/configure/app/performance/remove-console.mdx +8 -2
- package/docs/zh/configure/app/performance/remove-moment-locale.mdx +8 -2
- package/docs/zh/configure/app/performance/transform-lodash.mdx +42 -2
- package/docs/zh/configure/app/plugins.mdx +3 -3
- package/docs/zh/configure/app/security/check-syntax.mdx +66 -2
- package/docs/zh/configure/app/security/nonce.mdx +13 -2
- package/docs/zh/configure/app/security/sri.mdx +19 -2
- package/docs/zh/configure/app/server/port.mdx +5 -0
- package/docs/zh/configure/app/server/ssr.mdx +10 -9
- package/docs/zh/configure/app/source/alias-strategy.mdx +8 -2
- package/docs/zh/configure/app/source/alias.mdx +17 -2
- package/docs/zh/configure/app/source/config-dir.mdx +1 -1
- package/docs/zh/configure/app/source/decorators.mdx +8 -20
- package/docs/zh/configure/app/source/define.mdx +14 -2
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/configure/app/source/entries-dir.mdx +1 -1
- package/docs/zh/configure/app/source/exclude.mdx +8 -2
- package/docs/zh/configure/app/source/global-vars.mdx +102 -2
- package/docs/zh/configure/app/source/include.mdx +19 -2
- package/docs/zh/configure/app/source/mainEntryName.mdx +1 -1
- package/docs/zh/configure/app/source/module-scopes.mdx +62 -2
- package/docs/zh/configure/app/source/pre-entry.mdx +8 -2
- package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +50 -2
- package/docs/zh/configure/app/source/resolve-main-fields.mdx +39 -2
- package/docs/zh/configure/app/source/transform-import.mdx +56 -2
- package/docs/zh/configure/app/tools/autoprefixer.mdx +41 -2
- package/docs/zh/configure/app/tools/babel.mdx +218 -2
- package/docs/zh/configure/app/tools/bundler-chain.mdx +26 -2
- package/docs/zh/configure/app/tools/css-extract.mdx +28 -2
- package/docs/zh/configure/app/tools/css-loader.mdx +15 -2
- package/docs/zh/configure/app/tools/dev-server.mdx +435 -2
- package/docs/zh/configure/app/tools/esbuild.mdx +2 -2
- package/docs/zh/configure/app/tools/html-plugin.mdx +21 -2
- package/docs/zh/configure/app/tools/less.mdx +79 -2
- package/docs/zh/configure/app/tools/minify-css.mdx +50 -2
- package/docs/zh/configure/app/tools/postcss.mdx +31 -2
- package/docs/zh/configure/app/tools/pug.mdx +47 -2
- package/docs/zh/configure/app/tools/rspack.mdx +8 -2
- package/docs/zh/configure/app/tools/sass.mdx +73 -2
- package/docs/zh/configure/app/tools/style-loader.mdx +8 -2
- package/docs/zh/configure/app/tools/styled-components.mdx +47 -2
- package/docs/zh/configure/app/tools/swc.mdx +34 -3
- package/docs/zh/configure/app/tools/terser.mdx +49 -2
- package/docs/zh/configure/app/tools/ts-checker.mdx +49 -2
- package/docs/zh/configure/app/tools/ts-loader.mdx +63 -2
- package/docs/zh/configure/app/tools/webpack-chain.mdx +243 -2
- package/docs/zh/configure/app/tools/webpack.mdx +295 -2
- package/docs/zh/guides/_meta.json +0 -5
- package/docs/zh/guides/advanced-features/_meta.json +7 -5
- package/docs/zh/guides/advanced-features/bff/_meta.json +1 -1
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +156 -0
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +51 -117
- package/docs/zh/guides/advanced-features/bff/function.mdx +69 -59
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +27 -36
- package/docs/zh/guides/advanced-features/build-performance.mdx +6 -21
- package/docs/zh/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/zh/guides/advanced-features/rspack-start.mdx +4 -4
- package/docs/zh/guides/basic-features/alias.mdx +5 -11
- package/docs/zh/guides/basic-features/css/css-modules.mdx +1 -1
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/output-files.mdx +2 -2
- package/docs/zh/guides/basic-features/routes.mdx +1 -2
- package/docs/zh/guides/basic-features/static-assets.mdx +1 -1
- package/docs/zh/guides/concept/builder.mdx +1 -1
- package/docs/zh/guides/deprecated.md +4 -0
- package/docs/zh/guides/get-started/glossary.mdx +7 -7
- package/docs/zh/guides/get-started/quick-start.mdx +1 -1
- package/docs/zh/guides/topic-detail/_meta.json +0 -6
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -1
- package/docs/zh/guides/troubleshooting/builder.mdx +2 -2
- package/docs/zh/plugin/_meta.json +19 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -0
- package/docs/zh/plugin/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/zh/plugin/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/zh/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +11 -4
- package/docs/zh/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
- package/docs/zh/plugin/cli-plugins.mdx +6 -0
- package/docs/zh/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +36 -11
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
- package/docs/zh/plugin/rsbuild-plugins/_meta.json +1 -0
- package/docs/zh/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +6 -6
- package/docs/zh/plugin/rsbuild-plugins.mdx +4 -0
- package/i18n.json +27 -3
- package/package.json +8 -13
- package/rspress.config.ts +1 -58
- package/src/components/Footer/index.tsx +1 -1
- package/src/components/RsbuildLink/index.tsx +19 -0
- package/src/pages/index.tsx +0 -1
- package/docs/en/apis/app/hooks/api/api.mdx +0 -80
- package/docs/en/apis/app/hooks/api/app.mdx +0 -12
- package/docs/en/guides/advanced-features/bff/type.mdx +0 -46
- package/docs/en/guides/advanced-features/eslint.mdx +0 -148
- package/docs/zh/apis/app/hooks/api/api.mdx +0 -81
- package/docs/zh/apis/app/hooks/api/app.mdx +0 -12
- package/docs/zh/guides/advanced-features/bff/type.mdx +0 -46
- package/docs/zh/guides/advanced-features/eslint.mdx +0 -152
- /package/docs/en/configure/app/output/{splitRouteChunks.mdx → split-route-chunks.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
- /package/docs/zh/configure/app/output/{splitRouteChunks.mdx → split-route-chunks.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
# Extend BFF Server
|
2
|
+
|
3
|
+
In some applications, developers may want to handle all BFF functions uniformly, such as for authentication, logging, data processing, etc.
|
4
|
+
|
5
|
+
Modern.js provides two methods that allow developers to extend the BFF Server freely according to the runtime framework.
|
6
|
+
|
7
|
+
## Middleware
|
8
|
+
|
9
|
+
Developers can write middleware in the `api/_app.ts` file to extend the BFF Server. Taking Express as the runtime framework, here is an example of how to write a middleware to add permission checks:
|
10
|
+
|
11
|
+
```ts title="api/_app.ts"
|
12
|
+
import { hook } from '@modern-js/runtime/server';
|
13
|
+
import { Request, Response, NextFunction } from 'express';
|
14
|
+
|
15
|
+
export default hook(({ addMiddleware }) => {
|
16
|
+
addMiddleware(async (req: Request, res: Response, next: NextFunction) => {
|
17
|
+
if (req.url !== '/api/login') {
|
18
|
+
const sid = req?.cookies?.sid;
|
19
|
+
if (!sid) {
|
20
|
+
res.status(400);
|
21
|
+
res.json({ code: -1, message: 'need login' });
|
22
|
+
} else {
|
23
|
+
next();
|
24
|
+
}
|
25
|
+
} else {
|
26
|
+
next();
|
27
|
+
}
|
28
|
+
});
|
29
|
+
});
|
30
|
+
```
|
31
|
+
|
32
|
+
Then add a standard BFF function `api/lambda/hello.ts`:
|
33
|
+
|
34
|
+
```ts title="api/lambda/hello.ts"
|
35
|
+
export default async () => {
|
36
|
+
return 'Hello Modern.js';
|
37
|
+
};
|
38
|
+
```
|
39
|
+
|
40
|
+
Next, in the frontend, add the code to access the API in `src/routes/page.tsx`, directly using the integrated method for the call:
|
41
|
+
|
42
|
+
```ts title="src/routes/page.tsx"
|
43
|
+
import { useState, useEffect } from 'react';
|
44
|
+
import { get as hello } from '@api/hello';
|
45
|
+
|
46
|
+
export default () => {
|
47
|
+
const [text, setText] = useState('');
|
48
|
+
|
49
|
+
useEffect(() => {
|
50
|
+
async function fetchMyApi() {
|
51
|
+
const { message } = await hello();
|
52
|
+
setText(message);
|
53
|
+
}
|
54
|
+
|
55
|
+
fetchMyApi();
|
56
|
+
}, []);
|
57
|
+
|
58
|
+
return <p>{text}</p>;
|
59
|
+
};
|
60
|
+
```
|
61
|
+
|
62
|
+
Now run the `dev` command to start the project, and visit `http://localhost:8080/`. You will find that the request to `/api/hello` is intercepted:
|
63
|
+
|
64
|
+

|
65
|
+
|
66
|
+
Finally, modify the frontend code in `src/routes/page.tsx` to call the login interface before accessing `/api/hello`:
|
67
|
+
|
68
|
+
:::note
|
69
|
+
Here the login interface is not actually implemented; the code is just for demonstration.
|
70
|
+
:::
|
71
|
+
|
72
|
+
```ts
|
73
|
+
import { useState, useEffect } from 'react';
|
74
|
+
import { get as hello } from '@api/hello';
|
75
|
+
import { post as login } from '@api/login';
|
76
|
+
|
77
|
+
export default () => {
|
78
|
+
const [text, setText] = useState('');
|
79
|
+
|
80
|
+
useEffect(() => {
|
81
|
+
async function fetchAfterLogin() {
|
82
|
+
const { code } = await login();
|
83
|
+
if (code === 0) {
|
84
|
+
const { message } = await hello();
|
85
|
+
setText(message);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
fetchAfterLogin();
|
89
|
+
}, []);
|
90
|
+
|
91
|
+
return <p>{text}</p>;
|
92
|
+
};
|
93
|
+
```
|
94
|
+
|
95
|
+
Refresh the page to see that the access to `/api/hello` is successful:
|
96
|
+
|
97
|
+

|
98
|
+
|
99
|
+
The above code simulates adding middleware in `api/_app.ts` to implement simple login functionality. Similarly, other functionalities can be implemented in this hook file to extend the BFF Server.
|
100
|
+
|
101
|
+
:::info
|
102
|
+
The way middleware is written may differ depending on the runtime framework. For details, see [Runtime Frameworks](/guides/advanced-features/bff/frameworks).
|
103
|
+
:::
|
104
|
+
|
105
|
+
## Define Server Instance
|
106
|
+
|
107
|
+
In addition to middleware, you can also define a BFF Server instance via the `api/app.ts`. Developers need to export an instance that can be recognized by the runtime framework plugin. Here is a simple demonstration of how to define a server instance with Koa and Express.
|
108
|
+
|
109
|
+
import { Tabs, Tab as TabItem } from "@theme";
|
110
|
+
|
111
|
+
<Tabs>
|
112
|
+
<TabItem value="express" label="Express.js" default>
|
113
|
+
|
114
|
+
```ts title="api/app.ts"
|
115
|
+
import express from 'express';
|
116
|
+
|
117
|
+
const app = express();
|
118
|
+
app.use(async (req, res, next) => {
|
119
|
+
console.info(`access url: ${req.url}`);
|
120
|
+
next();
|
121
|
+
});
|
122
|
+
|
123
|
+
export default app;
|
124
|
+
```
|
125
|
+
|
126
|
+
</TabItem>
|
127
|
+
<TabItem value="koa" label="Koa.js">
|
128
|
+
|
129
|
+
```ts title="api/app.ts"
|
130
|
+
import koa from 'koa';
|
131
|
+
|
132
|
+
const app = new Koa();
|
133
|
+
app.use(async (ctx, next) => {
|
134
|
+
console.info(`access url: ${ctx.url}`);
|
135
|
+
await next();
|
136
|
+
});
|
137
|
+
|
138
|
+
export default app;
|
139
|
+
```
|
140
|
+
|
141
|
+
</TabItem>
|
142
|
+
</Tabs>
|
143
|
+
|
144
|
+
In complex BFF logic, defining a server instance allows for easier organization of code logic and directory structure design through a single entry point. In this file, you can perform initialization logic, add global middleware, declare routes, and even extend the original framework.
|
145
|
+
|
146
|
+
The routes defined by the BFF functions will be registered after the routes defined in the `app.ts` file. Therefore, you can also intercept the routes defined by the BFF functions here for preprocessing or early responses.
|
147
|
+
|
148
|
+
:::note
|
149
|
+
At this time, if `api/_app.ts` exists in the application, the defined middleware will be executed after the middleware exported by the `api/app.ts` instance. In most cases, middleware can cover most customization needs for BFF functions. Only when the application's server-side logic is more complex do you need to customize the server instance.
|
150
|
+
:::
|
151
|
+
|
152
|
+
:::caution
|
153
|
+
When `api/app.ts` does not exist in the application, Modern.js will default to adding [koa-body](https://www.npmjs.com/package/koa-body). When `api/app.ts` does exist in the application, if developers wish to use BFF functions with bodies, they will need to **add `koa-body` themselves**.
|
154
|
+
:::
|
@@ -1,152 +1,81 @@
|
|
1
|
-
|
2
|
-
sidebar_position: 3
|
3
|
-
---
|
1
|
+
# Runtime Framework
|
4
2
|
|
5
|
-
|
3
|
+
Modern.js BFF supports different runtime frameworks. Currently, Modern.js BFF supports two runtime frameworks: [Express.js](https://expressjs.com/) and [Koa.js](https://koajs.com/).
|
6
4
|
|
7
|
-
|
5
|
+
When using different runtime frameworks, some APIs may differ.
|
8
6
|
|
9
|
-
##
|
7
|
+
## Accessing Request Context
|
10
8
|
|
11
|
-
|
9
|
+
In BFF functions, you may need to access the request context to handle more logic. Depending on the runtime framework, you need to use different APIs:
|
12
10
|
|
13
|
-
|
14
|
-
import { hook } from '@modern-js/runtime/server';
|
15
|
-
import { Request, Response, NextFunction } from 'express';
|
11
|
+
import { Tabs, Tab as TabItem } from "@theme";
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
if (req.url !== '/api/login') {
|
20
|
-
const sid = req?.cookies?.sid;
|
21
|
-
if (!sid) {
|
22
|
-
res.status(400);
|
23
|
-
res.json({ code: -1, message: 'need login' });
|
24
|
-
} else {
|
25
|
-
next();
|
26
|
-
}
|
27
|
-
} else {
|
28
|
-
next();
|
29
|
-
}
|
30
|
-
});
|
31
|
-
});
|
32
|
-
```
|
33
|
-
|
34
|
-
Then add a normal BFF function `/api/hello.ts`:
|
13
|
+
<Tabs>
|
14
|
+
<TabItem value="express" label="Express.js" default>
|
35
15
|
|
36
|
-
```ts
|
37
|
-
|
38
|
-
|
16
|
+
```ts title="api/lambda/hello.ts"
|
17
|
+
import { useContext } from '@modern-js/runtime/express'
|
18
|
+
export const get = async () => {
|
19
|
+
const { req } = useContext();
|
20
|
+
console.info(`access url: ${req.url}`);
|
21
|
+
return 'Hello Modern.js'
|
39
22
|
};
|
40
23
|
```
|
41
24
|
|
42
|
-
|
25
|
+
</TabItem>
|
26
|
+
<TabItem value="koa" label="Koa.js">
|
43
27
|
|
44
|
-
```ts
|
45
|
-
import {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
useEffect(() => {
|
52
|
-
async function fetchMyApi() {
|
53
|
-
const { message } = await hello();
|
54
|
-
setText(message);
|
55
|
-
}
|
56
|
-
|
57
|
-
fetchMyApi();
|
58
|
-
}, []);
|
59
|
-
|
60
|
-
return <p>{text}</p>;
|
28
|
+
```ts title="api/lambda/hello.ts"
|
29
|
+
import { useContext } from '@modern-js/runtime/koa'
|
30
|
+
export const get = async () => {
|
31
|
+
const ctx = useContext();
|
32
|
+
console.info(`access url: ${req.url}`);
|
33
|
+
return 'Hello Modern.js'
|
61
34
|
};
|
62
35
|
```
|
63
36
|
|
64
|
-
|
37
|
+
</TabItem>
|
38
|
+
</Tabs>
|
65
39
|
|
66
|
-
|
40
|
+
:::info
|
41
|
+
For more details, refer to [useContext](/apis/app/runtime/bff/use-context).
|
42
|
+
:::
|
67
43
|
|
68
|
-
|
44
|
+
## Using Middleware
|
69
45
|
|
70
|
-
|
71
|
-
import { useState, useEffect } from 'react';
|
72
|
-
import { get as hello } from '@api/hello';
|
73
|
-
import { post as login } from '@api/login';
|
46
|
+
In BFF functions, you may need to use middleware to handle more logic. Depending on the runtime framework, you need to use different APIs:
|
74
47
|
|
75
|
-
|
76
|
-
|
48
|
+
<Tabs>
|
49
|
+
<TabItem value="express" label="Express.js" default>
|
77
50
|
|
78
|
-
|
79
|
-
|
80
|
-
const { code } = await login();
|
81
|
-
if (code === 0) {
|
82
|
-
const { message } = await hello();
|
83
|
-
setText(message);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
fetchAfterLogin();
|
87
|
-
}, []);
|
51
|
+
```ts title="api/_app.ts"
|
52
|
+
import { hook } from '@modern-js/runtime/express';
|
88
53
|
|
89
|
-
|
90
|
-
|
54
|
+
export default hook(({ addMiddleware }) => {
|
55
|
+
addMiddleware((req, res, next) => {
|
56
|
+
req.query.id = 'koa';
|
57
|
+
next();
|
58
|
+
});
|
59
|
+
});
|
91
60
|
```
|
92
61
|
|
93
|
-
|
94
|
-
|
95
|
-

|
96
|
-
|
97
|
-
The above code simulates the way to add middleware to the `/api/_app.ts` to achieve an easy login function. Also, other functions can be implemented in this hook file to extend BFF Server.
|
98
|
-
|
99
|
-
## Framework Mode
|
100
|
-
|
101
|
-
Under the framework writing, Modern.js does not collect middleware in the `api/_app.ts`, and the running process is controlled by the plugin itself.
|
102
|
-
|
103
|
-
### Express
|
62
|
+
</TabItem>
|
63
|
+
<TabItem value="koa" label="Koa.js">
|
104
64
|
|
105
|
-
|
65
|
+
```ts title="api/_app.ts"
|
66
|
+
import { hook } from '@modern-js/runtime/koa';
|
106
67
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
const app = express();
|
113
|
-
|
114
|
-
app.put('/user', function (req, res) {
|
115
|
-
res.send('Got a PUT request at /user');
|
116
|
-
});
|
117
|
-
|
118
|
-
app.use(async (req, res, next) => {
|
119
|
-
console.info(`access url: ${req.url}`);
|
120
|
-
next();
|
68
|
+
export default hook(({ addMiddleware }) => {
|
69
|
+
addMiddleware(async (ctx, next) => {
|
70
|
+
ctx.req.query.id = 'koa';
|
71
|
+
await next();
|
72
|
+
});
|
121
73
|
});
|
122
|
-
|
123
|
-
export default app;
|
124
74
|
```
|
125
75
|
|
126
|
-
|
127
|
-
|
128
|
-
The Koa framework is written in a similar way to Express. It supports defining the startup logic of API Server in `app.[tj]s`, performing the initialization work of the application, adding global middleware, declaring routes, extending the original framework, etc.
|
129
|
-
|
130
|
-
The route defined by the BFF function will be registered after the route defined by the `app.ts` file, so here you can also intercept the route defined by the BFF function, preprocess or respond in advance.
|
131
|
-
|
132
|
-
:::caution
|
133
|
-
Use the framework writing, when there is no `app.ts`, Modern.js will add koa-body by default. When there is `app.ts`, if the developer wants to use the BFF function with Body, he needs to ensure that the koa-body middleware has been added.
|
76
|
+
</TabItem>
|
77
|
+
</Tabs>
|
134
78
|
|
79
|
+
:::info
|
80
|
+
For more details, refer to [hook](/apis/app/runtime/bff/hook).
|
135
81
|
:::
|
136
|
-
|
137
|
-
```ts title=api/app.ts
|
138
|
-
import koa from 'koa';
|
139
|
-
|
140
|
-
const app = new Koa();
|
141
|
-
|
142
|
-
app.put('/user', function (req, res) {
|
143
|
-
res.send('Got a PUT request at /user');
|
144
|
-
});
|
145
|
-
|
146
|
-
app.use(async (ctx, next) => {
|
147
|
-
console.info(`access url: ${ctx.url}`);
|
148
|
-
await next();
|
149
|
-
});
|
150
|
-
|
151
|
-
export default app;
|
152
|
-
```
|