@plumeria/compiler 16.2.11 → 16.3.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 +20 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -415,6 +415,24 @@ function compileCSS(options) {
|
|
|
415
415
|
const getSource = (node) => ctx.sourceBuffer
|
|
416
416
|
.subarray(node.span.start - ctx.baseByteOffset, node.span.end - ctx.baseByteOffset)
|
|
417
417
|
.toString('utf-8');
|
|
418
|
+
const assertResolvable = (node) => {
|
|
419
|
+
if (utils_1.t.isIdentifier(node) && node.value === 'undefined')
|
|
420
|
+
return;
|
|
421
|
+
if (utils_1.t.isMemberExpression(node) ||
|
|
422
|
+
utils_1.t.isIdentifier(node) ||
|
|
423
|
+
utils_1.t.isCallExpression(node) ||
|
|
424
|
+
utils_1.t.isArrowFunctionExpression(node) ||
|
|
425
|
+
utils_1.t.isFunctionExpression(node)) {
|
|
426
|
+
const rootId = (0, utils_1.getRootIdentifier)(node);
|
|
427
|
+
const isPlumeriaStyle = rootId &&
|
|
428
|
+
(ctx.localCreateStyles[rootId] !== undefined ||
|
|
429
|
+
ctx.mergedCreateTable[rootId] !== undefined ||
|
|
430
|
+
ctx.mergedVariantsTable[rootId] !== undefined);
|
|
431
|
+
if (!isPlumeriaStyle) {
|
|
432
|
+
throw new Error(`[plumeria] Dynamic or unresolvable style object "${getSource(node)}" is not supported. (${path.basename(resourcePath)})`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
418
436
|
const collectConditions = (node, currentTestStrings = []) => {
|
|
419
437
|
if (node.type === 'ConditionalExpression') {
|
|
420
438
|
const testSource = getSource(node.test);
|
|
@@ -468,6 +486,7 @@ function compileCSS(options) {
|
|
|
468
486
|
}
|
|
469
487
|
return true;
|
|
470
488
|
}
|
|
489
|
+
assertResolvable(node);
|
|
471
490
|
return false;
|
|
472
491
|
};
|
|
473
492
|
const checkFunctionKey = (node) => {
|
|
@@ -657,6 +676,7 @@ function compileCSS(options) {
|
|
|
657
676
|
}
|
|
658
677
|
if (collectConditions(arg.expression))
|
|
659
678
|
continue;
|
|
679
|
+
assertResolvable(expr);
|
|
660
680
|
const extractedStyles = extractStylesFromExpression(arg.expression, ctx);
|
|
661
681
|
extractedStyles.forEach(processStyle);
|
|
662
682
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0",
|
|
4
4
|
"description": "Plumeria swc based compiler for statically extracting css",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist/"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@plumeria/utils": "^16.
|
|
24
|
+
"@plumeria/utils": "^16.3.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rust-gear/glob": "1.1.0",
|