@umijs/plugins 4.0.0-canary.20220422.3 → 4.0.0-canary.20220425.2
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 +17 -3
- package/dist/antd.js +11 -1
- package/dist/dva.js +10 -2
- package/dist/initial-state.js +1 -1
- package/dist/layout.js +4 -2
- package/package.json +6 -5
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
|
-
|
|
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
|
-
|
|
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'));
|
|
@@ -79,6 +80,15 @@ exports.default = (api) => {
|
|
|
79
80
|
},
|
|
80
81
|
'antd',
|
|
81
82
|
],
|
|
83
|
+
[
|
|
84
|
+
require.resolve('babel-plugin-import'),
|
|
85
|
+
{
|
|
86
|
+
libraryName: 'antd-4',
|
|
87
|
+
libraryDirectory: 'es',
|
|
88
|
+
style: style === 'less' ? true : 'css',
|
|
89
|
+
},
|
|
90
|
+
'antd-4',
|
|
91
|
+
],
|
|
82
92
|
]
|
|
83
93
|
: [];
|
|
84
94
|
});
|
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',
|
package/dist/initial-state.js
CHANGED
|
@@ -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
|
|
110
|
+
export function dataflowProvider(container) {
|
|
111
111
|
return <Provider>{ container }</Provider>;
|
|
112
112
|
}
|
|
113
113
|
`,
|
package/dist/layout.js
CHANGED
|
@@ -48,6 +48,7 @@ exports.default = (api) => {
|
|
|
48
48
|
cwd: api.cwd,
|
|
49
49
|
dep: '@ant-design/pro-layout',
|
|
50
50
|
}) || (0, path_1.dirname)(require.resolve('@ant-design/pro-layout/package.json'));
|
|
51
|
+
const antdPkgPath = (0, path_1.dirname)(require.resolve('antd/package.json'));
|
|
51
52
|
api.modifyAppData((memo) => {
|
|
52
53
|
const version = require(`${pkgPath}/package.json`).version;
|
|
53
54
|
memo.pluginLayout = {
|
|
@@ -59,6 +60,7 @@ exports.default = (api) => {
|
|
|
59
60
|
api.modifyConfig((memo) => {
|
|
60
61
|
// import from @ant-design/pro-layout
|
|
61
62
|
memo.alias['@ant-design/pro-layout'] = pkgPath;
|
|
63
|
+
memo.alias['antd-4'] = antdPkgPath;
|
|
62
64
|
return memo;
|
|
63
65
|
});
|
|
64
66
|
api.onGenerateFiles(() => {
|
|
@@ -245,7 +247,7 @@ export function patchRoutes({ routes }) {
|
|
|
245
247
|
});
|
|
246
248
|
const rightRenderContent = `
|
|
247
249
|
import React from 'react';
|
|
248
|
-
import { Avatar, Dropdown, Menu, Spin } from 'antd';
|
|
250
|
+
import { Avatar, Dropdown, Menu, Spin } from 'antd-4';
|
|
249
251
|
import { LogoutOutlined } from '@ant-design/icons';
|
|
250
252
|
{{#Locale}}
|
|
251
253
|
import { SelectLang } from '@@/plugin-locale';
|
|
@@ -487,7 +489,7 @@ export default LogoIcon;
|
|
|
487
489
|
content: `
|
|
488
490
|
import React from 'react';
|
|
489
491
|
import { history, type IRoute } from 'umi';
|
|
490
|
-
import { Result, Button } from 'antd';
|
|
492
|
+
import { Result, Button } from 'antd-4';
|
|
491
493
|
|
|
492
494
|
const Exception: React.FC<{
|
|
493
495
|
children: React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220425.2",
|
|
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": "
|
|
20
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
21
21
|
"dev": "pnpm build -- --watch",
|
|
22
|
-
"test": "
|
|
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.
|
|
28
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220425.2",
|
|
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.
|
|
48
|
+
"umi": "4.0.0-canary.20220425.2"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|