@plumeria/compiler 16.5.0 → 17.0.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.d.ts CHANGED
@@ -2,6 +2,7 @@ interface CompilerOptions {
2
2
  include: string[];
3
3
  exclude: string[];
4
4
  cwd?: string;
5
+ styleProp?: string;
5
6
  }
6
7
  export declare function compileCSS(options: CompilerOptions): string;
7
8
  export {};
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
- JSXAttribute({ node }) {
840
+ JSXOpeningElement({ node }) {
841
841
  if (node.name.type !== 'Identifier')
842
842
  return;
843
- const attrName = node.name.value;
844
- if (attrName !== 'styleName') {
845
- if (node.value &&
846
- node.value.type === 'JSXExpressionContainer' &&
847
- node.value.expression.type !== 'JSXEmptyExpression') {
848
- let expr = node.value.expression;
849
- if (utils_1.t.isIdentifier(expr) && localStyleAliases[expr.value]) {
850
- expr = localStyleAliases[expr.value];
851
- }
852
- const styles = extractStylesFromExpression(expr, ctx);
853
- styles.forEach(processStyle);
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": "16.5.0",
3
+ "version": "17.0.1",
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.5.0"
24
+ "@plumeria/utils": "^17.0.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rust-gear/glob": "1.1.0",