yuang-framework-ui-pc 1.1.88 → 1.1.90
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 +42 -42
- package/lib/utils/resolvers.cjs +42 -42
- 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
|
@@ -8,63 +8,63 @@ function getSideEffects(path, options) {
|
|
|
8
8
|
}
|
|
9
9
|
return `${path}/style/index`;
|
|
10
10
|
}
|
|
11
|
-
function getStylePath(namePath, packageName, path) {
|
|
12
|
-
if (!path) {
|
|
11
|
+
function getStylePath(namePath, packageName, path = "/es") {
|
|
12
|
+
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
13
13
|
return `${packageName}/es/${namePath}`;
|
|
14
14
|
}
|
|
15
|
-
if (path === "/es/core") {
|
|
16
|
-
return `${packageName}/es/${namePath}`;
|
|
17
|
-
}
|
|
18
|
-
if (path === "/lib/core") {
|
|
19
|
-
return `${packageName}/lib/${namePath}`;
|
|
20
|
-
}
|
|
21
15
|
return `${packageName}${path}/${namePath}`;
|
|
22
16
|
}
|
|
23
17
|
const componentDependencyMap = {
|
|
24
18
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// EleForm: ['
|
|
19
|
+
// 可继续添加其他依赖:
|
|
20
|
+
// EleTable: ['EleTableColumn'],
|
|
21
|
+
// EleForm: ['EleFormItem', 'EleInput']
|
|
28
22
|
};
|
|
29
|
-
|
|
23
|
+
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
24
|
+
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
25
|
+
Object.values(componentDependencyMap).forEach((children) => {
|
|
26
|
+
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
27
|
+
});
|
|
28
|
+
function generateComponentResolveConfig(name, options) {
|
|
29
|
+
const { path = "/es", exclude = [] } = options || {};
|
|
30
|
+
const packageName = "yuang-framework-ui-pc";
|
|
31
|
+
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
32
|
+
const stylePath = getStylePath(namePath, packageName, path);
|
|
33
|
+
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
from: `${packageName}${path}`,
|
|
37
|
+
// path已有默认值,无需??兜底
|
|
38
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
return {
|
|
42
|
+
name,
|
|
43
|
+
// 关键修复:补充name字段,符合解析配置规范
|
|
44
|
+
from: `${packageName}${path}/${namePath}/index`,
|
|
45
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
30
50
|
return {
|
|
31
51
|
type: "component",
|
|
32
52
|
resolve: (name) => {
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
53
|
+
const { exclude = [] } = options;
|
|
54
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
55
|
+
console.log(`按需加载插件: ${name},是否匹配:${isMatch}`);
|
|
37
56
|
if (isMatch) {
|
|
38
|
-
const
|
|
39
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
40
|
-
const stylePath = getStylePath(namePath, packageName, path);
|
|
41
|
-
let resolveResult;
|
|
42
|
-
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
43
|
-
resolveResult = {
|
|
44
|
-
name,
|
|
45
|
-
from: `${packageName}${path ?? "/es"}`,
|
|
46
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
resolveResult = {
|
|
50
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
51
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
57
|
+
const currentConfig = generateComponentResolveConfig(name, options);
|
|
54
58
|
const dependencyList = componentDependencyMap[name];
|
|
55
59
|
if (dependencyList && dependencyList.length) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
name: depName,
|
|
61
|
-
from: !path || path === "/es/core" || path === "/lib/core" ? `${packageName}${path ?? "/es"}` : `${packageName}${path}/${dependencyPath}/index`,
|
|
62
|
-
sideEffects: getSideEffects(dependencyStylePath, options)
|
|
63
|
-
};
|
|
64
|
-
});
|
|
60
|
+
const dependencyConfigs = dependencyList.map(
|
|
61
|
+
(depName) => generateComponentResolveConfig(depName, options)
|
|
62
|
+
);
|
|
63
|
+
return [currentConfig, ...dependencyConfigs];
|
|
65
64
|
}
|
|
66
|
-
return
|
|
65
|
+
return currentConfig;
|
|
67
66
|
}
|
|
67
|
+
return void 0;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -10,63 +10,63 @@ function getSideEffects(path, options) {
|
|
|
10
10
|
}
|
|
11
11
|
return `${path}/style/index`;
|
|
12
12
|
}
|
|
13
|
-
function getStylePath(namePath, packageName, path) {
|
|
14
|
-
if (!path) {
|
|
13
|
+
function getStylePath(namePath, packageName, path = "/es") {
|
|
14
|
+
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
15
15
|
return `${packageName}/es/${namePath}`;
|
|
16
16
|
}
|
|
17
|
-
if (path === "/es/core") {
|
|
18
|
-
return `${packageName}/es/${namePath}`;
|
|
19
|
-
}
|
|
20
|
-
if (path === "/lib/core") {
|
|
21
|
-
return `${packageName}/lib/${namePath}`;
|
|
22
|
-
}
|
|
23
17
|
return `${packageName}${path}/${namePath}`;
|
|
24
18
|
}
|
|
25
19
|
const componentDependencyMap = {
|
|
26
20
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
// EleForm: ['
|
|
21
|
+
// 可继续添加其他依赖:
|
|
22
|
+
// EleTable: ['EleTableColumn'],
|
|
23
|
+
// EleForm: ['EleFormItem', 'EleInput']
|
|
30
24
|
};
|
|
31
|
-
|
|
25
|
+
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
26
|
+
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
27
|
+
Object.values(componentDependencyMap).forEach((children) => {
|
|
28
|
+
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
29
|
+
});
|
|
30
|
+
function generateComponentResolveConfig(name, options) {
|
|
31
|
+
const { path = "/es", exclude = [] } = options || {};
|
|
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}`,
|
|
39
|
+
// path已有默认值,无需??兜底
|
|
40
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
return {
|
|
44
|
+
name,
|
|
45
|
+
// 关键修复:补充name字段,符合解析配置规范
|
|
46
|
+
from: `${packageName}${path}/${namePath}/index`,
|
|
47
|
+
sideEffects: getSideEffects(stylePath, options)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
32
52
|
return {
|
|
33
53
|
type: "component",
|
|
34
54
|
resolve: (name) => {
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
|
|
55
|
+
const { exclude = [] } = options;
|
|
56
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
|
|
57
|
+
console.log(`按需加载插件: ${name},是否匹配:${isMatch}`);
|
|
39
58
|
if (isMatch) {
|
|
40
|
-
const
|
|
41
|
-
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
42
|
-
const stylePath = getStylePath(namePath, packageName, path);
|
|
43
|
-
let resolveResult;
|
|
44
|
-
if (!path || path === "/es/core" || path === "/lib/core") {
|
|
45
|
-
resolveResult = {
|
|
46
|
-
name,
|
|
47
|
-
from: `${packageName}${path ?? "/es"}`,
|
|
48
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
49
|
-
};
|
|
50
|
-
} else {
|
|
51
|
-
resolveResult = {
|
|
52
|
-
from: `${packageName}${path}/${namePath}/index`,
|
|
53
|
-
sideEffects: getSideEffects(stylePath, options)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
59
|
+
const currentConfig = generateComponentResolveConfig(name, options);
|
|
56
60
|
const dependencyList = componentDependencyMap[name];
|
|
57
61
|
if (dependencyList && dependencyList.length) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
name: depName,
|
|
63
|
-
from: !path || path === "/es/core" || path === "/lib/core" ? `${packageName}${path ?? "/es"}` : `${packageName}${path}/${dependencyPath}/index`,
|
|
64
|
-
sideEffects: getSideEffects(dependencyStylePath, options)
|
|
65
|
-
};
|
|
66
|
-
});
|
|
62
|
+
const dependencyConfigs = dependencyList.map(
|
|
63
|
+
(depName) => generateComponentResolveConfig(depName, options)
|
|
64
|
+
);
|
|
65
|
+
return [currentConfig, ...dependencyConfigs];
|
|
67
66
|
}
|
|
68
|
-
return
|
|
67
|
+
return currentConfig;
|
|
69
68
|
}
|
|
69
|
+
return void 0;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
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;
|