@modern-js/main-doc 2.0.3-alpha.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/serve.md +2 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/framework/lambda.md +12 -12
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/api.md +13 -13
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/app.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/common.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/app.md +16 -9
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/index_.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/routes.md +5 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/server.md +6 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/stories.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/test.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/app/define-config.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/bff/hook.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +3 -6
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/create-app.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +58 -51
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-runtime-context.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +8 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +0 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/router.md +23 -54
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/no-ssr.md +1 -8
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/pre-render.md +10 -6
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/render.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/css-in-js.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/head.md +3 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/loadable.md +14 -15
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/hook.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/middleware.md +7 -6
- package/en/docusaurus-plugin-content-docs/current/components/command-tip.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/components/enable-bff.md +12 -16
- package/en/docusaurus-plugin-content-docs/current/components/enable-micro-frontend.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/components/global-proxy-config.md +6 -9
- package/en/docusaurus-plugin-content-docs/current/components/global-proxy.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/components/micro-master-manifest-config.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/components/micro-runtime-config.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/components/reduck-tip.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/components/router-legacy-tip.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/auto-load-plugin.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/prefix.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/proxy.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/builder-plugins.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/deploy/microFrontend.md +11 -13
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/asset-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/hmr.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/https.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/port.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/progress-bar.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/proxy.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/start-url.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/app-icon.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/crossorigin.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/disable-html-folder.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/mount-id.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/tags-by-entries.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/tags.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/asset-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/assets-retry.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/charset.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/clean-dist-path.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/convert-to-rem.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/copy.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/css-module-local-ident-name.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/data-uri-limit.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-module-extension.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-filename-hash.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-inline-runtime-chunk.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-minimize.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-node-polyfill.md +8 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-source-map.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/dist-path.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-fallback.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-manifest.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-css-module-tsdeclaration.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-scripts.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-styles.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-latest-decorators.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/externals.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/filename.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/legal-comments.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/override-browserslist.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/polyfill.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/ssg.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/svg-default-export.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/build-cache.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/bundle-analyze.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/chunk-split.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/print-file-size.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/profile.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-console.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-moment-locale.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/intro.md +11 -10
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/master-app.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/state.md +15 -15
- package/en/docusaurus-plugin-content-docs/current/configure/app/security/sri.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/base-url.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/enable-framework-ext.md +5 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/port.md +24 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/public-routes.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +7 -7
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr-by-entries.md +5 -5
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/alias.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/compile-js-data-uri.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/config-dir.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/define.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/design-system.md +656 -634
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-default-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-entry-dirs.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/enable-async-entry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries-dir.md +7 -7
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries.md +4 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/global-vars.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/include.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/module-scopes.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/pre-entry.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-extension-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-main-fields.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/autoprefixer.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/babel.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-extract.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/dev-server.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/html-plugin.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/inspector.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/jest.md +9 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/less.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/minify-css.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/postcss.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/pug.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/sass.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/style-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/styled-components.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/swc.md +12 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/terser.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-checker.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack-chain.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/frameworks.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/function.md +44 -38
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/index.md +9 -9
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/type.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/code-split.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/compatibility.md +6 -7
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/eslint.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/low-level.md +17 -19
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssg.md +8 -10
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssr.md +5 -11
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/testing.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/web-server.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/alias.md +7 -11
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-in-js.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-modules.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/less-sass.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/postcss.md +43 -47
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/tailwindcss.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +106 -192
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/env-vars.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/html.md +55 -47
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/mock.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/proxy.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +90 -9
- package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/upgrade.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/extend.md +13 -13
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook-list.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook.md +57 -54
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/implement.md +11 -11
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/lifecycle.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/plugin-api.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md +33 -33
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/handlebars.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/json.md +9 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md +2 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/introduce.md +4 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/run-in-js.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/structure.md +13 -11
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +18 -27
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/abstract.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/onForged.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInput.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/introduce.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/develop.md +11 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/use.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c01-introduction.md +7 -8
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c02-development.md +18 -21
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c03-main-app.md +41 -44
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c04-communicate.md +7 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c05-mixed-stack.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/auto-actions.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/computed-state.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/define-model.md +3 -6
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/faq.md +2 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/manage-effects.md +2 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/model-communicate.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/performance.md +1 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/quick-start.md +0 -6
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/redux-integration.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/test-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/typescript-best-practice.md +13 -14
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-model.md +14 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-out-of-modernjs.md +4 -6
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c01-start.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c03-css.md +6 -8
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c04-routes.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c05-loader.md +2 -1
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c07-container.md +5 -5
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c08-entries.md +5 -6
- package/package.json +4 -4
- package/scripts/config.ts +4 -2
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/scripts/sync.ts +1 -1
- package/zh/apis/app/commands/index.md +0 -5
- package/zh/apis/app/commands/lint.md +1 -1
- package/zh/apis/app/commands/serve.md +2 -4
- package/zh/apis/app/hooks/api/framework/lambda.md +12 -12
- package/zh/apis/app/hooks/api/functions/api.md +13 -13
- package/zh/apis/app/hooks/api/functions/app.md +0 -2
- package/zh/apis/app/hooks/api/functions/common.md +1 -1
- package/zh/apis/app/hooks/index.md +0 -5
- package/zh/apis/app/hooks/shared.md +0 -1
- package/zh/apis/app/hooks/src/app.md +16 -9
- package/zh/apis/app/hooks/src/index_.md +0 -2
- package/zh/apis/app/hooks/src/routes.md +6 -7
- package/zh/apis/app/hooks/src/server.md +6 -4
- package/zh/apis/app/hooks/src/stories.md +1 -1
- package/zh/apis/app/hooks/src/test.md +1 -1
- package/zh/apis/app/runtime/app/define-config.md +1 -2
- package/zh/apis/app/runtime/bff/hook.md +3 -3
- package/zh/apis/app/runtime/core/bootstrap.md +2 -3
- package/zh/apis/app/runtime/core/use-loader.md +2 -2
- package/zh/apis/app/runtime/core/use-module-apps.md +53 -50
- package/zh/apis/app/runtime/core/use-runtime-context.md +3 -4
- package/zh/apis/app/runtime/index.md +0 -5
- package/zh/apis/app/runtime/model/Provider.md +1 -0
- package/zh/apis/app/runtime/model/auto-actions.md +1 -1
- package/zh/apis/app/runtime/model/connect.md +9 -5
- package/zh/apis/app/runtime/model/create-app.md +3 -3
- package/zh/apis/app/runtime/model/create-store.md +2 -4
- package/zh/apis/app/runtime/model/handle-effect.md +3 -4
- package/zh/apis/app/runtime/model/model_.md +0 -3
- package/zh/apis/app/runtime/model/use-local-model.md +0 -1
- package/zh/apis/app/runtime/model/use-store.md +0 -2
- package/zh/apis/app/runtime/router/router.md +23 -53
- package/zh/apis/app/runtime/ssr/no-ssr.md +1 -5
- package/zh/apis/app/runtime/ssr/pre-render.md +10 -6
- package/zh/apis/app/runtime/testing/cleanup.md +2 -2
- package/zh/apis/app/runtime/testing/render.md +0 -2
- package/zh/apis/app/runtime/utility/css-in-js.md +2 -2
- package/zh/apis/app/runtime/utility/head.md +3 -5
- package/zh/apis/app/runtime/utility/loadable.md +14 -15
- package/zh/apis/app/runtime/web-server/hook.md +5 -4
- package/zh/apis/app/runtime/web-server/middleware.md +8 -6
- package/zh/apis/monorepo/commands/bump.md +1 -1
- package/zh/apis/monorepo/commands/change.md +3 -2
- package/zh/apis/monorepo/commands/gen-release-note.md +1 -2
- package/zh/apis/monorepo/commands/index.md +1 -6
- package/zh/apis/monorepo/commands/lint.md +1 -1
- package/zh/apis/monorepo/commands/release.md +0 -1
- package/zh/apis/monorepo/hooks/index.md +1 -6
- package/zh/components/command-tip.md +3 -2
- package/zh/components/enable-bff.md +12 -16
- package/zh/components/enable-micro-frontend.md +4 -4
- package/zh/components/global-proxy-config.md +6 -9
- package/zh/components/global-proxy.md +0 -1
- package/zh/components/init-app.md +0 -1
- package/zh/components/micro-master-manifest-config.md +2 -2
- package/zh/components/micro-runtime-config.md +1 -1
- package/zh/components/reduck-migration.md +0 -1
- package/zh/components/router-legacy-tip.md +0 -1
- package/zh/configure/app/auto-load-plugin.md +9 -10
- package/zh/configure/app/bff/prefix.md +6 -10
- package/zh/configure/app/bff/proxy.md +9 -8
- package/zh/configure/app/builder-plugins.md +6 -6
- package/zh/configure/app/deploy/microFrontend.md +11 -11
- package/zh/configure/app/dev/asset-prefix.md +2 -2
- package/zh/configure/app/dev/hmr.md +2 -2
- package/zh/configure/app/dev/https.md +2 -2
- package/zh/configure/app/dev/port.md +2 -2
- package/zh/configure/app/dev/progress-bar.md +2 -2
- package/zh/configure/app/dev/proxy.md +0 -1
- package/zh/configure/app/dev/start-url.md +2 -2
- package/zh/configure/app/experiments/lazy-compilation.md +2 -2
- package/zh/configure/app/html/app-icon.md +2 -2
- package/zh/configure/app/html/crossorigin.md +2 -2
- package/zh/configure/app/html/disable-html-folder.md +2 -2
- package/zh/configure/app/html/favicon-by-entries.md +2 -2
- package/zh/configure/app/html/favicon.md +2 -2
- package/zh/configure/app/html/inject-by-entries.md +2 -2
- package/zh/configure/app/html/inject.md +2 -2
- package/zh/configure/app/html/meta-by-entries.md +2 -2
- package/zh/configure/app/html/meta.md +2 -2
- package/zh/configure/app/html/mount-id.md +2 -2
- package/zh/configure/app/html/tags-by-entries.md +12 -0
- package/zh/configure/app/html/tags.md +12 -0
- package/zh/configure/app/html/template-by-entries.md +2 -2
- package/zh/configure/app/html/template-parameters-by-entries.md +2 -2
- package/zh/configure/app/html/template-parameters.md +2 -2
- package/zh/configure/app/html/template.md +2 -2
- package/zh/configure/app/html/title-by-entries.md +2 -2
- package/zh/configure/app/html/title.md +2 -2
- package/zh/configure/app/output/asset-prefix.md +2 -2
- package/zh/configure/app/output/assets-retry.md +2 -2
- package/zh/configure/app/output/charset.md +2 -2
- package/zh/configure/app/output/clean-dist-path.md +2 -2
- package/zh/configure/app/output/convert-to-rem.md +2 -2
- package/zh/configure/app/output/copy.md +2 -2
- package/zh/configure/app/output/css-module-local-ident-name.md +2 -2
- package/zh/configure/app/output/data-uri-limit.md +2 -2
- package/zh/configure/app/output/disable-css-extract.md +2 -2
- package/zh/configure/app/output/disable-css-module-extension.md +2 -2
- package/zh/configure/app/output/disable-filename-hash.md +2 -2
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +2 -2
- package/zh/configure/app/output/disable-minimize.md +2 -2
- package/zh/configure/app/output/disable-node-polyfill.md +8 -8
- package/zh/configure/app/output/disable-source-map.md +2 -2
- package/zh/configure/app/output/disable-ts-checker.md +2 -2
- package/zh/configure/app/output/dist-path.md +2 -2
- package/zh/configure/app/output/enable-asset-fallback.md +2 -2
- package/zh/configure/app/output/enable-asset-manifest.md +2 -2
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +2 -2
- package/zh/configure/app/output/enable-inline-scripts.md +2 -2
- package/zh/configure/app/output/enable-inline-styles.md +2 -2
- package/zh/configure/app/output/enable-latest-decorators.md +2 -2
- package/zh/configure/app/output/externals.md +2 -2
- package/zh/configure/app/output/filename.md +2 -2
- package/zh/configure/app/output/legal-comments.md +2 -2
- package/zh/configure/app/output/override-browserslist.md +2 -2
- package/zh/configure/app/output/polyfill.md +2 -2
- package/zh/configure/app/output/ssg.md +3 -2
- package/zh/configure/app/output/svg-default-export.md +2 -2
- package/zh/configure/app/performance/build-cache.md +2 -2
- package/zh/configure/app/performance/bundle-analyze.md +2 -2
- package/zh/configure/app/performance/chunk-split.md +2 -2
- package/zh/configure/app/performance/print-file-size.md +2 -2
- package/zh/configure/app/performance/profile.md +2 -2
- package/zh/configure/app/performance/remove-console.md +2 -2
- package/zh/configure/app/performance/remove-moment-locale.md +2 -2
- package/zh/configure/app/plugins.md +6 -6
- package/zh/configure/app/runtime/intro.md +12 -11
- package/zh/configure/app/runtime/master-app.md +1 -2
- package/zh/configure/app/runtime/router.md +6 -7
- package/zh/configure/app/runtime/state.md +15 -16
- package/zh/configure/app/security/sri.md +2 -2
- package/zh/configure/app/server/base-url.md +3 -6
- package/zh/configure/app/server/enable-framework-ext.md +5 -4
- package/zh/configure/app/server/port.md +24 -6
- package/zh/configure/app/server/public-routes.md +6 -8
- package/zh/configure/app/server/routes.md +6 -6
- package/zh/configure/app/server/ssr-by-entries.md +5 -8
- package/zh/configure/app/server/ssr.md +4 -5
- package/zh/configure/app/source/alias.md +2 -2
- package/zh/configure/app/source/compile-js-data-uri.md +2 -2
- package/zh/configure/app/source/config-dir.md +2 -2
- package/zh/configure/app/source/define.md +2 -2
- package/zh/configure/app/source/design-system.md +656 -630
- package/zh/configure/app/source/disable-default-entries.md +3 -3
- package/zh/configure/app/source/disable-entry-dirs.md +8 -7
- package/zh/configure/app/source/enable-async-entry.md +3 -3
- package/zh/configure/app/source/entries-dir.md +7 -7
- package/zh/configure/app/source/entries.md +5 -6
- package/zh/configure/app/source/exclude.md +2 -2
- package/zh/configure/app/source/global-vars.md +2 -2
- package/zh/configure/app/source/include.md +2 -2
- package/zh/configure/app/source/module-scopes.md +2 -2
- package/zh/configure/app/source/pre-entry.md +2 -2
- package/zh/configure/app/source/resolve-extension-prefix.md +2 -2
- package/zh/configure/app/source/resolve-main-fields.md +2 -2
- package/zh/configure/app/testing/transformer.md +2 -3
- package/zh/configure/app/tools/autoprefixer.md +2 -2
- package/zh/configure/app/tools/babel.md +2 -2
- package/zh/configure/app/tools/css-extract.md +2 -2
- package/zh/configure/app/tools/css-loader.md +2 -2
- package/zh/configure/app/tools/dev-server.md +2 -2
- package/zh/configure/app/tools/html-plugin.md +2 -2
- package/zh/configure/app/tools/inspector.md +2 -2
- package/zh/configure/app/tools/jest.md +9 -9
- package/zh/configure/app/tools/less.md +2 -2
- package/zh/configure/app/tools/minify-css.md +2 -2
- package/zh/configure/app/tools/postcss.md +2 -2
- package/zh/configure/app/tools/pug.md +2 -2
- package/zh/configure/app/tools/sass.md +2 -2
- package/zh/configure/app/tools/style-loader.md +2 -2
- package/zh/configure/app/tools/styled-components.md +2 -2
- package/zh/configure/app/tools/swc.md +12 -1
- package/zh/configure/app/tools/terser.md +2 -2
- package/zh/configure/app/tools/ts-checker.md +2 -2
- package/zh/configure/app/tools/ts-loader.md +2 -2
- package/zh/configure/app/tools/webpack-chain.md +2 -2
- package/zh/configure/app/tools/webpack.md +2 -2
- package/zh/guides/advanced-features/bff/frameworks.md +6 -6
- package/zh/guides/advanced-features/bff/function.md +49 -44
- package/zh/guides/advanced-features/bff/index.md +9 -9
- package/zh/guides/advanced-features/bff/type.md +0 -1
- package/zh/guides/advanced-features/code-split.md +3 -3
- package/zh/guides/advanced-features/compatibility.md +6 -7
- package/zh/guides/advanced-features/eslint.md +0 -1
- package/zh/guides/advanced-features/index.md +0 -5
- package/zh/guides/advanced-features/low-level.md +17 -19
- package/zh/guides/advanced-features/ssg.md +8 -9
- package/zh/guides/advanced-features/ssr.md +5 -11
- package/zh/guides/advanced-features/testing.md +3 -2
- package/zh/guides/advanced-features/web-server.md +3 -4
- package/zh/guides/basic-features/alias.md +7 -11
- package/zh/guides/basic-features/css/css-in-js.md +5 -5
- package/zh/guides/basic-features/css/css-modules.md +2 -2
- package/zh/guides/basic-features/css/postcss.md +42 -46
- package/zh/guides/basic-features/css/tailwindcss.md +5 -5
- package/zh/guides/basic-features/data-fetch.md +109 -192
- package/zh/guides/basic-features/env-vars.md +7 -6
- package/zh/guides/basic-features/html.md +54 -46
- package/zh/guides/basic-features/index.md +0 -5
- package/zh/guides/basic-features/mock.md +4 -4
- package/zh/guides/basic-features/proxy.md +4 -5
- package/zh/guides/basic-features/routes.md +23 -20
- package/zh/guides/concept/entries.md +5 -7
- package/zh/guides/get-started/quick-start.md +3 -4
- package/zh/guides/topic-detail/changesets/add.md +1 -3
- package/zh/guides/topic-detail/changesets/changelog.md +30 -31
- package/zh/guides/topic-detail/changesets/commit.md +44 -45
- package/zh/guides/topic-detail/changesets/config.md +2 -1
- package/zh/guides/topic-detail/changesets/github.md +6 -10
- package/zh/guides/topic-detail/changesets/introduce.md +0 -1
- package/zh/guides/topic-detail/changesets/release-note.md +9 -12
- package/zh/guides/topic-detail/changesets/release-pre.md +1 -1
- package/zh/guides/topic-detail/framework-plugin/extend.md +13 -13
- package/zh/guides/topic-detail/framework-plugin/hook-list.md +2 -2
- package/zh/guides/topic-detail/framework-plugin/hook.md +57 -54
- package/zh/guides/topic-detail/framework-plugin/implement.md +11 -11
- package/zh/guides/topic-detail/framework-plugin/plugin-api.md +4 -4
- package/zh/guides/topic-detail/generator/codesmith/api/app.md +36 -36
- package/zh/guides/topic-detail/generator/codesmith/api/ejs.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/fs.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/git.md +3 -2
- package/zh/guides/topic-detail/generator/codesmith/api/handlebars.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/json.md +9 -11
- package/zh/guides/topic-detail/generator/codesmith/api/npm.md +4 -2
- package/zh/guides/topic-detail/generator/codesmith/introduce.md +20 -7
- package/zh/guides/topic-detail/generator/codesmith/run-in-js.md +4 -5
- package/zh/guides/topic-detail/generator/codesmith/structure.md +13 -10
- package/zh/guides/topic-detail/generator/config/common.md +18 -27
- package/zh/guides/topic-detail/generator/plugin/abstract.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -0
- package/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +4 -4
- package/zh/guides/topic-detail/generator/plugin/api/info/locale.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +3 -4
- package/zh/guides/topic-detail/generator/plugin/api/input/setInput.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/introduce.md +8 -9
- package/zh/guides/topic-detail/generator/plugin/develop.md +13 -13
- package/zh/guides/topic-detail/generator/plugin/use.md +8 -8
- package/zh/guides/topic-detail/generator/project.md +1 -1
- package/zh/guides/topic-detail/micro-frontend/c01-introduction.md +7 -8
- package/zh/guides/topic-detail/micro-frontend/c02-development.md +20 -23
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.md +41 -44
- package/zh/guides/topic-detail/micro-frontend/c04-communicate.md +7 -5
- package/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.md +1 -1
- package/zh/guides/topic-detail/model/auto-actions.md +0 -1
- package/zh/guides/topic-detail/model/computed-state.md +0 -2
- package/zh/guides/topic-detail/model/define-model.md +3 -6
- package/zh/guides/topic-detail/model/faq.md +2 -5
- package/zh/guides/topic-detail/model/manage-effects.md +2 -5
- package/zh/guides/topic-detail/model/model-communicate.md +1 -4
- package/zh/guides/topic-detail/model/performance.md +1 -5
- package/zh/guides/topic-detail/model/quick-start.md +0 -6
- package/zh/guides/topic-detail/model/redux-integration.md +3 -2
- package/zh/guides/topic-detail/model/test-model.md +1 -1
- package/zh/guides/topic-detail/model/typescript-best-practice.md +13 -14
- package/zh/guides/topic-detail/model/use-model.md +14 -12
- package/zh/guides/topic-detail/model/use-out-of-modernjs.md +4 -6
- package/zh/guides/topic-detail/monorepo/intro.md +0 -1
- package/zh/guides/topic-detail/monorepo/sub-project-interface.md +14 -7
- package/zh/tutorials/first-app/c01-start.md +2 -2
- package/zh/tutorials/first-app/c03-css.md +6 -9
- package/zh/tutorials/first-app/c04-routes.md +1 -1
- package/zh/tutorials/first-app/c05-loader.md +2 -1
- package/zh/tutorials/first-app/c07-container.md +6 -7
- package/zh/tutorials/first-app/c08-entries.md +5 -7
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook.md
CHANGED
@@ -12,56 +12,55 @@ sidebar_position: 2
|
|
12
12
|
先以 Pipeline 为例,简单介绍一下 Hook 模型的工作方式。先看一个简单的例子:
|
13
13
|
|
14
14
|
```ts
|
15
|
-
import { createPipeline } from '@modern-js/plugin'
|
15
|
+
import { createPipeline } from '@modern-js/plugin';
|
16
16
|
|
17
17
|
// 1. 创建
|
18
|
-
const pipeline = createPipeline<number, number>()
|
18
|
+
const pipeline = createPipeline<number, number>();
|
19
19
|
|
20
20
|
// 2. 添加函数
|
21
21
|
pipeline.use((count, next) => {
|
22
|
-
return next(count + 1)
|
23
|
-
})
|
22
|
+
return next(count + 1);
|
23
|
+
});
|
24
24
|
pipeline.use((count, next) => {
|
25
|
-
return count * 2
|
26
|
-
})
|
25
|
+
return count * 2;
|
26
|
+
});
|
27
27
|
|
28
28
|
// 3. 执行
|
29
|
-
pipeline.run(1) // 4
|
30
|
-
pipeline.run(5) // 12
|
29
|
+
pipeline.run(1); // 4
|
30
|
+
pipeline.run(5); // 12
|
31
31
|
```
|
32
32
|
|
33
33
|
在这个例子中,创建了一个 `Pipeline<number, number>` 类型的 Pipeline(L3),这意味着运行它的时候,你需要传入一个 `number`,然后你会得到一个 `number`,而这个模型管理的函数的类型是:
|
34
34
|
|
35
35
|
```ts
|
36
|
-
(count: number, next: (nextCount: number) => number) => number
|
36
|
+
(count: number, next: (nextCount: number) => number) => number;
|
37
37
|
```
|
38
38
|
|
39
39
|
这里全是 `number`,是因为我们创建的是 `Pipeline<number, number>` ,如果创建的是 `Pipeline<number, string>` 则运行它入参是 `number`,返回值是 `string`,对应管理的函数的类型会是:
|
40
40
|
|
41
41
|
```ts
|
42
|
-
(count: number, next: (nextCount: number) => string) => string
|
42
|
+
(count: number, next: (nextCount: number) => string) => string;
|
43
43
|
```
|
44
44
|
|
45
|
-
|
46
45
|
创建好 Pipeline 之后,可以通过 `use` 添加函数(L5、L8),需要注意的是,添加的顺序就是他们默认的运行顺序,在这些函数中,你可以对 `count` 进行处理、返回一个值,如果你调用了 `next` 函数,则会运行后面的函数,即如果你添加了三个函数: `A`、`B`、`C`,如果你在 `A` 中调用 `next` 那么就会运行 `B`,同样的,如果你在 `B` 中调用 `next` 那么就会运行 `C`,而在上面的例子中,添加的第一个函数(L5)就运行了 `next`,所以这里就会运行第二个函数(L8),并且运行的返回值就是 第二个函数的返回值,如果在第一个函数中没有调用 `next`,直接返回,例如:
|
47
46
|
|
48
47
|
```ts
|
49
|
-
import { createPipeline } from '@modern-js/plugin'
|
48
|
+
import { createPipeline } from '@modern-js/plugin';
|
50
49
|
|
51
50
|
// 1. 创建
|
52
|
-
const pipeline = createPipeline<number, number>()
|
51
|
+
const pipeline = createPipeline<number, number>();
|
53
52
|
|
54
53
|
// 2. 添加函数
|
55
54
|
pipeline.use((count, next) => {
|
56
|
-
return count + 1
|
57
|
-
})
|
55
|
+
return count + 1;
|
56
|
+
});
|
58
57
|
pipeline.use((count, next) => {
|
59
|
-
return count * 2
|
60
|
-
})
|
58
|
+
return count * 2;
|
59
|
+
});
|
61
60
|
|
62
61
|
// 3. 执行
|
63
|
-
pipeline.run(1) // 2
|
64
|
-
pipeline.run(5) // 6
|
62
|
+
pipeline.run(1); // 2
|
63
|
+
pipeline.run(5); // 6
|
65
64
|
```
|
66
65
|
|
67
66
|
则在运行 Pipeline 的时候就不会运行第二个函数,那么 Pipeline 的运行结果则就是第一个函数的返回值。
|
@@ -80,12 +79,16 @@ pipeline.run(5) // 6
|
|
80
79
|
当 Pipeline 中没有函数或者所有函数都调用了 `next` 函数,则就需要在运行的时候提供:
|
81
80
|
|
82
81
|
```ts
|
83
|
-
pipeline(
|
82
|
+
pipeline(
|
83
|
+
{},
|
84
|
+
{
|
84
85
|
onLast: () => {
|
85
|
-
|
86
|
-
}
|
87
|
-
}
|
86
|
+
// do something
|
87
|
+
},
|
88
|
+
},
|
89
|
+
);
|
88
90
|
```
|
91
|
+
|
89
92
|
:::
|
90
93
|
|
91
94
|
### Waterfall
|
@@ -93,31 +96,31 @@ pipeline({}, {
|
|
93
96
|
这种模型顾名思义,他的特点就是参数的顺序递交,即前面一个函数的返回值,将会成为下一个函数的入参,我们也用一个例子来看一下:
|
94
97
|
|
95
98
|
```ts
|
96
|
-
import { createWaterfall } from '@modern-js/plugin'
|
99
|
+
import { createWaterfall } from '@modern-js/plugin';
|
97
100
|
|
98
101
|
// 1. 创建
|
99
|
-
const waterfall = createWaterfall<number>()
|
102
|
+
const waterfall = createWaterfall<number>();
|
100
103
|
|
101
104
|
// 2. 添加函数
|
102
|
-
waterfall.use(
|
103
|
-
return count + 1
|
104
|
-
})
|
105
|
-
waterfall.use(
|
106
|
-
return count * 2
|
107
|
-
})
|
105
|
+
waterfall.use(count => {
|
106
|
+
return count + 1;
|
107
|
+
});
|
108
|
+
waterfall.use(count => {
|
109
|
+
return count * 2;
|
110
|
+
});
|
108
111
|
|
109
112
|
// 3. 执行
|
110
|
-
waterfall.run(1) // 4
|
111
|
-
waterfall.run(5) // 12
|
113
|
+
waterfall.run(1); // 4
|
114
|
+
waterfall.run(5); // 12
|
112
115
|
```
|
113
116
|
|
114
117
|
这个例子中,创建了一个类型为 `Waterfall<number> `,即这个模型执行的入参和返回值是一样的,这个例子中都是 `number`,而它管理的函数的类型是:
|
115
118
|
|
116
119
|
```ts
|
117
|
-
(count: number) => number
|
120
|
+
(count: number) => number;
|
118
121
|
```
|
119
122
|
|
120
|
-
可能简单看这个例子感觉和上面的 Pipeline 功能一样,那需要注意的是,首先这里 Waterfall 管理的函数没有next 函数作为第二个参数,所以它无法在函数内部通过调用 next 来先运行之后添加的函数,从而修改运行的顺序,其次这里的运行的入参的类型和返回值的类型必须是一样的(而 Pipeline 可以不一样)。
|
123
|
+
可能简单看这个例子感觉和上面的 Pipeline 功能一样,那需要注意的是,首先这里 Waterfall 管理的函数没有 next 函数作为第二个参数,所以它无法在函数内部通过调用 next 来先运行之后添加的函数,从而修改运行的顺序,其次这里的运行的入参的类型和返回值的类型必须是一样的(而 Pipeline 可以不一样)。
|
121
124
|
|
122
125
|
同样的,在 Waterfall 这个大类中,也提供了 Sync 和 Async 的小类,分别对应 Sync 和 Async 的函数。
|
123
126
|
|
@@ -126,22 +129,22 @@ waterfall.run(5) // 12
|
|
126
129
|
这种 Hook 模型与上面两种 Hook 模型的区别是,没有那么强的前后参数返回值递交的概念,在这个模型中,每个函数都是基于同样的入参,相对独立运行的,通过一个例子简单看一下:
|
127
130
|
|
128
131
|
```ts
|
129
|
-
import { createWorkflow } from '@modern-js/plugin'
|
132
|
+
import { createWorkflow } from '@modern-js/plugin';
|
130
133
|
|
131
134
|
// 1. 创建
|
132
|
-
const workflow = createWorkflow
|
135
|
+
const workflow = createWorkflow<number, number>();
|
133
136
|
|
134
137
|
// 2. 添加函数
|
135
|
-
workflow.use(
|
136
|
-
return count + 1
|
137
|
-
})
|
138
|
-
workflow.use(
|
139
|
-
return count * 2
|
140
|
-
})
|
138
|
+
workflow.use(count => {
|
139
|
+
return count + 1;
|
140
|
+
});
|
141
|
+
workflow.use(count => {
|
142
|
+
return count * 2;
|
143
|
+
});
|
141
144
|
|
142
145
|
// 3. 执行
|
143
|
-
workflow.run(1) // [2, 2]
|
144
|
-
workflow.run(5) // [6, 10]
|
146
|
+
workflow.run(1); // [2, 2]
|
147
|
+
workflow.run(5); // [6, 10]
|
145
148
|
```
|
146
149
|
|
147
150
|
在这个例子中,添加了两个函数,所以运行的结果就是这两个函数运行的结果形成的一个数组。
|
@@ -153,15 +156,15 @@ workflow.run(5) // [6, 10]
|
|
153
156
|
<div style={{ width: "100%", overflowX: "scroll" }}>
|
154
157
|
<div style={{ width: "150%" }}>
|
155
158
|
|
156
|
-
|
157
|
-
|
158
|
-
|Pipeline|Sync
|
159
|
-
|AsyncPipeline|Sync/Async
|
160
|
-
|WaterFall|Sync
|
161
|
-
|AsyncWaterFall|Sync/Async
|
162
|
-
|Workflow|Sync
|
163
|
-
|AsyncWorkflow|Sync/Async
|
164
|
-
|ParallelWorkFlow|Sync/Async
|
159
|
+
| | 函数类型 | 执行顺序 | 函数参数来源 | 执行返回值来源 | 倾向处理的任务类型 | 函数 TS 类型 |
|
160
|
+
| ---------------- | ---------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------ | ------------------------------------------------------------------- | ------------------------------------------------------ |
|
161
|
+
| Pipeline | Sync | 默认执行第一个添加的函数,可以通过 next 调用之后添加的函数 | 第一个函数的参数来源是运行的参数,之后的函数的参数来源是,前一个函数向 next 函数传递的参数 | 第一个函数的返回值 | <ul><li>需要修改初始参数</li><li>需要修改函数执行顺序</li></ul> | `(input: I, next: Next<I, O>) => O` |
|
162
|
+
| AsyncPipeline | Sync/Async | 默认执行第一个添加的函数,可以通过 next 调用之后添加的函数 | 第一个函数的参数来源是运行的参数,之后的函数的参数来源是,前一个函数向 next 函数传递的参数 | 第一个函数的返回值 | <ul><li>需要修改初始参数</li><li>需要修改函数执行顺序</li></ul> | `(input: I, next: AsyncNext<I, O>) => O | Promise<O>` |
|
163
|
+
| WaterFall | Sync | 一直顺序执行 | 第一个函数的参数来源是运行的参数,之后的函数的参数来源是,前一个函数的返回值 | 最后一个函数的返回值 | <ul><li>需要修改初始参数</li><li>不需要修改函数执行顺序</li></ul> | `(I: I) => I` |
|
164
|
+
| AsyncWaterFall | Sync/Async | 一直顺序执行 | 第一个函数的参数来源是运行的参数,之后的函数的参数来源是,前一个函数的返回值 | 最后一个函数的返回值 | <ul><li>需要修改初始参数</li><li>不需要修改函数执行顺序</li></ul> | `(I: I) => I | Promise<I>` |
|
165
|
+
| Workflow | Sync | 一直顺序执行 | 所有函数的入参都是运行的参数 | 所有函数返回值形成的数组 | <ul><li>不需要修改初始参数</li><li>不需要修改函数执行顺序</li></ul> | `(I: I) => O` |
|
166
|
+
| AsyncWorkflow | Sync/Async | 一直顺序执行 | 所有函数的入参都是运行的参数 | 所有函数返回值形成的数组 | <ul><li>不需要修改初始参数</li><li>不需要修改函数执行顺序</li></ul> | `(I: I) => O | Promise<O>` |
|
167
|
+
| ParallelWorkFlow | Sync/Async | 异步执行 | 所有函数的入参都是运行的参数 | 所有函数返回值形成的数组 | <ul><li>不需要修改初始参数</li><li>不关心执行顺序</li></ul> | `(I: I) => O | Promise<O>` |
|
165
168
|
|
166
169
|
</div>
|
167
170
|
</div>
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/implement.md
CHANGED
@@ -13,7 +13,7 @@ Modern.js 插件是一个对象,对象包含以下属性:
|
|
13
13
|
- `setup`: 插件初始化函数,只会执行一次。setup 函数可以返回一个 Hooks 对象,Modern.js 会在特定的时机执行这些 Hooks。
|
14
14
|
|
15
15
|
```ts
|
16
|
-
const
|
16
|
+
const myPlugin = {
|
17
17
|
name: 'my-plugin',
|
18
18
|
|
19
19
|
setup() {
|
@@ -51,7 +51,7 @@ Modern-js 支持多种工程开发,如应用工程(app-tools), 模块工程(mo
|
|
51
51
|
```ts
|
52
52
|
import type { CliPlugin } from '@modern-js/core';
|
53
53
|
|
54
|
-
const
|
54
|
+
const myPlugin: CliPlugin = {
|
55
55
|
name: 'my-plugin',
|
56
56
|
|
57
57
|
setup() {
|
@@ -71,7 +71,7 @@ const MyPlugin: CliPlugin = {
|
|
71
71
|
```ts
|
72
72
|
import type { CliPlugin, AppTools } from '@modern-js/app-tools';
|
73
73
|
|
74
|
-
const
|
74
|
+
const myPlugin: CliPlugin<AppTools> = {
|
75
75
|
name: 'my-plugin',
|
76
76
|
|
77
77
|
setup() {
|
@@ -103,7 +103,7 @@ type AppTools = {
|
|
103
103
|
import type { CliPlugin } from '@modern-js/core';
|
104
104
|
import type { MyPluginHook } from 'xxx';
|
105
105
|
|
106
|
-
const
|
106
|
+
const myPlugin: CliPlugin<{ hooks: MyPluginHook }> = {};
|
107
107
|
```
|
108
108
|
|
109
109
|
```ts
|
@@ -111,7 +111,7 @@ const MyPlugin: CliPlugin<{ hooks: MyPluginHook }> = {};
|
|
111
111
|
import type { CliPlugin, AppTools } from '@modern-js/app-tools';
|
112
112
|
import type { MyPluginHook } from 'xxx';
|
113
113
|
|
114
|
-
const
|
114
|
+
const myPlugin: CliPlugin<AppTools & { hooks: MyPluginHook }> = {};
|
115
115
|
```
|
116
116
|
|
117
117
|
详细说明,请参考 [扩展 Hook](/docs/guides/topic-detail/framework-plugin/extend)。
|
@@ -127,7 +127,7 @@ type MyPluginOptions = {
|
|
127
127
|
foo: string;
|
128
128
|
};
|
129
129
|
|
130
|
-
const
|
130
|
+
const myPlugin = (options: MyPluginOptions): CliPlugin => ({
|
131
131
|
name: 'my-plugin',
|
132
132
|
|
133
133
|
setup() {
|
@@ -183,7 +183,7 @@ export default (): CliPlugin => ({
|
|
183
183
|
|
184
184
|
本地插件推荐写在 `config/plugin` 目录下,并通过 `export default` 导出:
|
185
185
|
|
186
|
-
```ts title=config/plugin/
|
186
|
+
```ts title=config/plugin/myPlugin.ts
|
187
187
|
import type { CliPlugin } from '@modern-js/core';
|
188
188
|
|
189
189
|
export default (): CliPlugin => ({
|
@@ -199,10 +199,10 @@ export default (): CliPlugin => ({
|
|
199
199
|
|
200
200
|
```ts title="modern.config.ts"
|
201
201
|
import { defineConfig } from '@modern-js/app-tools';
|
202
|
-
import
|
202
|
+
import myPlugin from './config/plugin/myPlugin';
|
203
203
|
|
204
204
|
export default defineConfig({
|
205
|
-
plugins: [
|
205
|
+
plugins: [myPlugin()],
|
206
206
|
});
|
207
207
|
```
|
208
208
|
|
@@ -237,10 +237,10 @@ export default (): CliPlugin => ({
|
|
237
237
|
|
238
238
|
```ts title="modern.config.ts"
|
239
239
|
import { defineConfig } from '@modern-js/app-tools';
|
240
|
-
import
|
240
|
+
import myPlugin from 'my-plugin';
|
241
241
|
|
242
242
|
export default defineConfig({
|
243
|
-
plugins: [
|
243
|
+
plugins: [myPlugin()],
|
244
244
|
});
|
245
245
|
```
|
246
246
|
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/lifecycle.md
CHANGED
@@ -7,7 +7,6 @@ Modern.js application has a complete lifecycle, including CLI, Server Side and R
|
|
7
7
|
|
8
8
|
Modern.js lifecycle is as follows:
|
9
9
|
|
10
|
-
|
11
10
|
:::note
|
12
11
|
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
12
|
:::
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/plugin-api.md
CHANGED
@@ -29,7 +29,7 @@ export default (): CliPlugin => ({
|
|
29
29
|
用于获取应用原始配置。
|
30
30
|
|
31
31
|
```ts
|
32
|
-
const useConfigContext: () => UserConfig
|
32
|
+
const useConfigContext: () => UserConfig;
|
33
33
|
|
34
34
|
interface UserConfig {
|
35
35
|
source?: SourceConfig;
|
@@ -51,7 +51,7 @@ interface UserConfig {
|
|
51
51
|
用于获取应用运行上下文。
|
52
52
|
|
53
53
|
```ts
|
54
|
-
const useAppContext: () => IAppContext
|
54
|
+
const useAppContext: () => IAppContext;
|
55
55
|
|
56
56
|
interface IAppContext {
|
57
57
|
appDirectory: string;
|
@@ -79,7 +79,7 @@ interface IAppContext {
|
|
79
79
|
用于获取解析之后的最终配置。
|
80
80
|
|
81
81
|
```ts
|
82
|
-
const useResolvedConfigContext: () => NormalizedConfig
|
82
|
+
const useResolvedConfigContext: () => NormalizedConfig;
|
83
83
|
|
84
84
|
interface NormalizedConfig {
|
85
85
|
source: NormalizedSourceConfig;
|
@@ -91,7 +91,7 @@ interface NormalizedConfig {
|
|
91
91
|
plugins: PluginConfig;
|
92
92
|
runtime: RuntimeConfig;
|
93
93
|
runtimeByEntries?: RuntimeByEntriesConfig;
|
94
|
-
_raw: UserConfig
|
94
|
+
_raw: UserConfig;
|
95
95
|
}
|
96
96
|
```
|
97
97
|
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md
CHANGED
@@ -8,13 +8,13 @@ The combination encapsulation of APIs commonly used in the development of microg
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { AppAPI } from '@modern-js/codesmith-api-app';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
15
|
const appApi = new AppAPI(context, generator);
|
16
16
|
await appApi.runInstall();
|
17
|
-
}
|
17
|
+
};
|
18
18
|
```
|
19
19
|
|
20
20
|
- Create AppAPI instance, the parameter is the generator of the microgenerator function parameter, please see the composition of the microgenerator project for details.
|
@@ -50,8 +50,8 @@ This function performs the following actions:
|
|
50
50
|
3. Install dependencies.
|
51
51
|
4. Commit the initial commit in a non-monorepo project (judging the condition, `isMonorepoSubProject` does not exist or is false in the config), the commit information is feat: init, and customize is supported.
|
52
52
|
|
53
|
-
|
54
53
|
Parameter:
|
54
|
+
|
55
55
|
- commitMessage?: `string`, Initialization commit message
|
56
56
|
- installFunc?: `() => Promise<void>`. Install dependency function
|
57
57
|
|
@@ -69,31 +69,31 @@ Parameter:
|
|
69
69
|
|
70
70
|
For example:
|
71
71
|
|
72
|
-
```
|
72
|
+
```ts
|
73
|
+
await appApi.forgeTemplate(
|
74
|
+
'templates/base-templates/**/*',
|
75
|
+
undefined,
|
76
|
+
resourceKey =>
|
77
|
+
resourceKey
|
78
|
+
.replace('templates/base-templates/', '')
|
79
|
+
.replace('.handlebars', ''),
|
80
|
+
);
|
81
|
+
|
73
82
|
await appApi.forgeTemplate(
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
.replace('language', language as string)
|
89
|
-
.replace('.handlebars', ''),
|
90
|
-
{
|
91
|
-
name: packageName as string,
|
92
|
-
language,
|
93
|
-
isTs: language === Language.TS,
|
94
|
-
packageManager: getPackageManagerText(packageManager as any),
|
95
|
-
},
|
96
|
-
);
|
83
|
+
'templates/base-template/**/*',
|
84
|
+
resourceKey => !resourceKey.include('eslintrc.json'),
|
85
|
+
resourceKey =>
|
86
|
+
resourceKey
|
87
|
+
.replace('templates/base-template/', projectPath)
|
88
|
+
.replace('language', language as string)
|
89
|
+
.replace('.handlebars', ''),
|
90
|
+
{
|
91
|
+
name: packageName as string,
|
92
|
+
language,
|
93
|
+
isTs: language === Language.TS,
|
94
|
+
packageManager: getPackageManagerText(packageManager as any),
|
95
|
+
},
|
96
|
+
);
|
97
97
|
```
|
98
98
|
|
99
99
|
### showSuccessInfo
|
@@ -116,12 +116,12 @@ Parameter:
|
|
116
116
|
|
117
117
|
For example:
|
118
118
|
|
119
|
-
```
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
119
|
+
```ts
|
120
|
+
await appApi.runSubGenerator(
|
121
|
+
getGeneratorPath('@modern-js/repo-generator', context.config.distTag),
|
122
|
+
undefined,
|
123
|
+
{ ...context.config, hasPlugin: false },
|
124
|
+
);
|
125
125
|
```
|
126
126
|
|
127
127
|
### getInputBySchema
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md
CHANGED
@@ -8,7 +8,7 @@ An API wrapper for file operations using [ejs] (https://ejs.co/) in microgenerat
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { EjsAPI } from '@modern-js/codesmith-api-ejs';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
@@ -32,7 +32,7 @@ Render a single template file.
|
|
32
32
|
|
33
33
|
Parameter:
|
34
34
|
|
35
|
-
- templateResource: `FsResource`. Template file resource, used by
|
35
|
+
- templateResource: `FsResource`. Template file resource, used by `context.materials.get(<filename>)`.
|
36
36
|
- target: `string`. Target file path name.
|
37
37
|
- parameters?: `Record<string, string>`. Render parameter.
|
38
38
|
|
@@ -47,7 +47,7 @@ Parameter:
|
|
47
47
|
- target: `(globMatch: string) => string`. The target file path generation function, the parameter is `resourceKey.`
|
48
48
|
- options?: `RenderTemplateDirOptions`. Glob Find the file configuration, the specific function viewable is here [glob] (https://www.npmjs.com/package/glob).
|
49
49
|
|
50
|
-
```
|
50
|
+
```ts
|
51
51
|
type RenderTemplateDirOptions = {
|
52
52
|
nodir?: boolean;
|
53
53
|
dot?: boolean;
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md
CHANGED
@@ -8,7 +8,7 @@ API wrapper for file operations in microgenerators, providing methods to render
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { FsAPI } from '@modern-js/codesmith-api-fs';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
@@ -31,7 +31,7 @@ Render a single template file.
|
|
31
31
|
|
32
32
|
Parameter:
|
33
33
|
|
34
|
-
- resource: `FsResource`. Template file resource, used by
|
34
|
+
- resource: `FsResource`. Template file resource, used by `context.materials.get(<filename>)`.
|
35
35
|
- target: `string`. Target file path name.
|
36
36
|
|
37
37
|
### renderDir
|
@@ -45,7 +45,7 @@ Parameter:
|
|
45
45
|
- target: `(globMatch: string) => string`. The target file path generation function, the parameter is `resourceKey.`
|
46
46
|
- options?: `RenderTemplateDirOptions`. Glob Find the file configuration, the specific function viewable is here [glob] (https://www.npmjs.com/package/glob).
|
47
47
|
|
48
|
-
```
|
48
|
+
```ts
|
49
49
|
type RenderTemplateDirOptions = {
|
50
50
|
nodir?: boolean;
|
51
51
|
dot?: boolean;
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md
CHANGED
@@ -8,13 +8,13 @@ The API encapsulation of git-related operations in the micro-generator provides
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { GitAPI } from '@modern-js/codesmith-api-git';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
15
|
const gitApi = new GitAPI(generatorCore, generatorContext);
|
16
16
|
await gitApi.initGitRepo();
|
17
|
-
}
|
17
|
+
};
|
18
18
|
```
|
19
19
|
|
20
20
|
- Create GitAPI instance, the parameter is the generator of the microgenerator function parameter, please see the composition of the microgenerator project for details.
|
@@ -45,5 +45,6 @@ Parameter:
|
|
45
45
|
Execute `git add .` and `git commit` commit the current changes.
|
46
46
|
|
47
47
|
Parameter:
|
48
|
+
|
48
49
|
- commitMessage: `string`. Commit information.
|
49
50
|
- cwd?: `string`. The execution directory of the git command, the default is microgenerator `outputPath`.
|
@@ -8,7 +8,7 @@ An API wrapper for file operations using [handlebars] (https://handlebarsjs.com/
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { HandlebarsAPI } from '@modern-js/codesmith-api-handlebars';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
@@ -25,7 +25,6 @@ export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
25
25
|
|
26
26
|
- Just call the API on its example.
|
27
27
|
|
28
|
-
|
29
28
|
## API
|
30
29
|
|
31
30
|
### renderTemplate
|
@@ -34,7 +33,7 @@ Render a single template file.
|
|
34
33
|
|
35
34
|
Parameter:
|
36
35
|
|
37
|
-
- templateResource: `FsResource`. Template file resource, used by
|
36
|
+
- templateResource: `FsResource`. Template file resource, used by `context.materials.get(<filename>)`.
|
38
37
|
- target: `string`. Target file path name.
|
39
38
|
- parameters?: `Record<string, string>`. Render parameter.
|
40
39
|
|
@@ -49,7 +48,7 @@ Parameter:
|
|
49
48
|
- target: `(globMatch: string) => string`. The target file path generation function, the parameter is `resourceKey.`
|
50
49
|
- options?: `RenderTemplateDirOptions`. Glob Find the file configuration, the specific function viewable is here [glob] (https://www.npmjs.com/package/glob).
|
51
50
|
|
52
|
-
```
|
51
|
+
```ts
|
53
52
|
type RenderTemplateDirOptions = {
|
54
53
|
nodir?: boolean;
|
55
54
|
dot?: boolean;
|
@@ -8,29 +8,25 @@ The JSON API encapsulation in the microgenerator provides common JSON file opera
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { JsonAPI } from '@modern-js/codesmith-api-json';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
15
|
const jsonAPI = new JsonAPI(generator);
|
16
|
-
await jsonAPI.update(
|
17
|
-
|
18
|
-
{
|
19
|
-
|
20
|
-
|
21
|
-
$set: {
|
22
|
-
'dependencies.@modern-js/plugin-bff': `^2.0.0`,
|
23
|
-
},
|
16
|
+
await jsonAPI.update(context.materials.default.get('package.json'), {
|
17
|
+
query: {},
|
18
|
+
update: {
|
19
|
+
$set: {
|
20
|
+
'dependencies.@modern-js/plugin-bff': `^2.0.0`,
|
24
21
|
},
|
25
22
|
},
|
26
|
-
);
|
27
|
-
|
23
|
+
});
|
24
|
+
};
|
28
25
|
```
|
29
26
|
|
30
27
|
- Create JsonAPI instance, the parameter is the generator of the microgenerator function parameter, please see the composition of the microgenerator project for details.
|
31
28
|
- Just call the API on its example.
|
32
29
|
|
33
|
-
|
34
30
|
## API
|
35
31
|
|
36
32
|
### get
|
@@ -38,6 +34,7 @@ export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
|
38
34
|
Get the JSON file content.
|
39
35
|
|
40
36
|
Parameter:
|
37
|
+
|
41
38
|
- resource: `FsResource`. A file resource,get by `context.materials.default.get(<filename>)`.
|
42
39
|
|
43
40
|
### extend
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md
CHANGED
@@ -8,20 +8,19 @@ The NPM API encapsulation in the microgenerator provides a common method for ins
|
|
8
8
|
|
9
9
|
## Use
|
10
10
|
|
11
|
-
```
|
11
|
+
```ts
|
12
12
|
import { NpmAPI } from '@modern-js/codesmith-api-npm';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
15
|
const npmApi = new NpmAPI(generator);
|
16
16
|
await npmApi.pnpmInstall();
|
17
|
-
}
|
17
|
+
};
|
18
18
|
```
|
19
19
|
|
20
20
|
- Create NpmAPI instance, the parameter is the generator of the microgenerator function parameter, please see the composition of the microgenerator project for details.
|
21
21
|
|
22
22
|
- Just call the API on its example.
|
23
23
|
|
24
|
-
|
25
24
|
## API
|
26
25
|
|
27
26
|
### npmInstall
|
@@ -16,7 +16,7 @@ Codesmith also encapsulates the commonly used methods, and can directly use the
|
|
16
16
|
|
17
17
|
GeneratorCore is the core of codesmith running generator, maintaining the context and running methods during the execution of the generator.
|
18
18
|
|
19
|
-
```
|
19
|
+
```ts
|
20
20
|
class GeneratorCore {
|
21
21
|
logger: ILogger;
|
22
22
|
materialsManager: MaterialsManager;
|
@@ -35,9 +35,10 @@ class GeneratorCore {
|
|
35
35
|
|
36
36
|
The micro-generator resource information currently only includes file resources (fsMaterials). Through this field, the template resources in the generator execution process can be obtained and operated through the API.
|
37
37
|
|
38
|
-
```
|
38
|
+
```ts
|
39
39
|
class MaterialsManager {
|
40
|
-
materialMap: {
|
40
|
+
materialMap: {
|
41
|
+
// 资源映射关系
|
41
42
|
[materialUri: string]: FsMaterial;
|
42
43
|
};
|
43
44
|
loadLocalGenerator(generator: string): Promise<FsMaterial>;
|