├── example ├── plugin-layout │ ├── index.js │ ├── renderRightContent │ │ └── index.js │ └── package.json ├── services │ ├── index.ts │ └── user.ts ├── models │ ├── count.ts │ ├── foo.ts │ └── bar.ts ├── locales │ ├── en-US.js │ ├── nl-NL.js │ └── zh-CN.js ├── .gitignore ├── typing.d.ts ├── pages │ ├── plugin-model.css │ ├── index.tsx │ ├── plugin-locale.css │ ├── plugin-access.tsx │ ├── plugin-no-access.tsx │ ├── request │ │ └── index.tsx │ ├── plugin-qiankun.tsx │ ├── plugin-model.js │ └── plugin-initial-state.js ├── mock │ └── user.js ├── package.json ├── access.ts └── tsconfig.json ├── typing.d.ts ├── packages ├── plugin-qiankun │ ├── examples │ │ ├── app3 │ │ │ ├── app.js │ │ │ ├── global.less │ │ │ ├── .env │ │ │ ├── services │ │ │ │ ├── request.js │ │ │ │ └── user.js │ │ │ ├── pages │ │ │ │ ├── index.js │ │ │ │ ├── $abc.js │ │ │ │ └── user │ │ │ │ │ └── index.js │ │ │ ├── layouts │ │ │ │ ├── style.less │ │ │ │ └── index.js │ │ │ ├── serve.json │ │ │ ├── package.json │ │ │ ├── mock │ │ │ │ └── user.js │ │ │ ├── models │ │ │ │ └── user.js │ │ │ └── .umirc.js │ │ ├── app4 │ │ │ ├── app.js │ │ │ ├── global.less │ │ │ ├── .env │ │ │ ├── services │ │ │ │ ├── request.js │ │ │ │ └── user.js │ │ │ ├── pages │ │ │ │ ├── index.js │ │ │ │ ├── $abc.js │ │ │ │ └── user │ │ │ │ │ └── index.js │ │ │ ├── layouts │ │ │ │ ├── style.less │ │ │ │ └── index.js │ │ │ ├── serve.json │ │ │ ├── package.json │ │ │ ├── mock │ │ │ │ └── user.js │ │ │ ├── models │ │ │ │ └── user.js │ │ │ └── .umirc.js │ │ ├── master │ │ │ ├── public │ │ │ │ └── .gitkeep │ │ │ ├── global.js │ │ │ ├── .env │ │ │ ├── pages │ │ │ │ ├── index.css │ │ │ │ ├── app2 │ │ │ │ │ └── index.js │ │ │ │ └── index.js │ │ │ ├── services │ │ │ │ ├── app.js │ │ │ │ └── request.js │ │ │ ├── serve.json │ │ │ ├── package.json │ │ │ ├── jsconfig.json │ │ │ ├── global.less │ │ │ ├── layouts │ │ │ │ └── style.less │ │ │ ├── mock │ │ │ │ └── app.js │ │ │ ├── app.js │ │ │ └── models │ │ │ │ └── base.js │ │ ├── app1 │ │ │ ├── global.less │ │ │ ├── .env │ │ │ ├── services │ │ │ │ ├── request.js │ │ │ │ └── user.js │ │ │ ├── app.js │ │ │ ├── layouts │ │ │ │ ├── style.less │ │ │ │ └── index.js │ │ │ ├── serve.json │ │ │ ├── package.json │ │ │ ├── mock │ │ │ │ └── user.js │ │ │ ├── models │ │ │ │ └── user.js │ │ │ ├── .umirc.js │ │ │ └── pages │ │ │ │ ├── user │ │ │ │ └── index.js │ │ │ │ └── index.js │ │ └── app2 │ │ │ ├── global.less │ │ │ ├── .env │ │ │ ├── services │ │ │ ├── request.js │ │ │ └── user.js │ │ │ ├── pages │ │ │ ├── index.js │ │ │ └── user │ │ │ │ ├── model.js │ │ │ │ └── index.js │ │ │ ├── layouts │ │ │ ├── style.less │ │ │ └── index.js │ │ │ ├── package.json │ │ │ ├── serve.json │ │ │ ├── mock │ │ │ └── user.js │ │ │ ├── app.js │ │ │ └── .umirc.js │ ├── src │ │ ├── master │ │ │ ├── ErrorBoundary.tsx.tpl │ │ │ ├── AntdLoader.tsx.tpl │ │ │ └── AntdErrorBoundary.tsx.tpl │ │ ├── constants.ts │ │ ├── slave │ │ │ ├── qiankunModel.ts.tpl │ │ │ ├── connectMaster.tsx.tpl │ │ │ └── slaveRuntimePlugin.ts.tpl │ │ └── index.ts │ ├── .fatherrc.ts │ ├── README.md │ ├── typings │ │ └── index.d.ts │ ├── tsconfig.json │ ├── readme │ │ └── IE兼容性初步解决方案.md │ └── LICENSE ├── plugin-dva │ ├── src │ │ ├── getModels │ │ │ └── fixtures │ │ │ │ ├── normal │ │ │ │ ├── a.css │ │ │ │ ├── h.d.ts │ │ │ │ ├── g.test.ts │ │ │ │ ├── e.jsx │ │ │ │ ├── f.tsx │ │ │ │ ├── b.js │ │ │ │ └── c.ts │ │ │ │ ├── extraModels │ │ │ │ └── .gitkeep │ │ │ │ ├── skipModelValidate │ │ │ │ └── no_content.js │ │ │ │ ├── models-for-extraModels │ │ │ │ ├── a_valid.js │ │ │ │ └── b_invalid.js │ │ │ │ └── jsx │ │ │ │ └── a.jsx │ │ ├── fixtures │ │ │ ├── lazyLoad │ │ │ │ ├── utils.ts │ │ │ │ ├── pages │ │ │ │ │ ├── index.less │ │ │ │ │ └── index.tsx │ │ │ │ ├── models │ │ │ │ │ └── foo.ts │ │ │ │ └── .umirc.ts │ │ │ ├── normal │ │ │ │ ├── pages │ │ │ │ │ ├── index.less │ │ │ │ │ └── index.tsx │ │ │ │ ├── models │ │ │ │ │ └── foo.ts │ │ │ │ └── .umirc.ts │ │ │ ├── with-immer │ │ │ │ ├── pages │ │ │ │ │ ├── index.less │ │ │ │ │ └── index.tsx │ │ │ │ ├── .umirc.ts │ │ │ │ └── models │ │ │ │ │ └── foo.ts │ │ │ └── page-models │ │ │ │ ├── models │ │ │ │ └── foo.ts │ │ │ │ ├── pages │ │ │ │ └── home │ │ │ │ │ ├── index.less │ │ │ │ │ ├── models │ │ │ │ │ └── bar.ts │ │ │ │ │ └── index.tsx │ │ │ │ └── .umirc.ts │ │ ├── exports.tpl │ │ ├── getUserLibDir.ts │ │ └── runtime.tpl │ ├── README.md │ └── package.json ├── plugin-crossorigin │ ├── src │ │ └── fixtures │ │ │ ├── normal │ │ │ ├── package.json │ │ │ ├── pages │ │ │ │ └── index.tsx │ │ │ └── .umirc.ts │ │ │ └── public-path │ │ │ ├── package.json │ │ │ ├── pages │ │ │ └── index.tsx │ │ │ └── .umirc.ts │ ├── README.md │ ├── package.json │ └── CHANGELOG.md ├── plugin-initial-state │ ├── src │ │ ├── fixtures │ │ │ ├── shouldPluginEnable │ │ │ │ ├── n-empty.js │ │ │ │ ├── n-ts-type-as.ts │ │ │ │ ├── n-tsx.tsx │ │ │ │ ├── y-export-function.js │ │ │ │ ├── y-export-ts-as.ts │ │ │ │ ├── y-export-const.js │ │ │ │ ├── y-export-specifiers.js │ │ │ │ ├── y-export-tsx-with-jsx.tsx │ │ │ │ └── n-more-syntax.js │ │ │ ├── default │ │ │ │ ├── src │ │ │ │ │ ├── app.js │ │ │ │ │ └── pages │ │ │ │ │ │ └── index.js │ │ │ │ └── .umirc.ts │ │ │ ├── noEntry │ │ │ │ ├── src │ │ │ │ │ ├── app.js │ │ │ │ │ └── pages │ │ │ │ │ │ └── index.js │ │ │ │ └── .umirc.ts │ │ │ ├── setInitialState │ │ │ │ ├── src │ │ │ │ │ ├── app.js │ │ │ │ │ └── pages │ │ │ │ │ │ └── index.js │ │ │ │ ├── .umirc.ts │ │ │ │ └── test.js │ │ │ └── noExports │ │ │ │ ├── .umirc.ts │ │ │ │ └── src │ │ │ │ └── pages │ │ │ │ └── index.js │ │ ├── utils │ │ │ ├── getExportContent.tsx │ │ │ ├── shouldPluginEnable.test.ts │ │ │ └── getProviderContent.tsx │ │ ├── runtime.tsx.tpl │ │ └── constants.ts │ ├── README.md │ └── package.json ├── plugin-locale │ ├── fixtures │ │ ├── multiple-ext │ │ │ ├── src │ │ │ │ ├── page │ │ │ │ │ └── temp │ │ │ │ │ │ ├── locale │ │ │ │ │ │ ├── test.js │ │ │ │ │ │ ├── en-US │ │ │ │ │ │ │ └── t.js │ │ │ │ │ │ ├── sk.json │ │ │ │ │ │ ├── en-US.js │ │ │ │ │ │ └── zh-CN.ts │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ └── model.js │ │ │ │ ├── locale │ │ │ │ │ ├── sk.json │ │ │ │ │ ├── en-US.js │ │ │ │ │ └── zh-CN.ts │ │ │ │ └── app.js │ │ │ ├── package.json │ │ │ └── config │ │ │ │ └── config.js │ │ ├── base-separator │ │ │ ├── src │ │ │ │ ├── pages │ │ │ │ │ └── temp │ │ │ │ │ │ ├── locales │ │ │ │ │ │ ├── test.js │ │ │ │ │ │ ├── en_US │ │ │ │ │ │ │ └── t.js │ │ │ │ │ │ ├── en_US.js │ │ │ │ │ │ ├── sk.js │ │ │ │ │ │ └── zh_CN.js │ │ │ │ │ │ ├── index.js │ │ │ │ │ │ └── model.js │ │ │ │ └── locales │ │ │ │ │ ├── sk.js │ │ │ │ │ ├── zh_CN.js │ │ │ │ │ └── en_US.js │ │ │ ├── package.json │ │ │ └── config │ │ │ │ └── config.js │ │ ├── normal │ │ │ ├── src │ │ │ │ ├── locales │ │ │ │ │ ├── sk.js │ │ │ │ │ ├── zh-CN.js │ │ │ │ │ └── en-US.js │ │ │ │ └── app.js │ │ │ └── .umirc.ts │ │ ├── singular │ │ │ ├── src │ │ │ │ ├── app.js │ │ │ │ └── locale │ │ │ │ │ ├── zh-CN.js │ │ │ │ │ ├── en-US.js │ │ │ │ │ └── sk.js │ │ │ └── .umirc.ts │ │ └── runtime │ │ │ ├── src │ │ │ ├── locales │ │ │ │ ├── zh-CN.js │ │ │ │ ├── en-US.js │ │ │ │ └── sk.js │ │ │ ├── app.js │ │ │ └── pages │ │ │ │ └── index.jsx │ │ │ └── .umirc.ts │ ├── README.md │ ├── src │ │ ├── templates │ │ │ └── runtime.tpl │ │ └── polyfill.ts │ └── package.json ├── plugin-model │ ├── tests │ │ ├── fixtures │ │ │ ├── modelWithDva │ │ │ │ ├── models │ │ │ │ │ ├── hook7.js │ │ │ │ │ ├── hook1.js │ │ │ │ │ ├── hook2.js │ │ │ │ │ ├── hook6.js │ │ │ │ │ ├── hook3.js │ │ │ │ │ ├── dva.js │ │ │ │ │ ├── hook5.js │ │ │ │ │ ├── dvaTs.ts │ │ │ │ │ └── hook4.js │ │ │ │ ├── test.js │ │ │ │ └── index.tsx │ │ │ ├── specialCharactersInModelName │ │ │ │ ├── models │ │ │ │ │ ├── 权限.ts │ │ │ │ │ ├── user-hook.js │ │ │ │ │ ├── umi's hook.js │ │ │ │ │ └── counter`hook-backup@1.0.tsx │ │ │ │ ├── test.js │ │ │ │ └── index.tsx │ │ │ ├── modelDoNotExist │ │ │ │ ├── test.js │ │ │ │ └── index.tsx │ │ │ ├── modelWithError │ │ │ │ ├── models │ │ │ │ │ └── name.js │ │ │ │ ├── test.js │ │ │ │ └── index.tsx │ │ │ ├── extraModel │ │ │ │ ├── extra │ │ │ │ │ └── initialState.js │ │ │ │ ├── models │ │ │ │ │ ├── auth.js │ │ │ │ │ └── message.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ ├── modelWithDependencies │ │ │ │ ├── models │ │ │ │ │ ├── auth.js │ │ │ │ │ └── message.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ ├── defaultUsage │ │ │ │ ├── models │ │ │ │ │ └── counter.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ ├── pageModels │ │ │ │ ├── pages │ │ │ │ │ └── user │ │ │ │ │ │ └── models │ │ │ │ │ │ └── counter.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ ├── pageSingleModel │ │ │ │ ├── pages │ │ │ │ │ └── user │ │ │ │ │ │ └── counter.model.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ ├── switchBackToInitialState │ │ │ │ ├── models │ │ │ │ │ └── counter.js │ │ │ │ ├── index.tsx │ │ │ │ └── test.js │ │ │ └── modelWithSelector │ │ │ │ ├── test.js │ │ │ │ ├── models │ │ │ │ └── user.js │ │ │ │ └── index.tsx │ │ └── getName.test.ts │ ├── src │ │ ├── constants.ts │ │ ├── helpers │ │ │ ├── constant.tsx.tpl │ │ │ └── dispatcher.tsx.tpl │ │ ├── runtime.tsx.tpl │ │ └── utils │ │ │ └── getModels.ts │ ├── README.md │ └── package.json ├── plugin-layout │ ├── fixtures │ │ └── .umirc.ts │ ├── src │ │ ├── types │ │ │ └── index.d.ts │ │ ├── layout │ │ │ ├── blankLayout.tsx │ │ │ └── getLayoutRenderConfig.ts │ │ ├── layoutExports.ts.tpl │ │ └── utils │ │ │ └── copySrcFiles.ts │ ├── README.md │ └── package.json ├── plugin-ant-design-pro-block │ ├── example │ │ ├── package.json │ │ ├── pages │ │ │ ├── index.css │ │ │ └── index.js │ │ ├── utils │ │ │ └── request.js │ │ └── .umirc.js │ ├── README.md │ ├── CHANGELOG.md │ └── package.json ├── plugin-helmet │ ├── fixtures │ │ ├── ssr │ │ │ ├── src │ │ │ │ ├── app.js │ │ │ │ └── pages │ │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ │ └── normal │ │ │ ├── src │ │ │ ├── app.js │ │ │ └── pages │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ ├── src │ │ └── templates │ │ │ └── exports.tpl │ ├── README.md │ └── package.json ├── plugin-analytics │ ├── src │ │ └── fixtures │ │ │ ├── analytics-ga-key │ │ │ ├── .env │ │ │ ├── pages │ │ │ │ ├── index.less │ │ │ │ └── index.tsx │ │ │ └── .umirc.ts │ │ │ └── analytics │ │ │ ├── pages │ │ │ ├── index.less │ │ │ └── index.tsx │ │ │ └── .umirc.ts │ ├── README.md │ └── package.json ├── plugin-block-devtool │ ├── example │ │ ├── src │ │ │ ├── index.css │ │ │ └── index.js │ │ ├── .umirc.js │ │ └── package.json │ ├── README.md │ ├── package.json │ └── LICENSE ├── plugin-request │ ├── .fatherrc.ts │ ├── tests │ │ └── mocks │ │ │ ├── antd.js │ │ │ └── umi │ │ │ └── index.js │ ├── src │ │ └── ui │ │ │ ├── noop.ts │ │ │ └── index.ts │ ├── README.md │ └── package.json ├── plugin-esbuild │ ├── src │ │ └── fixtures │ │ │ ├── ssr │ │ │ ├── src │ │ │ │ └── pages │ │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ │ │ ├── es5 │ │ │ ├── src │ │ │ │ └── pages │ │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ │ │ ├── no-es5 │ │ │ ├── src │ │ │ │ └── pages │ │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ │ │ └── normal │ │ │ ├── src │ │ │ └── pages │ │ │ │ └── index.js │ │ │ └── .umirc.ts │ ├── README.md │ └── package.json ├── plugin-access │ ├── src │ │ ├── fixtures │ │ │ └── normal │ │ │ │ ├── access.ts │ │ │ │ ├── pages │ │ │ │ └── index.tsx │ │ │ │ └── .umirc.ts │ │ ├── utils │ │ │ ├── getRootContainerContent.ts │ │ │ ├── getContextContent.ts │ │ │ ├── index.ts │ │ │ └── getAccessContent.ts │ │ └── index.test.ts │ ├── tests │ │ ├── utils │ │ │ ├── getAccessContent.test.ts │ │ │ ├── getContextContent.test.ts │ │ │ ├── getRootContainerContent.test.ts │ │ │ └── getAccessProviderContent.test.ts │ │ └── __mocks__ │ │ │ └── fs.ts │ ├── README.md │ └── package.json ├── preset-umi2-compatible │ ├── src │ │ ├── index.ts │ │ └── plugins │ │ │ └── router │ │ │ ├── router.ts │ │ │ └── historyAdapater.ts │ ├── README.md │ └── package.json ├── plugin-antd-dayjs │ ├── src │ │ └── runtime.tpl │ ├── README.md │ ├── CHANGELOG.md │ └── package.json ├── preset-react │ ├── src │ │ ├── defaultConfig.ts │ │ └── index.ts │ └── README.md ├── plugin-antd │ ├── README.md │ └── package.json ├── plugin-sass │ ├── README.md │ ├── CHANGELOG.md │ ├── package.json │ └── src │ │ └── index.ts ├── plugin-test │ ├── README.md │ ├── package.json │ ├── CHANGELOG.md │ └── src │ │ └── index.ts ├── plugin-preact │ ├── README.md │ ├── src │ │ └── index.ts │ └── package.json ├── plugin-stylus │ ├── README.md │ ├── CHANGELOG.md │ ├── package.json │ └── src │ │ └── index.ts ├── plugin-openapi │ ├── README.md │ └── package.json ├── plugin-antd-mobile │ ├── README.md │ ├── package.json │ └── CHANGELOG.md ├── plugin-dev-externals │ ├── README.md │ ├── CHANGELOG.md │ └── package.json └── preset-ant-design-pro │ ├── README.md │ ├── src │ ├── chainWebpack.ts │ └── index.ts │ └── package.json ├── .yarnrc ├── cypress.json ├── .prettierignore ├── .gitignore ├── cypress ├── fixtures │ └── example.json ├── support │ ├── index.js │ └── commands.js └── plugins │ └── index.js ├── scripts ├── utils │ ├── isNextVersion.js │ ├── getPackages.js │ └── exec.js └── verifyCommit.js ├── .prettierrc ├── .editorconfig ├── jest.config.js ├── .github └── workflows │ ├── outdated.yml │ ├── coverage.yml │ └── ci.yml ├── lerna.json ├── .fatherrc.ts ├── tsconfig.json └── README.md /example/plugin-layout/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /typing.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'semver'; 2 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/app.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/app.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/services/index.ts: -------------------------------------------------------------------------------- 1 | export * from './user'; 2 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/a.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/h.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/public/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/extraModels/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/g.test.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/models/count.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | state: 0, 3 | }; 4 | -------------------------------------------------------------------------------- /example/models/foo.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | state: 2, 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/normal/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/public-path/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/n-empty.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/locale/test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/locales/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'Hi, {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /example/locales/nl-NL.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: '你好,{name}', 3 | }; 4 | -------------------------------------------------------------------------------- /example/locales/zh-CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: '你好,{name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/skipModelValidate/no_content.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/locales/test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/locale/en-US/t.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/global.js: -------------------------------------------------------------------------------- 1 | import 'whatwg-fetch'; 2 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/locales/en_US/t.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook7.js: -------------------------------------------------------------------------------- 1 | export default {}; -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/.env: -------------------------------------------------------------------------------- 1 | PORT=8000 2 | BROWSER=none 3 | 4 | -------------------------------------------------------------------------------- /packages/plugin-layout/fixtures/.umirc.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | layout: {} 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/global.less: -------------------------------------------------------------------------------- 1 | #app1 { 2 | height: 100%; 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/global.less: -------------------------------------------------------------------------------- 1 | #app2 { 2 | height: 100%; 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/global.less: -------------------------------------------------------------------------------- 1 | #app3 { 2 | height: 100%; 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/global.less: -------------------------------------------------------------------------------- 1 | #app4 { 2 | height: 100%; 3 | } 4 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Using the official mirror source 2 | registry "https://registry.yarnpkg.com" 3 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /.umi 2 | /.umi-production 3 | /dist 4 | /node_modules 5 | /yarn.lock 6 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example" 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/lazyLoad/utils.ts: -------------------------------------------------------------------------------- 1 | export { data } from './pages/index'; 2 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/ssr/src/app.js: -------------------------------------------------------------------------------- 1 | export function patchRoutes({ routes }) { 2 | } -------------------------------------------------------------------------------- /packages/plugin-model/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const DIR_NAME_IN_TMP = 'plugin-model'; 2 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/.env: -------------------------------------------------------------------------------- 1 | PORT=8002 2 | # HTTPS=true 3 | BROWSER=none 4 | -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "projectId": "aprgbp", 3 | "baseUrl": "http://localhost:8000" 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics-ga-key/.env: -------------------------------------------------------------------------------- 1 | GA_KEY='google analytics code' 2 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/e.jsx: -------------------------------------------------------------------------------- 1 | export default { 2 | state: 0, 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/f.tsx: -------------------------------------------------------------------------------- 1 | export default { 2 | state: 0, 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/normal/src/app.js: -------------------------------------------------------------------------------- 1 | export function patchRoutes({ routes }) { 2 | } -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/.env: -------------------------------------------------------------------------------- 1 | PORT=8001 2 | BROWSER=none 3 | USE_REMOTE_IP=true 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/.env: -------------------------------------------------------------------------------- 1 | PORT=8003 2 | BROWSER=none 3 | USE_REMOTE_IP=true 4 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/.env: -------------------------------------------------------------------------------- 1 | PORT=8004 2 | BROWSER=none 3 | USE_REMOTE_IP=true 4 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/b.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | state: 0, 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/normal/c.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | state: 0, 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook1.js: -------------------------------------------------------------------------------- 1 | export default () => 'hook1'; 2 | -------------------------------------------------------------------------------- /example/typing.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.css'; 2 | declare module '*.less'; 3 | declare module '*.semver'; 4 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/normal/pages/index.tsx: -------------------------------------------------------------------------------- 1 | 2 | export default () =>

Foo

; 3 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/default/src/app.js: -------------------------------------------------------------------------------- 1 | export const getInitialState = () => {} 2 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/noEntry/src/app.js: -------------------------------------------------------------------------------- 1 | // export const getInitialState = () => {} 2 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/locale/sk.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": "test sk {name}" 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/example/pages/index.css: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | background: #79F2AA; 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/example/src/index.css: -------------------------------------------------------------------------------- 1 | .normal { 2 | height: 100%; 3 | padding: 80px; 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/public-path/pages/index.tsx: -------------------------------------------------------------------------------- 1 | 2 | export default () =>

Foo

; 3 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/n-ts-type-as.ts: -------------------------------------------------------------------------------- 1 | 2 | export default {}; 3 | -------------------------------------------------------------------------------- /packages/plugin-layout/src/types/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.less'; 2 | 3 | export * from './interface'; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/normal/src/locales/sk.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'sk {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/normal/src/locales/zh-CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: '你好 {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /example/pages/plugin-model.css: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(121, 207, 242); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | crossorigin: true, 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-helmet/src/templates/exports.tpl: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | export { Helmet } from '{{{ HelmetPkg }}}'; 3 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/n-tsx.tsx: -------------------------------------------------------------------------------- 1 | 2 | export default () =>

App

; 3 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/locale/sk.json: -------------------------------------------------------------------------------- 1 | { 2 | "test2": "test sk {name}" 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/normal/src/locales/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | name: 'Hello {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/locale/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test: 'test en {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/locale/zh-CN.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | test: '测试中文 {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/normal/src/app.js: -------------------------------------------------------------------------------- 1 | export const locale = { 2 | default: 'zh-CN', //默认语言 zh-CN 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/singular/src/app.js: -------------------------------------------------------------------------------- 1 | export const locale = { 2 | default: 'zh-CN', //默认语言 zh-CN 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-request/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | browserFiles: ['src/ui/index.ts', 'src/ui/noop.ts'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/plugin-layout/renderRightContent/index.js: -------------------------------------------------------------------------------- 1 | export default function renderRightContent() { 2 | return null; 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/models-for-extraModels/a_valid.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | namespace: 1, 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/models-for-extraModels/b_invalid.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | invalid: 1, 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/setInitialState/src/app.js: -------------------------------------------------------------------------------- 1 | export const getInitialState = () => 'hello world' 2 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/y-export-function.js: -------------------------------------------------------------------------------- 1 | 2 | export function getInitialState() {} 3 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/y-export-ts-as.ts: -------------------------------------------------------------------------------- 1 | 2 | export const getInitialState = {}; 3 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/app.js: -------------------------------------------------------------------------------- 1 | export const locale = { 2 | default: 'zh-CN', //默认语言 zh-CN 3 | }; 4 | -------------------------------------------------------------------------------- /example/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default function Index() { 4 | return
Home
; 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/example/utils/request.js: -------------------------------------------------------------------------------- 1 | import request from 'umi-request'; 2 | 3 | export default request; 4 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/y-export-const.js: -------------------------------------------------------------------------------- 1 | 2 | export const getInitialState = () => {}; 3 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/index.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | return
temp.
; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/locale/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test2: 'test en {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/locale/zh-CN.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | test2: '测试中文 {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook2.js: -------------------------------------------------------------------------------- 1 | const hook2 = () => 'hook2'; 2 | export default hook2; 3 | 4 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook6.js: -------------------------------------------------------------------------------- 1 | 2 | export default function () { 3 | return 'hook6'; 4 | }; 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/node_modules/** 2 | package.json 3 | 4 | # fixtures 5 | **/fixtures/** 6 | 7 | # templates 8 | **/templates/** 9 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/exports.tpl: -------------------------------------------------------------------------------- 1 | 2 | export { {{{ exportMethods }}} } from 'dva'; 3 | export { getApp as getDvaApp } from './dva'; 4 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/ssr/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () =>
Hello
4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/index.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | return
temp.
; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/locales/en_US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test2: 'test en {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/locales/sk.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test2: 'test sk {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/locales/zh_CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test2: '测试中文 {name}', 3 | }; 4 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/src/page/temp/model.js: -------------------------------------------------------------------------------- 1 | export default { 2 | namespace: 'temp', 3 | state: {}, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/normal/pages/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/pages/temp/model.js: -------------------------------------------------------------------------------- 1 | export default { 2 | namespace: 'temp', 3 | state: {}, 4 | }; 5 | -------------------------------------------------------------------------------- /packages/plugin-model/src/helpers/constant.tsx.tpl: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export const UmiContext = React.createContext({}); 4 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook3.js: -------------------------------------------------------------------------------- 1 | function hook3(){ 2 | return 'hook3'; 3 | }; 4 | export default hook3; 5 | -------------------------------------------------------------------------------- /packages/plugin-access/src/fixtures/normal/access.ts: -------------------------------------------------------------------------------- 1 | 2 | export default function() { 3 | return { 4 | canReadFoo: false, 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/lazyLoad/pages/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/normal/models/foo.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | state: { 4 | desc: 'foo', 5 | count: 0, 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/with-immer/pages/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/locales/sk.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test: 'test sk {name}', 3 | name: 'sk {name}', 4 | }; 5 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/locales/zh_CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test: '测试中文 {name}', 3 | name: '你好 {name}', 4 | }; 5 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/dva.js: -------------------------------------------------------------------------------- 1 | export default { 2 | state: {}, 3 | reducers: {}, 4 | effects: {}, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/pages/index.css: -------------------------------------------------------------------------------- 1 | .container { 2 | height: 100%; 3 | padding: 50px; 4 | background: white; 5 | } 6 | -------------------------------------------------------------------------------- /example/services/user.ts: -------------------------------------------------------------------------------- 1 | import { request } from 'umi'; 2 | 3 | export const fetchCurrentUser = () => { 4 | return request('/api/user'); 5 | }; 6 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics/pages/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/page-models/models/foo.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | state: { 4 | desc: 'foo', 5 | count: 0, 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/page-models/pages/home/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/src/locales/en_US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | test: 'test en {name}', 3 | name: 'Hello {name}', 4 | }; 5 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics-ga-key/pages/index.less: -------------------------------------------------------------------------------- 1 | 2 | .normal { 3 | } 4 | 5 | .title { 6 | background: rgb(196, 242, 121); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/default/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/noEntry/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/noExports/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/page-models/pages/home/models/bar.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | state: { 4 | desc: 'bar', 5 | count: 1, 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/default/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | 4 | export default function() { 5 | return null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/noEntry/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | 4 | export default function() { 5 | return null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/setInitialState/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/y-export-specifiers.js: -------------------------------------------------------------------------------- 1 | 2 | function getInitialState() { 3 | } 4 | 5 | export { getInitialState }; 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/services/request.js: -------------------------------------------------------------------------------- 1 | import { extend } from 'umi-request'; 2 | 3 | export default extend({ 4 | prefix: '/api/app1', 5 | }); 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/services/request.js: -------------------------------------------------------------------------------- 1 | import { extend } from 'umi-request'; 2 | 3 | export default extend({ 4 | prefix: '/api/app1', 5 | }); 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/services/request.js: -------------------------------------------------------------------------------- 1 | import { extend } from 'umi-request'; 2 | 3 | export default extend({ 4 | prefix: '/api/app3', 5 | }); 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/services/request.js: -------------------------------------------------------------------------------- 1 | import { extend } from 'umi-request'; 2 | 3 | export default extend({ 4 | prefix: '/api/app4', 5 | }); 6 | -------------------------------------------------------------------------------- /packages/preset-umi2-compatible/src/index.ts: -------------------------------------------------------------------------------- 1 | export default () => { 2 | return { 3 | plugins: [require.resolve('./plugins/router/router')], 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/noExports/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | 4 | export default function() { 5 | return null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/models/权限.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => { 4 | return 'this is 权限' 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/services/user.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | 3 | export async function query() { 4 | return request('/users'); 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/services/user.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | 3 | export async function query() { 4 | return request('/users'); 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/services/user.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | 3 | export async function query() { 4 | return request('/users'); 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/services/user.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | 3 | export async function query() { 4 | return request('/users'); 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/services/app.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | 3 | export async function query() { 4 | return request('/apps'); 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook5.js: -------------------------------------------------------------------------------- 1 | let hook5 = () => { 2 | const message = 'hook5' 3 | return message; 4 | }; 5 | export default hook5; 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/pages/index.js: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 |
4 |

Dashboard 2

5 |
6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/pages/index.js: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 |
4 |

Dashboard 3

5 |
6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/pages/index.js: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 |
4 |

Dashboard 4

5 |
6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/dvaTs.ts: -------------------------------------------------------------------------------- 1 | // typescript object 2 | export default { 3 | state: {}, 4 | reducers: {}, 5 | effects: {}, 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /coverage 2 | /packages/*/lib 3 | /packages/**/fixtures/**/dist 4 | node_modules 5 | .changelog 6 | .umi 7 | .umi-test 8 | .umi-production 9 | .DS_Store 10 | .idea 11 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/models/user-hook.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => { 4 | return 'this is user-hook' 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/app.js: -------------------------------------------------------------------------------- 1 | export const qiankun = { 2 | // 应用 render 之前触发 3 | async update(props) { 4 | console.log('app1 update', props); 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/services/request.js: -------------------------------------------------------------------------------- 1 | import { extend } from 'umi-request'; 2 | 3 | export default extend({ 4 | prefix: 'http://localhost:8000/api', 5 | }); 6 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | analytics: { 4 | ga:'google analytics code', 5 | baidu: '5a66cxxxxxxxxxx9e13', 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/y-export-tsx-with-jsx.tsx: -------------------------------------------------------------------------------- 1 | 2 | function App() { 3 | return

111

; 4 | } 5 | 6 | export const getInitialState = {}; 7 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/src/locales/zh-CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '标题', 3 | 'about.title': '关于标题', 4 | 'default.title': '默认标题', 5 | name: '你好 {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/singular/src/locale/zh-CN.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: '标题', 3 | 'about.title': '关于标题', 4 | 'default.title': '默认标题', 5 | name: '你好 {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/models/umi's hook.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => { 4 | return "this is umi's hook" 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/layouts/style.less: -------------------------------------------------------------------------------- 1 | .layout { 2 | height: 100%; 3 | } 4 | 5 | .sider { 6 | ul { 7 | background: rgba(243, 250, 240, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/layouts/style.less: -------------------------------------------------------------------------------- 1 | .layout { 2 | height: 100%; 3 | } 4 | 5 | .sider { 6 | ul { 7 | background: rgba(243, 250, 255, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/layouts/style.less: -------------------------------------------------------------------------------- 1 | .layout { 2 | height: 100%; 3 | } 4 | 5 | .sider { 6 | ul { 7 | background: rgba(243, 250, 240, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/layouts/style.less: -------------------------------------------------------------------------------- 1 | .layout { 2 | height: 100%; 3 | } 4 | 5 | .sider { 6 | ul { 7 | background: rgba(243, 250, 240, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-request/tests/mocks/antd.js: -------------------------------------------------------------------------------- 1 | export const message = { 2 | error: () => {}, 3 | warn: () => {}, 4 | }; 5 | 6 | export const notification = { 7 | open: () => {}, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics-ga-key/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | analytics: { 4 | // ga:'google analytics code', 5 | baidu: '5a66cxxxxxxxxxx9e13', 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/master/ErrorBoundary.tsx.tpl: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const ErrorBoundary = ({ error }: { error: any }) => ( 4 |
{error?.message}
5 | ); 6 | -------------------------------------------------------------------------------- /cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelDoNotExist/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId }) { 3 | expect(getByTestId('useModel').innerHTML).toEqual('useModel is: undefined'); 4 | } 5 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithError/models/name.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const data = {}; 5 | return { name: data.user.name }; 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/lazyLoad/models/foo.ts: -------------------------------------------------------------------------------- 1 | import { data } from '../utils' 2 | 3 | export default { 4 | state: { 5 | desc: 'foo', 6 | count: 0, 7 | data, 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app2", 3 | "scripts": { 4 | "start": "umi dev", 5 | "build": "COMPRESS=none umi build", 6 | "test": "umi test" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "dist", 3 | "rewrites": [ 4 | { 5 | "source": "/*", 6 | "destination": "/index.html" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /scripts/utils/isNextVersion.js: -------------------------------------------------------------------------------- 1 | module.exports = function (version) { 2 | return ( 3 | version.includes('-rc.') || 4 | version.includes('-beta.') || 5 | version.includes('-alpha.') 6 | ); 7 | }; 8 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/src/locales/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'Title', 3 | 'about.title': 'About Title', 4 | 'default.title': 'Default Title', 5 | name: 'Hello {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/src/locales/sk.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'skTitle', 3 | 'about.title': 'sk about Title', 4 | 'default.title': 'sk default Title', 5 | name: 'sk {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/singular/src/locale/en-US.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'Title', 3 | 'about.title': 'About Title', 4 | 'default.title': 'Default Title', 5 | name: 'Hello {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/singular/src/locale/sk.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: 'skTitle', 3 | 'about.title': 'sk about Title', 4 | 'default.title': 'sk default Title', 5 | name: 'sk {name}', 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/models/counter`hook-backup@1.0.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => { 4 | return 'this is counter`hook-backup@1.0' 5 | } 6 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "dist", 3 | "rewrites": [ 4 | { 5 | "source": "/app1/*", 6 | "destination": "/app1/index.html" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "dist", 3 | "rewrites": [ 4 | { 5 | "source": "/app2/*", 6 | "destination": "/app2/index.html" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/pages/$abc.js: -------------------------------------------------------------------------------- 1 | export default function (props) { 2 | const { abc } = props.match.params; 3 | return ( 4 |
5 |

{abc}

6 |
7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "dist", 3 | "rewrites": [ 4 | { 5 | "source": "/app3/*", 6 | "destination": "/app3/index.html" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/pages/$abc.js: -------------------------------------------------------------------------------- 1 | export default function (props) { 2 | const { abc } = props.match.params; 3 | return ( 4 |
5 |

{abc}

6 |
7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "public": "dist", 3 | "rewrites": [ 4 | { 5 | "source": "/app4/*", 6 | "destination": "/app4/index.html" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "master", 3 | "scripts": { 4 | "start": "umi dev", 5 | "build": "COMPRESS=none umi build", 6 | "test": "umi test" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-request/src/ui/noop.ts: -------------------------------------------------------------------------------- 1 | const noop = () => {}; 2 | 3 | export const message = { 4 | warn: noop, 5 | error: noop, 6 | }; 7 | 8 | export const notification = { 9 | open: noop, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/src/fixtures/public-path/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | publicPath: 'https://cdn.example.com/', 4 | crossorigin: { 5 | include: [/^https:\/\/.+\.example\.com/] 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | plugins: [ 7 | require.resolve('../../'), 8 | ], 9 | } 10 | -------------------------------------------------------------------------------- /example/models/bar.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default function () { 4 | const [count, setCount] = React.useState(0); 5 | return { 6 | description: count, 7 | setCount, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/page-models/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'home/index' }, 5 | ], 6 | plugins: [ 7 | require.resolve('../../'), 8 | ], 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/extraModel/extra/initialState.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [initialState] = useState('initialtest'); 5 | return { initialState }; 6 | }; 7 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true 4 | }, 5 | "paths": { 6 | "@": ["src/*"] 7 | }, 8 | "include": ["src/**/*"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/pages/app2/index.js: -------------------------------------------------------------------------------- 1 | import { MicroApp } from 'umi'; 2 | 3 | export default function () { 4 | return ( 5 |
6 | 7 |
8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/es5/src/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/no-es5/src/pages/index.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") 3 | } 4 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/models/hook4.js: -------------------------------------------------------------------------------- 1 | const dva = { 2 | state: {}, 3 | reducer: {}, 4 | effect: {}, 5 | }; 6 | 7 | function hook4 () { 8 | return dva.state.text || 'hook4'; 9 | }; 10 | export default hook4; 11 | -------------------------------------------------------------------------------- /packages/plugin-request/src/ui/index.ts: -------------------------------------------------------------------------------- 1 | import 'antd/es/message/style'; 2 | import message from 'antd/es/message'; 3 | import 'antd/es/notification/style'; 4 | import notification from 'antd/es/notification'; 5 | 6 | export { message, notification }; 7 | -------------------------------------------------------------------------------- /example/mock/user.js: -------------------------------------------------------------------------------- 1 | export default { 2 | '/api/user': { 3 | success: true, 4 | data: { 5 | name: 'yutingzhao1991', 6 | }, 7 | result: { 8 | name: 'name in result', 9 | }, 10 | name: 'name outside', 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/lazyLoad/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | dva: { 7 | lazyLoad: true, 8 | }, 9 | plugins: [ 10 | require.resolve('../../'), 11 | ], 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/with-immer/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index' }, 5 | ], 6 | dva: { 7 | immer: true, 8 | }, 9 | plugins: [ 10 | require.resolve('../../'), 11 | ], 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "CLEAR_CONSOLE=none umi dev" 4 | }, 5 | "devDependencies": { 6 | "umi": "latest" 7 | }, 8 | "dependencies": { 9 | "antd": "^3.7.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "CLEAR_CONSOLE=none umi dev" 4 | }, 5 | "devDependencies": { 6 | "umi": "latest" 7 | }, 8 | "dependencies": { 9 | "antd": "^3.7.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelDoNotExist/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | return (<> 6 |

{`useModel is: ${useModel}`}

7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "node ../node_modules/umi/bin/umi.js dev", 4 | "start": "node ../node_modules/umi/bin/umi.js dev", 5 | "build": "node ../node_modules/umi/bin/umi.js build" 6 | }, 7 | "dependencies": {} 8 | 9 | } 10 | -------------------------------------------------------------------------------- /example/pages/plugin-locale.css: -------------------------------------------------------------------------------- 1 | body, 2 | html, 3 | #root { 4 | height: 100%; 5 | margin: 0; 6 | } 7 | 8 | a { 9 | color: #1890ff; 10 | cursor: pointer; 11 | } 12 | 13 | .normal { 14 | background: #ddd; 15 | height: 100vh; 16 | padding: 48px; 17 | } 18 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithError/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId }) { 3 | console.error = jest.fn(); 4 | // expect(console.error).toHaveBeenCalledTimes(1); 5 | expect(getByTestId('count').innerHTML).toEqual('undefined'); 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-layout/src/layout/blankLayout.tsx: -------------------------------------------------------------------------------- 1 | export default ({ children }: { children: any }) => { 2 | console.error( 3 | '@umijs/plugin-layout 需要安装 @ant-design/pro-layout 才可运行', 4 | ); 5 | console.error('https://prolayout.ant.design/'); 6 | return children; 7 | }; 8 | -------------------------------------------------------------------------------- /scripts/utils/getPackages.js: -------------------------------------------------------------------------------- 1 | const { readdirSync } = require('fs'); 2 | const { join } = require('path'); 3 | 4 | module.exports = function getPackages() { 5 | return readdirSync(join(__dirname, '../../packages')).filter( 6 | (pkg) => pkg.charAt(0) !== '.', 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /example/access.ts: -------------------------------------------------------------------------------- 1 | import { InitialState } from 'umi'; 2 | 3 | export default function accessFactory(initialState: InitialState) { 4 | console.log('InitialState is:', initialState); 5 | return { 6 | readArticle: true, 7 | updateArticle: () => false, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/example/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.css'; 3 | 4 | export default function () { 5 | return ( 6 |
7 |

Page index

8 |
9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/example/.umirc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: [require.resolve('../lib')], 3 | blockDevtool: { 4 | menu: { 5 | name: 'demo', 6 | }, 7 | mockUmiRequest: true, // whether to build mock data . _mock.js \ _mock.ts 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/normal/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default () => { 4 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") 5 | } 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "proseWrap": "never", 6 | "overrides": [ 7 | { 8 | "files": ".prettierrc", 9 | "options": { 10 | "parser": "json" 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app1", 3 | "scripts": { 4 | "start": "umi dev", 5 | "build": "COMPRESS=none umi build", 6 | "test": "umi test" 7 | }, 8 | "devDependencies": { 9 | "source-map-loader": "^0.2.4" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app3", 3 | "scripts": { 4 | "start": "umi dev", 5 | "build": "COMPRESS=none umi build", 6 | "test": "umi test" 7 | }, 8 | "devDependencies": { 9 | "source-map-loader": "^0.2.4" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app4", 3 | "scripts": { 4 | "start": "umi dev", 5 | "build": "COMPRESS=none umi build", 6 | "test": "umi test" 7 | }, 8 | "devDependencies": { 9 | "source-map-loader": "^0.2.4" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-access/src/fixtures/normal/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const App = (props: any) => { 4 | return ( 5 |
6 |

unaccessible: {props.route.unaccessible?.toString()}

7 |
8 | ); 9 | }; 10 | 11 | export default App; 12 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | history: { 4 | type: 'memory', 5 | options: { 6 | initialEntries: ['/'], 7 | }, 8 | }, 9 | mountElementId: '', 10 | routes: [ 11 | { path: '/', component: 'index' }, 12 | ], 13 | } 14 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/extraModel/models/auth.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ role, setRole ] = useState('admin'); 5 | const switchRole = () => setRole(r => r === 'admin' ? 'user' : 'admin') 6 | return { role, switchRole }; 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithError/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const ret = useModel('name'); 6 | return (<> 7 |

{`${ret}`}

8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | runtimeHelpers: true, 3 | disableTypeCheck: false, 4 | browserFiles: [ 5 | 'src/master/runtimePlugin.ts', 6 | 'src/slave/lifecycles.ts', 7 | 'src/slave/runtimePlugin.ts', 8 | 'src/common.ts', 9 | ], 10 | }; 11 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/constants.ts: -------------------------------------------------------------------------------- 1 | export const defaultMasterRootId = 'root-master'; 2 | export const defaultHistoryType = 'browser'; 3 | export const qiankunStateForSlaveModelNamespace = '@@qiankunStateForSlave'; 4 | export const qiankunStateFromMasterModelNamespace = '@@qiankunStateFromMaster'; 5 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/multiple-ext/config/config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: [ 3 | require.resolve('../../../src/index'), 4 | ], 5 | locale: { 6 | baseNavigator: false, 7 | useLocalStorage: false, 8 | default: 'en-US', 9 | }, 10 | singular: true, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDependencies/models/auth.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ role, setRole ] = useState('admin'); 5 | const switchRole = () => setRole(r => r === 'admin' ? 'user' : 'admin') 6 | return { role, switchRole }; 7 | } 8 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/global.less: -------------------------------------------------------------------------------- 1 | body { 2 | overflow: hidden; 3 | } 4 | 5 | #root-master { 6 | height: 100%; 7 | } 8 | 9 | #root-slave { 10 | display: flex; 11 | flex: 1; 12 | overflow-y: auto; 13 | background: white; 14 | > div { 15 | flex: 1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/ssr/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | ssr: {}, 4 | history: { 5 | type: 'memory', 6 | options: { 7 | initialEntries: ['/'], 8 | }, 9 | }, 10 | mountElementId: '', 11 | routes: [ 12 | { path: '/', component: 'index' }, 13 | ], 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/utils/getExportContent.tsx: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | export default (modelPath: string) => ` 3 | // @ts-ignore 4 | import { InitialState as InitialStateType } from '../${modelPath}'; 5 | 6 | export type InitialState = InitialStateType; 7 | export const __PLUGIN_INITIAL_STATE = 1; 8 | `; 9 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | history: { 4 | type: 'memory', 5 | options: { 6 | initialEntries: ['/'], 7 | }, 8 | }, 9 | locale: {}, 10 | mountElementId: '', 11 | routes: [ 12 | { path: '/', component: 'index' }, 13 | ], 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/mock/user.js: -------------------------------------------------------------------------------- 1 | import mockjs from 'mockjs'; 2 | 3 | export default { 4 | 'GET /api/app1/users': mockjs.mock({ 5 | 'data|100': [ 6 | { 7 | 'id|+1': 1, 8 | name: '@cname', 9 | email: '@email', 10 | }, 11 | ], 12 | }), 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/mock/user.js: -------------------------------------------------------------------------------- 1 | import mockjs from 'mockjs'; 2 | 3 | export default { 4 | 'GET /api/app1/users': mockjs.mock({ 5 | 'data|100': [ 6 | { 7 | 'id|+1': 1, 8 | name: '@cname', 9 | email: '@email', 10 | }, 11 | ], 12 | }), 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/mock/user.js: -------------------------------------------------------------------------------- 1 | import mockjs from 'mockjs'; 2 | 3 | export default { 4 | 'GET /api/app3/users': mockjs.mock({ 5 | 'data|100': [ 6 | { 7 | 'id|+1': 1, 8 | name: '@cname', 9 | email: '@email', 10 | }, 11 | ], 12 | }), 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/mock/user.js: -------------------------------------------------------------------------------- 1 | import mockjs from 'mockjs'; 2 | 3 | export default { 4 | 'GET /api/app4/users': mockjs.mock({ 5 | 'data|100': [ 6 | { 7 | 'id|+1': 1, 8 | name: '@cname', 9 | email: '@email', 10 | }, 11 | ], 12 | }), 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-request/tests/mocks/umi/index.js: -------------------------------------------------------------------------------- 1 | exports.ApplyPluginsType = {}; 2 | 3 | exports.history = { 4 | push: (params) => { 5 | require('historyPush')(params); 6 | }, 7 | }; 8 | 9 | exports.plugin = { 10 | applyPlugins: () => { 11 | return require('runtimeConfig'); 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /example/pages/plugin-access.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useAccess } from 'umi'; 3 | 4 | export default () => { 5 | const access = useAccess(); 6 | 7 | if (access.readArticle) { 8 | return
you can read the article
; 9 | } 10 | return
no access
; 11 | }; 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /packages/plugin-model/src/runtime.tsx.tpl: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-dynamic-require */ 2 | import React from 'react'; 3 | import Provider from './Provider'; 4 | 5 | export function rootContainer(container: React.ReactNode) { 6 | return React.createElement( 7 | Provider, 8 | null, 9 | container, 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/defaultUsage/models/counter.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ counter, setCounter ] = useState(0); 5 | const increment = () => setCounter(c => c + 1); 6 | const decrement = () => setCounter(c => c - 1); 7 | return { counter, increment, decrement }; 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/with-immer/models/foo.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface IState { 3 | desc: string; 4 | count: number; 5 | } 6 | 7 | export default { 8 | state: { 9 | desc: 'foo', 10 | count: 0, 11 | } as IState, 12 | reducers: { 13 | add(state: IState) { 14 | state.count += 1; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/plugin-antd-dayjs/src/runtime.tpl: -------------------------------------------------------------------------------- 1 | import dayjs from '{{{dayjsPath}}}'; 2 | import antdPlugin from 'antd-dayjs-webpack-plugin/src/antd-plugin'; 3 | 4 | {{#plugins}} 5 | import {{.}} from '{{{dayjsPath}}}/plugin/{{.}}'; 6 | {{/plugins}} 7 | 8 | {{#plugins}} 9 | dayjs.extend({{.}}); 10 | {{/plugins}} 11 | 12 | dayjs.extend(antdPlugin); 13 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageModels/pages/user/models/counter.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ counter, setCounter ] = useState(0); 5 | const increment = () => setCounter(c => c + 1); 6 | const decrement = () => setCounter(c => c - 1); 7 | return { counter, increment, decrement }; 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageSingleModel/pages/user/counter.model.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ counter, setCounter ] = useState(0); 5 | const increment = () => setCounter(c => c + 1); 6 | const decrement = () => setCounter(c => c - 1); 7 | return { counter, increment, decrement }; 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/switchBackToInitialState/models/counter.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | export default () => { 4 | const [ counter, setCounter ] = useState(0); 5 | const increment = () => setCounter(c => c + 1); 6 | const decrement = () => setCounter(c => c - 1); 7 | return { counter, increment, decrement }; 8 | } 9 | -------------------------------------------------------------------------------- /packages/preset-react/src/defaultConfig.ts: -------------------------------------------------------------------------------- 1 | import { IApi, IConfig } from '@umijs/types'; 2 | 3 | export default (api: IApi) => { 4 | const defaultOptions = { 5 | access: {}, 6 | } as IConfig; 7 | 8 | api.modifyDefaultConfig((memo) => { 9 | return { 10 | ...defaultOptions, 11 | ...memo, 12 | }; 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /example/pages/plugin-no-access.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useAccess } from 'umi'; 3 | 4 | export default () => { 5 | const access = useAccess(); 6 | if (access.updateArticle()) { 7 | return
you can update the article
; 8 | } 9 | return
no access
; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/normal/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Helmet } from '../.umi-test/core/umiExports'; 3 | 4 | export default function() { 5 | return ( 6 |
7 |

Hello Helmet

8 | 9 | Title Helmet 10 | 11 |
12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /packages/plugin-access/src/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | routes: [ 4 | { path: '/', component: 'index', access: 'canReadFoo' }, 5 | ], 6 | plugins: [ 7 | require.resolve('../../'), 8 | require.resolve('@umijs/plugin-initial-state'), 9 | require.resolve('@umijs/plugin-model'), 10 | ], 11 | access: {} 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-access/src/utils/getRootContainerContent.ts: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return `\ 3 | import React from 'react'; 4 | import AccessProvider from './AccessProvider'; 5 | 6 | export function rootContainer(container: React.ReactNode, { routes }) { 7 | return React.createElement(AccessProvider, { routes }, container); 8 | } 9 | `; 10 | } 11 | -------------------------------------------------------------------------------- /packages/plugin-access/src/utils/getContextContent.ts: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return `\ 3 | import React from 'react'; 4 | import accessFactory from '@/access'; 5 | 6 | export type AccessInstance = ReturnType; 7 | 8 | const AccessContext = React.createContext(null!); 9 | 10 | export default AccessContext; 11 | `; 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/setInitialState/test.js: -------------------------------------------------------------------------------- 1 | export default async function ({ getByTestId, getByText, fireEvent, waitForDomChange }) { 2 | await waitForDomChange(); 3 | expect(getByTestId('content').innerHTML).toEqual('hello world'); 4 | fireEvent.click(getByText('set')); 5 | expect(getByTestId('content').innerHTML).toEqual('custom message'); 6 | } 7 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/example/.umirc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: [ 3 | '@umijs/plugin-blocks', 4 | require.resolve('../../plugin-ant-design-pro-block/lib'), 5 | ], 6 | antDesignProBlock: { 7 | modifyRequest: true, 8 | moveService: true, 9 | moveMock: true, 10 | moveService: true, 11 | autoAddMenu: true, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/normal/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | nodeModulesTransform: { 4 | type: 'none', 5 | }, 6 | history: { 7 | type: 'memory', 8 | options: { 9 | initialEntries: ['/'], 10 | }, 11 | }, 12 | mountElementId: '', 13 | routes: [ 14 | { path: '/', component: 'index' }, 15 | ], 16 | esbuild: {}, 17 | } 18 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDependencies/models/message.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { useModel } from '../.umi/useModel'; 3 | 4 | export default () => { 5 | // comments should be ignored 6 | // const message = useModel('message'); 7 | const { role } = useModel('auth'); 8 | return role === 'admin' ? 'Hello admin' : 'Hello user'; 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/ssr/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | nodeModulesTransform: { 4 | type: 'none', 5 | }, 6 | ssr: {}, 7 | history: { 8 | type: 'memory', 9 | options: { 10 | initialEntries: ['/'], 11 | }, 12 | }, 13 | mountElementId: '', 14 | routes: [ 15 | { path: '/', component: 'index' }, 16 | ], 17 | esbuild: {}, 18 | } 19 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/app.js: -------------------------------------------------------------------------------- 1 | export const qiankun = { 2 | // 应用加载之前 3 | async bootstrap(props) { 4 | console.log('app2 bootstrap', props); 5 | }, 6 | // 应用 render 之前触发 7 | async mount(props) { 8 | console.log('app2 mount', props); 9 | }, 10 | // 应用卸载之后触发 11 | async unmount(props) { 12 | console.log('app2 unmount', props); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/plugin-dva/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-dva 2 | 3 | > @umijs/plugin-dva. 4 | 5 | See our website [@umijs/plugin-dva](https://umijs.org/plugins/plugin-dva) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-dva 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-dva --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/runtime.tsx.tpl: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Provider from './Provider'; 3 | 4 | export function rootContainer(container: React.ReactNode) { 5 | return React.createElement( 6 | // 这里的 plugin-initial-state 不能从 constant 里取,里面有 path 依赖 7 | // 但 webpack-5 没有 node 补丁(包括 path) 8 | Provider, 9 | null, 10 | container, 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | history: { 4 | type: 'memory', 5 | options: { 6 | initialEntries: ['/'], 7 | }, 8 | }, 9 | locale: { 10 | useLocalStorage: false, 11 | antd: true, 12 | title: true, 13 | }, 14 | mountElementId: '', 15 | routes: [ 16 | { path: '/', component: 'index' }, 17 | ], 18 | } 19 | -------------------------------------------------------------------------------- /packages/plugin-access/tests/utils/getAccessContent.test.ts: -------------------------------------------------------------------------------- 1 | import getAccessContent from '../../src/utils/getAccessContent'; 2 | 3 | describe('getAccessContent', () => { 4 | it('should return content string when call getAccessContent', () => { 5 | const result = getAccessContent(); 6 | expect(typeof result).toBe('string'); 7 | expect(result.length).toBeGreaterThan(0); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/plugin-antd/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-antd 2 | 3 | > @umijs/plugin-antd. 4 | 5 | See our website [@umijs/plugin-antd](https://umijs.org/plugins/plugin-antd) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-antd 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-antd --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/normal/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export default connect(state => ({ 6 | foo: state.foo, 7 | }))((props) => { 8 | return ( 9 |
10 |

Page index { props.foo.desc } { props.foo.count }

11 |
12 | ); 13 | }) 14 | -------------------------------------------------------------------------------- /packages/plugin-helmet/fixtures/ssr/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Helmet } from '../.umi-test/core/umiExports'; 3 | 4 | export default function() { 5 | return ( 6 |
7 |

Hello Helmet

8 | 9 | 10 | Title Helmet 11 | 12 |
13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDependencies/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { switchRole } = useModel('auth'); 6 | const message = useModel('message'); 7 | return (<> 8 |

{message}

9 | 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-sass/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-sass 2 | 3 | > @umijs/plugin-sass. 4 | 5 | See our website [@umijs/plugin-sass](https://umijs.org/plugins/plugin-sass) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-sass 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-sass --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-test/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-test 2 | 3 | > @umijs/plugin-test. 4 | 5 | See our website [@umijs/plugin-test](https://umijs.org/plugins/plugin-test) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-test 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-test --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-access/tests/utils/getContextContent.test.ts: -------------------------------------------------------------------------------- 1 | import getContextContent from '../../src/utils/getContextContent'; 2 | 3 | describe('getContextContent', () => { 4 | it('should return content string when call getContextContent', () => { 5 | const result = getContextContent(); 6 | expect(typeof result).toBe('string'); 7 | expect(result.length).toBeGreaterThan(0); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/plugin-model/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-model 2 | 3 | > @umijs/plugin-model. 4 | 5 | See our website [@umijs/plugin-model](https://umijs.org/plugins/plugin-model) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-model 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-model --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/preset-react/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/preset-react 2 | 3 | > @umijs/preset-react. 4 | 5 | See our website [@umijs/preset-react](https://umijs.org/plugins/preset-react) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/preset-react 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/preset-react --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /example/pages/request/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useRequest } from 'umi'; 3 | import * as services from '../../services'; 4 | 5 | export default () => { 6 | const { data, loading } = useRequest(services.fetchCurrentUser); 7 | 8 | if (loading) { 9 | return
loading...
; 10 | } 11 | 12 | return
{data.name}
; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export default connect(state => ({ 6 | foo: state.foo, 7 | }))((props) => { 8 | return ( 9 |
10 |

Page index { props.foo.desc } { props.foo.count }

11 |
12 | ); 13 | }) 14 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/extraModel/models/message.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { useModel } from '../.umi/useModel'; 3 | 4 | export default () => { 5 | const { role } = useModel('auth'); 6 | const { initialState } = useModel('@@initialState'); 7 | return { 8 | initial: initialState, 9 | message: role === 'admin' ? 'Hello admin' : 'Hello user', 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /packages/plugin-analytics/src/fixtures/analytics-ga-key/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export default connect(state => ({ 6 | foo: state.foo, 7 | }))((props) => { 8 | return ( 9 |
10 |

Page index { props.foo.desc } { props.foo.count }

11 |
12 | ); 13 | }) 14 | -------------------------------------------------------------------------------- /packages/plugin-helmet/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-helmet 2 | 3 | > @umijs/plugin-ssr-helmet. 4 | 5 | See our website [@umijs/plugin-helmet](https://umijs.org/plugins/plugin-helmet) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-helmet 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-helmet --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-layout/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-layout 2 | 3 | > @umijs/plugin-layout. 4 | 5 | See our website [@umijs/plugin-layout](https://umijs.org/plugins/plugin-layout) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-layout 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-layout --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-locale/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-locale 2 | 3 | > @umijs/plugin-locale. 4 | 5 | See our website [@umijs/plugin-locale](https://umijs.org/plugins/plugin-locale) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-locale 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-locale --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/defaultUsage/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { counter, increment, decrement } = useModel('counter'); 6 | return (<> 7 |

{counter}

8 | 9 | 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-preact/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-preact 2 | 3 | > @umijs/plugin-preact. 4 | 5 | See our website [@umijs/plugin-preact](https://umijs.org/plugins/plugin-preact) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-preact 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-preact --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-stylus/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-stylus 2 | 3 | > @umijs/plugin-stylus. 4 | 5 | See our website [@umijs/plugin-stylus](https://umijs.org/plugins/plugin-stylus) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-stylus 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-stylus --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-esbuild 2 | 3 | > @umijs/plugin-esbuild. 4 | 5 | See our website [@umijs/plugin-esbuild](https://umijs.org/plugins/plugin-esbuild) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-esbuild 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-esbuild --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageModels/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { counter, increment, decrement } = useModel('user.counter'); 6 | return (<> 7 |

{counter}

8 | 9 | 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-openapi/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-openapi 2 | 3 | > @umijs/plugin-openapi. 4 | 5 | See our website [@umijs/plugin-openapi](https://umijs.org/plugins/plugin-openapi) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-openapi 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-openapi --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-request/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-request 2 | 3 | > @umijs/plugin-request. 4 | 5 | See our website [@umijs/plugin-request](https://umijs.org/plugins/plugin-request) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-request 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-request --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-access/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-access 2 | 3 | > Umi plugin for access management.. 4 | 5 | See our website [@umijs/plugin-access](https://umijs.org/plugins/plugin-access) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-access 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-access --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageSingleModel/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { counter, increment, decrement } = useModel('user.counter'); 6 | return (<> 7 |

{counter}

8 | 9 | 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/preset-umi2-compatible/src/plugins/router/router.ts: -------------------------------------------------------------------------------- 1 | import { IApi } from 'umi'; 2 | 3 | export default (api: IApi) => { 4 | api.addUmiExports(() => { 5 | return [ 6 | { 7 | source: require.resolve( 8 | '../../../src/plugins/router/historyAdapater.ts', 9 | ), 10 | specifiers: ['push', 'replace', 'go', 'goBack', 'goForward'], 11 | }, 12 | ]; 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/constants.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | 3 | export const DIR_NAME = 'plugin-initial-state'; 4 | export const MODEL_NAME = 'initialState'; 5 | export const RELATIVE_MODEL = join(DIR_NAME, 'models', MODEL_NAME); 6 | export const RELATIVE_MODEL_PATH = `${RELATIVE_MODEL}.ts`; 7 | export const RELATIVE_EXPORT = join(DIR_NAME, 'exports'); 8 | export const RELATIVE_EXPORT_PATH = `${RELATIVE_EXPORT}.ts`; 9 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/base-separator/config/config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | locale: { 3 | baseNavigator: false, 4 | antd: true, 5 | baseSeparator: '_', 6 | default: 'zh_CN', 7 | }, 8 | history: { 9 | type: 'memory', 10 | options: { 11 | initialEntries: ['/'], 12 | }, 13 | }, 14 | mountElementId: '', 15 | routes: [ 16 | { path: '/', component: 'index' }, 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "1.0.0", 4 | "description": "a example block", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "dev": "umi dev", 8 | "build": "umi build" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "umi": "^2.7.0" 14 | }, 15 | "dependencies": { 16 | "umi-request": "^1.0.7" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/lazyLoad/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export const data = {}; 6 | 7 | export default connect(state => ({ 8 | foo: state.foo, 9 | }))((props) => { 10 | return ( 11 |
12 |

Page index { props.foo.desc } { props.foo.count }

13 |
14 | ); 15 | }) 16 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDependencies/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent }) { 3 | expect(getByTestId('message').innerHTML).toEqual('Hello admin'); 4 | fireEvent.click(getByText('switch')); 5 | expect(getByTestId('message').innerHTML).toEqual('Hello user'); 6 | fireEvent.click(getByText('switch')); 7 | expect(getByTestId('message').innerHTML).toEqual('Hello admin'); 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/switchBackToInitialState/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { counter, increment, decrement } = useModel('counter', d => d); 6 | return (<> 7 |

{counter}

8 | 9 | 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/defaultUsage/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent }) { 3 | expect(getByTestId('count').innerHTML).toEqual('0'); 4 | fireEvent.click(getByText('add')); 5 | fireEvent.click(getByText('add')); 6 | expect(getByTestId('count').innerHTML).toEqual('2'); 7 | fireEvent.click(getByText('minus')); 8 | expect(getByTestId('count').innerHTML).toEqual('1'); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageModels/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent }) { 3 | expect(getByTestId('count').innerHTML).toEqual('0'); 4 | fireEvent.click(getByText('add')); 5 | fireEvent.click(getByText('add')); 6 | expect(getByTestId('count').innerHTML).toEqual('2'); 7 | fireEvent.click(getByText('minus')); 8 | expect(getByTestId('count').innerHTML).toEqual('1'); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/slave/qiankunModel.ts.tpl: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | 3 | let initState: any; 4 | let setModelState = (val: any) => { 5 | initState = val; 6 | }; 7 | 8 | export default () => { 9 | const [state, setState] = useState(initState); 10 | setModelState = (val: any) => { 11 | initState = val; 12 | setState(val); 13 | }; 14 | 15 | return state; 16 | }; 17 | 18 | export { setModelState }; 19 | -------------------------------------------------------------------------------- /packages/plugin-access/tests/utils/getRootContainerContent.test.ts: -------------------------------------------------------------------------------- 1 | import getRootContainerContent from '../../src/utils/getRootContainerContent'; 2 | 3 | describe('getRootContainerContent', () => { 4 | it('should return content string when call getRootContainerContent', () => { 5 | const result = getRootContainerContent(); 6 | expect(typeof result).toBe('string'); 7 | expect(result.length).toBeGreaterThan(0); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/pageSingleModel/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent }) { 3 | expect(getByTestId('count').innerHTML).toEqual('0'); 4 | fireEvent.click(getByText('add')); 5 | fireEvent.click(getByText('add')); 6 | expect(getByTestId('count').innerHTML).toEqual('2'); 7 | fireEvent.click(getByText('minus')); 8 | expect(getByTestId('count').innerHTML).toEqual('1'); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/master/AntdLoader.tsx.tpl: -------------------------------------------------------------------------------- 1 | import { Spin } from 'antd'; 2 | import React from 'react'; 3 | 4 | export default function AntdLoader(props: {loading: boolean}) { 5 | const { loading } = props; 6 | const style = { 7 | position: 'absolute', 8 | top: '50%', 9 | left: '50%', 10 | transform: 'translate(-50%, -50%)', 11 | } 12 | 13 | return ; 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-access/tests/utils/getAccessProviderContent.test.ts: -------------------------------------------------------------------------------- 1 | import getAccessProviderContent from '../../src/utils/getAccessProviderContent'; 2 | 3 | describe('getAccessProviderContent', () => { 4 | it('should return content string when call getAccessProviderContent', () => { 5 | const result = getAccessProviderContent(); 6 | expect(typeof result).toBe('string'); 7 | expect(result.length).toBeGreaterThan(0); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /packages/plugin-antd-mobile/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-antd-mobile 2 | 3 | > @umijs/plugin-antd-mobile. 4 | 5 | See our website [@umijs/plugin-antd-mobile](https://umijs.org/plugins/plugin-antd-mobile) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-antd-mobile 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-antd-mobile --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-crossorigin 2 | 3 | > @umijs/plugin-crossorigin. 4 | 5 | See our website [@umijs/plugin-crossorigin](https://umijs.org/plugins/plugin-crossorigin) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-crossorigin 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-crossorigin --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/es5/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | nodeModulesTransform: { 4 | type: 'none', 5 | }, 6 | targets: { 7 | ie: 11, 8 | }, 9 | history: { 10 | type: 'memory', 11 | options: { 12 | initialEntries: ['/'], 13 | }, 14 | }, 15 | mountElementId: '', 16 | routes: [ 17 | { path: '/', component: 'index' }, 18 | ], 19 | esbuild: { 20 | target: 'es5', 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-qiankun 2 | 3 | > umi plugin for [qiankun](https://qiankun.umijs.org/). 4 | 5 | See our website [@umijs/plugin-qiankun](https://v3.umijs.org/plugins/plugin-qiankun) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-qiankun 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-qiankun --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-analytics/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-analytics 2 | 3 | > analytics for baidu tongji and google analytics. 4 | 5 | See our website [@umijs/plugin-analytics](https://umijs.org/plugins/plugin-analytics) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-analytics 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-analytics --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-block-devtool 2 | 3 | > @umijs/plugin-block-devtool. 4 | 5 | See our website [@umijs/plugin-block-devtool](https://umijs.org/plugins/plugin-block-devtool) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-block-devtool 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-block-devtool --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-dev-externals/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-dev-externals 2 | 3 | > @umijs/plugin-dev-externals. 4 | 5 | See our website [@umijs/plugin-dev-externals](https://umijs.org/plugins/plugin-dev-externals) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-dev-externals 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-dev-externals --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/src/fixtures/no-es5/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | nodeModulesTransform: { 4 | type: 'none', 5 | }, 6 | targets: { 7 | ie: false, 8 | edge:15, 9 | chrome:51 10 | }, 11 | history: { 12 | type: 'memory', 13 | options: { 14 | initialEntries: ['/'], 15 | }, 16 | }, 17 | mountElementId: '', 18 | routes: [ 19 | { path: '/', component: 'index' }, 20 | ], 21 | esbuild: {}, 22 | } 23 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-initial-state 2 | 3 | > @umijs/plugin-initial-state. 4 | 5 | See our website [@umijs/plugin-initial-state](https://umijs.org/plugins/plugin-initial-state) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-initial-state 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-initial-state --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithSelector/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent, context }) { 3 | expect(getByTestId('user').innerHTML).toEqual('Troy is an adult'); 4 | expect(context.updateCount).toEqual(1); 5 | fireEvent.click(getByText(/changeGender/)); 6 | expect(context.updateCount).toEqual(1); 7 | fireEvent.click(getByText(/increaseAge/)); 8 | expect(context.updateCount).toEqual(2); 9 | } 10 | -------------------------------------------------------------------------------- /packages/plugin-stylus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | # 1.0.0-beta.2 (2021-10-11) 6 | 7 | ### Features 8 | 9 | - **stylus:** add package plugin-stylus. ([#716](https://github.com/umijs/plugins/issues/716)) ([bb81719](https://github.com/umijs/plugins/commit/bb817190a2f27afd3cec87ebd3598cfdb0ce7728)) 10 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/page-models/pages/home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export default connect(state => ({ 6 | foo: state.foo, 7 | bar: state.bar, 8 | }))((props) => { 9 | return ( 10 |
11 |

Page index { props.foo.desc } { props.foo.count } { props.bar.desc } { props.bar.count }

12 |
13 | ); 14 | }) 15 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/src/app.js: -------------------------------------------------------------------------------- 1 | 2 | import { history } from './.umi-test/core/history'; 3 | import queryString from 'query-string'; 4 | 5 | export const locale = { 6 | getLocale() { 7 | const { search } = window.location; 8 | const { locale = 'sk' } = queryString.parse(search); 9 | return locale; 10 | }, 11 | setLocale({ lang, realReload, updater }) { 12 | history.push(`/?locale=${lang}`); 13 | updater(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/preset-ant-design-pro/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/preset-ant-design-pro 2 | 3 | > @umijs/preset-ant-design-pro. 4 | 5 | See our website [@umijs/preset-ant-design-pro](https://umijs.org/plugins/preset-ant-design-pro) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/preset-ant-design-pro 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/preset-ant-design-pro --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent, context }) { 3 | expect(getByTestId('message1').innerHTML).toEqual('this is user-hook'); 4 | expect(getByTestId('message2').innerHTML).toEqual('this is 权限'); 5 | expect(getByTestId('message3').innerHTML).toEqual('this is counter`hook-backup@1.0'); 6 | expect(getByTestId('message4').innerHTML).toEqual('this is umi\'s hook'); 7 | } 8 | -------------------------------------------------------------------------------- /packages/preset-umi2-compatible/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/preset-umi2-compatible 2 | 3 | > @umijs/preset-umi2-compatible. 4 | 5 | See our website [@umijs/preset-umi2-compatible](https://umijs.org/plugins/preset-umi2-compatible) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/preset-umi2-compatible 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/preset-umi2-compatible --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/extraModel/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const { switchRole } = useModel('auth'); 6 | const { message, initial } = useModel('message'); 7 | return ( 8 | <> 9 |

{message}

10 |

{initial}

11 | 12 | 13 | ); 14 | }; 15 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/setInitialState/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel } from '../.umi-test/plugin-model/useModel'; 3 | 4 | export default function() { 5 | const { initialState ,setInitialState } = useModel('@@initialState') || {}; 6 | return ( 7 | <> 8 |
{initialState}
9 | 10 | 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /packages/plugin-antd-dayjs/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-antd-dayjs 2 | 3 | 用于在 umi 中代替 antd-dayjs-webpack-plugin. 4 | 5 | > @umijs/plugin-antd-dayjs 6 | 7 | See our website [@umijs/plugin-antd-dayjs](https://umijs.org/plugins/plugin-antd-dayjs) for more information. 8 | 9 | ## Install 10 | 11 | Using npm: 12 | 13 | ```bash 14 | $ npm install --save-dev @umijs/plugin-antd-dayjs 15 | ``` 16 | 17 | or using yarn: 18 | 19 | ```bash 20 | $ yarn add @umijs/plugin-antd-dayjs --dev 21 | ``` 22 | -------------------------------------------------------------------------------- /packages/plugin-layout/src/layoutExports.ts.tpl: -------------------------------------------------------------------------------- 1 | import { ProLayoutProps } from '@ant-design/pro-layout'; 2 | import { Models } from '@@/plugin-model/useModel'; 3 | 4 | export type RunTimeLayoutConfig = ( 5 | initData: Models<'@@initialState'>, 6 | ) => ProLayoutProps & { 7 | childrenRender?: (dom: JSX.Element, props: ProLayoutProps) => React.ReactNode, 8 | unAccessible?: JSX.Element, 9 | noFound?: JSX.Element, 10 | }; 11 | 12 | // avoid `export *` error 13 | export default {}; 14 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/singular/.umirc.ts: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | history: { 4 | type: 'memory', 5 | options: { 6 | initialEntries: ['/'], 7 | }, 8 | }, 9 | singular: true, 10 | title: 'default.title', 11 | locale: { 12 | baseNavigator: false, 13 | antd: true, 14 | title: true, 15 | default: 'zh-CN', 16 | }, 17 | mountElementId: '', 18 | routes: [ 19 | { path: '/', component: 'index', title: 'about.title' }, 20 | ], 21 | } 22 | -------------------------------------------------------------------------------- /packages/plugin-model/src/helpers/dispatcher.tsx.tpl: -------------------------------------------------------------------------------- 1 | export default class Dispatcher { 2 | callbacks = {}; 3 | 4 | data = {}; 5 | 6 | update = (namespace: string) => { 7 | (this.callbacks[namespace] || []).forEach( 8 | (callback: (val: any) => void) => { 9 | try { 10 | const data = this.data[namespace]; 11 | callback(data); 12 | } catch (e) { 13 | callback(undefined); 14 | } 15 | }, 16 | ); 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/extraModel/test.js: -------------------------------------------------------------------------------- 1 | export default async function({ getByTestId, getByText, fireEvent }) { 2 | expect(getByTestId('message').innerHTML).toEqual('Hello admin'); 3 | fireEvent.click(getByText('switch')); 4 | expect(getByTestId('message').innerHTML).toEqual('Hello user'); 5 | fireEvent.click(getByText('switch')); 6 | expect(getByTestId('message').innerHTML).toEqual('Hello admin'); 7 | expect(getByTestId('initial').innerHTML).toEqual('initialtest'); 8 | } 9 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/example/src/index.js: -------------------------------------------------------------------------------- 1 | import styles from './index.css'; 2 | 3 | import React from 'react'; 4 | 5 | const Welcome = () => ( 6 |
7 | Want to add more pages? Please refer to{' '} 8 | 13 | use block 14 | 15 |
16 | ); 17 | 18 | export default Welcome; 19 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugin-ant-design-pro-block 2 | 3 | > @umijs/plugin-ant-design-pro-block. 4 | 5 | See our website [@umijs/plugin-ant-design-pro-block](https://umijs.org/plugins/plugin-ant-design-pro-block) for more information. 6 | 7 | ## Install 8 | 9 | Using npm: 10 | 11 | ```bash 12 | $ npm install --save-dev @umijs/plugin-ant-design-pro-block 13 | ``` 14 | 15 | or using yarn: 16 | 17 | ```bash 18 | $ yarn add @umijs/plugin-ant-design-pro-block --dev 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/slave/connectMaster.tsx.tpl: -------------------------------------------------------------------------------- 1 | import { useModel } from 'umi'; 2 | import React from 'react'; 3 | import noop from 'lodash/noop'; 4 | 5 | const connectMaster = (Component: React.ComponentType) => { 6 | return (props: T, ...rest: any[]) => { 7 | const masterProps = (useModel || noop)('@@qiankunStateFromMaster') || {}; 8 | 9 | return ; 10 | }; 11 | }; 12 | 13 | export { 14 | connectMaster 15 | }; 16 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/.umirc.js: -------------------------------------------------------------------------------- 1 | import { name } from './package.json'; 2 | 3 | export default { 4 | base: name, 5 | publicPath: '/app2/', 6 | outputPath: './dist/app2', 7 | mountElementId: 'app2', 8 | qiankun: { 9 | slave: {}, 10 | }, 11 | plugins: [ 12 | require.resolve('../../../plugin-dva/lib'), 13 | require.resolve('../../../plugin-model/lib'), 14 | require.resolve('../../../plugin-antd/lib'), 15 | require.resolve('../../../plugin-qiankun/lib'), 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /packages/plugin-access/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { generateTmp, render } from '@umijs/test-utils'; 2 | import { join } from 'path'; 3 | import { cleanup } from '@testing-library/react'; 4 | 5 | const fixtures = join(__dirname, 'fixtures'); 6 | 7 | afterEach(cleanup); 8 | 9 | test('normal', async () => { 10 | const cwd = join(fixtures, 'normal'); 11 | await generateTmp({ cwd }); 12 | const { container } = render({ cwd }); 13 | expect(container.innerHTML).toEqual('

unaccessible: true

'); 14 | }); 15 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/layouts/style.less: -------------------------------------------------------------------------------- 1 | .layout { 2 | height: 100%; 3 | } 4 | 5 | .logo { 6 | float: left; 7 | width: 100px; 8 | height: 31px; 9 | margin: 16px 24px 0 0; 10 | color: white; 11 | line-height: 31px; 12 | text-align: center; 13 | background: #b6898933; 14 | } 15 | 16 | .content { 17 | display: flex; 18 | flex-direction: column; 19 | padding: 0 30px; 20 | } 21 | 22 | .breadcrumb { 23 | margin: 16px 0; 24 | } 25 | 26 | .footer { 27 | text-align: center; 28 | } 29 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/fixtures/with-immer/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styles from './index.less'; 3 | import { connect } from 'dva'; 4 | 5 | export default connect(state => ({ 6 | foo: state.foo, 7 | }))((props) => { 8 | return ( 9 |
10 |

Page index { props.foo.desc } { props.foo.count }

11 | 16 |
17 | ); 18 | }) 19 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transformIgnorePatterns: [ 3 | 'node_modules/(?!.*(@(babel)|dva-loading))[^/]+?/(?!(es|node_modules)/)', 4 | ], 5 | testMatch: ['**/packages/**/?*.(test|spec).(j|t)s?(x)'], 6 | moduleNameMapper(memo) { 7 | return Object.assign(memo, { 8 | '^react$': require.resolve('react'), 9 | '^react-dom$': require.resolve('react-dom'), 10 | '^@@/plugin-layout/renderRightContent$': require.resolve( 11 | './example/plugin-layout/renderRightContent', 12 | ), 13 | }); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /.github/workflows/outdated.yml: -------------------------------------------------------------------------------- 1 | name: Outdated Version Action 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | outdated-version: 9 | if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/version') 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: install 14 | run: yarn --ignore-engines 15 | - name: outdated version 16 | uses: ycjcl868/outdated-version-action@v1 17 | with: 18 | token: ${{ secrets.GITHUB_TOKEN }} 19 | -------------------------------------------------------------------------------- /packages/plugin-model/src/utils/getModels.ts: -------------------------------------------------------------------------------- 1 | import { utils } from 'umi'; 2 | import { getValidFiles } from '.'; 3 | 4 | export function getModels(cwd: string, pattern?: string) { 5 | const files = utils.glob 6 | .sync(pattern || '**/*.{ts,tsx,js,jsx}', { 7 | cwd, 8 | }) 9 | .filter( 10 | (file: string) => 11 | !file.endsWith('.d.ts') && 12 | !file.endsWith('.test.js') && 13 | !file.endsWith('.test.jsx') && 14 | !file.endsWith('.test.ts') && 15 | !file.endsWith('.test.tsx'), 16 | ); 17 | 18 | return getValidFiles(files, cwd); 19 | } 20 | -------------------------------------------------------------------------------- /example/pages/plugin-qiankun.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { MicroApp } from 'umi'; 3 | 4 | export default () => { 5 | return ( 6 | <> 7 |
Main
8 |
9 | 10 |
11 |
12 | 13 |
14 |
15 |
{e?.message}
} 19 | /> 20 |
21 | 22 | ); 23 | }; 24 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/fixtures/shouldPluginEnable/n-more-syntax.js: -------------------------------------------------------------------------------- 1 | 2 | // class property 3 | // decorators-legacy 4 | @m 5 | class A { 6 | foo = 'bar' 7 | } 8 | 9 | // dynamicImport 10 | import('./bar'); 11 | 12 | // exportDefaultFrom 13 | export default from './a'; 14 | 15 | // exportNamespaceFrom 16 | export { a } from './b' 17 | 18 | // functionBind 19 | a::b(); 20 | 21 | // nullishCoalescingOperator 22 | a ?? 'b'; 23 | 24 | // objectRestSpread 25 | const { g, ...h } = c; 26 | 27 | // optionalChaining 28 | a?.b(); 29 | 30 | // jsx 31 | function App() { 32 | return

App

; 33 | } 34 | -------------------------------------------------------------------------------- /packages/plugin-dev-externals/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | ## [1.0.1](https://github.com/umijs/plugins/compare/@umijs/plugin-dev-externals@1.0.0...@umijs/plugin-dev-externals@1.0.1) (2021-06-03) 6 | 7 | **Note:** Version bump only for package @umijs/plugin-dev-externals 8 | 9 | # 1.0.0 (2020-04-08) 10 | 11 | ### Features 12 | 13 | - add plugin-dev-externals ([71a1a9e](https://github.com/umijs/plugins/commit/71a1a9ea787f8cefa447fbdefae73a534d08eb30)) 14 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getModels/fixtures/jsx/a.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const A = () =>
123
4 | const AbcModel = { 5 | namespace: 'a', 6 | 7 | state: { 8 | name: '123', 9 | }, 10 | 11 | effects: { 12 | *query({ payload }, { call, put }) { 13 | yield put({ 14 | type: 'save', 15 | payload: { name: 'data.text' }, 16 | }); 17 | }, 18 | }, 19 | reducers: { 20 | save(state, action) { 21 | return { 22 | ...state, 23 | ...action.payload, 24 | }; 25 | }, 26 | }, 27 | }; 28 | 29 | export default AbcModel; 30 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/mock/app.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 'GET /api/apps': [ 3 | { 4 | name: 'app1', 5 | entry: 'http://localhost:8001/app1', 6 | to: '/app1', 7 | props: { 8 | testProp1: 'test1', 9 | }, 10 | }, 11 | { 12 | // name: 'app2', 13 | id: 'app2id', 14 | entry: 'http://localhost:8002/app2', 15 | to: '/app2', 16 | props: { 17 | testProp2: 'test2', 18 | }, 19 | }, 20 | { 21 | name: 'app3', 22 | entry: 'http://localhost:8003/app3', 23 | to: '/app3', 24 | }, 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /scripts/utils/exec.js: -------------------------------------------------------------------------------- 1 | const { spawn } = require('child_process'); 2 | 3 | module.exports = function exec(command, args, opts) { 4 | return new Promise((resolve, reject) => { 5 | const child = spawn(command, args, { 6 | stdio: 'inherit', 7 | shell: true, 8 | env: process.env, 9 | ...opts, 10 | }); 11 | child.once('error', (err) => { 12 | console.log(err); 13 | reject(err); 14 | }); 15 | child.once('close', (code) => { 16 | if (code === 1) { 17 | process.exit(1); 18 | } else { 19 | resolve(); 20 | } 21 | }); 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId }) { 3 | expect(getByTestId('dva').innerHTML).toEqual('undefined'); 4 | expect(getByTestId('hook1').innerHTML).toEqual('hook1'); 5 | expect(getByTestId('hook2').innerHTML).toEqual('hook2'); 6 | expect(getByTestId('hook3').innerHTML).toEqual('hook3'); 7 | expect(getByTestId('hook4').innerHTML).toEqual('hook4'); 8 | expect(getByTestId('hook5').innerHTML).toEqual('hook5'); 9 | expect(getByTestId('hook6').innerHTML).toEqual('hook6'); 10 | expect(getByTestId('hook7').innerHTML).toEqual('undefined'); 11 | } 12 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/specialCharactersInModelName/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const message1 = useModel('user-hook'); 6 | const message2 = useModel('权限'); 7 | const message3 = useModel('counter`hook-backup@1.0'); 8 | const message4 = useModel("umi's hook"); 9 | return (<> 10 |

{message1}

11 |

{message2}

12 |

{message3}

13 |

{message4}

14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "independent", 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "changelog": { 6 | "repo": "umijs/plugins", 7 | "labels": { 8 | "pr(enhancement)": ":rocket: Enhancement", 9 | "pr(bug)": ":bug: Bug Fix", 10 | "pr(documentation)": ":book: Documentation", 11 | "pr(dependency)": ":deciduous_tree: Dependency", 12 | "pr(chore)": ":turtle: Chore" 13 | }, 14 | "cacheDir": ".changelog" 15 | }, 16 | "ignoreChanges": [ 17 | "**/*.md", 18 | "**/*.test.ts", 19 | "**/*.e2e.ts", 20 | "**/fixtures/**", 21 | "**/test/**" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/models/user.js: -------------------------------------------------------------------------------- 1 | import { query } from '@/services/user'; 2 | 3 | export default { 4 | namespace: 'user', 5 | 6 | state: { 7 | list: [], 8 | }, 9 | 10 | effects: { 11 | *query(_, { put }) { 12 | const { data } = yield query(); 13 | yield put({ 14 | type: 'querySuccess', 15 | payload: { 16 | list: data, 17 | }, 18 | }); 19 | }, 20 | }, 21 | 22 | reducers: { 23 | querySuccess(state, { payload }) { 24 | return { 25 | ...state, 26 | list: payload.list, 27 | }; 28 | }, 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/models/user.js: -------------------------------------------------------------------------------- 1 | import { query } from '@/services/user'; 2 | 3 | // TODO 移动到 user/model.js 测试动态加载 dva model 的场景 4 | 5 | export default { 6 | namespace: 'user', 7 | 8 | state: { 9 | list: [], 10 | }, 11 | 12 | effects: { 13 | *query(_, { put }) { 14 | const { data } = yield query(); 15 | yield put({ 16 | type: 'querySuccess', 17 | payload: { 18 | list: data, 19 | }, 20 | }); 21 | }, 22 | }, 23 | 24 | reducers: { 25 | querySuccess(state, { payload }) { 26 | state.list = payload.list; 27 | }, 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/models/user.js: -------------------------------------------------------------------------------- 1 | import { query } from '@/services/user'; 2 | 3 | // TODO 移动到 user/model.js 测试动态加载 dva model 的场景 4 | 5 | export default { 6 | namespace: 'user', 7 | 8 | state: { 9 | list: [], 10 | }, 11 | 12 | effects: { 13 | *query(_, { put }) { 14 | const { data } = yield query(); 15 | yield put({ 16 | type: 'querySuccess', 17 | payload: { 18 | list: data, 19 | }, 20 | }); 21 | }, 22 | }, 23 | 24 | reducers: { 25 | querySuccess(state, { payload }) { 26 | state.list = payload.list; 27 | }, 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/pages/user/model.js: -------------------------------------------------------------------------------- 1 | import { query } from '@/services/user'; 2 | 3 | export default { 4 | namespace: 'user', 5 | 6 | state: { 7 | list: [], 8 | }, 9 | 10 | effects: { 11 | *query(_, { put }) { 12 | const { data } = yield query(); 13 | yield put({ 14 | type: 'querySuccess', 15 | payload: { 16 | list: data, 17 | }, 18 | }); 19 | }, 20 | }, 21 | 22 | reducers: { 23 | querySuccess(state, { payload }) { 24 | state.list = payload.list; 25 | return { 26 | ...state, 27 | }; 28 | }, 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - name: Use Node.js 11 | uses: actions/setup-node@v2 12 | with: 13 | node-version: 12.x 14 | - run: yarn --ignore-engines --frozen-lockfile --silent 15 | - run: yarn build 16 | - run: yarn run test:coverage 17 | env: 18 | CI: true 19 | PROGRESS: none 20 | NODE_ENV: test 21 | NODE_OPTIONS: --max_old_space_size=4096 22 | - run: bash <(curl -s https://codecov.io/bash) 23 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/.umirc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | base: '/app1Name', 3 | publicPath: '/app1/', 4 | outputPath: './dist/app1', 5 | mountElementId: 'app1', 6 | qiankun: { 7 | master: { 8 | apps: [ 9 | { 10 | name: 'app2', 11 | entry: 'http://localhost:8002/app2', 12 | }, 13 | ], 14 | }, 15 | slave: {}, 16 | }, 17 | plugins: [ 18 | require.resolve('../../../plugin-dva/lib'), 19 | require.resolve('../../../plugin-model/lib'), 20 | require.resolve('../../../plugin-antd/lib'), 21 | require.resolve('../../../plugin-qiankun/lib'), 22 | ], 23 | }; 24 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/switchBackToInitialState/test.js: -------------------------------------------------------------------------------- 1 | 2 | export default async function ({ getByTestId, getByText, fireEvent }) { 3 | expect(getByTestId('count').innerHTML).toEqual('0'); 4 | fireEvent.click(getByText('add')); 5 | fireEvent.click(getByText('add')); 6 | expect(getByTestId('count').innerHTML).toEqual('2'); 7 | fireEvent.click(getByText('minus')); 8 | expect(getByTestId('count').innerHTML).toEqual('1'); 9 | fireEvent.click(getByText('minus')); 10 | expect(getByTestId('count').innerHTML).toEqual('0'); 11 | fireEvent.click(getByText('minus')); 12 | expect(getByTestId('count').innerHTML).toEqual('-1'); 13 | } 14 | -------------------------------------------------------------------------------- /packages/preset-umi2-compatible/src/plugins/router/historyAdapater.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import { history } from '@@/core/history'; 3 | 4 | export function push(...args) { 5 | history.push(...args); 6 | } 7 | 8 | export function replace(...args) { 9 | history.replace(...args); 10 | } 11 | 12 | export function go(...args) { 13 | history.go(...args); 14 | } 15 | 16 | export function goBack(...args) { 17 | history.goBack(...args); 18 | } 19 | 20 | export function goForward(...args) { 21 | history.goForward(...args); 22 | } 23 | 24 | const router = { 25 | push, 26 | replace, 27 | go, 28 | goBack, 29 | goForward, 30 | }; 31 | 32 | export { router }; 33 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi } from 'umi'; 2 | 3 | export { isMasterEnable } from './master'; 4 | export { isSlaveEnable } from './slave'; 5 | 6 | export * from './types'; 7 | 8 | export default function (api: IApi) { 9 | api.addRuntimePluginKey(() => 'qiankun'); 10 | 11 | api.describe({ 12 | key: 'qiankun', 13 | config: { 14 | schema(joi) { 15 | return joi.object().keys({ 16 | slave: joi.object(), 17 | master: joi.object(), 18 | }); 19 | }, 20 | }, 21 | }); 22 | 23 | api.registerPlugins([ 24 | require.resolve('./master'), 25 | require.resolve('./slave'), 26 | ]); 27 | } 28 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/.umirc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | publicPath: '/app3/', 3 | outputPath: './dist/app3', 4 | mountElementId: 'app3', 5 | qiankun: { 6 | slave: {}, 7 | }, 8 | plugins: [ 9 | require.resolve('../../../plugin-model/lib'), 10 | require.resolve('../../../plugin-antd/lib'), 11 | require.resolve('../../../plugin-qiankun/lib'), 12 | ], 13 | // TODO 测试约定式路由 14 | routes: [ 15 | { path: '/', exact: true, component: './index.js' }, 16 | { path: '/:abc', component: './$abc.js' }, 17 | { path: '/users', component: './user/index.js' }, 18 | ], 19 | // TODO 测试 dynamicImport 20 | // dynamicImport: true, 21 | }; 22 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Kuitos 3 | * @since 2019-06-20 4 | */ 5 | declare module '@tmp/subAppsConfig.json'; 6 | 7 | declare module '@tmp/qiankunRootExports.js'; 8 | 9 | declare module '@@/plugin-qiankun/qiankunDefer.js' { 10 | const deferred: any; 11 | export { deferred }; 12 | } 13 | 14 | declare module '@@/plugin-qiankun/masterOptions' { 15 | export const getMasterOptions: () => any; 16 | export const setMasterOptions: (options: any) => void; 17 | } 18 | 19 | declare module '@@/plugin-qiankun/MicroAppLoader' { 20 | import { ReactNode } from 'react'; 21 | export default function Loader(props: { loading: boolean }): ReactNode; 22 | } 23 | -------------------------------------------------------------------------------- /.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import { readdirSync } from 'fs'; 2 | import { join } from 'path'; 3 | 4 | // utils must build before core 5 | // runtime must build before renderer-react 6 | const headPkgs: string[] = []; 7 | const tailPkgs = readdirSync(join(__dirname, 'packages')).filter( 8 | (pkg) => pkg.charAt(0) !== '.' && !headPkgs.includes(pkg), 9 | ); 10 | 11 | export default { 12 | target: 'node', 13 | cjs: { type: 'babel', lazy: true }, 14 | disableTypeCheck: true, 15 | pkgs: [...headPkgs, ...tailPkgs], 16 | extraBabelPlugins: [ 17 | [ 18 | 'babel-plugin-import', 19 | { libraryName: 'antd', libraryDirectory: 'es', style: true }, 20 | 'antd', 21 | ], 22 | ], 23 | }; 24 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | ## [1.0.1](https://github.com/umijs/plugins/compare/@umijs/plugin-ant-design-pro-block@1.0.0...@umijs/plugin-ant-design-pro-block@1.0.1) (2021-06-03) 6 | 7 | **Note:** Version bump only for package @umijs/plugin-ant-design-pro-block 8 | 9 | # 1.0.0 (2020-03-12) 10 | 11 | ### Features 12 | 13 | - ad plugin-ant-design-pro-block ([#43](https://github.com/umijs/plugins/issues/43)) ([fa0c79e](https://github.com/umijs/plugins/commit/fa0c79ea43a48312e504c75ac22ce323601d325c)) 14 | -------------------------------------------------------------------------------- /packages/plugin-sass/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | ## [1.1.1](https://github.com/umijs/plugins/compare/@umijs/plugin-sass@1.1.0...@umijs/plugin-sass@1.1.1) (2020-03-10) 6 | 7 | ### Bug Fixes 8 | 9 | - sass options missing, Close [#75](https://github.com/umijs/plugins/issues/75) ([dcf2160](https://github.com/umijs/plugins/commit/dcf21606e7762f5f8d31c1c975be12ffbb87be4e)) 10 | 11 | # 1.1.0 (2020-03-09) 12 | 13 | ### Features 14 | 15 | - add plugin-sass ([294a809](https://github.com/umijs/plugins/commit/294a80914ad8c092d32fe758de2bb359d39c6c5c)) 16 | -------------------------------------------------------------------------------- /packages/preset-ant-design-pro/src/chainWebpack.ts: -------------------------------------------------------------------------------- 1 | const webpackPlugin = (config: any) => { 2 | // optimize chunks 3 | config.merge({ 4 | optimization: { 5 | minimize: true, 6 | splitChunks: { 7 | chunks: 'all', 8 | minChunks: 2, 9 | automaticNameDelimiter: '.', 10 | cacheGroups: { 11 | vendor: { 12 | name: 'vendors', 13 | test({ resource }: { resource: string }) { 14 | return /[\\/]node_modules[\\/]/.test(resource); 15 | }, 16 | priority: 10, 17 | }, 18 | }, 19 | }, 20 | }, 21 | }); 22 | 23 | return config; 24 | }; 25 | 26 | export default webpackPlugin; 27 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/.umirc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | publicPath: '/app4/', 3 | outputPath: './dist/app4', 4 | mountElementId: 'app4', 5 | qiankun: { 6 | slave: { 7 | masterEntry: 'http://localhost:8000', 8 | }, 9 | }, 10 | plugins: [ 11 | require.resolve('../../../plugin-model/lib'), 12 | require.resolve('../../../plugin-antd/lib'), 13 | require.resolve('../../../plugin-qiankun/lib'), 14 | ], 15 | // TODO 测试约定式路由 16 | routes: [ 17 | { path: '/', exact: true, component: './index.js' }, 18 | { path: '/:abc', component: './$abc.js' }, 19 | { path: '/users', component: './user/index.js' }, 20 | ], 21 | // TODO 测试 dynamicImport 22 | // dynamicImport: true, 23 | }; 24 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/getUserLibDir.ts: -------------------------------------------------------------------------------- 1 | import { utils } from 'umi'; 2 | import { dirname } from 'path'; 3 | 4 | export function getUserLibDir({ 5 | library, 6 | pkg, 7 | cwd, 8 | }: { 9 | library: string; 10 | pkg: any; 11 | cwd: string; 12 | }) { 13 | if ( 14 | (pkg.dependencies && pkg.dependencies[library]) || 15 | (pkg.devDependencies && pkg.devDependencies[library]) 16 | ) { 17 | return utils.winPath( 18 | dirname( 19 | // 通过 resolve 往上找,可支持 lerna 仓库 20 | // lerna 仓库如果用 yarn workspace 的依赖不一定在 node_modules,可能被提到根目录,并且没有 link 21 | utils.resolve.sync(`${library}/package.json`, { 22 | basedir: cwd, 23 | }), 24 | ), 25 | ); 26 | } 27 | return null; 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "moduleResolution": "node", 5 | "jsx": "preserve", 6 | "allowJs": true, 7 | "esModuleInterop": true, 8 | "experimentalDecorators": true, 9 | "strict": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "noImplicitReturns": true, 12 | "suppressImplicitAnyIndexErrors": true, 13 | "declaration": true, 14 | "skipLibCheck": true, 15 | "paths": { 16 | "@@": ["./example/*"] 17 | } 18 | }, 19 | "exclude": [ 20 | "node_modules", 21 | "dist", 22 | "example", 23 | "jest.config.js", 24 | "**/*.spec.ts", 25 | "fixtures", 26 | "examples", 27 | "**/lib", 28 | "**/scripts" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands'; 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /packages/plugin-antd-dayjs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | # [0.3.0](https://github.com/umijs/plugins/compare/@umijs/plugin-antd-dayjs@0.2.0...@umijs/plugin-antd-dayjs@0.3.0) (2021-12-14) 6 | 7 | ### Features 8 | 9 | - access add Strict Mode ([#636](https://github.com/umijs/plugins/issues/636)) ([0a4954f](https://github.com/umijs/plugins/commit/0a4954f86c09d39735b30cc303889ee1a67020b2)) 10 | 11 | # 0.2.0 (2021-07-30) 12 | 13 | ### Features 14 | 15 | - add plugin dayjs ([#668](https://github.com/umijs/plugins/issues/668)) ([5385017](https://github.com/umijs/plugins/commit/53850174490503736b9540da1268fabcbf4ef75b)) 16 | -------------------------------------------------------------------------------- /packages/plugin-dva/src/runtime.tpl: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { _DvaContainer, getApp, _onCreate } from './dva'; 3 | 4 | export function rootContainer(container, opts) { 5 | return React.createElement(_DvaContainer, opts, container); 6 | } 7 | 8 | {{#SSR}} 9 | export const ssr = { 10 | modifyGetInitialPropsCtx: async (ctx) => { 11 | // 服务端执行早于 constructor 中的 onCreate 12 | if (process.env.__IS_SERVER && ctx.history) { 13 | const tmpApp = _onCreate({ 14 | // server 15 | history: ctx.history, 16 | }) 17 | tmpApp.router(() => {}) 18 | tmpApp.start(); 19 | ctx.app = tmpApp; 20 | } 21 | // 一定有 app 22 | const { _store } = getApp(); 23 | ctx.store = _store; 24 | return ctx; 25 | }, 26 | } 27 | {{/SSR}} 28 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithSelector/models/user.js: -------------------------------------------------------------------------------- 1 | import { useReducer } from 'react'; 2 | 3 | export default () => { 4 | function reducer(state, action) { 5 | switch (action.type) { 6 | case 'changeGender': 7 | return { 8 | ...state, 9 | gender: state.gender === 'male' ? 'female' : 'male', 10 | }; 11 | case 'setAge': 12 | return { 13 | ...state, 14 | age: action.payload, 15 | }; 16 | default: 17 | break; 18 | } 19 | } 20 | const [data, dispatch] = useReducer(reducer, { 21 | name: 'Troy', 22 | email: 'troy.lty@alipay.com', 23 | gender: 'male', 24 | height: '6\'2', 25 | age: 24, 26 | }); 27 | return [ 28 | data, 29 | dispatch, 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithSelector/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default (props) => { 5 | const { isAdult, name, dispatch } = useModel( 6 | 'user', 7 | user => ({ name: user[0].name, isAdult: user[0].age > 18, dispatch: user[1] }), 8 | ); 9 | useEffect(() => { 10 | props.onUpdate(); 11 | }); 12 | return (<> 13 |

{name} is {isAdult ? 'an adult' : 'a teen'}

14 | 19 | 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /packages/plugin-preact/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi } from 'umi'; 2 | import { dirname, join } from 'path'; 3 | 4 | export default (api: IApi) => { 5 | api.chainWebpack((memo) => { 6 | memo.resolve.alias 7 | .set('preact/devtools', require.resolve('preact/devtools')) 8 | .set('preact/hooks', require.resolve('preact/hooks')) 9 | .set('preact', require.resolve('preact')) 10 | .set('react', dirname(require.resolve('preact/compat/package.json'))) 11 | .set('react-dom', dirname(require.resolve('preact/compat/package.json'))); 12 | return memo; 13 | }); 14 | 15 | api.addEntryImports(() => { 16 | return process.env.NODE_ENV === 'development' 17 | ? [ 18 | { 19 | source: 'preact/devtools', 20 | }, 21 | ] 22 | : []; 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "moduleResolution": "node", 5 | "declaration": true, 6 | "jsx": "react", 7 | "rootDir": "./src", 8 | "downlevelIteration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "resolveJsonModule": true, 13 | "strictFunctionTypes": true, 14 | "strictPropertyInitialization": true, 15 | "noImplicitThis": true, 16 | "alwaysStrict": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "noImplicitReturns": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "allowSyntheticDefaultImports": true, 22 | "esModuleInterop": true, 23 | "typeRoots": ["./typings"], 24 | "skipLibCheck": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | node_version: [10.x, 12.x] 11 | os: [ubuntu-latest, macos-latest, windows-latest] 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: '1' 16 | - name: Use Node.js ${{ matrix.node_version }} 17 | uses: actions/setup-node@v2 18 | with: 19 | node-version: ${{ matrix.node_version }} 20 | registry-url: 'https://registry.yarnpkg.com' 21 | - run: yarn --ignore-engines 22 | - run: yarn build 23 | - run: yarn test --forceExit 24 | env: 25 | CI: true 26 | HEADLESS: false 27 | PROGRESS: none 28 | NODE_ENV: test 29 | -------------------------------------------------------------------------------- /packages/plugin-stylus/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-stylus", 3 | "version": "1.0.0-beta.2", 4 | "description": "@umijs/plugin-stylus", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "richard (https://github.com/richardo2016)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-stylus#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-crossorigin", 3 | "version": "1.2.1", 4 | "description": "@umijs/plugin-crossorigin", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-crossorigin#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/plugin-access/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | 3 | export function getScriptPath(filepath: string): string { 4 | let realFilePath: string = ''; 5 | if (fs.existsSync(`${filepath}.ts`)) { 6 | realFilePath = `${filepath}.ts`; 7 | } else if (fs.existsSync(`${filepath}.js`)) { 8 | realFilePath = `${filepath}.js`; 9 | } 10 | return realFilePath; 11 | } 12 | 13 | export function checkIfHasDefaultExporting(filepath: string): boolean { 14 | const scriptPath = getScriptPath(filepath); 15 | if (!scriptPath) { 16 | return false; 17 | } 18 | 19 | const fileContent = fs.readFileSync(scriptPath, 'utf8'); 20 | const validationRegExp = 21 | /(export\s*default)|(exports\.default)|(module.exports[\s\S]*default)|(module.exports[\s\n]*=)/m; 22 | 23 | return validationRegExp.test(fileContent); 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @umijs/plugins 2 | 3 | [![codecov](https://codecov.io/gh/umijs/plugins/branch/master/graph/badge.svg)](https://codecov.io/gh/umijs/plugins) [![GitHub Actions status](https://github.com/umijs/plugins/workflows/Node%20CI/badge.svg)](https://github.com/umijs/plugins) 4 | 5 | Official umi plugins and presets. 6 | 7 | ## Plugins 8 | 9 | [plugins list](https://umijs.org/plugins/preset-react) 10 | 11 | - plugin-access,权限管理 12 | - plugin-analytics,统计管理 13 | - plugin-antd,整合 antd UI 组件 14 | - plugin-crossorigin,通常用于 JS 出错统计 15 | - plugin-dva,整合 dva 16 | - plugin-helmet,整合 react-helmet,管理 HTML 文档标签(如标题、描述等) 17 | - plugin-initial-state,初始化数据管理 18 | - plugin-layout,配置启用 ant-design-pro 的布局 19 | - plugin-locale,国际化能力 20 | - plugin-model,基于 hooks 的简易数据流 21 | - plugin-request,基于 umi-request 和 umi-hooks 的请求方案 22 | 23 | ## LICENSE 24 | 25 | MIT 26 | -------------------------------------------------------------------------------- /packages/plugin-dev-externals/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-dev-externals", 3 | "version": "1.0.1", 4 | "description": "@umijs/plugin-dev-externals", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-dev-externals#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/app.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import request from './services/request'; 3 | 4 | export const qiankun = request('/apps').then((apps) => ({ 5 | apps, 6 | routes: [ 7 | { 8 | path: '/app1', 9 | microApp: 'app1', 10 | microAppProps: { 11 | autoSetLoading: true, 12 | className: 'appClassName', 13 | wrapperClassName: 'wrapperClass', 14 | loader: (loading) => { 15 | return loading ?
runtime loading
: null; 16 | }, 17 | }, 18 | }, 19 | ], 20 | })); 21 | 22 | export const useQiankunStateForSlave = () => { 23 | const [globalState, setQiankunGlobalState] = useState({ 24 | slogan: 'Hello MicroFrontend', 25 | }); 26 | 27 | return { 28 | globalState, 29 | setQiankunGlobalState, 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /packages/preset-umi2-compatible/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/preset-umi2-compatible", 3 | "version": "0.1.2", 4 | "description": "@umijs/preset-umi2-compatible", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/preset-umi2-compatible#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/pages/plugin-model.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel, history } from 'umi'; 3 | import styles from './plugin-model.css'; 4 | 5 | export default () => { 6 | const { description: bar, setCount } = useModel('bar'); 7 | // const setCount = useModel('bar', c => c.setCount); 8 | return ( 9 |
10 |

11 | Page plugin-model {bar} 12 |

13 | 16 | 25 |
26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /packages/plugin-analytics/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-analytics", 3 | "version": "0.2.4", 4 | "description": "analytics for baidu tongji and google analytics", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "xiaohuoni (https://github.com/xiaohuoni)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-analytics#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /// 2 | // *********************************************************** 3 | // This example plugins/index.js can be used to load plugins 4 | // 5 | // You can change the location of this file or turn off loading 6 | // the plugins file with the 'pluginsFile' configuration option. 7 | // 8 | // You can read more here: 9 | // https://on.cypress.io/plugins-guide 10 | // *********************************************************** 11 | 12 | // This function is called when a project is opened or re-opened (e.g. due to 13 | // the project's config changing) 14 | 15 | /** 16 | * @type {Cypress.PluginConfig} 17 | */ 18 | // eslint-disable-next-line no-unused-vars 19 | module.exports = (on, config) => { 20 | // `on` is used to hook into various events Cypress emits 21 | // `config` is the resolved Cypress config 22 | }; 23 | -------------------------------------------------------------------------------- /packages/plugin-locale/src/templates/runtime.tpl: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | // @ts-ignore 3 | import { _LocaleContainer } from './locale'; 4 | import { getIntl, getLocale } from './localeExports'; 5 | 6 | export function rootContainer(container: Element) { 7 | return React.createElement(_LocaleContainer, null, container); 8 | } 9 | 10 | {{#Title}} 11 | export function patchRoutes({ routes }) { 12 | // loop all route for patch title field 13 | const intl = getIntl(getLocale()); 14 | const traverseRoute = (routes) => { 15 | routes.forEach(route => { 16 | if (route.title) { 17 | route.title = intl.messages[route.title] ? intl.formatMessage({ id: route.title }, {}) : route.title; 18 | } 19 | if (route.routes) { 20 | traverseRoute(route.routes); 21 | } 22 | }) 23 | } 24 | traverseRoute(routes); 25 | } 26 | {{/Title}} 27 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-initial-state", 3 | "version": "2.4.0", 4 | "description": "@umijs/plugin-initial-state", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "Troy Li ", 20 | "chencheng (https://github.com/sorrycc)" 21 | ], 22 | "license": "MIT", 23 | "bugs": "http://github.com/umijs/plugins/issues", 24 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-initial-state#readme", 25 | "peerDependencies": { 26 | "umi": "3.x" 27 | }, 28 | "publishConfig": { 29 | "access": "public" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/plugin-preact/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-preact", 3 | "version": "1.0.2", 4 | "description": "@umijs/plugin-preact", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-preact#readme", 24 | "dependencies": { 25 | "preact": "^10.5.7" 26 | }, 27 | "peerDependencies": { 28 | "umi": "3.x" 29 | }, 30 | "publishConfig": { 31 | "access": "public" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/plugin-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-test", 3 | "version": "1.0.2", 4 | "description": "@umijs/plugin-test", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-test#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@umijs/test": "~3.5.14" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/preset-react/src/index.ts: -------------------------------------------------------------------------------- 1 | export default () => { 2 | return { 3 | plugins: [ 4 | require.resolve('./react'), 5 | require.resolve('@umijs/plugin-access'), 6 | require.resolve('@umijs/plugin-analytics'), 7 | require.resolve('@umijs/plugin-antd'), 8 | require.resolve('@umijs/plugin-antd-mobile'), 9 | require.resolve('@umijs/plugin-crossorigin'), 10 | require.resolve('@umijs/plugin-dva'), 11 | require.resolve('@umijs/plugin-initial-state'), 12 | require.resolve('@umijs/plugin-locale'), 13 | require.resolve('@umijs/plugin-layout'), 14 | require.resolve('@umijs/plugin-model'), 15 | require.resolve('@umijs/plugin-request'), 16 | require.resolve('@umijs/plugin-test'), 17 | require.resolve('@umijs/plugin-helmet'), 18 | require.resolve('./defaultConfig'), 19 | ], 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /packages/plugin-access/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-access", 3 | "version": "2.5.1", 4 | "description": "Umi plugin for access management.", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "James Tsang " 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-access#readme", 24 | "peerDependencies": { 25 | "@umijs/plugin-initial-state": "2.x", 26 | "@umijs/plugin-model": "2.x", 27 | "umi": "3.x" 28 | }, 29 | "publishConfig": { 30 | "access": "public" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/plugin-esbuild/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-esbuild", 3 | "version": "1.4.2", 4 | "description": "@umijs/plugin-esbuild", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-esbuild#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "esbuild-loader": "~2.9.2" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/plugin-antd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-antd", 3 | "version": "0.15.2", 4 | "description": "@umijs/plugin-antd", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-antd#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "antd": "^4.1.3", 32 | "semver": "^7.3.5" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-sass/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-sass", 3 | "version": "1.1.1", 4 | "description": "@umijs/plugin-sass", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-sass#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "sass": "^1.26.2", 32 | "sass-loader": "^8.0.2" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-sass/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi, utils } from 'umi'; 2 | 3 | export default (api: IApi) => { 4 | api.describe({ 5 | config: { 6 | schema(Joi) { 7 | return Joi.object({ 8 | implementation: Joi.any(), 9 | sassOptions: Joi.object(), 10 | prependData: Joi.alternatives(Joi.string(), Joi.func()), 11 | sourceMap: Joi.boolean(), 12 | webpackImporter: Joi.boolean(), 13 | }); 14 | }, 15 | }, 16 | }); 17 | 18 | api.chainWebpack((memo, { createCSSRule }) => { 19 | createCSSRule({ 20 | lang: 'sass', 21 | test: /\.(sass|scss)(\?.*)?$/, 22 | loader: require.resolve('sass-loader'), 23 | options: utils.deepmerge( 24 | { 25 | implementation: require('sass'), 26 | }, 27 | api.config.sass || {}, 28 | ), 29 | }); 30 | return memo; 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /packages/plugin-model/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-model", 3 | "version": "2.6.2", 4 | "description": "@umijs/plugin-model", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "Troy Li ", 20 | "chencheng (https://github.com/sorrycc)" 21 | ], 22 | "license": "MIT", 23 | "bugs": "http://github.com/umijs/plugins/issues", 24 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-model#readme", 25 | "peerDependencies": { 26 | "umi": "3.x" 27 | }, 28 | "publishConfig": { 29 | "access": "public" 30 | }, 31 | "dependencies": { 32 | "fast-deep-equal": "3.1.1" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-helmet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-helmet", 3 | "version": "1.1.4", 4 | "description": "@umijs/plugin-helmet", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "ycjcl868 <45808948@qq.com> (https://github.com/ycjcl868)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-helmet#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@types/react-helmet": "^6.1.0", 32 | "react-helmet": "^6.1.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-ant-design-pro-block/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-ant-design-pro-block", 3 | "version": "1.0.1", 4 | "description": "@umijs/plugin-ant-design-pro-block", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "yutingzhao1991 (https://github.com/yutingzhao1991)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-ant-design-pro-block#readme", 24 | "peerDependencies": { 25 | "@umijs/plugin-blocks": "2.x", 26 | "umi": "3.x" 27 | }, 28 | "publishConfig": { 29 | "access": "public" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/fixtures/modelWithDva/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { useModel } from './.umi/useModel'; 3 | 4 | export default () => { 5 | const dva = useModel('dva'); 6 | const hook1 = useModel('hook1'); 7 | const hook2 = useModel('hook2'); 8 | const hook3 = useModel('hook3'); 9 | const hook4 = useModel('hook4'); 10 | const hook5 = useModel('hook5'); 11 | const hook6 = useModel('hook6'); 12 | const hook7 = useModel('hook7'); 13 | 14 | return (<> 15 |

{`${dva}`}

16 |

{`${hook1}`}

17 |

{`${hook2}`}

18 |

{`${hook3}`}

19 |

{`${hook4}`}

20 |

{`${hook5}`}

21 |

{`${hook6}`}

22 |

{`${hook7}`}

23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/models/base.js: -------------------------------------------------------------------------------- 1 | import { query } from '@/services/app'; 2 | 3 | function sleep(ms) { 4 | return new Promise((resolve) => setTimeout(resolve, ms)); 5 | } 6 | 7 | export default { 8 | namespace: 'base', 9 | 10 | state: { 11 | name: 'Qiankun', 12 | apps: [], 13 | }, 14 | 15 | effects: { 16 | *getApps(_, { put }) { 17 | /* 18 | 子应用配置信息获取分同步、异步两种方式 19 | 同步有两种配置方式,1、app.js导出qiankun对象,2、配置写在umi配置文件中,可通过import @tmp/subAppsConfig获取 20 | */ 21 | yield sleep(1000); 22 | 23 | const apps = yield query(); 24 | yield put({ 25 | type: 'getAppsSuccess', 26 | payload: { 27 | apps, 28 | }, 29 | }); 30 | }, 31 | }, 32 | 33 | reducers: { 34 | getAppsSuccess(state, { payload }) { 35 | return { 36 | ...state, 37 | apps: payload.apps, 38 | }; 39 | }, 40 | }, 41 | }; 42 | -------------------------------------------------------------------------------- /packages/plugin-antd-dayjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-antd-dayjs", 3 | "version": "0.3.0", 4 | "description": "@umijs/plugin-antd-dayjs", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-antd-dayjs#readme", 24 | "peerDependencies": { 25 | "dayjs": "*", 26 | "umi": "3.x" 27 | }, 28 | "publishConfig": { 29 | "access": "public" 30 | }, 31 | "devDependencies": { 32 | "antd-dayjs-webpack-plugin": "^1.0.6" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/utils/shouldPluginEnable.test.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | import { shouldPluginEnable as s } from './shouldPluginEnable'; 3 | 4 | const fixture = join(__dirname, '..', 'fixtures', 'shouldPluginEnable'); 5 | 6 | test('should not enable', () => { 7 | expect(s(join(fixture, 'n-empty.js'))).toEqual(false); 8 | expect(s(join(fixture, 'n-more-syntax.js'))).toEqual(false); 9 | expect(s(join(fixture, 'n-ts-type-as.ts'))).toEqual(false); 10 | expect(s(join(fixture, 'n-tsx.tsx'))).toEqual(false); 11 | }); 12 | 13 | test('should enable', () => { 14 | expect(s(join(fixture, 'y-export-specifiers.js'))).toEqual(true); 15 | expect(s(join(fixture, 'y-export-const.js'))).toEqual(true); 16 | expect(s(join(fixture, 'y-export-function.js'))).toEqual(true); 17 | expect(s(join(fixture, 'y-export-ts-as.ts'))).toEqual(true); 18 | expect(s(join(fixture, 'y-export-tsx-with-jsx.tsx'))).toEqual(true); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/plugin-request/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-request", 3 | "version": "2.9.0", 4 | "description": "@umijs/plugin-request", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "yutingzhao1991 (https://github.com/yutingzhao1991)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-request#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@ahooksjs/use-request": "^2.8.0", 32 | "umi-request": "^1.2.14" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/plugin-stylus/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi, utils } from 'umi'; 2 | 3 | export default (api: IApi) => { 4 | api.describe({ 5 | config: { 6 | schema(Joi) { 7 | return Joi.object({ 8 | stylusOptions: Joi.object(), 9 | sourceMap: Joi.boolean(), 10 | webpackImporter: Joi.boolean(), 11 | additionalData: Joi.alternatives(Joi.string(), Joi.func()), 12 | implementation: Joi.alternatives(Joi.string(), Joi.func()), 13 | }); 14 | }, 15 | }, 16 | }); 17 | 18 | api.chainWebpack((memo, { createCSSRule }) => { 19 | createCSSRule({ 20 | lang: 'stylus', 21 | test: /\.styl(us)?$/, 22 | loader: require.resolve('stylus-loader'), 23 | options: utils.deepmerge( 24 | { 25 | implementation: require('stylus'), 26 | }, 27 | api.config.stylus || {}, 28 | ), 29 | }); 30 | return memo; 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/pages/user/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Table } from 'antd'; 3 | import { connect } from 'dva'; 4 | 5 | @connect(({ user }) => ({ user })) 6 | export default class extends React.PureComponent { 7 | constructor(props) { 8 | super(props); 9 | const { dispatch } = props; 10 | dispatch({ 11 | type: 'user/query', 12 | }); 13 | } 14 | 15 | render() { 16 | const { user } = this.props; 17 | const { list } = user; 18 | const columns = [ 19 | { 20 | dataIndex: 'id', 21 | title: 'ID', 22 | }, 23 | { 24 | dataIndex: 'name', 25 | title: 'Name', 26 | }, 27 | { 28 | dataIndex: 'email', 29 | title: 'Email', 30 | }, 31 | ]; 32 | 33 | return ( 34 |
35 | 36 | 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/pages/user/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Table } from 'antd'; 3 | import { connect } from 'dva'; 4 | 5 | @connect(({ user }) => ({ user })) 6 | export default class extends React.PureComponent { 7 | constructor(props) { 8 | super(props); 9 | const { dispatch } = props; 10 | dispatch({ 11 | type: 'user/query', 12 | }); 13 | } 14 | 15 | render() { 16 | const { user } = this.props; 17 | const { list } = user; 18 | const columns = [ 19 | { 20 | dataIndex: 'id', 21 | title: 'ID', 22 | }, 23 | { 24 | dataIndex: 'name', 25 | title: 'Name', 26 | }, 27 | { 28 | dataIndex: 'email', 29 | title: 'Email', 30 | }, 31 | ]; 32 | 33 | return ( 34 |
35 |
36 | 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/pages/user/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Table } from 'antd'; 3 | import { connect } from 'dva'; 4 | 5 | @connect(({ user }) => ({ user })) 6 | export default class extends React.PureComponent { 7 | constructor(props) { 8 | super(props); 9 | const { dispatch } = props; 10 | dispatch({ 11 | type: 'user/query', 12 | }); 13 | } 14 | 15 | render() { 16 | const { user } = this.props; 17 | const { list } = user; 18 | const columns = [ 19 | { 20 | dataIndex: 'id', 21 | title: 'ID', 22 | }, 23 | { 24 | dataIndex: 'name', 25 | title: 'Name', 26 | }, 27 | { 28 | dataIndex: 'email', 29 | title: 'Email', 30 | }, 31 | ]; 32 | 33 | return ( 34 |
35 |
36 | 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/plugin-openapi/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-openapi", 3 | "version": "1.3.3", 4 | "description": "@umijs/plugin-openapi", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-openapi#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@umijs/openapi": "^1.2.0", 32 | "serve-static": "^1.14.1", 33 | "swagger-ui-dist": "^4.12.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/plugin-antd-mobile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-antd-mobile", 3 | "version": "1.2.0", 4 | "description": "@umijs/plugin-antd-mobile", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "xiaohuoni (https://github.com/xiaohuoni)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-antd#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "antd-mobile": "^5.0.0-rc.0", 32 | "antd-mobile-v2": "^2.3.4", 33 | "semver": "^7.3.5" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/plugin-layout/src/layout/getLayoutRenderConfig.ts: -------------------------------------------------------------------------------- 1 | const getLayoutRenderConfig = (currentPathConfig: { 2 | layout: 3 | | { 4 | hideMenu: boolean; 5 | hideNav: boolean; 6 | hideFooter: boolean; 7 | } 8 | | false; 9 | hideFooter: boolean; 10 | }) => { 11 | const layoutRender: any = {}; 12 | 13 | if (currentPathConfig?.hideFooter) { 14 | layoutRender.footerRender = false; 15 | } 16 | 17 | if (currentPathConfig?.layout == false) { 18 | layoutRender.pure = true; 19 | return layoutRender; 20 | } 21 | 22 | if (currentPathConfig?.layout?.hideMenu) { 23 | layoutRender.menuRender = false; 24 | } 25 | 26 | if (currentPathConfig?.layout?.hideFooter) { 27 | layoutRender.footerRender = false; 28 | } 29 | 30 | if (currentPathConfig?.layout?.hideNav) { 31 | layoutRender.headerRender = false; 32 | } 33 | 34 | return layoutRender; 35 | }; 36 | 37 | export default getLayoutRenderConfig; 38 | -------------------------------------------------------------------------------- /packages/preset-ant-design-pro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/preset-ant-design-pro", 3 | "version": "1.3.3", 4 | "description": "@umijs/preset-ant-design-pro", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "ycjcl868" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/preset-ant-design-pro#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@umijs/plugin-block-devtool": "1.3.0", 32 | "umi-plugin-antd-icon-config": "^2.0.0", 33 | "umi-plugin-pro-block": "^2.0.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/plugin-dva/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-dva", 3 | "version": "0.13.2", 4 | "description": "@umijs/plugin-dva", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-dva#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "babel-plugin-dva-hmr": "^0.4.2", 32 | "dva": "^2.6.0-beta.20", 33 | "dva-immer": "1.0.0", 34 | "dva-loading": "^3.0.20" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/layouts/index.js: -------------------------------------------------------------------------------- 1 | import { Layout, Menu } from 'antd'; 2 | import { Link } from 'umi'; 3 | import style from './style.less'; 4 | 5 | const { Content, Sider } = Layout; 6 | 7 | export default ({ children }) => ( 8 | 9 | 10 | 15 | 16 | App1 Dashboard 17 | 18 | 19 | User 20 | 21 | 22 | 23 | 31 | {children} 32 | 33 | 34 | ); 35 | -------------------------------------------------------------------------------- /cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add('login', (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 26 | import 'cypress-wait-until'; 27 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "build/dist", 4 | "module": "esnext", 5 | "target": "esnext", 6 | "lib": ["esnext", "dom"], 7 | "types": ["cypress"], 8 | "sourceMap": true, 9 | "baseUrl": ".", 10 | "jsx": "react", 11 | "allowSyntheticDefaultImports": true, 12 | "moduleResolution": "node", 13 | "forceConsistentCasingInFileNames": true, 14 | "noImplicitReturns": true, 15 | "suppressImplicitAnyIndexErrors": true, 16 | "noUnusedLocals": true, 17 | "allowJs": true, 18 | "skipLibCheck": true, 19 | "experimentalDecorators": true, 20 | "strict": true, 21 | "paths": { 22 | "@/*": ["/*"], 23 | "@@/*": ["/.umi/*"] 24 | } 25 | }, 26 | "exclude": [ 27 | "node_modules", 28 | "build", 29 | "dist", 30 | "scripts", 31 | "acceptance-tests", 32 | "webpack", 33 | "jest", 34 | "src/setupTests.ts", 35 | "tslint:latest", 36 | "tslint-config-prettier" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-block-devtool", 3 | "version": "1.3.0", 4 | "description": "@umijs/plugin-block-devtool", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src", 10 | "layouts" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/umijs/plugins" 15 | }, 16 | "keywords": [ 17 | "umi" 18 | ], 19 | "authors": [ 20 | "chencheng (https://github.com/sorrycc)" 21 | ], 22 | "license": "MIT", 23 | "bugs": "http://github.com/umijs/plugins/issues", 24 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-block-devtool#readme", 25 | "peerDependencies": { 26 | "umi": "3.x" 27 | }, 28 | "publishConfig": { 29 | "access": "public" 30 | }, 31 | "dependencies": { 32 | "uppercamelcase": "^3.0.0" 33 | }, 34 | "devDependencies": { 35 | "@types/uppercamelcase": "^3.0.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/preset-ant-design-pro/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi } from 'umi'; 2 | import proChainWebpack from './chainWebpack'; 3 | 4 | export default (api: IApi) => { 5 | const { REACT_APP_ENV } = process.env; 6 | // support dev tools 7 | api.modifyDefaultConfig((config) => { 8 | const { define } = config; 9 | 10 | config.define = { 11 | ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: '', 12 | REACT_APP_ENV: REACT_APP_ENV || false, 13 | ...(define || {}), 14 | }; 15 | return config; 16 | }); 17 | 18 | if (api.chainWebpack) { 19 | api.chainWebpack(proChainWebpack); 20 | } 21 | 22 | const plugins = [require.resolve('umi-plugin-pro-block')]; 23 | 24 | // 有 plugin-react 时不加 plugin-antd-icon-config,因为已经内置了 25 | // 在 ant-design-pro 5 之后,用 plugin-react,去 plugin-antd-icon-config 26 | if (!api.hasPlugins(['@umijs/plugin-react'])) { 27 | plugins.push(require.resolve('umi-plugin-antd-icon-config')); 28 | } 29 | return { 30 | plugins, 31 | }; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/layouts/index.js: -------------------------------------------------------------------------------- 1 | import { Layout, Menu } from 'antd'; 2 | import { Link } from 'umi'; 3 | import style from './style.less'; 4 | 5 | const { SubMenu } = Menu; 6 | const { Header, Content, Sider } = Layout; 7 | 8 | export default ({ children }) => ( 9 | 10 | 11 | 16 | 17 | App2 Dashboard 18 | 19 | 20 | User 21 | 22 | 23 | 24 | 32 | {children} 33 | 34 | 35 | ); 36 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app3/layouts/index.js: -------------------------------------------------------------------------------- 1 | import { Layout, Menu } from 'antd'; 2 | import Link from 'umi/link'; 3 | import style from './style.less'; 4 | 5 | const { SubMenu } = Menu; 6 | const { Header, Content, Sider } = Layout; 7 | 8 | export default ({ children }) => ( 9 | 10 | 11 | 16 | 17 | App3 Dashboard 18 | 19 | 20 | User 21 | 22 | 23 | 24 | 32 | {children} 33 | 34 | 35 | ); 36 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app4/layouts/index.js: -------------------------------------------------------------------------------- 1 | import { Layout, Menu } from 'antd'; 2 | import Link from 'umi/link'; 3 | import style from './style.less'; 4 | 5 | const { SubMenu } = Menu; 6 | const { Header, Content, Sider } = Layout; 7 | 8 | export default ({ children }) => ( 9 | 10 | 11 | 16 | 17 | App4 Dashboard 18 | 19 | 20 | User 21 | 22 | 23 | 24 | 32 | {children} 33 | 34 | 35 | ); 36 | -------------------------------------------------------------------------------- /scripts/verifyCommit.js: -------------------------------------------------------------------------------- 1 | // Invoked on the commit-msg git hook by yorkie. 2 | 3 | const { chalk } = require('@umijs/utils'); 4 | const msgPath = process.env.GIT_PARAMS; 5 | const msg = require('fs').readFileSync(msgPath, 'utf-8').trim(); 6 | 7 | const commitRE = 8 | /^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release|dep)(\(.+\))?: .{1,50}/; 9 | 10 | if (!commitRE.test(msg)) { 11 | console.log(); 12 | console.error( 13 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( 14 | `invalid commit message format.`, 15 | )}\n\n` + 16 | chalk.red( 17 | ` Proper commit message format is required for automated changelog generation. Examples:\n\n`, 18 | ) + 19 | ` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` + 20 | ` ${chalk.green( 21 | `fix(v-model): handle events on blur (close #28)`, 22 | )}\n\n` + 23 | chalk.red(` See .github/commit-convention.md for more details.\n`), 24 | ); 25 | process.exit(1); 26 | } 27 | -------------------------------------------------------------------------------- /packages/plugin-test/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | ## [1.0.2](https://github.com/umijs/plugins/compare/@umijs/plugin-test@1.0.1...@umijs/plugin-test@1.0.2) (2021-07-29) 6 | 7 | ### Bug Fixes 8 | 9 | - upgrade umi-test to 3.5.x ([#667](https://github.com/umijs/plugins/issues/667)) ([dd04e07](https://github.com/umijs/plugins/commit/dd04e078299990902d59f700e3df7233f8096feb)) 10 | 11 | ## [1.0.1](https://github.com/umijs/plugins/compare/@umijs/plugin-test@1.0.0...@umijs/plugin-test@1.0.1) (2021-06-30) 12 | 13 | ### Bug Fixes 14 | 15 | - umi-test version match ([#646](https://github.com/umijs/plugins/issues/646)) ([529f5ac](https://github.com/umijs/plugins/commit/529f5ac3278c99e73e18964ef406c4671ca4e0bc)) 16 | 17 | # 1.0.0 (2020-03-12) 18 | 19 | ### Features 20 | 21 | - add plugin-test ([6e4b969](https://github.com/umijs/plugins/commit/6e4b969b08597591579282a293ead2cb2ab5dbbc)) 22 | -------------------------------------------------------------------------------- /packages/plugin-access/tests/__mocks__/fs.ts: -------------------------------------------------------------------------------- 1 | interface FS { 2 | existsSync: (filePath: string) => boolean; 3 | readFileSync: (filePath: string) => string; 4 | readdirSync: (dirPath: string) => string; 5 | } 6 | 7 | const fs = jest.genMockFromModule('fs'); 8 | 9 | const PathToAccess = 'path/to/access'; 10 | 11 | function existsSync(filePath: string): boolean { 12 | if (filePath.startsWith(PathToAccess)) { 13 | return true; 14 | } else if (filePath.endsWith('path/to/js.js')) { 15 | return true; 16 | } else if (filePath.endsWith('path/to/no/export/access.ts')) { 17 | return true; 18 | } 19 | return false; 20 | } 21 | 22 | function readFileSync(filePath: string): string { 23 | if (filePath.startsWith(PathToAccess)) { 24 | return 'export default'; 25 | } 26 | return 'Invalid content'; 27 | } 28 | 29 | function readdirSync(dirPath: string): string { 30 | return 'test'; 31 | } 32 | 33 | fs.existsSync = existsSync; 34 | fs.readFileSync = readFileSync; 35 | fs.readdirSync = readdirSync; 36 | 37 | export default fs; 38 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/master/pages/index.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { MicroApp, useModel } from 'umi'; 3 | import style from './index.css'; 4 | 5 | export default function () { 6 | const [microAppState, setState] = useState('Hello'); 7 | const { setQiankunGlobalState } = useModel('@@qiankunStateForSlave'); 8 | 9 | return ( 10 |
11 |

Welcome to use QianKun ~

12 |

13 | 如果在使用中遇到任何问题,请在 14 | 19 | 此处 20 | 21 | 提Issue 22 |

23 | 28 | 29 | 30 |
31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /example/pages/plugin-initial-state.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useModel, history } from 'umi'; 3 | 4 | export default () => { 5 | const { initialState, loading, setInitialState } = useModel('@@initialState'); 6 | const { description } = useModel('bar'); 7 | return ( 8 |
9 |

10 | initial-state: {loading ? 'loading...' : JSON.stringify(initialState)} 11 |

12 |

13 | count from another model: {description} 14 |

15 | 18 | 21 |
22 | 30 |
31 |
32 | ); 33 | }; 34 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/slave/slaveRuntimePlugin.ts.tpl: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import qiankunRender, { clientRenderOptsStack } from './lifecycles'; 3 | import { Context } from '@@/plugin-qiankun/qiankunContext'; 4 | 5 | export function rootContainer(container: HTMLElement) { 6 | const value = 7 | typeof window !== 'undefined' ? (window as any).g_rootExports : {}; 8 | // eslint-disable-next-line global-require 9 | return React.createElement(Context.Provider, { value }, container); 10 | } 11 | 12 | export const render = (oldRender: any) => { 13 | return qiankunRender().then(oldRender); 14 | }; 15 | 16 | export function modifyClientRenderOpts(memo: any) { 17 | // 每次应用 render 的时候会调 modifyClientRenderOpts,这时尝试从队列中取 render 的配置 18 | const clientRenderOpts = clientRenderOptsStack.shift(); 19 | if (clientRenderOpts) { 20 | const history = clientRenderOpts.getHistory(); 21 | delete clientRenderOpts.getHistory; 22 | clientRenderOpts.history = history; 23 | } 24 | 25 | return { 26 | ...memo, 27 | ...clientRenderOpts, 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /example/plugin-layout/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-layout", 3 | "version": "0.16.0", 4 | "description": "@umijs/plugin-layout", 5 | "keywords": [ 6 | "umi" 7 | ], 8 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-layout#readme", 9 | "bugs": "http://github.com/umijs/plugins/issues", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/umijs/plugins" 13 | }, 14 | "license": "MIT", 15 | "main": "index.js", 16 | "dependencies": { 17 | "@umijs/route-utils": "^2.0.0", 18 | "antd": "^4.1.2", 19 | "lodash": "^4.17.15", 20 | "path-to-regexp": "1.x" 21 | }, 22 | "peerDependencies": { 23 | "@ant-design/icons": "^4.0.0", 24 | "@ant-design/pro-layout": "^6.0.0", 25 | "@umijs/plugin-initial-state": "2.x", 26 | "@umijs/plugin-locale": "0.x", 27 | "@umijs/plugin-model": "2.x", 28 | "umi": "3.x" 29 | }, 30 | "publishConfig": { 31 | "access": "public" 32 | }, 33 | "authors": [ 34 | "Ariel <1319413542@qq.com> (https://github.com/Ariel-Cheng)" 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /packages/plugin-antd-mobile/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | # [1.2.0](https://github.com/umijs/plugins/compare/@umijs/plugin-antd-mobile@1.1.0...@umijs/plugin-antd-mobile@1.2.0) (2021-12-31) 6 | 7 | ### Features 8 | 9 | - describe antd-mobile config ([#780](https://github.com/umijs/plugins/issues/780)) ([c6f2b95](https://github.com/umijs/plugins/commit/c6f2b95cce9ede23df7af435e8aae49d5ce3de19)) 10 | - use config ([f933b5e](https://github.com/umijs/plugins/commit/f933b5ed4a7564f0768dc87c9c10f42f5ec6a316)) 11 | 12 | # 1.1.0 (2021-12-14) 13 | 14 | ### Features 15 | 16 | - add plugin-antd-mobile ([#759](https://github.com/umijs/plugins/issues/759)) ([b841fcb](https://github.com/umijs/plugins/commit/b841fcbc7fa9ab4eee11e8e06433e3acdd0ec144)) 17 | - remove mobile from plugin-antd & update preset-react ([#760](https://github.com/umijs/plugins/issues/760)) ([1a312a4](https://github.com/umijs/plugins/commit/1a312a4ef8dcbc7b9853a276761d7b2a0cfb6e3b)) 18 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/src/master/AntdErrorBoundary.tsx.tpl: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Button, Result } from "antd"; 3 | {{#enableLocale}} 4 | import { getLocale } from "umi"; 5 | {{/enableLocale}} 6 | 7 | const defaultLocale = "en-US"; 8 | 9 | export const ErrorBoundary = ({ error }: { error: any }) => { 10 | console.error(error); 11 | let currentLocale = defaultLocale; 12 | {{#enableLocale}} 13 | currentLocale = getLocale ? getLocale() : defaultLocale; 14 | {{/enableLocale}} 15 | 16 | 17 | return ( 18 | window.location.reload()}> 32 | {currentLocale === defaultLocale ? "Reload" : "再试一次"} 33 | 34 | } 35 | /> 36 | ); 37 | }; 38 | -------------------------------------------------------------------------------- /packages/plugin-test/src/index.ts: -------------------------------------------------------------------------------- 1 | import { IApi, utils } from 'umi'; 2 | 3 | export default (api: IApi) => { 4 | api.registerCommand({ 5 | name: 'test', 6 | description: 'test with jest', 7 | details: ` 8 | $ umi-test 9 | 10 | # watch mode 11 | $ umi-test -w 12 | $ umi-test --watch 13 | 14 | # collect coverage 15 | $ umi-test --coverage 16 | 17 | # print debug info 18 | $ umi-test --debug 19 | 20 | # test specified package for lerna package 21 | $ umi-test --package name 22 | 23 | # don't do e2e test 24 | $ umi-test --no-e2e 25 | `, 26 | async fn() { 27 | const args = utils.yParser(process.argv.slice(3), { 28 | alias: { 29 | watch: ['w'], 30 | version: ['v'], 31 | }, 32 | boolean: ['coverage', 'watch', 'version', 'debug', 'e2e'], 33 | default: { 34 | e2e: true, 35 | }, 36 | }); 37 | 38 | require('@umijs/test') 39 | .default(args) 40 | .catch((e: Error) => { 41 | console.error(utils.chalk.red(e)); 42 | process.exit(1); 43 | }); 44 | }, 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /packages/plugin-model/tests/getName.test.ts: -------------------------------------------------------------------------------- 1 | import { getName } from '../src/utils'; 2 | import { join } from 'path'; 3 | 4 | const srcDir = 'ae/src'; 5 | 6 | describe('getName test', () => { 7 | test('global model', () => { 8 | expect(getName(join('ae/src/models/global.ts'), srcDir)).toEqual('global'); 9 | }); 10 | test('page multiple model', () => { 11 | expect( 12 | getName(join('ae/src/pages/dashboard/Workplace/models/list.ts'), srcDir), 13 | ).toEqual('dashboard.Workplace.list'); 14 | }); 15 | test('page single model', () => { 16 | expect( 17 | getName(join('ae/src/pages/dashboard/Workplace/notice.model.ts'), srcDir), 18 | ).toEqual('dashboard.Workplace.notice'); 19 | }); 20 | test('page single model when singular is "page"', () => { 21 | expect( 22 | getName(join('ae/src/page/dashboard/Workplace/form.model.ts'), srcDir), 23 | ).toEqual('dashboard.Workplace.form'); 24 | }); 25 | test('subdirectories in base model dir', () => { 26 | expect(getName(join('ae/src/models/home/test.ts'), srcDir)).toEqual( 27 | 'home.test', 28 | ); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app1/pages/index.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useModel, MicroAppWithMemoHistory } from 'umi'; 3 | import { Drawer } from 'antd'; 4 | 5 | export default function () { 6 | const { testProp1, globalState } = useModel('@@qiankunStateFromMaster') || {}; 7 | const [visible, setVisible] = useState(false); 8 | return ( 9 |
10 |

Dashboard 1

11 |

testProp1: {testProp1}

12 |

globalState: {JSON.stringify(globalState)}

13 | 14 |

MicroAppWithMemoHistory

15 | 22 | 23 | { 27 | setVisible(false); 28 | }} 29 | width={800} 30 | > 31 | 37 | 38 |
39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /packages/plugin-access/src/utils/getAccessContent.ts: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return `\ 3 | import React, { useContext } from 'react'; 4 | import AccessContext, { AccessInstance as AccessInstanceType } from './context'; 5 | import { traverseModifyRoutes } from './runtimeUtil'; 6 | 7 | export { traverseModifyRoutes }; 8 | 9 | export type AccessInstance = AccessInstanceType; 10 | 11 | export const useAccess = () => { 12 | const access = useContext(AccessContext); 13 | 14 | return access; 15 | }; 16 | 17 | export interface AccessProps { 18 | accessible: boolean; 19 | fallback?: React.ReactNode; 20 | } 21 | 22 | export const Access: React.FC = props => { 23 | const { accessible, fallback, children } = props; 24 | 25 | if (process.env.NODE_ENV === 'development' && typeof accessible === 'function') { 26 | console.warn( 27 | '[plugin-access]: provided "accessible" prop is a function named "' + 28 | (accessible as Function).name + 29 | '" instead of a boolean, maybe you need check it.', 30 | ); 31 | } 32 | 33 | return <>{accessible ? children : fallback}; 34 | }; 35 | `; 36 | } 37 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/readme/IE兼容性初步解决方案.md: -------------------------------------------------------------------------------- 1 | # 如何在 IE11 中使用 umi-plugin-qiankun 2 | 3 | ## 主要问题 4 | 5 | 现在在 IE11 中使用`umi-plugin-qiankun`主要有两个问题: 6 | 7 | - 如果开启了`sandbox: true`会使用`proxy`, 由于 IE 不支持`proxy`, 应用将无法运行 8 | - `qiankun`加载微前端的请求是基于`fetch`的,而 IE 不支持`fetch`, 需要加载对应的`polyfill` 9 | 10 | ## 解决方案 11 | 12 | ### proxy 解决方案: 13 | 14 | - 在 master 应用的`.umirc.js`中不设置`sandbox`或者设置`sandbox: false` 15 | - 在 master 及 slave 应用的`.umirc.js`中,配置`runtimePublicPath`及`publicPath`, 不然会报错。具体内容参考这次 commit: [子应用默认开启 runtimePublicPath](https://github.com/umijs/umi-plugin-qiankun/commit/a2b4387c0ee6e2c23a03e2cd0284224a96bd6a20) 16 | 17 | ### fetch 解决方案: 18 | 19 | - 在 master 应用中安装`fetch`的 polyfill 20 | 21 | ```javascript 22 | yarn add whatwg-fetch 23 | ``` 24 | 25 | - 引入对应的 polyfill 26 | 27 | 在 master 应用的`global.js`中引入对应的 polyfill, 如下: 28 | 29 | ```javascript 30 | import 'whatwg-fetch'; 31 | ``` 32 | 33 | ## 在 IE11 上调试 34 | 35 | 如果需要在 Windows 及 IE11 上进行开发调试,需要在 IE11 上进行以下设置: 36 | 37 | 打开 IE11 的 Internet 选项,选择“安全”——“本地 Intranet”, 点击下方“站点”,在弹出窗口中取消勾选所有选项; ![image](https://user-images.githubusercontent.com/15656042/71427231-35cfb500-26f1-11ea-8d08-a297aca290b6.png) 38 | -------------------------------------------------------------------------------- /packages/plugin-crossorigin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 4 | 5 | ## [1.2.1](https://github.com/umijs/plugins/compare/@umijs/plugin-crossorigin@1.2.0...@umijs/plugin-crossorigin@1.2.1) (2021-06-03) 6 | 7 | **Note:** Version bump only for package @umijs/plugin-crossorigin 8 | 9 | # [1.2.0](https://github.com/umijs/plugins/compare/@umijs/plugin-crossorigin@1.1.1...@umijs/plugin-crossorigin@1.2.0) (2020-10-26) 10 | 11 | ### Features 12 | 13 | - support include args ([#416](https://github.com/umijs/plugins/issues/416)) ([ff8cd78](https://github.com/umijs/plugins/commit/ff8cd7866da0b1ecf46b54e5afb738c9fd3fe767)) 14 | 15 | ## [1.1.1](https://github.com/umijs/plugins/compare/@umijs/plugin-crossorigin@1.1.0...@umijs/plugin-crossorigin@1.1.1) (2020-07-20) 16 | 17 | **Note:** Version bump only for package @umijs/plugin-crossorigin 18 | 19 | # 1.1.0 (2020-02-17) 20 | 21 | ### Features 22 | 23 | - add plugin crossorigin ([b4dc5f6](https://github.com/umijs/plugins/commit/b4dc5f6599117ca09bb1aa923885001efe6a2c09)) 24 | -------------------------------------------------------------------------------- /packages/plugin-locale/src/polyfill.ts: -------------------------------------------------------------------------------- 1 | import { IApi } from 'umi'; 2 | 3 | // data come from https://caniuse.com/#search=intl 4 | // you can find all browsers in https://github.com/browserslist/browserslist#browsers 5 | const polyfillTargets = { 6 | ie: 10, 7 | firefox: 28, 8 | chrome: 23, 9 | safari: 9.1, 10 | opera: 12.1, 11 | ios: 9.3, 12 | ios_saf: 9.3, 13 | operamini: Infinity, 14 | op_mini: Infinity, 15 | android: 4.3, 16 | blackberry: Infinity, 17 | operamobile: 12.1, 18 | op_mob: 12.1, 19 | explorermobil: 10, 20 | ie_mob: 10, 21 | ucandroid: Infinity, 22 | }; 23 | 24 | function isNeedPolyfill(targets = {}) { 25 | return ( 26 | Object.keys(targets).find((key) => { 27 | const lowKey = key.toLocaleLowerCase(); 28 | return polyfillTargets[lowKey] && polyfillTargets[lowKey] >= targets[key]; 29 | }) !== undefined 30 | ); 31 | } 32 | 33 | export default ({ api }: { api: IApi }) => { 34 | api.addPolyfillImports(() => { 35 | return isNeedPolyfill(api.config.targets) 36 | ? [ 37 | { 38 | source: require.resolve('intl'), 39 | }, 40 | ] 41 | : []; 42 | }); 43 | }; 44 | -------------------------------------------------------------------------------- /packages/plugin-locale/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-locale", 3 | "version": "0.16.0", 4 | "description": "@umijs/plugin-locale", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/umijs/plugins" 14 | }, 15 | "keywords": [ 16 | "umi" 17 | ], 18 | "authors": [ 19 | "chencheng (https://github.com/sorrycc)" 20 | ], 21 | "license": "MIT", 22 | "bugs": "http://github.com/umijs/plugins/issues", 23 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-locale#readme", 24 | "peerDependencies": { 25 | "umi": "3.x" 26 | }, 27 | "publishConfig": { 28 | "access": "public" 29 | }, 30 | "dependencies": { 31 | "@ant-design/icons": "^4.1.0", 32 | "@formatjs/intl-pluralrules": "^1.5.0", 33 | "@formatjs/intl-relativetimeformat": "^4.5.7", 34 | "intl": "1.2.5", 35 | "moment": "^2.29.1", 36 | "react-intl": "3.12.1", 37 | "warning": "^4.0.3" 38 | }, 39 | "devDependencies": { 40 | "@types/warning": "^3.0.0" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/examples/app2/pages/user/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button, Table } from 'antd'; 3 | import { connect } from 'dva'; 4 | import { connectMaster } from 'umi'; 5 | @connect(({ user }) => ({ user })) 6 | @connectMaster 7 | export default class extends React.PureComponent { 8 | constructor(props) { 9 | super(props); 10 | const { dispatch } = props; 11 | dispatch({ 12 | type: 'user/query', 13 | }); 14 | } 15 | 16 | render() { 17 | const { user, current, pageSize } = this.props; 18 | const { list } = user; 19 | const columns = [ 20 | { 21 | dataIndex: 'id', 22 | title: 'ID', 23 | }, 24 | { 25 | dataIndex: 'name', 26 | title: 'Name', 27 | }, 28 | { 29 | dataIndex: 'email', 30 | title: 'Email', 31 | }, 32 | ]; 33 | 34 | return ( 35 |
36 |
37 |

来自 app1 的数据

38 |

current: {current}

39 |

pageSize: {pageSize}

40 |
41 |
42 | 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/plugin-layout/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@umijs/plugin-layout", 3 | "version": "0.18.4", 4 | "description": "@umijs/plugin-layout", 5 | "keywords": [ 6 | "umi" 7 | ], 8 | "homepage": "https://github.com/umijs/plugins/tree/master/packages/plugin-layout#readme", 9 | "bugs": "http://github.com/umijs/plugins/issues", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/umijs/plugins" 13 | }, 14 | "license": "MIT", 15 | "main": "lib/index.js", 16 | "types": "lib/types/index.d.ts", 17 | "files": [ 18 | "lib", 19 | "src" 20 | ], 21 | "dependencies": { 22 | "@umijs/route-utils": "^2.0.0", 23 | "antd": "^4.1.2", 24 | "lodash": "^4.17.15", 25 | "path-to-regexp": "1.x" 26 | }, 27 | "peerDependencies": { 28 | "@ant-design/icons": "^4.0.0", 29 | "@ant-design/pro-layout": "^6.0.0", 30 | "@umijs/plugin-initial-state": "2.x", 31 | "@umijs/plugin-locale": "0.x", 32 | "@umijs/plugin-model": "2.x", 33 | "umi": "3.x" 34 | }, 35 | "publishConfig": { 36 | "access": "public" 37 | }, 38 | "authors": [ 39 | "Ariel <1319413542@qq.com> (https://github.com/Ariel-Cheng)" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /packages/plugin-layout/src/utils/copySrcFiles.ts: -------------------------------------------------------------------------------- 1 | import { utils } from 'umi'; 2 | import { join } from 'path'; 3 | import { readFileSync, copyFileSync, statSync, writeFileSync } from 'fs'; 4 | 5 | export default ({ 6 | cwd, 7 | absTmpPath, 8 | config, 9 | }: { 10 | cwd: string; 11 | absTmpPath: string; 12 | config: object; 13 | }) => { 14 | const files = utils.glob.sync('**/*', { 15 | cwd, 16 | }); 17 | const base = join(absTmpPath, 'plugin-layout', 'layout'); 18 | utils.mkdirp.sync(base); 19 | files.forEach(async (file) => { 20 | if (['index.ts', 'runtime.tsx.tpl'].includes(file)) return; 21 | const source = join(cwd, file); 22 | const target = join(base, file); 23 | if (statSync(source).isDirectory()) { 24 | utils.mkdirp.sync(target); 25 | } else { 26 | if (target.endsWith('.tpl')) { 27 | const sourceContent = readFileSync(source, 'utf-8'); 28 | await writeFileSync( 29 | target.replace(/\.tpl$/, ''), 30 | utils.Mustache.render(sourceContent, config), 31 | 'utf-8', 32 | ); 33 | } else { 34 | await copyFileSync(source, target); 35 | } 36 | } 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /packages/plugin-qiankun/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-present chencheng (sorrycc@gmail.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/plugin-initial-state/src/utils/getProviderContent.tsx: -------------------------------------------------------------------------------- 1 | export default ` 2 | import React, { useRef, useEffect } from "react"; 3 | import { plugin } from "../core/umiExports"; 4 | import { ApplyPluginsType } from 'umi'; 5 | import { useModel } from "../plugin-model/useModel"; 6 | if (typeof useModel !== "function") { 7 | throw new Error( 8 | "[plugin-initial-state]: useModel is not a function, @umijs/plugin-model is required." 9 | ); 10 | } 11 | 12 | interface Props { 13 | children: React.ReactNode; 14 | } 15 | export default (props: Props) => { 16 | const { children } = props; 17 | const appLoaded = useRef(false); 18 | // 获取用户的配置,暂时只支持 loading 19 | const useRuntimeConfig = 20 | plugin.applyPlugins({ 21 | key: "initialStateConfig", 22 | type: ApplyPluginsType.modify, 23 | initialValue: {}, 24 | }) || {}; 25 | const { loading = false } = useModel("@@initialState") || {}; 26 | useEffect(() => { 27 | if (!loading) { 28 | appLoaded.current = true; 29 | } 30 | }, [loading]); 31 | // initial state loading 时,阻塞渲染 32 | if (loading && !appLoaded.current) { 33 | return useRuntimeConfig.loading || null; 34 | } 35 | return children; 36 | }; 37 | `; 38 | -------------------------------------------------------------------------------- /packages/plugin-locale/fixtures/runtime/src/pages/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'umi'; 3 | import { DatePicker } from 'antd'; 4 | import moment from 'moment'; 5 | import { useIntl, getLocale, getAllLocales, setLocale } from '../.umi-test/plugin-locale/localeExports'; 6 | 7 | export default function(props) { 8 | const intl = useIntl(); 9 | const list = getAllLocales(); 10 | const locale = getLocale(); 11 | 12 | return ( 13 |
14 |

Current language:{locale}

15 |

标题:

{props.route.title}

16 | 17 |

{moment().set({ 18 | year: 2020, 19 | month: 2, 20 | date: 21, 21 | }) 22 | .format('LL')}

23 | {list.map(locale => ( 24 | 25 | {locale} 26 | 27 | ))} 28 |

29 | {intl.formatMessage( 30 | { 31 | id: 'name', 32 | }, 33 | { 34 | name: 'Traveler', 35 | }, 36 | )} 37 |

38 |
39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /packages/plugin-block-devtool/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present yutingzhao1991 (yutingzhao1991@sina.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | --------------------------------------------------------------------------------