yuang-framework-ui-pc 1.1.90 → 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.
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 按需加载插件(修复依赖组件解析问题 + 路径undefined问题)
15
+ * 按需加载插件(彻底修复undefined路径问题)
16
16
  * @param options 参数
17
17
  */
18
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
@@ -1,7 +1,8 @@
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`;
@@ -9,10 +10,12 @@ function getSideEffects(path, options) {
9
10
  return `${path}/style/index`;
10
11
  }
11
12
  function getStylePath(namePath, packageName, path = "/es") {
12
- if (!path || path === "/es/core" || path === "/lib/core") {
13
+ const safePath = path || "/es";
14
+ if (["", "/es/core", "/lib/core"].includes(safePath)) {
13
15
  return `${packageName}/es/${namePath}`;
14
16
  }
15
- return `${packageName}${path}/${namePath}`;
17
+ const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
18
+ return `${packageName}${finalPath}/${namePath}`;
16
19
  }
17
20
  const componentDependencyMap = {
18
21
  YuFrameworkAttachmentUpload: ["EleUploadList"]
@@ -26,25 +29,38 @@ Object.values(componentDependencyMap).forEach((children) => {
26
29
  children.forEach((child) => allNeedResolveComponents.add(child));
27
30
  });
28
31
  function generateComponentResolveConfig(name, options) {
29
- const { path = "/es", exclude = [] } = options || {};
32
+ const {
33
+ path = "/es",
34
+ exclude = []
35
+ } = options || {};
30
36
  const packageName = "yuang-framework-ui-pc";
31
- 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();
32
38
  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
- };
39
+ let fromPath = "";
40
+ if (["", "/es/core", "/lib/core"].includes(path)) {
41
+ fromPath = `${packageName}${path || "/es"}`;
40
42
  } else {
41
- return {
42
- name,
43
- // 关键修复:补充name字段,符合解析配置规范
44
- from: `${packageName}${path}/${namePath}/index`,
45
- sideEffects: getSideEffects(stylePath, options)
46
- };
43
+ fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
47
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;
48
64
  }
49
65
  function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
50
66
  return {
@@ -52,14 +68,21 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
52
68
  resolve: (name) => {
53
69
  const { exclude = [] } = options;
54
70
  const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
55
- console.log(`按需加载插件: ${name},是否匹配:${isMatch}`);
71
+ console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
56
72
  if (isMatch) {
57
73
  const currentConfig = generateComponentResolveConfig(name, options);
74
+ if (currentConfig.from.includes("undefined")) {
75
+ console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
76
+ }
58
77
  const dependencyList = componentDependencyMap[name];
59
78
  if (dependencyList && dependencyList.length) {
60
- const dependencyConfigs = dependencyList.map(
61
- (depName) => generateComponentResolveConfig(depName, options)
62
- );
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
+ });
63
86
  return [currentConfig, ...dependencyConfigs];
64
87
  }
65
88
  return currentConfig;
@@ -1,9 +1,10 @@
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`;
@@ -11,10 +12,12 @@ function getSideEffects(path, options) {
11
12
  return `${path}/style/index`;
12
13
  }
13
14
  function getStylePath(namePath, packageName, path = "/es") {
14
- if (!path || path === "/es/core" || path === "/lib/core") {
15
+ const safePath = path || "/es";
16
+ if (["", "/es/core", "/lib/core"].includes(safePath)) {
15
17
  return `${packageName}/es/${namePath}`;
16
18
  }
17
- return `${packageName}${path}/${namePath}`;
19
+ const finalPath = safePath.startsWith("/") ? safePath : `/${safePath}`;
20
+ return `${packageName}${finalPath}/${namePath}`;
18
21
  }
19
22
  const componentDependencyMap = {
20
23
  YuFrameworkAttachmentUpload: ["EleUploadList"]
@@ -28,25 +31,38 @@ Object.values(componentDependencyMap).forEach((children) => {
28
31
  children.forEach((child) => allNeedResolveComponents.add(child));
29
32
  });
30
33
  function generateComponentResolveConfig(name, options) {
31
- const { path = "/es", exclude = [] } = options || {};
34
+ const {
35
+ path = "/es",
36
+ exclude = []
37
+ } = options || {};
32
38
  const packageName = "yuang-framework-ui-pc";
33
- 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();
34
40
  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
- };
41
+ let fromPath = "";
42
+ if (["", "/es/core", "/lib/core"].includes(path)) {
43
+ fromPath = `${packageName}${path || "/es"}`;
42
44
  } else {
43
- return {
44
- name,
45
- // 关键修复:补充name字段,符合解析配置规范
46
- from: `${packageName}${path}/${namePath}/index`,
47
- sideEffects: getSideEffects(stylePath, options)
48
- };
45
+ fromPath = `${packageName}${path.startsWith("/") ? path : "/" + path}/${namePath}/index`;
49
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;
50
66
  }
51
67
  function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
52
68
  return {
@@ -54,14 +70,21 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
54
70
  resolve: (name) => {
55
71
  const { exclude = [] } = options;
56
72
  const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name) && allNeedResolveComponents.has(name);
57
- console.log(`按需加载插件: ${name},是否匹配:${isMatch}`);
73
+ console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
58
74
  if (isMatch) {
59
75
  const currentConfig = generateComponentResolveConfig(name, options);
76
+ if (currentConfig.from.includes("undefined")) {
77
+ console.error(`[当前组件错误] ${name} 的from路径异常: ${currentConfig.from}`);
78
+ }
60
79
  const dependencyList = componentDependencyMap[name];
61
80
  if (dependencyList && dependencyList.length) {
62
- const dependencyConfigs = dependencyList.map(
63
- (depName) => generateComponentResolveConfig(depName, options)
64
- );
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
+ });
65
88
  return [currentConfig, ...dependencyConfigs];
66
89
  }
67
90
  return currentConfig;
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 按需加载插件(修复依赖组件解析问题 + 路径undefined问题)
15
+ * 按需加载插件(彻底修复undefined路径问题)
16
16
  * @param options 参数
17
17
  */
18
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-pc",
3
- "version": "1.1.90",
3
+ "version": "1.1.91",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host --config vite.global.ts --mode dev",