yuang-framework-ui-pc 1.1.93 → 1.1.95
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/es/utils/resolvers.d.ts +1 -1
- package/es/utils/resolvers.js +34 -54
- package/lib/utils/resolvers.cjs +34 -54
- package/lib/utils/resolvers.d.ts +1 -1
- package/package.json +1 -1
package/es/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|
package/es/utils/resolvers.js
CHANGED
|
@@ -1,69 +1,49 @@
|
|
|
1
1
|
function getSideEffects(path, options) {
|
|
2
|
-
|
|
3
|
-
const importStyle = (options == null ? void 0 : options.importStyle) ?? true;
|
|
2
|
+
const importStyle = options == null ? void 0 : options.importStyle;
|
|
4
3
|
if (!importStyle) {
|
|
5
|
-
return
|
|
4
|
+
return;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function getStylePath(namePath, packageName, path = "/es") {
|
|
10
|
-
const safePath = ["", "/es", "/lib", "/es/core", "/lib/core"].includes(path) ? path : "/es";
|
|
11
|
-
if (safePath === "/lib/core") {
|
|
12
|
-
return `${packageName}/lib/${namePath}`;
|
|
6
|
+
if (importStyle === "css") {
|
|
7
|
+
return `${path}/style/css`;
|
|
13
8
|
}
|
|
14
|
-
return `${
|
|
9
|
+
return `${path}/style/index`;
|
|
15
10
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
function generateComponentResolveConfig(name, options) {
|
|
21
|
-
const {
|
|
22
|
-
path = "/es",
|
|
23
|
-
exclude = []
|
|
24
|
-
} = options || {};
|
|
25
|
-
const packageName = "yuang-framework-ui-pc";
|
|
26
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
27
|
-
const safePath = path || "/es";
|
|
28
|
-
let fromPath = "";
|
|
29
|
-
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
30
|
-
fromPath = `${packageName}/${safePath === "/lib/core" ? "lib" : "es"}`;
|
|
31
|
-
} else if (safePath === "/lib") {
|
|
32
|
-
fromPath = `${packageName}/lib/${namePath}/index`;
|
|
33
|
-
} else {
|
|
34
|
-
fromPath = `${packageName}/es/${namePath}/index`;
|
|
11
|
+
function getStylePath(namePath, packageName, path) {
|
|
12
|
+
if (!path) {
|
|
13
|
+
return `${packageName}/es/${namePath}`;
|
|
35
14
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fromPath = `${packageName}/es/${namePath}`;
|
|
15
|
+
if (path === "/es/core") {
|
|
16
|
+
return `${packageName}/es/${namePath}`;
|
|
39
17
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
from: fromPath,
|
|
45
|
-
// 核心路径(绝对合法)
|
|
46
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
47
|
-
// 样式路径(允许undefined)
|
|
48
|
-
};
|
|
49
|
-
console.log(`[组件解析] ${name} -> 路径: ${config.from},样式: ${config.sideEffects}`);
|
|
50
|
-
return config;
|
|
18
|
+
if (path === "/lib/core") {
|
|
19
|
+
return `${packageName}/lib/${namePath}`;
|
|
20
|
+
}
|
|
21
|
+
return `${packageName}${path}/${namePath}`;
|
|
51
22
|
}
|
|
52
|
-
function EleAdminResolver(options
|
|
23
|
+
function EleAdminResolver(options) {
|
|
53
24
|
return {
|
|
54
25
|
type: "component",
|
|
55
26
|
resolve: (name) => {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const { path, exclude } = options || {};
|
|
29
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
|
|
30
|
+
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
31
|
+
if (isMatch) {
|
|
32
|
+
const packageName = "yuang-framework-ui-pc";
|
|
33
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
34
|
+
const stylePath = getStylePath(namePath, packageName, path);
|
|
35
|
+
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
36
|
+
return {
|
|
37
|
+
name,
|
|
38
|
+
from: `${packageName}${path ?? "/es"}`,
|
|
39
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
from: `${packageName}${path}/${namePath}/index`,
|
|
44
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
45
|
+
};
|
|
65
46
|
}
|
|
66
|
-
return currentConfig;
|
|
67
47
|
}
|
|
68
48
|
};
|
|
69
49
|
}
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -1,71 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
function getSideEffects(path, options) {
|
|
4
|
-
|
|
5
|
-
const importStyle = (options == null ? void 0 : options.importStyle) ?? true;
|
|
4
|
+
const importStyle = options == null ? void 0 : options.importStyle;
|
|
6
5
|
if (!importStyle) {
|
|
7
|
-
return
|
|
6
|
+
return;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
function getStylePath(namePath, packageName, path = "/es") {
|
|
12
|
-
const safePath = ["", "/es", "/lib", "/es/core", "/lib/core"].includes(path) ? path : "/es";
|
|
13
|
-
if (safePath === "/lib/core") {
|
|
14
|
-
return `${packageName}/lib/${namePath}`;
|
|
8
|
+
if (importStyle === "css") {
|
|
9
|
+
return `${path}/style/css`;
|
|
15
10
|
}
|
|
16
|
-
return `${
|
|
11
|
+
return `${path}/style/index`;
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
function generateComponentResolveConfig(name, options) {
|
|
23
|
-
const {
|
|
24
|
-
path = "/es",
|
|
25
|
-
exclude = []
|
|
26
|
-
} = options || {};
|
|
27
|
-
const packageName = "yuang-framework-ui-pc";
|
|
28
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
29
|
-
const safePath = path || "/es";
|
|
30
|
-
let fromPath = "";
|
|
31
|
-
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
32
|
-
fromPath = `${packageName}/${safePath === "/lib/core" ? "lib" : "es"}`;
|
|
33
|
-
} else if (safePath === "/lib") {
|
|
34
|
-
fromPath = `${packageName}/lib/${namePath}/index`;
|
|
35
|
-
} else {
|
|
36
|
-
fromPath = `${packageName}/es/${namePath}/index`;
|
|
13
|
+
function getStylePath(namePath, packageName, path) {
|
|
14
|
+
if (!path) {
|
|
15
|
+
return `${packageName}/es/${namePath}`;
|
|
37
16
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
fromPath = `${packageName}/es/${namePath}`;
|
|
17
|
+
if (path === "/es/core") {
|
|
18
|
+
return `${packageName}/es/${namePath}`;
|
|
41
19
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
from: fromPath,
|
|
47
|
-
// 核心路径(绝对合法)
|
|
48
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
49
|
-
// 样式路径(允许undefined)
|
|
50
|
-
};
|
|
51
|
-
console.log(`[组件解析] ${name} -> 路径: ${config.from},样式: ${config.sideEffects}`);
|
|
52
|
-
return config;
|
|
20
|
+
if (path === "/lib/core") {
|
|
21
|
+
return `${packageName}/lib/${namePath}`;
|
|
22
|
+
}
|
|
23
|
+
return `${packageName}${path}/${namePath}`;
|
|
53
24
|
}
|
|
54
|
-
function EleAdminResolver(options
|
|
25
|
+
function EleAdminResolver(options) {
|
|
55
26
|
return {
|
|
56
27
|
type: "component",
|
|
57
28
|
resolve: (name) => {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
29
|
+
var _a;
|
|
30
|
+
const { path, exclude } = options || {};
|
|
31
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
|
|
32
|
+
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
33
|
+
if (isMatch) {
|
|
34
|
+
const packageName = "yuang-framework-ui-pc";
|
|
35
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
36
|
+
const stylePath = getStylePath(namePath, packageName, path);
|
|
37
|
+
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
38
|
+
return {
|
|
39
|
+
name,
|
|
40
|
+
from: `${packageName}${path ?? "/es"}`,
|
|
41
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
from: `${packageName}${path}/${namePath}/index`,
|
|
46
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
47
|
+
};
|
|
67
48
|
}
|
|
68
|
-
return currentConfig;
|
|
69
49
|
}
|
|
70
50
|
};
|
|
71
51
|
}
|
package/lib/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|