@modern-js/main-doc 2.0.0-beta.1 → 2.0.0-beta.3
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/build.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/test.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +1 -1
- 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/auto-actions.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-local-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-static-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +1 -23
- package/en/docusaurus-plugin-content-docs/current/components/command-tip.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +1 -0
- package/en/docusaurus-plugin-content-docs/current/components/reduck-tip.md +5 -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 +12 -0
- 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/runtime/router.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/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/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/topic-detail/generator/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md +152 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md +49 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/handlebars.md +58 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/json.md +59 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md +49 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/develop.md +52 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/introduce.md +46 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/structure.md +87 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +106 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/module.md +39 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/monorepo.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/mwa.md +89 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/abstract.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addFile.md +52 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addHelper.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addManyFile.md +58 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addPartial.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/introduce.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmDir.md +24 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmFile.md +24 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +54 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.md +20 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/initGitRepo.md +16 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/isInGitRepo.md +16 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/afterForged.md +35 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/onForged.md +36 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/isFileExit.md +22 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/locale.md +17 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/readDir.md +22 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +57 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +56 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInput.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInputValue.md +30 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/type.md +65 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/introduce.md +91 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createElement.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createSubProject.md +35 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/enableFunc.md +44 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/introduce.md +15 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/install.md +18 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/develop.md +125 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/use.md +61 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +118 -0
- package/en/docusaurus-plugin-content-docs/current.json +57 -21
- package/package.json +3 -3
- package/scripts/config.ts +2 -2
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/zh/apis/app/commands/new.md +0 -3
- package/zh/apis/app/hooks/server/test.md +2 -2
- 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/apis/app/runtime/web-server/hook.md +4 -4
- package/zh/apis/app/runtime/web-server/middleware.md +4 -4
- 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 +12 -0
- 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/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/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/_category_.json +5 -1
- package/zh/guides/advanced-features/bff/bff-proxy.md +5 -3
- package/zh/guides/advanced-features/bff/frameworks.md +72 -51
- package/zh/guides/advanced-features/bff/function.md +16 -30
- package/zh/guides/advanced-features/bff/index.md +20 -0
- package/zh/guides/advanced-features/bff/type.md +43 -0
- package/zh/guides/advanced-features/custom-app.md +69 -1
- package/zh/guides/advanced-features/ssg.md +74 -63
- package/zh/guides/advanced-features/ssr.md +74 -11
- package/zh/guides/advanced-features/web-server.md +21 -110
- 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/data-fetch.md +62 -1
- package/zh/guides/basic-features/env-vars.md +122 -41
- package/zh/guides/basic-features/routes.md +264 -0
- package/zh/guides/concept/entries.md +112 -0
- package/zh/guides/concept/lifecycle.md +10 -0
- package/zh/guides/get-started/quick-start.md +199 -1
- package/zh/guides/get-started/upgrade.md +75 -1
- 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/generator/codesmith/api/_category_.json +4 -0
- package/zh/guides/topic-detail/generator/codesmith/api/app.md +152 -0
- package/zh/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
- package/zh/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
- package/zh/guides/topic-detail/generator/codesmith/api/git.md +48 -0
- package/zh/guides/topic-detail/generator/codesmith/api/handlebars.md +56 -0
- package/zh/guides/topic-detail/generator/codesmith/api/json.md +58 -0
- package/zh/guides/topic-detail/generator/codesmith/api/npm.md +45 -0
- package/zh/guides/topic-detail/generator/codesmith/develop.md +52 -0
- package/zh/guides/topic-detail/generator/codesmith/introduce.md +42 -1
- package/zh/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
- package/zh/guides/topic-detail/generator/codesmith/structure.md +86 -0
- package/zh/guides/topic-detail/generator/config/mwa.md +4 -8
- package/zh/guides/topic-detail/generator/plugin/api/file/addFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/addHelper.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/addPartial.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/rmDir.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/rmFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +3 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.md +3 -3
- package/zh/guides/topic-detail/generator/plugin/api/hook/onForged.md +3 -3
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createElement.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/npm/install.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/develop.md +11 -7
- package/zh/guides/topic-detail/model/quick-start.md +4 -0
- package/zh/guides/topic-detail/monorepo/sub-project-interface.md +0 -2
- package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +2 -2
- package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +2 -2
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +5 -2
- package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -8
- package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +12 -6
- package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +2 -4
- package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +1 -1
- package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +44 -50
- package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +1 -1
- package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +4 -4
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +8 -21
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +37 -13
- package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +3 -13
- package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +1 -21
- package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +9 -9
- package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +9 -14
- package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +7 -7
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +1 -1
- package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +2 -2
- package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +8 -17
- package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +24 -19
- package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +31 -35
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +4 -9
- package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +66 -63
- package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +35 -33
- package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +28 -102
- package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +4 -6
- package/zh/tutorials/first-app/c10-model/10.2-add-model.md +3 -3
- package/zh/tutorials/first-app/c10-model/10.3-use-model.md +21 -20
- package/zh/tutorials/first-app/c10-model/10.4-testing.md +2 -2
- package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +34 -68
- package/zh/tutorials/first-app/c11-container/11.2-add-container.md +40 -37
- package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +6 -4
- package/zh/tutorials/first-app/c11-container/11.4-testing.md +2 -2
- package/zh/tutorials/foundations/introduction.md +1 -1
- 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/env.md +0 -72
- 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/zh/apis/app/runtime/default-alias.md +0 -23
- package/zh/apis/app/runtime/env.md +0 -70
- 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/components/deploy.md +0 -60
- package/zh/components/dev-ide.md +0 -1
- package/zh/components/entry-name.md +0 -15
- package/zh/components/env-prepare.md +0 -1
- package/zh/components/launch-bff-choices.md +0 -6
- package/zh/guides/advanced-features/bff/bff-server.md +0 -142
- package/zh/guides/advanced-features/typescript.md +0 -4
- package/zh/guides/basic-features/image.md +0 -43
- package/zh/guides/concept/integrated.md +0 -4
- package/zh/guides/concept/solutions.md +0 -4
- package/zh/guides/topic-detail/compile-speed.md +0 -182
- package/zh/guides/topic-detail/framework-plugin/abstract.md +0 -27
- package/zh/guides/troubleshooting/compile.md +0 -379
- package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -318
@@ -1,4 +1,202 @@
|
|
1
1
|
---
|
2
2
|
title: 快速上手
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 1
|
4
4
|
---
|
5
|
+
|
6
|
+
## 环境准备
|
7
|
+
|
8
|
+
### Node.js
|
9
|
+
|
10
|
+
需要 [Node.js LTS](https://github.com/nodejs/Release),并确保 Node 版本大于等于 14.17.6。
|
11
|
+
|
12
|
+
Modern.js 推荐在开发环境里先安装 [nvm](https://github.com/nvm-sh/nvm#install--update-script),在 shell 里集成[自动切换 node 版本的脚本](https://github.com/nvm-sh/nvm#deeper-shell-integration)。
|
13
|
+
|
14
|
+
然后只要仓库根目录下有内容为 `lts/fermium` 或 `lts/gallium` 的 `.nvmrc` 文件,进入这个仓库时就会自动安装或切换到正确的 Node.js 版本。
|
15
|
+
|
16
|
+
### pnpm
|
17
|
+
|
18
|
+
推荐使用 [pnpm](https://pnpm.io/installation) 来管理依赖:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
npm install -g pnpm
|
22
|
+
```
|
23
|
+
|
24
|
+
:::note
|
25
|
+
Modern.js 同样支持使用 `yarn`、`npm` 进行依赖管理。
|
26
|
+
:::
|
27
|
+
|
28
|
+
## 安装
|
29
|
+
|
30
|
+
Modern.js 提供了 `@modern-js/create` 生成器来创建项目,不要全局安装,使用 `npx` 按需运行。
|
31
|
+
|
32
|
+
可以使用已有的空目录来创建项目:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
mkdir myapp && cd myapp
|
36
|
+
npx @modern-js/create
|
37
|
+
```
|
38
|
+
|
39
|
+
也可以直接用新目录创建项目:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
npx @modern-js/create myapp
|
43
|
+
```
|
44
|
+
|
45
|
+
## 初始化项目
|
46
|
+
|
47
|
+
Modern.js 生成器会提供一个可交互的问答界面,根据结果初始化项目,按照默认的选择进行初始化:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
? 请选择你想创建的工程类型 应用
|
51
|
+
? 请选择开发语言 TS
|
52
|
+
? 请选择包管理工具 pnpm
|
53
|
+
```
|
54
|
+
|
55
|
+
在生成项目后,Modern.js 会自动安装依赖、创建 git 仓库。
|
56
|
+
|
57
|
+
```bash
|
58
|
+
[INFO] 依赖自动安装成功
|
59
|
+
[INFO] git 仓库初始化成功
|
60
|
+
[INFO] 创建成功!
|
61
|
+
可在新项目的目录下运行以下命令:
|
62
|
+
pnpm run dev # 按开发环境的要求,运行和调试项目
|
63
|
+
pnpm run build # 按产品环境的要求,构建项目
|
64
|
+
pnpm run start # 按产品环境的要求,运行项目
|
65
|
+
pnpm run lint # 检查和修复所有代码
|
66
|
+
pnpm run new # 继续创建更多项目要素,比如应用入口
|
67
|
+
```
|
68
|
+
|
69
|
+
:::note
|
70
|
+
Modern.js 生成器除了在项目初始化时工作外,也能在后续研发中生成项目各种粒度的模块,并非一用即抛开。
|
71
|
+
:::
|
72
|
+
|
73
|
+
现在,项目结构如下:
|
74
|
+
|
75
|
+
```
|
76
|
+
.
|
77
|
+
├── node_modules
|
78
|
+
├── src
|
79
|
+
│ ├── modern-app-env.d.ts
|
80
|
+
│ └── routes
|
81
|
+
│ ├── index.css
|
82
|
+
│ ├── layout.tsx
|
83
|
+
│ └── page.tsx
|
84
|
+
├── modern.config.ts
|
85
|
+
├── package.json
|
86
|
+
├── pnpm-lock.yaml
|
87
|
+
├── README.md
|
88
|
+
└── tsconfig.json
|
89
|
+
```
|
90
|
+
|
91
|
+
## 启动项目
|
92
|
+
|
93
|
+
在项目中执行 `pnpm run dev` 即可启动项目:
|
94
|
+
|
95
|
+
```bash
|
96
|
+
$ pnpm run dev
|
97
|
+
|
98
|
+
> modern dev
|
99
|
+
|
100
|
+
info Starting dev server...
|
101
|
+
info App running at:
|
102
|
+
|
103
|
+
> Local: http://localhost:8080/
|
104
|
+
> Network: http://10.94.58.87:8080/
|
105
|
+
> Network: http://10.254.68.105:8080/
|
106
|
+
|
107
|
+
Client ✔ done in 76.10ms
|
108
|
+
```
|
109
|
+
|
110
|
+
在浏览器中打开 `http://localhost:8000/`,能看到以下内容:
|
111
|
+
|
112
|
+

|
113
|
+
|
114
|
+
## 使用配置
|
115
|
+
|
116
|
+
通过生成器创建的 Modern.js 项目中,存在 `modern.config.ts` 文件。
|
117
|
+
|
118
|
+
可以通过配置文件来开启功能,或覆盖 Modern.js 的默认行为。例如添加如下配置,开启 SSR:
|
119
|
+
|
120
|
+
```ts
|
121
|
+
import { defineConfig } from '@modern-js/app-tools';
|
122
|
+
|
123
|
+
// https://modernjs.dev/docs/apis/app/config
|
124
|
+
export default defineConfig({
|
125
|
+
runtime: {
|
126
|
+
router: true,
|
127
|
+
state: true,
|
128
|
+
},
|
129
|
+
server: {
|
130
|
+
ssr: true,
|
131
|
+
},
|
132
|
+
});
|
133
|
+
```
|
134
|
+
|
135
|
+
重新执行 `pnpm run dev`,在浏览器 Network 菜单中,可以发现项目已经在服务端完成了页面渲染。
|
136
|
+
|
137
|
+
## 构建项目
|
138
|
+
|
139
|
+
在项目中执行 `pnpm run build` 即可构建项目生产环境产物:
|
140
|
+
|
141
|
+
```bash
|
142
|
+
$ pnpm run build
|
143
|
+
|
144
|
+
> modern build
|
145
|
+
|
146
|
+
info Create a production build...
|
147
|
+
|
148
|
+
info File sizes after production build:
|
149
|
+
|
150
|
+
File Size Gzipped
|
151
|
+
dist/static/js/lib-corejs.ffeb7fb8.js 214.96 kB 67.23 kB
|
152
|
+
dist/static/js/lib-react.09721b5c.js 152.61 kB 49.02 kB
|
153
|
+
dist/static/js/218.102e2f39.js 85.45 kB 28.5 kB
|
154
|
+
dist/static/js/lib-babel.a7bba875.js 11.93 kB 3.95 kB
|
155
|
+
dist/html/main/index.html 5.84 kB 2.57 kB
|
156
|
+
dist/static/js/main.3568a38e.js 3.57 kB 1.44 kB
|
157
|
+
dist/static/css/async/304.c3c481a5.css 2.62 kB 874 B
|
158
|
+
dist/asset-manifest.json 1.48 kB 349 B
|
159
|
+
dist/static/js/async/304.c45706bc.js 1.4 kB 575 B
|
160
|
+
dist/static/js/async/509.fcb06e14.js 283 B 230 B
|
161
|
+
|
162
|
+
Client ✔ done in 3.57s
|
163
|
+
```
|
164
|
+
|
165
|
+
构建产物默认生成到 `dist/`,目录结构如下:
|
166
|
+
|
167
|
+
```
|
168
|
+
.
|
169
|
+
├── asset-manifest.json
|
170
|
+
├── html
|
171
|
+
│ └── main
|
172
|
+
├── loader-routes
|
173
|
+
│ └── main
|
174
|
+
├── modern.config.json
|
175
|
+
├── route.json
|
176
|
+
└── static
|
177
|
+
├── css
|
178
|
+
└── js
|
179
|
+
```
|
180
|
+
|
181
|
+
## 本地验证
|
182
|
+
|
183
|
+
在项目中执行 `pnpm run start` 即可在本地验证构建产物是否正常运行:
|
184
|
+
|
185
|
+
```bash
|
186
|
+
$ pnpm run start
|
187
|
+
|
188
|
+
> modern start
|
189
|
+
|
190
|
+
Starting the modern server...
|
191
|
+
info App running at:
|
192
|
+
|
193
|
+
> Local: http://localhost:8080/
|
194
|
+
> Network: http://10.94.58.87:8080/
|
195
|
+
> Network: http://10.254.68.105:8080/
|
196
|
+
```
|
197
|
+
|
198
|
+
在浏览器中打开 `http://localhost:8000/`,内容应该和 `pnpm run dev` 时一致。
|
199
|
+
|
200
|
+
## 部署
|
201
|
+
|
202
|
+
本地验证完成后,可以将 `dist/` 下的产物整理成服务器需要的结构,进行部署。
|
@@ -1,4 +1,78 @@
|
|
1
1
|
---
|
2
2
|
title: 升级
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 2
|
4
4
|
---
|
5
|
+
|
6
|
+
## 通过命令行升级
|
7
|
+
|
8
|
+
Modern.js 提供了 `upgrade` 命令支持项目升级到最新的 Modern.js 版本。
|
9
|
+
|
10
|
+
在项目中执行 `pnpm run upgrade`:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ pnpm run upgrade
|
14
|
+
|
15
|
+
> modern upgrade
|
16
|
+
|
17
|
+
[INFO] [项目类型]: 应用
|
18
|
+
[INFO] [Modern.js 最新版本]: 2.0.0
|
19
|
+
[INFO] [当前项目 Modern.js 依赖已经为最新版本]: 2.0.0
|
20
|
+
```
|
21
|
+
|
22
|
+
可以看到项目 `package.json` 中的依赖已经更改到最新,执行 `pnpm install` 重新安装即可。
|
23
|
+
|
24
|
+
## 指定版本升级
|
25
|
+
|
26
|
+
Modern.js 所有的官方包目前都使用统一版本号进行发布。
|
27
|
+
|
28
|
+
根据官网 Release Note,开发者也可以手动将项目升级到想要的版本。
|
29
|
+
|
30
|
+
:::tip
|
31
|
+
对所有 Modern.js 官方提供的包做统一升级,而不是升级单个依赖。
|
32
|
+
:::
|
33
|
+
|
34
|
+
## 锁定子依赖
|
35
|
+
|
36
|
+
当项目某个子依赖出现问题,而 Modern.js 无法立即更新时,可以使用包管理器锁定子依赖版本。
|
37
|
+
|
38
|
+
### Pnpm
|
39
|
+
|
40
|
+
对于使用 Pnpm 的项目,请在**项目根目录**的 `package.json` 中添加以下配置,然后重新执行 `pnpm i`:
|
41
|
+
|
42
|
+
```json
|
43
|
+
{
|
44
|
+
"pnpm": {
|
45
|
+
"overrides": {
|
46
|
+
"package-name": "^1.0.0"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
### Yarn
|
53
|
+
|
54
|
+
对于使用 Yarn 的项目,请在**项目根目录**的 `package.json` 中添加以下配置,然后重新执行 `yarn i`:
|
55
|
+
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"resolutions": {
|
59
|
+
"package-name": "^1.0.0"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Npm
|
65
|
+
|
66
|
+
对于使用 Npm 的项目,请在**项目根目录**的 `package.json` 中添加以下配置,然后重新执行 `npm i`:
|
67
|
+
|
68
|
+
```json
|
69
|
+
{
|
70
|
+
"overrides": {
|
71
|
+
"package-name": "^1.0.0"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
:::info
|
77
|
+
对于 Monorepo 仓库,只能在项目根目录的 `package.json` 中锁定依赖版本,并且会影响 Monorepo 中的所有 package。
|
78
|
+
:::
|
@@ -1,10 +1,9 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
title: 扩展插件 Hook
|
3
|
+
sidebar_position: 5
|
3
4
|
---
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
本章节介绍如何通过动态注册 [Hook 模型](/docs/apis/app/runtime/plugin/hook#hook-模型) 的方式来扩展插件 Hook。
|
6
|
+
本小节介绍如何通过动态注册 [Hook 模型](/docs/guides/topic-detail/framework-plugin/hook) 的方式来扩展插件 Hook。
|
8
7
|
|
9
8
|
## 示例
|
10
9
|
|
package/zh/{apis/app/runtime/plugin/hook-api.md → guides/topic-detail/framework-plugin/hook-list.md}
RENAMED
@@ -1,18 +1,13 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
title: Hook 列表
|
3
|
+
sidebar_position: 8
|
3
4
|
---
|
4
5
|
|
5
|
-
|
6
|
+
在 Modern.js 中暴露了三类插件:CLI、Runtime、Server。下面列举下各类中的 Hook:
|
6
7
|
|
7
|
-
|
8
|
+
## CLI
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
这一部分的 Hook 模型是所有工程方案都有的,就是说在任意的工程方案中都可以在插件中添加实现对应的中间件函数。
|
12
|
-
|
13
|
-
接下来对支持的所有基础 Hook 分别进行介绍。
|
14
|
-
|
15
|
-
#### `config`
|
10
|
+
### `config`
|
16
11
|
|
17
12
|
- 功能:收集配置
|
18
13
|
- 执行阶段:解析完 `modern.config.ts` 中的配置之后
|
@@ -38,7 +33,7 @@ export default (): CliPlugin => ({
|
|
38
33
|
|
39
34
|
这里返回的配置信息,会被收集和统一处理合并。
|
40
35
|
|
41
|
-
|
36
|
+
### `validateSchema`
|
42
37
|
|
43
38
|
- 功能:收集各个插件中配置的用来校验用户配置的 [JSON Schema](https://json-schema.org/)
|
44
39
|
- 执行阶段:`config` Hook 运行完之后。
|
@@ -104,7 +99,7 @@ $ modern dev
|
|
104
99
|
| ^^^^^ Property foo is not expected to be here
|
105
100
|
```
|
106
101
|
|
107
|
-
|
102
|
+
### `prepare`
|
108
103
|
|
109
104
|
- 功能:运行主流程的前置准备流程
|
110
105
|
- 执行阶段:校验完配置之后
|
@@ -126,7 +121,7 @@ export default (): CliPlugin => ({
|
|
126
121
|
});
|
127
122
|
```
|
128
123
|
|
129
|
-
|
124
|
+
### `commands`
|
130
125
|
|
131
126
|
- 功能:为 command 添加新的命令
|
132
127
|
- 执行阶段:`prepare` Hook 运行完之后
|
@@ -168,7 +163,7 @@ $ modern foo
|
|
168
163
|
foo
|
169
164
|
```
|
170
165
|
|
171
|
-
|
166
|
+
### `beforeExit`
|
172
167
|
|
173
168
|
- 功能:在退出进程前,重置一些文件状态
|
174
169
|
- 执行阶段:进程退出之前
|
@@ -190,17 +185,7 @@ export default (): CliPlugin => ({
|
|
190
185
|
});
|
191
186
|
```
|
192
187
|
|
193
|
-
|
194
|
-
|
195
|
-
应用工程支持添加到项目中的插件主要有三种:CLI 插件、 Server 插件、Runtime 插件。他们是基于同一套插件系统实现的,但它们所支持的 Hook 不同、功能不同、运行的时机也不同。
|
196
|
-
|
197
|
-
不同的 Manager 对应 Hook 模型和运行时机是不同的,所以接下来会对 CLI、Server、Runtime 的 Hook 模型分开讨论。
|
198
|
-
|
199
|
-
### CLI
|
200
|
-
|
201
|
-
应用工程中除了上面提到的基础的 CLI Hook 之外还有一些 MWA 场景下特定的 Hook。
|
202
|
-
|
203
|
-
#### `beforeDev`
|
188
|
+
### `beforeDev`
|
204
189
|
|
205
190
|
- 功能:运行 dev 主流程的之前的任务
|
206
191
|
- 执行阶段:`dev` 命令运行时,项目开始启动前执行
|
@@ -222,7 +207,7 @@ export default (): CliPlugin => ({
|
|
222
207
|
});
|
223
208
|
```
|
224
209
|
|
225
|
-
|
210
|
+
### `afterDev`
|
226
211
|
|
227
212
|
- 功能:运行 dev 主流程的之后的任务
|
228
213
|
- 执行阶段:`dev` 命令运行时,项目启动完成之后执行
|
@@ -244,7 +229,7 @@ export default (): CliPlugin => ({
|
|
244
229
|
});
|
245
230
|
```
|
246
231
|
|
247
|
-
|
232
|
+
### `beforeCreateCompiler`
|
248
233
|
|
249
234
|
- 功能:在中间件函数中可以拿到创建 Webpack Compiler 的 Webpack 配置
|
250
235
|
- 执行阶段:创建 Webpack Compiler 之前执行
|
@@ -266,7 +251,7 @@ export default (): CliPlugin => ({
|
|
266
251
|
});
|
267
252
|
```
|
268
253
|
|
269
|
-
|
254
|
+
### `afterCreateCompiler`
|
270
255
|
|
271
256
|
- 功能:在中间件函数中可以拿到创建的 Webpack Compiler
|
272
257
|
- 执行阶段:创建 Webpack Compiler 之后执行
|
@@ -288,7 +273,7 @@ export default (): CliPlugin => ({
|
|
288
273
|
});
|
289
274
|
```
|
290
275
|
|
291
|
-
|
276
|
+
### `beforePrintInstructions`
|
292
277
|
|
293
278
|
- 功能:在中间件函数中可以拿到即将打印的日志信息,并对其进行修改
|
294
279
|
- 执行阶段:打印日志信息之前执行
|
@@ -313,7 +298,7 @@ export default (): CliPlugin => ({
|
|
313
298
|
});
|
314
299
|
```
|
315
300
|
|
316
|
-
|
301
|
+
### `beforeBuild`
|
317
302
|
|
318
303
|
- 功能:运行 build 主流程的之前的任务,可以拿到构建的 Webpack 配置
|
319
304
|
- 执行阶段:`build` 命令运行时,项目构建启动前执行
|
@@ -335,7 +320,7 @@ export default (): CliPlugin => ({
|
|
335
320
|
});
|
336
321
|
```
|
337
322
|
|
338
|
-
|
323
|
+
### `afterBuild`
|
339
324
|
|
340
325
|
- 功能:运行 build 主流程的之后的任务
|
341
326
|
- 执行阶段:`build` 命令运行时,项目构建完成之后执行
|
@@ -357,7 +342,7 @@ export default (): CliPlugin => ({
|
|
357
342
|
});
|
358
343
|
```
|
359
344
|
|
360
|
-
|
345
|
+
### `modifyEntryImports`
|
361
346
|
|
362
347
|
- 功能:用于修改、添加生成入口文件中的 `import` 语句
|
363
348
|
- 执行阶段:生成入口文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -389,7 +374,7 @@ export default (): CliPlugin => ({
|
|
389
374
|
});
|
390
375
|
```
|
391
376
|
|
392
|
-
|
377
|
+
### `modifyEntryExport`
|
393
378
|
|
394
379
|
- 功能:用于修改生成入口文件中的 `export` 语句
|
395
380
|
- 执行阶段:生成入口文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -416,7 +401,7 @@ export default (): CliPlugin => ({
|
|
416
401
|
});
|
417
402
|
```
|
418
403
|
|
419
|
-
|
404
|
+
### `modifyEntryRuntimePlugins`
|
420
405
|
|
421
406
|
- 功能:用于添加、修改生成入口文件中的 [Runtime 插件](#Runtime)
|
422
407
|
- 执行阶段:生成入口文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -451,7 +436,7 @@ export default (): CliPlugin => ({
|
|
451
436
|
});
|
452
437
|
```
|
453
438
|
|
454
|
-
|
439
|
+
### `modifyEntryRenderFunction`
|
455
440
|
|
456
441
|
- 功能:用于修改生成入口文件中 `render` 函数
|
457
442
|
- 执行阶段:生成入口文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -477,7 +462,7 @@ export default (): CliPlugin => ({
|
|
477
462
|
});
|
478
463
|
```
|
479
464
|
|
480
|
-
|
465
|
+
### `modifyFileSystemRoutes`
|
481
466
|
|
482
467
|
- 功能:用于修改生成前端页面路由文件中的内容,内容都是需要可序列化的
|
483
468
|
- 执行阶段:生成前端路由文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -511,7 +496,7 @@ export default (): CliPlugin => ({
|
|
511
496
|
|
512
497
|
这样就为前端新增了一个页面路由。
|
513
498
|
|
514
|
-
|
499
|
+
### `modifyServerRoutes`
|
515
500
|
|
516
501
|
- 功能:用于修改生成服务器路由中的内容
|
517
502
|
- 执行阶段:生成 Server 路由文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -544,7 +529,7 @@ export default (): CliPlugin => ({
|
|
544
529
|
});
|
545
530
|
```
|
546
531
|
|
547
|
-
|
532
|
+
### `modifyAsyncEntry`
|
548
533
|
|
549
534
|
- 功能:用于修改包裹入口文件的异步模块,参见 [source.enableAsyncEntry](/docs/configure/app/source/enable-async-entry)
|
550
535
|
- 执行阶段:生成入口文件之前,[`prepare`](#prepare) 阶段触发
|
@@ -570,7 +555,7 @@ export default (): CliPlugin => ({
|
|
570
555
|
});
|
571
556
|
```
|
572
557
|
|
573
|
-
|
558
|
+
### `htmlPartials`
|
574
559
|
|
575
560
|
- 功能:用于定制生成的 HTML 页面模版
|
576
561
|
- 执行阶段:[`prepare`](#prepare) 阶段触发
|
@@ -598,11 +583,15 @@ export default (): CliPlugin => ({
|
|
598
583
|
|
599
584
|
这样就为 HTML 模版中新增了一个 Script 标签。
|
600
585
|
|
601
|
-
|
586
|
+
## Server
|
587
|
+
|
588
|
+
:::note
|
589
|
+
目前 Server 插件还未完全开放,API 不保证稳定,使用需谨慎。
|
590
|
+
:::
|
602
591
|
|
603
592
|
应用工程中的 Server 部分也支持了插件。其中的 Hook 将会提供一些特定阶段调用和特殊功能的 Hook。
|
604
593
|
|
605
|
-
|
594
|
+
### `create`
|
606
595
|
|
607
596
|
- 功能:在中间件函数中会拿到 Server 初始化用到的指标测量工具配置 `measureOptions` 和日志工具配置 `loggerOptions`,并返回自定义的指标测量工具 `measure` 和日志工具配置 `logger`
|
608
597
|
- 执行阶段:Server 初始化
|
@@ -624,7 +613,7 @@ export default (): ServerPlugin => ({
|
|
624
613
|
});
|
625
614
|
```
|
626
615
|
|
627
|
-
|
616
|
+
### `prepareWebServer`
|
628
617
|
|
629
618
|
- 功能:设置 Web 路由的处理函数,在中间件函数中可以拿到 Web Server 的前置中间件
|
630
619
|
- 执行阶段:在请求到达的时候
|
@@ -650,7 +639,7 @@ export default (): ServerPlugin => ({
|
|
650
639
|
});
|
651
640
|
```
|
652
641
|
|
653
|
-
|
642
|
+
### `prepareApiServer`
|
654
643
|
|
655
644
|
- 功能:设置 API 路由的处理函数,在中间件函数中可以拿到 API Server 的前置中间件
|
656
645
|
- 执行阶段:请求到达并且 match bff basename 之后执行
|
@@ -676,11 +665,15 @@ export default (): ServerPlugin => ({
|
|
676
665
|
});
|
677
666
|
```
|
678
667
|
|
679
|
-
|
668
|
+
## Runtime
|
669
|
+
|
670
|
+
:::note
|
671
|
+
目前 Runtime 插件还未完全开放,API 不保证稳定,使用需谨慎。
|
672
|
+
:::
|
680
673
|
|
681
674
|
Runtime 插件主要用于开发者修改需要渲染的组件与 Element 和定制服务器端、客户端的渲染过程。
|
682
675
|
|
683
|
-
|
676
|
+
### `init`
|
684
677
|
|
685
678
|
- 功能:执行 `App.init`
|
686
679
|
- 执行阶段:渲染(SSR/CSR)
|
@@ -703,7 +696,7 @@ export default (): Plugin => ({
|
|
703
696
|
});
|
704
697
|
```
|
705
698
|
|
706
|
-
|
699
|
+
### `hoc`
|
707
700
|
|
708
701
|
- 功能:修改需要渲染的组件
|
709
702
|
- 执行阶段:渲染(SSR/CSR)
|
@@ -735,7 +728,7 @@ export default (): Plugin => ({
|
|
735
728
|
});
|
736
729
|
```
|
737
730
|
|
738
|
-
|
731
|
+
### `provide`
|
739
732
|
|
740
733
|
- 功能:修改需要渲染的 Element
|
741
734
|
- 执行阶段:渲染(SSR/CSR)
|
@@ -758,7 +751,7 @@ export default (): Plugin => ({
|
|
758
751
|
});
|
759
752
|
```
|
760
753
|
|
761
|
-
|
754
|
+
### `client`
|
762
755
|
|
763
756
|
- 功能:定制客户端渲染流程
|
764
757
|
- 执行阶段:在浏览器客户端渲染
|
@@ -784,7 +777,7 @@ export default (): Plugin => ({
|
|
784
777
|
});
|
785
778
|
```
|
786
779
|
|
787
|
-
|
780
|
+
### `server`
|
788
781
|
|
789
782
|
- 功能:定制服务器端渲染流程
|
790
783
|
- 执行阶段:SSR
|
@@ -808,89 +801,3 @@ export default (): Plugin => ({
|
|
808
801
|
},
|
809
802
|
});
|
810
803
|
```
|
811
|
-
|
812
|
-
## 模块工程方案
|
813
|
-
|
814
|
-
模块工程方案用于开发可复用模块,主要提供编译构建的能力,插件方面则是主要提供了调整编译构建配置的 Hook。
|
815
|
-
|
816
|
-
#### `moduleLessConfig`
|
817
|
-
|
818
|
-
- 功能:用于设置 [Less](https://lesscss.org/) 文件的编译配置
|
819
|
-
- 执行阶段:`build` 阶段
|
820
|
-
- Hook 模型:AsyncPipeline
|
821
|
-
- 类型:`AsyncPipeline<{ modernConfig: NormalizedConfig }, LessOption | undefined>`
|
822
|
-
- 使用示例:
|
823
|
-
|
824
|
-
```ts
|
825
|
-
import type { CliPlugin } from '@modern-js/core';
|
826
|
-
|
827
|
-
export default (): CliPlugin => ({
|
828
|
-
setup(api) {
|
829
|
-
return {
|
830
|
-
moduleLessConfig: ({ modernConfig }) => {
|
831
|
-
// do something
|
832
|
-
|
833
|
-
return {
|
834
|
-
// LESS 配置
|
835
|
-
};
|
836
|
-
},
|
837
|
-
};
|
838
|
-
},
|
839
|
-
});
|
840
|
-
```
|
841
|
-
|
842
|
-
#### `moduleSassConfig`
|
843
|
-
|
844
|
-
- 功能:用于设置 [Sass](https://sass-lang.com/) 文件的编译配置
|
845
|
-
- 执行阶段:`build` 阶段
|
846
|
-
- Hook 模型:AsyncPipeline
|
847
|
-
- 类型:`AsyncPipeline<{ modernConfig: NormalizedConfig }, SassOptions | undefined>`
|
848
|
-
- 使用示例:
|
849
|
-
|
850
|
-
```ts
|
851
|
-
import type { CliPlugin } from '@modern-js/core';
|
852
|
-
|
853
|
-
export default (): CliPlugin => ({
|
854
|
-
setup(api) {
|
855
|
-
return {
|
856
|
-
moduleSassConfig: ({ modernConfig }) => {
|
857
|
-
// do something
|
858
|
-
|
859
|
-
return {
|
860
|
-
// SASS 配置
|
861
|
-
};
|
862
|
-
},
|
863
|
-
};
|
864
|
-
},
|
865
|
-
});
|
866
|
-
```
|
867
|
-
|
868
|
-
#### `moduleTailwindConfig`
|
869
|
-
|
870
|
-
- 功能:用于设置 [Tailwind CSS](https://tailwindcss.com/) 的相关配置
|
871
|
-
- 执行阶段:`build` 阶段
|
872
|
-
- Hook 模型:AsyncPipeline
|
873
|
-
- 类型:`AsyncPipeline<{ modernConfig: NormalizedConfig }, any>`
|
874
|
-
- 使用示例:
|
875
|
-
|
876
|
-
```ts
|
877
|
-
import type { CliPlugin } from '@modern-js/core';
|
878
|
-
|
879
|
-
export default (): CliPlugin => ({
|
880
|
-
setup(api) {
|
881
|
-
return {
|
882
|
-
moduleTailwindConfig: ({ modernConfig }) => {
|
883
|
-
// do something
|
884
|
-
|
885
|
-
return {
|
886
|
-
// Tailwind CSS 配置
|
887
|
-
};
|
888
|
-
},
|
889
|
-
};
|
890
|
-
},
|
891
|
-
});
|
892
|
-
```
|
893
|
-
|
894
|
-
## Monorepo 工程方案
|
895
|
-
|
896
|
-
Monorepo 工程方案中目前没有设置额外的插件 Hook,可以创建、添加拥有基础 Hook 的插件:[基础](#基础)。
|
@@ -1,9 +1,8 @@
|
|
1
1
|
---
|
2
|
+
title: Hook 模型
|
2
3
|
sidebar_position: 2
|
3
4
|
---
|
4
5
|
|
5
|
-
# Hook 模型
|
6
|
-
|
7
6
|
首先介绍一下 Modern.js 的基础的插件系统中的一些内容,包括 Hook 模型的工作方式、各个 Hook 模型的运行模式、Manager 的工作模式。
|
8
7
|
|
9
8
|
每种 Hook 模型都是独立的,可以独立管理运行函数。
|
@@ -167,4 +166,4 @@ workflow.run(5) // [6, 10]
|
|
167
166
|
</div>
|
168
167
|
</div>
|
169
168
|
|
170
|
-
Workflow、Waterfall 其实都是 Pipeline 的变体,Pipeline 可以通过特定的写法来实现 Workflow、Waterfall
|
169
|
+
Workflow、Waterfall 其实都是 Pipeline 的变体,Pipeline 可以通过特定的写法来实现 Workflow、Waterfall,但都较为麻烦,有许多隐形的约定。为了方便使用,提供了这两种变体来满足这种特殊场景。
|