@modern-js/main-doc 2.3.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/LICENSE +0 -123
- package/README.md +26 -0
- package/en/apis/app/commands/_category_.json +1 -4
- package/en/apis/app/commands/new.mdx +11 -10
- package/en/apis/app/commands/test.mdx +1 -1
- package/en/apis/app/hooks/_category_.json +1 -4
- package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
- package/en/apis/app/hooks/api/functions/api.mdx +1 -1
- package/en/apis/app/hooks/server/index_.mdx +2 -1
- package/en/apis/app/hooks/src/pages.mdx +7 -7
- package/en/apis/app/hooks/src/routes.mdx +1 -1
- package/en/apis/app/runtime/_category_.json +1 -5
- package/en/apis/app/runtime/app/define-config.mdx +2 -2
- package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
- package/en/apis/app/runtime/core/create-app.mdx +2 -2
- package/en/apis/app/runtime/core/use-loader.mdx +4 -4
- package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
- package/en/apis/app/runtime/model/Provider.mdx +2 -2
- package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
- package/en/apis/app/runtime/model/connect.mdx +5 -5
- package/en/apis/app/runtime/model/create-app.mdx +9 -9
- package/en/apis/app/runtime/model/create-store.mdx +3 -3
- package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
- package/en/apis/app/runtime/model/use-store.mdx +1 -1
- package/en/apis/app/runtime/router/router.mdx +1 -1
- package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
- package/en/apis/app/runtime/testing/render.mdx +1 -1
- package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
- package/en/apis/app/runtime/utility/loadable.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +5 -5
- package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
- package/en/components/global-proxy-config.mdx +3 -3
- package/en/components/init-app.mdx +1 -1
- package/en/configure/app/bff/_category_.json +4 -0
- package/en/configure/app/builder-plugins.mdx +3 -3
- package/en/configure/app/deploy/_category_.json +4 -0
- package/en/configure/app/dev/_category_.json +4 -0
- package/en/configure/app/dev/asset-prefix.mdx +1 -1
- package/en/configure/app/dev/hmr.mdx +1 -1
- package/en/configure/app/dev/https.mdx +1 -1
- package/en/configure/app/dev/port.mdx +1 -1
- package/en/configure/app/dev/progress-bar.mdx +1 -1
- package/en/configure/app/dev/start-url.mdx +1 -1
- package/en/configure/app/experiments/_category_.json +4 -0
- package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
- package/en/configure/app/html/_category_.json +4 -0
- package/en/configure/app/html/app-icon.mdx +1 -1
- package/en/configure/app/html/crossorigin.mdx +1 -1
- package/en/configure/app/html/disable-html-folder.mdx +1 -1
- package/en/configure/app/html/favicon-by-entries.mdx +1 -1
- package/en/configure/app/html/favicon.mdx +1 -1
- package/en/configure/app/html/inject-by-entries.mdx +1 -1
- package/en/configure/app/html/inject.mdx +1 -1
- package/en/configure/app/html/meta-by-entries.mdx +1 -1
- package/en/configure/app/html/meta.mdx +1 -1
- package/en/configure/app/html/mount-id.mdx +1 -1
- package/en/configure/app/html/tags-by-entries.mdx +1 -1
- package/en/configure/app/html/tags.mdx +1 -1
- package/en/configure/app/html/template-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters.mdx +1 -1
- package/en/configure/app/html/template.mdx +1 -1
- package/en/configure/app/html/title-by-entries.mdx +1 -1
- package/en/configure/app/html/title.mdx +1 -1
- package/en/configure/app/output/_category_.json +4 -0
- package/en/configure/app/output/asset-prefix.mdx +1 -1
- package/en/configure/app/output/assets-retry.mdx +1 -1
- package/en/configure/app/output/charset.mdx +1 -1
- package/en/configure/app/output/clean-dist-path.mdx +1 -1
- package/en/configure/app/output/convert-to-rem.mdx +1 -1
- package/en/configure/app/output/copy.mdx +1 -1
- package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
- package/en/configure/app/output/data-uri-limit.mdx +1 -1
- package/en/configure/app/output/disable-css-extract.mdx +1 -1
- package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
- package/en/configure/app/output/disable-filename-hash.mdx +1 -1
- package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
- package/en/configure/app/output/disable-minimize.mdx +1 -1
- package/en/configure/app/output/disable-source-map.mdx +1 -1
- package/en/configure/app/output/disable-ts-checker.mdx +1 -1
- package/en/configure/app/output/dist-path.mdx +1 -1
- package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
- package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
- package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
- package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
- package/en/configure/app/output/enable-inline-styles.mdx +1 -1
- package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
- package/en/configure/app/output/externals.mdx +1 -1
- package/en/configure/app/output/filename.mdx +1 -1
- package/en/configure/app/output/legal-comments.mdx +1 -1
- package/en/configure/app/output/override-browserslist.mdx +1 -1
- package/en/configure/app/output/polyfill.mdx +1 -1
- package/en/configure/app/output/ssg.mdx +2 -2
- package/en/configure/app/output/svg-default-export.mdx +1 -1
- package/en/configure/app/performance/_category_.json +4 -0
- package/en/configure/app/performance/build-cache.mdx +1 -1
- package/en/configure/app/performance/bundle-analyze.mdx +1 -1
- package/en/configure/app/performance/chunk-split.mdx +1 -1
- package/en/configure/app/performance/print-file-size.mdx +1 -1
- package/en/configure/app/performance/profile.mdx +1 -1
- package/en/configure/app/performance/remove-console.mdx +1 -1
- package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
- package/en/configure/app/plugins.mdx +1 -1
- package/en/configure/app/runtime/_category_.json +4 -0
- package/en/configure/app/runtime/intro.mdx +2 -2
- package/en/configure/app/security/_category_.json +4 -0
- package/en/configure/app/security/check-syntax.mdx +1 -1
- package/en/configure/app/security/sri.mdx +1 -1
- package/en/configure/app/server/_category_.json +4 -0
- package/en/configure/app/server/base-url.mdx +3 -3
- package/en/configure/app/server/enable-framework-ext.mdx +1 -1
- package/en/configure/app/server/ssr-by-entries.mdx +1 -1
- package/en/configure/app/source/_category_.json +4 -0
- package/en/configure/app/source/alias.mdx +1 -1
- package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
- package/en/configure/app/source/define.mdx +1 -1
- package/en/configure/app/source/design-system.mdx +5 -5
- package/en/configure/app/source/entries.mdx +3 -3
- package/en/configure/app/source/exclude.mdx +1 -1
- package/en/configure/app/source/global-vars.mdx +1 -1
- package/en/configure/app/source/include.mdx +1 -1
- package/en/configure/app/source/module-scopes.mdx +1 -1
- package/en/configure/app/source/pre-entry.mdx +1 -1
- package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
- package/en/configure/app/source/resolve-main-fields.mdx +1 -1
- package/en/configure/app/testing/_category_.json +4 -0
- package/en/configure/app/tools/_category_.json +4 -0
- package/en/configure/app/tools/autoprefixer.mdx +1 -1
- package/en/configure/app/tools/babel.mdx +1 -1
- package/en/configure/app/tools/css-extract.mdx +1 -1
- package/en/configure/app/tools/css-loader.mdx +1 -1
- package/en/configure/app/tools/dev-server.mdx +1 -1
- package/en/configure/app/tools/html-plugin.mdx +1 -1
- package/en/configure/app/tools/inspector.mdx +1 -1
- package/en/configure/app/tools/less.mdx +1 -1
- package/en/configure/app/tools/minify-css.mdx +1 -1
- package/en/configure/app/tools/postcss.mdx +1 -1
- package/en/configure/app/tools/pug.mdx +1 -1
- package/en/configure/app/tools/rspack.mdx +13 -0
- package/en/configure/app/tools/sass.mdx +1 -1
- package/en/configure/app/tools/style-loader.mdx +1 -1
- package/en/configure/app/tools/styled-components.mdx +1 -1
- package/en/configure/app/tools/tailwindcss.mdx +1 -1
- package/en/configure/app/tools/terser.mdx +1 -1
- package/en/configure/app/tools/ts-checker.mdx +1 -1
- package/en/configure/app/tools/ts-loader.mdx +1 -1
- package/en/configure/app/tools/webpack-chain.mdx +1 -1
- package/en/configure/app/tools/webpack.mdx +1 -1
- package/en/configure/app/usage.mdx +64 -1
- package/en/guides/advanced-features/_category_.json +5 -0
- package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
- package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/en/guides/advanced-features/bff/function.mdx +3 -3
- package/en/guides/advanced-features/code-split.mdx +2 -2
- package/en/guides/advanced-features/compatibility.mdx +2 -3
- package/en/guides/advanced-features/eslint.mdx +4 -4
- package/en/guides/advanced-features/low-level.mdx +1 -1
- package/en/guides/advanced-features/ssg.mdx +4 -5
- package/en/guides/advanced-features/ssr.mdx +5 -5
- package/en/guides/advanced-features/testing.mdx +4 -5
- package/en/guides/advanced-features/web-server.mdx +0 -1
- package/en/guides/basic-features/_category_.json +5 -0
- package/en/guides/basic-features/alias.mdx +1 -1
- package/en/guides/basic-features/data-fetch.mdx +21 -8
- package/en/guides/basic-features/env-vars.mdx +1 -1
- package/en/guides/basic-features/html.mdx +11 -11
- package/en/guides/basic-features/mock.mdx +21 -1
- package/en/guides/basic-features/proxy.mdx +2 -2
- package/en/guides/basic-features/routes.mdx +33 -7
- package/en/guides/concept/_category_.json +5 -0
- package/en/guides/{basic-features → concept}/builder.mdx +2 -2
- package/en/guides/concept/entries.mdx +11 -11
- package/en/guides/css/_category_.json +5 -0
- package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
- package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
- package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
- package/en/guides/get-started/_category_.json +5 -0
- package/en/guides/get-started/introduction.mdx +34 -0
- package/en/guides/get-started/quick-start.mdx +2 -2
- package/en/guides/get-started/upgrade.mdx +2 -1
- package/en/guides/topic-detail/_category_.json +2 -2
- package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
- package/en/guides/topic-detail/generator/config/{mwa.mdx → app.mdx} +1 -1
- package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +3 -3
- package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +72 -41
- package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
- package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
- package/en/guides/topic-detail/model/define-model.mdx +1 -1
- package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/en/guides/topic-detail/model/quick-start.mdx +2 -2
- package/en/guides/topic-detail/model/test-model.mdx +1 -1
- package/en/guides/topic-detail/model/use-model.mdx +3 -3
- package/en/guides/troubleshooting/_category_.json +2 -2
- package/en/guides/troubleshooting/cli.mdx +1 -1
- package/en/index.md +1 -1
- package/en/tutorials/first-app/_category_.json +1 -1
- package/en/tutorials/first-app/c01-start.mdx +0 -1
- package/en/tutorials/first-app/c03-css.mdx +1 -2
- package/en/tutorials/first-app/c06-model.mdx +1 -1
- package/en/tutorials/first-app/c07-container.mdx +1 -1
- package/en/tutorials/first-app/c08-entries.mdx +1 -2
- package/en/tutorials/foundations/introduction.mdx +17 -34
- package/package.json +3 -3
- package/scripts/config.ts +3 -1
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/zh/apis/app/commands/_category_.json +1 -4
- package/zh/apis/app/hooks/_category_.json +1 -4
- package/zh/apis/app/hooks/src/pages.mdx +1 -1
- package/zh/apis/app/hooks/src/routes.mdx +1 -1
- package/zh/apis/app/runtime/_category_.json +1 -5
- package/zh/apis/app/runtime/core/create-app.mdx +1 -1
- package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
- package/zh/apis/app/runtime/model/Provider.mdx +2 -2
- package/zh/apis/app/runtime/model/create-app.mdx +7 -7
- package/zh/apis/app/runtime/model/create-store.mdx +2 -2
- package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-store.mdx +1 -1
- package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/zh/components/custom-router-micro-frontend.mdx +40 -0
- package/zh/components/enable-micro-frontend.mdx +12 -2
- package/zh/components/micro-runtime-config.mdx +9 -10
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/builder-plugins.mdx +3 -3
- package/zh/configure/app/dev/asset-prefix.mdx +1 -1
- package/zh/configure/app/dev/hmr.mdx +1 -1
- package/zh/configure/app/dev/https.mdx +1 -1
- package/zh/configure/app/dev/port.mdx +1 -1
- package/zh/configure/app/dev/progress-bar.mdx +1 -1
- package/zh/configure/app/dev/start-url.mdx +1 -1
- package/zh/configure/app/experiments/lazy-compilation.mdx +1 -1
- package/zh/configure/app/html/app-icon.mdx +1 -1
- package/zh/configure/app/html/crossorigin.mdx +1 -1
- package/zh/configure/app/html/disable-html-folder.mdx +1 -1
- package/zh/configure/app/html/favicon-by-entries.mdx +1 -1
- package/zh/configure/app/html/favicon.mdx +1 -1
- package/zh/configure/app/html/inject-by-entries.mdx +1 -1
- package/zh/configure/app/html/inject.mdx +1 -1
- package/zh/configure/app/html/meta-by-entries.mdx +1 -1
- package/zh/configure/app/html/meta.mdx +1 -1
- package/zh/configure/app/html/mount-id.mdx +1 -1
- package/zh/configure/app/html/tags-by-entries.mdx +1 -1
- package/zh/configure/app/html/tags.mdx +1 -1
- package/zh/configure/app/html/template-by-entries.mdx +1 -1
- package/zh/configure/app/html/template-parameters-by-entries.mdx +1 -1
- package/zh/configure/app/html/template-parameters.mdx +1 -1
- package/zh/configure/app/html/template.mdx +1 -1
- package/zh/configure/app/html/title-by-entries.mdx +1 -1
- package/zh/configure/app/html/title.mdx +1 -1
- package/zh/configure/app/output/asset-prefix.mdx +1 -1
- package/zh/configure/app/output/assets-retry.mdx +1 -1
- package/zh/configure/app/output/charset.mdx +1 -1
- package/zh/configure/app/output/clean-dist-path.mdx +1 -1
- package/zh/configure/app/output/convert-to-rem.mdx +1 -1
- package/zh/configure/app/output/copy.mdx +1 -1
- package/zh/configure/app/output/css-module-local-ident-name.mdx +1 -1
- package/zh/configure/app/output/data-uri-limit.mdx +1 -1
- package/zh/configure/app/output/disable-css-extract.mdx +1 -1
- package/zh/configure/app/output/disable-css-module-extension.mdx +1 -1
- package/zh/configure/app/output/disable-filename-hash.mdx +1 -1
- package/zh/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
- package/zh/configure/app/output/disable-minimize.mdx +1 -1
- package/zh/configure/app/output/disable-source-map.mdx +1 -1
- package/zh/configure/app/output/disable-ts-checker.mdx +1 -1
- package/zh/configure/app/output/dist-path.mdx +1 -1
- package/zh/configure/app/output/enable-asset-fallback.mdx +1 -1
- package/zh/configure/app/output/enable-asset-manifest.mdx +1 -1
- package/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
- package/zh/configure/app/output/enable-inline-scripts.mdx +1 -1
- package/zh/configure/app/output/enable-inline-styles.mdx +1 -1
- package/zh/configure/app/output/enable-latest-decorators.mdx +1 -1
- package/zh/configure/app/output/externals.mdx +1 -1
- package/zh/configure/app/output/filename.mdx +1 -1
- package/zh/configure/app/output/legal-comments.mdx +1 -1
- package/zh/configure/app/output/override-browserslist.mdx +1 -1
- package/zh/configure/app/output/polyfill.mdx +1 -1
- package/zh/configure/app/output/svg-default-export.mdx +1 -1
- package/zh/configure/app/performance/build-cache.mdx +1 -1
- package/zh/configure/app/performance/bundle-analyze.mdx +1 -1
- package/zh/configure/app/performance/chunk-split.mdx +1 -1
- package/zh/configure/app/performance/print-file-size.mdx +1 -1
- package/zh/configure/app/performance/profile.mdx +1 -1
- package/zh/configure/app/performance/remove-console.mdx +1 -1
- package/zh/configure/app/performance/remove-moment-locale.mdx +1 -1
- package/zh/configure/app/plugins.mdx +1 -1
- package/zh/configure/app/security/check-syntax.mdx +1 -1
- package/zh/configure/app/security/sri.mdx +1 -1
- package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
- package/zh/configure/app/source/alias.mdx +1 -1
- package/zh/configure/app/source/compile-js-data-uri.mdx +1 -1
- package/zh/configure/app/source/define.mdx +1 -1
- package/zh/configure/app/source/exclude.mdx +1 -1
- package/zh/configure/app/source/global-vars.mdx +1 -1
- package/zh/configure/app/source/include.mdx +1 -1
- package/zh/configure/app/source/module-scopes.mdx +1 -1
- package/zh/configure/app/source/pre-entry.mdx +1 -1
- package/zh/configure/app/source/resolve-extension-prefix.mdx +1 -1
- package/zh/configure/app/source/resolve-main-fields.mdx +1 -1
- package/zh/configure/app/tools/autoprefixer.mdx +1 -1
- package/zh/configure/app/tools/babel.mdx +1 -1
- package/zh/configure/app/tools/css-extract.mdx +1 -1
- package/zh/configure/app/tools/css-loader.mdx +1 -1
- package/zh/configure/app/tools/dev-server.mdx +1 -1
- package/zh/configure/app/tools/html-plugin.mdx +1 -1
- package/zh/configure/app/tools/inspector.mdx +1 -1
- package/zh/configure/app/tools/less.mdx +1 -1
- package/zh/configure/app/tools/minify-css.mdx +1 -1
- package/zh/configure/app/tools/postcss.mdx +1 -1
- package/zh/configure/app/tools/pug.mdx +1 -1
- package/zh/configure/app/tools/rspack.mdx +13 -0
- package/zh/configure/app/tools/sass.mdx +1 -1
- package/zh/configure/app/tools/style-loader.mdx +1 -1
- package/zh/configure/app/tools/styled-components.mdx +1 -1
- package/zh/configure/app/tools/terser.mdx +1 -1
- package/zh/configure/app/tools/ts-checker.mdx +1 -1
- package/zh/configure/app/tools/ts-loader.mdx +1 -1
- package/zh/configure/app/tools/webpack-chain.mdx +1 -1
- package/zh/configure/app/tools/webpack.mdx +1 -1
- package/zh/configure/app/usage.mdx +64 -1
- package/zh/guides/advanced-features/_category_.json +2 -6
- package/zh/guides/advanced-features/compatibility.mdx +0 -1
- package/zh/guides/advanced-features/ssg.mdx +0 -1
- package/zh/guides/advanced-features/ssr.mdx +2 -2
- package/zh/guides/advanced-features/testing.mdx +0 -1
- package/zh/guides/advanced-features/web-server.mdx +0 -1
- package/zh/guides/basic-features/_category_.json +1 -5
- package/zh/guides/basic-features/alias.mdx +1 -1
- package/zh/guides/basic-features/data-fetch.mdx +35 -26
- package/zh/guides/basic-features/html.mdx +10 -9
- package/zh/guides/basic-features/mock.mdx +20 -0
- package/zh/guides/basic-features/routes.mdx +41 -9
- package/zh/guides/{basic-features → concept}/builder.mdx +2 -2
- package/zh/guides/concept/entries.mdx +11 -11
- package/zh/guides/css/_category_.json +5 -0
- package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
- package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
- package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
- package/zh/guides/get-started/introduction.mdx +31 -0
- package/zh/guides/get-started/quick-start.mdx +2 -3
- package/zh/guides/get-started/upgrade.mdx +2 -1
- package/zh/guides/topic-detail/_category_.json +2 -2
- package/zh/guides/topic-detail/generator/config/{mwa.mdx → app.mdx} +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +2 -2
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +3 -3
- package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +155 -63
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +71 -40
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/troubleshooting/_category_.json +2 -2
- package/zh/index.md +1 -1
- package/zh/tutorials/first-app/_category_.json +1 -1
- package/zh/tutorials/first-app/c01-start.mdx +1 -2
- package/zh/tutorials/first-app/c03-css.mdx +1 -2
- package/zh/tutorials/first-app/c06-model.mdx +2 -2
- package/zh/tutorials/first-app/c07-container.mdx +1 -1
- package/zh/tutorials/first-app/c08-entries.mdx +2 -3
- package/zh/tutorials/foundations/introduction.mdx +14 -29
- package/en/apis/app/commands/index.mdx +0 -7
- package/en/apis/app/hooks/index.mdx +0 -7
- package/en/apis/app/runtime/index.mdx +0 -7
- package/en/guides/advanced-features/index.mdx +0 -7
- package/en/guides/basic-features/css/_category_.json +0 -4
- package/zh/apis/app/commands/index.mdx +0 -7
- package/zh/apis/app/hooks/index.mdx +0 -7
- package/zh/apis/app/runtime/index.mdx +0 -7
- package/zh/guides/advanced-features/index.mdx +0 -7
- package/zh/guides/basic-features/css/_category_.json +0 -4
- package/zh/guides/basic-features/index.mdx +0 -7
@@ -5,7 +5,7 @@ sidebar_label: less
|
|
5
5
|
# tools.less
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.less](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.less](https://modernjs.dev/builder/api/config-tools.html#toolsless)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/less.md'
|
@@ -5,7 +5,7 @@ sidebar_label: minifyCss
|
|
5
5
|
# tools.minifyCss
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.minifyCss](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.minifyCss](https://modernjs.dev/builder/api/config-tools.html#toolsminifycss)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/minifyCss.md'
|
@@ -5,7 +5,7 @@ sidebar_label: postcss
|
|
5
5
|
# tools.postcss
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.postcss](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.postcss](https://modernjs.dev/builder/api/config-tools.html#toolspostcss)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/postcss.md'
|
@@ -5,7 +5,7 @@ sidebar_label: pug
|
|
5
5
|
# tools.pug
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.pug](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.pug](https://modernjs.dev/builder/api/config-tools.html#toolspug)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/pug.md'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: rspack
|
3
|
+
---
|
4
|
+
|
5
|
+
# tools.rspack
|
6
|
+
|
7
|
+
:::tip
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.rspack](https://modernjs.dev/builder/api/config-tools.html#toolsrspack)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/docs/zh/config/tools/rspack.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -5,7 +5,7 @@ sidebar_label: sass
|
|
5
5
|
# tools.sass
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.sass](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.sass](https://modernjs.dev/builder/api/config-tools.html#toolssass)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/sass.md'
|
@@ -5,7 +5,7 @@ sidebar_label: styleLoader
|
|
5
5
|
# tools.styleLoader
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styleLoader](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styleLoader](https://modernjs.dev/builder/api/config-tools.html#toolsstyleloader)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/styleLoader.md'
|
@@ -5,7 +5,7 @@ sidebar_label: styledComponents
|
|
5
5
|
# tools.styledComponents
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styledComponents](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styledComponents](https://modernjs.dev/builder/api/config-tools.html#toolsstyledcomponents)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/styledComponents.md'
|
@@ -5,7 +5,7 @@ sidebar_label: terser
|
|
5
5
|
# tools.terser
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.terser](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.terser](https://modernjs.dev/builder/api/config-tools.html#toolsterser)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/terser.md'
|
@@ -5,7 +5,7 @@ sidebar_label: tsChecker
|
|
5
5
|
# tools.tsChecker
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsChecker](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsChecker](https://modernjs.dev/builder/api/config-tools.html#toolstschecker)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/tsChecker.md'
|
@@ -5,7 +5,7 @@ sidebar_label: tsLoader
|
|
5
5
|
# tools.tsLoader
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsLoader](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsLoader](https://modernjs.dev/builder/api/config-tools.html#toolstsloader)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/tsLoader.md'
|
@@ -5,7 +5,7 @@ sidebar_label: webpackChain
|
|
5
5
|
# tools.webpackChain
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpackChain](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpackChain](https://modernjs.dev/builder/api/config-tools.html#toolswebpackchain)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/webpackChain.md'
|
@@ -5,7 +5,7 @@ sidebar_label: webpack
|
|
5
5
|
# tools.webpack
|
6
6
|
|
7
7
|
:::tip
|
8
|
-
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpack](https://modernjs.dev/builder/api/config-tools.html#
|
8
|
+
该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpack](https://modernjs.dev/builder/api/config-tools.html#toolswebpack)。
|
9
9
|
:::
|
10
10
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/zh/config/tools/webpack.md'
|
@@ -12,7 +12,7 @@ Modern.js 中有两种配置,一个是编译时配置,一个是服务端运
|
|
12
12
|
- `package.json` 文件
|
13
13
|
|
14
14
|
:::info
|
15
|
-
不支持同时在 package.json 中和 modern.config.ts 中配置同一个配置项,推荐优先在 modern.config.ts 中进行配置。如果 Modern.js 检测到重复配置导致的冲突,将会抛出警告。
|
15
|
+
Modern.js 不支持同时在 package.json 中和 modern.config.ts 中配置同一个配置项,推荐优先在 modern.config.ts 中进行配置。如果 Modern.js 检测到重复配置导致的冲突,将会抛出警告。
|
16
16
|
:::
|
17
17
|
|
18
18
|
服务端运行时配置可以在根路径下的 `modern.server-runtime.config.(ts|js|mjs)` 中自定义配置选项。
|
@@ -69,6 +69,69 @@ export default defineConfig({
|
|
69
69
|
});
|
70
70
|
```
|
71
71
|
|
72
|
+
### 导出配置函数
|
73
|
+
|
74
|
+
Modern.js 支持在配置文件中导出一个函数,你可以在函数中动态计算配置,并返回给 Modern.js。
|
75
|
+
|
76
|
+
```js title="modern.config.js"
|
77
|
+
import { defineConfig } from '@modern-js/app-tools';
|
78
|
+
|
79
|
+
export default defineConfig(({ env, command }) => ({
|
80
|
+
source: {
|
81
|
+
alias: {
|
82
|
+
'@foo': env === 'development' ? './src/foo.dev.ts' : './src/foo.prod.ts',
|
83
|
+
},
|
84
|
+
},
|
85
|
+
}));
|
86
|
+
```
|
87
|
+
|
88
|
+
该函数接受以下入参:
|
89
|
+
|
90
|
+
- `env`:对应 `process.env.NODE_ENV` 的值。
|
91
|
+
- 当运行 `modern dev` 或 `modern start` 时,`env` 的值为 `development`。
|
92
|
+
- 当运行 `modern build` 或 `modern serve` 时,`env` 的值为 `production`。
|
93
|
+
- 当运行 `modern test` 时,`env` 的值为 `test`。
|
94
|
+
- `command`: 对应当前运行的命令,如 `dev`、`start`、`build`、`serve`。
|
95
|
+
|
96
|
+
### 导出异步函数
|
97
|
+
|
98
|
+
Modern.js 也支持在配置文件中导出一个异步函数,你可以在函数中进行一些异步操作:
|
99
|
+
|
100
|
+
```js title="modern.config.js"
|
101
|
+
import { defineConfig } from '@modern-js/app-tools';
|
102
|
+
|
103
|
+
export default defineConfig(async ({ env, command }) => {
|
104
|
+
const result = await someAsyncFunction();
|
105
|
+
|
106
|
+
return {
|
107
|
+
html: {
|
108
|
+
title: result,
|
109
|
+
},
|
110
|
+
};
|
111
|
+
});
|
112
|
+
```
|
113
|
+
|
114
|
+
### 指定配置文件
|
115
|
+
|
116
|
+
Modern.js 命令行支持通过 `--config` 选项来指定配置文件的名称。
|
117
|
+
|
118
|
+
例如,你需要在执行 build 命令时使用 `modern.prod.config.ts` 文件,可以在 `package.json` 中添加如下配置:
|
119
|
+
|
120
|
+
```json title="package.json"
|
121
|
+
{
|
122
|
+
"scripts": {
|
123
|
+
"dev": "modern modern",
|
124
|
+
"build": "modern build --config modern.prod.config.ts"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
你也可以将 `--config` 选项缩写为 `-c`:
|
130
|
+
|
131
|
+
```bash
|
132
|
+
$ modern build -c modern.prod.config.js
|
133
|
+
```
|
134
|
+
|
72
135
|
## 在 package.json 中配置(不推荐)
|
73
136
|
|
74
137
|
除了配置文件外,也可以在 `package.json` 中的 `modernConfig` 字段下设置配置选项,如:
|
@@ -55,7 +55,6 @@ Modern.js 中还提供了基于浏览器 [UA](https://developer.mozilla.org/zh-C
|
|
55
55
|
```ts title="modern.config.ts"
|
56
56
|
import polyfillPlugin from '@modern-js/plugin-polyfill';
|
57
57
|
|
58
|
-
// https://modernjs.dev/docs/apis/app/config
|
59
58
|
export default defineConfig({
|
60
59
|
plugins: [..., polyfillPlugin()],
|
61
60
|
});
|
@@ -242,11 +242,11 @@ if (process.env.MODERN_TARGET === 'browser') {
|
|
242
242
|
例如在代码中引入了 `fs-extra`,这时候直接引用到组件中,会造成 CSR 加载报错。可以创建同名的 `.ts` 和 `.node.ts` 文件做一层代理:
|
243
243
|
|
244
244
|
```ts title="compat.ts"
|
245
|
-
export
|
245
|
+
export const readFileSync: any = () => {};
|
246
246
|
```
|
247
247
|
|
248
248
|
```ts title="compat.node.ts"
|
249
|
-
export
|
249
|
+
export { readFileSync } from 'fs-extra';
|
250
250
|
```
|
251
251
|
|
252
252
|
在文件中直接引入 `./compat`,此时 SSR 环境下会优先使用 `.node.ts` 后缀的文件,CSR 环境下会使用 `.ts` 后缀的文件。
|
@@ -20,7 +20,6 @@ Modern.js 默认继承了 [Jest](https://jestjs.io/) 的测试能力。
|
|
20
20
|
```ts title="modern.config.ts"
|
21
21
|
import testPlugin from '@modern-js/plugin-testing';
|
22
22
|
|
23
|
-
// https://modernjs.dev/docs/apis/app/config
|
24
23
|
export default defineConfig({
|
25
24
|
...,
|
26
25
|
plugins: [..., testPlugin()],
|
@@ -2,6 +2,7 @@
|
|
2
2
|
title: 数据获取
|
3
3
|
sidebar_position: 3
|
4
4
|
---
|
5
|
+
|
5
6
|
# 数据获取
|
6
7
|
|
7
8
|
Modern.js 中提供了开箱即用的数据获取能力,开发者可以通过这些 API,在 CSR 和 SSR 环境同构的进行开发。
|
@@ -220,38 +221,46 @@ export default function UserLayout() {
|
|
220
221
|
|
221
222
|
:::
|
222
223
|
|
224
|
+
创建 `user/layout.loader.ts`,并添加以下代码:
|
225
|
+
|
226
|
+
```ts title="routes/user/layout.loader.ts"
|
227
|
+
import { defer } from "@edenx/runtime/router"
|
228
|
+
|
229
|
+
const loader = () =>
|
230
|
+
defer({
|
231
|
+
userInfo: new Promise((resolve) => {
|
232
|
+
setTimeout(() => {
|
233
|
+
resolve({
|
234
|
+
age: 1,
|
235
|
+
name: 'user layout'
|
236
|
+
})
|
237
|
+
}, 1000)
|
238
|
+
})
|
239
|
+
})
|
240
|
+
|
241
|
+
export default loader;
|
242
|
+
```
|
243
|
+
|
223
244
|
在 `user/layout.tsx` 中添加以下代码:
|
224
245
|
|
225
246
|
```tsx title="routes/user/layout.tsx"
|
226
|
-
import {
|
227
|
-
Await,
|
228
|
-
defer,
|
229
|
-
useLoaderData,
|
230
|
-
Outlet
|
231
|
-
} from '@modern-js/runtime/router';
|
232
|
-
|
233
|
-
export const loader = () => {
|
234
|
-
return defer({
|
235
|
-
// fetchUserInfo 是一个异步函数,返回用户信息
|
236
|
-
userInfo: fetchUserInfo(),
|
237
|
-
})
|
238
|
-
}
|
247
|
+
import { Await, defer, useLoaderData, Outlet } from '@modern-js/runtime/router';
|
239
248
|
|
240
249
|
export default function UserLayout() {
|
241
|
-
const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
|
250
|
+
const { userInfo } = useLoaderData() as { userInfo: Promise<UserInfo> };
|
242
251
|
return (
|
243
252
|
<div>
|
244
|
-
<React.Suspense
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
253
|
+
<React.Suspense fallback={<p>Loading...</p>}>
|
254
|
+
<Await
|
255
|
+
resolve={userInfo}
|
256
|
+
children={userInfo => (
|
257
|
+
<div>
|
258
|
+
<span>{userInfo.name}</span>
|
259
|
+
<span>{userInfo.age}</span>
|
260
|
+
<Outlet />
|
261
|
+
</div>
|
262
|
+
)}
|
263
|
+
></Await>
|
255
264
|
</React.Suspense>
|
256
265
|
</div>
|
257
266
|
);
|
@@ -265,7 +274,7 @@ defer 的具体用法请查看 [defer](https://reactrouter.com/en/main/guides/de
|
|
265
274
|
|
266
275
|
:::
|
267
276
|
|
268
|
-
{/* TODO 缓存相关
|
277
|
+
{/* TODO 缓存相关 */}
|
269
278
|
|
270
279
|
### 错误用法
|
271
280
|
|
@@ -2,9 +2,10 @@
|
|
2
2
|
title: HTML 模板
|
3
3
|
sidebar_position: 9
|
4
4
|
---
|
5
|
+
|
5
6
|
# HTML 模板
|
6
7
|
|
7
|
-
Modern.js 提供了 **JSX
|
8
|
+
Modern.js 提供了 **JSX 语法**和 **HTML(EJS) 语法**两种方式用于自定义 HTML 模板。
|
8
9
|
|
9
10
|
## JSX 语法
|
10
11
|
|
@@ -14,14 +15,14 @@ Modern.js 约定,在 `src/` 目录下,或在入口目录下,可以创建 `
|
|
14
15
|
|
15
16
|
```bash
|
16
17
|
.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
│
|
21
|
-
│
|
22
|
-
|
23
|
-
│
|
24
|
-
|
18
|
+
└── src
|
19
|
+
├── Document.tsx
|
20
|
+
├── entry-a
|
21
|
+
│ ├── Document.tsx
|
22
|
+
│ └── routes
|
23
|
+
├── entry-b
|
24
|
+
│ └── routes
|
25
|
+
└── modern-app-env.d.ts
|
25
26
|
```
|
26
27
|
|
27
28
|
`entry-a` 会优先使用当前入口下的 `Docoument.[jt]sx` 文件。如果当前入口没有 `Document.[jt]sx` 文件,例如 `entry-b`,则会查找根目录下的 `Document.[jt]sx` 文件。
|
@@ -77,3 +77,23 @@ module.exports = {
|
|
77
77
|
},
|
78
78
|
};
|
79
79
|
```
|
80
|
+
|
81
|
+
## 按需使用 Mock 服务
|
82
|
+
|
83
|
+
`config/mock/index.ts` 下还可以到处 `config` 对象,更精细的控制 Mock 服务。
|
84
|
+
|
85
|
+
```ts
|
86
|
+
type MockConfig = {
|
87
|
+
enable: ((req: IncomingMessage, res: ServerResponse) => boolean) | boolean;
|
88
|
+
};
|
89
|
+
|
90
|
+
export const config = {
|
91
|
+
enable: false
|
92
|
+
}
|
93
|
+
```
|
94
|
+
|
95
|
+
目前仅支持 `enable` 配置,开发者可以通过该配置控制是否执行 Mock。
|
96
|
+
|
97
|
+
:::note
|
98
|
+
修改 `config` 后无需重启服务,即刻生效。
|
99
|
+
:::
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# 路由
|
6
6
|
|
7
|
-
Modern.js
|
7
|
+
Modern.js 的路由基于 [React Router 6](https://reactrouter.com/en/main),并提供了多种类型的路由模式。根据不同 [入口](/guides/concept/entries) 类型,将路由分为三种模式,分别是**约定式路由**,**自控式路由**和**其他路由方案**。
|
8
8
|
|
9
9
|
:::note
|
10
10
|
本小节提到的路由,都是客户端路由,即 SPA 路由。
|
@@ -164,10 +164,37 @@ export default () => {
|
|
164
164
|
|
165
165
|
`routes/[id]/page.tsx` 文件会转为 `/:id` 路由。除了可以确切匹配的 `/blog` 路由,其他所有 `/xxx` 都会匹配到该路由。
|
166
166
|
|
167
|
-
在组件中,可以通过 [useParams](/apis/app/runtime/router
|
167
|
+
在组件中,可以通过 [useParams](/apis/app/runtime/router/router#useparams) 获取对应命名的参数。
|
168
168
|
|
169
169
|
在 loader 中,params 会作为 [loader](/guides/basic-features/data-fetch#loader-函数) 的入参,通过 `params.xxx` 可以获取。
|
170
170
|
|
171
|
+
### 通配路由
|
172
|
+
|
173
|
+
如果在 routes 目录下创建 `$.tsx` 文件,该文件会作为通配路由组件,当没有匹配的路由时,会渲染该路由组件。
|
174
|
+
|
175
|
+
:::note
|
176
|
+
`$.tsx` 可以认为是一种特殊的 `page` 路由组件,当前目录下有 `layout` 组件时,`$.tsx`,会作为 `layout` 的子组件渲染。
|
177
|
+
:::
|
178
|
+
|
179
|
+
例如以下目录结构:
|
180
|
+
```
|
181
|
+
└── routes
|
182
|
+
├── $.tsx
|
183
|
+
├── blog
|
184
|
+
│ └── page.tsx
|
185
|
+
└── page.tsx
|
186
|
+
```
|
187
|
+
|
188
|
+
当访问任何匹配不到的路径时,都会渲染 `routes/$.tsx` 组件,同样,`$.tsx` 中可以使用 [useParams](/apis/app/runtime/router/router#useparams) 捕获 url 的剩余部分。
|
189
|
+
```ts title="$.tsx"
|
190
|
+
import { useParams } from '@modern-js/runtime/router';
|
191
|
+
// 当 path 是 `/aaa/bbb` 时
|
192
|
+
const params = useParams();
|
193
|
+
params['*'] // => 'aaa/bbb'
|
194
|
+
```
|
195
|
+
|
196
|
+
`$.tsx` 可以加入到 `routes` 目录下的任意目录中,一个常见的使用示例是添加 `routes/$.tsx` 文件去定制任意层级的 404 页面。
|
197
|
+
|
171
198
|
### 无路径布局
|
172
199
|
|
173
200
|
当目录名以 \_\_ 开头时,对应的目录名不会转换为实际的路由路径,例如以下文件目录:
|
@@ -275,7 +302,7 @@ Modern.js 建议必须有根 layout 和根 loading。
|
|
275
302
|
|
276
303
|
{/* Todo API 路由 */}
|
277
304
|
|
278
|
-
在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router
|
305
|
+
在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router/router#useparams) 获取的错误的具体信息:
|
279
306
|
|
280
307
|
```tsx
|
281
308
|
import { useRouteError } from '@modern-js/runtime/router';
|
@@ -302,8 +329,15 @@ import type { AppConfig } from '@modern-js/runtime';
|
|
302
329
|
export const config = (): AppConfig => {
|
303
330
|
return {
|
304
331
|
router: {
|
305
|
-
|
306
|
-
|
332
|
+
createRoutes() {
|
333
|
+
return [
|
334
|
+
{
|
335
|
+
path: 'edenx',
|
336
|
+
element: <div>edenx</div>,
|
337
|
+
},
|
338
|
+
];
|
339
|
+
},
|
340
|
+
},
|
307
341
|
}
|
308
342
|
};
|
309
343
|
```
|
@@ -353,12 +387,10 @@ export default () => {
|
|
353
387
|
配合 SSR 功能时,浏览器端可以获取到 SSR 时 `init` 返回的数据,开发者可以自行判断是否要在浏览器端重新获取数据来覆盖 SSR 数据,例如:
|
354
388
|
|
355
389
|
```tsx title="src/routes/layout.tsx"
|
356
|
-
import {
|
357
|
-
RuntimeContext,
|
358
|
-
} from '@modern-js/runtime';
|
390
|
+
import { RuntimeContext } from '@modern-js/runtime';
|
359
391
|
|
360
392
|
export const init = (context: RuntimeContext) => {
|
361
|
-
if (process.env.
|
393
|
+
if (process.env.MODERN_TARGET === 'node') {
|
362
394
|
return {
|
363
395
|
message: 'Hello World By Server',
|
364
396
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
sidebar_position: 2
|
2
|
+
sidebar_position: 1
|
4
3
|
---
|
4
|
+
|
5
5
|
# 入口
|
6
6
|
|
7
7
|
入口是 Modern.js 默认的文件约定,项目的每一个入口是一张独立的页面,对应一条**服务端路由**。
|
@@ -15,11 +15,11 @@ Modern.js 初始化的项目是单入口的,项目结构如下:
|
|
15
15
|
```
|
16
16
|
.
|
17
17
|
├── src
|
18
|
-
│
|
19
|
-
│
|
20
|
-
│
|
21
|
-
│
|
22
|
-
│
|
18
|
+
│ ├── modern-app-env.d.ts
|
19
|
+
│ └── routes
|
20
|
+
│ ├── index.css
|
21
|
+
│ ├── layout.tsx
|
22
|
+
│ └── page.tsx
|
23
23
|
├── package.json
|
24
24
|
├── modern.config.ts
|
25
25
|
├── pnpm-lock.yaml
|
@@ -41,10 +41,10 @@ Modern.js 可以很方便的将单入口切换成多入口。可以在项目下
|
|
41
41
|
.
|
42
42
|
├── modern-app-env.d.ts
|
43
43
|
├── myapp
|
44
|
-
│
|
45
|
-
│
|
46
|
-
│
|
47
|
-
│
|
44
|
+
│ └── routes
|
45
|
+
│ ├── index.css
|
46
|
+
│ ├── layout.tsx
|
47
|
+
│ └── page.tsx
|
48
48
|
└── new-entry
|
49
49
|
└── routes
|
50
50
|
├── index.css
|
File without changes
|
File without changes
|
@@ -12,6 +12,6 @@ sidebar_position: 4
|
|
12
12
|
- 如果需要自定义 [sass-loader](https://github.com/webpack-contrib/sass-loader) 的配置,请参考 [tools.less](/configure/app/tools/sass) 配置项。
|
13
13
|
|
14
14
|
:::tip 提示
|
15
|
-
经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/
|
15
|
+
经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/css/postcss)】。
|
16
16
|
|
17
17
|
:::
|
@@ -10,10 +10,11 @@ sidebar_position: 3
|
|
10
10
|
|
11
11
|
1. [Autoprefixer](https://github.com/postcss/autoprefixer) 根据需要支持的浏览器范围,会自动为 CSS 规则添加需要的浏览器厂商前缀。Modern.js 默认支持的浏览器范围为:`['> 0.01%', 'not dead', 'not op_mini all']`。
|
12
12
|
|
13
|
-
:::info
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
:::info 注意
|
14
|
+
|
15
|
+
- 【支持的浏览器范围为:`> 0.01%`】是指浏览器市场份额大于 0.01%。
|
16
|
+
- `not dead` 是指不包含官方不再支持的浏览器和过去 24 个月没有更新的浏览器。
|
17
|
+
- `not op_mini all` 是指不包含 Opera Mini。
|
17
18
|
|
18
19
|
:::
|
19
20
|
|