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.
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 按需加载插件:支持所有 Ele/Yu 开头的组件
15
+ * 按需加载插件,这里控制打包后的组件按需加载,如果匹配不上,会出现:开发环境组件正常显示,但是生产环境无法解析组件的情况
16
16
  * @param options 参数
17
17
  */
18
18
  export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
@@ -1,69 +1,49 @@
1
1
  function getSideEffects(path, options) {
2
- if (!path) return void 0;
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 void 0;
4
+ return;
6
5
  }
7
- return importStyle === "css" ? `${path}/style/css` : `${path}/style/index`;
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 `${packageName}/es/${namePath}`;
9
+ return `${path}/style/index`;
15
10
  }
16
- const componentDependencyMap = {
17
- YuFrameworkAttachmentUpload: ["EleUploadList"]
18
- // 后续有依赖的组件可继续加:EleTable: ['EleTableColumn']
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
- fromPath = fromPath.replace(/undefined/g, "").replace(/\/+/g, "/").replace(/^\/|\/$/g, "");
37
- if (!fromPath || fromPath === packageName) {
38
- fromPath = `${packageName}/es/${namePath}`;
15
+ if (path === "/es/core") {
16
+ return `${packageName}/es/${namePath}`;
39
17
  }
40
- const stylePath = getStylePath(namePath, packageName, safePath);
41
- const config = {
42
- name: name.trim(),
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 = { path: "/es", exclude: [], importStyle: true }) {
23
+ function EleAdminResolver(options) {
53
24
  return {
54
25
  type: "component",
55
26
  resolve: (name) => {
56
- const { exclude = [] } = options;
57
- const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name);
58
- console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
59
- if (!isMatch) return void 0;
60
- const currentConfig = generateComponentResolveConfig(name, options);
61
- const dependencyList = componentDependencyMap[name];
62
- if (dependencyList && dependencyList.length) {
63
- const dependencyConfigs = dependencyList.filter((depName) => !exclude.includes(depName)).map((depName) => generateComponentResolveConfig(depName, options));
64
- return [currentConfig, ...dependencyConfigs].filter(Boolean);
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
  }
@@ -1,71 +1,51 @@
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;
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 void 0;
6
+ return;
8
7
  }
9
- return importStyle === "css" ? `${path}/style/css` : `${path}/style/index`;
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 `${packageName}/es/${namePath}`;
11
+ return `${path}/style/index`;
17
12
  }
18
- const componentDependencyMap = {
19
- YuFrameworkAttachmentUpload: ["EleUploadList"]
20
- // 后续有依赖的组件可继续加:EleTable: ['EleTableColumn']
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
- fromPath = fromPath.replace(/undefined/g, "").replace(/\/+/g, "/").replace(/^\/|\/$/g, "");
39
- if (!fromPath || fromPath === packageName) {
40
- fromPath = `${packageName}/es/${namePath}`;
17
+ if (path === "/es/core") {
18
+ return `${packageName}/es/${namePath}`;
41
19
  }
42
- const stylePath = getStylePath(namePath, packageName, safePath);
43
- const config = {
44
- name: name.trim(),
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 = { path: "/es", exclude: [], importStyle: true }) {
25
+ function EleAdminResolver(options) {
55
26
  return {
56
27
  type: "component",
57
28
  resolve: (name) => {
58
- const { exclude = [] } = options;
59
- const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name);
60
- console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
61
- if (!isMatch) return void 0;
62
- const currentConfig = generateComponentResolveConfig(name, options);
63
- const dependencyList = componentDependencyMap[name];
64
- if (dependencyList && dependencyList.length) {
65
- const dependencyConfigs = dependencyList.filter((depName) => !exclude.includes(depName)).map((depName) => generateComponentResolveConfig(depName, options));
66
- return [currentConfig, ...dependencyConfigs].filter(Boolean);
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
  }
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
12
12
  importStyle?: boolean | 'css' | 'sass';
13
13
  }
14
14
  /**
15
- * 按需加载插件:支持所有 Ele/Yu 开头的组件
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.93",
3
+ "version": "1.1.95",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host --config vite.global.ts --mode dev",