yuang-framework-ui-pc 1.1.89 → 1.1.91
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 +50 -30
- package/lib/utils/resolvers.cjs +50 -30
- 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
|
+
* 按需加载插件(彻底修复undefined路径问题)
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|
package/es/utils/resolvers.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
function getSideEffects(path, options) {
|
|
2
|
+
if (!path) return void 0;
|
|
2
3
|
const importStyle = options == null ? void 0 : options.importStyle;
|
|
3
4
|
if (!importStyle) {
|
|
4
|
-
return;
|
|
5
|
+
return void 0;
|
|
5
6
|
}
|
|
6
7
|
if (importStyle === "css") {
|
|
7
8
|
return `${path}/style/css`;
|
|
8
9
|
}
|
|
9
10
|
return `${path}/style/index`;
|
|
10
11
|
}
|
|
11
|
-
function getStylePath(namePath, packageName, path) {
|
|
12
|
-
|
|
12
|
+
function getStylePath(namePath, packageName, path = "/es") {
|
|
13
|
+
const safePath = path || "/es";
|
|
14
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
13
15
|
return `${packageName}/es/${namePath}`;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
if (path === "/lib/core") {
|
|
19
|
-
return `${packageName}/lib/${namePath}`;
|
|
20
|
-
}
|
|
21
|
-
return `${packageName}${path}/${namePath}`;
|
|
17
|
+
const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
|
|
18
|
+
return `${packageName}${finalPath}/${namePath}`;
|
|
22
19
|
}
|
|
23
20
|
const componentDependencyMap = {
|
|
24
21
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
@@ -32,42 +29,65 @@ Object.values(componentDependencyMap).forEach((children) => {
|
|
|
32
29
|
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
33
30
|
});
|
|
34
31
|
function generateComponentResolveConfig(name, options) {
|
|
35
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
path = "/es",
|
|
34
|
+
exclude = []
|
|
35
|
+
} = options || {};
|
|
36
36
|
const packageName = "yuang-framework-ui-pc";
|
|
37
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
37
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
38
38
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
from: `${packageName}${path ?? "/es"}`,
|
|
43
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
44
|
-
};
|
|
39
|
+
let fromPath = "";
|
|
40
|
+
if (["", "/es/core", "/lib/core"].includes(path)) {
|
|
41
|
+
fromPath = `${packageName}${path || "/es"}`;
|
|
45
42
|
} else {
|
|
46
|
-
|
|
47
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
48
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
49
|
-
};
|
|
43
|
+
fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
|
|
50
44
|
}
|
|
45
|
+
console.log(`[组件解析调试]
|
|
46
|
+
组件名: ${name}
|
|
47
|
+
path参数: ${path} (类型: ${typeof path})
|
|
48
|
+
namePath: ${namePath}
|
|
49
|
+
stylePath: ${stylePath}
|
|
50
|
+
fromPath: ${fromPath}
|
|
51
|
+
packageName: ${packageName}`);
|
|
52
|
+
const config = {
|
|
53
|
+
name: name || "",
|
|
54
|
+
// 组件名兜底
|
|
55
|
+
from: fromPath || `${packageName}/es`,
|
|
56
|
+
// from路径终极兜底
|
|
57
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
58
|
+
// 样式路径允许undefined
|
|
59
|
+
};
|
|
60
|
+
if (config.from.includes("undefined")) {
|
|
61
|
+
console.error(`[严重错误] from路径包含undefined: ${config.from},组件名: ${name}`);
|
|
62
|
+
}
|
|
63
|
+
return config;
|
|
51
64
|
}
|
|
52
|
-
function EleAdminResolver(options) {
|
|
65
|
+
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
53
66
|
return {
|
|
54
67
|
type: "component",
|
|
55
68
|
resolve: (name) => {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
69
|
+
const { exclude = [] } = options;
|
|
70
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
71
|
+
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
60
72
|
if (isMatch) {
|
|
61
73
|
const currentConfig = generateComponentResolveConfig(name, options);
|
|
74
|
+
if (currentConfig.from.includes("undefined")) {
|
|
75
|
+
console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
|
|
76
|
+
}
|
|
62
77
|
const dependencyList = componentDependencyMap[name];
|
|
63
78
|
if (dependencyList && dependencyList.length) {
|
|
64
|
-
const dependencyConfigs = dependencyList.map(
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
const dependencyConfigs = dependencyList.map((depName) => {
|
|
80
|
+
const depConfig = generateComponentResolveConfig(depName, options);
|
|
81
|
+
if (depConfig.from.includes("undefined")) {
|
|
82
|
+
console.error(`[依赖组件错误] ${depName} 的from路径异常: ${depConfig.from}`);
|
|
83
|
+
}
|
|
84
|
+
return depConfig;
|
|
85
|
+
});
|
|
67
86
|
return [currentConfig, ...dependencyConfigs];
|
|
68
87
|
}
|
|
69
88
|
return currentConfig;
|
|
70
89
|
}
|
|
90
|
+
return void 0;
|
|
71
91
|
}
|
|
72
92
|
};
|
|
73
93
|
}
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
function getSideEffects(path, options) {
|
|
4
|
+
if (!path) return void 0;
|
|
4
5
|
const importStyle = options == null ? void 0 : options.importStyle;
|
|
5
6
|
if (!importStyle) {
|
|
6
|
-
return;
|
|
7
|
+
return void 0;
|
|
7
8
|
}
|
|
8
9
|
if (importStyle === "css") {
|
|
9
10
|
return `${path}/style/css`;
|
|
10
11
|
}
|
|
11
12
|
return `${path}/style/index`;
|
|
12
13
|
}
|
|
13
|
-
function getStylePath(namePath, packageName, path) {
|
|
14
|
-
|
|
14
|
+
function getStylePath(namePath, packageName, path = "/es") {
|
|
15
|
+
const safePath = path || "/es";
|
|
16
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
15
17
|
return `${packageName}/es/${namePath}`;
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
if (path === "/lib/core") {
|
|
21
|
-
return `${packageName}/lib/${namePath}`;
|
|
22
|
-
}
|
|
23
|
-
return `${packageName}${path}/${namePath}`;
|
|
19
|
+
const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
|
|
20
|
+
return `${packageName}${finalPath}/${namePath}`;
|
|
24
21
|
}
|
|
25
22
|
const componentDependencyMap = {
|
|
26
23
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
@@ -34,42 +31,65 @@ Object.values(componentDependencyMap).forEach((children) => {
|
|
|
34
31
|
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
35
32
|
});
|
|
36
33
|
function generateComponentResolveConfig(name, options) {
|
|
37
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
path = "/es",
|
|
36
|
+
exclude = []
|
|
37
|
+
} = options || {};
|
|
38
38
|
const packageName = "yuang-framework-ui-pc";
|
|
39
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
39
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
40
40
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
from: `${packageName}${path ?? "/es"}`,
|
|
45
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
46
|
-
};
|
|
41
|
+
let fromPath = "";
|
|
42
|
+
if (["", "/es/core", "/lib/core"].includes(path)) {
|
|
43
|
+
fromPath = `${packageName}${path || "/es"}`;
|
|
47
44
|
} else {
|
|
48
|
-
|
|
49
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
50
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
51
|
-
};
|
|
45
|
+
fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
|
|
52
46
|
}
|
|
47
|
+
console.log(`[组件解析调试]
|
|
48
|
+
组件名: ${name}
|
|
49
|
+
path参数: ${path} (类型: ${typeof path})
|
|
50
|
+
namePath: ${namePath}
|
|
51
|
+
stylePath: ${stylePath}
|
|
52
|
+
fromPath: ${fromPath}
|
|
53
|
+
packageName: ${packageName}`);
|
|
54
|
+
const config = {
|
|
55
|
+
name: name || "",
|
|
56
|
+
// 组件名兜底
|
|
57
|
+
from: fromPath || `${packageName}/es`,
|
|
58
|
+
// from路径终极兜底
|
|
59
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
60
|
+
// 样式路径允许undefined
|
|
61
|
+
};
|
|
62
|
+
if (config.from.includes("undefined")) {
|
|
63
|
+
console.error(`[严重错误] from路径包含undefined: ${config.from},组件名: ${name}`);
|
|
64
|
+
}
|
|
65
|
+
return config;
|
|
53
66
|
}
|
|
54
|
-
function EleAdminResolver(options) {
|
|
67
|
+
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
55
68
|
return {
|
|
56
69
|
type: "component",
|
|
57
70
|
resolve: (name) => {
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
71
|
+
const { exclude = [] } = options;
|
|
72
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
73
|
+
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
62
74
|
if (isMatch) {
|
|
63
75
|
const currentConfig = generateComponentResolveConfig(name, options);
|
|
76
|
+
if (currentConfig.from.includes("undefined")) {
|
|
77
|
+
console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
|
|
78
|
+
}
|
|
64
79
|
const dependencyList = componentDependencyMap[name];
|
|
65
80
|
if (dependencyList && dependencyList.length) {
|
|
66
|
-
const dependencyConfigs = dependencyList.map(
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
const dependencyConfigs = dependencyList.map((depName) => {
|
|
82
|
+
const depConfig = generateComponentResolveConfig(depName, options);
|
|
83
|
+
if (depConfig.from.includes("undefined")) {
|
|
84
|
+
console.error(`[依赖组件错误] ${depName} 的from路径异常: ${depConfig.from}`);
|
|
85
|
+
}
|
|
86
|
+
return depConfig;
|
|
87
|
+
});
|
|
69
88
|
return [currentConfig, ...dependencyConfigs];
|
|
70
89
|
}
|
|
71
90
|
return currentConfig;
|
|
72
91
|
}
|
|
92
|
+
return void 0;
|
|
73
93
|
}
|
|
74
94
|
};
|
|
75
95
|
}
|
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
|
+
* 按需加载插件(彻底修复undefined路径问题)
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|