@plumeria/compiler 18.5.1 → 18.5.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 +13 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -91,11 +91,10 @@ const destructuredPropAliases = (fn) => {
|
|
|
91
91
|
if (pattern?.type !== 'ObjectPattern')
|
|
92
92
|
return aliases;
|
|
93
93
|
for (const item of pattern.properties ?? []) {
|
|
94
|
-
if (item.type !== 'KeyValuePatternProperty'
|
|
95
|
-
item.type !== 'AssignmentPatternProperty')
|
|
94
|
+
if (item.type !== 'KeyValuePatternProperty')
|
|
96
95
|
continue;
|
|
96
|
+
const local = unwrapPatternDefault(item.value);
|
|
97
97
|
const key = item.key;
|
|
98
|
-
const local = unwrapPatternDefault(item.value) ?? key;
|
|
99
98
|
if (!utils_1.t.isIdentifier(local))
|
|
100
99
|
continue;
|
|
101
100
|
if (!utils_1.t.isIdentifier(key) && !utils_1.t.isStringLiteral(key))
|
|
@@ -109,6 +108,11 @@ const destructuredPropAliases = (fn) => {
|
|
|
109
108
|
const sourceOf = (node, sourceBuffer, baseByteOffset) => sourceBuffer
|
|
110
109
|
.subarray(node.span.start - baseByteOffset, node.span.end - baseByteOffset)
|
|
111
110
|
.toString('utf-8');
|
|
111
|
+
const isNoOpStyle = (node) => utils_1.t.isNullLiteral(node) ||
|
|
112
|
+
(utils_1.t.isBooleanLiteral(node) && node.value === false) ||
|
|
113
|
+
(utils_1.t.isIdentifier(node) && node.value === 'undefined');
|
|
114
|
+
const propDefaultError = (source, fileName) => new Error(`[plumeria] A style prop default must be a defined style: "${source}". ` +
|
|
115
|
+
`Apply a conditional or dynamic style where the element is styled. (${fileName})`);
|
|
112
116
|
const spreadStyleError = (source, fileName) => new Error(`[plumeria] Spread elements in a style array are not supported: "...${source}". ` +
|
|
113
117
|
`List each style explicitly. (${fileName})`);
|
|
114
118
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
@@ -760,8 +764,12 @@ function compileCSS(options) {
|
|
|
760
764
|
}
|
|
761
765
|
}
|
|
762
766
|
const fallback = owner && propDefaults.get(owner)?.get(propName);
|
|
763
|
-
if (fallback)
|
|
764
|
-
|
|
767
|
+
if (fallback && !isNoOpStyle((0, utils_1.unwrapExpression)(fallback))) {
|
|
768
|
+
const style = resolveStyleObject(fallback);
|
|
769
|
+
if (!style)
|
|
770
|
+
throw propDefaultError(getSource(fallback), path.basename(resourcePath));
|
|
771
|
+
processStyle(style);
|
|
772
|
+
}
|
|
765
773
|
if (possibilities.length > 0) {
|
|
766
774
|
const uniqueEntries = [];
|
|
767
775
|
possibilities.forEach((entry) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "18.5.
|
|
3
|
+
"version": "18.5.2",
|
|
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": "^18.5.
|
|
24
|
+
"@plumeria/utils": "^18.5.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rust-gear/glob": "1.1.1",
|