@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
@@ -1,16 +1,12 @@
|
|
1
|
-
|
2
|
-
sidebar_position: 4
|
3
|
-
title: 自定义请求 SDK
|
4
|
-
---
|
5
|
-
# 自定义请求 SDK
|
1
|
+
# 扩展一体化调用 SDK
|
6
2
|
|
7
|
-
|
3
|
+
BFF 函数的一体化调用在 CSR 和 SSR 是同构的。Modern.js 封装的请求 SDK,在浏览器端依赖了 [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch),在服务端依赖了 [node-fetch](https://www.npmjs.com/package/node-fetch)。但在实际业务场景下,有时需要对请求或响应做一些额外的处理,例如:
|
8
4
|
|
9
5
|
- 在请求头中写入鉴权信息
|
10
6
|
- 对响应的数据或错误进行统一的处理
|
11
7
|
- 特定平台无法使用浏览器的原生 fetch 函数,需要使用其他方式发送请求
|
12
8
|
|
13
|
-
针对上述的场景,Modern.js 提供了 `configure`
|
9
|
+
针对上述的场景,Modern.js 提供了 `configure` 函数,开放了一系列扩展能力,可以用它配置 ssr 透传请求头,添加拦截器,自定义请求 SDK。
|
14
10
|
|
15
11
|
:::caution 注意
|
16
12
|
`configure` 函数的调用需要在所有 BFF 请求发送前调用,以确保覆盖默认的请求配置。
|
@@ -18,42 +14,42 @@ Modern.js 的 BFF 在 CSR 和 SSR 是同构的。在浏览器端依赖了[Fetch
|
|
18
14
|
:::
|
19
15
|
|
20
16
|
|
21
|
-
```
|
17
|
+
```tsx title="routes/page.tsx"
|
22
18
|
import { configure } from '@modern-js/runtime/bff';
|
23
19
|
|
24
|
-
configure({
|
25
|
-
|
20
|
+
configure({
|
21
|
+
// ...
|
26
22
|
})
|
23
|
+
|
24
|
+
const Index = () => <div>Hello world</div>
|
25
|
+
export default Index;
|
27
26
|
```
|
28
27
|
|
29
|
-
## 配置
|
28
|
+
## 配置 SSR 透传请求头
|
30
29
|
|
31
|
-
在同时使用
|
30
|
+
在同时使用 Modern.js SSR 和 BFF 的场景下,常常需要将 SSR 页面请求上的一些请求头信息,透传给 BFF 服务。
|
32
31
|
|
33
32
|
例如项目有页面地址是 `https://website.com`,该页面是 SSR 的,在组件中会调用 API 接口 `https://website.com/api/info`,该接口需要用户的 cookie 信息做鉴权。页面在请求该 API 接口时,需要将 SSR 页面请求的 `cookie` 传给 BFF。
|
34
33
|
|
35
34
|
目前以下请求头在 Modernjs 中是自动透传的:
|
36
35
|
|
37
|
-
|
38
|
-
- x-tt-logid
|
39
|
-
|
40
|
-
- x-tt-stress
|
41
|
-
|
42
|
-
可以通过 `configure` 配置请求头。例如以下例子,Modern.js 会自动将 SSR 页面请求的 cookie 信息透传给 BFF 服务:
|
36
|
+
```ts
|
37
|
+
['cookie', 'user-agent', 'x-tt-logid', 'x-tt-stress']
|
38
|
+
```
|
43
39
|
|
44
|
-
|
45
|
-
import { configure } from '@modern-js/runtime/bff';
|
40
|
+
可以通过 `configure` 配置请求头。例如以下例子,Modern.js 会自动将 SSR 页面请求的 `x-uid` 信息透传给 BFF 服务:
|
46
41
|
|
42
|
+
```tsx
|
47
43
|
configure({
|
48
44
|
allowedHeaders: ['x-uid']
|
49
45
|
})
|
50
46
|
```
|
51
47
|
|
52
|
-
##
|
48
|
+
## 添加拦截器
|
53
49
|
|
54
|
-
|
50
|
+
在有些业务场景下需要对请求和响应进行统一的处理,这种场景下可以通过**配置拦截器**满足需求:
|
55
51
|
|
56
|
-
```tsx
|
52
|
+
```tsx
|
57
53
|
configure({
|
58
54
|
// 这里的 request 是一体化默认的请求工具,interceptor 函数需返回一个新的 request。
|
59
55
|
// 新 request 的出参必须是 parse body 之后的结果
|
@@ -66,16 +62,11 @@ configure({
|
|
66
62
|
});
|
67
63
|
```
|
68
64
|
|
69
|
-
##
|
70
|
-
|
71
|
-
如果仅仅通过配置拦截器无法满足需求,需要对请求的 SDK 做进一步的自定义,可以通过 `configure` 函数配置自定义请求 SDK:
|
72
|
-
|
73
|
-
:::caution 注意
|
74
|
-
在 SSR 和一体化调用的场景下,在 SSR 向 BFF 服务发送请求时,Modern.js 会通过**服务发现**找到 BFF 服务内网 IP,并通过 IP 发送请求,以提高性能。如果使用自定义请求 SDK 会**失去这种优化**。
|
65
|
+
## 自定义请求 SDK
|
75
66
|
|
76
|
-
|
67
|
+
如果仅仅通过配置拦截器无法满足需求,希望自定义请求函数,也可以通过 `configure` 进行配置:
|
77
68
|
|
78
|
-
```tsx
|
69
|
+
```tsx
|
79
70
|
import nodeFetch from 'node-fetch';
|
80
71
|
|
81
72
|
const customFetch = (input: RequestInfo | URL, init: RequestInit) => {
|
@@ -92,13 +83,13 @@ configure({
|
|
92
83
|
});
|
93
84
|
```
|
94
85
|
|
95
|
-
|
86
|
+
配置自定义请求函数有以下约定:
|
96
87
|
|
97
|
-
-
|
98
|
-
-
|
99
|
-
- 如果是 SSR
|
88
|
+
- 函数的入参与浏览器中的 Fetch 或 node-fetch 对齐,所有 BFF 函数的一体化调用会通过该函数发送请求。
|
89
|
+
- 函数出参必须是接口实际返回的数据,不能是 Promise,否则会导致 BFF 函数无法正常返回数据。
|
90
|
+
- 如果是 SSR 项目,函数必须要同时支持浏览器端和服务器端发送请求。
|
100
91
|
|
101
|
-
|
92
|
+
下面是使用 axios 定制自定义请求函数的示例:
|
102
93
|
|
103
94
|
```tsx title="App.tsx"
|
104
95
|
import { configure } from '@modern-js/runtime/bff';
|
@@ -9,13 +9,17 @@ Modern.js 默认对构建性能进行了充分优化,但是随着业务场景
|
|
9
9
|
本文档提供了一些可选的提速策略,**开发者可以根据实际场景选取其中的部分策略**,从而进一步提升构建速度。
|
10
10
|
|
11
11
|
:::tip 📢 注意
|
12
|
-
在[优化产物体积](/guides/advanced-features/optimize-bundle
|
12
|
+
在[优化产物体积](/guides/advanced-features/page-performance/optimize-bundle)一文中介绍的策略也可以用于提升构建性能,这里不再重复介绍。
|
13
13
|
:::
|
14
14
|
|
15
15
|
## 通用优化策略
|
16
16
|
|
17
17
|
以下是一些通用的优化策略,对开发环境和生产环境均有提速效果,其中部分策略对包体积也有优化。
|
18
18
|
|
19
|
+
### 使用 Rspack 构建(推荐)
|
20
|
+
|
21
|
+
如果你还未使用 Rspack 构建,可以切换到 Rspack 构建模式来提升 5~10 倍的构建速度,请参考 [使用 Rspack](/guides/advanced-features/rspack-start.html) 来进行切换。
|
22
|
+
|
19
23
|
### 升级 Node.js 版本
|
20
24
|
|
21
25
|
通常来说,将 Node.js 更新到最新的 [LTS 版本](https://github.com/nodejs/release#release-schedule),有助于提升构建性能。
|
@@ -40,25 +44,6 @@ nvm default 18
|
|
40
44
|
node -v
|
41
45
|
```
|
42
46
|
|
43
|
-
### 使用 Rspack 构建
|
44
|
-
|
45
|
-
如果你对构建性能有更极致的需求,可以一键切换到 Rspack 构建模式,请参考 [使用 Rspack](/guides/advanced-features/rspack-start.html) 来进行切换。
|
46
|
-
|
47
|
-
### 使用 SWC 或 esbuild 编译
|
48
|
-
|
49
|
-
[SWC](https://swc.rs/) (Speedy Web Compiler) 是基于 `Rust` 语言编写的高性能 JavaScript 和 TypeScript 转译和压缩工具。在 Polyfill 和语法降级方面可以和 Babel 提供一致的能力,并且性能比 Babel 高出一个数量级。
|
50
|
-
|
51
|
-
[esbuild](https://esbuild.github.io/) 是一款基于 Golang 开发的前端构建工具,具有打包、编译和压缩 JavaScript 代码的功能,相比传统的打包编译工具,esbuild 在性能上有显著提升。
|
52
|
-
|
53
|
-
Modern.js 提供了 SWC 插件和 esbuild 插件,让你能使用 SWC 或 esbuild 代替 babel-loader、ts-loader 和 terser 等库进行代码编译和压缩。详见:
|
54
|
-
|
55
|
-
- [SWC 插件文档](/configure/app/tools/swc.html)
|
56
|
-
- [esbuild 插件文档](/configure/app/tools/esbuild.html)
|
57
|
-
|
58
|
-
:::tip SWC vs esbuild
|
59
|
-
SWC 编译产物的兼容性较好,支持注入 core-js 等 Polyfill,并且功能更加完备,因此推荐优先使用 SWC 插件。
|
60
|
-
:::
|
61
|
-
|
62
47
|
### 避免使用 ts-loader
|
63
48
|
|
64
49
|
默认情况下,Modern.js 使用 Babel 编译 TS 文件,开启 [tools.tsLoader](/configure/app/tools/ts-loader.html) 选项后,会使用 `ts-loader` 编译 TS 文件。
|
@@ -118,7 +103,7 @@ export default {
|
|
118
103
|
|
119
104
|
### 调整 Browserslist 范围
|
120
105
|
|
121
|
-
这项优化的原理与[「提升 Browserslist 范围」](/guides/advanced-features/optimize-bundle
|
106
|
+
这项优化的原理与[「提升 Browserslist 范围」](/guides/advanced-features/page-performance/optimize-bundle#adjust-browserslist)类似,区别在于,我们可以为开发环境和生产环境设置不同的 browserslist,从而减少开发环境下的编译开销。
|
122
107
|
|
123
108
|
比如,你可以在 `package.json` 中添加以下配置,表示在开发环境下只兼容最新的浏览器,在生产环境下兼容实际需要的浏览器:
|
124
109
|
|
@@ -0,0 +1 @@
|
|
1
|
+
["code-split", "inline-assets", "optimize-bundle"]
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
4
4
|
|
5
5
|
# 使用 Rspack
|
6
6
|
|
7
|
-
import Rspack from '@
|
7
|
+
import Rspack from '@site-docs/components/rspackTip.mdx';
|
8
8
|
|
9
9
|
<Rspack />
|
10
10
|
|
@@ -39,10 +39,10 @@ export default defineConfig({
|
|
39
39
|
```
|
40
40
|
|
41
41
|
:::tip
|
42
|
-
如果你当前版本低于 MAJOR_VERSION.59.0
|
42
|
+
如果你当前版本低于 MAJOR_VERSION.59.0,可通过执行 `npx modern upgrade` 进行升级。
|
43
43
|
:::
|
44
44
|
|
45
|
-
import RspackPrecautions from '@
|
45
|
+
import RspackPrecautions from '@site-docs/components/rspackPrecautions.mdx';
|
46
46
|
|
47
47
|
<RspackPrecautions />
|
48
48
|
|
@@ -104,7 +104,7 @@ export default defineConfig<'rspack'>({
|
|
104
104
|
|
105
105
|

|
106
106
|
|
107
|
-
|
107
|
+
### 修改内置 Rspack 版本
|
108
108
|
|
109
109
|
可以使用 pnpm / yarn / npm 等包管理工具自带的依赖升级功能来将 Rspack 强制升级到指定版本。
|
110
110
|
|
@@ -15,9 +15,7 @@ sidebar_position: 4
|
|
15
15
|
|
16
16
|
## 通过 `tsconfig.json` 的 `paths` 配置
|
17
17
|
|
18
|
-
你可以通过 `tsconfig.json` 中的 `paths` 来配置别名,这是我们在 TypeScript 项目中推荐使用的方式,因为它可以解决路径别名的 TS
|
19
|
-
|
20
|
-
比如:
|
18
|
+
你可以通过 `tsconfig.json` 中的 `paths` 来配置别名,这是我们在 TypeScript 项目中推荐使用的方式,因为它可以解决路径别名的 TS 类型问题。比如:
|
21
19
|
|
22
20
|
```json title="tsconfig.json"
|
23
21
|
{
|
@@ -29,7 +27,7 @@ sidebar_position: 4
|
|
29
27
|
}
|
30
28
|
```
|
31
29
|
|
32
|
-
以上配置完成后,如果你在代码中引用 `@common/Foo.tsx
|
30
|
+
以上配置完成后,如果你在代码中引用 `@common/Foo.tsx`,则会映射到 `<project>/src/common/Foo.tsx` 路径上。
|
33
31
|
|
34
32
|
:::tip
|
35
33
|
你可以阅读 [TypeScript - paths](https://www.typescriptlang.org/tsconfig#paths) 文档来了解更多用法。
|
@@ -47,9 +45,7 @@ Modern.js 提供了 [source.alias](/configure/app/source/alias) 配置项,对
|
|
47
45
|
|
48
46
|
### 对象用法
|
49
47
|
|
50
|
-
你可以通过对象的方式来配置 `source.alias
|
51
|
-
|
52
|
-
比如:
|
48
|
+
你可以通过对象的方式来配置 `source.alias`,其中的相对路径会被自动补全为绝对路径。比如:
|
53
49
|
|
54
50
|
```js
|
55
51
|
export default {
|
@@ -61,13 +57,11 @@ export default {
|
|
61
57
|
};
|
62
58
|
```
|
63
59
|
|
64
|
-
以上配置完成后,如果你在代码中引用 `@common/Foo.tsx
|
60
|
+
以上配置完成后,如果你在代码中引用 `@common/Foo.tsx`,则会映射到 `<project>/src/common/Foo.tsx` 路径上。
|
65
61
|
|
66
62
|
### 函数用法
|
67
63
|
|
68
|
-
你也可以将 `source.alias` 配置为一个函数,拿到内置的 `alias`
|
69
|
-
|
70
|
-
比如:
|
64
|
+
你也可以将 `source.alias` 配置为一个函数,拿到内置的 `alias` 对象,对其进行修改。比如:
|
71
65
|
|
72
66
|
```js
|
73
67
|
export default {
|
@@ -167,7 +167,7 @@ declare module '*.styl' {
|
|
167
167
|
|
168
168
|
上述方法虽然可以解决 CSS Modules 在 TypeScript 中的类型问题,但是无法准确地提示出某个 CSS 文件导出了哪些类名。
|
169
169
|
|
170
|
-
|
170
|
+
Modern.js 支持为 CSS Modules 生成准确的类型声明,你只需要开启 [output.enableCssModuleTSDeclaration](/configure/app/output/enable-css-module-tsdeclaration) 配置项,再执行构建命令,Modern.js 就会为项目中所有的 CSS Modules 文件生成相应的类型声明文件。
|
171
171
|
|
172
172
|
```ts
|
173
173
|
export default {
|
@@ -42,7 +42,7 @@ dist
|
|
42
42
|
|
43
43
|
## 修改产物目录
|
44
44
|
|
45
|
-
|
45
|
+
Modern.js 提供了多个配置项来修改产物目录和产物名称,你可以:
|
46
46
|
|
47
47
|
- 通过 [output.filename](/configure/app/output/filename) 来修改产物的文件名。
|
48
48
|
- 通过 [output.distPath](/configure/app/output/dist-path) 来修改产物的输出路径。
|
@@ -158,7 +158,7 @@ dist
|
|
158
158
|
|
159
159
|
## 产物不写入磁盘
|
160
160
|
|
161
|
-
默认情况下,
|
161
|
+
默认情况下,Modern.js 会将构建产物写入磁盘,以方便开发者查看产物的内容,或是配置静态资源的代理规则。
|
162
162
|
|
163
163
|
在开发环境,你可以选择将构建产物保存在 Dev Server 的内存中,从而减少文件操作产生的开销。
|
164
164
|
|
@@ -464,8 +464,7 @@ Modern.js 支持通过 `loading.tsx` 文件来解决这个问题,`routes/` 下
|
|
464
464
|
|
465
465
|
:::tip
|
466
466
|
|
467
|
-
|
468
|
-
- 对数据的预加载目前只会预加载 SSR 项目中 [Data Loader](/guides/basic-features/data/data-fetch) 中返回的数据。
|
467
|
+
对数据的预加载目前只会预加载 SSR 项目中 [Data Loader](/guides/basic-features/data/data-fetch) 中返回的数据。
|
469
468
|
|
470
469
|
:::
|
471
470
|
|
@@ -72,7 +72,7 @@ console.log(largeImage); // "/static/largeImage.6c12aba3.png"
|
|
72
72
|
console.log(smallImage); // "data:image/png;base64,iVBORw0KGgo..."
|
73
73
|
```
|
74
74
|
|
75
|
-
关于资源内联的更详细介绍,请参考 [静态资源内联](/guides/advanced-features/inline-assets) 章节。
|
75
|
+
关于资源内联的更详细介绍,请参考 [静态资源内联](/guides/advanced-features/page-performance/inline-assets) 章节。
|
76
76
|
|
77
77
|
## 构建产物
|
78
78
|
|
@@ -4,7 +4,7 @@ sidebar_position: 2
|
|
4
4
|
|
5
5
|
# 构建工具
|
6
6
|
|
7
|
-
Modern.js
|
7
|
+
Modern.js 构建是基于 [Rsbuild](https://rsbuild.dev/) 实现的,并支持在 Webpack 和 Rspack 两种打包工具间无缝切换。
|
8
8
|
|
9
9
|
:::tip 什么是 Rsbuild
|
10
10
|
Rsbuild 是基于 Rspack 的构建工具,是一个增强版的 Rspack CLI,更易用、开箱即用。
|
@@ -13,3 +13,7 @@ Modern.js 之前提供的 Monorepo 方案是基于 [pnpm Workspace](https://pnpm
|
|
13
13
|
## new 命令开启 test 能力
|
14
14
|
|
15
15
|
Modern.js 之前提供的测试能力是基于 Jest 的简单封装。该封装导致 Jest 配置不直观、用户配置更加复杂等问题。在 [v2.53.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.53.0) 版本中,移除了在应用项目和模块项目中开启 test 功能的选项。推荐直接使用社区提供的测试方案。
|
16
|
+
|
17
|
+
## Eslint 规则集
|
18
|
+
|
19
|
+
Modern.js 之前提供了 ESLint 的完整规则集,涵盖了 @modern-js(针对 Node.js 项目的 Lint 规则)和 @modern-js-app(针对前端项目的 Lint 规则)。在 [v2.60.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.60.0) 版本中,我们正式移除了这些规则集。我们鼓励开发者根据自身需求选择合适的代码规范工具,直接使用 ESLint 并结合社区推荐的规则,或使用 Biome 以提升代码格式化的性能。
|
@@ -12,13 +12,13 @@ BFF 服务作为前端应用程序和服务端 API 之间的中介,可以为
|
|
12
12
|
|
13
13
|
## Bundler
|
14
14
|
|
15
|
-
import Bundler from '@
|
15
|
+
import Bundler from '@site-docs/components/bundler.mdx';
|
16
16
|
|
17
17
|
<Bundler />
|
18
18
|
|
19
19
|
## Builder
|
20
20
|
|
21
|
-
import Builder from '@
|
21
|
+
import Builder from '@site-docs/components/builder.mdx';
|
22
22
|
|
23
23
|
<Builder />
|
24
24
|
|
@@ -36,25 +36,25 @@ CSR 是 "Client-Side Rendering"(客户端渲染)的缩写。它表示页面
|
|
36
36
|
|
37
37
|
## Micro-frontend
|
38
38
|
|
39
|
-
import MicroFrontend from '@
|
39
|
+
import MicroFrontend from '@site-docs/components/micro-frontend.mdx';
|
40
40
|
|
41
41
|
<MicroFrontend />
|
42
42
|
|
43
43
|
## Module Federation
|
44
44
|
|
45
|
-
import ModuleFederation from '@
|
45
|
+
import ModuleFederation from '@site-docs/components/module-federation.mdx';
|
46
46
|
|
47
47
|
<ModuleFederation />
|
48
48
|
|
49
49
|
## Rsbuild
|
50
50
|
|
51
|
-
import Rsbuild from '@
|
51
|
+
import Rsbuild from '@site-docs/components/rsbuild.mdx';
|
52
52
|
|
53
53
|
<Rsbuild />
|
54
54
|
|
55
55
|
## Rspack
|
56
56
|
|
57
|
-
import Rspack from '@
|
57
|
+
import Rspack from '@site-docs/components/rspack.mdx';
|
58
58
|
|
59
59
|
<Rspack />
|
60
60
|
|
@@ -76,6 +76,6 @@ SSG 是 "Static Site Generation"(静态网站生成)的缩写。它表示网
|
|
76
76
|
|
77
77
|
## SWC
|
78
78
|
|
79
|
-
import SWC from '@
|
79
|
+
import SWC from '@site-docs/components/swc.mdx';
|
80
80
|
|
81
81
|
<SWC />
|
@@ -72,7 +72,7 @@ export default defineConfig({
|
|
72
72
|
|
73
73
|
- 提供 `modern dev`, `modern build` 等常用的 CLI 命令。
|
74
74
|
- 集成 Modern.js Core,提供配置解析、插件加载等能力。
|
75
|
-
- 集成
|
75
|
+
- 集成 Rsbuild,提供构建能力。
|
76
76
|
- 集成 Modern.js Server,提供开发和生产服务器相关能力。
|
77
77
|
|
78
78
|
`@modern-js/app-tools` 是基于 Modern.js 的插件体系实现的,本质上是一个插件,因此你需要在配置文件的 `plugins` 字段中注册 `appTools`:
|
@@ -40,8 +40,8 @@ Modern.js 提供 [inspect 命令](/apis/app/commands.html) 用于查看项目最
|
|
40
40
|
|
41
41
|
Inspect config succeed, open following files to view the content:
|
42
42
|
|
43
|
-
-
|
44
|
-
- Rspack Config (web): /root/my-project/dist/rspack.config.web.
|
43
|
+
- Rsbuild Config: /root/my-project/dist/rsbuild.config.mjs
|
44
|
+
- Rspack Config (web): /root/my-project/dist/rspack.config.web.mjs
|
45
45
|
```
|
46
46
|
|
47
47
|
---
|
@@ -0,0 +1,19 @@
|
|
1
|
+
[
|
2
|
+
"introduction",
|
3
|
+
{
|
4
|
+
"type": "dir",
|
5
|
+
"name": "plugin-system",
|
6
|
+
"label": "plugin-system",
|
7
|
+
"collapsed": true
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"type": "dir",
|
11
|
+
"name": "cli-plugins",
|
12
|
+
"label": "cli-plugins"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"type": "dir",
|
16
|
+
"name": "rsbuild-plugins",
|
17
|
+
"label": "rsbuild-plugins"
|
18
|
+
}
|
19
|
+
]
|
@@ -0,0 +1 @@
|
|
1
|
+
["plugin-tailwind", "plugin-bff", "plugin-ssg", "plugin-swc"]
|
@@ -4,7 +4,14 @@ sidebar_position: 2
|
|
4
4
|
|
5
5
|
# SWC 插件
|
6
6
|
|
7
|
-
|
7
|
+
:::warning
|
8
|
+
**当前文档中的 SWC 功能已停止迭代**,我们更推荐使用 Rspack + SWC 的方案。
|
9
|
+
|
10
|
+
请参考[「使用 Rspack」](/guides/advanced-features/rspack-start.html)了解更多。
|
11
|
+
|
12
|
+
:::
|
13
|
+
|
14
|
+
import SWC from '@site-docs/components/swc.mdx';
|
8
15
|
|
9
16
|
<SWC />
|
10
17
|
|
@@ -44,9 +51,9 @@ import SWC from '@modern-js/builder-doc/docs/zh/shared/swc.md';
|
|
44
51
|
|
45
52
|
### 在 Modern.js 框架中使用
|
46
53
|
|
47
|
-
Modern.js 框架对
|
54
|
+
Modern.js 框架对 SWC 插件进行了封装,你可以通过以下方式来使用:
|
48
55
|
|
49
|
-
import EnableSWC from '@
|
56
|
+
import EnableSWC from '@site-docs/components/enableSwc.mdx';
|
50
57
|
|
51
58
|
<EnableSWC />
|
52
59
|
|
@@ -278,7 +285,7 @@ boolean | {
|
|
278
285
|
#### extensions.pluginImport
|
279
286
|
|
280
287
|
:::tip
|
281
|
-
|
288
|
+
Modern.js 提供了 [source.transformImport](/configure/app/source/transform-import) 配置项,因此你不需要手动配置 `extensions.pluginImport`。
|
282
289
|
:::
|
283
290
|
|
284
291
|
移植自 [babel-plugin-import](https://github.com/umijs/babel-plugin-import),配置选项保持一致。
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# 概览
|
2
|
+
|
3
|
+
- [@modern-js/plugin-tailwindcss](/plugin/cli-plugins/plugin-tailwind):提供使用 Tailwind CSS 样式的能力。
|
4
|
+
- [@modern-js/plugin-bff](/plugin/cli-plugins/plugin-bff):提供 BFF 服务,一体化调用的能力。
|
5
|
+
- [@modern-js/plugin-ssg](/plugin/cli-plugins/plugin-bff):提供静态站点生成的能力。
|
6
|
+
- [@modern-js/plugin-swc](/plugin/cli-plugins/plugin-swc):提供 SWC 编译支持。
|
@@ -1,11 +1,28 @@
|
|
1
|
-
|
2
|
-
sidebar_position: 21
|
3
|
-
title: 使用 Rsbuild 插件
|
4
|
-
---
|
1
|
+
# 插件
|
5
2
|
|
6
|
-
|
3
|
+
在 Modern.js 中目前可以直接使用两种插件,分别是 Modern.js 框架插件和 Rsbuild 构建插件。
|
7
4
|
|
8
|
-
##
|
5
|
+
## Modern.js 框架插件
|
6
|
+
|
7
|
+
Modern.js 拥有自己的框架插件系统,你可以通过在 `modern.config.ts` 中配置 [`plugins`](/configure/app/plugins) 字段来使用 Modern.js 插件。
|
8
|
+
|
9
|
+
### 插件类型
|
10
|
+
|
11
|
+
框架插件可以细分成三类,分别是:
|
12
|
+
|
13
|
+
1. [CLI 插件](/plugin/cli-plugins):用于在应用执行 Modern.js 命令时,提供额外的功能。例如,添加命令、修改配置、监听文件等。大多数构建相关的能力都可以通过 CLI 插件来实现。
|
14
|
+
2. 服务端插件:用于在应用接受请求时,提供额外的功能。例如,添加中间件、修改请求响应等。
|
15
|
+
3. 运行时插件:用于在应用运行 React 代码时,提供额外的功能。例如,执行初始化行为,包裹 React 高阶组件等。
|
16
|
+
|
17
|
+
:::note
|
18
|
+
服务端插件和运行时插件即将正式对外开放。
|
19
|
+
:::
|
20
|
+
|
21
|
+
### 开发插件
|
22
|
+
|
23
|
+
如果你需要开发 Modern.js 框架插件,可以阅读 [Modern.js 插件系统](/plugin/plugin-system/introduction) 获取更多信息。
|
24
|
+
|
25
|
+
## Rsbuild 构建插件
|
9
26
|
|
10
27
|
Rsbuild 是 Modern.js 底层的构建工具,可通过添加 Rsbuild 插件修改默认的构建行为并添加各类额外功能,包括但不限于:
|
11
28
|
|
@@ -17,14 +34,18 @@ Rsbuild 是 Modern.js 底层的构建工具,可通过添加 Rsbuild 插件修
|
|
17
34
|
你可以在 `modern.config.ts` 中通过 `builderPlugins` 选项来注册 Rsbuild 插件,详见 [builderPlugins 构建插件](/configure/app/builder-plugins.html)。
|
18
35
|
|
19
36
|
:::tip
|
20
|
-
Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [Rsbuild](https://rsbuild.dev/)
|
37
|
+
Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [Rsbuild](https://rsbuild.dev/).
|
38
|
+
|
39
|
+
如果你当前版本低于 MAJOR_VERSION.46.0,可通过执行 `npx modern upgrade` 进行升级。
|
40
|
+
:::
|
21
41
|
|
22
|
-
|
42
|
+
:::info
|
43
|
+
可以阅读 [Rsbuild 官网 - 插件](https://rsbuild.dev/plugins/list/index) 来了解更多 Rsbuild 插件体系的内容。
|
23
44
|
:::
|
24
45
|
|
25
|
-
|
46
|
+
### 官方插件
|
26
47
|
|
27
|
-
|
48
|
+
#### 内置插件
|
28
49
|
|
29
50
|
以下是已在 Modern.js 中内置的 Rsbuild 官方插件,无需安装,即可启用:
|
30
51
|
|
@@ -44,10 +65,14 @@ Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [R
|
|
44
65
|
| [YAML 插件](https://github.com/rspack-contrib/rsbuild-plugin-yaml) | 用于引用 YAML 文件,并将其转换为 JavaScript 对象 | [TOML 文件](/guides/basic-features/static-assets/json-files.html#toml-文件) |
|
45
66
|
| [TOML 插件](https://github.com/rspack-contrib/rsbuild-plugin-toml) | 用于引用 TOML 文件,并将其转换为 JavaScript 对象 | [YAML 文件](/guides/basic-features/static-assets/json-files.html#yaml-文件) |
|
46
67
|
|
47
|
-
|
68
|
+
#### 未内置的插件
|
48
69
|
|
49
70
|
以下是未在 Modern.js 中内置的 Rsbuild 官方插件:
|
50
71
|
|
51
72
|
- [Image Compress 插件](https://github.com/rspack-contrib/rsbuild-plugin-image-compress):将项目中用到的图片资源进行压缩处理。
|
52
73
|
- [Stylus 插件](https://rsbuild.dev/zh/plugins/list/plugin-stylus):使用 Stylus 作为 CSS 预处理器。
|
53
74
|
- [UMD 插件](https://github.com/rspack-contrib/rsbuild-plugin-umd):用于构建 UMD 格式的产物。
|
75
|
+
|
76
|
+
import OtherPlugins from '@site-docs/components/other-plugins.mdx';
|
77
|
+
|
78
|
+
<OtherPlugins />
|
@@ -31,7 +31,7 @@ const myPlugin = {
|
|
31
31
|
};
|
32
32
|
```
|
33
33
|
|
34
|
-
另外,在插件中,允许配置与其他插件的执行顺序。详情可以参考[插件关系](/
|
34
|
+
另外,在插件中,允许配置与其他插件的执行顺序。详情可以参考[插件关系](/plugin/plugin-system/relationship)。
|
35
35
|
|
36
36
|
### 插件类型
|
37
37
|
|
@@ -115,7 +115,7 @@ import type { MyPluginHook } from 'xxx';
|
|
115
115
|
const myPlugin: CliPlugin<AppTools & { hooks: MyPluginHook }> = {};
|
116
116
|
```
|
117
117
|
|
118
|
-
详细说明,请参考 [扩展 Hook](/
|
118
|
+
详细说明,请参考 [扩展 Hook](/plugin/plugin-system/extend)。
|
119
119
|
|
120
120
|
### 插件配置项
|
121
121
|
|
@@ -158,7 +158,7 @@ export const myPlugin = (): CliPlugin => ({
|
|
158
158
|
});
|
159
159
|
```
|
160
160
|
|
161
|
-
插件 API 的详细说明,请参考 [Plugin API](/
|
161
|
+
插件 API 的详细说明,请参考 [Plugin API](/plugin/plugin-system/plugin-api)。
|
162
162
|
|
163
163
|
### 异步 setup
|
164
164
|
|