@modern-js/main-doc 2.69.7 → 3.0.0-alpha.1
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/docs/en/{_meta.json → _nav.json} +5 -1
- package/docs/en/apis/app/commands.mdx +8 -33
- package/docs/en/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/en/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/en/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/en/apis/app/runtime/_meta.json +0 -18
- package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/en/apis/app/runtime/router/router.mdx +1 -1
- package/docs/en/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/en/community/blog/v2-release-note.mdx +0 -2
- package/docs/en/community/contributing-guide.mdx +10 -12
- package/docs/en/components/bff-upload.mdx +19 -17
- package/docs/en/components/build-output.mdx +45 -0
- package/docs/en/components/bundler.mdx +1 -1
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/enable-bff-caution.mdx +2 -2
- package/docs/en/components/enable-bff.mdx +42 -8
- package/docs/en/components/enable-ssg.mdx +49 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/esbuild.mdx +2 -2
- package/docs/en/components/extend-bff-function.mdx +2 -4
- package/docs/en/components/hono.mdx +119 -0
- package/docs/en/components/init-app.mdx +40 -17
- 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 +23 -0
- package/docs/en/components/international/instance-code.mdx +26 -0
- package/docs/en/components/international/introduce.mdx +2 -0
- package/docs/en/components/module-federation.mdx +4 -4
- package/docs/en/components/nodeVersion.mdx +2 -6
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/components/ua-polyfill.mdx +16 -12
- package/docs/en/components/upgrade-config-deploy.mdx +0 -0
- package/docs/en/configure/_meta.json +7 -8
- package/docs/en/configure/app/bff/cross-project.mdx +24 -0
- package/docs/en/configure/app/builder-plugins.mdx +1 -2
- package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/server.mdx +211 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
- package/docs/en/configure/app/experiments/source-build.mdx +0 -1
- package/docs/en/configure/app/html/app-icon.mdx +1 -23
- package/docs/en/configure/app/output/assets-retry.mdx +1 -1
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/en/configure/app/output/filename.mdx +2 -4
- package/docs/en/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/en/configure/app/output/override-browserslist.mdx +6 -4
- package/docs/en/configure/app/output/source-map.mdx +6 -3
- package/docs/en/configure/app/output/ssg.mdx +12 -43
- package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
- package/docs/en/configure/app/output/temp-dir.mdx +3 -3
- package/docs/en/configure/app/performance/build-cache.mdx +1 -5
- package/docs/en/configure/app/performance/profile.mdx +1 -1
- package/docs/en/configure/app/plugins.mdx +1 -3
- 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 +2 -51
- package/docs/en/configure/app/runtime/router.mdx +0 -4
- package/docs/en/configure/app/security/check-syntax.mdx +1 -1
- package/docs/en/configure/app/security/sri.mdx +0 -1
- package/docs/en/configure/app/server/port.mdx +1 -21
- package/docs/en/configure/app/server/rsc.mdx +30 -0
- package/docs/en/configure/app/server/ssr.mdx +20 -9
- package/docs/en/configure/app/source/alias.mdx +1 -1
- package/docs/en/configure/app/source/decorators.mdx +4 -2
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/entries.mdx +0 -2
- package/docs/en/configure/app/source/include.mdx +2 -14
- package/docs/en/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/en/configure/app/source/transform-import.mdx +1 -59
- package/docs/en/configure/app/tools/bundler-chain.mdx +5 -5
- package/docs/en/configure/app/tools/css-extract.mdx +1 -1
- package/docs/en/configure/app/tools/dev-server.mdx +22 -256
- package/docs/en/configure/app/tools/html-plugin.mdx +3 -3
- package/docs/en/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -43
- package/docs/en/configure/app/usage.mdx +5 -27
- package/docs/en/guides/_meta.json +5 -1
- package/docs/en/guides/advanced-features/_meta.json +6 -0
- package/docs/en/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +2 -8
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -15
- package/docs/en/guides/advanced-features/bff/function.mdx +6 -10
- package/docs/en/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/en/guides/advanced-features/bff/sdk.mdx +20 -12
- package/docs/en/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/en/guides/advanced-features/build-performance.mdx +23 -26
- package/docs/en/guides/advanced-features/compatibility.mdx +53 -9
- package/docs/en/guides/advanced-features/international/_meta.json +11 -0
- package/docs/en/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/en/guides/advanced-features/international/api.mdx +400 -0
- package/docs/en/guides/advanced-features/international/basic.mdx +417 -0
- package/docs/en/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/en/guides/advanced-features/international/configuration.mdx +428 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +126 -0
- package/docs/en/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/en/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/en/guides/advanced-features/international.mdx +37 -0
- package/docs/en/guides/advanced-features/low-level.mdx +21 -16
- package/docs/en/guides/advanced-features/page-performance/code-split.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +8 -22
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +19 -12
- package/docs/en/guides/advanced-features/rspack-start.mdx +3 -23
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +121 -36
- package/docs/en/guides/advanced-features/web-server.mdx +82 -299
- package/docs/en/guides/basic-features/_meta.json +6 -1
- package/docs/en/guides/basic-features/css/css-in-js.mdx +46 -11
- package/docs/en/guides/basic-features/css/css-modules.mdx +5 -17
- package/docs/en/guides/basic-features/css/css.mdx +3 -3
- package/docs/en/guides/basic-features/css/tailwindcss.mdx +5 -89
- package/docs/en/guides/basic-features/data/data-cache.mdx +65 -77
- package/docs/en/guides/basic-features/data/data-fetch.mdx +19 -18
- package/docs/en/guides/basic-features/data/data-write.mdx +2 -2
- package/docs/en/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/en/guides/basic-features/debug/proxy.mdx +6 -17
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +5 -5
- package/docs/en/guides/basic-features/deploy.mdx +25 -18
- package/docs/en/guides/basic-features/env-vars.mdx +1 -1
- package/docs/en/guides/basic-features/html.mdx +1 -1
- package/docs/en/guides/basic-features/output-files.mdx +3 -3
- package/docs/en/guides/basic-features/render/_meta.json +1 -1
- package/docs/en/guides/basic-features/render/before-render.mdx +16 -23
- package/docs/en/guides/basic-features/render/overview.mdx +51 -0
- package/docs/en/guides/basic-features/render/rsc.mdx +399 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +26 -67
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -10
- package/docs/en/guides/basic-features/render/ssr.mdx +31 -31
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +29 -9
- 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.mdx → routes/routes.mdx} +7 -110
- package/docs/en/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/en/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/en/guides/basic-features/static-assets.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +27 -12
- package/docs/en/guides/concept/entries.mdx +139 -147
- package/docs/en/guides/get-started/glossary.mdx +0 -18
- package/docs/en/guides/get-started/introduction.mdx +1 -4
- package/docs/en/guides/get-started/quick-start.mdx +4 -71
- package/docs/en/guides/get-started/tech-stack.mdx +7 -27
- package/docs/en/guides/get-started/upgrade.mdx +30 -23
- package/docs/en/guides/topic-detail/_meta.json +0 -12
- package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/en/guides/topic-detail/module-federation/application.mdx +16 -15
- package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
- package/docs/en/guides/topic-detail/module-federation/introduce.mdx +5 -4
- package/docs/en/guides/topic-detail/module-federation/ssr.mdx +50 -2
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +10 -30
- package/docs/en/guides/troubleshooting/builder.mdx +3 -82
- package/docs/en/guides/troubleshooting/cli.mdx +6 -30
- package/docs/en/guides/troubleshooting/dependencies.mdx +22 -22
- package/docs/en/guides/upgrade/_meta.json +1 -0
- package/docs/en/guides/upgrade/config.mdx +936 -0
- package/docs/en/guides/upgrade/entry.mdx +463 -0
- package/docs/en/guides/upgrade/other.mdx +83 -0
- package/docs/en/guides/upgrade/overview.mdx +33 -0
- package/docs/en/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/en/guides/upgrade/web-server.mdx +91 -0
- package/docs/en/plugin/_meta.json +5 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/cli-plugins/api.mdx +17 -68
- package/docs/en/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/en/plugin/introduction.mdx +44 -44
- package/docs/en/plugin/official/_meta.json +0 -5
- package/docs/en/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/en/plugin/official/cli-plugins.mdx +0 -2
- package/docs/en/plugin/plugin-system.mdx +69 -62
- package/docs/en/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
- package/docs/en/plugin/server-plugins/_meta.json +1 -0
- package/docs/en/plugin/server-plugins/api.mdx +210 -1
- package/docs/en/plugin/server-plugins/life-cycle.mdx +41 -1
- package/docs/en/tutorials/_meta.json +0 -10
- package/docs/en/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/en/tutorials/foundations/introduction.mdx +9 -25
- package/docs/zh/{_meta.json → _nav.json} +10 -6
- package/docs/zh/apis/app/commands.mdx +8 -33
- package/docs/zh/apis/app/hooks/src/entry.mdx +1 -5
- package/docs/zh/apis/app/hooks/src/entry.server.mdx +4 -5
- package/docs/zh/apis/app/hooks/src/routes.mdx +2 -2
- package/docs/zh/apis/app/runtime/_meta.json +0 -18
- package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +2 -2
- package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +3 -2
- package/docs/zh/community/blog/v2-release-note.mdx +0 -2
- package/docs/zh/community/contributing-guide.mdx +10 -12
- 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 +8 -7
- package/docs/zh/components/build-output.mdx +45 -0
- package/docs/zh/components/bundler.mdx +1 -1
- package/docs/zh/components/debug-app.mdx +1 -1
- package/docs/zh/components/enable-bff-caution.mdx +1 -1
- package/docs/zh/components/enable-bff.mdx +41 -8
- package/docs/zh/components/enable-ssg.mdx +49 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/esbuild.mdx +2 -2
- package/docs/zh/components/extend-bff-function.mdx +2 -4
- package/docs/zh/components/hono.mdx +119 -0
- package/docs/zh/components/init-app.mdx +40 -18
- 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 +23 -0
- package/docs/zh/components/international/instance-code.mdx +26 -0
- package/docs/zh/components/international/introduce.mdx +2 -0
- package/docs/zh/components/international/platform-support.mdx +0 -0
- package/docs/zh/components/module-federation.mdx +4 -4
- package/docs/zh/components/new-entry-tooltip.mdx +0 -0
- package/docs/zh/components/nodeVersion.mdx +3 -7
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/components/self-route-example.mdx +3 -3
- package/docs/zh/components/ua-polyfill.mdx +11 -6
- package/docs/zh/components/upgrade-browserslist.mdx +0 -0
- package/docs/zh/components/upgrade-config-deploy.mdx +0 -0
- package/docs/zh/configure/_meta.json +7 -8
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/builder-plugins.mdx +1 -2
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/server.mdx +211 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
- package/docs/zh/configure/app/experiments/source-build.mdx +0 -1
- package/docs/zh/configure/app/html/app-icon.mdx +1 -23
- package/docs/zh/configure/app/output/assets-retry.mdx +1 -1
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/zh/configure/app/output/filename.mdx +2 -4
- package/docs/zh/configure/app/output/inline-scripts.mdx +1 -1
- package/docs/zh/configure/app/output/override-browserslist.mdx +3 -3
- package/docs/zh/configure/app/output/source-map.mdx +10 -3
- package/docs/zh/configure/app/output/ssg.mdx +13 -45
- package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
- package/docs/zh/configure/app/output/temp-dir.mdx +3 -3
- package/docs/zh/configure/app/performance/build-cache.mdx +1 -5
- package/docs/zh/configure/app/performance/profile.mdx +1 -1
- package/docs/zh/configure/app/plugins.mdx +1 -2
- 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 +2 -53
- package/docs/zh/configure/app/runtime/router.mdx +0 -4
- package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
- package/docs/zh/configure/app/security/sri.mdx +0 -1
- package/docs/zh/configure/app/server/port.mdx +2 -21
- package/docs/zh/configure/app/server/rsc.mdx +30 -0
- package/docs/zh/configure/app/server/ssr.mdx +21 -11
- package/docs/zh/configure/app/source/alias.mdx +1 -1
- package/docs/zh/configure/app/source/decorators.mdx +4 -4
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/configure/app/source/entries.mdx +0 -2
- package/docs/zh/configure/app/source/include.mdx +2 -16
- package/docs/zh/configure/app/source/main-entry-name.mdx +4 -4
- package/docs/zh/configure/app/source/transform-import.mdx +1 -59
- package/docs/zh/configure/app/tools/bundler-chain.mdx +6 -6
- package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
- package/docs/zh/configure/app/tools/dev-server.mdx +14 -248
- package/docs/zh/configure/app/tools/html-plugin.mdx +3 -2
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +0 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -43
- package/docs/zh/configure/app/usage.mdx +6 -28
- package/docs/zh/guides/_meta.json +5 -1
- package/docs/zh/guides/advanced-features/_meta.json +6 -1
- package/docs/zh/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/zh/guides/advanced-features/bff/cross-project.mdx +8 -16
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +25 -8
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +2 -16
- package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
- package/docs/zh/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +23 -16
- package/docs/zh/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/zh/guides/advanced-features/build-performance.mdx +23 -30
- package/docs/zh/guides/advanced-features/compatibility.mdx +44 -0
- package/docs/zh/guides/advanced-features/international/_meta.json +11 -0
- package/docs/zh/guides/advanced-features/international/advanced.mdx +193 -0
- package/docs/zh/guides/advanced-features/international/api.mdx +400 -0
- package/docs/zh/guides/advanced-features/international/basic.mdx +416 -0
- package/docs/zh/guides/advanced-features/international/best-practices.mdx +135 -0
- package/docs/zh/guides/advanced-features/international/configuration.mdx +432 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +126 -0
- package/docs/zh/guides/advanced-features/international/resource-loading.mdx +417 -0
- package/docs/zh/guides/advanced-features/international/routing.mdx +212 -0
- package/docs/zh/guides/advanced-features/international.mdx +36 -0
- package/docs/zh/guides/advanced-features/low-level.mdx +21 -16
- package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +3 -3
- package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +8 -22
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +19 -12
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +120 -37
- package/docs/zh/guides/advanced-features/web-server.mdx +79 -300
- package/docs/zh/guides/basic-features/_meta.json +6 -1
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +40 -5
- package/docs/zh/guides/basic-features/css/css-modules.mdx +6 -17
- package/docs/zh/guides/basic-features/css/css.mdx +2 -2
- package/docs/zh/guides/basic-features/css/tailwindcss.mdx +6 -90
- package/docs/zh/guides/basic-features/data/data-cache.mdx +55 -59
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +14 -16
- package/docs/zh/guides/basic-features/data/data-write.mdx +4 -4
- package/docs/zh/guides/basic-features/debug/mock.mdx +4 -1
- package/docs/zh/guides/basic-features/debug/proxy.mdx +4 -15
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +6 -6
- package/docs/zh/guides/basic-features/deploy.mdx +24 -20
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/html.mdx +2 -2
- package/docs/zh/guides/basic-features/output-files.mdx +3 -3
- package/docs/zh/guides/basic-features/render/_meta.json +1 -1
- package/docs/zh/guides/basic-features/render/before-render.mdx +17 -24
- package/docs/zh/guides/basic-features/render/overview.mdx +52 -0
- package/docs/zh/guides/basic-features/render/rsc.mdx +399 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -9
- package/docs/zh/guides/basic-features/render/ssr.mdx +34 -31
- package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +34 -14
- 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.mdx → routes/routes.mdx} +8 -114
- package/docs/zh/guides/basic-features/static-assets/json-files.mdx +21 -3
- package/docs/zh/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
- package/docs/zh/guides/basic-features/testing/cypress.mdx +5 -5
- package/docs/zh/guides/basic-features/testing/jest.mdx +12 -12
- package/docs/zh/guides/concept/builder.mdx +26 -11
- package/docs/zh/guides/concept/entries.mdx +95 -92
- package/docs/zh/guides/get-started/glossary.mdx +0 -18
- package/docs/zh/guides/get-started/introduction.mdx +1 -5
- package/docs/zh/guides/get-started/quick-start.mdx +5 -72
- package/docs/zh/guides/get-started/tech-stack.mdx +8 -28
- package/docs/zh/guides/get-started/upgrade.mdx +30 -23
- package/docs/zh/guides/topic-detail/_meta.json +0 -12
- package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +18 -16
- package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
- package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +4 -4
- package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +51 -5
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +11 -31
- package/docs/zh/guides/troubleshooting/builder.mdx +4 -85
- package/docs/zh/guides/troubleshooting/cli.mdx +6 -30
- package/docs/zh/guides/troubleshooting/dependencies.mdx +23 -23
- package/docs/zh/guides/upgrade/_meta.json +1 -0
- package/docs/zh/guides/upgrade/config.mdx +940 -0
- package/docs/zh/guides/upgrade/entry.mdx +463 -0
- package/docs/zh/guides/upgrade/other.md +90 -0
- package/docs/zh/guides/upgrade/overview.mdx +36 -0
- package/docs/zh/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/zh/guides/upgrade/web-server.md +93 -0
- package/docs/zh/plugin/_meta.json +5 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/cli-plugins/api.mdx +19 -70
- package/docs/zh/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/zh/plugin/introduction.mdx +40 -40
- package/docs/zh/plugin/official/_meta.json +0 -5
- package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
- package/docs/zh/plugin/official/cli-plugins.mdx +0 -2
- package/docs/zh/plugin/plugin-system.mdx +43 -51
- package/docs/zh/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
- package/docs/zh/plugin/server-plugins/_meta.json +1 -0
- package/docs/zh/plugin/server-plugins/api.mdx +210 -1
- package/docs/zh/plugin/server-plugins/life-cycle.mdx +41 -1
- package/docs/zh/tutorials/_meta.json +0 -10
- package/docs/zh/tutorials/examples/csr-auth.mdx +1 -1
- package/docs/zh/tutorials/foundations/introduction.mdx +8 -25
- package/i18n.json +0 -16
- package/package.json +12 -12
- package/rspress.config.ts +5 -8
- package/src/components/ContentCard/index.module.scss +11 -7
- package/src/components/ContentCard/index.tsx +1 -1
- package/src/components/FeatureLayout/index.module.css +1 -1
- package/src/components/Footer/index.tsx +2 -14
- package/src/components/Footer/styles.module.scss +5 -5
- package/src/components/FrameworkCode/index.tsx +605 -0
- package/src/components/ListCard/index.tsx +1 -1
- package/src/components/RandomMemberList/index.tsx +1 -1
- package/src/components/RsbuildLink/index.tsx +1 -1
- package/src/components/Sandpack/index.tsx +1 -1
- package/src/custom.scss +15 -0
- package/src/i18n/enUS.ts +2 -4
- package/src/i18n/index.ts +1 -1
- package/src/i18n/zhCN.ts +2 -4
- package/src/index.ts +2 -1
- package/src/pages/index.module.scss +59 -41
- package/src/pages/index.tsx +9 -24
- package/docs/en/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/en/apis/app/hooks/src/index_.mdx +0 -38
- package/docs/en/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/en/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/en/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/en/apis/app/runtime/core/create-app.mdx +0 -49
- package/docs/en/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/en/apis/app/runtime/core/use-module-apps.mdx +0 -140
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/en/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/en/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/en/apis/app/runtime/model/connect.mdx +0 -146
- package/docs/en/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/en/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/en/apis/app/runtime/model/handle-effect.mdx +0 -107
- package/docs/en/apis/app/runtime/model/model_.mdx +0 -198
- package/docs/en/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/en/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/en/apis/app/runtime/model/use-static-model.mdx +0 -51
- package/docs/en/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/en/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/en/apis/app/runtime/web-server/hook.mdx +0 -134
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +0 -113
- package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +0 -167
- package/docs/en/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/en/components/bff-proxy-principle.mdx +0 -1
- package/docs/en/components/builder.mdx +0 -3
- package/docs/en/components/create-bff-api-app.mdx +0 -25
- package/docs/en/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/en/components/enable-micro-frontend.mdx +0 -30
- package/docs/en/components/enableSwc.mdx +0 -17
- package/docs/en/components/global-proxy-config.mdx +0 -85
- package/docs/en/components/global-proxy.mdx +0 -29
- package/docs/en/components/package-manager.mdx +0 -11
- package/docs/en/components/reduck-notify.mdx +0 -27
- package/docs/en/components/reduck-tip.mdx +0 -8
- package/docs/en/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/en/configure/app/deploy/microFrontend.mdx +0 -53
- package/docs/en/configure/app/dev/port.mdx +0 -25
- package/docs/en/configure/app/dev/proxy.mdx +0 -9
- package/docs/en/configure/app/experiments/lazy-compilation.mdx +0 -106
- package/docs/en/configure/app/html/disable-html-folder.mdx +0 -46
- package/docs/en/configure/app/html/favicon-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/inject-by-entries.mdx +0 -36
- package/docs/en/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/en/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/en/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/en/configure/app/html/template-parameters-by-entries.mdx +0 -35
- package/docs/en/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/en/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/en/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/en/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/en/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/en/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/en/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/en/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/en/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/en/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/en/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/en/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/en/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/en/configure/app/runtime/master-app.mdx +0 -36
- package/docs/en/configure/app/runtime/state.mdx +0 -52
- package/docs/en/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/en/configure/app/source/enable-custom-entry.mdx +0 -68
- package/docs/en/configure/app/source/module-scopes.mdx +0 -72
- package/docs/en/configure/app/source/resolve-extension-prefix.mdx +0 -55
- package/docs/en/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/en/configure/app/tools/babel.mdx +0 -225
- package/docs/en/configure/app/tools/esbuild.mdx +0 -44
- package/docs/en/configure/app/tools/pug.mdx +0 -54
- package/docs/en/configure/app/tools/styled-components.mdx +0 -55
- package/docs/en/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/en/configure/app/tools/terser.mdx +0 -58
- package/docs/en/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/en/configure/app/tools/webpack-chain.mdx +0 -253
- package/docs/en/configure/app/tools/webpack.mdx +0 -309
- package/docs/en/guides/deprecated.md +0 -17
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -27
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +0 -290
- package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -298
- package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -26
- package/docs/en/guides/topic-detail/model/_meta.json +0 -14
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -85
- package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -148
- package/docs/en/guides/topic-detail/model/define-model.mdx +0 -62
- package/docs/en/guides/topic-detail/model/faq.mdx +0 -35
- package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -247
- package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/en/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/en/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -68
- package/docs/en/guides/topic-detail/model/use-model.mdx +0 -243
- package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/en/plugin/cli-plugins/migration.mdx +0 -98
- package/docs/en/plugin/official/cli-plugins/plugin-swc.mdx +0 -363
- package/docs/en/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/en/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/en/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -205
- package/docs/en/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/en/plugin/runtime-plugins/migration.mdx +0 -101
- package/docs/en/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/en/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/en/tutorials/first-app/c03-css.mdx +0 -324
- package/docs/en/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/en/tutorials/first-app/c05-loader.mdx +0 -87
- package/docs/en/tutorials/first-app/c06-model.mdx +0 -278
- package/docs/en/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/en/tutorials/first-app/c08-entries.mdx +0 -135
- package/docs/zh/apis/app/hooks/server/index_.mdx +0 -10
- package/docs/zh/apis/app/hooks/src/index_.mdx +0 -39
- package/docs/zh/apis/app/hooks/src/stories.mdx +0 -16
- package/docs/zh/apis/app/runtime/app/define-config.mdx +0 -67
- package/docs/zh/apis/app/runtime/core/bootstrap.mdx +0 -74
- package/docs/zh/apis/app/runtime/core/create-app.mdx +0 -35
- package/docs/zh/apis/app/runtime/core/use-loader.mdx +0 -89
- package/docs/zh/apis/app/runtime/core/use-module-apps.mdx +0 -179
- package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +0 -116
- package/docs/zh/apis/app/runtime/model/Provider.mdx +0 -36
- package/docs/zh/apis/app/runtime/model/auto-actions.mdx +0 -122
- package/docs/zh/apis/app/runtime/model/connect.mdx +0 -143
- package/docs/zh/apis/app/runtime/model/create-app.mdx +0 -75
- package/docs/zh/apis/app/runtime/model/create-store.mdx +0 -61
- package/docs/zh/apis/app/runtime/model/handle-effect.mdx +0 -108
- package/docs/zh/apis/app/runtime/model/model_.mdx +0 -201
- package/docs/zh/apis/app/runtime/model/use-local-model.mdx +0 -29
- package/docs/zh/apis/app/runtime/model/use-model.mdx +0 -89
- package/docs/zh/apis/app/runtime/model/use-static-model.mdx +0 -49
- package/docs/zh/apis/app/runtime/model/use-store.mdx +0 -26
- package/docs/zh/apis/app/runtime/ssr/pre-render.mdx +0 -96
- package/docs/zh/apis/app/runtime/web-server/hook.mdx +0 -136
- package/docs/zh/apis/app/runtime/web-server/middleware.mdx +0 -114
- package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +0 -165
- package/docs/zh/components/bff-proxy-path-rewrite.mdx +0 -16
- package/docs/zh/components/bff-proxy-principle.mdx +0 -1
- package/docs/zh/components/builder.mdx +0 -3
- package/docs/zh/components/create-bff-api-app.mdx +0 -25
- package/docs/zh/components/custom-router-micro-frontend.mdx +0 -40
- package/docs/zh/components/default-mwa-generate.mdx +0 -4
- package/docs/zh/components/enable-micro-frontend.mdx +0 -30
- package/docs/zh/components/enableSwc.mdx +0 -17
- package/docs/zh/components/global-proxy-config.mdx +0 -85
- package/docs/zh/components/global-proxy.mdx +0 -29
- package/docs/zh/components/package-manager.mdx +0 -11
- package/docs/zh/components/reduck-notify.mdx +0 -27
- package/docs/zh/components/reduck-tip.mdx +0 -8
- package/docs/zh/configure/app/auto-load-plugin.mdx +0 -66
- package/docs/zh/configure/app/deploy/microFrontend.mdx +0 -55
- package/docs/zh/configure/app/dev/port.mdx +0 -25
- package/docs/zh/configure/app/dev/proxy.mdx +0 -9
- package/docs/zh/configure/app/experiments/lazy-compilation.mdx +0 -105
- package/docs/zh/configure/app/html/disable-html-folder.mdx +0 -45
- package/docs/zh/configure/app/html/favicon-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/inject-by-entries.mdx +0 -37
- package/docs/zh/configure/app/html/meta-by-entries.mdx +0 -48
- package/docs/zh/configure/app/html/tags-by-entries.mdx +0 -44
- package/docs/zh/configure/app/html/template-by-entries.mdx +0 -33
- package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +0 -36
- package/docs/zh/configure/app/html/title-by-entries.mdx +0 -37
- package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +0 -21
- package/docs/zh/configure/app/output/disable-css-extract.mdx +0 -16
- package/docs/zh/configure/app/output/disable-filename-hash.mdx +0 -16
- package/docs/zh/configure/app/output/disable-minimize.mdx +0 -14
- package/docs/zh/configure/app/output/disable-node-polyfill.mdx +0 -22
- package/docs/zh/configure/app/output/disable-source-map.mdx +0 -31
- package/docs/zh/configure/app/output/enable-asset-fallback.mdx +0 -36
- package/docs/zh/configure/app/output/enable-inline-scripts.mdx +0 -22
- package/docs/zh/configure/app/output/enable-inline-styles.mdx +0 -22
- package/docs/zh/configure/app/output/enable-latest-decorators.mdx +0 -14
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/zh/configure/app/performance/transform-lodash.mdx +0 -52
- package/docs/zh/configure/app/runtime/master-app.mdx +0 -38
- package/docs/zh/configure/app/runtime/state.mdx +0 -52
- package/docs/zh/configure/app/source/disable-entry-dirs.mdx +0 -38
- package/docs/zh/configure/app/source/enable-custom-entry.mdx +0 -67
- package/docs/zh/configure/app/source/module-scopes.mdx +0 -72
- package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +0 -57
- package/docs/zh/configure/app/source/resolve-main-fields.mdx +0 -46
- package/docs/zh/configure/app/tools/babel.mdx +0 -224
- package/docs/zh/configure/app/tools/esbuild.mdx +0 -44
- package/docs/zh/configure/app/tools/pug.mdx +0 -54
- package/docs/zh/configure/app/tools/styled-components.mdx +0 -54
- package/docs/zh/configure/app/tools/tailwindcss.mdx +0 -98
- package/docs/zh/configure/app/tools/terser.mdx +0 -58
- package/docs/zh/configure/app/tools/ts-loader.mdx +0 -76
- package/docs/zh/configure/app/tools/webpack-chain.mdx +0 -257
- package/docs/zh/configure/app/tools/webpack.mdx +0 -309
- package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -154
- package/docs/zh/guides/deprecated.md +0 -19
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -26
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +0 -332
- package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -296
- package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
- package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -27
- package/docs/zh/guides/topic-detail/model/_meta.json +0 -14
- package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -88
- package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -147
- package/docs/zh/guides/topic-detail/model/define-model.mdx +0 -63
- package/docs/zh/guides/topic-detail/model/faq.mdx +0 -36
- package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -256
- package/docs/zh/guides/topic-detail/model/model-communicate.mdx +0 -217
- package/docs/zh/guides/topic-detail/model/performance.mdx +0 -167
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +0 -117
- package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -20
- package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -67
- package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -248
- package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
- package/docs/zh/plugin/cli-plugins/migration.mdx +0 -98
- package/docs/zh/plugin/official/cli-plugins/plugin-swc.mdx +0 -351
- package/docs/zh/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
- package/docs/zh/plugin/official/rsbuild-plugins/_meta.json +0 -1
- package/docs/zh/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -201
- package/docs/zh/plugin/official/rsbuild-plugins.mdx +0 -3
- package/docs/zh/plugin/runtime-plugins/migration.mdx +0 -101
- package/docs/zh/tutorials/first-app/c01-start.mdx +0 -99
- package/docs/zh/tutorials/first-app/c02-component.mdx +0 -60
- package/docs/zh/tutorials/first-app/c03-css.mdx +0 -323
- package/docs/zh/tutorials/first-app/c04-routes.mdx +0 -172
- package/docs/zh/tutorials/first-app/c05-loader.mdx +0 -89
- package/docs/zh/tutorials/first-app/c06-model.mdx +0 -274
- package/docs/zh/tutorials/first-app/c07-container.mdx +0 -281
- package/docs/zh/tutorials/first-app/c08-entries.mdx +0 -135
- /package/docs/en/components/{reduck-migration.mdx → auto-upgrade.mdx} +0 -0
- /package/docs/en/components/{router-legacy-tip.mdx → international/platform-support.mdx} +0 -0
- /package/docs/{zh/components/reduck-migration.mdx → en/components/new-entry-tooltip.mdx} +0 -0
- /package/docs/{zh/components/router-legacy-tip.mdx → en/components/upgrade-browserslist.mdx} +0 -0
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 2
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# SWC Plugin
|
|
6
|
-
|
|
7
|
-
:::warning
|
|
8
|
-
**The SWC feature in the current document is no longer maintained**, we recommend using the Rspack + SWC solution.
|
|
9
|
-
|
|
10
|
-
Please refer to [「Use Rspack」](guides/advanced-features/rspack-start) for more information.
|
|
11
|
-
|
|
12
|
-
:::
|
|
13
|
-
|
|
14
|
-
import SWC from '@site-docs-en/components/swc.mdx';
|
|
15
|
-
|
|
16
|
-
<SWC />
|
|
17
|
-
|
|
18
|
-
## Usage Scenarios
|
|
19
|
-
|
|
20
|
-
Before using the SWC plugin, please understand the scenarios and limitations of the SWC plugin to determine whether your project is suitable for using it.
|
|
21
|
-
|
|
22
|
-
### Rspack Scenario
|
|
23
|
-
|
|
24
|
-
If you are already using Rspack as the bundler in your project, then you do not need to use the SWC plugin, because Rspack uses SWC for transpiler and minifier by default, and the SWC compilation capabilities are available out of the box.
|
|
25
|
-
|
|
26
|
-
If you have configured the current SWC plugin when using Rspack, it will not have any effect.
|
|
27
|
-
|
|
28
|
-
### Babel Plugins
|
|
29
|
-
|
|
30
|
-
If your project requires the registration of some custom Babel plugins, you will not be able to register and use Babel plugins after using SWC, since it replaces Babel as the transpiler.
|
|
31
|
-
|
|
32
|
-
For most common Babel plugins, you can find corresponding replacements in SWC, such as:
|
|
33
|
-
|
|
34
|
-
- `@babel/preset-env`: use [presetEnv](#presetenv) instead.
|
|
35
|
-
- `@babel/preset-react`: use [presetReact](#presetreact) instead.
|
|
36
|
-
- `babel-plugin-import`: use [source.transformImport](/configure/app/source/transform-import) instead.
|
|
37
|
-
- `babel-plugin-lodash`: use [extensions.lodash](#extensionslodash) instead.
|
|
38
|
-
- `@emotion/babel-plugin`: use [extensions.emotion](#extensionsemotion) instead.
|
|
39
|
-
- `babel-plugin-styled-components`: use [extensions.styledComponents](#extensionsstyledcomponents) instead.
|
|
40
|
-
- `@babel/plugin-react-transform-remove-prop-types`: use [reactUtils.removePropTypes](#extensionsreactutils) instead.
|
|
41
|
-
|
|
42
|
-
If you use Babel plugin capabilities that are not yet supported by SWC, you will no longer be able to use them after switching to SWC compilation. You can give feedback via issues under the [swc-plugins](https://github.com/web-infra-dev/swc-plugins) repository and we will evaluate if built-in support is needed.
|
|
43
|
-
|
|
44
|
-
### Bundle Size
|
|
45
|
-
|
|
46
|
-
When using SWC for code minification instead of [terser](https://github.com/terser/terser) and [cssnano](https://github.com/cssnano/cssnano), there may be a small change in the bundle size. SWC outperforms terser for JavaScript code compression and slightly underperforms cssnano for CSS code compression.
|
|
47
|
-
|
|
48
|
-
For a detailed comparison between minifiers, see [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks).
|
|
49
|
-
|
|
50
|
-
## Quick Start
|
|
51
|
-
|
|
52
|
-
### Used in Modern.js framework
|
|
53
|
-
|
|
54
|
-
The Modern.js framework integrates the SWC plugin, and you can use it in the following ways:
|
|
55
|
-
|
|
56
|
-
import EnableSWC from '@site-docs-en/components/enableSwc.mdx';
|
|
57
|
-
|
|
58
|
-
<EnableSWC />
|
|
59
|
-
|
|
60
|
-
That's it! Now you can use SWC transformation and minification in your project.
|
|
61
|
-
|
|
62
|
-
## Config
|
|
63
|
-
|
|
64
|
-
- **Type:**
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
type PluginConfig =
|
|
68
|
-
| ObjPluginConfig
|
|
69
|
-
| ((
|
|
70
|
-
config: ObjPluginConfig,
|
|
71
|
-
utils: { mergeConfig: typeof lodash.merge; setConfig: typeof lodash.set },
|
|
72
|
-
) => ObjPluginConfig | void);
|
|
73
|
-
|
|
74
|
-
// SwcOptions is configurations of swc https://swc.rs/docs/configuration/compilation
|
|
75
|
-
interface ObjPluginConfig extends SwcOptions {
|
|
76
|
-
presetReact?: ReactConfig;
|
|
77
|
-
presetEnv?: EnvConfig;
|
|
78
|
-
jsMinify?: boolean | JsMinifyOptions;
|
|
79
|
-
cssMinify?: boolean | CssMinifyOptions;
|
|
80
|
-
extensions?: Extensions;
|
|
81
|
-
overrides?: Overrides;
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
The plugin configuration is based on the SWC configuration. In order to simplify some deep-level configurations and improve development experience, certain extensions have been made. When using object-based configuration, for example you can use `presetReact` and `presetEnv` to quickly configure React-related features and syntax downgrading. Other configurations will also be directly passed through to SWC.
|
|
86
|
-
|
|
87
|
-
When using function-based configuration, the default configuration generated by the plugin will be passed in, allowing you to modify it or return a new configuration.
|
|
88
|
-
|
|
89
|
-
### presetReact
|
|
90
|
-
|
|
91
|
-
- **Type:** [presetReact](https://swc.rs/docs/configuration/compilation#jsctransformreact) in SWC.
|
|
92
|
-
|
|
93
|
-
Ported from `@babel/preset-react`. The value you passed will be merged with default option.
|
|
94
|
-
|
|
95
|
-
By default, the plugin will set `runtime` field based on your `react` version, if `react` version is newer than 17.0.0, it will be set to `automatic`, otherwish `classic`.
|
|
96
|
-
|
|
97
|
-
### presetEnv
|
|
98
|
-
|
|
99
|
-
- **Type:** [presetEnv](https://swc.rs/docs/configuration/supported-browsers#options) in SWC.
|
|
100
|
-
|
|
101
|
-
Ported from `@babel/preset-env`. The value you passed will be merged with default option.
|
|
102
|
-
|
|
103
|
-
Default option is:
|
|
104
|
-
|
|
105
|
-
```ts
|
|
106
|
-
{
|
|
107
|
-
targets: '', // automatic get browserslist from your project, so you don't have to set this field
|
|
108
|
-
mode: 'usage',
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### jsMinify
|
|
113
|
-
|
|
114
|
-
- **Type:** `boolean` or [compress configuration](https://terser.org/docs/api-reference.html#compress-options).
|
|
115
|
-
- **Default:** `{ compress: {}, mangle: true }`.
|
|
116
|
-
|
|
117
|
-
If set it to `false`, then SWC minification will be disabled, if set it to `true` then will it applies default option. If you pass an object, then this object will be merged with default option.
|
|
118
|
-
|
|
119
|
-
### cssMinify
|
|
120
|
-
|
|
121
|
-
- **Type:**: `boolean`
|
|
122
|
-
- **Default:**: `true`
|
|
123
|
-
|
|
124
|
-
Whether enable to compress CSS files by SWC. If enabled, it will improve the performance of CSS compression, but the compression ratio will be slightly reduced.
|
|
125
|
-
|
|
126
|
-
### overrides
|
|
127
|
-
|
|
128
|
-
- **Type:**
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
interface Overrides extends SwcOptions {
|
|
132
|
-
test: RegExp;
|
|
133
|
-
include: RegExp[];
|
|
134
|
-
exclude: RegExp[];
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
- **Default:** `undefined`
|
|
139
|
-
|
|
140
|
-
Specify special configuration for specific modules. For example if you want to set ie 11 target for `foo.ts`:
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
{
|
|
144
|
-
test: /foo.ts/,
|
|
145
|
-
env: { targets: 'ie 11' }
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
This will merged into the default configuration, and do not affect other modules.
|
|
150
|
-
|
|
151
|
-
### extensions
|
|
152
|
-
|
|
153
|
-
- **Type:** `Object`
|
|
154
|
-
|
|
155
|
-
Some plugins ported from Babel.
|
|
156
|
-
|
|
157
|
-
#### extensions.reactUtils
|
|
158
|
-
|
|
159
|
-
- **Type:** `Object`
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
type ReactUtilsOptions = {
|
|
163
|
-
autoImportReact?: boolean;
|
|
164
|
-
removeEffect?: boolean;
|
|
165
|
-
removePropTypes?: {
|
|
166
|
-
mode?: 'remove' | 'unwrap' | 'unsafe-wrap';
|
|
167
|
-
removeImport?: boolean;
|
|
168
|
-
ignoreFilenames?: string[];
|
|
169
|
-
additionalLibraries?: string[];
|
|
170
|
-
classNameMatchers?: string[];
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Some little help utils for `React`.
|
|
176
|
-
|
|
177
|
-
**reactUtils.autoImportReact**
|
|
178
|
-
|
|
179
|
-
- **Type:** `boolean`
|
|
180
|
-
|
|
181
|
-
Automatically import `React` as global variable, eg: `import React from 'react'`.
|
|
182
|
-
Mostly used for generated `React.createElement`.
|
|
183
|
-
|
|
184
|
-
**reactUtils.removeEffect**
|
|
185
|
-
|
|
186
|
-
- **Type:** `boolean`
|
|
187
|
-
|
|
188
|
-
Remove `useEffect` call.
|
|
189
|
-
|
|
190
|
-
**reactUtils.removePropTypes**
|
|
191
|
-
|
|
192
|
-
- **Type:**
|
|
193
|
-
|
|
194
|
-
```ts
|
|
195
|
-
type RemovePropTypesOptions = {
|
|
196
|
-
mode?: 'remove' | 'unwrap' | 'unsafe-wrap';
|
|
197
|
-
removeImport?: boolean;
|
|
198
|
-
ignoreFilenames?: string[];
|
|
199
|
-
additionalLibraries?: string[];
|
|
200
|
-
classNameMatchers?: string[];
|
|
201
|
-
};
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Remove `React` runtime type checking. This is ported from [@babel/plugin-react-transform-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types), All the configurations remain the same.
|
|
205
|
-
|
|
206
|
-
#### extensions.lodash
|
|
207
|
-
|
|
208
|
-
- **Type:**
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
type LodashOptions = {
|
|
212
|
-
cwd?: string;
|
|
213
|
-
ids?: string[];
|
|
214
|
-
};
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
- **Default:**
|
|
218
|
-
|
|
219
|
-
```ts
|
|
220
|
-
const defaultOptions = {
|
|
221
|
-
cwd: process.cwd(),
|
|
222
|
-
ids: ['lodash', 'lodash-es'],
|
|
223
|
-
};
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
Ported from [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash), it is used to automatically convert references to Lodash into on-demand imports, thereby reducing the bundle size of Lodash code.
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
// Input
|
|
230
|
-
import { get, throttle } from 'lodash';
|
|
231
|
-
|
|
232
|
-
// Output
|
|
233
|
-
import get from 'lodash/get';
|
|
234
|
-
import throttle from 'lodash/throttle';
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
#### extensions.styledComponents
|
|
238
|
-
|
|
239
|
-
- **Type:**
|
|
240
|
-
|
|
241
|
-
```ts
|
|
242
|
-
boolean | {
|
|
243
|
-
// Enabled by default in development, disabled in production to reduce file size,
|
|
244
|
-
// setting this will override the default for all environments.
|
|
245
|
-
displayName?: boolean,
|
|
246
|
-
// Enabled by default.
|
|
247
|
-
ssr?: boolean,
|
|
248
|
-
// Enabled by default.
|
|
249
|
-
fileName?: boolean,
|
|
250
|
-
// Empty by default.
|
|
251
|
-
topLevelImportPaths?: string[],
|
|
252
|
-
// Defaults to ["index"].
|
|
253
|
-
meaninglessFileNames?: string[],
|
|
254
|
-
// Enabled by default.
|
|
255
|
-
cssProp?: boolean,
|
|
256
|
-
// Empty by default.
|
|
257
|
-
namespace?: string,
|
|
258
|
-
};
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
This is ported by Next.js team from [babel-plugin-styled-components](https://github.com/styled-components/babel-plugin-styled-components).
|
|
262
|
-
|
|
263
|
-
#### extensions.emotion
|
|
264
|
-
|
|
265
|
-
- **Type:**
|
|
266
|
-
|
|
267
|
-
```ts
|
|
268
|
-
boolean | {
|
|
269
|
-
// default is true. It will be disabled when build type is production.
|
|
270
|
-
sourceMap?: boolean,
|
|
271
|
-
// default is 'dev-only'.
|
|
272
|
-
autoLabel?: 'never' | 'dev-only' | 'always',
|
|
273
|
-
// default is '[local]'.
|
|
274
|
-
// Allowed values: `[local]` `[filename]` and `[dirname]`
|
|
275
|
-
// This option only works when autoLabel is set to 'dev-only' or 'always'.
|
|
276
|
-
// It allows you to define the format of the resulting label.
|
|
277
|
-
// The format is defined via string where variable parts are enclosed in square brackets [].
|
|
278
|
-
// For example labelFormat: "my-classname--[local]", where [local] will be replaced with the name of the variable the result is assigned to.
|
|
279
|
-
labelFormat?: string,
|
|
280
|
-
// default is undefined.
|
|
281
|
-
// This option allows you to tell the compiler what imports it should
|
|
282
|
-
// look at to determine what it should transform so if you re-export
|
|
283
|
-
// Emotion's exports, you can still use transforms.
|
|
284
|
-
importMap?: {
|
|
285
|
-
[packageName: string]: {
|
|
286
|
-
[exportName: string]: {
|
|
287
|
-
canonicalImport?: [string, string],
|
|
288
|
-
styledBaseImport?: [string, string],
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
This is ported by Next.js team from [@emotion/babel-plugin](https://www.npmjs.com/package/@emotion/babel-plugin)
|
|
296
|
-
|
|
297
|
-
#### extensions.pluginImport
|
|
298
|
-
|
|
299
|
-
:::tip
|
|
300
|
-
Modern.js provides the [source.transformImport](/configure/app/source/transform-import) config, so you don't need to configure `extensions.pluginImport` manually.
|
|
301
|
-
:::
|
|
302
|
-
|
|
303
|
-
Ported from [babel-plugin-import](https://github.com/umijs/babel-plugin-import), configurations are the same.
|
|
304
|
-
|
|
305
|
-
Some configurations can be passed in functions, such as `customName`, `customStyleName`. These JavaScript functions will be called by Rust through Node-API, which will cause some performance overhead.
|
|
306
|
-
|
|
307
|
-
Some simple function logic can be replaced by template language. Therefore, the configuration of function items such as `customName`, `customStyleName` can also be passed in strings as templates to replace functions and improve performance.
|
|
308
|
-
|
|
309
|
-
For example:
|
|
310
|
-
|
|
311
|
-
```ts
|
|
312
|
-
import { MyButton as Btn } from 'foo';
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Apply following configurations:
|
|
316
|
-
|
|
317
|
-
```ts
|
|
318
|
-
PluginSWC({
|
|
319
|
-
extensions: {
|
|
320
|
-
pluginImport: [
|
|
321
|
-
{
|
|
322
|
-
libraryName: 'foo',
|
|
323
|
-
customName: 'foo/es/{{ member }}',
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
`{{ member }}` will be replaced by the imported specifier:
|
|
331
|
-
|
|
332
|
-
```ts
|
|
333
|
-
import Btn from 'foo/es/MyButton';
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
Template `customName: 'foo/es/{{ member }}'` is the same as `` customName: (member) => `foo/es/${member}` ``, but template value has no performance overhead of Node-API.
|
|
337
|
-
|
|
338
|
-
The template used here is [handlebars](https://handlebarsjs.com). There are some useful builtin tools, Take the above import statement as an example:
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
PluginSWC({
|
|
342
|
-
extensions: {
|
|
343
|
-
pluginImport: [
|
|
344
|
-
{
|
|
345
|
-
libraryName: 'foo',
|
|
346
|
-
customName: 'foo/es/{{ kebabCase member }}',
|
|
347
|
-
},
|
|
348
|
-
],
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
Transformed to:
|
|
354
|
-
|
|
355
|
-
```ts
|
|
356
|
-
import Btn from 'foo/es/my-button';
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
In addition to `kebabCase`, there are `cameraCase`, `snakeCase`, `upperCase` and `lowerCase` can be used as well.
|
|
360
|
-
|
|
361
|
-
## Limitation
|
|
362
|
-
|
|
363
|
-
Do not support `@babel/plugin-transform-runtime` and other custom Babel plugins.
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Tailwind CSS Plugin
|
|
2
|
-
|
|
3
|
-
Tailwind CSS is a utility-first CSS framework and design system that allows you to quickly add commonly used styles to components while supporting flexible theme style extensions.
|
|
4
|
-
|
|
5
|
-
For more details, refer to [Using Tailwind CSS](/guides/basic-features/css/tailwindcss).
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
["plugin-esbuild"]
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 3
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Esbuild Plugin
|
|
6
|
-
|
|
7
|
-
:::warning
|
|
8
|
-
**The esbuild feature in the current document is no longer maintained**, we recommend using the Rspack + SWC solution, because Rspack + SWC provide better build performance, richer features, and better compatibility.
|
|
9
|
-
|
|
10
|
-
Please refer to [「Use Rspack」](guides/advanced-features/rspack-start) for more information.
|
|
11
|
-
|
|
12
|
-
:::
|
|
13
|
-
|
|
14
|
-
import Esbuild from '@site-docs-en/components/esbuild.mdx';
|
|
15
|
-
|
|
16
|
-
<Esbuild />
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
### Used in Modern.js framework
|
|
21
|
-
|
|
22
|
-
The Modern.js framework integrates the esbuild plugin by default, so you don't need to manually install and register the plugin, just use the [tools.esbuild](https://modernjs.dev/en/configure/app/tools/esbuild.html) configuration:
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
export default defineConfig({
|
|
26
|
-
tools: {
|
|
27
|
-
esbuild: {
|
|
28
|
-
loader: {
|
|
29
|
-
target: 'chrome61',
|
|
30
|
-
},
|
|
31
|
-
minimize: {
|
|
32
|
-
target: 'chrome61',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Config
|
|
40
|
-
|
|
41
|
-
The plugin will enable code transformation and minification by default. You can also customize the behavior of the plugin through configuration.
|
|
42
|
-
|
|
43
|
-
### loader
|
|
44
|
-
|
|
45
|
-
- **Type:**
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
type LoaderOptions = EsbuildLoaderOptions | false | undefined;
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
- **Default:**
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
const defaultOptions = {
|
|
55
|
-
target: 'es2015',
|
|
56
|
-
charset: builderConfig.output.charset,
|
|
57
|
-
};
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
This config is used to enable JavaScript/TypeScript transformation, which will replace babel-loader and ts-loader with esbuild-loader.
|
|
61
|
-
|
|
62
|
-
If you want to modify the options, you can check the [esbuild-loader documentation](https://github.com/privatenumber/esbuild-loader#loader).
|
|
63
|
-
|
|
64
|
-
#### Set JSX Format
|
|
65
|
-
|
|
66
|
-
When using esbuild for transformation, esbuild will read the `compilerOptions.jsx` field in `tsconfig.json` to determine which JSX syntax to use.
|
|
67
|
-
|
|
68
|
-
Therefore, you need to set the correct JSX syntax in `tsconfig.json`.
|
|
69
|
-
|
|
70
|
-
For example, React projects need to set `compilerOptions.jsx` to `react-jsx`:
|
|
71
|
-
|
|
72
|
-
```json
|
|
73
|
-
{
|
|
74
|
-
"compilerOptions": {
|
|
75
|
-
"jsx": "react-jsx"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### Set the target environment
|
|
81
|
-
|
|
82
|
-
Use the `target` option to set the target environment for transformation. `target` can be set directly to the JavaScript language version, such as `es6`, `es2020`; it can also be set to several target environments, each target environment is an environment name followed by a version number, such as `['chrome58', 'edge16' ,'firefox57']`. For a detailed introduction of the `target` option, please refer to [esbuild - target](https://esbuild.github.io/api/#target).
|
|
83
|
-
|
|
84
|
-
target supports setting to the following environments:
|
|
85
|
-
|
|
86
|
-
- chrome
|
|
87
|
-
- edge
|
|
88
|
-
- firefox
|
|
89
|
-
- ie
|
|
90
|
-
- ios
|
|
91
|
-
- node
|
|
92
|
-
- opera
|
|
93
|
-
- safari
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
builderPluginEsbuild({
|
|
97
|
-
loader: {
|
|
98
|
-
target: 'chrome61',
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
#### Disable transformation
|
|
104
|
-
|
|
105
|
-
Set `loader` to `false` to disable esbuild transformation, and Modern.js will continue to use Babel to transform the code.
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
builderPluginEsbuild({
|
|
109
|
-
loader: false,
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### minimize
|
|
114
|
-
|
|
115
|
-
- **Type:**
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
type MinimizeOptions = EsbuildMinifyOptions | false | undefined;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
- **Default:**
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
const defaultOptions = {
|
|
125
|
-
css: true,
|
|
126
|
-
target: 'es2015',
|
|
127
|
-
format: builderTarget === 'web' ? 'iife' : undefined,
|
|
128
|
-
};
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
This option is used to enable minification for JavaScript and CSS.
|
|
132
|
-
|
|
133
|
-
If you want to modify the options, you can check the [esbuild-loader documentation](https://github.com/privatenumber/esbuild-loader#minifyplugin).
|
|
134
|
-
|
|
135
|
-
#### Set the target environment
|
|
136
|
-
|
|
137
|
-
Use the `target` option to set the target environment for minification.
|
|
138
|
-
|
|
139
|
-
```ts
|
|
140
|
-
builderPluginEsbuild({
|
|
141
|
-
minimize: {
|
|
142
|
-
target: 'chrome61',
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Disable minification
|
|
148
|
-
|
|
149
|
-
Set `minimize` to `false` to disable esbuild minification, and Modern.js will continue to use Terser to minify the code.
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
builderPluginEsbuild({
|
|
153
|
-
minimize: false,
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Limitations
|
|
158
|
-
|
|
159
|
-
Although esbuild can significantly improve the build performance of existing webpack projects, it still has certain limitations that require special attention.
|
|
160
|
-
|
|
161
|
-
### Compatibility
|
|
162
|
-
|
|
163
|
-
As a compiler (i.e. `loader` capability), esbuild usually supports at least ES2015 (that is, ES6) syntax, and does not have the ability to automatically inject Polyfill.. If the production environment needs to downgrade to ES5 and below syntax, it is recommended to use SWC compilation.
|
|
164
|
-
|
|
165
|
-
You can specify the target syntax version by following config:
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
builderPluginEsbuild({
|
|
169
|
-
loader: {
|
|
170
|
-
target: 'es2015',
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
As a code minify tool (i.e. `minimize` capability), esbuild can minify the code in production environment, and usually supports ES2015 syntax at least.
|
|
176
|
-
|
|
177
|
-
If you set the compressed `target` to `es5`, you need to ensure that all codes have been compiled to ES5 codes, otherwise it will cause esbuild compilation error: `Transforming 'xxx' to the configured target environment ("es5") is not supported yet `.
|
|
178
|
-
|
|
179
|
-
Therefore, for projects that need to be compatible with ES5 and below syntax in the production environment, please be careful to enable the minimize capability, and it is recommended to use SWC compression.
|
|
180
|
-
|
|
181
|
-
You can specify the target syntax version by following config:
|
|
182
|
-
|
|
183
|
-
```js
|
|
184
|
-
builderPluginEsbuild({
|
|
185
|
-
minimize: {
|
|
186
|
-
target: 'es2015',
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
:::danger Caution
|
|
192
|
-
Projects that need to be compatible with ES5 and below syntax in the production environment need to be careful to turn on the minimize config.
|
|
193
|
-
:::
|
|
194
|
-
|
|
195
|
-
### Not support Babel plugins
|
|
196
|
-
|
|
197
|
-
As a compiler, the syntax transformation function of the original Babel plugins such as `babel-plugin-import` is not available after esbuild is turned on. And since the bottom layer of the plugin uses esbuild's `Transform API`, it does not support esbuild plugins to customize the compilation process.
|
|
198
|
-
|
|
199
|
-
If you have requirements related to Babel plugins such as `babel-plugin-import`, you can use the SWC plugin.
|
|
200
|
-
|
|
201
|
-
### Bundle Size
|
|
202
|
-
|
|
203
|
-
Although the compression speed of esbuild is faster, the compression ratio of esbuild is lower than that of terser, so the bundle size will increase, please use it according to the scenes. Generally speaking, esbuild is more suitable for scenes that are not sensitive to bundle size.
|
|
204
|
-
|
|
205
|
-
You can refer to [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks) for a detailed comparison between minimizers.
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# Plugin Migration
|
|
2
|
-
|
|
3
|
-
### Migration Background
|
|
4
|
-
|
|
5
|
-
The Modern.js plugin system is constantly evolving. To provide a clearer API and more powerful features, we've optimized the definition and usage of Runtime plugins. While the old plugin syntax is still partially compatible, we strongly recommend migrating according to this guide to take full advantage of the new plugin system.
|
|
6
|
-
|
|
7
|
-
### Migration Steps Overview
|
|
8
|
-
|
|
9
|
-
1. **Update Plugin Type Definition:** Replace the `Plugin` type with `RuntimePluginFuture`.
|
|
10
|
-
2. **Adjust Hook Invocation:** Migrate from the `return hooks` pattern to direct `api.xxx` calls.
|
|
11
|
-
3. **Replace Changed APIs:** Refer to the detailed API mapping table and update your code.
|
|
12
|
-
|
|
13
|
-
### Detailed Migration Steps
|
|
14
|
-
|
|
15
|
-
#### Update Plugin Type Definition
|
|
16
|
-
|
|
17
|
-
This is the first and most crucial step. It ensures that your plugin interacts correctly with the new plugin system.
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
// Old Syntax
|
|
21
|
-
import type { Plugin } from '@modern-js/runtime';
|
|
22
|
-
|
|
23
|
-
const plugin: Plugin = { ... };
|
|
24
|
-
|
|
25
|
-
// New Syntax
|
|
26
|
-
import type { RuntimePluginFuture } from '@modern-js/runtime';
|
|
27
|
-
|
|
28
|
-
const plugin: RuntimePluginFuture = { ... };
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**Explanation:** The `RuntimePluginFuture` type is the standard definition for new plugins. It provides better type inference and a clearer API structure.
|
|
32
|
-
|
|
33
|
-
#### Adjust Hook Invocation
|
|
34
|
-
|
|
35
|
-
The new plugin system recommends using the `api` object to directly call Hooks. This approach is more intuitive and easier to maintain.
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
// Old Syntax (return hooks)
|
|
39
|
-
{
|
|
40
|
-
setup: () => ({
|
|
41
|
-
beforeRender({ req, res }) { /*...*/ }
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// New Syntax (api.xxx)
|
|
46
|
-
{
|
|
47
|
-
setup: api => {
|
|
48
|
-
api.onBeforeRender(({ req, res }) => { /*...*/ })
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Explanation:** The `api` object provides all available Hooks and utility methods.
|
|
54
|
-
|
|
55
|
-
#### Replace Changed APIs
|
|
56
|
-
|
|
57
|
-
To maintain API consistency and clarity, we've adjusted the names of some APIs. Additionally, the `hoc` and `init` Hooks have been removed. Please use the new Hooks as replacements. The table below lists all changed APIs and their old and new counterparts:
|
|
58
|
-
|
|
59
|
-
| Old API | New API | Description |
|
|
60
|
-
| :------------ | :---------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
-
| `beforeRender` | `onBeforeRender` | Executed before application rendering. |
|
|
62
|
-
| `hoc` | `wrapRoot` | **Important Change:** Used to wrap the root component, achieving the functionality of a Higher-Order Component (HOC). Make sure to pass props to the original component. |
|
|
63
|
-
| `init` | `onBeforeRender` | **Important Change:** Execute initialization logic before application rendering. This replaces the previous `init` hook. Use `onBeforeRender` to perform any setup or initialization tasks that were previously done in `init`. This provides a single, consistent point for pre-rendering logic. |
|
|
64
|
-
|
|
65
|
-
**Explanation:**
|
|
66
|
-
- `onBeforeRender` replaces both the original `beforeRender` and `init`, used for pre-rendering logic and initialization, respectively.
|
|
67
|
-
- `wrapRoot` replaces `hoc` and is used to implement higher-order component functionality. It's crucial to pass props correctly when using `wrapRoot`.
|
|
68
|
-
|
|
69
|
-
**`wrapRoot` Usage Example:**
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
{
|
|
73
|
-
setup: api => {
|
|
74
|
-
api.wrapRoot((App) => {
|
|
75
|
-
const AppWrapper = (props) => {
|
|
76
|
-
// Ensure props are passed to the original component
|
|
77
|
-
return <Provider value={xx}><App {...props}/></Provider>;
|
|
78
|
-
};
|
|
79
|
-
return AppWrapper;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Frequently Asked Questions
|
|
86
|
-
|
|
87
|
-
**Q: Will my plugin still work correctly after migration?**
|
|
88
|
-
|
|
89
|
-
A: As long as you've correctly completed all the steps in this guide, your plugin should function properly. If you encounter any issues, please refer to the official Modern.js documentation or seek community support.
|
|
90
|
-
|
|
91
|
-
**Q: Do I have to migrate my plugin immediately?**
|
|
92
|
-
|
|
93
|
-
A: While the old plugin syntax remains partially compatible, we strongly recommend migrating as soon as possible. The new plugin system offers improved performance and richer functionality, making migration worthwhile in the long run.
|
|
94
|
-
|
|
95
|
-
**Q: Where can I find more information about the new plugin system?**
|
|
96
|
-
|
|
97
|
-
A: Please consult the official Modern.js documentation, especially the section on the plugin system. You can also refer to examples of other migrated plugins to understand best practices.
|
|
98
|
-
|
|
99
|
-
### Summary
|
|
100
|
-
|
|
101
|
-
With this detailed migration guide, we hope to help you smoothly transition your Runtime plugins to the new Modern.js plugin system. If you encounter any problems during the migration process, please don't hesitate to ask for assistance.
|