@umijs/plugins 4.0.0-canary.20220422.2 → 4.0.0-canary.20220425.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/access.js CHANGED
@@ -8,7 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs_1 = __importDefault(require("fs"));
12
16
  const path_1 = require("path");
13
17
  const withTmpPath_1 = require("./utils/withTmpPath");
14
18
  exports.default = (api) => {
@@ -21,18 +25,28 @@ exports.default = (api) => {
21
25
  enableBy: api.EnableBy.config,
22
26
  });
23
27
  api.onGenerateFiles(() => __awaiter(void 0, void 0, void 0, function* () {
28
+ // allow enable access without access file
29
+ const hasAccessFile = ['js', 'jsx', 'ts', 'tsx'].some((ext) => fs_1.default.existsSync((0, path_1.join)(api.paths.absSrcPath, `access.${ext}`)));
24
30
  // runtime.tsx
25
31
  api.writeTmpFile({
26
32
  path: 'runtime.tsx',
27
33
  content: `
28
- import React from 'react';
29
- import accessFactory from '@/access';
34
+ import React from 'react';${hasAccessFile
35
+ ? `
36
+ import accessFactory from '@/access'
30
37
  import { useModel } from '@@/plugin-model';
38
+ `
39
+ : ''}
31
40
  import { AccessContext } from './context';
32
41
 
33
- function Provider(props) {
42
+ function Provider(props) {${hasAccessFile
43
+ ? `
34
44
  const { initialState } = useModel('@@initialState');
35
45
  const access = React.useMemo(() => accessFactory(initialState), [initialState]);
46
+ `
47
+ : `
48
+ const access = {};
49
+ `}
36
50
  return (
37
51
  <AccessContext.Provider value={access}>
38
52
  { props.children }
package/dist/antd.js CHANGED
@@ -49,7 +49,8 @@ exports.default = (api) => {
49
49
  api.modifyConfig((memo) => {
50
50
  checkPkgPath();
51
51
  // antd import
52
- memo.alias.antd = pkgPath;
52
+ // alias 会导致 antd 不能多实例,故删除
53
+ // memo.alias.antd = pkgPath;
53
54
  // moment > dayjs
54
55
  if (memo.antd.dayjs) {
55
56
  memo.alias.moment = (0, path_1.dirname)(require.resolve('dayjs/package.json'));
package/dist/dva.js CHANGED
@@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getAllModels = exports.getModelUtil = void 0;
27
27
  const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
28
+ const utils_1 = require("@umijs/utils");
28
29
  const path_1 = require("path");
29
30
  const plugin_utils_1 = require("umi/plugin-utils");
30
31
  const modelUtils_1 = require("./utils/modelUtils");
31
32
  const withTmpPath_1 = require("./utils/withTmpPath");
32
- const utils_1 = require("@umijs/utils");
33
33
  exports.default = (api) => {
34
34
  const pkgPath = (0, path_1.join)(__dirname, '../libs/dva.ts');
35
35
  api.describe({
@@ -80,15 +80,22 @@ import dvaImmer, { enableES5, enableAllPlugins } from '${(0, utils_1.winPath)(re
80
80
  `
81
81
  : ''}
82
82
  import React, { useRef } from 'react';
83
- import { history } from 'umi';
83
+ import { history, ApplyPluginsType, useAppData } from 'umi';
84
84
  import { models } from './models';
85
85
 
86
86
  export function RootContainer(props: any) {
87
+ const { pluginManager } = useAppData();
87
88
  const app = useRef<any>();
89
+ const runtimeDva = pluginManager.applyPlugins({
90
+ key: 'dva',
91
+ type: ApplyPluginsType.modify,
92
+ initialValue: {},
93
+ });
88
94
  if (!app.current) {
89
95
  app.current = create(
90
96
  {
91
97
  history,
98
+ ...(runtimeDva.config || {}),
92
99
  },
93
100
  {
94
101
  initialReducer: {},
@@ -139,6 +146,7 @@ export { connect, useDispatch, useStore, useSelector } from 'dva';`,
139
146
  api.addRuntimePlugin(() => {
140
147
  return [(0, withTmpPath_1.withTmpPath)({ api, path: 'runtime.tsx' })];
141
148
  });
149
+ api.addRuntimePluginKey(() => ['dva']);
142
150
  // dva list model
143
151
  api.registerCommand({
144
152
  name: 'dva',
@@ -107,7 +107,7 @@ export default () => ({ loading: false, refresh: () => {} })
107
107
  content: `
108
108
  import React from 'react';
109
109
  import Provider from './Provider';
110
- export function innerProvider(container) {
110
+ export function dataflowProvider(container) {
111
111
  return <Provider>{ container }</Provider>;
112
112
  }
113
113
  `,
@@ -129,7 +129,7 @@ if (!window.__POWERED_BY_QIANKUN__) {
129
129
  path: file.replace(/\.tpl$/, ''),
130
130
  content: getFileContent(file)
131
131
  .replace('__USE_MODEL__', api.isPluginEnable('model')
132
- ? `import { useModel } from '@@/plugin/model'`
132
+ ? `import { useModel } from '@@/plugin-model'`
133
133
  : `const useModel = null;`)
134
134
  .replace(/from 'qiankun'/g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('qiankun/package')))}'`)
135
135
  .replace(/from 'lodash\//g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('lodash/package')))}/`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-canary.20220422.2",
3
+ "version": "4.0.0-canary.20220425.1",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -17,15 +17,16 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "pnpm tsc",
20
- "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
20
+ "build:deps": "umi-scripts bundleDeps",
21
21
  "dev": "pnpm build -- --watch",
22
- "test": "jest -c ../../jest.turbo.config.ts"
22
+ "test": "umi-scripts jest-turbo"
23
23
  },
24
24
  "dependencies": {
25
25
  "@ahooksjs/use-request": "^2.0.0",
26
26
  "@ant-design/icons": "^4.7.0",
27
27
  "@ant-design/pro-layout": "^6.35.1",
28
- "@umijs/bundler-utils": "4.0.0-canary.20220422.2",
28
+ "@umijs/bundler-utils": "4.0.0-canary.20220425.1",
29
+ "antd": "^4.20.0",
29
30
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
31
  "axios": "^0.26.1",
31
32
  "babel-plugin-import": "^1.13.3",
@@ -44,7 +45,7 @@
44
45
  "warning": "^4.0.3"
45
46
  },
46
47
  "devDependencies": {
47
- "umi": "4.0.0-canary.20220422.2"
48
+ "umi": "4.0.0-canary.20220425.1"
48
49
  },
49
50
  "publishConfig": {
50
51
  "access": "public"