g-ui-web 1.4.37 → 1.4.39
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/lib/g-ui-web.cjs +158 -72
- package/lib/g-ui-web.iife.js +159 -73
- package/lib/g-ui-web.iife.js.gz +0 -0
- package/lib/g-ui-web.js +82008 -61490
- package/lib/g-ui-web.js.gz +0 -0
- package/lib/g-ui-web.umd.cjs +159 -73
- package/lib/plugins/index.cjs +19 -10
- package/lib/plugins/index.mjs +19 -10
- package/package.json +1 -1
package/lib/plugins/index.cjs
CHANGED
|
@@ -88,6 +88,8 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// packages/plugins/component-usage.ts
|
|
91
|
+
var import_compiler_sfc = require("@vue/compiler-sfc");
|
|
92
|
+
var import_compiler_dom = require("@vue/compiler-dom");
|
|
91
93
|
function componentUsagePlugin(options = {}) {
|
|
92
94
|
const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
|
|
93
95
|
const importStats = {
|
|
@@ -161,14 +163,21 @@ function componentUsagePlugin(options = {}) {
|
|
|
161
163
|
});
|
|
162
164
|
}
|
|
163
165
|
if (id.endsWith(".vue")) {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
const { descriptor } = (0, import_compiler_sfc.parse)(code);
|
|
167
|
+
if (descriptor.template?.ast) {
|
|
168
|
+
const walkNode = (node) => {
|
|
169
|
+
if (node.type === import_compiler_dom.NodeTypes.ELEMENT && node.tag?.startsWith("g-")) {
|
|
170
|
+
const tag = node.tag;
|
|
171
|
+
const currentCount = importStats.componentCount.get(tag) || 0;
|
|
172
|
+
importStats.componentCount.set(tag, currentCount + 1);
|
|
173
|
+
componentsInFile.push(tag);
|
|
174
|
+
importStats.totalImports++;
|
|
175
|
+
}
|
|
176
|
+
if (Array.isArray(node.children)) {
|
|
177
|
+
node.children.forEach(walkNode);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
descriptor.template.ast.children.forEach(walkNode);
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
183
|
if (componentsInFile.length > 0) {
|
|
@@ -180,8 +189,8 @@ function componentUsagePlugin(options = {}) {
|
|
|
180
189
|
}
|
|
181
190
|
return null;
|
|
182
191
|
},
|
|
183
|
-
//
|
|
184
|
-
async
|
|
192
|
+
// 整个构建完全结束后再统计和上报,确保所有文件都已处理
|
|
193
|
+
async closeBundle() {
|
|
185
194
|
if (!isBuild && !enableInDev) return;
|
|
186
195
|
if (hasReported) return;
|
|
187
196
|
hasReported = true;
|
package/lib/plugins/index.mjs
CHANGED
|
@@ -62,6 +62,8 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
// packages/plugins/component-usage.ts
|
|
65
|
+
import { parse as parseSFC } from "@vue/compiler-sfc";
|
|
66
|
+
import { NodeTypes } from "@vue/compiler-dom";
|
|
65
67
|
function componentUsagePlugin(options = {}) {
|
|
66
68
|
const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
|
|
67
69
|
const importStats = {
|
|
@@ -135,14 +137,21 @@ function componentUsagePlugin(options = {}) {
|
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
139
|
if (id.endsWith(".vue")) {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
const { descriptor } = parseSFC(code);
|
|
141
|
+
if (descriptor.template?.ast) {
|
|
142
|
+
const walkNode = (node) => {
|
|
143
|
+
if (node.type === NodeTypes.ELEMENT && node.tag?.startsWith("g-")) {
|
|
144
|
+
const tag = node.tag;
|
|
145
|
+
const currentCount = importStats.componentCount.get(tag) || 0;
|
|
146
|
+
importStats.componentCount.set(tag, currentCount + 1);
|
|
147
|
+
componentsInFile.push(tag);
|
|
148
|
+
importStats.totalImports++;
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(node.children)) {
|
|
151
|
+
node.children.forEach(walkNode);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
descriptor.template.ast.children.forEach(walkNode);
|
|
146
155
|
}
|
|
147
156
|
}
|
|
148
157
|
if (componentsInFile.length > 0) {
|
|
@@ -154,8 +163,8 @@ function componentUsagePlugin(options = {}) {
|
|
|
154
163
|
}
|
|
155
164
|
return null;
|
|
156
165
|
},
|
|
157
|
-
//
|
|
158
|
-
async
|
|
166
|
+
// 整个构建完全结束后再统计和上报,确保所有文件都已处理
|
|
167
|
+
async closeBundle() {
|
|
159
168
|
if (!isBuild && !enableInDev) return;
|
|
160
169
|
if (hasReported) return;
|
|
161
170
|
hasReported = true;
|