@plumeria/unplugin 18.3.4 → 18.3.5
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/core.js +8 -6
- package/dist/core.mjs +9 -7
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -618,10 +618,11 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
618
618
|
if (utils_1.t.isIdentifier(node.id)) {
|
|
619
619
|
idSpans.add(node.id.span.start);
|
|
620
620
|
}
|
|
621
|
-
let selector = '';
|
|
622
621
|
const selectorExpr = init.arguments[0].expression;
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
const selector = (0, utils_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
623
|
+
if (!selector) {
|
|
624
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
625
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
625
626
|
}
|
|
626
627
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
627
628
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
@@ -800,10 +801,11 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
800
801
|
else if (propName === 'createTheme' &&
|
|
801
802
|
args.length >= 2 &&
|
|
802
803
|
utils_1.t.isObjectExpression(args[1].expression)) {
|
|
803
|
-
let selector = '';
|
|
804
804
|
const selectorExpr = args[0].expression;
|
|
805
|
-
|
|
806
|
-
|
|
805
|
+
const selector = (0, utils_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
806
|
+
if (!selector) {
|
|
807
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
808
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
807
809
|
}
|
|
808
810
|
if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
|
|
809
811
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
package/dist/core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createFilter } from '@rollup/pluginutils';
|
|
|
2
2
|
import { parseSync } from '@swc/core';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { applyCssValue, genBase36Hash, exceptionCamelCase, camelToKebabCase, isAtRule, } from 'zss-engine';
|
|
5
|
-
import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, themeHashOf, getFileDependencies, resolveExport, resolveComponentKey, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
5
|
+
import { traverse, collectReferenceIdentifiers, getStyleRecords, getStateWeights, collectLocalConsts, objectExpressionToObject, t, getRootIdentifier, extractOndemandStyles, deepMerge, scanAll, resolveImportPath, getLeadingCommentLength, optimizer, themeHashOf, getFileDependencies, resolveExport, resolveComponentKey, resolveThemeSelector, DEFAULT_STYLE_PROP, } from '@plumeria/utils';
|
|
6
6
|
export const TARGET_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
|
|
7
7
|
export const EXTENSION_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
8
8
|
const isStaticArgValue = (node) => node.type === 'StringLiteral' ||
|
|
@@ -582,10 +582,11 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
582
582
|
if (t.isIdentifier(node.id)) {
|
|
583
583
|
idSpans.add(node.id.span.start);
|
|
584
584
|
}
|
|
585
|
-
let selector = '';
|
|
586
585
|
const selectorExpr = init.arguments[0].expression;
|
|
587
|
-
|
|
588
|
-
|
|
586
|
+
const selector = resolveThemeSelector(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
587
|
+
if (!selector) {
|
|
588
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
589
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
589
590
|
}
|
|
590
591
|
if (selector.startsWith('@') && !isAtRule(selector)) {
|
|
591
592
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
|
@@ -764,10 +765,11 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
764
765
|
else if (propName === 'createTheme' &&
|
|
765
766
|
args.length >= 2 &&
|
|
766
767
|
t.isObjectExpression(args[1].expression)) {
|
|
767
|
-
let selector = '';
|
|
768
768
|
const selectorExpr = args[0].expression;
|
|
769
|
-
|
|
770
|
-
|
|
769
|
+
const selector = resolveThemeSelector(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
|
|
770
|
+
if (!selector) {
|
|
771
|
+
throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
|
|
772
|
+
`Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
|
|
771
773
|
}
|
|
772
774
|
if (selector.startsWith('@') && !isAtRule(selector)) {
|
|
773
775
|
throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.5",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@rollup/pluginutils": "^5.4.0",
|
|
96
96
|
"unplugin": "^3.0.0",
|
|
97
|
-
"@plumeria/utils": "^18.3.
|
|
97
|
+
"@plumeria/utils": "^18.3.5"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@swc/core": "1.15.47",
|