@plumeria/webpack-plugin 6.0.2 → 6.1.1
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 +101 -35
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41,9 +41,26 @@ function loader(source) {
|
|
|
41
41
|
const localConsts = (0, utils_1.collectLocalConsts)(ast);
|
|
42
42
|
const resourcePath = this.resourcePath;
|
|
43
43
|
const importMap = {};
|
|
44
|
+
const plumeriaAliases = {};
|
|
44
45
|
(0, utils_1.traverse)(ast, {
|
|
45
46
|
ImportDeclaration({ node }) {
|
|
46
47
|
const sourcePath = node.source.value;
|
|
48
|
+
if (sourcePath === '@plumeria/core') {
|
|
49
|
+
node.specifiers.forEach((specifier) => {
|
|
50
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
51
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
52
|
+
}
|
|
53
|
+
else if (specifier.type === 'ImportDefaultSpecifier') {
|
|
54
|
+
plumeriaAliases[specifier.local.value] = 'NAMESPACE';
|
|
55
|
+
}
|
|
56
|
+
else if (specifier.type === 'ImportSpecifier') {
|
|
57
|
+
const importedName = specifier.imported
|
|
58
|
+
? specifier.imported.value
|
|
59
|
+
: specifier.local.value;
|
|
60
|
+
plumeriaAliases[specifier.local.value] = importedName;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
47
64
|
const actualPath = (0, utils_1.resolveImportPath)(sourcePath, resourcePath);
|
|
48
65
|
if (actualPath) {
|
|
49
66
|
node.specifiers.forEach((specifier) => {
|
|
@@ -134,6 +151,9 @@ function loader(source) {
|
|
|
134
151
|
const processedDecls = new Set();
|
|
135
152
|
const idSpans = new Set();
|
|
136
153
|
const excludedSpans = new Set();
|
|
154
|
+
if (scannedTables.extractedSheet) {
|
|
155
|
+
addSheet(scannedTables.extractedSheet);
|
|
156
|
+
}
|
|
137
157
|
const checkVariantAssignment = (decl) => {
|
|
138
158
|
if (decl.init &&
|
|
139
159
|
utils_1.t.isCallExpression(decl.init) &&
|
|
@@ -147,14 +167,31 @@ function loader(source) {
|
|
|
147
167
|
}
|
|
148
168
|
};
|
|
149
169
|
const registerStyle = (node, declSpan, isExported) => {
|
|
170
|
+
let propName;
|
|
150
171
|
if (utils_1.t.isIdentifier(node.id) &&
|
|
151
172
|
node.init &&
|
|
152
173
|
utils_1.t.isCallExpression(node.init) &&
|
|
153
|
-
utils_1.t.isMemberExpression(node.init.callee) &&
|
|
154
|
-
utils_1.t.isIdentifier(node.init.callee.object, { name: 'css' }) &&
|
|
155
|
-
utils_1.t.isIdentifier(node.init.callee.property) &&
|
|
156
174
|
node.init.arguments.length >= 1) {
|
|
157
|
-
const
|
|
175
|
+
const callee = node.init.callee;
|
|
176
|
+
if (utils_1.t.isMemberExpression(callee) &&
|
|
177
|
+
utils_1.t.isIdentifier(callee.object) &&
|
|
178
|
+
utils_1.t.isIdentifier(callee.property)) {
|
|
179
|
+
const objectName = callee.object.value;
|
|
180
|
+
const propertyName = callee.property.value;
|
|
181
|
+
const alias = plumeriaAliases[objectName];
|
|
182
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
183
|
+
propName = propertyName;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else if (utils_1.t.isIdentifier(callee)) {
|
|
187
|
+
const calleeName = callee.value;
|
|
188
|
+
const originalName = plumeriaAliases[calleeName];
|
|
189
|
+
if (originalName) {
|
|
190
|
+
propName = originalName;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (propName) {
|
|
158
195
|
if (propName === 'create' &&
|
|
159
196
|
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
160
197
|
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable, mergedCreateTable, mergedVariantsTable);
|
|
@@ -275,10 +312,25 @@ function loader(source) {
|
|
|
275
312
|
},
|
|
276
313
|
CallExpression({ node }) {
|
|
277
314
|
const callee = node.callee;
|
|
315
|
+
let propName;
|
|
278
316
|
if (utils_1.t.isMemberExpression(callee) &&
|
|
279
|
-
utils_1.t.isIdentifier(callee.object
|
|
317
|
+
utils_1.t.isIdentifier(callee.object) &&
|
|
280
318
|
utils_1.t.isIdentifier(callee.property)) {
|
|
281
|
-
const
|
|
319
|
+
const objectName = callee.object.value;
|
|
320
|
+
const propertyName = callee.property.value;
|
|
321
|
+
const alias = plumeriaAliases[objectName];
|
|
322
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
323
|
+
propName = propertyName;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else if (utils_1.t.isIdentifier(callee)) {
|
|
327
|
+
const calleeName = callee.value;
|
|
328
|
+
const originalName = plumeriaAliases[calleeName];
|
|
329
|
+
if (originalName) {
|
|
330
|
+
propName = originalName;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (propName) {
|
|
282
334
|
const args = node.arguments;
|
|
283
335
|
if (propName === 'keyframes' &&
|
|
284
336
|
args.length > 0 &&
|
|
@@ -339,48 +391,62 @@ function loader(source) {
|
|
|
339
391
|
if (utils_1.t.isIdentifier(node.object) && utils_1.t.isIdentifier(node.property)) {
|
|
340
392
|
const varName = node.object.value;
|
|
341
393
|
const propName = node.property.value;
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
394
|
+
const uniqueKey = `${this.resourcePath}-${varName}`;
|
|
395
|
+
let hash = scannedTables.createHashTable[uniqueKey];
|
|
396
|
+
if (!hash) {
|
|
397
|
+
hash = mergedCreateTable[varName];
|
|
398
|
+
}
|
|
399
|
+
if (!hash) {
|
|
400
|
+
const styleInfo = localCreateStyles[varName];
|
|
401
|
+
if (styleInfo) {
|
|
402
|
+
const atomMap = styleInfo.hashMap[propName];
|
|
403
|
+
if (atomMap) {
|
|
404
|
+
replacements.push({
|
|
405
|
+
start: node.span.start - ast.span.start,
|
|
406
|
+
end: node.span.end - ast.span.start,
|
|
407
|
+
content: JSON.stringify(atomMap),
|
|
408
|
+
});
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (hash) {
|
|
414
|
+
let atomMap;
|
|
415
|
+
if (scannedTables.createAtomicMapTable[hash]) {
|
|
416
|
+
atomMap = scannedTables.createAtomicMapTable[hash][propName];
|
|
417
|
+
}
|
|
345
418
|
if (atomMap) {
|
|
346
419
|
replacements.push({
|
|
347
420
|
start: node.span.start - ast.span.start,
|
|
348
421
|
end: node.span.end - ast.span.start,
|
|
349
422
|
content: JSON.stringify(atomMap),
|
|
350
423
|
});
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const hash = mergedCreateTable[varName];
|
|
355
|
-
if (hash) {
|
|
356
|
-
const obj = scannedTables.createObjectTable[hash];
|
|
357
|
-
if (obj && obj[propName]) {
|
|
358
|
-
const style = obj[propName];
|
|
359
|
-
if (typeof style === 'object' && style !== null) {
|
|
360
|
-
const records = (0, utils_1.getStyleRecords)(propName, style, 2);
|
|
361
|
-
if (!isProduction) {
|
|
362
|
-
(0, utils_1.extractOndemandStyles)(style, extractedSheets, scannedTables);
|
|
363
|
-
records.forEach((r) => addSheet(r.sheet));
|
|
364
|
-
}
|
|
365
|
-
const atomMap = {};
|
|
366
|
-
records.forEach((r) => (atomMap[r.key] = r.hash));
|
|
367
|
-
if (Object.keys(atomMap).length > 0) {
|
|
368
|
-
replacements.push({
|
|
369
|
-
start: node.span.start - ast.span.start,
|
|
370
|
-
end: node.span.end - ast.span.start,
|
|
371
|
-
content: JSON.stringify(atomMap),
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
424
|
}
|
|
376
425
|
}
|
|
377
426
|
}
|
|
378
427
|
},
|
|
379
428
|
CallExpression({ node }) {
|
|
380
429
|
const callee = node.callee;
|
|
430
|
+
let isPropsCall = false;
|
|
381
431
|
if (utils_1.t.isMemberExpression(callee) &&
|
|
382
|
-
utils_1.t.isIdentifier(callee.object
|
|
383
|
-
utils_1.t.isIdentifier(callee.property
|
|
432
|
+
utils_1.t.isIdentifier(callee.object) &&
|
|
433
|
+
utils_1.t.isIdentifier(callee.property)) {
|
|
434
|
+
const objectName = callee.object.value;
|
|
435
|
+
const propertyName = callee.property.value;
|
|
436
|
+
const alias = plumeriaAliases[objectName];
|
|
437
|
+
if ((alias === 'NAMESPACE' || objectName === 'css') &&
|
|
438
|
+
propertyName === 'props') {
|
|
439
|
+
isPropsCall = true;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else if (utils_1.t.isIdentifier(callee)) {
|
|
443
|
+
const calleeName = callee.value;
|
|
444
|
+
const originalName = plumeriaAliases[calleeName];
|
|
445
|
+
if (originalName === 'props') {
|
|
446
|
+
isPropsCall = true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (isPropsCall) {
|
|
384
450
|
const args = node.arguments;
|
|
385
451
|
const resolveStyleObject = (expr) => {
|
|
386
452
|
if (utils_1.t.isObjectExpression(expr)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
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": "^6.
|
|
25
|
+
"@plumeria/utils": "^6.1.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|