@modern-js/main-doc 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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/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 +1 -1
- package/en/guides/advanced-features/_category_.json +2 -2
- 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 +3 -3
- package/en/guides/advanced-features/testing.mdx +4 -5
- package/en/guides/advanced-features/web-server.mdx +0 -1
- 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 +6 -8
- package/en/guides/{basic-features → concept}/builder.mdx +1 -1
- 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/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/plugin/api/hook/onForged.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- 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/micro-runtime-config.mdx +6 -6
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/builder-plugins.mdx +3 -3
- package/zh/configure/app/plugins.mdx +1 -1
- package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
- package/zh/configure/app/tools/rspack.mdx +13 -0
- package/zh/configure/app/usage.mdx +1 -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/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 +15 -10
- 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/plugin/api/input/addInputBefore.mdx +1 -1
- package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +15 -15
- 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: minifyCss
|
|
|
5
5
|
# tools.minifyCss
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.minifyCss](https://modernjs.dev/builder/en/api/config-tools.html#toolsminifycss)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.minifyCss](https://modernjs.dev/builder/en/api/config-tools.html#toolsminifycss).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/minifyCss.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: postcss
|
|
|
5
5
|
# tools.postcss
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.postcss](https://modernjs.dev/builder/en/api/config-tools.html#toolspostcss)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.postcss](https://modernjs.dev/builder/en/api/config-tools.html#toolspostcss).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/postcss.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: pug
|
|
|
5
5
|
# tools.pug
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.pug](https://modernjs.dev/builder/en/api/config-tools.html#toolspug)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.pug](https://modernjs.dev/builder/en/api/config-tools.html#toolspug).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/pug.md'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_label: rspack
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# tools.rspack
|
|
6
|
+
|
|
7
|
+
:::tip
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.rspack](https://modernjs.dev/builder/en/api/config-tools.html#toolsrspack).
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
import Main from '@modern-js/builder-doc/docs/en/config/tools/rspack.md'
|
|
12
|
+
|
|
13
|
+
<Main />
|
|
@@ -5,7 +5,7 @@ sidebar_label: sass
|
|
|
5
5
|
# tools.sass
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.sass](https://modernjs.dev/builder/en/api/config-tools.html#toolssass)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.sass](https://modernjs.dev/builder/en/api/config-tools.html#toolssass).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/sass.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: styleLoader
|
|
|
5
5
|
# tools.styleLoader
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.styleLoader](https://modernjs.dev/builder/en/api/config-tools.html#toolsstyleloader)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.styleLoader](https://modernjs.dev/builder/en/api/config-tools.html#toolsstyleloader).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/styleLoader.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: styledComponents
|
|
|
5
5
|
# tools.styledComponents
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.styledComponents](https://modernjs.dev/builder/en/api/config-tools.html#toolsstyledcomponents)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.styledComponents](https://modernjs.dev/builder/en/api/config-tools.html#toolsstyledcomponents).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/styledComponents.md'
|
|
@@ -32,4 +32,4 @@ When the value is of type `Function`, the object returned by the function is mer
|
|
|
32
32
|
|
|
33
33
|
The `theme` attribute is not allowed, otherwise the build will fail. Modern.js use [source.designSystem](/configure/app/source/design-system) as the Tailwind CSS Theme configuration.
|
|
34
34
|
|
|
35
|
-
Other uses are consistent with [Tailwind CSS](https://tailwindcss.com/docs/configuration)
|
|
35
|
+
Other uses are consistent with [Tailwind CSS](https://tailwindcss.com/docs/configuration).
|
|
@@ -5,7 +5,7 @@ sidebar_label: terser
|
|
|
5
5
|
# tools.terser
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.terser](https://modernjs.dev/builder/en/api/config-tools.html#toolsterser)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.terser](https://modernjs.dev/builder/en/api/config-tools.html#toolsterser).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/terser.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: tsChecker
|
|
|
5
5
|
# tools.tsChecker
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.tsChecker](https://modernjs.dev/builder/en/api/config-tools.html#toolstschecker)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.tsChecker](https://modernjs.dev/builder/en/api/config-tools.html#toolstschecker).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/tsChecker.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: tsLoader
|
|
|
5
5
|
# tools.tsLoader
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.tsLoader](https://modernjs.dev/builder/en/api/config-tools.html#toolstsloader)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.tsLoader](https://modernjs.dev/builder/en/api/config-tools.html#toolstsloader).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/tsLoader.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: webpackChain
|
|
|
5
5
|
# tools.webpackChain
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.webpackChain](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpackchain)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.webpackChain](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpackchain).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/webpackChain.md'
|
|
@@ -5,7 +5,7 @@ sidebar_label: webpack
|
|
|
5
5
|
# tools.webpack
|
|
6
6
|
|
|
7
7
|
:::tip
|
|
8
|
-
This config is provided by Modern.js Builder, more detail can see [tools.webpack](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpack)
|
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [tools.webpack](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpack).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
import Main from '@modern-js/builder-doc/docs/en/config/tools/webpack.md'
|
|
@@ -25,6 +25,6 @@ export default defineConfig({
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
:::note
|
|
28
|
-
For more detail, see [bff.proxy](/configure/app/bff/proxy)
|
|
28
|
+
For more detail, see [bff.proxy](/configure/app/bff/proxy). For more proxy info, see [Proxy](/guides/basic-features/proxy).
|
|
29
29
|
|
|
30
30
|
:::
|
|
@@ -58,7 +58,7 @@ Function Writing & Framework Writing will introduce soon.
|
|
|
58
58
|
|
|
59
59
|
:::
|
|
60
60
|
|
|
61
|
-
All routes generated by BFF functions have a prefix, and the default value is `/api`. The prefix can be set through [bff.prefix]
|
|
61
|
+
All routes generated by BFF functions have a prefix, and the default value is `/api`. The prefix can be set through [bff.prefix](/configure/app/bff/prefix).
|
|
62
62
|
|
|
63
63
|
Several routing conventions are described as follow.
|
|
64
64
|
|
|
@@ -130,9 +130,9 @@ export const post = async () => {
|
|
|
130
130
|
};
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
- Modern.js supports 9 definitions for HTTP Method: `GET`、`POST`、`PUT`、`DELETE`、`CONNECT`、`TRACE`、`PATCH`、`OPTION`、`HEAD`, can be exported using these methods as functions
|
|
133
|
+
- Modern.js supports 9 definitions for HTTP Method: `GET`、`POST`、`PUT`、`DELETE`、`CONNECT`、`TRACE`、`PATCH`、`OPTION`、`HEAD`, can be exported using these methods as functions.
|
|
134
134
|
|
|
135
|
-
- The name is size insensitive,if `GET`,can write `get`、`Get`、`GEt`、`GET`,can be accurately identified. But default export as `export default xxx` will be map to `Get
|
|
135
|
+
- The name is size insensitive,if `GET`,can write `get`、`Get`、`GEt`、`GET`,can be accurately identified. But default export as `export default xxx` will be map to `Get`.
|
|
136
136
|
|
|
137
137
|
- Multiple functions of different Methods can be defined in one file, but if multiple functions of the same Method are defined, only the first will take effect.
|
|
138
138
|
|
|
@@ -56,7 +56,7 @@ function MyComponent() {
|
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
For detail, see [React lazy](https://reactjs.org/docs/code-splitting.html#reactlazy)
|
|
59
|
+
For detail, see [React lazy](https://reactjs.org/docs/code-splitting.html#reactlazy).
|
|
60
60
|
|
|
61
61
|
## loadable
|
|
62
62
|
|
|
@@ -72,7 +72,7 @@ function MyComponent() {
|
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
For detail, see [loadable API](/apis/app/runtime/utility/loadable)
|
|
75
|
+
For detail, see [loadable API](/apis/app/runtime/utility/loadable).
|
|
76
76
|
|
|
77
77
|
:::info
|
|
78
78
|
SSR is supported out of the box by `loadable`.
|
|
@@ -48,8 +48,8 @@ Modern.js also provides a runtime Polyfill solution based on browser [UA](https:
|
|
|
48
48
|
exec `pnpm run new` to enable this features:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
?
|
|
52
|
-
?
|
|
51
|
+
? Action Enable features
|
|
52
|
+
? Enable features Enable UA-based Polyfill Feature
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
After executing the command, register the Polyfill plugin in `modern.config.ts`:
|
|
@@ -57,7 +57,6 @@ After executing the command, register the Polyfill plugin in `modern.config.ts`:
|
|
|
57
57
|
```ts title="modern.config.ts"
|
|
58
58
|
import polyfillPlugin from '@modern-js/plugin-polyfill';
|
|
59
59
|
|
|
60
|
-
// https://modernjs.dev/docs/apis/app/config
|
|
61
60
|
export default defineConfig({
|
|
62
61
|
plugins: [..., polyfillPlugin()],
|
|
63
62
|
});
|
|
@@ -43,7 +43,7 @@ pnpm run lint:error
|
|
|
43
43
|
/* eslint-enable filenames/match-exported */
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
:::info
|
|
46
|
+
:::info
|
|
47
47
|
在 VS Code 编辑器里输入 eslint,会自动出现关于 "eslint-disable" 的提示框,选择提示选项生成对应注释对。
|
|
48
48
|
|
|
49
49
|
:::
|
|
@@ -74,7 +74,7 @@ pnpm run lint:error
|
|
|
74
74
|
|
|
75
75
|
Modern.js 的应用工程、模块工程,源代码目录里都会默认有这个配置文件,是针对 Universal JS 代码设计的。
|
|
76
76
|
|
|
77
|
-
:::info
|
|
77
|
+
:::info
|
|
78
78
|
Universal JS 代码是既能浏览器端也能在服务器端运行的代码。
|
|
79
79
|
|
|
80
80
|
:::
|
|
@@ -106,7 +106,7 @@ module.exports = {
|
|
|
106
106
|
};
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
:::tip
|
|
109
|
+
:::tip
|
|
110
110
|
注意:没有必要使用 `extends` 字段,会自动继承父目录的配置。
|
|
111
111
|
|
|
112
112
|
:::
|
|
@@ -129,7 +129,7 @@ module.exports = {
|
|
|
129
129
|
|
|
130
130
|
做完这些操作之后,在业务项目的 `./node_modules` 目录里,这个插件应该只存在一份,并且升级到了你指定的版本。
|
|
131
131
|
|
|
132
|
-
:::tip
|
|
132
|
+
:::tip
|
|
133
133
|
- Major 版本就是主版本号。更多信息,请阅读【[Semantic Versioning](https://semver.org/#summary)】。
|
|
134
134
|
- 所有被 Modern.js 封装的上游项目(比如 ESLint、[ESLint 插件](https://eslint.org/docs/user-guide/configuring/plugins#plugins)、[React Router](https://reactrouter.com/) 等),也都可以这样升级。
|
|
135
135
|
- Modern.js 也会在每次发版中尽量及时的升级这些上游依赖。
|
|
@@ -10,7 +10,7 @@ Modern.js internally integrates tools such as [Babel](https://babeljs.io/), [Typ
|
|
|
10
10
|
|
|
11
11
|
Usually, the default configuration can meet most development needs. When there are special needs, it can be achieved through the underlying configuration.
|
|
12
12
|
|
|
13
|
-
Take configuring Webpack as an example, just add [
|
|
13
|
+
Take configuring Webpack as an example, just add [tools.webpack](/configure/app/tools/webpack) to the modern.config.ts:
|
|
14
14
|
|
|
15
15
|
```ts title="modern.config.ts"
|
|
16
16
|
export default defineConfig({
|
|
@@ -9,8 +9,8 @@ Static Site Generation is a solution for rendering complete static web pages at
|
|
|
9
9
|
First need to execute `pnpm run new` to enable the SSG features:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
?
|
|
13
|
-
?
|
|
12
|
+
? Action Enable features
|
|
13
|
+
? Enable features Enable SSG
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
After execute script,register SSG plugin in `modern.config.ts`:
|
|
@@ -18,7 +18,6 @@ After execute script,register SSG plugin in `modern.config.ts`:
|
|
|
18
18
|
```ts title="modern.config.ts"
|
|
19
19
|
import ssgPlugin from '@modern-js/plugin-ssg';
|
|
20
20
|
|
|
21
|
-
// https://modernjs.dev/docs/apis/app/config
|
|
22
21
|
export default defineConfig({
|
|
23
22
|
output: {
|
|
24
23
|
ssg: true,
|
|
@@ -107,11 +106,11 @@ export default defineConfig({
|
|
|
107
106
|
});
|
|
108
107
|
```
|
|
109
108
|
|
|
110
|
-
run `pnpm run build` and `pnpm run serve`,access `http://localhost:8080/about`. In the Preview view, you can see that the page has been rendered
|
|
109
|
+
run `pnpm run build` and `pnpm run serve`,access `http://localhost:8080/about`. In the Preview view, you can see that the page has been rendered.
|
|
111
110
|
|
|
112
111
|
Looking at the bundle file, a new `main/about/index.html` file has been added in the `dist/` directory.
|
|
113
112
|
|
|
114
113
|
:::info
|
|
115
|
-
The above only introduces the single entry, more related content can be viewed [SSG API](/configure/app/output/ssg)
|
|
114
|
+
The above only introduces the single entry, more related content can be viewed [SSG API](/configure/app/output/ssg).
|
|
116
115
|
|
|
117
116
|
:::
|
|
@@ -44,7 +44,7 @@ And it provides elegant degradation processing. Once the SSR request fails, it w
|
|
|
44
44
|
However, developers still need to pay attention to the fallback of data, such as `null` values or data returns that do not as expect. Avoid React rendering errors or messy rendering results when SSR.
|
|
45
45
|
|
|
46
46
|
:::info
|
|
47
|
-
When using Data Loader, data fetching happens before rendering, Modern.js still supports fetching data when the component is rendered. See [Data Fetch](/guides/basic-features/data-fetch)
|
|
47
|
+
When using Data Loader, data fetching happens before rendering, Modern.js still supports fetching data when the component is rendered. See [Data Fetch](/guides/basic-features/data-fetch).
|
|
48
48
|
|
|
49
49
|
:::
|
|
50
50
|
|
|
@@ -198,7 +198,7 @@ This is because in the previous request, the SPR has asynchronously obtained the
|
|
|
198
198
|
It is conceivable that when `interval` is set to 1, users can have the responsive experience of a static page.
|
|
199
199
|
|
|
200
200
|
:::info
|
|
201
|
-
For more detail, see [`<PreRender>`](/apis/app/runtime/ssr/pre-render)
|
|
201
|
+
For more detail, see [`<PreRender>`](/apis/app/runtime/ssr/pre-render).
|
|
202
202
|
|
|
203
203
|
:::
|
|
204
204
|
|
|
@@ -276,7 +276,7 @@ export const loader = () => {
|
|
|
276
276
|
|
|
277
277
|
### Independent File
|
|
278
278
|
|
|
279
|
-
Both of the above methods will bring some burden to the developer. Modern.js based on [Nested Routing](/guides/basic-features/routes) developed and designed [Data Fetch](/guides/basic-features/data-fetch) to separate CSR and SSR code
|
|
279
|
+
Both of the above methods will bring some burden to the developer. Modern.js based on [Nested Routing](/guides/basic-features/routes) developed and designed [Data Fetch](/guides/basic-features/data-fetch) to separate CSR and SSR code.
|
|
280
280
|
|
|
281
281
|
## Remote Request
|
|
282
282
|
|
|
@@ -9,8 +9,8 @@ Modern.js inherits the testing capabilities of [Jest](https://jestjs.io/) by def
|
|
|
9
9
|
First need to execute `pnpm run new` enable [unit test/integration test] features:
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
?
|
|
13
|
-
?
|
|
12
|
+
? Action: Enable features
|
|
13
|
+
? Enable features: Enable Unit Test / Integration Test
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
After executing the above command, the `"test": "modern test"` command will be automatically generated in package.json.
|
|
@@ -20,7 +20,6 @@ register plugin in `modern.config.ts`:
|
|
|
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
|
plugins: [..., testPlugin()],
|
|
26
25
|
});
|
|
@@ -28,7 +27,7 @@ export default defineConfig({
|
|
|
28
27
|
|
|
29
28
|
## Test file
|
|
30
29
|
|
|
31
|
-
Modern.js default recognized test file paths are: `<rootDir>/src/**/*.test.[jt]s?(x)` and `<rootDir>/tests/**/*.test.[jt]s?(x)
|
|
30
|
+
Modern.js default recognized test file paths are: `<rootDir>/src/**/*.test.[jt]s?(x)` and `<rootDir>/tests/**/*.test.[jt]s?(x)`.
|
|
32
31
|
|
|
33
32
|
If you need to customize the test directory, you can configure it with [tools.jest](/configure/app/tools/jest).
|
|
34
33
|
|
|
@@ -40,7 +39,7 @@ Modern.js test support [testing-library](https://testing-library.com/docs/). API
|
|
|
40
39
|
import { render, screen } from '@modern-js/runtime/testing';
|
|
41
40
|
```
|
|
42
41
|
|
|
43
|
-
Other Modern.js supported testing APIs can be found [here](/apis/app/runtime/testing/cleanup)
|
|
42
|
+
Other Modern.js supported testing APIs can be found [here](/apis/app/runtime/testing/cleanup).
|
|
44
43
|
|
|
45
44
|
## transform
|
|
46
45
|
|
|
@@ -90,7 +90,7 @@ export default async ({ params }: LoaderArgs) => {
|
|
|
90
90
|
};
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
When accessing `/user/123`, the parameters of the `loader` function are `{ params: { id: '123' } }`.
|
|
94
94
|
|
|
95
95
|
#### `request`
|
|
96
96
|
|
|
@@ -220,6 +220,26 @@ Currently, only CSR is supported, so stay tuned for Streaming SSR.
|
|
|
220
220
|
|
|
221
221
|
:::
|
|
222
222
|
|
|
223
|
+
Add the following code to `user/layout.loader.ts`:
|
|
224
|
+
|
|
225
|
+
```ts title="routes/user/layout.loader.ts"
|
|
226
|
+
import { defer } from "@edenx/runtime/router"
|
|
227
|
+
|
|
228
|
+
const loader = () =>
|
|
229
|
+
defer({
|
|
230
|
+
userInfo: new Promise((resolve) => {
|
|
231
|
+
setTimeout(() => {
|
|
232
|
+
resolve({
|
|
233
|
+
age: 1,
|
|
234
|
+
name: 'user layout'
|
|
235
|
+
})
|
|
236
|
+
}, 1000)
|
|
237
|
+
})
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
export default loader;
|
|
241
|
+
```
|
|
242
|
+
|
|
223
243
|
Add the following code to `user/layout.tsx`:
|
|
224
244
|
|
|
225
245
|
```tsx title="routes/user/layout.tsx"
|
|
@@ -230,13 +250,6 @@ import {
|
|
|
230
250
|
Outlet
|
|
231
251
|
} from '@modern-js/runtime/router';
|
|
232
252
|
|
|
233
|
-
export const loader = () => {
|
|
234
|
-
return defer({
|
|
235
|
-
// fetchUserInfo 是一个异步函数,返回用户信息
|
|
236
|
-
userInfo: fetchUserInfo(),
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
|
|
240
253
|
export default function UserLayout() {
|
|
241
254
|
const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
|
|
242
255
|
return (
|
|
@@ -167,4 +167,4 @@ const foo = TWO;
|
|
|
167
167
|
const foo = 1 + 1;
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
In most cases, `source.globalVars` is already sufficient to replace variables. But the values passed in by `source.globalVars` will be serialized by JSON by default. So it cannot be replaced like `1 + 1` in the example above,at this time, we need use [`source.define`](/configure/app/source/define)
|
|
170
|
+
In most cases, `source.globalVars` is already sufficient to replace variables. But the values passed in by `source.globalVars` will be serialized by JSON by default. So it cannot be replaced like `1 + 1` in the example above,at this time, we need use [`source.define`](/configure/app/source/define).
|
|
@@ -4,7 +4,7 @@ sidebar_position: 9
|
|
|
4
4
|
---
|
|
5
5
|
# HTML Template
|
|
6
6
|
|
|
7
|
-
Modern.js provides **JSX syntax** and **HTML(
|
|
7
|
+
Modern.js provides **JSX syntax** and **HTML(EJS) syntax** for customizing HTML template.
|
|
8
8
|
|
|
9
9
|
## JSX syntax
|
|
10
10
|
|
|
@@ -14,14 +14,14 @@ For example the following directory structure:
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
│
|
|
21
|
-
│
|
|
22
|
-
|
|
23
|
-
│
|
|
24
|
-
|
|
17
|
+
└── src
|
|
18
|
+
├── Document.tsx
|
|
19
|
+
├── entry-a
|
|
20
|
+
│ ├── Document.tsx
|
|
21
|
+
│ └── routes
|
|
22
|
+
├── entry-b
|
|
23
|
+
│ └── routes
|
|
24
|
+
└── modern-app-env.d.ts
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
`entry-a` will take precedence over the `Docoument.[jt]sx` file under the current entry. If the current entry does not have a `Document.[jt]sx` file, such as `entry-b`, it will look for the `Document.[jt]sx` file in the root directory.
|
|
@@ -42,7 +42,7 @@ These components are rendered:
|
|
|
42
42
|
|
|
43
43
|
- `Body`:Provide the ability of native Body Element, which needs to contain the `<Root>` component internally, and also supports other elements as child elements at the same time, such as adding footers.
|
|
44
44
|
|
|
45
|
-
- `Root`:React root element `<div id='root'></div
|
|
45
|
+
- `Root`:React root element `<div id='root'></div>`. the default element id is `id = 'root'`, can set `props.rootId` to change the id.Child components can be added, and will also be rendered into HTML templates, which will be overwritten when React rendering is complete, generally used to implement global Loading.
|
|
46
46
|
|
|
47
47
|
- `Head`:Provides native Head Element capabilities and automatically populates `<meta>`, as well as the `<Scripts>` component.
|
|
48
48
|
|
|
@@ -193,7 +193,7 @@ In the application root directory, create the `config/html/` directory, which su
|
|
|
193
193
|
</html>
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
HTML Fragments support the use [Lodash template](https://lodash.com/docs/4.17.15#template)
|
|
196
|
+
HTML Fragments support the use [Lodash template](https://lodash.com/docs/4.17.15#template).
|
|
197
197
|
|
|
198
198
|
For example, insert a script in `body.html`:
|
|
199
199
|
|
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
};
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
when access `http://localhost:8080/api/getInfo`, the api will return json `{ "data": [1, 2, 3, 4] }
|
|
43
|
+
when access `http://localhost:8080/api/getInfo`, the api will return json `{ "data": [1, 2, 3, 4] }`.
|
|
44
44
|
|
|
45
45
|
## Return Random Data
|
|
46
46
|
|
|
@@ -77,3 +77,23 @@ export default {
|
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
79
|
```
|
|
80
|
+
|
|
81
|
+
## Use Mock On Demand
|
|
82
|
+
|
|
83
|
+
Under the `config/mock/index.ts`, you can also export the `config` to control the Mock service.
|
|
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
|
+
Currently only the `enable` configuration is supported, through which developers can control whether to execute Mock.
|
|
96
|
+
|
|
97
|
+
:::note
|
|
98
|
+
After modifying `config`, there is no need to restart the service, which will take effect immediately.
|
|
99
|
+
:::
|
|
@@ -6,7 +6,7 @@ sidebar_position: 5
|
|
|
6
6
|
|
|
7
7
|
## Local Proxy
|
|
8
8
|
|
|
9
|
-
Modern.js provides a way to configure the development proxy in [
|
|
9
|
+
Modern.js provides a way to configure the development proxy in [tools.devServer](/configure/app/tools/dev-server). For example, to proxy the local interface to an online address:
|
|
10
10
|
|
|
11
11
|
```ts title="modern.config.ts"
|
|
12
12
|
import { defineConfig } from '@modern-js/app-tools';
|
|
@@ -28,7 +28,7 @@ export default defineConfig({
|
|
|
28
28
|
when access `http://localhost:8080/go/api`, the response content is returned from [http://www.example.com/](http://www.example.com/).
|
|
29
29
|
|
|
30
30
|
:::info
|
|
31
|
-
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
|
|
31
|
+
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
|
|
32
32
|
|
|
33
33
|
:::
|
|
34
34
|
|
|
@@ -132,7 +132,7 @@ With a file directory named `[]`, the generated route will be used as a dynamic
|
|
|
132
132
|
|
|
133
133
|
The `routes/[id]/page.tsx` file is converted to the `/:id` route. Except for the `/blog` route that exactly matches, all other `/xxx` will match this route.
|
|
134
134
|
|
|
135
|
-
In component, you can get the corresponding named parameters through [useParams](/apis/app/runtime/router
|
|
135
|
+
In component, you can get the corresponding named parameters through [useParams](/apis/app/runtime/router/router#useparams).
|
|
136
136
|
|
|
137
137
|
### Catch all routing
|
|
138
138
|
|
|
@@ -152,7 +152,7 @@ For example, the following directory structure:
|
|
|
152
152
|
└── page.tsx
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
The `routes/$.tsx` component is rendered when accessing any path that does not match, and again, the remainder of the url can be captured in `$.tsx` using [useParams](/apis/app/runtime/router
|
|
155
|
+
The `routes/$.tsx` component is rendered when accessing any path that does not match, and again, the remainder of the url can be captured in `$.tsx` using [useParams](/apis/app/runtime/router/router#useparams).
|
|
156
156
|
|
|
157
157
|
```ts title="$.tsx"
|
|
158
158
|
import { useParams } from '@modern-js/runtime/router';
|
|
@@ -235,7 +235,7 @@ When the component exists in a routing directory, the component render error is
|
|
|
235
235
|
|
|
236
236
|
{/* Todo API 路由 */}
|
|
237
237
|
|
|
238
|
-
Within the `<ErrorBoundary>` component, you can use [useRouteError](/apis/app/runtime/router
|
|
238
|
+
Within the `<ErrorBoundary>` component, you can use [useRouteError](/apis/app/runtime/router/router#useparams) to get the specific information of the error:
|
|
239
239
|
|
|
240
240
|
```tsx
|
|
241
241
|
import { useRouteError } from '@modern-js/runtime/router';
|
|
@@ -295,19 +295,17 @@ export default () => {
|
|
|
295
295
|
When working with SSR, the browser side can get the data returned by `init` during SSR, and the developer can decide whether to retrieve the data on the browser side to overwrite the SSR data, for example:
|
|
296
296
|
|
|
297
297
|
```tsx title="src/routes/layout.tsx"
|
|
298
|
-
import {
|
|
299
|
-
RuntimeContext,
|
|
300
|
-
} from '@modern-js/runtime';
|
|
298
|
+
import { RuntimeContext } from '@modern-js/runtime';
|
|
301
299
|
|
|
302
300
|
export const init = (context: RuntimeContext) => {
|
|
303
|
-
if (process.env.
|
|
301
|
+
if (process.env.MODERN_TARGET === 'node') {
|
|
304
302
|
return {
|
|
305
303
|
message: 'Hello World By Server',
|
|
306
304
|
}
|
|
307
305
|
} else {
|
|
308
306
|
const { context } = runtimeContext;
|
|
309
307
|
const data = context.getInitData();
|
|
310
|
-
//
|
|
308
|
+
// If do not get the expected data
|
|
311
309
|
if (!data.message) {
|
|
312
310
|
return {
|
|
313
311
|
message: 'Hello World By Client'
|