@umijs/plugins 4.0.0-beta.4 → 4.0.0-beta.8
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.d.ts +1 -1
- package/dist/access.d.ts.map +1 -0
- package/dist/antd.d.ts +1 -1
- package/dist/antd.d.ts.map +1 -0
- package/dist/antd.js +160 -3
- package/dist/dva.d.ts +1 -1
- package/dist/dva.d.ts.map +1 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -0
- package/dist/initial-state.d.ts +1 -1
- package/dist/initial-state.d.ts.map +1 -0
- package/dist/layout.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -0
- package/dist/locale.d.ts +1 -1
- package/dist/locale.d.ts.map +1 -0
- package/dist/model.d.ts +1 -1
- package/dist/model.d.ts.map +1 -0
- package/dist/qiankun.d.ts +1 -1
- package/dist/qiankun.d.ts.map +1 -0
- package/dist/request.d.ts +1 -1
- package/dist/request.d.ts.map +1 -0
- package/dist/sass.d.ts +1 -1
- package/dist/sass.d.ts.map +1 -0
- package/package.json +8 -2
package/dist/access.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/antd.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antd.d.ts","sourceRoot":"","sources":["../src/antd.ts"],"names":[],"mappings":";AA0EA,wBA0IE"}
|
package/dist/antd.js
CHANGED
|
@@ -1,11 +1,168 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@umijs/utils");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const presets = {
|
|
7
|
+
antd: {
|
|
8
|
+
plugins: [
|
|
9
|
+
'isSameOrBefore',
|
|
10
|
+
'isSameOrAfter',
|
|
11
|
+
'advancedFormat',
|
|
12
|
+
'customParseFormat',
|
|
13
|
+
'weekday',
|
|
14
|
+
'weekYear',
|
|
15
|
+
'weekOfYear',
|
|
16
|
+
'isMoment',
|
|
17
|
+
'localeData',
|
|
18
|
+
'localizedFormat',
|
|
19
|
+
],
|
|
20
|
+
replaceMoment: true,
|
|
21
|
+
},
|
|
22
|
+
antdv3: {
|
|
23
|
+
plugins: [
|
|
24
|
+
'isSameOrBefore',
|
|
25
|
+
'isSameOrAfter',
|
|
26
|
+
'advancedFormat',
|
|
27
|
+
'customParseFormat',
|
|
28
|
+
'weekday',
|
|
29
|
+
'weekYear',
|
|
30
|
+
'weekOfYear',
|
|
31
|
+
'isMoment',
|
|
32
|
+
'localeData',
|
|
33
|
+
'localizedFormat',
|
|
34
|
+
'badMutable',
|
|
35
|
+
],
|
|
36
|
+
replaceMoment: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const getConfig = (api) => {
|
|
40
|
+
let { preset = 'antd', plugins, replaceMoment, } = api.userConfig.antdDayjs || {};
|
|
41
|
+
if (preset && presets[preset]) {
|
|
42
|
+
plugins = presets[preset].plugins;
|
|
43
|
+
replaceMoment = presets[preset].replaceMoment;
|
|
44
|
+
}
|
|
45
|
+
if (plugins)
|
|
46
|
+
plugins = plugins;
|
|
47
|
+
if (replaceMoment !== undefined)
|
|
48
|
+
replaceMoment = replaceMoment;
|
|
49
|
+
return {
|
|
50
|
+
plugins,
|
|
51
|
+
replaceMoment,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const DIR_NAME = 'plugin-antd';
|
|
3
55
|
exports.default = (api) => {
|
|
4
|
-
api;
|
|
56
|
+
const opts = api.userConfig.antd;
|
|
57
|
+
// dayjs (by default)
|
|
58
|
+
const { dayjs = true } = opts;
|
|
59
|
+
api.describe({
|
|
60
|
+
config: {
|
|
61
|
+
schema(Joi) {
|
|
62
|
+
return Joi.object({
|
|
63
|
+
dark: Joi.boolean(),
|
|
64
|
+
compact: Joi.boolean(),
|
|
65
|
+
config: Joi.object(),
|
|
66
|
+
dayjs: Joi.alternatives(Joi.boolean(), Joi.object({
|
|
67
|
+
preset: Joi.string(),
|
|
68
|
+
plugins: Joi.array(),
|
|
69
|
+
replaceMoment: Joi.boolean(),
|
|
70
|
+
})),
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
5
75
|
// antd import
|
|
76
|
+
api.chainWebpack((memo) => {
|
|
77
|
+
function getUserLibDir({ library }) {
|
|
78
|
+
if (
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
(api.pkg.dependencies && api.pkg.dependencies[library]) ||
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
(api.pkg.devDependencies && api.pkg.devDependencies[library]) ||
|
|
83
|
+
// egg project using `clientDependencies` in ali tnpm
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
(api.pkg.clientDependencies && api.pkg.clientDependencies[library])) {
|
|
86
|
+
return (0, utils_1.winPath)((0, path_1.dirname)(
|
|
87
|
+
// 通过 resolve 往上找,可支持 lerna 仓库
|
|
88
|
+
// lerna 仓库如果用 yarn workspace 的依赖不一定在 node_modules,可能被提到根目录,并且没有 link
|
|
89
|
+
utils_1.resolve.sync(`${library}/package.json`, {
|
|
90
|
+
basedir: api.paths.cwd,
|
|
91
|
+
})));
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
memo.resolve.alias.set('antd', getUserLibDir({ library: 'antd' }) ||
|
|
96
|
+
(0, path_1.dirname)(require.resolve('antd/package.json')));
|
|
97
|
+
if (dayjs !== false) {
|
|
98
|
+
const { replaceMoment } = getConfig(api);
|
|
99
|
+
if (replaceMoment) {
|
|
100
|
+
memo.resolve.alias.set('moment', getUserLibDir({ library: 'dayjs' }) ||
|
|
101
|
+
(0, path_1.dirname)(require.resolve('dayjs/package.json')));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return memo;
|
|
105
|
+
});
|
|
6
106
|
// dark mode
|
|
7
107
|
// compat mode
|
|
8
|
-
|
|
108
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.dark) || (opts === null || opts === void 0 ? void 0 : opts.compact)) {
|
|
109
|
+
// support dark mode, user use antd 4 by default
|
|
110
|
+
const { getThemeVariables } = require('antd/dist/theme');
|
|
111
|
+
api.modifyDefaultConfig((config) => {
|
|
112
|
+
config.theme = Object.assign(Object.assign({}, getThemeVariables(opts)), config.theme);
|
|
113
|
+
return config;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (dayjs !== false) {
|
|
117
|
+
api.onGenerateFiles({
|
|
118
|
+
fn: () => {
|
|
119
|
+
const { plugins } = getConfig(api);
|
|
120
|
+
const runtimeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../templates/antd/dayjs.tpl'), 'utf-8');
|
|
121
|
+
api.writeTmpFile({
|
|
122
|
+
path: 'plugin-antd/dayjs.tsx',
|
|
123
|
+
content: utils_1.Mustache.render(runtimeTpl, {
|
|
124
|
+
plugins,
|
|
125
|
+
dayjsPath: (0, path_1.dirname)(require.resolve('dayjs/package.json')),
|
|
126
|
+
dayjsPluginPath: (0, path_1.dirname)(require.resolve('antd-dayjs-webpack-plugin/package.json')),
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
api.addEntryCodeAhead(() => {
|
|
132
|
+
return [`import './${DIR_NAME}/dayjs.tsx'`];
|
|
133
|
+
});
|
|
134
|
+
}
|
|
9
135
|
// babel-plugin-import
|
|
10
|
-
|
|
136
|
+
api.addExtraBabelPlugins(() => {
|
|
137
|
+
return [
|
|
138
|
+
[
|
|
139
|
+
require.resolve('babel-plugin-import'),
|
|
140
|
+
{
|
|
141
|
+
libraryName: 'antd',
|
|
142
|
+
libraryDirectory: 'es',
|
|
143
|
+
style: true,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
];
|
|
147
|
+
});
|
|
148
|
+
// antd config provider
|
|
149
|
+
// TODO: use umi provider
|
|
150
|
+
if (opts === null || opts === void 0 ? void 0 : opts.config) {
|
|
151
|
+
api.onGenerateFiles({
|
|
152
|
+
fn() {
|
|
153
|
+
// runtime.tsx
|
|
154
|
+
const runtimeTpl = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../templates/antd/runtime.tpl'), 'utf-8');
|
|
155
|
+
api.writeTmpFile({
|
|
156
|
+
path: `${DIR_NAME}/runtime.tsx`,
|
|
157
|
+
content: utils_1.Mustache.render(runtimeTpl, {
|
|
158
|
+
config: JSON.stringify(opts === null || opts === void 0 ? void 0 : opts.config),
|
|
159
|
+
}),
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
//TODO:Runtime Plugin
|
|
164
|
+
api.addRuntimePlugin(() => [
|
|
165
|
+
(0, path_1.join)(api.paths.absTmpPath, DIR_NAME, 'runtime.tsx'),
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
11
168
|
};
|
package/dist/dva.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dva.d.ts","sourceRoot":"","sources":["../src/dva.ts"],"names":[],"mappings":";AAEA,wBAOE"}
|
package/dist/icons.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/initial-state.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-state.d.ts","sourceRoot":"","sources":["../src/initial-state.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/layout.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/locale.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/model.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/qiankun.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qiankun.d.ts","sourceRoot":"","sources":["../src/qiankun.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/request.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/dist/sass.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sass.d.ts","sourceRoot":"","sources":["../src/sass.ts"],"names":[],"mappings":";AAEA,wBAEE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,13 @@
|
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"antd": "^4.16.13",
|
|
30
|
+
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
31
|
+
"babel-plugin-import": "^1.13.3",
|
|
32
|
+
"dayjs": "^1.10.7"
|
|
33
|
+
},
|
|
28
34
|
"devDependencies": {
|
|
29
|
-
"umi": "4.0.0-beta.
|
|
35
|
+
"umi": "4.0.0-beta.8"
|
|
30
36
|
}
|
|
31
37
|
}
|