@plumeria/webpack-plugin 6.0.2 → 6.1.0
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 +74 -8
- 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) => {
|
|
@@ -147,14 +164,31 @@ function loader(source) {
|
|
|
147
164
|
}
|
|
148
165
|
};
|
|
149
166
|
const registerStyle = (node, declSpan, isExported) => {
|
|
167
|
+
let propName;
|
|
150
168
|
if (utils_1.t.isIdentifier(node.id) &&
|
|
151
169
|
node.init &&
|
|
152
170
|
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
171
|
node.init.arguments.length >= 1) {
|
|
157
|
-
const
|
|
172
|
+
const callee = node.init.callee;
|
|
173
|
+
if (utils_1.t.isMemberExpression(callee) &&
|
|
174
|
+
utils_1.t.isIdentifier(callee.object) &&
|
|
175
|
+
utils_1.t.isIdentifier(callee.property)) {
|
|
176
|
+
const objectName = callee.object.value;
|
|
177
|
+
const propertyName = callee.property.value;
|
|
178
|
+
const alias = plumeriaAliases[objectName];
|
|
179
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
180
|
+
propName = propertyName;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (utils_1.t.isIdentifier(callee)) {
|
|
184
|
+
const calleeName = callee.value;
|
|
185
|
+
const originalName = plumeriaAliases[calleeName];
|
|
186
|
+
if (originalName) {
|
|
187
|
+
propName = originalName;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (propName) {
|
|
158
192
|
if (propName === 'create' &&
|
|
159
193
|
utils_1.t.isObjectExpression(node.init.arguments[0].expression)) {
|
|
160
194
|
const obj = (0, utils_1.objectExpressionToObject)(node.init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedThemeTable, mergedCreateTable, mergedVariantsTable);
|
|
@@ -275,10 +309,25 @@ function loader(source) {
|
|
|
275
309
|
},
|
|
276
310
|
CallExpression({ node }) {
|
|
277
311
|
const callee = node.callee;
|
|
312
|
+
let propName;
|
|
278
313
|
if (utils_1.t.isMemberExpression(callee) &&
|
|
279
|
-
utils_1.t.isIdentifier(callee.object
|
|
314
|
+
utils_1.t.isIdentifier(callee.object) &&
|
|
280
315
|
utils_1.t.isIdentifier(callee.property)) {
|
|
281
|
-
const
|
|
316
|
+
const objectName = callee.object.value;
|
|
317
|
+
const propertyName = callee.property.value;
|
|
318
|
+
const alias = plumeriaAliases[objectName];
|
|
319
|
+
if (alias === 'NAMESPACE' || objectName === 'css') {
|
|
320
|
+
propName = propertyName;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (utils_1.t.isIdentifier(callee)) {
|
|
324
|
+
const calleeName = callee.value;
|
|
325
|
+
const originalName = plumeriaAliases[calleeName];
|
|
326
|
+
if (originalName) {
|
|
327
|
+
propName = originalName;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (propName) {
|
|
282
331
|
const args = node.arguments;
|
|
283
332
|
if (propName === 'keyframes' &&
|
|
284
333
|
args.length > 0 &&
|
|
@@ -378,9 +427,26 @@ function loader(source) {
|
|
|
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.0
|
|
3
|
+
"version": "6.1.0",
|
|
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.0
|
|
25
|
+
"@plumeria/utils": "^6.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@swc/core": "1.15.8",
|