@plumeria/compiler 16.2.10 → 16.2.12

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.
Files changed (2) hide show
  1. package/dist/index.js +20 -0
  2. package/package.json +3 -3
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.2.10",
3
+ "version": "16.2.12",
4
4
  "description": "Plumeria swc based compiler for statically extracting css",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -21,12 +21,12 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@plumeria/utils": "^16.2.10"
24
+ "@plumeria/utils": "^16.2.12"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rust-gear/glob": "1.1.0",
28
28
  "@swc/core": "1.15.43",
29
- "zss-engine": "2.3.0"
29
+ "zss-engine": "2.3.2"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public",