@csszyx/unplugin 0.11.11 → 0.13.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +11 -7
  3. package/dist/index.d.cts +4 -4
  4. package/dist/index.d.mts +4 -4
  5. package/dist/index.mjs +4 -3
  6. package/dist/next-config.cjs +3 -0
  7. package/dist/next-config.d.cts +10 -0
  8. package/dist/next-config.d.mts +10 -0
  9. package/dist/next-config.mjs +3 -0
  10. package/dist/next-prebuild.cjs +12 -5
  11. package/dist/next-prebuild.d.cts +7 -0
  12. package/dist/next-prebuild.d.mts +7 -0
  13. package/dist/next-prebuild.mjs +12 -5
  14. package/dist/next-turbo-loader.cjs +29 -59
  15. package/dist/next-turbo-loader.d.cts +10 -0
  16. package/dist/next-turbo-loader.d.mts +10 -0
  17. package/dist/next-turbo-loader.mjs +28 -58
  18. package/dist/next-watcher.cjs +1 -1
  19. package/dist/next-watcher.mjs +1 -1
  20. package/dist/shared/unplugin.4du3qMst.cjs +529 -0
  21. package/dist/shared/unplugin.5l4RHMQh.mjs +578 -0
  22. package/dist/shared/unplugin.BB0iWSds.mjs +495 -0
  23. package/dist/shared/{unplugin.DMcbmP01.mjs → unplugin.BU0O4IkX.mjs} +4 -1
  24. package/dist/shared/{unplugin.CJcFsJcf.cjs → unplugin.Bf4fNbp7.cjs} +452 -504
  25. package/dist/shared/{unplugin.BZq6FKn2.cjs → unplugin.CUTa6bY9.cjs} +89 -1
  26. package/dist/shared/{unplugin.DblMogcN.cjs → unplugin.Cji6O5jv.cjs} +4 -1
  27. package/dist/shared/{unplugin.-yLpX1Ck.mjs → unplugin.CogPHmDs.mjs} +73 -3
  28. package/dist/shared/{unplugin.BK7BIeBn.d.cts → unplugin.DCT7DDG6.d.cts} +88 -26
  29. package/dist/shared/{unplugin.BK7BIeBn.d.mts → unplugin.DCT7DDG6.d.mts} +88 -26
  30. package/dist/shared/unplugin.X9a9SL_s.cjs +612 -0
  31. package/dist/shared/{unplugin.B2RUVK6Z.mjs → unplugin.ymMe428s.mjs} +426 -477
  32. package/dist/vite.cjs +4 -3
  33. package/dist/vite.d.cts +2 -2
  34. package/dist/vite.d.mts +1 -1
  35. package/dist/vite.mjs +4 -3
  36. package/dist/webpack.cjs +4 -3
  37. package/dist/webpack.d.cts +2 -2
  38. package/dist/webpack.d.mts +1 -1
  39. package/dist/webpack.mjs +4 -3
  40. package/package.json +13 -11
  41. package/dist/shared/unplugin.CKIOVNOg.cjs +0 -241
  42. package/dist/shared/unplugin.Cnxm1DcC.cjs +0 -53
  43. package/dist/shared/unplugin.Lhzkcj-A.mjs +0 -49
  44. package/dist/shared/unplugin.fOnGXWgS.mjs +0 -217
@@ -6,17 +6,18 @@ import * as path from 'node:path';
6
6
  import { dirname } from 'node:path';
7
7
  import { performance } from 'node:perf_hooks';
8
8
  import { fileURLToPath } from 'node:url';
9
- import { scanGlobalVarUsages, sortStrings as sortStrings$1, ensureRustTransformAvailable, transformSourceCode, transformRust, transformOxc, ASTBudgetExceededError, transformRustBatch, transform, isRustTransformAvailable } from '@csszyx/compiler';
9
+ import { scanGlobalVarUsages, sortStrings as sortStrings$1, szFallbackConsequenceOf, ensureRustTransformAvailable, transformSourceCode, transformRust, transformOxc, ASTBudgetExceededError, transformRustBatch, transform, isRustTransformAvailable } from '@csszyx/compiler';
10
10
  import { encode, compute_mangle_checksum } from '@csszyx/core';
11
11
  import { getNativePackageName } from '@csszyx/core/native';
12
12
  import { preprocess as preprocess$1 } from '@csszyx/svelte-adapter';
13
- import { isTailwindReservedCustomProperty, CSSZYX_GLOBAL_ALIAS_PREFIX, isCsszyxGlobalAliasCustomProperty, DEFAULT_BUILD_CONFIG, validateGlobalVarMangleConfig } from '@csszyx/types';
13
+ import { isTailwindReservedCustomProperty, CSSZYX_GLOBAL_ALIAS_PREFIX, isCsszyxGlobalAliasCustomProperty, DEFAULT_IMPORTED_STATIC_SZ, DEFAULT_BUILD_CONFIG, validateGlobalVarMangleConfig } from '@csszyx/types';
14
14
  import { preprocess } from '@csszyx/vue-adapter';
15
15
  import { createUnplugin } from 'unplugin';
16
- import { n as normalizePathSeparators, r as resolveTransformCacheDir, c as createTransformCacheKey, w as writeTransformCache, e as evictOldTransformCacheEntries, a as readTransformCache, d as evictMemoryCacheToBudget, b as babelFallbackReason } from './unplugin.fOnGXWgS.mjs';
16
+ import { n as normalizePathSeparators, c as collectSpecifierAliases, h as recordSzvRegistryFile, j as recordSzObjectRegistryFile, k as resolveCrossModuleStaticsFor, r as resolveTransformCacheDir, e as createTransformCacheKey, w as writeTransformCache, l as evictOldTransformCacheEntries, m as mayExportSzvFactories, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, f as readTransformCache, o as evictMemoryCacheToBudget, p as resolveProviderPath, g as babelFallbackReason, d as isReadableProviderFile } from './unplugin.BB0iWSds.mjs';
17
17
  import { mangleCSSSync } from '../css-mangler.mjs';
18
- import { i as importsRuntimeHelper, f as findRuntimeImportClause, a as insertAfterUseDirective } from './unplugin.Lhzkcj-A.mjs';
18
+ import { c as createThemeGroupsModule, e as ensureThemeGroupsFile, R as RESOLVED_VIRTUAL_MODULE_ID, b as createMangleMapModule, d as RESOLVED_VIRTUAL_CHECKSUM_ID, f as createChecksumModule, g as RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID, j as createMangleRuntimeModule, k as RESOLVED_THEME_GROUPS_VIRTUAL_ID, l as isVirtualModule, r as resolveVirtualModule, p as parseThemeBlocks, m as mergeThemes, n as discoverProjectTheme, C as CHECKSUM_PLACEHOLDER, M as MANGLE_MAP_PLACEHOLDER, V as VAR_MANGLE_MAP_PLACEHOLDER, o as importsRuntimeHelper, q as findRuntimeImportClause, T as THEME_GROUPS_VIRTUAL_ID, u as THEME_GROUPS_FILE_MARKER, t as themeGroupsSpecifier, v as MANGLE_RUNTIME_VIRTUAL_ID, w as runtimeHelperGroupsFromUsage, a as insertAfterUseDirective } from './unplugin.5l4RHMQh.mjs';
19
19
  import { s as sortStrings, a as replaceEveryLiteral, u as unicodeEscape, b as escapeDoubleQuotedString, c as escapeSingleQuotedString, e as escapeHtmlAttribute, r as renderTailwindScannerCandidates } from './unplugin.B3XoSRB8.mjs';
20
+ import { gzipSync } from 'node:zlib';
20
21
  import postcss from 'postcss';
21
22
  import valueParser from 'postcss-value-parser';
22
23
 
@@ -291,7 +292,7 @@ function validateCandidates(candidates, definitions, reserved, aliasPrefix) {
291
292
  code: "registered-property",
292
293
  severity: "error",
293
294
  name,
294
- message: `Registered custom property ${name} is not aliasable in Phase H v1.`,
295
+ message: `Registered custom property ${name} cannot be aliased: @property gives it a type and inheritance behaviour that an alias would not carry.`,
295
296
  location: registeredDefinition
296
297
  });
297
298
  }
@@ -1111,237 +1112,6 @@ function maskBlockComment(code, start) {
1111
1112
  return { end, value };
1112
1113
  }
1113
1114
 
1114
- const EMPTY_THEME = {
1115
- colors: [],
1116
- spacings: [],
1117
- fonts: [],
1118
- textSizes: [],
1119
- fontWeights: [],
1120
- radii: [],
1121
- shadows: [],
1122
- breakpoints: []
1123
- };
1124
- function findMatchingBrace(source, openBrace) {
1125
- let depth = 0;
1126
- for (let index = openBrace; index < source.length; index++) {
1127
- if (source[index] === "{") {
1128
- depth++;
1129
- } else if (source[index] === "}") {
1130
- depth--;
1131
- if (depth === 0) {
1132
- return index;
1133
- }
1134
- }
1135
- }
1136
- return -1;
1137
- }
1138
- function stripLayerWrappers(css) {
1139
- let result = "";
1140
- let i = 0;
1141
- while (i < css.length) {
1142
- const layerIdx = css.indexOf("@layer", i);
1143
- if (layerIdx === -1) {
1144
- result += css.slice(i);
1145
- break;
1146
- }
1147
- result += css.slice(i, layerIdx);
1148
- const openBrace = css.indexOf("{", layerIdx);
1149
- if (openBrace === -1) {
1150
- result += css.slice(layerIdx);
1151
- break;
1152
- }
1153
- const closeBrace = findMatchingBrace(css, openBrace);
1154
- if (closeBrace === -1) {
1155
- result += css.slice(openBrace);
1156
- break;
1157
- }
1158
- result += css.slice(openBrace + 1, closeBrace);
1159
- i = closeBrace + 1;
1160
- }
1161
- return result;
1162
- }
1163
- function themePreludeStart(css, at) {
1164
- const cursor = at + "@theme".length;
1165
- const next = css[cursor];
1166
- const validBoundary = next === "{" || next === " " || next === " " || next === "\n" || next === "\r";
1167
- return validBoundary ? cursor : null;
1168
- }
1169
- function readThemeBlock(css, start) {
1170
- for (let cursor = start; cursor < css.length; cursor++) {
1171
- const character = css[cursor];
1172
- if (character === "{") {
1173
- const close = findMatchingBrace(css, cursor);
1174
- return {
1175
- body: close === -1 ? null : css.slice(cursor + 1, close),
1176
- end: close === -1 ? cursor : close
1177
- };
1178
- }
1179
- if (character === ";" || character === "}" || character === "@") {
1180
- return { body: null, end: cursor };
1181
- }
1182
- }
1183
- return { body: null, end: css.length };
1184
- }
1185
- function extractThemeBlocks(css) {
1186
- const blocks = [];
1187
- let searchFrom = 0;
1188
- for (; ; ) {
1189
- const at = css.indexOf("@theme", searchFrom);
1190
- if (at === -1) {
1191
- break;
1192
- }
1193
- const preludeStart = themePreludeStart(css, at);
1194
- if (preludeStart === null) {
1195
- searchFrom = at + "@theme".length;
1196
- continue;
1197
- }
1198
- const match = readThemeBlock(css, preludeStart);
1199
- if (match.body !== null) blocks.push(match.body);
1200
- searchFrom = Math.max(match.end, at + "@theme".length);
1201
- }
1202
- return blocks;
1203
- }
1204
- function categorizeProperty(prop) {
1205
- const categoryMap = [
1206
- ["color-", "colors"],
1207
- ["spacing-", "spacings"],
1208
- // `font-weight-` MUST precede `font-`: startsWith would otherwise route
1209
- // `font-weight-chunky` into font FAMILIES as token "weight-chunky".
1210
- ["font-weight-", "fontWeights"],
1211
- ["font-", "fonts"],
1212
- // `--text-*` defines font-size utilities (text-huge) in Tailwind v4.
1213
- ["text-", "textSizes"],
1214
- ["radius-", "radii"],
1215
- ["shadow-", "shadows"],
1216
- ["breakpoint-", "breakpoints"]
1217
- ];
1218
- for (const [prefix, category] of categoryMap) {
1219
- if (prop.startsWith(prefix)) {
1220
- let token = prop.slice(prefix.length);
1221
- if (category !== "breakpoints") {
1222
- token = token.replace(/-\d+$/, "");
1223
- }
1224
- if (token) {
1225
- return { category, token };
1226
- }
1227
- }
1228
- }
1229
- return null;
1230
- }
1231
- function parseThemeBlocks(cssContent) {
1232
- const result = {
1233
- colors: /* @__PURE__ */ new Set(),
1234
- spacings: /* @__PURE__ */ new Set(),
1235
- fonts: /* @__PURE__ */ new Set(),
1236
- textSizes: /* @__PURE__ */ new Set(),
1237
- fontWeights: /* @__PURE__ */ new Set(),
1238
- radii: /* @__PURE__ */ new Set(),
1239
- shadows: /* @__PURE__ */ new Set(),
1240
- breakpoints: /* @__PURE__ */ new Set()
1241
- };
1242
- const stripped = stripLayerWrappers(cssContent);
1243
- const blocks = extractThemeBlocks(stripped);
1244
- for (const block of blocks) {
1245
- for (const name of scanCustomPropertyNames(block)) {
1246
- const categorized = categorizeProperty(name);
1247
- if (categorized) {
1248
- result[categorized.category].add(categorized.token);
1249
- }
1250
- }
1251
- }
1252
- return {
1253
- colors: sortStrings(result.colors),
1254
- spacings: sortStrings(result.spacings),
1255
- fonts: sortStrings(result.fonts),
1256
- textSizes: sortStrings(result.textSizes),
1257
- fontWeights: sortStrings(result.fontWeights),
1258
- radii: sortStrings(result.radii),
1259
- shadows: sortStrings(result.shadows),
1260
- breakpoints: sortStrings(result.breakpoints)
1261
- };
1262
- }
1263
- function mergeThemes(themes) {
1264
- if (themes.length === 0) {
1265
- return { ...EMPTY_THEME };
1266
- }
1267
- const merged = {
1268
- colors: /* @__PURE__ */ new Set(),
1269
- spacings: /* @__PURE__ */ new Set(),
1270
- fonts: /* @__PURE__ */ new Set(),
1271
- textSizes: /* @__PURE__ */ new Set(),
1272
- fontWeights: /* @__PURE__ */ new Set(),
1273
- radii: /* @__PURE__ */ new Set(),
1274
- shadows: /* @__PURE__ */ new Set(),
1275
- breakpoints: /* @__PURE__ */ new Set()
1276
- };
1277
- for (const theme of themes) {
1278
- for (const cat of Object.keys(merged)) {
1279
- for (const token of theme[cat]) {
1280
- merged[cat].add(token);
1281
- }
1282
- }
1283
- }
1284
- return {
1285
- colors: sortStrings(merged.colors),
1286
- spacings: sortStrings(merged.spacings),
1287
- fonts: sortStrings(merged.fonts),
1288
- textSizes: sortStrings(merged.textSizes),
1289
- fontWeights: sortStrings(merged.fontWeights),
1290
- radii: sortStrings(merged.radii),
1291
- shadows: sortStrings(merged.shadows),
1292
- breakpoints: sortStrings(merged.breakpoints)
1293
- };
1294
- }
1295
- function hasTokens(theme) {
1296
- return Object.values(theme).some((arr) => arr.length > 0);
1297
- }
1298
- function readCustomPropertyName(block, dashes) {
1299
- let end = dashes + 2;
1300
- if (end >= block.length || !/[a-z]/.test(block[end])) {
1301
- return null;
1302
- }
1303
- end++;
1304
- while (end < block.length && /[a-z0-9-]/.test(block[end])) {
1305
- end++;
1306
- }
1307
- return { name: block.slice(dashes + 2, end), end };
1308
- }
1309
- function findCustomPropertyDeclarationEnd(block, nameEnd) {
1310
- let cursor = nameEnd;
1311
- while (cursor < block.length && /\s/.test(block[cursor])) {
1312
- cursor++;
1313
- }
1314
- if (block[cursor] === ":") {
1315
- const valueStart = cursor + 1;
1316
- const semicolon = block.indexOf(";", valueStart);
1317
- return semicolon > valueStart ? semicolon + 1 : -1;
1318
- }
1319
- return block[nameEnd] === ";" ? nameEnd + 1 : -1;
1320
- }
1321
- function scanCustomPropertyNames(block) {
1322
- const names = [];
1323
- let i = 0;
1324
- while (i < block.length) {
1325
- const dashes = block.indexOf("--", i);
1326
- if (dashes === -1) {
1327
- break;
1328
- }
1329
- const property = readCustomPropertyName(block, dashes);
1330
- if (!property) {
1331
- i = dashes + 1;
1332
- continue;
1333
- }
1334
- const matchEnd = findCustomPropertyDeclarationEnd(block, property.end);
1335
- if (matchEnd === -1) {
1336
- i = dashes + 1;
1337
- continue;
1338
- }
1339
- names.push(property.name);
1340
- i = matchEnd;
1341
- }
1342
- return names;
1343
- }
1344
-
1345
1115
  const REGEX_PREFIXES = new Set("([{:,;=!?&|+-*%^~<>/");
1346
1116
  const REGEX_PREFIX_KEYWORDS = /* @__PURE__ */ new Set([
1347
1117
  "await",
@@ -1711,6 +1481,78 @@ function collectAuthoredClassNames(source) {
1711
1481
  return classes;
1712
1482
  }
1713
1483
 
1484
+ const KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
1485
+ "include",
1486
+ "exclude",
1487
+ "compileSources",
1488
+ "contentScopeCheck",
1489
+ "quiet",
1490
+ "mode",
1491
+ "development",
1492
+ "production",
1493
+ "build",
1494
+ "hydration"
1495
+ ]);
1496
+ const RENAMED_KEYS = {
1497
+ // Replaced by the path-based form: package NAMES could not express a
1498
+ // sibling directory outside the project root, and resolving them meant
1499
+ // guessing at workspace layout.
1500
+ compilePackages: "compileSources"
1501
+ };
1502
+ function nearestKnownConfigKey(key) {
1503
+ const lower = key.toLowerCase();
1504
+ let best = null;
1505
+ let bestDistance = Number.POSITIVE_INFINITY;
1506
+ for (const candidate of KNOWN_TOP_LEVEL_KEYS) {
1507
+ const distance = editDistance(lower, candidate.toLowerCase());
1508
+ if (distance < bestDistance) {
1509
+ bestDistance = distance;
1510
+ best = candidate;
1511
+ }
1512
+ }
1513
+ return best !== null && bestDistance <= Math.max(1, Math.floor(key.length / 4)) ? best : null;
1514
+ }
1515
+ function editDistance(a, b) {
1516
+ let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
1517
+ for (let i = 1; i <= a.length; i += 1) {
1518
+ const current = [i];
1519
+ for (let j = 1; j <= b.length; j += 1) {
1520
+ const substitution = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
1521
+ current.push(Math.min(substitution, previous[j] + 1, current[j - 1] + 1));
1522
+ }
1523
+ previous = current;
1524
+ }
1525
+ return previous[b.length];
1526
+ }
1527
+ function findUnknownConfigKeys(options) {
1528
+ if (options === null || typeof options !== "object" || Array.isArray(options)) {
1529
+ return [];
1530
+ }
1531
+ const unknown = [];
1532
+ for (const key of Object.keys(options)) {
1533
+ if (KNOWN_TOP_LEVEL_KEYS.has(key)) continue;
1534
+ const renamedTo = RENAMED_KEYS[key];
1535
+ if (renamedTo !== void 0) {
1536
+ unknown.push({ key, renamedTo });
1537
+ continue;
1538
+ }
1539
+ const suggestion = nearestKnownConfigKey(key);
1540
+ unknown.push(suggestion === null ? { key } : { key, suggestion });
1541
+ }
1542
+ return unknown;
1543
+ }
1544
+ function unknownConfigKeysMessage(unknown) {
1545
+ const lines = unknown.map((entry) => {
1546
+ if (entry.renamedTo !== void 0) {
1547
+ return ` - \`${entry.key}\` was replaced by \`${entry.renamedTo}\``;
1548
+ }
1549
+ return entry.suggestion === void 0 ? ` - \`${entry.key}\`` : ` - \`${entry.key}\` \u2014 did you mean \`${entry.suggestion}\`?`;
1550
+ });
1551
+ return `[csszyx] ${unknown.length} plugin option(s) are not recognized and have no effect:
1552
+ ${lines.join("\n")}
1553
+ An unread option is silent, so whatever you configured it for is not happening.`;
1554
+ }
1555
+
1714
1556
  const GLOB_MAGIC_RE = /[*?[\]{}]/;
1715
1557
  const DEFAULT_IGNORED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", ".turbo", "dist", "build"]);
1716
1558
  function normalizeFileId(id) {
@@ -1863,17 +1705,19 @@ function injectMangleMapScript(html, mangleMap, options = {}) {
1863
1705
  const {
1864
1706
  prettyPrint = false,
1865
1707
  varMangleMap = {},
1866
- globalVarAliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX
1708
+ globalVarAliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX,
1709
+ installRuntimeObject = true
1867
1710
  } = options;
1868
1711
  const checksumMap = createHydrationMangleMap(mangleMap, varMangleMap);
1869
1712
  const jsonContent = safeJsonForScriptTag(checksumMap, prettyPrint);
1870
- const classMapContent = safeJsonForScriptTag(mangleMap);
1871
1713
  const varMapContent = safeJsonForScriptTag(varMangleMap);
1714
+ const reuseChecksumPayload = Object.keys(varMangleMap).length === 0;
1715
+ const classMapExpr = reuseChecksumPayload ? '(function(){var e=document.getElementById("__CSSZYX_MANGLE_MAP__");return e?JSON.parse(e.textContent):{}})()' : safeJsonForScriptTag(mangleMap);
1872
1716
  const scriptTag = `<script id="__CSSZYX_MANGLE_MAP__" type="application/json">${jsonContent}<\/script>`;
1873
1717
  const prefixContent = safeJsonForScriptTag(globalVarAliasPrefix);
1874
- const debugScript = `<script>(function(){var m=${classMapContent};var vm=${varMapContent};var gp=${prefixContent};var r={};var vr={};for(var k in m)r[m[k]]=k;for(var vk in vm){var vv=vm[vk];var vs=Array.isArray(vv)?vv:[vv];for(var vi=0;vi<vs.length;vi++)(vr[vs[vi]]||(vr[vs[vi]]=[])).push(vk)}var cs=document.documentElement.getAttribute("data-sz-checksum")||"";window.__csszyx={mangleMap:m,varMangleMap:vm,checksum:cs,decode:function(c){return r[c]},encode:function(c){return m[c]},decodeVar:function(v){return vr[v]||[]},encodeVar:function(v){return vm[v]},decodeGlobalVar:function(v){var a=vr[v]||[];return v.indexOf(gp)===0?a[0]:void 0},decodeAll:function(el){return(el.className||"").split(" ").map(function(c){return r[c]||c})}}})()<\/script>`;
1875
- const combined = `${scriptTag}
1876
- ${debugScript}`;
1718
+ const debugScript = `<script>(function(){var m=${classMapExpr};var vm=${varMapContent};var gp=${prefixContent};var r={};var vr={};for(var k in m)r[m[k]]=k;for(var vk in vm){var vv=vm[vk];var vs=Array.isArray(vv)?vv:[vv];for(var vi=0;vi<vs.length;vi++)(vr[vs[vi]]||(vr[vs[vi]]=[])).push(vk)}var cs=document.documentElement.getAttribute("data-sz-checksum")||"";window.__csszyx={mangleMap:m,varMangleMap:vm,checksum:cs,decode:function(c){return r[c]},encode:function(c){return m[c]},decodeVar:function(v){return vr[v]||[]},encodeVar:function(v){return vm[v]},decodeGlobalVar:function(v){var a=vr[v]||[];return v.indexOf(gp)===0?a[0]:void 0},decodeAll:function(el){return(el.className||"").split(" ").map(function(c){return r[c]||c})}}})()<\/script>`;
1719
+ const combined = installRuntimeObject ? `${scriptTag}
1720
+ ${debugScript}` : scriptTag;
1877
1721
  if (html.includes("</head>")) {
1878
1722
  return html.replace("</head>", `${combined}
1879
1723
  </head>`);
@@ -1978,6 +1822,42 @@ function escapeForDoubleQuotedString(value) {
1978
1822
  return escapeDoubleQuotedString(value);
1979
1823
  }
1980
1824
 
1825
+ function createMangleSizeAccount() {
1826
+ return { cssGzBefore: 0, cssGzAfter: 0, channels: /* @__PURE__ */ new Set() };
1827
+ }
1828
+ function resetMangleSizeAccount(account) {
1829
+ account.cssGzBefore = 0;
1830
+ account.cssGzAfter = 0;
1831
+ account.channels.clear();
1832
+ }
1833
+ function gzipBytes(text) {
1834
+ if (text.length === 0) return 0;
1835
+ return gzipSync(Buffer.from(text, "utf8")).length;
1836
+ }
1837
+ function recordCssPair(account, before, after) {
1838
+ if (before === after) {
1839
+ const bytes = gzipBytes(before);
1840
+ account.cssGzBefore += bytes;
1841
+ account.cssGzAfter += bytes;
1842
+ return;
1843
+ }
1844
+ account.cssGzBefore += gzipBytes(before);
1845
+ account.cssGzAfter += gzipBytes(after);
1846
+ }
1847
+ function computeMangleSizeVerdict(account, mapPayload) {
1848
+ const channels = sortStrings(account.channels);
1849
+ const mapCost = gzipBytes(mapPayload) * channels.length;
1850
+ const cssSaving = account.cssGzBefore - account.cssGzAfter;
1851
+ return { mapCost, cssSaving, net: mapCost - cssSaving, channels };
1852
+ }
1853
+ function mangleSizeMessage(verdict) {
1854
+ if (verdict.channels.length === 0) return null;
1855
+ if (verdict.net <= 0) return null;
1856
+ const cssPart = verdict.cssSaving >= 0 ? `the mangled CSS saves ${verdict.cssSaving} B` : `the mangled CSS COSTS ${-verdict.cssSaving} B (short tokens compress worse than the names they replaced)`;
1857
+ const channelPart = verdict.channels.length > 1 ? `${verdict.channels.join(" + ")} (${verdict.channels.length} copies)` : verdict.channels[0];
1858
+ return `[csszyx] production.mangle is making this build BIGGER: +${verdict.net} B gzipped. The runtime mangle map costs ${verdict.mapCost} B via ${channelPart}, while ${cssPart}. Mangling is a name-obfuscation feature; over a compressed response it does not reduce payload, because utility class names compress far better than the map they need. If you enabled it for size, set \`production.mangle: false\`. If you enabled it to hide class names, this is the expected price and you can ignore this. Narrowing \`production.mangleMapDelivery\` removes a map copy when only one channel is needed. (Measured on CSS and the map; class shortening inside JS chunks is not counted, so the real net is slightly better than this figure.)`;
1859
+ }
1860
+
1981
1861
  function isParserMode(value) {
1982
1862
  return value === "rust" || value === "oxc" || value === "babel";
1983
1863
  }
@@ -2093,127 +1973,6 @@ function writeThemeDts(opts) {
2093
1973
  writeFileSync(opts.outputPath, content, "utf-8");
2094
1974
  }
2095
1975
 
2096
- const VIRTUAL_MODULE_ID = "virtual:csszyx/mangle-map";
2097
- const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
2098
- const THEME_GROUPS_VIRTUAL_ID = "virtual:csszyx/theme-groups";
2099
- const RESOLVED_THEME_GROUPS_VIRTUAL_ID = `\0${THEME_GROUPS_VIRTUAL_ID}`;
2100
- const VIRTUAL_CHECKSUM_ID = "virtual:csszyx/checksum";
2101
- const RESOLVED_VIRTUAL_CHECKSUM_ID = `\0${VIRTUAL_CHECKSUM_ID}`;
2102
- function createMangleMapModule(mangleMap, checksum, varMangleMap = {}, cssVarMetrics = null) {
2103
- return `/**
2104
- * Auto-generated mangle map for csszyx.
2105
- * This module is generated at build time and contains the mapping
2106
- * from original class names and CSS variable names to mangled names.
2107
- *
2108
- * @generated
2109
- */
2110
-
2111
- export const mangleMap = ${JSON.stringify(mangleMap, null, 2)};
2112
-
2113
- export const varMangleMap = ${JSON.stringify(varMangleMap, null, 2)};
2114
-
2115
- export const cssVarMetrics = ${JSON.stringify(cssVarMetrics, null, 2)};
2116
-
2117
- export const checksum = ${JSON.stringify(checksum)};
2118
-
2119
- export default {
2120
- mangleMap,
2121
- varMangleMap,
2122
- cssVarMetrics,
2123
- checksum,
2124
- };
2125
- `;
2126
- }
2127
- function createChecksumModule(checksum) {
2128
- return `/**
2129
- * Auto-generated checksum for csszyx mangle map.
2130
- *
2131
- * @generated
2132
- */
2133
-
2134
- export const checksum = ${JSON.stringify(checksum)};
2135
-
2136
- export default checksum;
2137
- `;
2138
- }
2139
- function isVirtualModule(id) {
2140
- return id === VIRTUAL_MODULE_ID || id === VIRTUAL_CHECKSUM_ID || id === THEME_GROUPS_VIRTUAL_ID || id === MANGLE_RUNTIME_VIRTUAL_ID;
2141
- }
2142
- function resolveVirtualModule(id) {
2143
- if (id === VIRTUAL_MODULE_ID) {
2144
- return RESOLVED_VIRTUAL_MODULE_ID;
2145
- }
2146
- if (id === VIRTUAL_CHECKSUM_ID) {
2147
- return RESOLVED_VIRTUAL_CHECKSUM_ID;
2148
- }
2149
- if (id === THEME_GROUPS_VIRTUAL_ID) {
2150
- return RESOLVED_THEME_GROUPS_VIRTUAL_ID;
2151
- }
2152
- if (id === MANGLE_RUNTIME_VIRTUAL_ID) {
2153
- return RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID;
2154
- }
2155
- return void 0;
2156
- }
2157
- const MANGLE_RUNTIME_VIRTUAL_ID = "virtual:csszyx/mangle-runtime";
2158
- const RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID = `\0${MANGLE_RUNTIME_VIRTUAL_ID}`;
2159
- const MANGLE_MAP_PLACEHOLDER = "___CSSZYX_MANGLE_MAP___";
2160
- const VAR_MANGLE_MAP_PLACEHOLDER = "___CSSZYX_VAR_MANGLE_MAP___";
2161
- const CHECKSUM_PLACEHOLDER = "___CSSZYX_CHECKSUM___";
2162
- function createMangleRuntimeModule(globalVarAliasPrefix) {
2163
- return `/**
2164
- * Auto-generated by csszyx: installs the runtime mangle map from the bundle.
2165
- *
2166
- * @generated
2167
- */
2168
-
2169
- const m = ${MANGLE_MAP_PLACEHOLDER};
2170
- const vm = ${VAR_MANGLE_MAP_PLACEHOLDER};
2171
- const gp = ${JSON.stringify(globalVarAliasPrefix)};
2172
- const checksum = "${CHECKSUM_PLACEHOLDER}";
2173
-
2174
- if (typeof window !== 'undefined' && !window.__csszyx) {
2175
- const r = {};
2176
- const vr = {};
2177
- for (const k in m) r[m[k]] = k;
2178
- for (const vk in vm) {
2179
- const vv = vm[vk];
2180
- const vs = Array.isArray(vv) ? vv : [vv];
2181
- for (const v of vs) (vr[v] || (vr[v] = [])).push(vk);
2182
- }
2183
- window.__csszyx = {
2184
- mangleMap: m,
2185
- varMangleMap: vm,
2186
- checksum,
2187
- decode: (c) => r[c],
2188
- encode: (c) => m[c],
2189
- decodeVar: (v) => vr[v] || [],
2190
- encodeVar: (v) => vm[v],
2191
- decodeGlobalVar: (v) => {
2192
- const a = vr[v] || [];
2193
- return v.indexOf(gp) === 0 ? a[0] : undefined;
2194
- },
2195
- decodeAll: (el) => (el.className || '').split(' ').map((c) => r[c] || c),
2196
- };
2197
- }
2198
-
2199
- export {};
2200
- `;
2201
- }
2202
- function createThemeGroupsModule(tokens) {
2203
- const payload = JSON.stringify({
2204
- colors: tokens.colors,
2205
- textSizes: tokens.textSizes,
2206
- fontFamilies: tokens.fontFamilies,
2207
- fontWeights: tokens.fontWeights
2208
- });
2209
- return [
2210
- "// Auto-generated by csszyx from the @theme blocks in scanned CSS.",
2211
- "import { registerSzcnGroups } from '@csszyx/runtime';",
2212
- `registerSzcnGroups(${payload});`,
2213
- "export {};"
2214
- ].join("\n");
2215
- }
2216
-
2217
1976
  function registerWebpackAssetProcessor(compiler, processAssets) {
2218
1977
  compiler.hooks.compilation.tap("csszyx:post", (compilation) => {
2219
1978
  const stage = compiler.webpack?.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE || compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE;
@@ -2402,15 +2161,28 @@ function shouldWarnUnscopedMonorepo(sawTailwindEntry, tailwindEntryScoped, inMon
2402
2161
  function unscopedMonorepoMessage() {
2403
2162
  return '[csszyx] Tailwind content detection is UNSCOPED in a monorepo. Tailwind v4 climbs to the workspace root and scans sibling packages + docs (.md/.mdx/.txt are not ignored), which can generate phantom or broken url() classes and fail the build. Scope it in your Tailwind CSS entry:\n @import "tailwindcss" source(none);\n @source "."; /* this package, relative to the CSS file */\ncsszyx auto-injects @source for its generated classes, so only your own templates need listing. Guide: https://csszyx.com/docs/monorepo-content-scope/\nSilence (if a broad scan is intentional): csszyx({ contentScopeCheck: false }).';
2404
2163
  }
2164
+ function resolveQuietMode(quiet) {
2165
+ if (quiet === true || quiet === "all") return "all";
2166
+ if (quiet === "nudges") return "nudges";
2167
+ return "off";
2168
+ }
2405
2169
  function shouldEmitWarning(quiet, devOnly, isProduction) {
2406
- if (quiet) {
2170
+ const mode = resolveQuietMode(quiet);
2171
+ if (mode === "all") {
2407
2172
  return false;
2408
2173
  }
2409
- if (devOnly && isProduction) {
2174
+ if (devOnly && (isProduction || mode === "nudges")) {
2410
2175
  return false;
2411
2176
  }
2412
2177
  return true;
2413
2178
  }
2179
+ function shouldEmitMissingCssFallback(quiet, message) {
2180
+ return resolveQuietMode(quiet) !== "all" && szFallbackConsequenceOf(message) === "missing-css";
2181
+ }
2182
+ function emitMissingCssFallback(quiet, message, id, emit) {
2183
+ if (shouldEmitMissingCssFallback(quiet, message)) emit(`[csszyx] ${id}
2184
+ ${message}`);
2185
+ }
2414
2186
  function normalizeForMatch(p) {
2415
2187
  const n = normalizePathSeparators(p);
2416
2188
  return n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
@@ -2515,11 +2287,13 @@ function isPackagesSkippedSource(id, sourceDirs = []) {
2515
2287
  }
2516
2288
  return !isCompileSourceOptedIn(p, sourceDirs);
2517
2289
  }
2518
- function skippedSzFilesMessage(files) {
2290
+ function skippedSzFilesMessage(files, szvExportFiles = []) {
2519
2291
  const list = files.map((file) => ` - ${file}`).join("\n");
2520
- return `[csszyx] ${files.length} file(s) under packages/ contain \`sz\` but were skipped by ignore rules:
2292
+ const registryClause = szvExportFiles.length === 0 ? "" : `
2293
+ ${szvExportFiles.length} of them may export \`szv\` factories, so they stay out of the cross-module registry and every importer falls back to the runtime path.`;
2294
+ return `[csszyx] ${files.length} file(s) under packages/ use csszyx but were skipped by ignore rules:
2521
2295
  ${list}
2522
- Add the package directory to \`compileSources\` (or move the file out of packages/) \u2014 otherwise their \`sz\` produces no CSS.`;
2296
+ Add the package directory to \`compileSources\` (or move the file out of packages/) \u2014 otherwise their classes never reach the safelist.` + registryClause;
2523
2297
  }
2524
2298
  function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
2525
2299
  const safelistPath = normalizePathSeparators(path.join(rootDir, safelistFilename));
@@ -3160,20 +2934,33 @@ ${errors.join("\n")}`
3160
2934
  if (config?.enabled === true) {
3161
2935
  if (!config.tokens || config.tokens.length === 0) {
3162
2936
  throw new Error(
3163
- "[csszyx] production.mangleGlobalVars.enabled requires explicit tokens in Phase H v1."
2937
+ "[csszyx] production.mangleGlobalVars.enabled requires explicit tokens. Aliasing a property csszyx was not told about would rename references it cannot see."
3164
2938
  );
3165
2939
  }
3166
2940
  if (config.autoPrefix !== void 0 && config.autoPrefix !== "") {
3167
2941
  throw new Error(
3168
- "[csszyx] production.mangleGlobalVars.autoPrefix requires CSS pre-scan support and is not enabled in Phase H v1."
2942
+ "[csszyx] production.mangleGlobalVars.autoPrefix is not available: choosing tokens by prefix needs a CSS pre-scan that does not exist yet. List the tokens instead."
3169
2943
  );
3170
2944
  }
3171
2945
  }
3172
2946
  }
3173
2947
  function createCsszyxPlugins(options = {}) {
3174
2948
  assertGlobalVarMangleConfig(options);
3175
- let manglingEnabled = options.production?.mangle !== false;
2949
+ let manglingEnabled = options.production?.mangle === true;
2950
+ const importedStaticSzEnabled = options.build?.importedStaticSz ?? DEFAULT_IMPORTED_STATIC_SZ;
2951
+ const szvCrossModuleRegistry = /* @__PURE__ */ new Map();
2952
+ const szObjectProvidersExamined = /* @__PURE__ */ new Set();
2953
+ let specifierAliases = [];
3176
2954
  const mangleReserved = new Set(options.production?.mangleExclude ?? []);
2955
+ const mangleMapDelivery = options.production?.mangleMapDelivery ?? "both";
2956
+ if (!["both", "html", "bundle"].includes(mangleMapDelivery)) {
2957
+ throw new Error(
2958
+ `[csszyx] production.mangleMapDelivery must be 'both', 'html' or 'bundle'; got ${JSON.stringify(mangleMapDelivery)}.`
2959
+ );
2960
+ }
2961
+ const deliverMapInHtml = mangleMapDelivery !== "bundle";
2962
+ const deliverMapInBundle = mangleMapDelivery !== "html";
2963
+ const sizeAccount = createMangleSizeAccount();
3177
2964
  const astBudgetOverride = options.build?.astBudgetLimit;
3178
2965
  const prescanAstBudget = astBudgetOverride ?? 5e5;
3179
2966
  const cacheRequested = (options.build?.cache ?? DEFAULT_BUILD_CONFIG.cache) !== false;
@@ -3195,7 +2982,11 @@ function createCsszyxPlugins(options = {}) {
3195
2982
  );
3196
2983
  }
3197
2984
  const compileSources = options.compileSources ?? [];
3198
- const quiet = options.quiet === true;
2985
+ const quiet = resolveQuietMode(options.quiet);
2986
+ const unknownConfigKeys = findUnknownConfigKeys(options);
2987
+ if (unknownConfigKeys.length > 0) {
2988
+ emitWarning(unknownConfigKeysMessage(unknownConfigKeys));
2989
+ }
3199
2990
  function emitWarning(message, opts = {}) {
3200
2991
  if (shouldEmitWarning(quiet, opts.devOnly ?? false, process.env.NODE_ENV === "production")) {
3201
2992
  console.warn(message);
@@ -3232,6 +3023,7 @@ function createCsszyxPlugins(options = {}) {
3232
3023
  const state = {
3233
3024
  classes: /* @__PURE__ */ new Set(),
3234
3025
  parsedTheme: null,
3026
+ scanCssTheme: null,
3235
3027
  autoThemeCssFiles: [],
3236
3028
  sawTailwindEntry: false,
3237
3029
  sawAnyCss: false,
@@ -3240,6 +3032,7 @@ function createCsszyxPlugins(options = {}) {
3240
3032
  contentScopeWarningEmitted: false,
3241
3033
  spreadWarnings: /* @__PURE__ */ new Set(),
3242
3034
  skippedSzFiles: /* @__PURE__ */ new Set(),
3035
+ skippedSzvExportFiles: /* @__PURE__ */ new Set(),
3243
3036
  skipWarningEmitted: false,
3244
3037
  classesCapped: false,
3245
3038
  ownedClasses: /* @__PURE__ */ new Set(),
@@ -3334,56 +3127,14 @@ function createCsszyxPlugins(options = {}) {
3334
3127
  }
3335
3128
  }
3336
3129
  function runAutoThemeScan(rootDir) {
3337
- if (options.build?.scanCss) {
3338
- return;
3339
- }
3340
3130
  refreshCompileSourceDirs();
3341
- const cssFiles = [];
3342
- const walk = (dir) => {
3343
- let entries;
3344
- try {
3345
- entries = fs.readdirSync(dir, { withFileTypes: true });
3346
- } catch {
3347
- return;
3348
- }
3349
- for (const entry of entries) {
3350
- if (entry.isDirectory()) {
3351
- if (!IGNORE_DIRS.has(entry.name) && !entry.name.startsWith(".")) {
3352
- walk(path.join(dir, entry.name));
3353
- }
3354
- continue;
3355
- }
3356
- if (entry.name.endsWith(".css")) {
3357
- cssFiles.push(path.join(dir, entry.name));
3358
- }
3359
- }
3360
- };
3361
- walk(rootDir);
3362
- const normRoot = normalizeForMatch(rootDir);
3363
- for (const sourceDir of compileSourceDirs) {
3364
- if (sourceDir === normRoot || sourceDir.startsWith(`${normRoot}/`)) {
3365
- continue;
3366
- }
3367
- walk(sourceDir);
3368
- }
3369
- const themes = [];
3370
- const themeFiles = [];
3371
- for (const file of cssFiles) {
3372
- let content;
3373
- try {
3374
- content = fs.readFileSync(file, "utf-8");
3375
- } catch {
3376
- continue;
3377
- }
3378
- if (!content.includes("@theme")) {
3379
- continue;
3380
- }
3381
- themes.push(parseThemeBlocks(content));
3382
- themeFiles.push(file);
3383
- }
3384
- state.autoThemeCssFiles = themeFiles;
3385
- if (themes.length > 0) {
3386
- state.parsedTheme = mergeThemes(themes);
3131
+ const discovered = discoverProjectTheme(rootDir, [...compileSourceDirs]);
3132
+ state.autoThemeCssFiles = discovered.files;
3133
+ const sources = [state.scanCssTheme, discovered.theme].filter(
3134
+ (theme) => theme !== null
3135
+ );
3136
+ if (sources.length > 0) {
3137
+ state.parsedTheme = mergeThemes(sources);
3387
3138
  }
3388
3139
  }
3389
3140
  function isHardIgnored(id) {
@@ -3399,6 +3150,18 @@ function createCsszyxPlugins(options = {}) {
3399
3150
  function transformConfiguredSource(source, filename, astBudget) {
3400
3151
  const compilerOptions = createCompilerOptions(astBudget);
3401
3152
  const effectiveFilename = normalizeSourceFilename(filename);
3153
+ const crossModuleStatics = resolveCrossModuleStaticsFor(
3154
+ szvCrossModuleRegistry,
3155
+ filename,
3156
+ source,
3157
+ specifierAliases
3158
+ );
3159
+ if (crossModuleStatics.szvConfigs !== void 0) {
3160
+ compilerOptions.crossModuleStatics = crossModuleStatics.szvConfigs;
3161
+ }
3162
+ if (crossModuleStatics.szObjects !== void 0) {
3163
+ compilerOptions.crossModuleSzObjects = crossModuleStatics.szObjects;
3164
+ }
3402
3165
  const cacheRoot = resolveTransformCacheDir(state.rootDir, options.build?.cacheDir);
3403
3166
  if (cacheEnabled) {
3404
3167
  evictTransformCacheOnce();
@@ -3510,6 +3273,11 @@ function createCsszyxPlugins(options = {}) {
3510
3273
  mangleVars: compilerOptions.mangleVars,
3511
3274
  mangleVarHoistMaxDepth: compilerOptions.mangleVarHoistMaxDepth,
3512
3275
  globalVarAliases: normalizeGlobalVarAliasesForCache(compilerOptions.globalVarAliases),
3276
+ // The registry entries fed to this file are part of its identity:
3277
+ // module A's config change must miss B's cached transform, or the
3278
+ // cache serves a stale table.
3279
+ crossModuleStatics: compilerOptions.crossModuleStatics === void 0 ? void 0 : JSON.stringify(compilerOptions.crossModuleStatics),
3280
+ crossModuleSzObjects: compilerOptions.crossModuleSzObjects === void 0 ? void 0 : JSON.stringify(compilerOptions.crossModuleSzObjects),
3513
3281
  filename: effectiveFilename,
3514
3282
  source
3515
3283
  };
@@ -3518,19 +3286,35 @@ function createCsszyxPlugins(options = {}) {
3518
3286
  if (parserMode !== "rust" || files.length <= 1) {
3519
3287
  return transformPrescanSourcesIndividually(files);
3520
3288
  }
3289
+ const perFile = [];
3290
+ const batchable = [];
3291
+ for (const file of files) {
3292
+ (hasCrossModuleStatics(file) ? perFile : batchable).push(file);
3293
+ }
3294
+ const individual = transformPrescanSourcesIndividually(perFile);
3521
3295
  const compilerOptions = createCompilerOptions(prescanAstBudget);
3522
3296
  const cacheRoot = resolveTransformCacheDir(state.rootDir, options.build?.cacheDir);
3523
3297
  const results = /* @__PURE__ */ new Map();
3524
3298
  if (cacheEnabled) evictTransformCacheOnce();
3525
3299
  ensureRustTransformAvailable();
3526
- const misses = collectRustPrescanMisses(files, compilerOptions, cacheRoot, results);
3527
- if (misses.length === 0) return orderPrescanResults(files, results);
3528
- try {
3529
- runRustPrescanBatch(misses, compilerOptions, cacheRoot, results);
3530
- } catch {
3531
- runRustPrescanFallback(misses, results);
3300
+ const misses = collectRustPrescanMisses(batchable, compilerOptions, cacheRoot, results);
3301
+ if (misses.length > 0) {
3302
+ try {
3303
+ runRustPrescanBatch(misses, compilerOptions, cacheRoot, results);
3304
+ } catch {
3305
+ runRustPrescanFallback(misses, results);
3306
+ }
3532
3307
  }
3533
- return orderPrescanResults(files, results);
3308
+ return [...individual, ...orderPrescanResults(batchable, results)];
3309
+ }
3310
+ function hasCrossModuleStatics(file) {
3311
+ const resolved = resolveCrossModuleStaticsFor(
3312
+ szvCrossModuleRegistry,
3313
+ file.filePath,
3314
+ file.content,
3315
+ specifierAliases
3316
+ );
3317
+ return resolved.szvConfigs !== void 0 || resolved.szObjects !== void 0;
3534
3318
  }
3535
3319
  function collectRustPrescanMisses(files, compilerOptions, cacheRoot, results) {
3536
3320
  const misses = [];
@@ -3678,7 +3462,7 @@ function createCsszyxPlugins(options = {}) {
3678
3462
  }
3679
3463
  }
3680
3464
  function recordPackagesSkipIfSz(filePath) {
3681
- if (!isPackagesSkippedSource(filePath, compileSourceDirs)) {
3465
+ if (state.skippedSzFiles.has(filePath) || !isPackagesSkippedSource(filePath, compileSourceDirs)) {
3682
3466
  return;
3683
3467
  }
3684
3468
  let content;
@@ -3687,8 +3471,12 @@ function createCsszyxPlugins(options = {}) {
3687
3471
  } catch {
3688
3472
  return;
3689
3473
  }
3690
- if (content.includes("sz=") || content.includes("szs=") || content.includes("sz:")) {
3691
- state.skippedSzFiles.add(filePath);
3474
+ if (!fileMayContainSafelistableSz(content)) {
3475
+ return;
3476
+ }
3477
+ state.skippedSzFiles.add(filePath);
3478
+ if (mayExportSzvFactories(content)) {
3479
+ state.skippedSzvExportFiles.add(filePath);
3692
3480
  }
3693
3481
  }
3694
3482
  function processPrescanTransform(filePath, content, result, discoveredClasses, rawDiscoveredClasses) {
@@ -3719,12 +3507,73 @@ function createCsszyxPlugins(options = {}) {
3719
3507
  }
3720
3508
  collectPrescanResult(result, filePath, discoveredClasses, rawDiscoveredClasses);
3721
3509
  }
3510
+ function refreshSzvRegistryEntry(filePath, content) {
3511
+ if (!shouldProcessSource(filePath)) return;
3512
+ if (content === null) {
3513
+ szvCrossModuleRegistry.delete(normalizePathSeparators(filePath));
3514
+ return;
3515
+ }
3516
+ recordSzvRegistryFile(szvCrossModuleRegistry, filePath, content);
3517
+ if (importedStaticSzEnabled) {
3518
+ recordSzObjectRegistryFile(szvCrossModuleRegistry, filePath, content);
3519
+ szObjectProvidersExamined.add(normalizePathSeparators(filePath));
3520
+ recordProvidersDemandedBy(filePath, content);
3521
+ }
3522
+ }
3523
+ function recordProvidersDemandedBy(filePath, content) {
3524
+ if (!fileMayContainSafelistableSz(content)) return;
3525
+ const directory = path.dirname(filePath);
3526
+ for (const specifier of importedSpecifiersIn(content)) {
3527
+ for (const base of specifierBases(specifier, directory, specifierAliases)) {
3528
+ const providerPath = resolveProviderPathWith(base, isReadableProviderFile);
3529
+ if (providerPath === void 0) continue;
3530
+ const key = normalizePathSeparators(providerPath);
3531
+ if (!szObjectProvidersExamined.has(key)) {
3532
+ szObjectProvidersExamined.add(key);
3533
+ readAndRecordSzObjectProvider(providerPath);
3534
+ }
3535
+ break;
3536
+ }
3537
+ }
3538
+ }
3539
+ function readAndRecordSzObjectProvider(providerPath) {
3540
+ let content;
3541
+ try {
3542
+ content = fs.readFileSync(providerPath, "utf-8");
3543
+ } catch {
3544
+ return;
3545
+ }
3546
+ recordSzObjectRegistryFile(szvCrossModuleRegistry, providerPath, content);
3547
+ }
3548
+ function recordDemandedSzObjectProviders(seenSourcePaths, demand) {
3549
+ for (const base of demand) {
3550
+ const providerPath = resolveProviderPath(seenSourcePaths, base);
3551
+ if (providerPath === void 0) continue;
3552
+ szObjectProvidersExamined.add(normalizePathSeparators(providerPath));
3553
+ readAndRecordSzObjectProvider(providerPath);
3554
+ }
3555
+ }
3556
+ function refreshSzvRegistryEntryFromDisk(filePath) {
3557
+ if (!shouldProcessSource(filePath)) return;
3558
+ let content;
3559
+ try {
3560
+ content = fs.readFileSync(filePath, "utf-8");
3561
+ } catch {
3562
+ refreshSzvRegistryEntry(filePath, null);
3563
+ return;
3564
+ }
3565
+ refreshSzvRegistryEntry(filePath, content);
3566
+ }
3722
3567
  function prescanAndWriteClasses() {
3723
3568
  refreshCompileSourceDirs();
3569
+ szvCrossModuleRegistry.clear();
3570
+ szObjectProvidersExamined.clear();
3724
3571
  const prescanStarted = performance.now();
3725
3572
  const discoveredClasses = /* @__PURE__ */ new Set();
3726
3573
  const rawDiscoveredClasses = /* @__PURE__ */ new Set();
3727
3574
  const prescanSources = [];
3575
+ const seenSourcePaths = /* @__PURE__ */ new Set();
3576
+ const szObjectDemand = /* @__PURE__ */ new Set();
3728
3577
  function collectPrescanSource(filePath) {
3729
3578
  if (!shouldProcessSource(filePath)) {
3730
3579
  recordPackagesSkipIfSz(filePath);
@@ -3737,10 +3586,25 @@ function createCsszyxPlugins(options = {}) {
3737
3586
  return;
3738
3587
  }
3739
3588
  recordAuthoredClasses(content);
3589
+ recordSzvRegistryEntries(filePath, content);
3590
+ seenSourcePaths.add(normalizePathSeparators(filePath));
3740
3591
  if (fileMayContainSafelistableSz(content)) {
3741
3592
  prescanSources.push({ filePath, content });
3593
+ recordSzObjectDemand(filePath, content);
3742
3594
  }
3743
3595
  }
3596
+ function recordSzObjectDemand(filePath, content) {
3597
+ if (!importedStaticSzEnabled) return;
3598
+ const directory = path.dirname(filePath);
3599
+ for (const specifier of importedSpecifiersIn(content)) {
3600
+ for (const base of specifierBases(specifier, directory, specifierAliases)) {
3601
+ szObjectDemand.add(base);
3602
+ }
3603
+ }
3604
+ }
3605
+ function recordSzvRegistryEntries(filePath, content) {
3606
+ recordSzvRegistryFile(szvCrossModuleRegistry, filePath, content);
3607
+ }
3744
3608
  function scanDir(dir) {
3745
3609
  let entries;
3746
3610
  try {
@@ -3768,6 +3632,7 @@ function createCsszyxPlugins(options = {}) {
3768
3632
  }
3769
3633
  scanDir(sourceDir);
3770
3634
  }
3635
+ recordDemandedSzObjectProviders(seenSourcePaths, szObjectDemand);
3771
3636
  const prescanContentByPath = new Map(
3772
3637
  prescanSources.map((file) => [file.filePath, file.content])
3773
3638
  );
@@ -3961,6 +3826,9 @@ function createCsszyxPlugins(options = {}) {
3961
3826
  usesMerge: false,
3962
3827
  usesSzcn: false,
3963
3828
  usesSzPart: false,
3829
+ usesSzvPick: false,
3830
+ usesSzvPick1: false,
3831
+ szPartArgsProvable: true,
3964
3832
  usesColorVar: false,
3965
3833
  usesSpacingVar: false,
3966
3834
  usesUnitVar: false
@@ -3981,16 +3849,20 @@ function createCsszyxPlugins(options = {}) {
3981
3849
  if (message.includes("unresolvable sz spread")) {
3982
3850
  state.spreadWarnings.add(`${id}
3983
3851
  ${message}`);
3984
- } else if (message.includes("AST budget exceeded")) {
3852
+ continue;
3853
+ }
3854
+ if (message.includes("AST budget exceeded")) {
3985
3855
  console.warn(`[csszyx] ${id}
3986
3856
  ${message}`);
3857
+ continue;
3987
3858
  }
3859
+ emitMissingCssFallback(quiet, message, id, console.warn);
3988
3860
  }
3989
- if (quiet || result.diagnostics.length === 0 || process.env.NODE_ENV === "production") {
3861
+ if (quiet !== "off" || result.diagnostics.length === 0 || process.env.NODE_ENV === "production") {
3990
3862
  return;
3991
3863
  }
3992
3864
  for (const message of result.diagnostics) {
3993
- if (message.includes("unresolvable sz spread") || message.includes("AST budget exceeded")) {
3865
+ if (message.includes("unresolvable sz spread") || message.includes("AST budget exceeded") || szFallbackConsequenceOf(message) === "missing-css") {
3994
3866
  continue;
3995
3867
  }
3996
3868
  warn(`[csszyx] ${id}
@@ -4005,6 +3877,9 @@ function createCsszyxPlugins(options = {}) {
4005
3877
  usesMerge: result.usesMerge,
4006
3878
  usesSzcn: result.usesSzcn,
4007
3879
  usesSzPart: result.usesSzPart,
3880
+ usesSzvPick: result.usesSzvPick,
3881
+ usesSzvPick1: result.usesSzvPick1,
3882
+ szPartArgsProvable: result.szPartArgsProvable,
4008
3883
  usesColorVar: result.usesColorVar,
4009
3884
  usesSpacingVar: result.usesSpacingVar,
4010
3885
  usesUnitVar: result.usesUnitVar,
@@ -4047,36 +3922,58 @@ function createCsszyxPlugins(options = {}) {
4047
3922
  return transformedCode;
4048
3923
  }
4049
3924
  function requiredRuntimeHelpers(output) {
4050
- const helpers = [];
4051
- if (output.usesRuntime) helpers.push("_sz");
4052
- if (output.usesMerge) helpers.push("_szMerge");
4053
- if (output.usesSzcn) helpers.push("_szcn");
4054
- if (output.usesSzPart) helpers.push("_szPart");
4055
- if (output.usesColorVar) helpers.push("__szColorVar");
4056
- if (output.usesSpacingVar) helpers.push("__szSpacingVar");
4057
- if (output.usesUnitVar) helpers.push("__szUnitVar");
4058
- return helpers;
3925
+ return runtimeHelperGroupsFromUsage(output);
4059
3926
  }
4060
3927
  function injectRuntimeHelpers(code, output) {
4061
- const imports = requiredRuntimeHelpers(output);
4062
- const hasRuntimeImport = imports.length > 0 && code.includes("@csszyx/runtime");
4063
- const needed = hasRuntimeImport ? imports.filter((name) => !importsRuntimeHelper(code, name)) : imports;
4064
- if (needed.length === 0) return null;
4065
- const existingImport = findRuntimeImportClause(code);
3928
+ const groups = requiredRuntimeHelpers(output);
3929
+ let result = null;
3930
+ let current = code;
3931
+ if (groups.merge.length > 0 && !current.includes("@csszyx/runtime/merge")) {
3932
+ current = insertRuntimeImport(
3933
+ current,
3934
+ `import { ${groups.merge.join(", ")} } from '@csszyx/runtime/merge';
3935
+ `
3936
+ );
3937
+ result = current;
3938
+ }
3939
+ const imports = groups.barrel;
3940
+ const hasRuntimeImport = imports.length > 0 && current.includes("@csszyx/runtime");
3941
+ const needed = hasRuntimeImport ? imports.filter((name) => !importsRuntimeHelper(current, name)) : imports;
3942
+ if (needed.length === 0) return result;
3943
+ const existingImport = findRuntimeImportClause(current);
4066
3944
  if (existingImport) {
4067
- return code.replace(
3945
+ return current.replace(
4068
3946
  existingImport.statement,
4069
3947
  `${existingImport.prefixWithBody}, ${needed.join(", ")} } from '@csszyx/runtime'`
4070
3948
  );
4071
3949
  }
4072
3950
  const importStatement = `import { ${needed.join(", ")} } from '@csszyx/runtime';
4073
3951
  `;
4074
- return insertRuntimeImport(code, importStatement);
3952
+ return insertRuntimeImport(current, importStatement);
3953
+ }
3954
+ function themeGroupTokens() {
3955
+ const theme = state.parsedTheme;
3956
+ return {
3957
+ colors: theme?.colors ?? [],
3958
+ textSizes: theme?.textSizes ?? [],
3959
+ fontFamilies: theme?.fonts ?? [],
3960
+ fontWeights: theme?.fontWeights ?? []
3961
+ };
4075
3962
  }
4076
3963
  function injectThemeGroups(code, transformedCode, id, usesSzcn) {
4077
- if (!usesSzcn && !/\bszcn\s*\(/.test(code) || transformedCode.includes(THEME_GROUPS_VIRTUAL_ID) || !shouldProcessSource(id)) {
3964
+ if (!usesSzcn && !/\bszcn\s*\(/.test(code) || transformedCode.includes(THEME_GROUPS_VIRTUAL_ID) || transformedCode.includes(THEME_GROUPS_FILE_MARKER) || !shouldProcessSource(id)) {
4078
3965
  return null;
4079
3966
  }
3967
+ if (activeFramework === "webpack") {
3968
+ const groups = ensureThemeGroupsFile(
3969
+ state.rootDir,
3970
+ path.join(state.rootDir, ".csszyx")
3971
+ );
3972
+ if (groups.file === null) return null;
3973
+ const [from] = id.split("?");
3974
+ return `import '${themeGroupsSpecifier(from, groups.file)}';
3975
+ ${transformedCode}`;
3976
+ }
4080
3977
  return `import '${THEME_GROUPS_VIRTUAL_ID}';
4081
3978
  ${transformedCode}`;
4082
3979
  }
@@ -4086,7 +3983,7 @@ ${transformedCode}`;
4086
3983
  if (activeFramework !== "vite" && activeFramework !== "rollup") {
4087
3984
  return null;
4088
3985
  }
4089
- if (!manglingEnabled || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(MANGLE_RUNTIME_VIRTUAL_ID)) {
3986
+ if (!manglingEnabled || !deliverMapInBundle || !shouldProcessSource(id) || !MANGLE_RUNTIME_CONSUMER_RE.test(transformedCode) || transformedCode.includes(MANGLE_RUNTIME_VIRTUAL_ID)) {
4090
3987
  return null;
4091
3988
  }
4092
3989
  return insertRuntimeImport(transformedCode, `import '${MANGLE_RUNTIME_VIRTUAL_ID}';
@@ -4156,16 +4053,11 @@ ${transformedCode}`;
4156
4053
  return createChecksumModule(state.checksum);
4157
4054
  }
4158
4055
  if (id === RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID) {
4056
+ sizeAccount.channels.add("bundle");
4159
4057
  return createMangleRuntimeModule(globalVarAliasPrefix);
4160
4058
  }
4161
4059
  if (id === RESOLVED_THEME_GROUPS_VIRTUAL_ID) {
4162
- const theme = state.parsedTheme;
4163
- return createThemeGroupsModule({
4164
- colors: theme?.colors ?? [],
4165
- textSizes: theme?.textSizes ?? [],
4166
- fontFamilies: theme?.fonts ?? [],
4167
- fontWeights: theme?.fontWeights ?? []
4168
- });
4060
+ return createThemeGroupsModule(themeGroupTokens());
4169
4061
  }
4170
4062
  return null;
4171
4063
  },
@@ -4179,7 +4071,11 @@ ${transformedCode}`;
4179
4071
  if (shouldProcessCss(id)) {
4180
4072
  return true;
4181
4073
  }
4182
- return shouldProcessSource(id);
4074
+ if (shouldProcessSource(id)) {
4075
+ return true;
4076
+ }
4077
+ recordPackagesSkipIfSz(id);
4078
+ return false;
4183
4079
  },
4184
4080
  /**
4185
4081
  * Core transform: detects sz prop, compiles to className, injects runtime, collects classes.
@@ -4203,7 +4099,12 @@ ${transformedCode}`;
4203
4099
  if (matchesScriptExtension(id, [".css"])) {
4204
4100
  return transformTailwindCssEntry(code, id);
4205
4101
  }
4206
- const hasSzProp = code.includes("sz=") || code.includes("szs=") || /\bsz\s*:\s*["'{]/.test(code) || code.includes('sz: "');
4102
+ const hasSzProp = code.includes("sz=") || code.includes("szs=") || /\bsz\s*:\s*["'{]/.test(code) || code.includes('sz: "') || // szr-only modules (no sz attribute) historically skipped the
4103
+ // compiler entirely — which also skipped the szr import
4104
+ // rewrite AND the szr fallback diagnostics. The substring is
4105
+ // deliberately loose; a false positive only costs one file
4106
+ // the compiler pass, which then changes nothing.
4107
+ code.includes("szr(");
4207
4108
  const output = hasSzProp ? transformSzSource(code, id, (message) => this.warn(message)) : unchangedPreTransform(code);
4208
4109
  if (!hasSzProp && shouldProcessSource(id)) {
4209
4110
  recordFileVarMangleEntries(state, id, []);
@@ -4261,9 +4162,13 @@ ${transformedCode}`;
4261
4162
  }
4262
4163
  if (!state.skipWarningEmitted && state.skippedSzFiles.size > 0) {
4263
4164
  state.skipWarningEmitted = true;
4264
- emitWarning(skippedSzFilesMessage(sortStrings$1(state.skippedSzFiles)), {
4265
- devOnly: true
4266
- });
4165
+ emitWarning(
4166
+ skippedSzFilesMessage(
4167
+ sortStrings$1(state.skippedSzFiles),
4168
+ sortStrings$1(state.skippedSzvExportFiles)
4169
+ ),
4170
+ { devOnly: state.skippedSzvExportFiles.size === 0 }
4171
+ );
4267
4172
  }
4268
4173
  if (state.classesCapped) {
4269
4174
  emitWarning(
@@ -4285,7 +4190,10 @@ ${transformedCode}`;
4285
4190
  recordGlobalVarSourceFile(state, id, null);
4286
4191
  recordFileVarMangleEntries(state, id, []);
4287
4192
  recordFileCSSVariableMetrics(state, id, null);
4193
+ refreshSzvRegistryEntry(id, null);
4194
+ return;
4288
4195
  }
4196
+ refreshSzvRegistryEntryFromDisk(id);
4289
4197
  },
4290
4198
  /**
4291
4199
  * Webpack hook: pre-scans source files before compilation for Tailwind class discovery.
@@ -4293,18 +4201,37 @@ ${transformedCode}`;
4293
4201
  */
4294
4202
  webpack(compiler) {
4295
4203
  activeFramework = "webpack";
4204
+ compiler.hooks?.beforeCompile?.tap?.("csszyx:theme-groups", () => {
4205
+ const root = compiler.context || process.cwd();
4206
+ ensureThemeGroupsFile(root, path.join(root, ".csszyx"));
4207
+ });
4296
4208
  if (compiler.options?.mode === "development") {
4297
4209
  manglingEnabled = false;
4298
4210
  }
4211
+ if (manglingEnabled && mangleMapDelivery !== "both") {
4212
+ console.warn(
4213
+ `[csszyx] production.mangleMapDelivery: '${mangleMapDelivery}' has no effect on the webpack lane \u2014 map delivery only narrows on vite/rollup builds.`
4214
+ );
4215
+ }
4299
4216
  compiler.hooks.beforeCompile.tap("csszyx:prescan", () => {
4300
4217
  announceActiveParser();
4301
4218
  const root = compiler.context || process.cwd();
4302
4219
  state.rootDir = root;
4220
+ specifierAliases = collectSpecifierAliases(
4221
+ root,
4222
+ compiler.options?.resolve?.alias
4223
+ );
4303
4224
  evictTransformCacheOnce();
4304
4225
  if (state.classes.size === 0) {
4305
4226
  prescanAndWriteClasses();
4306
4227
  }
4307
- state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
4228
+ for (const changed of compiler.modifiedFiles ?? []) {
4229
+ refreshSzvRegistryEntryFromDisk(changed);
4230
+ }
4231
+ for (const removed of compiler.removedFiles ?? []) {
4232
+ refreshSzvRegistryEntry(removed, null);
4233
+ }
4234
+ state.scanCssTheme = runThemeScan(root, options.build?.scanCss) ?? state.scanCssTheme;
4308
4235
  runAutoThemeScan(root);
4309
4236
  });
4310
4237
  if (options.build?.scanCss) {
@@ -4333,12 +4260,13 @@ ${transformedCode}`;
4333
4260
  announceActiveParser();
4334
4261
  const root = config.root || process.cwd();
4335
4262
  state.rootDir = root;
4263
+ specifierAliases = collectSpecifierAliases(root, config.resolve?.alias);
4336
4264
  if (config.command === "serve") {
4337
4265
  manglingEnabled = false;
4338
4266
  }
4339
4267
  evictTransformCacheOnce();
4340
4268
  prescanAndWriteClasses();
4341
- state.parsedTheme = runThemeScan(root, options.build?.scanCss) ?? state.parsedTheme;
4269
+ state.scanCssTheme = runThemeScan(root, options.build?.scanCss) ?? state.scanCssTheme;
4342
4270
  runAutoThemeScan(root);
4343
4271
  },
4344
4272
  /**
@@ -4357,15 +4285,17 @@ ${transformedCode}`;
4357
4285
  ctx.server.moduleGraph.invalidateModule(themeGroupsModule);
4358
4286
  }
4359
4287
  };
4360
- if (scanCss) {
4288
+ if (ctx.file.endsWith(".css")) {
4361
4289
  const root = ctx.server.config.root || process.cwd();
4362
- if (matchesAnyPattern(ctx.file, scanCss, root)) {
4363
- state.parsedTheme = runThemeScan(root, scanCss) ?? state.parsedTheme;
4364
- reloadThemeGroupsModule();
4290
+ const before = createThemeGroupsModule(themeGroupTokens());
4291
+ if (scanCss && matchesAnyPattern(ctx.file, scanCss, root)) {
4292
+ state.scanCssTheme = runThemeScan(root, scanCss) ?? state.scanCssTheme;
4365
4293
  }
4366
- } else if (ctx.file.endsWith(".css")) {
4367
- runAutoThemeScan(ctx.server.config.root || process.cwd());
4294
+ runAutoThemeScan(root);
4368
4295
  reloadThemeGroupsModule();
4296
+ if (createThemeGroupsModule(themeGroupTokens()) !== before) {
4297
+ ctx.server.ws.send({ type: "full-reload" });
4298
+ }
4369
4299
  }
4370
4300
  if (!shouldProcessSource(ctx.file)) {
4371
4301
  return;
@@ -4374,8 +4304,10 @@ ${transformedCode}`;
4374
4304
  try {
4375
4305
  fileContent = fs.readFileSync(ctx.file, "utf-8");
4376
4306
  } catch {
4307
+ refreshSzvRegistryEntry(ctx.file, null);
4377
4308
  return;
4378
4309
  }
4310
+ refreshSzvRegistryEntry(ctx.file, fileContent);
4379
4311
  if (!fileContent.includes("sz=") && !fileContent.includes("szs=") && !/\bsz\s*:\s*["'{]/.test(fileContent)) {
4380
4312
  trackGlobalVarSourceFile(ctx.file, fileContent);
4381
4313
  recordFileVarMangleEntries(state, ctx.file, []);
@@ -4436,8 +4368,12 @@ ${transformedCode}`;
4436
4368
  mode: "script",
4437
4369
  minify: process.env.NODE_ENV === "production",
4438
4370
  varMangleMap: state.varMangleMap,
4439
- globalVarAliasPrefix
4371
+ globalVarAliasPrefix,
4372
+ installRuntimeObject: deliverMapInHtml
4440
4373
  });
4374
+ if (manglingEnabled) {
4375
+ sizeAccount.channels.add("html");
4376
+ }
4441
4377
  if (state.recoveryTokens.size > 0) {
4442
4378
  const isProduction = process.env.NODE_ENV === "production";
4443
4379
  const { manifest, strippedDevOnlyPaths } = buildRecoveryManifest(
@@ -4486,7 +4422,7 @@ ${transformedCode}`;
4486
4422
  return manifest;
4487
4423
  }
4488
4424
  function rewriteOutputCss(source, file, shouldMangle, mangledSources, externalClasses) {
4489
- let css = rewriteCssWithValidatedGlobalVarPlan(
4425
+ const css = rewriteCssWithValidatedGlobalVarPlan(
4490
4426
  source,
4491
4427
  file,
4492
4428
  state.globalVarValidationResult
@@ -4499,8 +4435,9 @@ ${transformedCode}`;
4499
4435
  });
4500
4436
  for (const className of result.mangledClasses) mangledSources.add(className);
4501
4437
  for (const className of result.unmangledClasses) externalClasses.add(className);
4502
- if (result.transformedCount > 0) css = result.css;
4503
- return css;
4438
+ const mangled = result.transformedCount > 0 ? result.css : css;
4439
+ recordCssPair(sizeAccount, css, mangled);
4440
+ return mangled;
4504
4441
  } catch (error) {
4505
4442
  if (isCssSyntaxError(error)) return css;
4506
4443
  throw error;
@@ -4512,6 +4449,16 @@ ${transformedCode}`;
4512
4449
  collectMangleHybridHazards(state.mangleMap, mangledSources, externalClasses)
4513
4450
  );
4514
4451
  if (message) console.warn(message);
4452
+ reportMangleSize();
4453
+ }
4454
+ function reportMangleSize() {
4455
+ const verdict = computeMangleSizeVerdict(
4456
+ sizeAccount,
4457
+ JSON.stringify(createHydrationMangleMap(state.mangleMap, state.varMangleMap))
4458
+ );
4459
+ const message = mangleSizeMessage(verdict);
4460
+ if (message) console.warn(message);
4461
+ resetMangleSizeAccount(sizeAccount);
4515
4462
  }
4516
4463
  function rewriteWebpackCodeAsset(file, source, shouldMangle, compilation, compiler) {
4517
4464
  if (shouldMangle && file.endsWith(".html")) {
@@ -4595,7 +4542,9 @@ ${transformedCode}`;
4595
4542
  collectRollupGlobalVarCssAssets(bundle)
4596
4543
  );
4597
4544
  const shouldMangle = manglingEnabled && Object.keys(state.mangleMap).length > 0;
4598
- emitAsset("csszyx-manifest.json", JSON.stringify(createBundleManifest(shouldMangle)));
4545
+ if (options.build?.emitManifest === true) {
4546
+ emitAsset("csszyx-manifest.json", JSON.stringify(createBundleManifest(shouldMangle)));
4547
+ }
4599
4548
  if (shouldEmitGlobalVarMapAsset(globalVarMangleConfig)) {
4600
4549
  const globalVarMap = createGlobalVarMapAssetSource(
4601
4550
  state.varMangleMap,
@@ -4696,4 +4645,4 @@ const esbuildPlugin = (options = {}) => {
4696
4645
  };
4697
4646
  };
4698
4647
 
4699
- export { validateGlobalVarAliasInputs as $, isMonorepoPackage as A, isPackagesSkippedSource as B, isRSCServerModule as C, isTailwindReservedGlobalVar as D, mangleCodeClassesSync as E, mangleEligibleClasses as F, mangleHybridHazardMessage as G, mergeThemes as H, missingTailwindEntryMessage as I, normalizeGlobalVarAliasesForCache as J, parseThemeBlocks as K, planGlobalVarAliases as L, readGlobalVarScanCache as M, recordGlobalVarSourceFile as N, resolveCompileSourceDirs as O, resolveGlobalVarScanCacheDir as P, resolveNativeCacheIdentity as Q, rewriteGlobalVarCssAliases as R, rollupPlugin as S, scanCustomPropertyNames as T, scanGlobalVarCss as U, shouldEmitWarning as V, shouldTrackGlobalVarSources as W, shouldWarnMissingTailwindEntry as X, shouldWarnUnscopedMonorepo as Y, skippedSzFilesMessage as Z, unscopedMonorepoMessage as _, allocateMangleTokens as a, vitePlugin as a0, webpackPlugin as a1, writeGlobalVarScanCache as a2, appendTailwindSourceDirective as b, assertNoRSCBoundaryViolation as c, assertNoRSCGraphViolation as d, collectMangleHybridHazards as e, computeSafelistRelPath as f, createGlobalVarAliasValidationOptions as g, createGlobalVarMapAssetSource as h, createGlobalVarScanCacheKey as i, createRSCModuleRecord as j, cssHasContentScope as k, cssImportsTailwind as l, deleteRSCModuleRecord as m, esbuildPlugin as n, extractGlobalVarAliasesForManifest as o, fileMayContainSafelistableSz as p, findLocalImportSources as q, findRSCBoundaryViolation as r, findRSCGraphViolation as s, hasInjectableTailwindCandidate as t, unplugin as u, hasTokens as v, hasUseClientDirective as w, hasUseServerDirective as x, isCompileSourceOptedIn as y, isHardIgnoredPath as z };
4648
+ export { vitePlugin as $, isMonorepoPackage as A, isPackagesSkippedSource as B, isRSCServerModule as C, isTailwindReservedGlobalVar as D, mangleCodeClassesSync as E, mangleEligibleClasses as F, mangleHybridHazardMessage as G, missingTailwindEntryMessage as H, normalizeGlobalVarAliasesForCache as I, planGlobalVarAliases as J, readGlobalVarScanCache as K, recordGlobalVarSourceFile as L, resolveCompileSourceDirs as M, resolveGlobalVarScanCacheDir as N, resolveNativeCacheIdentity as O, resolveQuietMode as P, rewriteGlobalVarCssAliases as Q, rollupPlugin as R, scanGlobalVarCss as S, shouldEmitMissingCssFallback as T, shouldEmitWarning as U, shouldTrackGlobalVarSources as V, shouldWarnMissingTailwindEntry as W, shouldWarnUnscopedMonorepo as X, skippedSzFilesMessage as Y, unscopedMonorepoMessage as Z, validateGlobalVarAliasInputs as _, allocateMangleTokens as a, webpackPlugin as a0, writeGlobalVarScanCache as a1, appendTailwindSourceDirective as b, assertNoRSCBoundaryViolation as c, assertNoRSCGraphViolation as d, collectMangleHybridHazards as e, computeSafelistRelPath as f, createGlobalVarAliasValidationOptions as g, createGlobalVarMapAssetSource as h, createGlobalVarScanCacheKey as i, createRSCModuleRecord as j, cssHasContentScope as k, cssImportsTailwind as l, deleteRSCModuleRecord as m, emitMissingCssFallback as n, esbuildPlugin as o, extractGlobalVarAliasesForManifest as p, fileMayContainSafelistableSz as q, findLocalImportSources as r, findRSCBoundaryViolation as s, findRSCGraphViolation as t, unplugin as u, hasInjectableTailwindCandidate as v, hasUseClientDirective as w, hasUseServerDirective as x, isCompileSourceOptedIn as y, isHardIgnoredPath as z };