@plumeria/compiler 16.5.0 → 17.0.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.d.ts +1 -0
- package/dist/index.js +27 -14
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -138,7 +138,7 @@ function extractStylesFromExpression(expression, ctx) {
|
|
|
138
138
|
return results;
|
|
139
139
|
}
|
|
140
140
|
function compileCSS(options) {
|
|
141
|
-
const { include, exclude, cwd = process.cwd() } = options;
|
|
141
|
+
const { include, exclude, cwd = process.cwd(), styleProp = utils_1.DEFAULT_STYLE_PROP, } = options;
|
|
142
142
|
const allSheets = new Set();
|
|
143
143
|
const files = rs.globSync(include, {
|
|
144
144
|
cwd,
|
|
@@ -837,23 +837,36 @@ function compileCSS(options) {
|
|
|
837
837
|
if (!processedNodes.has(path.node))
|
|
838
838
|
processCall(path.node);
|
|
839
839
|
},
|
|
840
|
-
|
|
840
|
+
JSXOpeningElement({ node }) {
|
|
841
841
|
if (node.name.type !== 'Identifier')
|
|
842
842
|
return;
|
|
843
|
-
const
|
|
844
|
-
if (
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
843
|
+
const tagName = node.name.value;
|
|
844
|
+
if (tagName[0] !== tagName[0].toUpperCase())
|
|
845
|
+
return;
|
|
846
|
+
node.attributes.forEach((attr) => {
|
|
847
|
+
if (attr.type !== 'JSXAttribute')
|
|
848
|
+
return;
|
|
849
|
+
if (attr.name.type !== 'Identifier')
|
|
850
|
+
return;
|
|
851
|
+
if (attr.name.value === styleProp)
|
|
852
|
+
return;
|
|
853
|
+
const value = attr.value;
|
|
854
|
+
if (!value || value.type !== 'JSXExpressionContainer')
|
|
855
|
+
return;
|
|
856
|
+
if (value.expression.type === 'JSXEmptyExpression')
|
|
857
|
+
return;
|
|
858
|
+
let expr = value.expression;
|
|
859
|
+
if (utils_1.t.isIdentifier(expr) && localStyleAliases[expr.value]) {
|
|
860
|
+
expr = localStyleAliases[expr.value];
|
|
854
861
|
}
|
|
862
|
+
extractStylesFromExpression(expr, ctx).forEach(processStyle);
|
|
863
|
+
});
|
|
864
|
+
},
|
|
865
|
+
JSXAttribute({ node }) {
|
|
866
|
+
if (node.name.type !== 'Identifier')
|
|
867
|
+
return;
|
|
868
|
+
if (node.name.value !== styleProp)
|
|
855
869
|
return;
|
|
856
|
-
}
|
|
857
870
|
if (!node.value || node.value.type !== 'JSXExpressionContainer')
|
|
858
871
|
return;
|
|
859
872
|
if (node.value.expression.type === 'JSXEmptyExpression')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.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": "^
|
|
24
|
+
"@plumeria/utils": "^17.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rust-gear/glob": "1.1.0",
|