@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.100 → 3.5.0-ultramodern.102
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/bin/modern-bundle-docs.js +7 -0
- package/dist/cjs/bundleDocs.js +114 -0
- package/dist/esm/bundleDocs.mjs +62 -0
- package/dist/esm-node/bundleDocs.mjs +63 -0
- package/dist/types/bundleDocs.d.ts +20 -0
- package/docs/apis/app/{commands.mdx → commands.md} +35 -9
- package/docs/apis/app/hooks/api/{lambda.mdx → lambda.md} +2 -6
- package/docs/apis/app/hooks/config/{favicon.mdx → favicon.md} +1 -6
- package/docs/apis/app/hooks/config/{html.mdx → html.md} +1 -5
- package/docs/apis/app/hooks/config/{icon.mdx → icon.md} +1 -6
- package/docs/apis/app/hooks/config/{mock.mdx → mock.md} +1 -5
- package/docs/apis/app/hooks/config/{public.mdx → public.md} +0 -4
- package/docs/apis/app/hooks/config/{upload.mdx → upload.md} +3 -7
- package/docs/apis/app/hooks/{modern-config.mdx → modern-config.md} +1 -5
- package/docs/apis/app/hooks/server/{server.mdx → server.md} +1 -6
- package/docs/apis/app/hooks/{shared.mdx → shared.md} +0 -4
- package/docs/apis/app/hooks/src/{app.mdx → app.md} +2 -2
- package/docs/apis/app/hooks/src/{entry.mdx → entry.md} +1 -6
- package/docs/apis/app/hooks/src/{entry.server.mdx → entry.server.md} +0 -5
- package/docs/apis/app/hooks/src/{modern.runtime.mdx → modern.runtime.md} +1 -5
- package/docs/apis/app/hooks/src/{routes.mdx → routes.md} +3 -7
- package/docs/apis/app/hooks/src/{server.mdx → server.md} +1 -5
- package/docs/apis/app/runtime/bff/{use-backend-context.mdx → use-backend-context.md} +0 -3
- package/docs/apis/app/runtime/core/{create-root.mdx → create-root.md} +0 -3
- package/docs/apis/app/runtime/core/{render.mdx → render.md} +1 -4
- package/docs/apis/app/runtime/core/{runtime-context.mdx → runtime-context.md} +0 -4
- package/docs/apis/app/runtime/router/{router.mdx → router.md} +1 -6
- package/docs/apis/app/runtime/ssr/{no-ssr.mdx → no-ssr.md} +0 -3
- package/docs/apis/app/runtime/ssr/{renderStreaming.mdx → renderStreaming.md} +0 -4
- package/docs/apis/app/runtime/ssr/{renderString.mdx → renderString.md} +0 -4
- package/docs/apis/app/runtime/ssr/{requestHandler.mdx → requestHandler.md} +0 -4
- package/docs/apis/app/runtime/utility/{css-in-js.mdx → css-in-js.md} +0 -4
- package/docs/apis/app/runtime/utility/{head.mdx → head.md} +0 -3
- package/docs/apis/app/runtime/utility/{loadable.mdx → loadable.md} +0 -3
- package/docs/community/blog/2022-0708-updates.md +91 -0
- package/docs/community/blog/2022-0910-updates.md +76 -0
- package/docs/community/blog/overview.md +63 -0
- package/docs/community/blog/v2-release-note.md +238 -0
- package/docs/community/blog/v3-release-note.md +622 -0
- package/docs/community/contributing-guide.md +252 -0
- package/docs/community/releases.md +23 -0
- package/docs/community/showcase.md +24 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/{cross-project.mdx → cross-project.md} +4 -8
- package/docs/configure/app/bff/{effect.mdx → effect.md} +3 -7
- package/docs/configure/app/bff/{prefix.mdx → prefix.md} +3 -7
- package/docs/configure/app/bff/{runtime-framework.mdx → runtime-framework.md} +3 -7
- package/docs/configure/app/{builder-plugins.mdx → builder-plugins.md} +4 -8
- package/docs/configure/app/dev/{asset-prefix.mdx → asset-prefix.md} +4 -9
- package/docs/configure/app/dev/{before-start-url.mdx → before-start-url.md} +0 -4
- package/docs/configure/app/dev/{client.mdx → client.md} +3 -7
- package/docs/configure/app/dev/hmr.md +10 -0
- package/docs/configure/app/dev/{host.mdx → host.md} +0 -4
- package/docs/configure/app/dev/{https.mdx → https.md} +0 -4
- package/docs/configure/app/dev/{lazy-compilation.mdx → lazy-compilation.md} +2 -8
- package/docs/configure/app/dev/live-reload.md +10 -0
- package/docs/configure/app/dev/{mock-dir.mdx → mock-dir.md} +0 -4
- package/docs/configure/app/dev/progress-bar.md +19 -0
- package/docs/configure/app/dev/{server.mdx → server.md} +0 -4
- package/docs/configure/app/dev/{setup-middlewares.mdx → setup-middlewares.md} +3 -7
- package/docs/configure/app/dev/{start-url.mdx → start-url.md} +0 -5
- package/docs/configure/app/dev/{watch-files.mdx → watch-files.md} +3 -7
- package/docs/configure/app/dev/{write-to-disk.mdx → write-to-disk.md} +3 -7
- package/docs/configure/app/experiments/{source-build.mdx → source-build.md} +1 -3
- package/docs/configure/app/html/{app-icon.mdx → app-icon.md} +3 -7
- package/docs/configure/app/html/{crossorigin.mdx → crossorigin.md} +3 -7
- package/docs/configure/app/html/{favicon.mdx → favicon.md} +3 -7
- package/docs/configure/app/html/inject.md +10 -0
- package/docs/configure/app/html/{meta.mdx → meta.md} +3 -7
- package/docs/configure/app/html/{mount-id.mdx → mount-id.md} +3 -7
- package/docs/configure/app/html/output-structure.md +10 -0
- package/docs/configure/app/html/script-loading.md +10 -0
- package/docs/configure/app/html/{tags.mdx → tags.md} +3 -7
- package/docs/configure/app/html/{template-parameters.mdx → template-parameters.md} +3 -7
- package/docs/configure/app/html/template.md +10 -0
- package/docs/configure/app/html/title.md +18 -0
- package/docs/configure/app/output/asset-prefix.md +11 -0
- package/docs/configure/app/output/{assets-retry.mdx → assets-retry.md} +1 -5
- package/docs/configure/app/output/{charset.mdx → charset.md} +3 -7
- package/docs/configure/app/output/{clean-dist-path.mdx → clean-dist-path.md} +0 -4
- package/docs/configure/app/output/{convert-to-rem.mdx → convert-to-rem.md} +12 -16
- package/docs/configure/app/output/{copy.mdx → copy.md} +3 -7
- package/docs/configure/app/output/{css-modules.mdx → css-modules.md} +3 -7
- package/docs/configure/app/output/{data-uri-limit.mdx → data-uri-limit.md} +3 -7
- package/docs/configure/app/output/{disable-css-module-extension.mdx → disable-css-module-extension.md} +3 -7
- package/docs/configure/app/output/{disable-inline-runtime-chunk.mdx → disable-inline-runtime-chunk.md} +0 -4
- package/docs/configure/app/output/{disable-svgr.mdx → disable-svgr.md} +0 -4
- package/docs/configure/app/output/{disable-ts-checker.mdx → disable-ts-checker.md} +0 -4
- package/docs/configure/app/output/{dist-path.mdx → dist-path.md} +3 -11
- package/docs/configure/app/output/{enable-asset-manifest.mdx → enable-asset-manifest.md} +0 -4
- package/docs/configure/app/output/{enable-css-module-tsdeclaration.mdx → enable-css-module-tsdeclaration.md} +0 -4
- package/docs/configure/app/output/{enable-inline-route-manifests.mdx → enable-inline-route-manifests.md} +0 -4
- package/docs/configure/app/output/{externals.mdx → externals.md} +3 -7
- package/docs/configure/app/output/filename-hash.md +10 -0
- package/docs/configure/app/output/{filename.mdx → filename.md} +3 -7
- package/docs/configure/app/output/inject-styles.md +10 -0
- package/docs/configure/app/output/{inline-scripts.mdx → inline-scripts.md} +4 -8
- package/docs/configure/app/output/{inline-styles.mdx → inline-styles.md} +4 -8
- package/docs/configure/app/output/{legal-comments.mdx → legal-comments.md} +3 -7
- package/docs/configure/app/output/{minify.mdx → minify.md} +3 -7
- package/docs/configure/app/output/{override-browserslist.mdx → override-browserslist.md} +4 -8
- package/docs/configure/app/output/polyfill.md +12 -0
- package/docs/configure/app/output/{source-map.mdx → source-map.md} +3 -7
- package/docs/configure/app/output/{split-route-chunks.mdx → split-route-chunks.md} +0 -4
- package/docs/configure/app/output/{ssg.mdx → ssg.md} +3 -7
- package/docs/configure/app/output/{ssgByEntries.mdx → ssgByEntries.md} +1 -4
- package/docs/configure/app/output/{svg-default-export.mdx → svg-default-export.md} +0 -4
- package/docs/configure/app/output/{temp-dir.mdx → temp-dir.md} +0 -4
- package/docs/configure/app/performance/{build-cache.mdx → build-cache.md} +3 -7
- package/docs/configure/app/performance/{chunk-split.mdx → chunk-split.md} +3 -7
- package/docs/configure/app/performance/{dns-prefetch.mdx → dns-prefetch.md} +3 -7
- package/docs/configure/app/performance/preconnect.md +16 -0
- package/docs/configure/app/performance/{prefetch.mdx → prefetch.md} +3 -7
- package/docs/configure/app/performance/{preload.mdx → preload.md} +3 -7
- package/docs/configure/app/performance/{print-file-size.mdx → print-file-size.md} +3 -7
- package/docs/configure/app/performance/profile.md +10 -0
- package/docs/configure/app/performance/remove-console.md +10 -0
- package/docs/configure/app/performance/remove-moment-locale.md +10 -0
- package/docs/configure/app/performance/{rsdoctor.mdx → rsdoctor.md} +0 -4
- package/docs/configure/app/{plugins.mdx → plugins.md} +4 -4
- package/docs/configure/app/resolve/{alias-strategy.mdx → alias-strategy.md} +3 -7
- package/docs/configure/app/resolve/alias.md +9 -0
- package/docs/configure/app/resolve/{condition-names.mdx → condition-names.md} +3 -8
- package/docs/configure/app/resolve/{dedupe.mdx → dedupe.md} +3 -7
- package/docs/configure/app/resolve/{extensions.mdx → extensions.md} +3 -8
- package/docs/configure/app/runtime/{0-intro.mdx → 0-intro.md} +1 -4
- package/docs/configure/app/runtime/{plugins.mdx → plugins.md} +1 -1
- package/docs/configure/app/runtime/{router.mdx → router.md} +3 -7
- package/docs/configure/app/security/{check-syntax.mdx → check-syntax.md} +0 -4
- package/docs/configure/app/security/{nonce.mdx → nonce.md} +3 -7
- package/docs/configure/app/security/{sri.mdx → sri.md} +0 -4
- package/docs/configure/app/server/{base-url.mdx → base-url.md} +0 -4
- package/docs/configure/app/server/{port.mdx → port.md} +3 -7
- package/docs/configure/app/server/{public-routes.mdx → public-routes.md} +0 -4
- package/docs/configure/app/server/{routes.mdx → routes.md} +1 -5
- package/docs/configure/app/server/{rsc.mdx → rsc.md} +2 -6
- package/docs/configure/app/server/{ssr-by-entries.mdx → ssr-by-entries.md} +1 -5
- package/docs/configure/app/server/ssr.md +80 -0
- package/docs/configure/app/server/{tsconfig-path.mdx → tsconfig-path.md} +0 -4
- package/docs/configure/app/source/{alias-strategy.mdx → alias-strategy.md} +4 -8
- package/docs/configure/app/source/{alias.mdx → alias.md} +4 -8
- package/docs/configure/app/source/{config-dir.mdx → config-dir.md} +1 -5
- package/docs/configure/app/source/{decorators.mdx → decorators.md} +0 -4
- package/docs/configure/app/source/{define.mdx → define.md} +3 -7
- package/docs/configure/app/source/{disable-default-entries.mdx → disable-default-entries.md} +2 -6
- package/docs/{components/module-federation.mdx → configure/app/source/enable-async-entry.md} +47 -0
- package/docs/configure/app/source/{enable-async-pre-entry.mdx → enable-async-pre-entry.md} +0 -4
- package/docs/configure/app/source/{entries-dir.mdx → entries-dir.md} +0 -4
- package/docs/configure/app/source/{entries.mdx → entries.md} +1 -5
- package/docs/configure/app/source/{exclude.mdx → exclude.md} +4 -8
- package/docs/configure/app/source/{global-vars.mdx → global-vars.md} +0 -4
- package/docs/configure/app/source/{include.mdx → include.md} +4 -8
- package/docs/configure/app/source/{main-entry-name.mdx → main-entry-name.md} +0 -4
- package/docs/configure/app/source/{pre-entry.mdx → pre-entry.md} +3 -7
- package/docs/configure/app/source/{react-compiler.mdx → react-compiler.md} +0 -4
- package/docs/configure/app/source/{transform-import.mdx → transform-import.md} +3 -7
- package/docs/configure/app/{split-chunks.mdx → split-chunks.md} +3 -3
- package/docs/configure/app/tools/{autoprefixer.mdx → autoprefixer.md} +0 -4
- package/docs/configure/app/tools/{bundler-chain.mdx → bundler-chain.md} +0 -4
- package/docs/configure/app/tools/{css-extract.mdx → css-extract.md} +3 -7
- package/docs/configure/app/tools/{css-loader.mdx → css-loader.md} +3 -7
- package/docs/configure/app/tools/{dev-server.mdx → dev-server.md} +0 -4
- package/docs/configure/app/tools/{html-plugin.mdx → html-plugin.md} +3 -7
- package/docs/configure/app/tools/{less.mdx → less.md} +0 -4
- package/docs/configure/app/tools/{lightningcss-loader.mdx → lightningcss-loader.md} +3 -7
- package/docs/configure/app/tools/{minify-css.mdx → minify-css.md} +0 -4
- package/docs/configure/app/tools/{postcss.mdx → postcss.md} +3 -7
- package/docs/configure/app/tools/rspack.md +10 -0
- package/docs/configure/app/tools/{sass.mdx → sass.md} +0 -4
- package/docs/configure/app/tools/style-loader.md +10 -0
- package/docs/configure/app/tools/{swc.mdx → swc.md} +4 -8
- package/docs/configure/app/tools/{ts-checker.mdx → ts-checker.md} +20 -7
- package/docs/configure/app/{usage.mdx → usage.md} +1 -1
- package/docs/guides/advanced-features/bff/{cross-project.mdx → cross-project.md} +1 -2
- package/docs/guides/advanced-features/bff/{data-platform.mdx → data-platform.md} +0 -4
- package/docs/guides/advanced-features/bff/{extend-server.mdx → extend-server.md} +1 -1
- package/docs/guides/advanced-features/bff/frameworks.md +243 -0
- package/docs/guides/advanced-features/bff/{function.mdx → function.md} +60 -7
- package/docs/guides/advanced-features/bff/{operators.mdx → operators.md} +2 -77
- package/docs/{components/bff-upload.mdx → guides/advanced-features/bff/upload.md} +4 -0
- package/docs/guides/advanced-features/{bff.mdx → bff.md} +0 -4
- package/docs/guides/advanced-features/{build-performance.mdx → build-performance.md} +3 -7
- package/docs/guides/advanced-features/{compatibility.mdx → compatibility.md} +54 -15
- package/docs/guides/advanced-features/international/{advanced.mdx → advanced.md} +0 -4
- package/docs/guides/advanced-features/international/{api.mdx → api.md} +16 -20
- package/docs/guides/advanced-features/international/{best-practices.mdx → best-practices.md} +0 -4
- package/docs/guides/advanced-features/international/configuration.md +228 -0
- package/docs/guides/advanced-features/international/{locale-detection.mdx → locale-detection.md} +25 -29
- package/docs/guides/advanced-features/international/{quick-start.mdx → quick-start.md} +29 -13
- package/docs/guides/advanced-features/international/{resource-loading.mdx → resource-loading.md} +11 -15
- package/docs/guides/advanced-features/international/{routing.mdx → routing.md} +12 -16
- package/docs/guides/advanced-features/international.md +27 -0
- package/docs/guides/advanced-features/{low-level.mdx → low-level.md} +17 -21
- package/docs/guides/advanced-features/page-performance/{code-split.mdx → code-split.md} +2 -6
- package/docs/guides/advanced-features/page-performance/{inline-assets.mdx → inline-assets.md} +3 -7
- package/docs/guides/advanced-features/page-performance/{optimize-bundle.mdx → optimize-bundle.md} +4 -8
- package/docs/{components/internal-logger.mdx → guides/advanced-features/server-monitor/logger.md} +16 -0
- package/docs/guides/advanced-features/server-monitor/metrics.md +58 -0
- package/docs/guides/advanced-features/server-monitor/{monitors.mdx → monitors.md} +3 -3
- package/docs/guides/advanced-features/{source-build.mdx → source-build.md} +1 -5
- package/docs/guides/advanced-features/{web-server.mdx → web-server.md} +1 -9
- package/docs/guides/basic-features/{alias.mdx → alias.md} +3 -7
- package/docs/guides/basic-features/css/{css-in-js.mdx → css-in-js.md} +12 -9
- package/docs/guides/basic-features/css/{css-modules.mdx → css-modules.md} +3 -3
- package/docs/guides/basic-features/css/{css.mdx → css.md} +2 -6
- package/docs/guides/basic-features/data/{data-cache.mdx → data-cache.md} +1 -6
- package/docs/guides/basic-features/data/{data-fetch.mdx → data-fetch.md} +4 -8
- package/docs/guides/basic-features/data/{data-write.mdx → data-write.md} +6 -9
- package/docs/guides/basic-features/debug/{mock.mdx → mock.md} +1 -5
- package/docs/guides/basic-features/debug/{proxy.mdx → proxy.md} +1 -5
- package/docs/guides/basic-features/debug/{using-storybook.mdx → using-storybook.md} +20 -8
- package/docs/guides/basic-features/{deploy.mdx → deploy.md} +23 -13
- package/docs/guides/basic-features/{env-vars.mdx → env-vars.md} +8 -12
- package/docs/guides/basic-features/{html.mdx → html.md} +3 -7
- package/docs/guides/basic-features/{output-files.mdx → output-files.md} +6 -10
- package/docs/guides/basic-features/render/{before-render.mdx → before-render.md} +1 -1
- package/docs/guides/basic-features/render/overview.md +47 -0
- package/docs/guides/basic-features/render/{rsc.mdx → rsc.md} +12 -20
- package/docs/guides/basic-features/render/{ssg.mdx → ssg.md} +71 -10
- package/docs/guides/basic-features/render/{ssr-cache.mdx → ssr-cache.md} +5 -5
- package/docs/guides/basic-features/render/{ssr.mdx → ssr.md} +10 -12
- package/docs/guides/basic-features/render/{streaming-ssr.mdx → streaming-ssr.md} +5 -8
- package/docs/guides/basic-features/routes/{config-routes.mdx → config-routes.md} +10 -11
- package/docs/guides/basic-features/routes/{routes.mdx → routes.md} +8 -16
- package/docs/guides/basic-features/static-assets/{json-files.mdx → json-files.md} +0 -4
- package/docs/guides/basic-features/static-assets/{svg-assets.mdx → svg-assets.md} +3 -7
- package/docs/guides/basic-features/static-assets/{wasm-assets.mdx → wasm-assets.md} +1 -5
- package/docs/guides/basic-features/{static-assets.mdx → static-assets.md} +10 -14
- package/docs/guides/basic-features/testing/{playwright.mdx → playwright.md} +12 -3
- package/docs/guides/basic-features/testing/{rstest.mdx → rstest.md} +70 -11
- package/docs/guides/concept/{builder.mdx → builder.md} +3 -26
- package/docs/guides/concept/{entries.mdx → entries.md} +11 -17
- package/docs/guides/concept/{server.mdx → server.md} +3 -3
- package/docs/guides/get-started/{ai-coding-agents.mdx → ai-coding-agents.md} +4 -9
- package/docs/guides/get-started/glossary.md +63 -0
- package/docs/guides/get-started/{introduction.mdx → introduction.md} +1 -6
- package/docs/guides/get-started/quick-start.md +269 -0
- package/docs/guides/get-started/{tech-stack.mdx → tech-stack.md} +9 -15
- package/docs/guides/get-started/{ultramodern.mdx → ultramodern.md} +19 -24
- package/docs/guides/get-started/{upgrade.mdx → upgrade.md} +21 -12
- package/docs/guides/topic-detail/module-federation/{application.mdx → application.md} +3 -3
- package/docs/guides/topic-detail/module-federation/{deploy.mdx → deploy.md} +2 -2
- package/docs/guides/topic-detail/module-federation/{i18n.mdx → i18n.md} +14 -14
- package/docs/guides/topic-detail/module-federation/{introduce.mdx → introduce.md} +2 -3
- package/docs/guides/topic-detail/module-federation/{ssr.mdx → ssr.md} +12 -7
- package/docs/guides/topic-detail/module-federation/{usage.mdx → usage.md} +20 -3
- package/docs/guides/troubleshooting/{builder.mdx → builder.md} +10 -14
- package/docs/guides/troubleshooting/{cli.mdx → cli.md} +0 -4
- package/docs/guides/troubleshooting/{dependencies.mdx → dependencies.md} +7 -11
- package/docs/guides/troubleshooting/{hmr.mdx → hmr.md} +5 -9
- package/docs/guides/upgrade/{config.mdx → config.md} +8 -5
- package/docs/guides/upgrade/{entry.mdx → entry.md} +6 -6
- package/docs/guides/upgrade/{other.mdx → other.md} +8 -8
- package/docs/guides/upgrade/{overview.mdx → overview.md} +4 -4
- package/docs/guides/upgrade/{tailwindcss.mdx → tailwindcss.md} +0 -1
- package/docs/guides/upgrade/web-server.md +11 -11
- package/docs/index.md +33 -4
- package/docs/llms.txt +290 -0
- package/docs/plugin/cli-plugins/api.md +573 -0
- package/docs/plugin/cli-plugins/life-cycle.md +2 -0
- package/docs/plugin/introduction.md +152 -0
- package/docs/plugin/official/cli-plugins/plugin-bff.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-ssg.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-styled-components.md +5 -0
- package/docs/plugin/official/cli-plugins.md +4 -0
- package/docs/plugin/plugin-system.md +238 -0
- package/docs/plugin/runtime-plugins/api.md +194 -0
- package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
- package/docs/plugin/server-plugins/api.md +209 -0
- package/docs/plugin/server-plugins/life-cycle.md +13 -0
- package/docs/tutorials/examples/csr-auth.md +9 -0
- package/docs/tutorials/foundations/introduction.md +16 -0
- package/package.json +32 -14
- package/docs/_nav.json +0 -36
- package/docs/apis/_meta.json +0 -13
- package/docs/apis/app/hooks/_meta.json +0 -28
- package/docs/apis/app/hooks/config/_meta.json +0 -1
- package/docs/apis/app/runtime/_meta.json +0 -32
- package/docs/components/auto-upgrade.mdx +0 -0
- package/docs/components/build-output.mdx +0 -45
- package/docs/components/bundler.mdx +0 -3
- package/docs/components/convention-routing-motivation.mdx +0 -0
- package/docs/components/debug-app.mdx +0 -15
- package/docs/components/default-browserslist.mdx +0 -7
- package/docs/components/deploy-command.mdx +0 -14
- package/docs/components/deploy.mdx +0 -1
- package/docs/components/enable-bff-caution.mdx +0 -3
- package/docs/components/enable-bff.mdx +0 -56
- package/docs/components/enable-ssg.mdx +0 -49
- package/docs/components/entry-mode.mdx +0 -0
- package/docs/components/entry-scan-logic.mdx +0 -7
- package/docs/components/extend-bff-function.mdx +0 -3
- package/docs/components/hono.mdx +0 -120
- package/docs/components/init-app.mdx +0 -93
- package/docs/components/init-rspack-app.mdx +0 -5
- package/docs/components/internal-metrics.mdx +0 -20
- package/docs/components/international/custom-instance-code.mdx +0 -16
- package/docs/components/international/init-options-desc.mdx +0 -1
- package/docs/components/international/install-command.mdx +0 -10
- package/docs/components/international/instance-code.mdx +0 -16
- package/docs/components/international/introduce.mdx +0 -5
- package/docs/components/international/platform-support.mdx +0 -0
- package/docs/components/language-config.mdx +0 -9
- package/docs/components/micro-frontend.mdx +0 -6
- package/docs/components/micro-master-manifest-config.mdx +0 -15
- package/docs/components/micro-runtime-config.mdx +0 -17
- package/docs/components/new-entry-tooltip.mdx +0 -0
- package/docs/components/nodeVersion.mdx +0 -28
- package/docs/components/other-plugins.mdx +0 -0
- package/docs/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/components/output-distpath-warning.mdx +0 -0
- package/docs/components/output-polyfill-extend.mdx +0 -1
- package/docs/components/prerequisites.mdx +0 -18
- package/docs/components/release-note.mdx +0 -1
- package/docs/components/routes-practice.mdx +0 -0
- package/docs/components/rsbuild-config-tooltip.mdx +0 -5
- package/docs/components/rsbuild.mdx +0 -3
- package/docs/components/rsc-deploy-tip.mdx +0 -1
- package/docs/components/rspack.mdx +0 -3
- package/docs/components/rspackTip.mdx +0 -7
- package/docs/components/runtime-cli-config.mdx +0 -0
- package/docs/components/serve-command.mdx +0 -22
- package/docs/components/ssr-monitor.mdx +0 -3
- package/docs/components/stream-ssr-performance.mdx +0 -0
- package/docs/components/swc.mdx +0 -3
- package/docs/components/tech-stack-node-framework.mdx +0 -1
- package/docs/components/turtorials-example-list.mdx +0 -2
- package/docs/components/ua-polyfill.mdx +0 -44
- package/docs/components/upgrade-browserslist.mdx +0 -0
- package/docs/components/upgrade-config-deploy.mdx +0 -0
- package/docs/components/upgrade-faq.mdx +0 -0
- package/docs/configure/_meta.json +0 -78
- package/docs/configure/app/dev/hmr.mdx +0 -14
- package/docs/configure/app/dev/live-reload.mdx +0 -14
- package/docs/configure/app/dev/progress-bar.mdx +0 -23
- package/docs/configure/app/html/inject.mdx +0 -14
- package/docs/configure/app/html/output-structure.mdx +0 -14
- package/docs/configure/app/html/script-loading.mdx +0 -14
- package/docs/configure/app/html/template.mdx +0 -14
- package/docs/configure/app/html/title.mdx +0 -22
- package/docs/configure/app/output/asset-prefix.mdx +0 -18
- package/docs/configure/app/output/filename-hash.mdx +0 -14
- package/docs/configure/app/output/inject-styles.mdx +0 -14
- package/docs/configure/app/output/polyfill.mdx +0 -18
- package/docs/configure/app/performance/preconnect.mdx +0 -20
- package/docs/configure/app/performance/profile.mdx +0 -14
- package/docs/configure/app/performance/remove-console.mdx +0 -14
- package/docs/configure/app/performance/remove-moment-locale.mdx +0 -14
- package/docs/configure/app/resolve/alias.mdx +0 -13
- package/docs/configure/app/server/ssr.mdx +0 -85
- package/docs/configure/app/source/enable-async-entry.mdx +0 -54
- package/docs/configure/app/tools/rspack.mdx +0 -14
- package/docs/configure/app/tools/style-loader.mdx +0 -14
- package/docs/guides/_meta.json +0 -37
- package/docs/guides/advanced-features/_meta.json +0 -32
- package/docs/guides/advanced-features/bff/_meta.json +0 -10
- package/docs/guides/advanced-features/bff/frameworks.mdx +0 -131
- package/docs/guides/advanced-features/bff/upload.mdx +0 -7
- package/docs/guides/advanced-features/international/_meta.json +0 -10
- package/docs/guides/advanced-features/international/configuration.mdx +0 -222
- package/docs/guides/advanced-features/international.mdx +0 -29
- package/docs/guides/advanced-features/page-performance/_meta.json +0 -1
- package/docs/guides/advanced-features/server-monitor/_meta.json +0 -1
- package/docs/guides/advanced-features/server-monitor/logger.mdx +0 -19
- package/docs/guides/advanced-features/server-monitor/metrics.mdx +0 -41
- package/docs/guides/basic-features/_meta.json +0 -49
- package/docs/guides/basic-features/css/_meta.json +0 -1
- package/docs/guides/basic-features/data/_meta.json +0 -1
- package/docs/guides/basic-features/debug/_meta.json +0 -1
- package/docs/guides/basic-features/render/_meta.json +0 -1
- package/docs/guides/basic-features/render/overview.mdx +0 -51
- package/docs/guides/basic-features/routes/_meta.json +0 -1
- package/docs/guides/basic-features/static-assets/_meta.json +0 -1
- package/docs/guides/basic-features/testing/_meta.json +0 -1
- package/docs/guides/concept/_meta.json +0 -1
- package/docs/guides/get-started/_meta.json +0 -9
- package/docs/guides/get-started/glossary.mdx +0 -63
- package/docs/guides/get-started/quick-start.mdx +0 -92
- package/docs/guides/topic-detail/_meta.json +0 -8
- package/docs/guides/topic-detail/module-federation/_meta.json +0 -1
- package/docs/guides/troubleshooting/_meta.json +0 -1
- package/docs/guides/upgrade/_meta.json +0 -1
- package/scripts/copy-main-doc.mjs +0 -50
- /package/docs/guides/advanced-features/bff/{sdk.mdx → sdk.md} +0 -0
- /package/docs/guides/advanced-features/page-performance/{react-compiler.mdx → react-compiler.md} +0 -0
- /package/docs/guides/basic-features/css/{tailwindcss.mdx → tailwindcss.md} +0 -0
- /package/docs/guides/basic-features/debug/{rsdoctor.mdx → rsdoctor.md} +0 -0
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 6
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Browser Compatibility
|
|
6
2
|
|
|
7
3
|
## Browserslist Configuration
|
|
@@ -14,10 +10,12 @@ Modern.js supports setting the range of browsers that a web application needs to
|
|
|
14
10
|
|
|
15
11
|
When you create a new Modern.js project, a default `.browserslistrc` configuration is included, which indicates that JavaScript code will be compiled to ES6 format.
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
```yaml title=".browserslistrc"
|
|
14
|
+
chrome >= 87
|
|
15
|
+
edge >= 88
|
|
16
|
+
firefox >= 78
|
|
17
|
+
safari >= 14
|
|
18
|
+
```
|
|
21
19
|
|
|
22
20
|
When the `overrideBrowserslist` configuration is not specified in the project, this `.browserslistrc` file will take effect.
|
|
23
21
|
|
|
@@ -36,7 +34,7 @@ You can also configure browserslist by setting the `browserslist` field in the `
|
|
|
36
34
|
|
|
37
35
|
### Method 3: Configure via `output.overrideBrowserslist`
|
|
38
36
|
|
|
39
|
-
You can also configure browserslist by setting the [`output.overrideBrowserslist`](/configure/app/output/override-browserslist) field in the `modern.config.js` file:
|
|
37
|
+
You can also configure browserslist by setting the [`output.overrideBrowserslist`](/configure/app/output/override-browserslist.md) field in the `modern.config.js` file:
|
|
40
38
|
|
|
41
39
|
```js title="modern.config.js"
|
|
42
40
|
export default {
|
|
@@ -59,9 +57,6 @@ In most scenarios, it is recommended to prioritize using the `.browserslistrc` f
|
|
|
59
57
|
Please refer to [Rsbuild - Setting Browser Range](https://v2.rsbuild.rs/zh/guide/advanced/browserslist) for more information.
|
|
60
58
|
:::
|
|
61
59
|
|
|
62
|
-
import UpgradeBrowserslist from '@site-docs-en/components/upgrade-browserslist';
|
|
63
|
-
|
|
64
|
-
<UpgradeBrowserslist />
|
|
65
60
|
|
|
66
61
|
## Polyfill
|
|
67
62
|
|
|
@@ -72,10 +67,54 @@ Modern.js by default injects corresponding polyfill code at compile time through
|
|
|
72
67
|
By default, it will include the necessary polyfill code based on the project's Browserslist settings, so you generally do not need to worry about polyfill issues for your project source code and third-party dependencies. However, since some unused polyfill code is included, the final bundle size may increase.
|
|
73
68
|
|
|
74
69
|
:::info
|
|
75
|
-
For scenarios where certain third-party dependencies clearly do not require polyfills, you can set [`output.polyfill`](/configure/app/output/polyfill) to `usage`. This way, Babel will only inject polyfill code based on the syntax used in the code during compilation.
|
|
70
|
+
For scenarios where certain third-party dependencies clearly do not require polyfills, you can set [`output.polyfill`](/configure/app/output/polyfill.md) to `usage`. This way, Babel will only inject polyfill code based on the syntax used in the code during compilation.
|
|
76
71
|
|
|
77
72
|
:::
|
|
78
73
|
|
|
79
|
-
|
|
74
|
+
### 运行时按需 Polyfill
|
|
75
|
+
|
|
76
|
+
Modern.js 中还提供了基于浏览器 [UA](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/User-Agent) 信息的运行时按需 Polyfill 方案,相比于 Babel 优势如下:
|
|
77
|
+
|
|
78
|
+
- 不会插入到代码中,只根据访问页面的设备,按需下发 Polyfill 代码 ,减少整体代码体积。
|
|
79
|
+
- 相同浏览器会公用一份 Polyfill 代码。因此,随着项目越来越多,基于 UA 的 Polyfill 代码下发速度会越来越快,综合速度超过常规方案。
|
|
80
|
+
|
|
81
|
+
Modern.js 提供了 `@modern-js/plugin-polyfill` 插件来实现该功能,可以通过安装该插件来开启该功能:
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
```sh [npm]
|
|
85
|
+
npm install @modern-js/plugin-polyfill
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```sh [yarn]
|
|
89
|
+
yarn add @modern-js/plugin-polyfill
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```sh [pnpm]
|
|
93
|
+
pnpm add @modern-js/plugin-polyfill
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
然后在 `modern.config.ts` 中注册 Polyfill 插件:
|
|
97
|
+
|
|
98
|
+
```ts title="modern.config.ts"
|
|
99
|
+
import { polyfillPlugin } from '@modern-js/plugin-polyfill';
|
|
100
|
+
|
|
101
|
+
export default defineConfig({
|
|
102
|
+
plugins: [..., polyfillPlugin()],
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
配置 `output.polyfill` 为 `ua` 并且执行 `pnpm run build && pnpm run serve` 启动服务器后,访问页面可以看到 HTML 产物中包含如下脚本:
|
|
80
107
|
|
|
81
|
-
|
|
108
|
+
```js
|
|
109
|
+
<script src="/__polyfill__" crossorigin></script>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
在 Chrome 51 下访问页面可以看到 `http://localhost:8080/__polyfill__` 返回内容如下:
|
|
113
|
+
|
|
114
|
+

|
|
115
|
+
|
|
116
|
+
:::caution 注意
|
|
117
|
+
该功能只有在使用 Modern.js 内置的 Web Server 时才会生效。
|
|
118
|
+
|
|
119
|
+
如果有自定义模版的需求,请参考 [HTML 模板](/zh/guides/basic-features/html.md)。通过 `html.template` 或 `tools.html` 手动修改模版时,可能会导致该功能无法正确生效。
|
|
120
|
+
:::
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: API Reference
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# API Reference
|
|
6
2
|
|
|
7
3
|
## useModernI18n
|
|
@@ -10,15 +6,15 @@ title: API Reference
|
|
|
10
6
|
|
|
11
7
|
### Return Value
|
|
12
8
|
|
|
13
|
-
| Field
|
|
14
|
-
|
|
|
15
|
-
| `language`
|
|
16
|
-
| `changeLanguage`
|
|
17
|
-
| `supportedLanguages`
|
|
18
|
-
| `localisedUrls`
|
|
19
|
-
| `isLanguageSupported` | `(lang: string) => boolean`
|
|
20
|
-
| `isResourcesReady`
|
|
21
|
-
| `i18nInstance`
|
|
9
|
+
| Field | Type | Description |
|
|
10
|
+
| --------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
11
|
+
| `language` | `string` | Current language code |
|
|
12
|
+
| `changeLanguage` | `(lang: string) => Promise<void>` | Switches language |
|
|
13
|
+
| `supportedLanguages` | `string[]` | Supported language list, from `localeDetection.languages` |
|
|
14
|
+
| `localisedUrls` | `boolean \| Record<string, Record<string, string>>` | Localised URL mapping from `localeDetection.localisedUrls` |
|
|
15
|
+
| `isLanguageSupported` | `(lang: string) => boolean` | Checks whether a language is in the supported list |
|
|
16
|
+
| `isResourcesReady` | `boolean` | Whether translation resources for the current language have finished loading |
|
|
17
|
+
| `i18nInstance` | `I18nInstance` | i18next instance for advanced scenarios |
|
|
22
18
|
|
|
23
19
|
When `localePathRedirect` is enabled and `localisedUrls` is omitted, Modern.js keeps prefix-only paths such as `/en/about`. Translated path segments are enabled only by a non-empty `localisedUrls` map. Route generation validates every localisable path and every configured language only while that map is enabled.
|
|
24
20
|
|
|
@@ -88,13 +84,13 @@ A route link component with a locale prefix.
|
|
|
88
84
|
|
|
89
85
|
### Props
|
|
90
86
|
|
|
91
|
-
| Prop
|
|
92
|
-
|
|
|
93
|
-
| `to`
|
|
94
|
-
| `children`
|
|
95
|
-
| `replace`
|
|
96
|
-
| `state`
|
|
97
|
-
| Other Link props | -
|
|
87
|
+
| Prop | Type | Required | Description |
|
|
88
|
+
| ---------------- | ----------------- | -------- | ----------------------------------------------------------- |
|
|
89
|
+
| `to` | `string` | Yes | Target path. Do not include the locale prefix |
|
|
90
|
+
| `children` | `React.ReactNode` | Yes | Link content |
|
|
91
|
+
| `replace` | `boolean` | No | Uses `history.replace` instead of `push` |
|
|
92
|
+
| `state` | `any` | No | State passed to the target route |
|
|
93
|
+
| Other Link props | - | No | Passed to the active router link when a router is available |
|
|
98
94
|
|
|
99
95
|
### Usage
|
|
100
96
|
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
Plugin configuration is split between two files, each with a different responsibility:
|
|
4
|
+
|
|
5
|
+
| File | Purpose |
|
|
6
|
+
| ----------------------- | ------------------------------------------------ |
|
|
7
|
+
| `modern.config.ts` | Basic plugin settings, read during build/startup |
|
|
8
|
+
| `src/modern.runtime.ts` | i18next initialization options, read at runtime |
|
|
9
|
+
|
|
10
|
+
:::warning Function values can only be configured at runtime
|
|
11
|
+
`modern.config.ts` runs at build time and cannot serialize functions. SDK loaders, custom detection functions, and similar function values must be placed in `modern.runtime.ts`.
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
## Configuration Ownership
|
|
15
|
+
|
|
16
|
+
| Configuration | Where to configure |
|
|
17
|
+
| -------------------------------------------------------------- | ------------------- |
|
|
18
|
+
| `localeDetection` (language detection, path redirects, etc.) | `modern.config.ts` |
|
|
19
|
+
| `backend` (resource paths, SDK declaration, etc.) | `modern.config.ts` |
|
|
20
|
+
| `i18nInstance` | `modern.runtime.ts` |
|
|
21
|
+
| `initOptions` (`fallbackLng`, `ns`, and other i18next options) | `modern.runtime.ts` |
|
|
22
|
+
| The actual `backend.sdk` loader function | `modern.runtime.ts` |
|
|
23
|
+
|
|
24
|
+
## CLI Configuration
|
|
25
|
+
|
|
26
|
+
```ts title="modern.config.ts"
|
|
27
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
28
|
+
import { i18nPlugin } from '@modern-js/plugin-i18n';
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
plugins: [
|
|
32
|
+
appTools(),
|
|
33
|
+
i18nPlugin({
|
|
34
|
+
localeDetection: { ... },
|
|
35
|
+
backend: { ... },
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### localeDetection Options
|
|
42
|
+
|
|
43
|
+
| Field | Type | Default | Description |
|
|
44
|
+
| ------------------------ | --------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `languages` | `string[]` | `[]` | Supported language list |
|
|
46
|
+
| `fallbackLanguage` | `string` | `''` | Fallback language when detection fails |
|
|
47
|
+
| `localePathRedirect` | `boolean` | `false` | Handles URL locale prefix recognition, redirects, and switching. See [Routing Integration](/guides/advanced-features/international/routing.md#enable-locale-path-prefixes) |
|
|
48
|
+
| `localisedUrls` | `boolean \| Record<string, Record<string, string>>` | Prefix-only behavior | Localised route path map. Only a non-empty map enables translated path segments; omitted, `true`, `false`, and `{}` keep locale prefixes without translating path segments. |
|
|
49
|
+
| `i18nextDetector` | `boolean` | `false` | Enables the i18next detector (Cookie / Header, etc.) |
|
|
50
|
+
| `detection` | `LanguageDetectorOptions` | - | Detailed i18next detector configuration. See [Locale Detection](/guides/advanced-features/international/locale-detection.md) |
|
|
51
|
+
| `ignoreRedirectRoutes` | `string[] \| Function` | - | Routes that skip redirects. See [Locale Detection](/guides/advanced-features/international/locale-detection.md#ignoreredirectroutes) |
|
|
52
|
+
| `localeDetectionByEntry` | `Record<string, ...>` | - | Per-entry overrides for multiple entries |
|
|
53
|
+
|
|
54
|
+
**Example:**
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
i18nPlugin({
|
|
58
|
+
localeDetection: {
|
|
59
|
+
localePathRedirect: true,
|
|
60
|
+
i18nextDetector: true,
|
|
61
|
+
languages: ['zh', 'en', 'ja'],
|
|
62
|
+
fallbackLanguage: 'en',
|
|
63
|
+
detection: {
|
|
64
|
+
order: ['path', 'cookie', 'header'],
|
|
65
|
+
lookupCookie: 'i18next',
|
|
66
|
+
caches: ['cookie'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### backend Options
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
interface BackendOptions {
|
|
76
|
+
// Whether to enable backend resource loading.
|
|
77
|
+
// Automatically enabled when loadPath/addPath is configured, or when a locales directory exists.
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
|
|
80
|
+
// Decides which URL or local file to request for translations. Supports {{lng}} and {{ns}}.
|
|
81
|
+
// Default: '/locales/{{lng}}/{{ns}}.json'
|
|
82
|
+
loadPath?: string;
|
|
83
|
+
|
|
84
|
+
// Path for reporting missing translations (optional).
|
|
85
|
+
addPath?: string;
|
|
86
|
+
|
|
87
|
+
// Enables the custom backend SDK. The actual loader is provided in runtime config.
|
|
88
|
+
sdk?: boolean | string;
|
|
89
|
+
|
|
90
|
+
// Cache strategy for chained backend mode, effective when both loadPath and sdk are configured.
|
|
91
|
+
// 'none' - use local files and do not request the custom backend after a hit
|
|
92
|
+
// 'refresh' - continue requesting the custom backend and update cache, but not the page
|
|
93
|
+
// 'refreshAndUpdateStore' - continue requesting and update page text as well (default)
|
|
94
|
+
cacheHitMode?: 'none' | 'refresh' | 'refreshAndUpdateStore';
|
|
95
|
+
|
|
96
|
+
// Per-entry overrides for multiple-entry scenarios.
|
|
97
|
+
backendOptionsByEntry?: Record<string, BaseBackendOptions>;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**About the `sdk` field:** In `modern.config.ts`, set it to `true` to declare that the SDK backend is enabled. Provide the actual loader in `initOptions.backend.sdk` in `modern.runtime.ts`. See [Resource Loading -> Custom Backend](/guides/advanced-features/international/resource-loading.md#custom-backend).
|
|
102
|
+
|
|
103
|
+
**backend auto-enable rules:**
|
|
104
|
+
|
|
105
|
+
| Situation | Result |
|
|
106
|
+
| ---------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
107
|
+
| `loadPath` or `addPath` is configured | Automatically enabled. No need to write `enabled: true` |
|
|
108
|
+
| No backend is configured, but a `locales` directory exists and contains JSON files | Automatically enabled with the default `loadPath` |
|
|
109
|
+
| `enabled: false` is set explicitly | Disabled, and auto-detection is skipped |
|
|
110
|
+
|
|
111
|
+
Auto-detected directory locations, in priority order:
|
|
112
|
+
|
|
113
|
+
1. `{project root}/config/public/locales`
|
|
114
|
+
2. The `locales` subdirectory under the directory configured by `server.publicDir`
|
|
115
|
+
|
|
116
|
+
**Which backend should you choose?**
|
|
117
|
+
|
|
118
|
+
| Scenario | Recommended approach |
|
|
119
|
+
| ----------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
120
|
+
| Translation files are local to the project | Static file backend (configure `loadPath`; CSR/SSR switch automatically) |
|
|
121
|
+
| Translations come from a remote API or translation platform | Custom backend (configure `sdk: true`) |
|
|
122
|
+
| Local fallback + remote real-time updates | Chained backend (configure both `loadPath` and `sdk`) |
|
|
123
|
+
|
|
124
|
+
See [Resource Loading](/guides/advanced-features/international/resource-loading.md) for detailed usage.
|
|
125
|
+
|
|
126
|
+
## Runtime Configuration
|
|
127
|
+
|
|
128
|
+
```ts title="src/modern.runtime.ts"
|
|
129
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
|
130
|
+
import i18next from 'i18next';
|
|
131
|
+
|
|
132
|
+
const i18nInstance = i18next.createInstance();
|
|
133
|
+
|
|
134
|
+
export default defineRuntimeConfig({
|
|
135
|
+
i18n: {
|
|
136
|
+
i18nInstance, // Optional. An isolated instance is recommended.
|
|
137
|
+
initOptions: {
|
|
138
|
+
fallbackLng: 'en',
|
|
139
|
+
supportedLngs: ['zh', 'en'],
|
|
140
|
+
ns: ['translation'],
|
|
141
|
+
defaultNS: 'translation',
|
|
142
|
+
interpolation: {
|
|
143
|
+
escapeValue: false, // React already escapes text; disable this to avoid double escaping.
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### i18nInstance Configuration
|
|
151
|
+
|
|
152
|
+
If you need to use a custom i18n instance, provide it in the runtime configuration:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
|
156
|
+
import i18next from 'i18next';
|
|
157
|
+
|
|
158
|
+
// 创建自定义实例
|
|
159
|
+
const customI18n = i18next.createInstance({
|
|
160
|
+
// 自定义配置
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export default defineRuntimeConfig({
|
|
164
|
+
i18n: {
|
|
165
|
+
i18nInstance: customI18n,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### initOptions
|
|
171
|
+
|
|
172
|
+
支持所有 [i18next 初始化选项](https://www.i18next.com/overview/configuration-options),常用选项说明如下:
|
|
173
|
+
|
|
174
|
+
| Field | Description |
|
|
175
|
+
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| `fallbackLng` | Which language resources i18next falls back to when a translation key is missing. Supports strings, arrays, and maps (fallback chains) |
|
|
177
|
+
| `supportedLngs` | Language list supported by i18next |
|
|
178
|
+
| `ns` | Namespace list. Default is `['translation']` |
|
|
179
|
+
| `defaultNS` | Default namespace. Default is `'translation'` |
|
|
180
|
+
| `lng` | Forces the initial language. Usually not needed because the detector decides it |
|
|
181
|
+
|
|
182
|
+
`fallbackLng` supports fallback chains, which are useful for regional language degradation:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
initOptions: {
|
|
186
|
+
lng: 'zh-CN',
|
|
187
|
+
fallbackLng: {
|
|
188
|
+
'zh-CN': ['zh', 'en'], // If zh-CN is missing, try zh first, then en.
|
|
189
|
+
default: ['en'],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Custom Backend Function Configuration
|
|
195
|
+
|
|
196
|
+
The actual loader function for a custom backend must be provided in runtime configuration:
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
// modern.config.ts: only declare that it is enabled.
|
|
200
|
+
i18nPlugin({
|
|
201
|
+
backend: { sdk: true },
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// modern.runtime.ts: provide the actual function.
|
|
205
|
+
import type { I18nSdkLoader } from '@modern-js/plugin-i18n/runtime';
|
|
206
|
+
|
|
207
|
+
const myLoader: I18nSdkLoader = async options => {
|
|
208
|
+
if (options.lng && options.ns) {
|
|
209
|
+
const res = await fetch(`/api/i18n/${options.lng}/${options.ns}`);
|
|
210
|
+
return res.json();
|
|
211
|
+
}
|
|
212
|
+
return {};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export default defineRuntimeConfig({
|
|
216
|
+
i18n: {
|
|
217
|
+
initOptions: {
|
|
218
|
+
backend: { sdk: myLoader },
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
For complete usage, see [Resource Loading -> Custom Backend](/guides/advanced-features/international/resource-loading.md#custom-backend).
|
|
225
|
+
|
|
226
|
+
## Multiple Entries
|
|
227
|
+
|
|
228
|
+
Multiple-entry projects can override configuration per entry. See [Advanced Usage -> Multiple Entries](/guides/advanced-features/international/advanced.md#multiple-entries).
|
package/docs/guides/advanced-features/international/{locale-detection.mdx → locale-detection.md}
RENAMED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Locale Detection
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Locale Detection
|
|
6
2
|
|
|
7
3
|
Locale detection means automatically inferring which language to use when the user has not manually selected one. The plugin can detect language from URL path, Cookie, request headers, browser settings, and other sources, and these methods can be combined.
|
|
@@ -38,7 +34,7 @@ i18nPlugin({
|
|
|
38
34
|
});
|
|
39
35
|
```
|
|
40
36
|
|
|
41
|
-
After enabling path detection, you also need to configure a `[lang]` dynamic parameter in your routes. See [Routing Integration](
|
|
37
|
+
After enabling path detection, you also need to configure a `[lang]` dynamic parameter in your routes. See [Routing Integration](/guides/advanced-features/international/routing.md).
|
|
42
38
|
|
|
43
39
|
### i18next Detector
|
|
44
40
|
|
|
@@ -77,19 +73,19 @@ i18nPlugin({
|
|
|
77
73
|
|
|
78
74
|
## Detection Options (`detection`)
|
|
79
75
|
|
|
80
|
-
| Option
|
|
81
|
-
|
|
|
82
|
-
| `order`
|
|
83
|
-
| `lookupQuerystring`
|
|
84
|
-
| `lookupCookie`
|
|
85
|
-
| `lookupLocalStorage`
|
|
86
|
-
| `lookupSession`
|
|
87
|
-
| `lookupHeader`
|
|
88
|
-
| `lookupFromPathIndex`
|
|
89
|
-
| `caches`
|
|
90
|
-
| `cookieMinutes`
|
|
91
|
-
| `cookieExpirationDate` | `Date`
|
|
92
|
-
| `cookieDomain`
|
|
76
|
+
| Option | Type | Default | Description |
|
|
77
|
+
| ---------------------- | ------------------- | ------------------- | ------------------------------------------------------------- |
|
|
78
|
+
| `order` | `string[]` | See below | Detection order inside the i18next detector |
|
|
79
|
+
| `lookupQuerystring` | `string` | `'lng'` | Query parameter key, such as `?lng=en` |
|
|
80
|
+
| `lookupCookie` | `string` | `'i18next'` | Cookie key |
|
|
81
|
+
| `lookupLocalStorage` | `string` | `'i18nextLng'` | LocalStorage key (browser only) |
|
|
82
|
+
| `lookupSession` | `string` | - | SessionStorage key (browser only) |
|
|
83
|
+
| `lookupHeader` | `string` | `'accept-language'` | HTTP request header key |
|
|
84
|
+
| `lookupFromPathIndex` | `number` | `0` | Which URL path segment to start recognizing language from |
|
|
85
|
+
| `caches` | `false \| string[]` | - | Where to cache the detected language, such as `['cookie']` |
|
|
86
|
+
| `cookieMinutes` | `number` | `525600` (1 year) | Cookie expiration time in minutes |
|
|
87
|
+
| `cookieExpirationDate` | `Date` | - | Cookie expiration date. Takes precedence over `cookieMinutes` |
|
|
88
|
+
| `cookieDomain` | `string` | - | Cookie domain |
|
|
93
89
|
|
|
94
90
|
**Default detection order when `order` is not configured:**
|
|
95
91
|
|
|
@@ -99,17 +95,17 @@ i18nPlugin({
|
|
|
99
95
|
|
|
100
96
|
**Available `order` values:**
|
|
101
97
|
|
|
102
|
-
| Value
|
|
103
|
-
|
|
|
104
|
-
| `querystring`
|
|
105
|
-
| `cookie`
|
|
106
|
-
| `localStorage`
|
|
107
|
-
| `sessionStorage` | SessionStorage
|
|
108
|
-
| `navigator`
|
|
109
|
-
| `htmlTag`
|
|
110
|
-
| `header`
|
|
111
|
-
| `path`
|
|
112
|
-
| `subdomain`
|
|
98
|
+
| Value | Source | Limitation |
|
|
99
|
+
| ---------------- | ---------------------------------------- | ------------ |
|
|
100
|
+
| `querystring` | URL query parameter (`?lng=en`) | - |
|
|
101
|
+
| `cookie` | Cookie | - |
|
|
102
|
+
| `localStorage` | LocalStorage | Browser only |
|
|
103
|
+
| `sessionStorage` | SessionStorage | Browser only |
|
|
104
|
+
| `navigator` | Browser language settings | Browser only |
|
|
105
|
+
| `htmlTag` | `<html lang="...">` | Browser only |
|
|
106
|
+
| `header` | `Accept-Language` request header | - |
|
|
107
|
+
| `path` | URL path (requires `localePathRedirect`) | - |
|
|
108
|
+
| `subdomain` | Subdomain (`en.example.com`) | - |
|
|
113
109
|
|
|
114
110
|
## ignoreRedirectRoutes
|
|
115
111
|
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Quick Start
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Quick Start
|
|
6
2
|
|
|
7
3
|
This guide helps you quickly integrate internationalization into a Modern.js project.
|
|
8
4
|
|
|
9
5
|
## Install the Plugin
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
`i18next` 和 `react-i18next` 是 **Peer Dependency**,需要手动安装。
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
:::note 版本一致性
|
|
10
|
+
`@modern-js/plugin-i18n` 需要与项目中 `@modern-js/app-tools` 版本保持一致。
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm list @modern-js/app-tools
|
|
15
|
+
pnpm add @modern-js/plugin-i18n@<version> i18next react-i18next
|
|
16
|
+
```
|
|
14
17
|
|
|
15
18
|
## Basic Configuration
|
|
16
19
|
|
|
@@ -67,9 +70,22 @@ config/public/locales/
|
|
|
67
70
|
|
|
68
71
|
### Step 3: Configure Runtime Options
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
创建 `src/modern.runtime.ts`:
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
```ts
|
|
76
|
+
import { defineRuntimeConfig } from '@modern-js/runtime';
|
|
77
|
+
import i18next from 'i18next';
|
|
78
|
+
|
|
79
|
+
// i18next 默认导出一个全局单例,多个应用共用会互相影响。
|
|
80
|
+
// createInstance() 创建独立实例,确保每个应用有独立的语言状态。
|
|
81
|
+
const i18nInstance = i18next.createInstance();
|
|
82
|
+
|
|
83
|
+
export default defineRuntimeConfig({
|
|
84
|
+
i18n: {
|
|
85
|
+
i18nInstance,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
73
89
|
|
|
74
90
|
### Step 4: Use It in Components
|
|
75
91
|
|
|
@@ -105,8 +121,8 @@ function App() {
|
|
|
105
121
|
|
|
106
122
|
Choose what to read next based on your needs:
|
|
107
123
|
|
|
108
|
-
- **Want a URL structure like `/en/about`** -> [Routing Integration](
|
|
109
|
-
- **Need automatic language switching based on Cookie / Header** -> [Locale Detection](
|
|
110
|
-
- **Translation resources come from a remote service** -> [Resource Loading -> Custom Backend](
|
|
111
|
-
- **SSR scenarios** -> [Advanced Usage](
|
|
112
|
-
- **View all configuration options** -> [Configuration](
|
|
124
|
+
- **Want a URL structure like `/en/about`** -> [Routing Integration](/guides/advanced-features/international/routing.md)
|
|
125
|
+
- **Need automatic language switching based on Cookie / Header** -> [Locale Detection](/guides/advanced-features/international/locale-detection.md)
|
|
126
|
+
- **Translation resources come from a remote service** -> [Resource Loading -> Custom Backend](/guides/advanced-features/international/resource-loading.md#custom-backend)
|
|
127
|
+
- **SSR scenarios** -> [Advanced Usage](/guides/advanced-features/international/advanced.md)
|
|
128
|
+
- **View all configuration options** -> [Configuration](/guides/advanced-features/international/configuration.md)
|
package/docs/guides/advanced-features/international/{resource-loading.mdx → resource-loading.md}
RENAMED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Resource Loading
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Resource Loading
|
|
6
2
|
|
|
7
3
|
How translation files are loaded depends on where your translation resources are stored:
|
|
8
4
|
|
|
9
|
-
| Scenario
|
|
10
|
-
|
|
|
11
|
-
| Translation files are local to the project
|
|
12
|
-
| Translations come from a remote API or translation platform | Custom backend
|
|
13
|
-
| Both: local fallback + remote real-time updates
|
|
5
|
+
| Scenario | Loading method |
|
|
6
|
+
| ----------------------------------------------------------- | ------------------------------------------------------ |
|
|
7
|
+
| Translation files are local to the project | Static file backend (the default method in this guide) |
|
|
8
|
+
| Translations come from a remote API or translation platform | Custom backend |
|
|
9
|
+
| Both: local fallback + remote real-time updates | Chained backend |
|
|
14
10
|
|
|
15
11
|
## Static File Backend
|
|
16
12
|
|
|
@@ -111,7 +107,7 @@ interface I18nSdkLoadOptions {
|
|
|
111
107
|
}
|
|
112
108
|
```
|
|
113
109
|
|
|
114
|
-
When using a custom backend, translation resources are loaded asynchronously. You can use `isResourcesReady` to show a loading state before loading is complete. See [Best Practices -> Loading State Handling](
|
|
110
|
+
When using a custom backend, translation resources are loaded asynchronously. You can use `isResourcesReady` to show a loading state before loading is complete. See [Best Practices -> Loading State Handling](/guides/advanced-features/international/best-practices.md#loading-state-handling).
|
|
115
111
|
|
|
116
112
|
## Chained Backend
|
|
117
113
|
|
|
@@ -151,8 +147,8 @@ export default defineRuntimeConfig({
|
|
|
151
147
|
|
|
152
148
|
**`cacheHitMode` option** (controls how the two backends cooperate):
|
|
153
149
|
|
|
154
|
-
| Value
|
|
155
|
-
|
|
|
156
|
-
| `'none'`
|
|
157
|
-
| `'refresh'`
|
|
158
|
-
| `'refreshAndUpdateStore'` | Continue requesting the custom backend, update cache, and refresh page text (default)
|
|
150
|
+
| Value | Behavior |
|
|
151
|
+
| ------------------------- | ------------------------------------------------------------------------------------------- |
|
|
152
|
+
| `'none'` | Use local files after a successful local hit and do not request the custom backend |
|
|
153
|
+
| `'refresh'` | Continue requesting the custom backend and update cache, but do not update the current page |
|
|
154
|
+
| `'refreshAndUpdateStore'` | Continue requesting the custom backend, update cache, and refresh page text (default) |
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Routing Integration
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# Routing Integration
|
|
6
2
|
|
|
7
3
|
## Enable Locale Path Prefixes
|
|
@@ -26,13 +22,13 @@ i18nPlugin({
|
|
|
26
22
|
|
|
27
23
|
**Result:**
|
|
28
24
|
|
|
29
|
-
| Visited path | Result
|
|
30
|
-
|
|
|
31
|
-
| `/about`
|
|
32
|
-
| `/en/about`
|
|
33
|
-
| `/zh/about`
|
|
25
|
+
| Visited path | Result |
|
|
26
|
+
| ------------ | --------------------------------- |
|
|
27
|
+
| `/about` | Redirects to `/en/about` |
|
|
28
|
+
| `/en/about` | Visits normally, language is `en` |
|
|
29
|
+
| `/zh/about` | Visits normally, language is `zh` |
|
|
34
30
|
|
|
35
|
-
API and BFF prefixes are skipped automatically, including server API routes, the default `/api` BFF prefix when BFF is configured, and custom `bff.prefix` values. Those routes do not need locale prefixes or `localisedUrls` entries. For additional application paths that should not redirect, use `ignoreRedirectRoutes`. See [Locale Detection -> ignoreRedirectRoutes](
|
|
31
|
+
API and BFF prefixes are skipped automatically, including server API routes, the default `/api` BFF prefix when BFF is configured, and custom `bff.prefix` values. Those routes do not need locale prefixes or `localisedUrls` entries. For additional application paths that should not redirect, use `ignoreRedirectRoutes`. See [Locale Detection -> ignoreRedirectRoutes](/guides/advanced-features/international/locale-detection.md#ignoreredirectroutes).
|
|
36
32
|
|
|
37
33
|
## Localised URL Paths
|
|
38
34
|
|
|
@@ -69,11 +65,11 @@ i18nPlugin({
|
|
|
69
65
|
|
|
70
66
|
**Result:**
|
|
71
67
|
|
|
72
|
-
| Visited path
|
|
73
|
-
|
|
|
74
|
-
| `/terms-of-service`
|
|
75
|
-
| `/cs/terms-of-service`
|
|
76
|
-
| `/cs/podminky-pouzivani` | Visits normally, language is `cs`
|
|
68
|
+
| Visited path | Result |
|
|
69
|
+
| ------------------------ | ------------------------------------- |
|
|
70
|
+
| `/terms-of-service` | Redirects to `/en/terms-of-service` |
|
|
71
|
+
| `/cs/terms-of-service` | Redirects to `/cs/podminky-pouzivani` |
|
|
72
|
+
| `/cs/podminky-pouzivani` | Visits normally, language is `cs` |
|
|
77
73
|
|
|
78
74
|
Set `localisedUrls: false` as the escape hatch when a preset, shared config, or generated metadata would otherwise provide a map but this entry should keep locale prefixes without translated path segments.
|
|
79
75
|
|
|
@@ -174,4 +170,4 @@ function Navigation() {
|
|
|
174
170
|
<I18nLink to="/en/about">About</I18nLink>
|
|
175
171
|
```
|
|
176
172
|
|
|
177
|
-
`I18nLink` uses the active Modern.js router. In React Router projects it renders the React Router `Link`; in TanStack Router projects it navigates through TanStack Router. For the full Props type, see [API Reference](
|
|
173
|
+
`I18nLink` uses the active Modern.js router. In React Router projects it renders the React Router `Link`; in TanStack Router projects it navigates through TanStack Router. For the full Props type, see [API Reference](/guides/advanced-features/international/api.md#i18nlink-component).
|