@csszyx/unplugin 0.10.10 → 0.10.11

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.
@@ -15,7 +15,7 @@ const unplugin$1 = require('unplugin');
15
15
  const cssMangler = require('../css-mangler.cjs');
16
16
  const htmlEscape = require('./unplugin.BCwRIUs_.cjs');
17
17
  const node_crypto = require('node:crypto');
18
- const transformCache = require('./unplugin.pmTknYLy.cjs');
18
+ const transformCache = require('./unplugin.D32Rb29j.cjs');
19
19
  const postcss = require('postcss');
20
20
  const valueParser = require('postcss-value-parser');
21
21
 
@@ -1026,6 +1026,8 @@ const EMPTY_THEME = {
1026
1026
  colors: [],
1027
1027
  spacings: [],
1028
1028
  fonts: [],
1029
+ textSizes: [],
1030
+ fontWeights: [],
1029
1031
  radii: [],
1030
1032
  shadows: [],
1031
1033
  breakpoints: []
@@ -1095,7 +1097,12 @@ function categorizeProperty(prop) {
1095
1097
  const categoryMap = [
1096
1098
  ["color-", "colors"],
1097
1099
  ["spacing-", "spacings"],
1100
+ // `font-weight-` MUST precede `font-`: startsWith would otherwise route
1101
+ // `font-weight-chunky` into font FAMILIES as token "weight-chunky".
1102
+ ["font-weight-", "fontWeights"],
1098
1103
  ["font-", "fonts"],
1104
+ // `--text-*` defines font-size utilities (text-huge) in Tailwind v4.
1105
+ ["text-", "textSizes"],
1099
1106
  ["radius-", "radii"],
1100
1107
  ["shadow-", "shadows"],
1101
1108
  ["breakpoint-", "breakpoints"]
@@ -1118,6 +1125,8 @@ function parseThemeBlocks(cssContent) {
1118
1125
  colors: /* @__PURE__ */ new Set(),
1119
1126
  spacings: /* @__PURE__ */ new Set(),
1120
1127
  fonts: /* @__PURE__ */ new Set(),
1128
+ textSizes: /* @__PURE__ */ new Set(),
1129
+ fontWeights: /* @__PURE__ */ new Set(),
1121
1130
  radii: /* @__PURE__ */ new Set(),
1122
1131
  shadows: /* @__PURE__ */ new Set(),
1123
1132
  breakpoints: /* @__PURE__ */ new Set()
@@ -1137,6 +1146,8 @@ function parseThemeBlocks(cssContent) {
1137
1146
  colors: htmlEscape.sortStrings(result.colors),
1138
1147
  spacings: htmlEscape.sortStrings(result.spacings),
1139
1148
  fonts: htmlEscape.sortStrings(result.fonts),
1149
+ textSizes: htmlEscape.sortStrings(result.textSizes),
1150
+ fontWeights: htmlEscape.sortStrings(result.fontWeights),
1140
1151
  radii: htmlEscape.sortStrings(result.radii),
1141
1152
  shadows: htmlEscape.sortStrings(result.shadows),
1142
1153
  breakpoints: htmlEscape.sortStrings(result.breakpoints)
@@ -1150,6 +1161,8 @@ function mergeThemes(themes) {
1150
1161
  colors: /* @__PURE__ */ new Set(),
1151
1162
  spacings: /* @__PURE__ */ new Set(),
1152
1163
  fonts: /* @__PURE__ */ new Set(),
1164
+ textSizes: /* @__PURE__ */ new Set(),
1165
+ fontWeights: /* @__PURE__ */ new Set(),
1153
1166
  radii: /* @__PURE__ */ new Set(),
1154
1167
  shadows: /* @__PURE__ */ new Set(),
1155
1168
  breakpoints: /* @__PURE__ */ new Set()
@@ -1165,6 +1178,8 @@ function mergeThemes(themes) {
1165
1178
  colors: htmlEscape.sortStrings(merged.colors),
1166
1179
  spacings: htmlEscape.sortStrings(merged.spacings),
1167
1180
  fonts: htmlEscape.sortStrings(merged.fonts),
1181
+ textSizes: htmlEscape.sortStrings(merged.textSizes),
1182
+ fontWeights: htmlEscape.sortStrings(merged.fontWeights),
1168
1183
  radii: htmlEscape.sortStrings(merged.radii),
1169
1184
  shadows: htmlEscape.sortStrings(merged.shadows),
1170
1185
  breakpoints: htmlEscape.sortStrings(merged.breakpoints)
@@ -1488,6 +1503,12 @@ function generateThemeDts(opts) {
1488
1503
  if (theme.fonts.length > 0) {
1489
1504
  entries.push(` fonts: ${toUnion(theme.fonts)};`);
1490
1505
  }
1506
+ if (theme.textSizes.length > 0) {
1507
+ entries.push(` textSizes: ${toUnion(theme.textSizes)};`);
1508
+ }
1509
+ if (theme.fontWeights.length > 0) {
1510
+ entries.push(` fontWeights: ${toUnion(theme.fontWeights)};`);
1511
+ }
1491
1512
  if (theme.radii.length > 0) {
1492
1513
  entries.push(` radii: ${toUnion(theme.radii)};`);
1493
1514
  }
@@ -1538,6 +1559,8 @@ function writeThemeDts(opts) {
1538
1559
 
1539
1560
  const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
1540
1561
  const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
1562
+ const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
1563
+ const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
1541
1564
  const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
1542
1565
  const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
1543
1566
  function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
@@ -1578,7 +1601,7 @@ export default checksum;
1578
1601
  `;
1579
1602
  }
1580
1603
  function isVirtualModule(id) {
1581
- return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID;
1604
+ return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID;
1582
1605
  }
1583
1606
  function resolveVirtualModule(id) {
1584
1607
  if (id === VIRTUAL_MODULE_ID) {
@@ -1587,8 +1610,25 @@ function resolveVirtualModule(id) {
1587
1610
  if (id === VIRTUAL_CHECKSUM_ID) {
1588
1611
  return RESOLVED_VIRTUAL_CHECKSUM_ID;
1589
1612
  }
1613
+ if (id === THEME_GROUPS_VIRTUAL_ID) {
1614
+ return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
1615
+ }
1590
1616
  return void 0;
1591
1617
  }
1618
+ function createThemeGroupsModule(tokens) {
1619
+ const payload = JSON.stringify({
1620
+ colors: tokens.colors,
1621
+ textSizes: tokens.textSizes,
1622
+ fontFamilies: tokens.fontFamilies,
1623
+ fontWeights: tokens.fontWeights
1624
+ });
1625
+ return [
1626
+ "// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
1627
+ "import { registerSzcnGroups } from '@csszyx/runtime';",
1628
+ `registerSzcnGroups(${payload});`,
1629
+ "export {};"
1630
+ ].join("\n");
1631
+ }
1592
1632
 
1593
1633
  const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
1594
1634
  const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
@@ -1597,6 +1637,7 @@ const UNKNOWN_PACKAGE_VERSION = "0.0.0";
1597
1637
  const TRANSFORM_CACHE_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
1598
1638
  const TRANSFORM_CACHE_MAX_ENTRIES = 1e4;
1599
1639
  const TRANSFORM_MEMORY_CACHE_MAX_ENTRIES = 1e3;
1640
+ const TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS = 32e6;
1600
1641
  const MAX_SAFELIST_CLASSES = 1e5;
1601
1642
  const DEFAULT_VAR_MANGLE_MAP_MAX_BYTES = 100 * 1024;
1602
1643
  const GLOBAL_VAR_ALIAS_MAP_OWNER = "\0csszyx:global-var-aliases";
@@ -1609,11 +1650,11 @@ const RUNTIME_HELPER_IMPORT_RE = {
1609
1650
  let _hasWarnedTsConfig = false;
1610
1651
  let _hasWarnedTransformCacheVersion = false;
1611
1652
  let _hasWarnedNativeFallback = false;
1612
- let _hasLoggedActiveParser = false;
1653
+ const _loggedActiveParsers = /* @__PURE__ */ new Set();
1613
1654
  const _babelFallbackFiles = /* @__PURE__ */ new Set();
1614
- const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.Cq_8AIBn.cjs', document.baseURI).href)));
1655
+ const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.q0k37crS.cjs', document.baseURI).href)));
1615
1656
  const PLUGIN_VERSION = findPackageVersionFromFile(
1616
- node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.Cq_8AIBn.cjs', document.baseURI).href))),
1657
+ node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.q0k37crS.cjs', document.baseURI).href))),
1617
1658
  UNKNOWN_PACKAGE_VERSION
1618
1659
  );
1619
1660
  const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
@@ -1817,7 +1858,10 @@ function isHardIgnoredPath(id, sourceDirs = []) {
1817
1858
  return false;
1818
1859
  }
1819
1860
  function fileMayContainSafelistableSz(content) {
1820
- return content.includes("sz=") || content.includes("szs=") || content.includes("sz:") || content.includes("szv(");
1861
+ return content.includes("sz=") || content.includes("szs=") || content.includes("sz:") || content.includes("szv(") || content.includes("szr(") || // dynamic() literal args are extracted for the safelist, but a module
1862
+ // containing ONLY dynamic() calls never passed this gate — the
1863
+ // engine-parity harness caught its classes missing on all engines.
1864
+ content.includes("dynamic(");
1821
1865
  }
1822
1866
  function isPackagesSkippedSource(id, sourceDirs = []) {
1823
1867
  const p = normalizeForMatch(id);
@@ -1869,6 +1913,9 @@ function recordFileVarMangleEntries(state, filename, entries) {
1869
1913
  }
1870
1914
  state.varMangleMap = buildVarMangleMap(state.varMangleEntriesByFile);
1871
1915
  }
1916
+ function shouldTrackGlobalVarSources(config) {
1917
+ return config?.enabled === true;
1918
+ }
1872
1919
  function recordGlobalVarSourceFile(state, filename, code) {
1873
1920
  const normalizedFilename = normalizeSourceFilename(filename);
1874
1921
  if (!/\.[tj]sx?(?:\?.*)?$/.test(normalizedFilename)) {
@@ -2143,11 +2190,11 @@ function traceBenchTiming(label, filename, elapsedMs) {
2143
2190
  }
2144
2191
  function runThemeScan(rootDir, scanCss) {
2145
2192
  if (!scanCss) {
2146
- return;
2193
+ return null;
2147
2194
  }
2148
2195
  const sourceFiles = expandFilePatterns(rootDir, scanCss).filter((file) => file.endsWith(".css"));
2149
2196
  if (sourceFiles.length === 0) {
2150
- return;
2197
+ return null;
2151
2198
  }
2152
2199
  const themes = sourceFiles.map((f) => {
2153
2200
  try {
@@ -2187,6 +2234,7 @@ function runThemeScan(rootDir, scanCss) {
2187
2234
  } catch {
2188
2235
  }
2189
2236
  }
2237
+ return merged;
2190
2238
  }
2191
2239
  function findPackageVersionFromModule(specifier, fallback) {
2192
2240
  try {
@@ -2469,6 +2517,7 @@ function createCsszyxPlugins(options = {}) {
2469
2517
  const cacheEnabled = cacheRequested && cacheVersionsKnown;
2470
2518
  const varMangleMapMaxBytes = resolveVarMangleMapMaxBytes();
2471
2519
  const globalVarMangleConfig = options.production?.mangleGlobalVars;
2520
+ const globalVarSourceTrackingEnabled = shouldTrackGlobalVarSources(globalVarMangleConfig);
2472
2521
  const globalVarAliasPrefix = globalVarMangleConfig?.aliasPrefix ?? types.CSSZYX_GLOBAL_ALIAS_PREFIX;
2473
2522
  const encodedGlobalVarAliasPrefix = encodeURIComponent(globalVarAliasPrefix);
2474
2523
  const earlyGlobalVarAliasEntries = createEarlyGlobalVarAliasEntries(
@@ -2494,21 +2543,25 @@ function createCsszyxPlugins(options = {}) {
2494
2543
  defaultParser: types.DEFAULT_BUILD_CONFIG.parser ?? "rust",
2495
2544
  isRustAvailable: compiler.isRustTransformAvailable
2496
2545
  });
2497
- if (parserDegraded && !_hasWarnedNativeFallback) {
2498
- _hasWarnedNativeFallback = true;
2499
- console.warn(
2500
- "[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to `oxc`. Output classes are identical (parity-tested); only parse speed differs. To use the native engine, install the matching @csszyx/core-<platform> package (or do not omit optional dependencies). Set `build.parser` explicitly to silence this."
2501
- );
2502
- }
2503
- if (!_hasLoggedActiveParser) {
2504
- _hasLoggedActiveParser = true;
2505
- const detail = parserDegraded ? "oxc (degraded from default `rust`: no native binary for this platform)" : parserMode === "rust" ? "rust (native engine)" : parserMode;
2506
- console.warn(`[csszyx] active parser: ${detail}`);
2546
+ function announceActiveParser() {
2547
+ if (parserDegraded && !_hasWarnedNativeFallback) {
2548
+ _hasWarnedNativeFallback = true;
2549
+ console.warn(
2550
+ "[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to `oxc`. Output classes are identical (parity-tested); only parse speed differs. To use the native engine, install the matching @csszyx/core-<platform> package (or do not omit optional dependencies). Set `build.parser` explicitly to silence this."
2551
+ );
2552
+ }
2553
+ if (!_loggedActiveParsers.has(parserMode)) {
2554
+ _loggedActiveParsers.add(parserMode);
2555
+ const detail = parserDegraded ? "oxc (degraded from default `rust`: no native binary for this platform)" : parserMode === "rust" ? "rust (native engine)" : parserMode;
2556
+ console.warn(`[csszyx] active parser: ${detail}`);
2557
+ }
2507
2558
  }
2508
2559
  let evictedCacheRoot = null;
2509
2560
  const transformMemoryCache = /* @__PURE__ */ new Map();
2561
+ let transformMemoryCacheCodeChars = 0;
2510
2562
  const state = {
2511
2563
  classes: /* @__PURE__ */ new Set(),
2564
+ parsedTheme: null,
2512
2565
  sawTailwindEntry: false,
2513
2566
  sawAnyCss: false,
2514
2567
  tailwindWarningEmitted: false,
@@ -2536,7 +2589,16 @@ function createCsszyxPlugins(options = {}) {
2536
2589
  state.varMangleEntriesByFile.set(GLOBAL_VAR_ALIAS_MAP_OWNER, earlyGlobalVarAliasEntries);
2537
2590
  }
2538
2591
  const SAFELIST_FILENAME = "csszyx-classes.html";
2539
- const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".tsx", ".jsx", ".ts", ".js"]);
2592
+ const SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
2593
+ ".tsx",
2594
+ ".jsx",
2595
+ ".ts",
2596
+ ".js",
2597
+ ".mjs",
2598
+ ".cjs",
2599
+ ".mts",
2600
+ ".cts"
2601
+ ]);
2540
2602
  const IGNORE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".next", ".git", "dist", "build", ".turbo"]);
2541
2603
  function isUserExcluded(id) {
2542
2604
  return matchesAnyPattern(id, options.exclude, state.rootDir);
@@ -2578,6 +2640,12 @@ function createCsszyxPlugins(options = {}) {
2578
2640
  assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
2579
2641
  return result;
2580
2642
  }
2643
+ function trackGlobalVarSourceFile(filename, code) {
2644
+ if (!globalVarSourceTrackingEnabled) {
2645
+ return;
2646
+ }
2647
+ recordGlobalVarSourceFile(state, filename, code);
2648
+ }
2581
2649
  let compileSourceDirs = [];
2582
2650
  let compileSourceDirsRoot = null;
2583
2651
  function refreshCompileSourceDirs() {
@@ -2598,7 +2666,7 @@ function createCsszyxPlugins(options = {}) {
2598
2666
  return isHardIgnoredPath(id, compileSourceDirs);
2599
2667
  }
2600
2668
  function shouldProcessSource(id) {
2601
- return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.[tj]sx?(\?.*)?$/.test(id) || id.endsWith(".vue") || id.endsWith(".svelte"));
2669
+ return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.([cm]?[tj]s|[tj]sx)(\?.*)?$/.test(id) || id.endsWith(".vue") || id.endsWith(".svelte"));
2602
2670
  }
2603
2671
  function shouldProcessCss(id) {
2604
2672
  return !isHardIgnored(id) && !isUserExcluded(id) && /\.css(\?.*)?$/.test(id);
@@ -2779,21 +2847,28 @@ function createCsszyxPlugins(options = {}) {
2779
2847
  filePath: file.filePath,
2780
2848
  result: transformConfiguredSource(file.content, file.filePath)
2781
2849
  });
2782
- } catch {
2850
+ } catch (err) {
2851
+ console.warn(
2852
+ `[csszyx] prescan skipped ${file.filePath}: transform failed, so none of its classes reached the safelist. ${err instanceof Error ? err.message : String(err)}`
2853
+ );
2783
2854
  }
2784
2855
  }
2785
2856
  return results;
2786
2857
  }
2787
2858
  function rememberTransformCacheEntry(key, result) {
2788
- transformMemoryCache.delete(key);
2789
- transformMemoryCache.set(key, result);
2790
- if (transformMemoryCache.size <= TRANSFORM_MEMORY_CACHE_MAX_ENTRIES) {
2791
- return;
2792
- }
2793
- const oldest = transformMemoryCache.keys().next().value;
2794
- if (oldest) {
2795
- transformMemoryCache.delete(oldest);
2859
+ const existing = transformMemoryCache.get(key);
2860
+ if (existing) {
2861
+ transformMemoryCacheCodeChars -= existing.code.length;
2862
+ transformMemoryCache.delete(key);
2796
2863
  }
2864
+ transformMemoryCache.set(key, result);
2865
+ transformMemoryCacheCodeChars += result.code.length;
2866
+ transformMemoryCacheCodeChars = transformCache.evictMemoryCacheToBudget(
2867
+ transformMemoryCache,
2868
+ transformMemoryCacheCodeChars,
2869
+ TRANSFORM_MEMORY_CACHE_MAX_ENTRIES,
2870
+ TRANSFORM_MEMORY_CACHE_MAX_CODE_CHARS
2871
+ );
2797
2872
  }
2798
2873
  function evictTransformCacheOnce() {
2799
2874
  if (!cacheEnabled) {
@@ -2901,6 +2976,12 @@ function createCsszyxPlugins(options = {}) {
2901
2976
  scanDir(sourceDir);
2902
2977
  }
2903
2978
  for (const { filePath, result } of transformPrescanSources(prescanSources)) {
2979
+ if (result.classes.size === 0 && result.rawClassNames.size === 0 && result.diagnostics.some((d) => d.includes("[csszyx] parse error in "))) {
2980
+ console.warn(
2981
+ `[csszyx] prescan skipped ${filePath}: the file failed to parse, so none of its classes reached the safelist. Fix the syntax error (or check the file extension matches its contents).`
2982
+ );
2983
+ continue;
2984
+ }
2904
2985
  if (!result.transformed && result.classes.size === 0) {
2905
2986
  continue;
2906
2987
  }
@@ -3091,7 +3172,7 @@ function createCsszyxPlugins(options = {}) {
3091
3172
  * @returns true only for csszyx virtual modules
3092
3173
  */
3093
3174
  loadInclude(id) {
3094
- return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID;
3175
+ return id === RESOLVED_VIRTUAL_MODULE_ID || id === RESOLVED_VIRTUAL_CHECKSUM_ID || id === RESOLVED_THEME_GROUPS_VIRTUAL_ID;
3095
3176
  },
3096
3177
  /**
3097
3178
  * Loads virtual module content — generates mangle map or checksum module code.
@@ -3112,6 +3193,15 @@ function createCsszyxPlugins(options = {}) {
3112
3193
  finalizeMangleMap();
3113
3194
  return createChecksumModule(state.checksum);
3114
3195
  }
3196
+ if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
3197
+ const theme = state.parsedTheme;
3198
+ return createThemeGroupsModule({
3199
+ colors: theme?.colors ?? [],
3200
+ textSizes: theme?.textSizes ?? [],
3201
+ fontFamilies: theme?.fonts ?? [],
3202
+ fontWeights: theme?.fontWeights ?? []
3203
+ });
3204
+ }
3115
3205
  return null;
3116
3206
  },
3117
3207
  /**
@@ -3134,11 +3224,12 @@ function createCsszyxPlugins(options = {}) {
3134
3224
  * @returns transformed code with source map, or null if no changes were made
3135
3225
  */
3136
3226
  transform(code, id) {
3227
+ announceActiveParser();
3137
3228
  if (!shouldProcessCss(id) && !shouldProcessSource(id)) {
3138
3229
  return null;
3139
3230
  }
3140
3231
  if (shouldProcessSource(id)) {
3141
- recordGlobalVarSourceFile(state, id, code);
3232
+ trackGlobalVarSourceFile(id, code);
3142
3233
  }
3143
3234
  if (/\.[tj]sx?(\?.*)?$/.test(id)) {
3144
3235
  assertNoRSCBoundaryViolation(code, id);
@@ -3268,6 +3359,11 @@ function createCsszyxPlugins(options = {}) {
3268
3359
  transformed = true;
3269
3360
  }
3270
3361
  }
3362
+ if (/\bszcn\s*\(/.test(code) && !transformedCode.includes(THEME_GROUPS_VIRTUAL_ID) && shouldProcessSource(id)) {
3363
+ transformedCode = `import '${THEME_GROUPS_VIRTUAL_ID}';
3364
+ ${transformedCode}`;
3365
+ transformed = true;
3366
+ }
3271
3367
  if (/\.[tj]sx?(\?.*)?$/.test(id)) {
3272
3368
  assertNoRSCBoundaryViolation(transformedCode, id);
3273
3369
  const record = createRSCModuleRecord(transformedCode, id);
@@ -3344,13 +3440,14 @@ function createCsszyxPlugins(options = {}) {
3344
3440
  */
3345
3441
  webpack(compiler) {
3346
3442
  compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
3443
+ announceActiveParser();
3347
3444
  const root = compiler.context || process.cwd();
3348
3445
  state.rootDir = root;
3349
3446
  evictTransformCacheOnce();
3350
3447
  if (state.classes.size === 0) {
3351
3448
  prescanAndWriteClasses();
3352
3449
  }
3353
- runThemeScan(root, options.build?.scanCss);
3450
+ state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
3354
3451
  });
3355
3452
  if (options.build?.scanCss) {
3356
3453
  compiler.hooks.thisCompilation.tap("csszyx:theme-deps", (compilation) => {
@@ -3368,6 +3465,7 @@ function createCsszyxPlugins(options = {}) {
3368
3465
  * @param config - the resolved Vite configuration object
3369
3466
  */
3370
3467
  configResolved(config) {
3468
+ announceActiveParser();
3371
3469
  const root = config.root || process.cwd();
3372
3470
  state.rootDir = root;
3373
3471
  if (config.command === "serve") {
@@ -3375,7 +3473,7 @@ function createCsszyxPlugins(options = {}) {
3375
3473
  }
3376
3474
  evictTransformCacheOnce();
3377
3475
  prescanAndWriteClasses();
3378
- runThemeScan(root, options.build?.scanCss);
3476
+ state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
3379
3477
  },
3380
3478
  /**
3381
3479
  * Vite HMR hook: re-runs theme scan when a watched CSS file changes,
@@ -3387,7 +3485,13 @@ function createCsszyxPlugins(options = {}) {
3387
3485
  if (scanCss) {
3388
3486
  const root = ctx.server.config.root || process.cwd();
3389
3487
  if (matchesAnyPattern(ctx.file, scanCss, root)) {
3390
- runThemeScan(root, scanCss);
3488
+ state.parsedTheme = runThemeScan(root, scanCss) ?? state.parsedTheme;
3489
+ const themeGroupsModule = ctx.server.moduleGraph.getModuleById(
3490
+ RESOLVED_THEME_GROUPS_VIRTUAL_ID
3491
+ );
3492
+ if (themeGroupsModule) {
3493
+ ctx.server.moduleGraph.invalidateModule(themeGroupsModule);
3494
+ }
3391
3495
  }
3392
3496
  }
3393
3497
  if (!shouldProcessSource(ctx.file)) {
@@ -3400,7 +3504,7 @@ function createCsszyxPlugins(options = {}) {
3400
3504
  return;
3401
3505
  }
3402
3506
  if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
3403
- recordGlobalVarSourceFile(state, ctx.file, fileContent);
3507
+ trackGlobalVarSourceFile(ctx.file, fileContent);
3404
3508
  recordFileVarMangleEntries(state, ctx.file, []);
3405
3509
  recordFileCSSVariableMetrics(state, ctx.file, null);
3406
3510
  return;
@@ -3414,19 +3518,19 @@ function createCsszyxPlugins(options = {}) {
3414
3518
  node_perf_hooks.performance.now() - hmrTransformStarted
3415
3519
  );
3416
3520
  } catch {
3417
- recordGlobalVarSourceFile(state, ctx.file, fileContent);
3521
+ trackGlobalVarSourceFile(ctx.file, fileContent);
3418
3522
  recordFileVarMangleEntries(state, ctx.file, []);
3419
3523
  recordFileCSSVariableMetrics(state, ctx.file, null);
3420
3524
  return;
3421
3525
  }
3422
3526
  if (!result.transformed) {
3423
- recordGlobalVarSourceFile(state, ctx.file, fileContent);
3527
+ trackGlobalVarSourceFile(ctx.file, fileContent);
3424
3528
  recordFileVarMangleEntries(state, ctx.file, []);
3425
3529
  recordFileCSSVariableMetrics(state, ctx.file, null);
3426
3530
  return;
3427
3531
  }
3428
3532
  const sizeBefore = state.classes.size;
3429
- recordGlobalVarSourceFile(state, ctx.file, fileContent);
3533
+ trackGlobalVarSourceFile(ctx.file, fileContent);
3430
3534
  for (const cls of result.classes) {
3431
3535
  addSafelistClass(cls);
3432
3536
  state.ownedClasses.add(cls);
@@ -3846,6 +3950,7 @@ exports.normalizeGlobalVarAliasesForCache = normalizeGlobalVarAliasesForCache;
3846
3950
  exports.parseThemeBlocks = parseThemeBlocks;
3847
3951
  exports.planGlobalVarAliases = planGlobalVarAliases;
3848
3952
  exports.readGlobalVarScanCache = readGlobalVarScanCache;
3953
+ exports.recordGlobalVarSourceFile = recordGlobalVarSourceFile;
3849
3954
  exports.resolveCompileSourceDirs = resolveCompileSourceDirs;
3850
3955
  exports.resolveGlobalVarScanCacheDir = resolveGlobalVarScanCacheDir;
3851
3956
  exports.resolveNativeCacheIdentity = resolveNativeCacheIdentity;
@@ -3853,6 +3958,7 @@ exports.rewriteGlobalVarCssAliases = rewriteGlobalVarCssAliases;
3853
3958
  exports.rollupPlugin = rollupPlugin;
3854
3959
  exports.scanGlobalVarCss = scanGlobalVarCss;
3855
3960
  exports.shouldEmitWarning = shouldEmitWarning;
3961
+ exports.shouldTrackGlobalVarSources = shouldTrackGlobalVarSources;
3856
3962
  exports.shouldWarnMissingTailwindEntry = shouldWarnMissingTailwindEntry;
3857
3963
  exports.shouldWarnUnscopedMonorepo = shouldWarnUnscopedMonorepo;
3858
3964
  exports.skippedSzFilesMessage = skippedSzFilesMessage;
package/dist/vite.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const unplugin = require('./shared/unplugin.Cq_8AIBn.cjs');
5
+ const unplugin = require('./shared/unplugin.q0k37crS.cjs');
6
6
  require('node:fs');
7
7
  require('node:module');
8
8
  require('node:path');
@@ -20,7 +20,7 @@ require('postcss');
20
20
  require('postcss-selector-parser');
21
21
  require('./shared/unplugin.BCwRIUs_.cjs');
22
22
  require('node:crypto');
23
- require('./shared/unplugin.pmTknYLy.cjs');
23
+ require('./shared/unplugin.D32Rb29j.cjs');
24
24
  require('postcss-value-parser');
25
25
 
26
26
 
package/dist/vite.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { W as vitePlugin } from './shared/unplugin.CK6U5gAP.cjs';
1
+ import { ab as vitePlugin } from './shared/unplugin.D3qsS8Pe.cjs';
2
2
  import '@csszyx/compiler';
3
3
  import '@csszyx/types';
4
4
  import 'esbuild';
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { W as vitePlugin } from './shared/unplugin.CK6U5gAP.mjs';
1
+ import { ab as vitePlugin } from './shared/unplugin.D3qsS8Pe.mjs';
2
2
  import '@csszyx/compiler';
3
3
  import '@csszyx/types';
4
4
  import 'esbuild';
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as vitePlugin } from './shared/unplugin.Ble541_h.mjs';
1
+ import { Y as vitePlugin } from './shared/unplugin.CiSDltfp.mjs';
2
2
  import 'node:fs';
3
3
  import 'node:module';
4
4
  import 'node:path';
@@ -16,7 +16,7 @@ import 'postcss';
16
16
  import 'postcss-selector-parser';
17
17
  import './shared/unplugin.B1mblcm-.mjs';
18
18
  import 'node:crypto';
19
- import './shared/unplugin.BpWUtI9U.mjs';
19
+ import './shared/unplugin.CGqFVGlB.mjs';
20
20
  import 'postcss-value-parser';
21
21
 
22
22
 
package/dist/webpack.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const unplugin = require('./shared/unplugin.Cq_8AIBn.cjs');
5
+ const unplugin = require('./shared/unplugin.q0k37crS.cjs');
6
6
  require('node:fs');
7
7
  require('node:module');
8
8
  require('node:path');
@@ -20,7 +20,7 @@ require('postcss');
20
20
  require('postcss-selector-parser');
21
21
  require('./shared/unplugin.BCwRIUs_.cjs');
22
22
  require('node:crypto');
23
- require('./shared/unplugin.pmTknYLy.cjs');
23
+ require('./shared/unplugin.D32Rb29j.cjs');
24
24
  require('postcss-value-parser');
25
25
 
26
26
 
@@ -1,4 +1,4 @@
1
- import { X as webpackPlugin } from './shared/unplugin.CK6U5gAP.cjs';
1
+ import { ac as webpackPlugin } from './shared/unplugin.D3qsS8Pe.cjs';
2
2
  import '@csszyx/compiler';
3
3
  import '@csszyx/types';
4
4
  import 'esbuild';
@@ -1,4 +1,4 @@
1
- import { X as webpackPlugin } from './shared/unplugin.CK6U5gAP.mjs';
1
+ import { ac as webpackPlugin } from './shared/unplugin.D3qsS8Pe.mjs';
2
2
  import '@csszyx/compiler';
3
3
  import '@csszyx/types';
4
4
  import 'esbuild';
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { X as webpackPlugin } from './shared/unplugin.Ble541_h.mjs';
1
+ import { Z as webpackPlugin } from './shared/unplugin.CiSDltfp.mjs';
2
2
  import 'node:fs';
3
3
  import 'node:module';
4
4
  import 'node:path';
@@ -16,7 +16,7 @@ import 'postcss';
16
16
  import 'postcss-selector-parser';
17
17
  import './shared/unplugin.B1mblcm-.mjs';
18
18
  import 'node:crypto';
19
- import './shared/unplugin.BpWUtI9U.mjs';
19
+ import './shared/unplugin.CGqFVGlB.mjs';
20
20
  import 'postcss-value-parser';
21
21
 
22
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/unplugin",
3
- "version": "0.10.10",
3
+ "version": "0.10.11",
4
4
  "description": "Vite and Webpack integration for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -117,14 +117,14 @@
117
117
  "postcss-value-parser": "^4.2.0",
118
118
  "proper-lockfile": "^4.1.2",
119
119
  "unplugin": "^1.10.1",
120
- "@csszyx/compiler": "0.10.10",
121
- "@csszyx/svelte-adapter": "0.10.10",
122
- "@csszyx/types": "0.10.10",
123
- "@csszyx/core": "0.10.10",
124
- "@csszyx/vue-adapter": "0.10.10"
120
+ "@csszyx/compiler": "0.10.11",
121
+ "@csszyx/core": "0.10.11",
122
+ "@csszyx/types": "0.10.11",
123
+ "@csszyx/vue-adapter": "0.10.11",
124
+ "@csszyx/svelte-adapter": "0.10.11"
125
125
  },
126
126
  "peerDependencies": {
127
- "@csszyx/runtime": "^0.10.10"
127
+ "@csszyx/runtime": "^0.10.11"
128
128
  },
129
129
  "devDependencies": {
130
130
  "@types/node": "^20.11.0",