@plumeria/webpack-plugin 4.1.0 → 4.1.2
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/dist/index.js +47 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -197,11 +197,10 @@ function loader(source) {
|
|
|
197
197
|
if (styleInfo && !styleInfo.hasDynamicAccess) {
|
|
198
198
|
const atomMap = styleInfo.hashMap[node.property.value];
|
|
199
199
|
if (atomMap) {
|
|
200
|
-
const combinedHash = Object.values(atomMap).join(' ');
|
|
201
200
|
replacements.push({
|
|
202
201
|
start: node.span.start - ast.span.start,
|
|
203
202
|
end: node.span.end - ast.span.start,
|
|
204
|
-
content: JSON.stringify(
|
|
203
|
+
content: JSON.stringify(atomMap),
|
|
205
204
|
});
|
|
206
205
|
}
|
|
207
206
|
}
|
|
@@ -252,7 +251,31 @@ function loader(source) {
|
|
|
252
251
|
}
|
|
253
252
|
return false;
|
|
254
253
|
};
|
|
254
|
+
const hasDynamicAccess = (expr) => {
|
|
255
|
+
if (utils_1.t.isMemberExpression(expr) && utils_1.t.isIdentifier(expr.object)) {
|
|
256
|
+
const info = localCreateStyles[expr.object.value];
|
|
257
|
+
if (info && info.hasDynamicAccess)
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
if (utils_1.t.isIdentifier(expr)) {
|
|
261
|
+
const info = localCreateStyles[expr.value];
|
|
262
|
+
if (info && info.hasDynamicAccess)
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
if (utils_1.t.isConditionalExpression(expr)) {
|
|
266
|
+
return (hasDynamicAccess(expr.consequent) ||
|
|
267
|
+
hasDynamicAccess(expr.alternate));
|
|
268
|
+
}
|
|
269
|
+
if (utils_1.t.isBinaryExpression(expr) &&
|
|
270
|
+
(expr.operator === '&&' ||
|
|
271
|
+
expr.operator === '||' ||
|
|
272
|
+
expr.operator === '??')) {
|
|
273
|
+
return hasDynamicAccess(expr.left) || hasDynamicAccess(expr.right);
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
};
|
|
255
277
|
const allStatic = args.every((arg) => checkStatic(arg.expression));
|
|
278
|
+
const anyDynamic = args.some((arg) => hasDynamicAccess(arg.expression));
|
|
256
279
|
if (allStatic && args.length > 0) {
|
|
257
280
|
const merged = args.reduce((acc, arg) => {
|
|
258
281
|
const expr = arg.expression;
|
|
@@ -289,6 +312,28 @@ function loader(source) {
|
|
|
289
312
|
});
|
|
290
313
|
}
|
|
291
314
|
}
|
|
315
|
+
else if (anyDynamic) {
|
|
316
|
+
const processExpr = (expr) => {
|
|
317
|
+
if (utils_1.t.isIdentifier(expr)) {
|
|
318
|
+
const info = localCreateStyles[expr.value];
|
|
319
|
+
if (info && info.hasDynamicAccess) {
|
|
320
|
+
excludedSpans.add(expr.span.start);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (utils_1.t.isConditionalExpression(expr)) {
|
|
324
|
+
processExpr(expr.consequent);
|
|
325
|
+
processExpr(expr.alternate);
|
|
326
|
+
}
|
|
327
|
+
else if (utils_1.t.isBinaryExpression(expr) &&
|
|
328
|
+
(expr.operator === '&&' ||
|
|
329
|
+
expr.operator === '||' ||
|
|
330
|
+
expr.operator === '??')) {
|
|
331
|
+
processExpr(expr.left);
|
|
332
|
+
processExpr(expr.right);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
args.forEach((arg) => processExpr(arg.expression));
|
|
336
|
+
}
|
|
292
337
|
else {
|
|
293
338
|
const processExpr = (expr) => {
|
|
294
339
|
if (utils_1.t.isMemberExpression(expr) &&
|
|
@@ -310,7 +355,6 @@ function loader(source) {
|
|
|
310
355
|
else if (utils_1.t.isIdentifier(expr)) {
|
|
311
356
|
const info = localCreateStyles[expr.value];
|
|
312
357
|
if (info) {
|
|
313
|
-
info.hasDynamicAccess = true;
|
|
314
358
|
excludedSpans.add(expr.span.start);
|
|
315
359
|
replacements.push({
|
|
316
360
|
start: expr.span.start - ast.span.start,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "Plumeria Webpack plugin",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"zero-virtual.css"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@plumeria/utils": "^4.1.
|
|
25
|
+
"@plumeria/utils": "^4.1.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|