yuang-framework-ui-pc 1.1.87 → 1.1.89

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
- * 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
15
+ * 按需加载插件(修复依赖组件解析问题)
16
16
  * @param options 参数
17
17
  */
18
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
@@ -22,48 +22,51 @@ function getStylePath(namePath, packageName, path) {
22
22
  }
23
23
  const componentDependencyMap = {
24
24
  YuFrameworkAttachmentUpload: ["EleUploadList"]
25
- // 你的核心依赖:上传组件依赖文件列表组件
26
- // 后续如果有其他组件有内部依赖,直接加在这里即可,比如:
27
- // EleForm: ['EleInput', 'EleSelect', 'EleButton']
25
+ // 可继续添加其他依赖:
26
+ // EleTable: ['EleTableColumn'],
27
+ // EleForm: ['EleFormItem', 'EleInput']
28
28
  };
29
+ const allNeedResolveComponents = /* @__PURE__ */ new Set();
30
+ Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
31
+ Object.values(componentDependencyMap).forEach((children) => {
32
+ children.forEach((child) => allNeedResolveComponents.add(child));
33
+ });
34
+ function generateComponentResolveConfig(name, options) {
35
+ const { path, exclude } = options || {};
36
+ const packageName = "yuang-framework-ui-pc";
37
+ const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
38
+ const stylePath = getStylePath(namePath, packageName, path);
39
+ if (!path || path === "/es/core" || path === "/lib/core") {
40
+ return {
41
+ name,
42
+ from: `${packageName}${path ?? "/es"}`,
43
+ sideEffects: getSideEffects(stylePath, options)
44
+ };
45
+ } else {
46
+ return {
47
+ from: `${packageName}${path}/${namePath}/index`,
48
+ sideEffects: getSideEffects(stylePath, options)
49
+ };
50
+ }
51
+ }
29
52
  function EleAdminResolver(options) {
30
53
  return {
31
54
  type: "component",
32
55
  resolve: (name) => {
33
56
  var _a;
34
- const { path, exclude } = options || {};
35
- const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
57
+ const { exclude } = options || {};
58
+ const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name)) && allNeedResolveComponents.has(name);
36
59
  console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
37
60
  if (isMatch) {
38
- const packageName = "yuang-framework-ui-pc";
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
- }
61
+ const currentConfig = generateComponentResolveConfig(name, options);
54
62
  const dependencyList = componentDependencyMap[name];
55
63
  if (dependencyList && dependencyList.length) {
56
- resolveResult.imports = dependencyList.map((depName) => {
57
- const dependencyPath = depName.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
58
- const dependencyStylePath = getStylePath(dependencyPath, packageName, path);
59
- return {
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
- });
64
+ const dependencyConfigs = dependencyList.map(
65
+ (depName) => generateComponentResolveConfig(depName, options)
66
+ );
67
+ return [currentConfig, ...dependencyConfigs];
65
68
  }
66
- return resolveResult;
69
+ return currentConfig;
67
70
  }
68
71
  }
69
72
  };
@@ -24,48 +24,51 @@ function getStylePath(namePath, packageName, path) {
24
24
  }
25
25
  const componentDependencyMap = {
26
26
  YuFrameworkAttachmentUpload: ["EleUploadList"]
27
- // 你的核心依赖:上传组件依赖文件列表组件
28
- // 后续如果有其他组件有内部依赖,直接加在这里即可,比如:
29
- // EleForm: ['EleInput', 'EleSelect', 'EleButton']
27
+ // 可继续添加其他依赖:
28
+ // EleTable: ['EleTableColumn'],
29
+ // EleForm: ['EleFormItem', 'EleInput']
30
30
  };
31
+ const allNeedResolveComponents = /* @__PURE__ */ new Set();
32
+ Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
33
+ Object.values(componentDependencyMap).forEach((children) => {
34
+ children.forEach((child) => allNeedResolveComponents.add(child));
35
+ });
36
+ function generateComponentResolveConfig(name, options) {
37
+ const { path, exclude } = options || {};
38
+ const packageName = "yuang-framework-ui-pc";
39
+ const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
40
+ const stylePath = getStylePath(namePath, packageName, path);
41
+ if (!path || path === "/es/core" || path === "/lib/core") {
42
+ return {
43
+ name,
44
+ from: `${packageName}${path ?? "/es"}`,
45
+ sideEffects: getSideEffects(stylePath, options)
46
+ };
47
+ } else {
48
+ return {
49
+ from: `${packageName}${path}/${namePath}/index`,
50
+ sideEffects: getSideEffects(stylePath, options)
51
+ };
52
+ }
53
+ }
31
54
  function EleAdminResolver(options) {
32
55
  return {
33
56
  type: "component",
34
57
  resolve: (name) => {
35
58
  var _a;
36
- const { path, exclude } = options || {};
37
- const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name));
59
+ const { exclude } = options || {};
60
+ const isMatch = /^(Ele|Yu)/.test(name) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name)) && allNeedResolveComponents.has(name);
38
61
  console.log("按需加载插件:" + name + ",是否匹配:" + isMatch);
39
62
  if (isMatch) {
40
- const packageName = "yuang-framework-ui-pc";
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
- }
63
+ const currentConfig = generateComponentResolveConfig(name, options);
56
64
  const dependencyList = componentDependencyMap[name];
57
65
  if (dependencyList && dependencyList.length) {
58
- resolveResult.imports = dependencyList.map((depName) => {
59
- const dependencyPath = depName.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
60
- const dependencyStylePath = getStylePath(dependencyPath, packageName, path);
61
- return {
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
- });
66
+ const dependencyConfigs = dependencyList.map(
67
+ (depName) => generateComponentResolveConfig(depName, options)
68
+ );
69
+ return [currentConfig, ...dependencyConfigs];
67
70
  }
68
- return resolveResult;
71
+ return currentConfig;
69
72
  }
70
73
  }
71
74
  };
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-pc",
3
- "version": "1.1.87",
3
+ "version": "1.1.89",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host --config vite.global.ts --mode dev",