@modern-js/main-doc 2.69.5 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/en/{_meta.json → _nav.json} +5 -1
- package/docs/en/apis/app/commands.mdx +2 -3
- 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 +16 -12
- package/docs/en/components/build-output.mdx +45 -0
- 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 +38 -8
- package/docs/en/components/enable-ssg.mdx +48 -0
- package/docs/en/components/entry-scan-logic.mdx +7 -0
- package/docs/en/components/init-app.mdx +40 -17
- package/docs/en/components/international/install-command.mdx +9 -0
- package/docs/en/components/international/introduce.mdx +2 -0
- package/docs/en/components/module-federation.mdx +4 -4
- package/docs/en/components/new-entry-tooltip.mdx +0 -0
- 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-browserslist.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/dev/lazy-compilation.mdx +45 -0
- package/docs/en/configure/app/dev/server.mdx +103 -0
- package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
- package/docs/en/configure/app/html/app-icon.mdx +1 -23
- 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/performance/build-cache.mdx +0 -4
- 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/security/check-syntax.mdx +1 -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/decorators.mdx +4 -2
- package/docs/en/configure/app/source/entries.mdx +0 -2
- 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 +14 -248
- 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 +7 -17
- package/docs/en/guides/_meta.json +1 -2
- package/docs/en/guides/advanced-features/_meta.json +6 -0
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -7
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/docs/en/guides/advanced-features/bff/function.mdx +2 -6
- package/docs/en/guides/advanced-features/bff/sdk.mdx +3 -3
- 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 +437 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
- package/docs/en/guides/advanced-features/international/quick-start.mdx +154 -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 +7 -21
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/en/guides/advanced-features/rspack-start.mdx +2 -22
- package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -34
- 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 +5 -1
- package/docs/en/guides/basic-features/data/data-fetch.mdx +4 -4
- 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 +0 -8
- 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 +394 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +26 -62
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -6
- 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.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +24 -9
- 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 +8 -73
- package/docs/en/guides/get-started/tech-stack.mdx +7 -25
- 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/plugin/cli-plugins/api.mdx +4 -5
- package/docs/en/plugin/cli-plugins/migration.mdx +33 -48
- package/docs/en/plugin/introduction.mdx +39 -27
- 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 +68 -61
- package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
- package/docs/en/plugin/runtime-plugins/migration.mdx +29 -20
- 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 +2 -3
- 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-upload.mdx +8 -5
- package/docs/zh/components/build-output.mdx +45 -0
- 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 +37 -8
- package/docs/zh/components/enable-ssg.mdx +47 -0
- package/docs/zh/components/entry-scan-logic.mdx +7 -0
- package/docs/zh/components/init-app.mdx +40 -18
- package/docs/zh/components/international/install-command.mdx +8 -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/configure/_meta.json +7 -8
- package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
- package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
- package/docs/zh/configure/app/dev/server.mdx +104 -0
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
- package/docs/zh/configure/app/html/app-icon.mdx +1 -23
- 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/performance/build-cache.mdx +0 -4
- 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/security/check-syntax.mdx +1 -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/decorators.mdx +4 -4
- package/docs/zh/configure/app/source/entries.mdx +0 -2
- 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 +8 -18
- 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/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 +1 -1
- package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +4 -4
- 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 +441 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +149 -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 +7 -21
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
- package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +63 -35
- 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 +8 -5
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +6 -5
- 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 +0 -8
- 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 +413 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -5
- 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.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 +24 -9
- 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 -26
- 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 -32
- package/docs/zh/guides/troubleshooting/builder.mdx +3 -84
- 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 +809 -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/cli-plugins/api.mdx +4 -5
- package/docs/zh/plugin/cli-plugins/migration.mdx +30 -45
- package/docs/zh/plugin/introduction.mdx +36 -24
- 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 +45 -42
- package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
- package/docs/zh/plugin/runtime-plugins/migration.mdx +26 -17
- 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/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/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/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 -249
- package/docs/en/configure/app/tools/webpack.mdx +0 -305
- 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/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/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/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/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/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 -253
- package/docs/zh/configure/app/tools/webpack.mdx +0 -305
- 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/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/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/{zh/components/reduck-migration.mdx → en/components/international/platform-support.mdx} +0 -0
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# Use Models
|
|
2
|
-
|
|
3
|
-
## Using Models in Components
|
|
4
|
-
|
|
5
|
-
### Using as Global State
|
|
6
|
-
|
|
7
|
-
`useModel` can be used to obtain the State, Actions, and other information of the Model. When the State of the Model is modified by Actions, any other components that use the Model will automatically re-render.
|
|
8
|
-
|
|
9
|
-
In the counter example in [Quick Start](/guides/topic-detail/model/quick-start), we have demonstrated the use of `useModel` and will not repeat it here.
|
|
10
|
-
|
|
11
|
-
`useModel` supports passing multiple Models, and the State and Actions of multiple Models will be merged and returned as the result. For example:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
const fooModel = model('foo').define({
|
|
15
|
-
state: {
|
|
16
|
-
value: 1,
|
|
17
|
-
},
|
|
18
|
-
actions: {
|
|
19
|
-
add(state) {
|
|
20
|
-
state += 1;
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const barModel = model('bar').define({
|
|
26
|
-
state: {
|
|
27
|
-
title: 'bar',
|
|
28
|
-
},
|
|
29
|
-
actions: {
|
|
30
|
-
set(state, payload) {
|
|
31
|
-
state.title = payload;
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const [state, actions] = useModel([fooModel, barModel]);
|
|
37
|
-
// Or
|
|
38
|
-
const [state, actions] = useModel(fooModel, barModel);
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`state` and `actions` value are:
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
state = {
|
|
45
|
-
value: 1,
|
|
46
|
-
title: 'bar',
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
actions = {
|
|
50
|
-
add(state) {
|
|
51
|
-
state += 1;
|
|
52
|
-
},
|
|
53
|
-
set(state, payload) {
|
|
54
|
-
state.title = payload;
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
`useModel` also supports selector operations on State and Actions to filter or rename State and Actions. For example:
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
const fooModel = model('foo').define({
|
|
63
|
-
state: {
|
|
64
|
-
value: 1,
|
|
65
|
-
},
|
|
66
|
-
actions: {
|
|
67
|
-
add(state) {
|
|
68
|
-
state += 1;
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const barModel = model('bar').define({
|
|
74
|
-
state: {
|
|
75
|
-
value: 'bar',
|
|
76
|
-
},
|
|
77
|
-
actions: {
|
|
78
|
-
set(state, payload) {
|
|
79
|
-
state.value = payload;
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const [state, actions] = useModel(
|
|
85
|
-
[fooModel, barModel],
|
|
86
|
-
(fooState, barState) => ({
|
|
87
|
-
fooValue: fooState.value,
|
|
88
|
-
barValue: barState.value,
|
|
89
|
-
}), // stateSelector
|
|
90
|
-
(fooActions, barActions) => ({ add: fooActions.add }), // actionsSelector
|
|
91
|
-
);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
We use `stateSelector` to rename the states with the same name in `fooModel` and `barModel`. We use `actionsSelector` to filter out the Actions of `barModel`.
|
|
95
|
-
|
|
96
|
-
If only `actionsSelector` needs to be set, you can set `stateSelector` to `undefined` as a placeholder. For example:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
const [state, actions] = useModel(
|
|
100
|
-
[fooModel, barModel],
|
|
101
|
-
undefined,
|
|
102
|
-
(fooActions, barActions) => ({ add: fooActions.add }), // actionsSelector
|
|
103
|
-
);
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Using as Static State
|
|
107
|
-
|
|
108
|
-
`useStaticModel` can be used to obtain the Model and use the state of the Model as a static state. This ensures that the State accessed by the component is always the latest value, but the change of the Model's State does not cause the current component to re-render.
|
|
109
|
-
|
|
110
|
-
:::info
|
|
111
|
-
The usage of `useStaticModel` is exactly the same as `useModel`.
|
|
112
|
-
:::
|
|
113
|
-
|
|
114
|
-
Consider the following scenario: there is an Input component responsible for user input, and another Search component responsible for executing a search operation after the user input information is entered and the search button is clicked. We do not want the state changes during the user input process to cause Search to re-render. In this case, `useStaticModel` can be used:
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
import { useStaticModel } from '@modern-js/runtime/model';
|
|
118
|
-
|
|
119
|
-
function Search() {
|
|
120
|
-
// should not be destructured
|
|
121
|
-
const [state] = useStaticModel(searchModel);
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<div>
|
|
125
|
-
<button
|
|
126
|
-
onClick={async () => {
|
|
127
|
-
const result = await mockSearch(state.input);
|
|
128
|
-
console.log(result);
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
Search
|
|
132
|
-
</button>
|
|
133
|
-
</div>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
:::warning Caution
|
|
139
|
-
Do not destructure the `state` returned by `useStaticModel`. For example, changing it to the following code:
|
|
140
|
-
`const [{input}] = useStaticModel(searchModel);`
|
|
141
|
-
will always get the initial value of Input.
|
|
142
|
-
|
|
143
|
-
:::
|
|
144
|
-
|
|
145
|
-
`useStaticModel` is also suitable for use with animation libraries such as [react-three-fiber](https://github.com/pmndrs/react-three-fiber), because binding fast-changing states in animation component UI can easily cause [performance issues](https://docs.pmnd.rs/react-three-fiber/advanced/pitfalls#never-bind-fast-state-reactive). In this case, you can choose to use `useStaticModel`, which only subscribes to the State but does not cause the view component to re-render. Here is a simplified example:
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
function ThreeComponent() {
|
|
149
|
-
const [state, actions] = useStaticModel(modelA);
|
|
150
|
-
|
|
151
|
-
useFrame(() => {
|
|
152
|
-
state.value;
|
|
153
|
-
actions.setValue(1);
|
|
154
|
-
state.value;
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Using React's refs can also achieve similar effects. In fact, `useStaticModel` also uses refs internally. However, using `useStaticModel` directly helps decouple the state management logic from the component and converge it into the Model layer.
|
|
160
|
-
|
|
161
|
-
The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/static-model).
|
|
162
|
-
|
|
163
|
-
### Using as Local State
|
|
164
|
-
|
|
165
|
-
`useLocalModel` can be used to obtain the Model and use the state of the Model as local state. At this time, the change of the Model State only causes the current component to re-render, but does not cause other components that use the Model to re-render. The effect is similar to managing state through `useState` in React, but it can decouple the state management logic from the component and converge it into the Model layer.
|
|
166
|
-
|
|
167
|
-
:::info
|
|
168
|
-
The usage of `useLocalModel` is exactly the same as `useModel`.
|
|
169
|
-
:::
|
|
170
|
-
|
|
171
|
-
For example, we modify the code of the counter application and add a counter component `LocalCounter` with local state:
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
import { useLocalModel } from '@modern-js/runtime/model';
|
|
175
|
-
|
|
176
|
-
function LocalCounter() {
|
|
177
|
-
const [state, actions] = useLocalModel(countModel);
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<div>
|
|
181
|
-
<div>local counter: {state.value}</div>
|
|
182
|
-
<button onClick={() => actions.add()}>add</button>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
Click the `add` button of `Counter` and `LocalCounter` respectively, and the states of the two do not affect each other:
|
|
189
|
-
|
|
190
|
-

|
|
191
|
-
|
|
192
|
-
The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/local-model).
|
|
193
|
-
|
|
194
|
-
## Using outside of components
|
|
195
|
-
|
|
196
|
-
In actual business scenarios, sometimes we need to use Model outside of React components, such as accessing State and executing Actions in utility functions. At this time, we need to use the Store. The Store is a low-level concept that users generally cannot touch. It is responsible for storing and managing the entire application's state. Reduck's Store is based on Redux's Store implementation and adds Reduck-specific APIs, such as `use`.
|
|
197
|
-
|
|
198
|
-
First, call `useStore` in the component to obtain the `store` object used by the current application and mount it to a variable outside the component:
|
|
199
|
-
|
|
200
|
-
```ts
|
|
201
|
-
let store; // Reference to `store` object outside of the component
|
|
202
|
-
function setStore(s) {
|
|
203
|
-
store = s;
|
|
204
|
-
}
|
|
205
|
-
function getStore() {
|
|
206
|
-
return store;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function Counter() {
|
|
210
|
-
const [state] = useModel(countModel);
|
|
211
|
-
const store = useStore();
|
|
212
|
-
// Avoid unnecessary duplicate settings through `useMemo`
|
|
213
|
-
useMemo(() => {
|
|
214
|
-
setStore(store);
|
|
215
|
-
}, [store]);
|
|
216
|
-
|
|
217
|
-
return (
|
|
218
|
-
<div>
|
|
219
|
-
<div>counter: {state.value}</div>
|
|
220
|
-
</div>
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
You can obtain the Model object through `store.use`, and the usage of `store.use` is the same as `useModel`. Taking the counter application as an example, we perform an increment operation on the counter value every 1 second outside the component tree:
|
|
226
|
-
|
|
227
|
-
```ts
|
|
228
|
-
setInterval(() => {
|
|
229
|
-
const store = getStore();
|
|
230
|
-
const [, actions] = store.use(countModel);
|
|
231
|
-
actions.add();
|
|
232
|
-
}, 1000);
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/counter-model-outof-react).
|
|
236
|
-
|
|
237
|
-
:::info
|
|
238
|
-
If the Store object is manually created through [`createStore`](/apis/app/runtime/model/create-store), there is no need to obtain it through `useStore` in the component, and it can be used directly.
|
|
239
|
-
:::
|
|
240
|
-
|
|
241
|
-
:::info Additional Information
|
|
242
|
-
For detailed API definitions related to this section, please refer to [here](/apis/app/runtime/model/model_).
|
|
243
|
-
:::
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Using Reduck Separately
|
|
2
|
-
|
|
3
|
-
When integrating Reduck separately from Modern.js, the following modifications need to be made:
|
|
4
|
-
|
|
5
|
-
1. Install the Reduck related packages
|
|
6
|
-
|
|
7
|
-
Install the Reduck package in the project: `@modern-js-reduck/react`.
|
|
8
|
-
|
|
9
|
-
2. Import package names for API
|
|
10
|
-
|
|
11
|
-
When used in Modern.js, the package name for exporting Reduck API is: `@modern-js/runtime/model`. When using Reduck separately, the package name for exporting is: `@modern-js-reduck/react`.
|
|
12
|
-
|
|
13
|
-
3. Wrap the `Provider` component
|
|
14
|
-
|
|
15
|
-
Modern.js automatically wraps the [`Provider`](/apis/app/runtime/model/Provider) component used to inject the Reduck global Store on the entry component of the application. When using Reduck separately, this needs to be done manually.
|
|
16
|
-
|
|
17
|
-
Example:
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
// Root Component
|
|
21
|
-
const Root = () => {
|
|
22
|
-
return (
|
|
23
|
-
<Provider>
|
|
24
|
-
{/* Entry App */}
|
|
25
|
-
<App />
|
|
26
|
-
</Provider>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
4. Feature configuration
|
|
32
|
-
|
|
33
|
-
When used in Modern.js, Reduck features can be configured through [`runtime.state`](/configure/app/runtime/state). When used separately, configuration needs to be done through the `config` or `store` parameter of [`Provider`](/apis/app/runtime/model/Provider).
|
|
34
|
-
|
|
35
|
-
Example:
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
const Root = () => {
|
|
39
|
-
return (
|
|
40
|
-
{/* Close Redux DevTools */}
|
|
41
|
-
<Provider config={{ devTools: false }}>
|
|
42
|
-
<App />
|
|
43
|
-
</Provider>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
```
|
|
@@ -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"]
|