@modern-js/main-doc 2.0.0-beta.2 → 2.0.0-beta.4
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/en/docusaurus-plugin-content-docs/current/apis/app/commands/inspect.md +0 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +17 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +0 -22
- package/en/docusaurus-plugin-content-docs/current/components/init-app.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +1 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/asset-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/hmr.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/https.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/port.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/progress-bar.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/start-url.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/app-icon.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/crossorigin.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/disable-html-folder.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/mount-id.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title-by-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/asset-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/assets-retry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/charset.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/clean-dist-path.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/convert-to-rem.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/copy.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/css-module-local-ident-name.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/data-uri-limit.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-module-extension.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-filename-hash.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-inline-runtime-chunk.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-minimize.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-source-map.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/dist-path.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-fallback.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-manifest.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-scripts.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-styles.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-latest-decorators.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/externals.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/filename.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/legal-comments.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/override-browserslist.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/polyfill.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/svg-default-export.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/build-cache.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/bundle-analyze.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/chunk-split.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/print-file-size.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/profile.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-console.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-moment-locale.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/security/sri.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +2 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/alias.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/compile-js-data-uri.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/define.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/global-vars.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/include.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/module-scopes.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/pre-entry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-extension-prefix.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-main-fields.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/autoprefixer.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/babel.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-extract.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/dev-server.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/esbuild.md +16 -39
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/html-plugin.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/inspector.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/less.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/minify-css.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/postcss.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/pug.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/sass.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/style-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/styled-components.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/swc.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/terser.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-checker.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-loader.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack-chain.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/builder.md +46 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-in-js.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-modules.md +86 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/less-sass.md +17 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/postcss.md +81 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/tailwindcss.md +95 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +66 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +270 -0
- package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +116 -0
- package/en/docusaurus-plugin-content-docs/current/guides/concept/lifecycle.md +15 -0
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +162 -0
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/upgrade.md +78 -0
- package/{zh/tutorials/first-app → en/docusaurus-plugin-content-docs/current/guides}/overview.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/introduction.md +1 -1
- package/en/docusaurus-plugin-content-docs/current.json +29 -29
- package/package.json +3 -3
- package/scripts/config.ts +2 -2
- package/zh/apis/app/commands/inspect.md +0 -4
- package/zh/apis/app/commands/new.md +1 -3
- package/zh/apis/app/hooks/src/index_.md +6 -5
- package/zh/apis/app/runtime/app/_category_.json +1 -1
- package/zh/apis/app/runtime/bff/_category_.json +1 -1
- package/zh/apis/app/runtime/core/_category_.json +1 -1
- package/zh/apis/app/runtime/core/bootstrap.md +17 -3
- package/zh/apis/app/runtime/model/_category_.json +1 -1
- package/zh/apis/app/runtime/model/create-app.md +1 -1
- package/zh/apis/app/runtime/model/use-store.md +1 -23
- package/zh/apis/app/runtime/router/_category_.json +1 -1
- package/zh/apis/app/runtime/ssr/_category_.json +1 -1
- package/zh/apis/app/runtime/testing/_category_.json +1 -1
- package/zh/apis/app/runtime/utility/_category_.json +1 -1
- package/zh/apis/app/runtime/web-server/_category_.json +1 -1
- package/zh/components/debug-app.md +18 -0
- package/zh/components/global-proxy.md +28 -0
- package/zh/components/init-app.md +44 -0
- package/zh/components/prerequisites.md +19 -0
- package/zh/components/reduck-migration.md +1 -0
- package/zh/configure/app/dev/asset-prefix.md +1 -1
- package/zh/configure/app/dev/hmr.md +1 -1
- package/zh/configure/app/dev/https.md +1 -1
- package/zh/configure/app/dev/port.md +1 -1
- package/zh/configure/app/dev/progress-bar.md +1 -1
- package/zh/configure/app/dev/start-url.md +1 -1
- package/zh/configure/app/experiments/_category_.json +4 -0
- package/zh/configure/app/experiments/lazy-compilation.md +1 -1
- package/zh/configure/app/html/_category_.json +4 -0
- package/zh/configure/app/html/app-icon.md +1 -1
- package/zh/configure/app/html/crossorigin.md +1 -1
- package/zh/configure/app/html/disable-html-folder.md +1 -1
- package/zh/configure/app/html/favicon-by-entries.md +1 -1
- package/zh/configure/app/html/favicon.md +1 -1
- package/zh/configure/app/html/inject-by-entries.md +1 -1
- package/zh/configure/app/html/inject.md +1 -1
- package/zh/configure/app/html/meta-by-entries.md +1 -1
- package/zh/configure/app/html/meta.md +1 -1
- package/zh/configure/app/html/mount-id.md +1 -1
- package/zh/configure/app/html/template-by-entries.md +1 -1
- package/zh/configure/app/html/template-parameters-by-entries.md +1 -1
- package/zh/configure/app/html/template-parameters.md +1 -1
- package/zh/configure/app/html/template.md +1 -1
- package/zh/configure/app/html/title-by-entries.md +1 -1
- package/zh/configure/app/html/title.md +1 -1
- package/zh/configure/app/output/asset-prefix.md +1 -1
- package/zh/configure/app/output/assets-retry.md +1 -1
- package/zh/configure/app/output/charset.md +1 -1
- package/zh/configure/app/output/clean-dist-path.md +1 -1
- package/zh/configure/app/output/convert-to-rem.md +1 -1
- package/zh/configure/app/output/copy.md +1 -1
- package/zh/configure/app/output/css-module-local-ident-name.md +1 -1
- package/zh/configure/app/output/data-uri-limit.md +1 -1
- package/zh/configure/app/output/disable-css-extract.md +1 -1
- package/zh/configure/app/output/disable-css-module-extension.md +1 -1
- package/zh/configure/app/output/disable-filename-hash.md +1 -1
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +1 -1
- package/zh/configure/app/output/disable-minimize.md +1 -1
- package/zh/configure/app/output/disable-source-map.md +1 -1
- package/zh/configure/app/output/disable-ts-checker.md +1 -1
- package/zh/configure/app/output/dist-path.md +1 -1
- package/zh/configure/app/output/enable-asset-fallback.md +1 -1
- package/zh/configure/app/output/enable-asset-manifest.md +1 -1
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
- package/zh/configure/app/output/enable-inline-scripts.md +1 -1
- package/zh/configure/app/output/enable-inline-styles.md +1 -1
- package/zh/configure/app/output/enable-latest-decorators.md +1 -1
- package/zh/configure/app/output/externals.md +1 -1
- package/zh/configure/app/output/filename.md +1 -1
- package/zh/configure/app/output/legal-comments.md +1 -1
- package/zh/configure/app/output/override-browserslist.md +1 -1
- package/zh/configure/app/output/polyfill.md +1 -1
- package/zh/configure/app/output/ssg.md +118 -114
- package/zh/configure/app/output/svg-default-export.md +1 -1
- package/zh/configure/app/performance/_category_.json +4 -0
- package/zh/configure/app/performance/build-cache.md +1 -1
- package/zh/configure/app/performance/bundle-analyze.md +1 -1
- package/zh/configure/app/performance/chunk-split.md +1 -1
- package/zh/configure/app/performance/print-file-size.md +1 -1
- package/zh/configure/app/performance/profile.md +1 -1
- package/zh/configure/app/performance/remove-console.md +1 -1
- package/zh/configure/app/performance/remove-moment-locale.md +1 -1
- package/zh/configure/app/plugins.md +1 -1
- package/zh/configure/app/runtime/state.md +13 -0
- package/zh/configure/app/security/_category_.json +4 -0
- package/zh/configure/app/security/sri.md +1 -1
- package/zh/configure/app/server/routes.md +2 -4
- package/zh/configure/app/server/ssr.md +0 -2
- package/zh/configure/app/source/alias.md +1 -1
- package/zh/configure/app/source/compile-js-data-uri.md +1 -1
- package/zh/configure/app/source/define.md +1 -1
- package/zh/configure/app/source/exclude.md +1 -1
- package/zh/configure/app/source/global-vars.md +1 -1
- package/zh/configure/app/source/include.md +1 -1
- package/zh/configure/app/source/module-scopes.md +1 -1
- package/zh/configure/app/source/pre-entry.md +1 -1
- package/zh/configure/app/source/resolve-extension-prefix.md +1 -1
- package/zh/configure/app/source/resolve-main-fields.md +1 -1
- package/zh/configure/app/tools/autoprefixer.md +1 -1
- package/zh/configure/app/tools/babel.md +1 -1
- package/zh/configure/app/tools/css-extract.md +1 -1
- package/zh/configure/app/tools/css-loader.md +1 -1
- package/zh/configure/app/tools/dev-server.md +1 -1
- package/zh/configure/app/tools/esbuild.md +16 -39
- package/zh/configure/app/tools/html-plugin.md +1 -1
- package/zh/configure/app/tools/inspector.md +1 -1
- package/zh/configure/app/tools/less.md +1 -1
- package/zh/configure/app/tools/minify-css.md +1 -1
- package/zh/configure/app/tools/postcss.md +1 -1
- package/zh/configure/app/tools/pug.md +1 -1
- package/zh/configure/app/tools/sass.md +1 -1
- package/zh/configure/app/tools/style-loader.md +1 -1
- package/zh/configure/app/tools/styled-components.md +1 -1
- package/zh/configure/app/tools/swc.md +42 -0
- package/zh/configure/app/tools/terser.md +1 -1
- package/zh/configure/app/tools/ts-checker.md +1 -1
- package/zh/configure/app/tools/ts-loader.md +1 -1
- package/zh/configure/app/tools/webpack-chain.md +1 -1
- package/zh/configure/app/tools/webpack.md +1 -1
- package/zh/guides/advanced-features/bff/bff-proxy.md +1 -1
- package/zh/guides/advanced-features/compatibility.md +2 -38
- package/zh/guides/advanced-features/custom-app.md +23 -19
- package/zh/guides/advanced-features/ssg.md +73 -62
- package/zh/guides/advanced-features/ssr.md +142 -36
- package/zh/guides/advanced-features/testing.md +33 -1
- package/zh/guides/advanced-features/web-server.md +2 -2
- package/zh/guides/basic-features/builder.md +46 -0
- package/zh/guides/basic-features/css/_category_.json +1 -1
- package/zh/guides/basic-features/css/less-sass.md +1 -14
- package/zh/guides/basic-features/css/tailwindcss.md +2 -6
- package/zh/guides/basic-features/data-fetch.md +1 -1
- package/zh/guides/basic-features/env-vars.md +34 -0
- package/zh/guides/basic-features/html.md +182 -0
- package/zh/guides/basic-features/mock.md +3 -9
- package/zh/guides/basic-features/proxy.md +2 -27
- package/zh/guides/basic-features/routes.md +32 -35
- package/zh/guides/concept/entries.md +8 -9
- package/zh/guides/get-started/quick-start.md +6 -78
- package/zh/guides/get-started/upgrade.md +8 -8
- package/zh/guides/topic-detail/framework-plugin/extend.md +3 -4
- package/zh/{apis/app/runtime/plugin/hook-api.md → guides/topic-detail/framework-plugin/hook-list.md} +42 -135
- package/zh/{apis/app/runtime/plugin → guides/topic-detail/framework-plugin}/hook.md +2 -3
- package/zh/guides/topic-detail/framework-plugin/implement.md +21 -10
- package/zh/guides/topic-detail/framework-plugin/introduction.md +49 -0
- package/{en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin → zh/guides/topic-detail/framework-plugin}/plugin-api.md +3 -4
- package/zh/guides/topic-detail/framework-plugin/relationship.md +2 -3
- package/zh/guides/topic-detail/model/quick-start.md +5 -1
- package/zh/guides/topic-detail/model/test-model.md +2 -2
- package/zh/guides/topic-detail/monorepo/intro.md +1 -1
- package/zh/guides/troubleshooting/dependencies.md +0 -69
- package/zh/tutorials/first-app/_category_.json +1 -1
- package/zh/tutorials/first-app/c01-start.md +94 -0
- package/zh/tutorials/first-app/c02-component.md +56 -0
- package/zh/tutorials/first-app/c03-css.md +305 -0
- package/zh/tutorials/first-app/c04-routes.md +169 -0
- package/zh/tutorials/first-app/c05-loader.md +82 -0
- package/zh/tutorials/first-app/c06-model.md +256 -0
- package/zh/tutorials/first-app/c07-container.md +268 -0
- package/zh/tutorials/first-app/c08-entries.md +134 -0
- package/zh/tutorials/foundations/introduction.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/default-alias.md +0 -25
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/_category_.json +0 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/abstract.md +0 -26
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook-api.md +0 -896
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook.md +0 -170
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-modern-mode.md +0 -34
- package/zh/apis/app/runtime/default-alias.md +0 -23
- package/zh/apis/app/runtime/plugin/_category_.json +0 -4
- package/zh/apis/app/runtime/plugin/abstract.md +0 -26
- package/zh/apis/app/runtime/plugin/plugin-api.md +0 -117
- package/zh/apis/generator/overview.md +0 -32
- package/zh/configure/app/output/enable-modern-mode.md +0 -34
- package/zh/guides/basic-features/image.md +0 -43
- package/zh/guides/topic-detail/compile-speed.md +0 -182
- package/zh/guides/topic-detail/framework-plugin/abstract.md +0 -27
- package/zh/guides/topic-detail/monorepo/deploy.md +0 -43
- package/zh/guides/troubleshooting/compile.md +0 -379
- package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +0 -25
- package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +0 -118
- package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +0 -29
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +0 -44
- package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +0 -18
- package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +0 -31
- package/zh/tutorials/first-app/c01-getting-started/_category_.json +0 -3
- package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -79
- package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +0 -36
- package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +0 -21
- package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +0 -3
- package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +0 -55
- package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +0 -66
- package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +0 -11
- package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +0 -63
- package/zh/tutorials/first-app/c03-ide/_category_.json +0 -3
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +0 -67
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +0 -111
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +0 -67
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +0 -3
- package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +0 -68
- package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +0 -92
- package/zh/tutorials/first-app/c05-component/_category_.json +0 -3
- package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +0 -110
- package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +0 -148
- package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +0 -84
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +0 -83
- package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +0 -77
- package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +0 -113
- package/zh/tutorials/first-app/c06-css-and-component/_category_.json +0 -3
- package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +0 -64
- package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +0 -100
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +0 -74
- package/zh/tutorials/first-app/c07-app-entry/_category_.json +0 -3
- package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +0 -153
- package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -310
- package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +0 -3
- package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +0 -30
- package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +0 -93
- package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +0 -205
- package/zh/tutorials/first-app/c09-bff/_category_.json +0 -3
- package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +0 -23
- package/zh/tutorials/first-app/c10-model/10.2-add-model.md +0 -185
- package/zh/tutorials/first-app/c10-model/10.3-use-model.md +0 -54
- package/zh/tutorials/first-app/c10-model/10.4-testing.md +0 -69
- package/zh/tutorials/first-app/c10-model/_category_.json +0 -3
- package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +0 -274
- package/zh/tutorials/first-app/c11-container/11.2-add-container.md +0 -106
- package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +0 -61
- package/zh/tutorials/first-app/c11-container/11.4-testing.md +0 -56
- package/zh/tutorials/first-app/c11-container/_category_.json +0 -3
@@ -0,0 +1,270 @@
|
|
1
|
+
---
|
2
|
+
title: Routes
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
Modern.js build-in provides partial support for [React Router 6](https://reactrouter.com/en/main) and provides various types of routing modes. According to different [entry](/docs/guides/concept/entries) types, routing is divided into three modes, namely **Conventional routing**, **Self-controlled routing** and **Other**.
|
7
|
+
|
8
|
+
:::note
|
9
|
+
The routes mentioned in this section are client routes, that is, SPA routes.
|
10
|
+
:::
|
11
|
+
|
12
|
+
## Conventional routing
|
13
|
+
|
14
|
+
With `routes/` as the agreed entry, Modern.js will automatically generate the corresponding routing structure based on the file system.
|
15
|
+
|
16
|
+
Modern.js supports the popular convention routing mode in the industry: **nested routing**. When using nested routing, the routing of the page corresponds the UI structure, and we will introduce this routing mode in detail.
|
17
|
+
|
18
|
+
|
19
|
+
```
|
20
|
+
/user/johnny/profile /user/johnny/posts
|
21
|
+
+------------------+ +-----------------+
|
22
|
+
| User | | User |
|
23
|
+
| +--------------+ | | +-------------+ |
|
24
|
+
| | Profile | | +------------> | | Posts | |
|
25
|
+
| | | | | | | |
|
26
|
+
| +--------------+ | | +-------------+ |
|
27
|
+
+------------------+ +-----------------+
|
28
|
+
```
|
29
|
+
|
30
|
+
### Routing file convention
|
31
|
+
|
32
|
+
There are two file conventions in the `routes/` directory `layout.[jt]sx` and `page.[jt]sx`(abbreviated as `.tsx` later). These two files determine the layout hierarchy of the application, where `layout.tsx` is used as the layout component, and `page.tsx` is used as the content component, which is the leaf node of the entire routing table.
|
33
|
+
|
34
|
+
For example, here `routes/layout.tsx` will be used as the layout component of all components under the `/` route:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
.
|
38
|
+
└── routes
|
39
|
+
├── layout.tsx
|
40
|
+
├── page.tsx
|
41
|
+
└── user
|
42
|
+
├── layout.tsx
|
43
|
+
└── page.tsx
|
44
|
+
```
|
45
|
+
|
46
|
+
When the route is `/`, there will be the following UI layout:
|
47
|
+
|
48
|
+
```tsx
|
49
|
+
<Layout>
|
50
|
+
<Page />
|
51
|
+
</Layout>
|
52
|
+
```
|
53
|
+
|
54
|
+
Similarly, `routes/user/layout.tsx` will be used as a layout component for all components under the `/user` route. When the route is `/user`, the following UI layout will be available:
|
55
|
+
|
56
|
+
```tsx
|
57
|
+
<Layout>
|
58
|
+
<UserLayout>
|
59
|
+
<UserPage>
|
60
|
+
<UserLayout>
|
61
|
+
</Layout>
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Layout
|
65
|
+
|
66
|
+
`<Layout>` component refers to all `layout.tsx` files in the `routes/` directory, which represent the layout of the corresponding route segment, and use `<Outlet>` to represent sub-components.
|
67
|
+
|
68
|
+
:::note
|
69
|
+
`<Outlet>` is a new API in React Router 6, see [Outlet](https://reactrouter.com/en/main/components/outlet#outlet) for details.
|
70
|
+
:::
|
71
|
+
|
72
|
+
In order to facilitate the introduction of the relationship between `<Layout>` and `<Outlet>`, the following file directory example:
|
73
|
+
|
74
|
+
```bash
|
75
|
+
.
|
76
|
+
└── routes
|
77
|
+
├── blog
|
78
|
+
│ └── page.tsx
|
79
|
+
├── layout.tsx
|
80
|
+
├── page.tsx
|
81
|
+
└── user
|
82
|
+
├── layout.tsx
|
83
|
+
└── page.tsx
|
84
|
+
```
|
85
|
+
|
86
|
+
1. When the route is `/`, `<Outlet>` in `routes/layout.tsx` represents the component exported in `routes/page.tsx`, generating the following UI structure:
|
87
|
+
|
88
|
+
```tsx
|
89
|
+
<Layout>
|
90
|
+
<Page />
|
91
|
+
</Layout>
|
92
|
+
```
|
93
|
+
|
94
|
+
2. When the route is `/blog`, `<Outlet>` in `routes/layout.tsx` represents the component exported in `routes/blog/page.tsx`, generating the following UI structure:
|
95
|
+
|
96
|
+
```tsx
|
97
|
+
<Layout>
|
98
|
+
<BlogPage />
|
99
|
+
</Layout>
|
100
|
+
```
|
101
|
+
|
102
|
+
3. When the route is `/user`, `<Outlet>` in `routes/layout.tsx` represents the component exported in `routes/user/layout.tsx`. `<Outlet>` in `routes/user/layout.tsx` represents the component exported in `routes/user/page.tsx`. Generate the following UI structure:
|
103
|
+
|
104
|
+
```tsx
|
105
|
+
<Layout>
|
106
|
+
<UserLayout>
|
107
|
+
<UserPage>
|
108
|
+
<UserLayout>
|
109
|
+
</Layout>
|
110
|
+
```
|
111
|
+
|
112
|
+
In summary, if there is a `layout.tsx` in the file directory of the subroute, the `<Outlet>` in the previous `layout.tsx` is the `layout.tsx` under the file directory of the subroute, otherwise it is the `page.tsx` under the file directory of the subroute.
|
113
|
+
|
114
|
+
#### Page
|
115
|
+
|
116
|
+
All routes should end with the `<Page>` component. In the `page.tsx` file, if the developer introduces the `<Outlet>` component, it will have no effect.
|
117
|
+
|
118
|
+
### Dynamic routing
|
119
|
+
|
120
|
+
With a file directory named `[]`, the generated route will be used as a dynamic route. For example the following file directory:
|
121
|
+
|
122
|
+
```
|
123
|
+
└── routes
|
124
|
+
├── [id]
|
125
|
+
│ └── page.tsx
|
126
|
+
├── blog
|
127
|
+
│ └── page.tsx
|
128
|
+
└── page.tsx
|
129
|
+
```
|
130
|
+
|
131
|
+
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.
|
132
|
+
|
133
|
+
In component, you can get the corresponding named parameters through [useParams](/docs/apis/app/runtime/router/#useparams).
|
134
|
+
|
135
|
+
### Layout with No Path
|
136
|
+
|
137
|
+
When a directory name begins with `__`, the corresponding directory name is not converted to the actual routing path, such as the following file directory:
|
138
|
+
|
139
|
+
```
|
140
|
+
.
|
141
|
+
└── routes
|
142
|
+
├── __auth
|
143
|
+
│ ├── layout.tsx
|
144
|
+
│ ├── login
|
145
|
+
│ │ └── page.tsx
|
146
|
+
│ └── signup
|
147
|
+
│ └── page.tsx
|
148
|
+
├── layout.tsx
|
149
|
+
└── page.tsx
|
150
|
+
```
|
151
|
+
|
152
|
+
Modern.js will generate two routes, `/login` and `/sign`, `__auth/layout.tsx` component will be used as the layout component of `login/page.tsx` and `signup/page.tsx`, but __auth will not be used as the route path fragment.
|
153
|
+
|
154
|
+
|
155
|
+
This feature is useful when you need to do separate layouts for certain types of routes, or when you want to categorize routes.
|
156
|
+
|
157
|
+
### No Layout
|
158
|
+
|
159
|
+
In some cases, the project needs more sophisticated routes, but these routes do not have independent UI layouts. If you create a route like a normal file directory, the directory level will be deeper.
|
160
|
+
|
161
|
+
Therefore Modern.js supports splitting routing fragments by `.` instead of file directory. For example, when you need `/user/profile/2022/edit`, you can directly create the following file:
|
162
|
+
|
163
|
+
```
|
164
|
+
└── routes
|
165
|
+
├── user.profile.[id].edit
|
166
|
+
│ └── page.tsx
|
167
|
+
├── layout.tsx
|
168
|
+
└── page.tsx
|
169
|
+
```
|
170
|
+
|
171
|
+
When accessing a route, you will get the following UI layout:
|
172
|
+
|
173
|
+
```tsx
|
174
|
+
<RootLayout>
|
175
|
+
<UserProfileEdit /> // routes/user.profile.[id].edit/page.tsx
|
176
|
+
</RootLayout>
|
177
|
+
```
|
178
|
+
|
179
|
+
### Loading
|
180
|
+
|
181
|
+
In each layer directory under `routes/`, developers can create `loading.tsx` files and export a `<Loading>` component by default.
|
182
|
+
|
183
|
+
When the component exists in the routing directory, all routing switches under this level of subrouting will use the `<Loading>` component as the Fallback UI when JS Chunk is loaded. When the `layout.tsx` file is not defined in this directory, the `<Loading>` component will not take effect. For example, the following file directory:
|
184
|
+
|
185
|
+
```bash
|
186
|
+
.
|
187
|
+
└── routes
|
188
|
+
├── blog
|
189
|
+
│ ├── [id]
|
190
|
+
│ │ └── page.tsx
|
191
|
+
│ └── page.tsx
|
192
|
+
├── layout.tsx
|
193
|
+
├── loading.tsx
|
194
|
+
└── page.tsx
|
195
|
+
```
|
196
|
+
|
197
|
+
When a route jumps from `/` to `/blog`, if the JS Chunk of the `<Blog>` component is not loaded, the component UI exported in `loading.tsx` will be displayed first. But when jumping from `/blog` to `/blog/20220101`, it will not be displayed.
|
198
|
+
|
199
|
+
### ErrorBoundary
|
200
|
+
|
201
|
+
In each layer directory under `routes/`, the developer can also define a `error.tsx` file, and export a `<ErrorBoundary>` component by default.
|
202
|
+
|
203
|
+
When the component exists in a routing directory, the component render error is caught by the `ErrorBoundary` component. The `<ErrorBoundary>` component does not take effect when the directory does not have a `layout.tsx` file defined.
|
204
|
+
|
205
|
+
`<ErrorBoundary>` can return the UI view when the error occurred. When the `<ErrorBoundary>` component is not declared at the current level, the error will bubble up to the higher component until it is caught or throws an error. At the same time, when a component fails, it will only affect the routed component and sub-component that caught the error. The state and view of other components are not affected and can continue to interact.
|
206
|
+
|
207
|
+
<!-- Todo API 路由-->
|
208
|
+
Within the `<ErrorBoundary>` component, you can use [useRouteError](/docs/apis/app/runtime/router/#useparams) to get the specific information of the error:
|
209
|
+
|
210
|
+
```tsx
|
211
|
+
import { useRouteError } from '@modern-js/runtime/router';
|
212
|
+
export default const ErrorBoundary = () => {
|
213
|
+
const error = useRouteError();
|
214
|
+
return (
|
215
|
+
<div>
|
216
|
+
<h1>{error.status}</h1>
|
217
|
+
<h2>{error.message}</h2>
|
218
|
+
</div>
|
219
|
+
)
|
220
|
+
}
|
221
|
+
```
|
222
|
+
|
223
|
+
## Self-controlled routing
|
224
|
+
|
225
|
+
With `src/App.tsx` as the agreed entry, Modern.js will not do additional operations with multiple routes, developers can use the React Router 6 API for development by themselves, for example:
|
226
|
+
|
227
|
+
```tsx
|
228
|
+
import { Route, Routes, BrowserRouter } from '@modern-js/runtime/router';
|
229
|
+
import { StaticRouter } from '@modern-js/runtime/router/server';
|
230
|
+
|
231
|
+
const Router = typeof window === 'undefined' ? StaticRouter : BrowserRouter;
|
232
|
+
export default () => {
|
233
|
+
return (
|
234
|
+
<Router location={context.request.pathname}>
|
235
|
+
<Routes>
|
236
|
+
<Route index element={<div>index</div>} />
|
237
|
+
<Route path="about" element={<div>about</div>} />
|
238
|
+
</Routes>
|
239
|
+
</Router>
|
240
|
+
);
|
241
|
+
};
|
242
|
+
```
|
243
|
+
|
244
|
+
:::note
|
245
|
+
Under self-controlled routing, if developers want to use the [Loader API](https://reactrouter.com/en/main/hooks/use-loader-data#useloaderdata) capabilities in React Router 6 in SSR will be relatively complicated, it is recommended to use conventional routing directly. Modern.js has already encapsulated everything for you.
|
246
|
+
<!-- Todo 嵌套路由带来的优化可以补充下文档-->
|
247
|
+
If the project only wants to upgrade to React Router 6 and does not want to use the optimizations brought by nested routing, then [useLoader](/docs/apis/app/runtime/core/use-loader) will still work under SSR.
|
248
|
+
:::
|
249
|
+
|
250
|
+
## Other
|
251
|
+
|
252
|
+
By default, Modern.js turn on the built-in routing scheme, React Router.
|
253
|
+
|
254
|
+
```js
|
255
|
+
export default defineConfig({
|
256
|
+
runtime: {
|
257
|
+
router: true,
|
258
|
+
}
|
259
|
+
})
|
260
|
+
```
|
261
|
+
|
262
|
+
Modern.js exposes the React Router API from the `@modern-js/runtime/router` namespace for developers to use, ensuring that developers and Modern.js use the same code. In addition, in this case, the React Router code will be packaged into JS products. If the project already has its own routing scheme, or does not need to use client routing, this feature can be turned off.
|
263
|
+
|
264
|
+
```js
|
265
|
+
export default defineConfig({
|
266
|
+
runtime: {
|
267
|
+
router: false,
|
268
|
+
}
|
269
|
+
})
|
270
|
+
```
|
@@ -0,0 +1,116 @@
|
|
1
|
+
---
|
2
|
+
title: Entries
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
|
6
|
+
Entries are Modern.js default file convention, and each entry in the project is a separate page, corresponding to a server level route.
|
7
|
+
|
8
|
+
Many configurations, such as HTML templates, Meta information, whether SSR is enabled, SSG, server level routing rules are divided by the entry dimension.
|
9
|
+
|
10
|
+
## Single Entry and Multiple Entries
|
11
|
+
|
12
|
+
Modern.js initialization project is a single entry, the project structure is as follows:
|
13
|
+
|
14
|
+
```
|
15
|
+
.
|
16
|
+
├── src
|
17
|
+
│ ├── modern-app-env.d.ts
|
18
|
+
│ └── routes
|
19
|
+
│ ├── index.css
|
20
|
+
│ ├── layout.tsx
|
21
|
+
│ └── page.tsx
|
22
|
+
├── package.json
|
23
|
+
├── modern.config.ts
|
24
|
+
├── pnpm-lock.yaml
|
25
|
+
├── README.md
|
26
|
+
└── tsconfig.json
|
27
|
+
```
|
28
|
+
|
29
|
+
Modern.js can easily switch from single entry to multiple entry. You can execute `pnpm run new` under the project to create entry through generator:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
? Action: Create project element
|
33
|
+
? Create project element: New "entry"
|
34
|
+
? Entry name: new-entry
|
35
|
+
```
|
36
|
+
|
37
|
+
After execution, the `src/` directory will become the following structure:
|
38
|
+
|
39
|
+
```
|
40
|
+
.
|
41
|
+
├── modern-app-env.d.ts
|
42
|
+
├── myapp
|
43
|
+
│ └── routes
|
44
|
+
│ ├── index.css
|
45
|
+
│ ├── layout.tsx
|
46
|
+
│ └── page.tsx
|
47
|
+
└── new-entry
|
48
|
+
└── routes
|
49
|
+
├── index.css
|
50
|
+
├── layout.tsx
|
51
|
+
└── page.tsx
|
52
|
+
```
|
53
|
+
|
54
|
+
The original code was moved to the directory with the same name as the `name` in the `package.json`, and a new directory was created.
|
55
|
+
|
56
|
+
After executing `pnpm run dev`, you can see that a `/new-entry` route has been added, and the migrated code route has not changed.
|
57
|
+
|
58
|
+
:::note
|
59
|
+
Modern.js will use the directory with the same name as the `name` in the `package.json` as the main entry, the default route is `/`, and the default route for other entries is `/{entryName}`.
|
60
|
+
:::
|
61
|
+
|
62
|
+
## Entry conditions
|
63
|
+
|
64
|
+
By default, the Modern.js entry currently scans the file under `src/`, identifies the entry, and generates the corresponding server level route.
|
65
|
+
|
66
|
+
:::tip
|
67
|
+
You can change the entry directory to another directory by [source.entriesDir](/docs/configure/app/source/entries-dir).
|
68
|
+
:::
|
69
|
+
|
70
|
+
Not all first-level directories under `src/` will become project entrances. The directory where the entry is located must meet one of the following four conditions:
|
71
|
+
|
72
|
+
|
73
|
+
1. Directory with `routes/`
|
74
|
+
2. Has the `App.[jt]sx?` file
|
75
|
+
3. With `index.[jt]sx?` file
|
76
|
+
2. With `pages/` directory (compatible Modern.js 1.0)
|
77
|
+
|
78
|
+
When the `src/` directory satisfies the entry feature, the Modern.js considers the current project to be a single entry application.
|
79
|
+
|
80
|
+
:::tip
|
81
|
+
Single entry The default entry name is `main`.
|
82
|
+
:::
|
83
|
+
|
84
|
+
When the project is not a single-entry application, Modern.js further look at the first-level directory under `src/`.
|
85
|
+
|
86
|
+
## Difference between entries
|
87
|
+
|
88
|
+
Entries to different conventions have different behaviors.
|
89
|
+
|
90
|
+
### routes
|
91
|
+
|
92
|
+
If the entry is the `routes/` convention, Modern.js will scan the files under `routes` at startup, and automatically generate the client route based on the file convention(react-router).
|
93
|
+
|
94
|
+
For details, please refer to [Routing](/docs/guides/basic-features/routes).
|
95
|
+
|
96
|
+
### App
|
97
|
+
|
98
|
+
If the entry is the `App.[jt]sx?` convention, the developer can freely set the client route in this file, or not set the client route.
|
99
|
+
|
100
|
+
For details, please refer to [Routing](/docs/guides/basic-features/routes).
|
101
|
+
|
102
|
+
### Index
|
103
|
+
|
104
|
+
Typically, the above two modes are sufficient, but when developers need to take over the React mount logic themselves, or take over the Webpack entry entirely, the `index.[jt]sx?`convention can be used.
|
105
|
+
|
106
|
+
If the entry is the `index.[jt]sx?` convention, the Modern.js determines the build behavior based on whether the file has a default component export.
|
107
|
+
|
108
|
+
For details, please refer to [customized App](/docs/guides/advanced-features/custom-app).
|
109
|
+
|
110
|
+
## configuration
|
111
|
+
|
112
|
+
In Modern.js, you can manually configure the entry in `modern.config.[jt]s`, in addition to using the file convention to generate the entry.
|
113
|
+
|
114
|
+
:::tip
|
115
|
+
Details can be found in [source.entries](/docs/configure/app/source/entries).
|
116
|
+
:::
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
title: Lifecycle
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
Modern.js application has a complete lifecycle, including CLI, Server Side and Runtime three stages.
|
7
|
+
|
8
|
+
Modern.js lifecycle is as follows:
|
9
|
+
|
10
|
+
|
11
|
+
:::note
|
12
|
+
The rectangle of the pink box represents the plugin hook provided by the Modern.js, and the light yellow base color ellipse represents the linkage point with the next stage.
|
13
|
+
:::
|
14
|
+
|
15
|
+

|
@@ -0,0 +1,162 @@
|
|
1
|
+
---
|
2
|
+
title: Quick Start
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
## Environment
|
7
|
+
|
8
|
+
### Node.js
|
9
|
+
|
10
|
+
Requires [Node.js LTS](https://github.com/nodejs/Release) and ensures that the Node version is greater than or equal to 14.19.0, 16.x version is recommended.
|
11
|
+
|
12
|
+
Modern.js recommend installing [nvm](https://github.com/nvm-sh/nvm#install--update-script) in the development environment and integrating [script to automatically switch node versions](https://github.com/nvm-sh/nvm#deeper-shell-integration) in the shell.
|
13
|
+
|
14
|
+
Then there is a `.nvmrc` file with the content of `lts/fermium` or `lts/gallium` in the root directory of the repository, it will automatically install or switch to the correct Node.js version when entering the repository.
|
15
|
+
|
16
|
+
### pnpm
|
17
|
+
|
18
|
+
[pnpm](https://pnpm.io/installation) is recommended for package management.
|
19
|
+
|
20
|
+
```bash
|
21
|
+
npm install -g pnpm
|
22
|
+
```
|
23
|
+
|
24
|
+
:::note
|
25
|
+
Modern.js also supports package management with `yarn` and `npm`.
|
26
|
+
:::
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Modern.js provides the `@modern-js/create` tool to create projects. Don't install globally, use `npx` to run on demand.
|
31
|
+
|
32
|
+
Projects can be created using an existing empty directory:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
mkdir myapp && cd myapp
|
36
|
+
npx @modern-js/create
|
37
|
+
```
|
38
|
+
|
39
|
+
Projects can also be created directly from the new directory:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
npx @modern-js/create myapp
|
43
|
+
```
|
44
|
+
|
45
|
+
## Initialize
|
46
|
+
|
47
|
+
import InitApp from '@site-docs/components/init-app.md'
|
48
|
+
|
49
|
+
<InitApp />
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
Execute `pnpm run dev` in the project to start the project:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
$ pnpm run dev
|
57
|
+
|
58
|
+
> modern dev
|
59
|
+
|
60
|
+
info Starting dev server...
|
61
|
+
info App running at:
|
62
|
+
|
63
|
+
> Local: http://localhost:8080/
|
64
|
+
> Network: http://10.94.58.87:8080/
|
65
|
+
> Network: http://10.254.68.105:8080/
|
66
|
+
|
67
|
+
Client ✔ done in 76.10ms
|
68
|
+
```
|
69
|
+
|
70
|
+
Open `http://localhost:8000/` in your browser and you will see the following:
|
71
|
+
|
72
|
+

|
73
|
+
|
74
|
+
## Configuration
|
75
|
+
|
76
|
+
The `modern.config.ts` files exist in Modern.js projects created by the generator.
|
77
|
+
|
78
|
+
Features can be enabled through the configuration file, or the default behavior of the coverage Modern.js. For example, add the following configuration to enable SSR:
|
79
|
+
|
80
|
+
```ts
|
81
|
+
import { defineConfig } from '@modern-js/app-tools';
|
82
|
+
|
83
|
+
// https://modernjs.dev/docs/apis/app/config
|
84
|
+
export default defineConfig({
|
85
|
+
runtime: {
|
86
|
+
router: true,
|
87
|
+
state: true,
|
88
|
+
},
|
89
|
+
server: {
|
90
|
+
ssr: true,
|
91
|
+
},
|
92
|
+
});
|
93
|
+
```
|
94
|
+
|
95
|
+
Re-execute `pnpm run dev`, in the browser Network menu, you can find that the project has completed page rendering at the server level.
|
96
|
+
|
97
|
+
## Build
|
98
|
+
|
99
|
+
Execute `pnpm run build` in the project to build the project production environment product:
|
100
|
+
|
101
|
+
```bash
|
102
|
+
$ pnpm run build
|
103
|
+
|
104
|
+
> modern build
|
105
|
+
|
106
|
+
info Create a production build...
|
107
|
+
|
108
|
+
info File sizes after production build:
|
109
|
+
|
110
|
+
File Size Gzipped
|
111
|
+
dist/static/js/lib-corejs.ffeb7fb8.js 214.96 kB 67.23 kB
|
112
|
+
dist/static/js/lib-react.09721b5c.js 152.61 kB 49.02 kB
|
113
|
+
dist/static/js/218.102e2f39.js 85.45 kB 28.5 kB
|
114
|
+
dist/static/js/lib-babel.a7bba875.js 11.93 kB 3.95 kB
|
115
|
+
dist/html/main/index.html 5.84 kB 2.57 kB
|
116
|
+
dist/static/js/main.3568a38e.js 3.57 kB 1.44 kB
|
117
|
+
dist/static/css/async/304.c3c481a5.css 2.62 kB 874 B
|
118
|
+
dist/asset-manifest.json 1.48 kB 349 B
|
119
|
+
dist/static/js/async/304.c45706bc.js 1.4 kB 575 B
|
120
|
+
dist/static/js/async/509.fcb06e14.js 283 B 230 B
|
121
|
+
|
122
|
+
Client ✔ done in 3.57s
|
123
|
+
```
|
124
|
+
|
125
|
+
The bundle is generated to `dist/` by default, and the directory structure is as follows:
|
126
|
+
|
127
|
+
```
|
128
|
+
.
|
129
|
+
├── asset-manifest.json
|
130
|
+
├── html
|
131
|
+
│ └── main
|
132
|
+
├── loader-routes
|
133
|
+
│ └── main
|
134
|
+
├── modern.config.json
|
135
|
+
├── route.json
|
136
|
+
└── static
|
137
|
+
├── css
|
138
|
+
└── js
|
139
|
+
```
|
140
|
+
|
141
|
+
## Verify
|
142
|
+
|
143
|
+
Execute `pnpm run start` in the project to verify locally that the bundle is running correctly:
|
144
|
+
|
145
|
+
```bash
|
146
|
+
$ pnpm run start
|
147
|
+
|
148
|
+
> modern start
|
149
|
+
|
150
|
+
Starting the modern server...
|
151
|
+
info App running at:
|
152
|
+
|
153
|
+
> Local: http://localhost:8080/
|
154
|
+
> Network: http://10.94.58.87:8080/
|
155
|
+
> Network: http://10.254.68.105:8080/
|
156
|
+
```
|
157
|
+
|
158
|
+
Open http://localhost:8000/ in the browser and the content should be the same as when `pnpm run dev`.
|
159
|
+
|
160
|
+
## Deploy
|
161
|
+
|
162
|
+
After the local verification is completed, the products under `dist/` can be organized into the structure required by the server for deployment.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
---
|
2
|
+
title: Upgrade
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
|
6
|
+
## Upgrade with command
|
7
|
+
|
8
|
+
Modern.js provides the `upgrade` command to support projects to upgrade to the latest version.
|
9
|
+
|
10
|
+
Execute `pnpm run upgrade` in the project:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ pnpm run upgrade
|
14
|
+
|
15
|
+
> modern upgrade
|
16
|
+
|
17
|
+
[INFO] [Project Type]: Application
|
18
|
+
[INFO] [Modern.js Latest Version]: 2.0.0
|
19
|
+
[INFO] Upgrade Modern.js package version success!
|
20
|
+
```
|
21
|
+
|
22
|
+
You can see that the dependency in the project `package.json` has been changed to the latest.
|
23
|
+
|
24
|
+
## Specify version upgrade
|
25
|
+
|
26
|
+
Modern.js all packages are published using the **unified version number**.
|
27
|
+
|
28
|
+
According to the website Release Note, developers can also manually upgrade the project to the desired version.
|
29
|
+
|
30
|
+
:::tip
|
31
|
+
When upgrading, you need to upgrade to all packages provided by the Modern.js, rather than upgrading a single dependency.
|
32
|
+
:::
|
33
|
+
|
34
|
+
## lock child dependency
|
35
|
+
|
36
|
+
When there is a problem with one of the child dependencies of the project, and the Modern.js cannot be updated immediately, you can use the package manager to lock the child dependency version.
|
37
|
+
|
38
|
+
### pnpm
|
39
|
+
|
40
|
+
For projects using pnpm, add the following configuration to the `package.json` in the **project root directory** and re-execute `pnpm install`:
|
41
|
+
|
42
|
+
```json
|
43
|
+
{
|
44
|
+
"pnpm": {
|
45
|
+
"overrides": {
|
46
|
+
"package-name": "^1.0.0"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
### Yarn
|
53
|
+
|
54
|
+
For projects using Yarn, add the following configuration to the `package.json` in the **project root directory** and re-execute `yarn install`:
|
55
|
+
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"resolutions": {
|
59
|
+
"package-name": "^1.0.0"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Npm
|
65
|
+
|
66
|
+
For projects using Npm, add the following configuration to the `package.json` in the **project root directory** and re-execute `npm install`:
|
67
|
+
|
68
|
+
```json
|
69
|
+
{
|
70
|
+
"overrides": {
|
71
|
+
"package-name": "^1.0.0"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
:::info
|
77
|
+
For Monorepo repositories, the dependency version can only be locked in the `package.json` in the project root directory, and all packages in Monorepo are affected.
|
78
|
+
:::
|
package/{zh/tutorials/first-app → en/docusaurus-plugin-content-docs/current/guides}/overview.md
RENAMED
@@ -2,10 +2,10 @@
|
|
2
2
|
sidebar_position: 0
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# Overview
|
6
6
|
|
7
7
|
import OverviewNav from '@site/src/components/OverviewNav';
|
8
|
-
import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json'
|
9
|
-
import Link from '@docusaurus/Link';
|
10
8
|
|
11
|
-
|
9
|
+
import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
|
10
|
+
|
11
|
+
<OverviewNav cards={sidebarData.docsSidebars.guidesSidebar} />
|
@@ -40,4 +40,4 @@ It mainly contains the following features:
|
|
40
40
|
|
41
41
|
If you are a front-end beginner, you may find these concepts a bit complicated. We provide some [JavaScript and React](/docs/tutorials/foundations/basic) learning materials, you can do some understanding of them first。
|
42
42
|
|
43
|
-
If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/docs/tutorials/first-app/
|
43
|
+
If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/docs/tutorials/first-app/c01-start), or read [Guide](/docs/guides/overview).
|