@csszyx/unplugin 0.12.0 → 0.14.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 (46) hide show
  1. package/README.md +8 -10
  2. package/dist/index.cjs +14 -7
  3. package/dist/index.d.cts +4 -4
  4. package/dist/index.d.mts +4 -4
  5. package/dist/index.mjs +3 -3
  6. package/dist/next-config.cjs +3 -0
  7. package/dist/next-config.d.cts +13 -2
  8. package/dist/next-config.d.mts +13 -2
  9. package/dist/next-config.mjs +3 -0
  10. package/dist/next-prebuild.cjs +13 -7
  11. package/dist/next-prebuild.d.cts +8 -2
  12. package/dist/next-prebuild.d.mts +8 -2
  13. package/dist/next-prebuild.mjs +13 -7
  14. package/dist/next-turbo-loader.cjs +31 -15
  15. package/dist/next-turbo-loader.d.cts +11 -2
  16. package/dist/next-turbo-loader.d.mts +11 -2
  17. package/dist/next-turbo-loader.mjs +30 -14
  18. package/dist/next-watcher.cjs +1 -1
  19. package/dist/next-watcher.mjs +1 -1
  20. package/dist/shared/{unplugin.CXV7fOa2.d.cts → unplugin.B32Exn-K.d.cts} +2 -2
  21. package/dist/shared/{unplugin.CXV7fOa2.d.mts → unplugin.B32Exn-K.d.mts} +2 -2
  22. package/dist/shared/{unplugin.Bb5TeU9B.cjs → unplugin.BJiWWF6w.cjs} +93 -23
  23. package/dist/shared/unplugin.BKGCkMgM.cjs +523 -0
  24. package/dist/shared/{unplugin.DMcbmP01.mjs → unplugin.BU0O4IkX.mjs} +4 -1
  25. package/dist/shared/unplugin.BcsvXjIV.mjs +579 -0
  26. package/dist/shared/{unplugin.CtnKJhAi.d.cts → unplugin.BsjD3mtb.d.cts} +165 -33
  27. package/dist/shared/{unplugin.CtnKJhAi.d.mts → unplugin.BsjD3mtb.d.mts} +165 -33
  28. package/dist/shared/{unplugin.DblMogcN.cjs → unplugin.Cji6O5jv.cjs} +4 -1
  29. package/dist/shared/unplugin.CkNQjA4G.cjs +613 -0
  30. package/dist/shared/unplugin.DKcwO8O4.mjs +490 -0
  31. package/dist/shared/{unplugin.DXgxFHzO.mjs → unplugin.DjRylBC_.mjs} +77 -25
  32. package/dist/shared/{unplugin.BK3XVHe8.cjs → unplugin.ZMa9YE1H.cjs} +621 -615
  33. package/dist/shared/{unplugin.B9vpjOhD.mjs → unplugin.gR_h2DVG.mjs} +585 -582
  34. package/dist/vite.cjs +3 -3
  35. package/dist/vite.d.cts +2 -2
  36. package/dist/vite.d.mts +1 -1
  37. package/dist/vite.mjs +3 -3
  38. package/dist/webpack.cjs +3 -3
  39. package/dist/webpack.d.cts +2 -2
  40. package/dist/webpack.d.mts +1 -1
  41. package/dist/webpack.mjs +3 -3
  42. package/package.json +9 -9
  43. package/dist/shared/unplugin.C2lHQFii.cjs +0 -114
  44. package/dist/shared/unplugin.CBMJufQ8.mjs +0 -108
  45. package/dist/shared/unplugin.CDqY7kmk.mjs +0 -224
  46. package/dist/shared/unplugin.DbZ7tCfN.cjs +0 -248
@@ -0,0 +1,523 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path');
4
+ const compiler = require('@csszyx/compiler');
5
+ const fs = require('node:fs');
6
+ const node_crypto = require('node:crypto');
7
+
8
+ function _interopNamespaceCompat(e) {
9
+ if (e && typeof e === 'object' && 'default' in e) return e;
10
+ const n = Object.create(null);
11
+ if (e) {
12
+ for (const k in e) {
13
+ n[k] = e[k];
14
+ }
15
+ }
16
+ n.default = e;
17
+ return n;
18
+ }
19
+
20
+ const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
21
+ const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs);
22
+
23
+ const WINDOWS_PATH_SEPARATOR = String.fromCodePoint(92);
24
+ function normalizePathSeparators(value) {
25
+ return value.split(WINDOWS_PATH_SEPARATOR).join("/");
26
+ }
27
+
28
+ const TSCONFIG_CANDIDATES = ["tsconfig.json", "jsconfig.json", "tsconfig.app.json"];
29
+ const MAX_EXTENDS_DEPTH = 8;
30
+ function collectSpecifierAliases(rootDir, resolveAlias) {
31
+ return [...aliasesFromResolveConfig(rootDir, resolveAlias), ...aliasesFromTsconfig(rootDir)];
32
+ }
33
+ function aliasesFromResolveConfig(rootDir, raw) {
34
+ const aliases = [];
35
+ if (Array.isArray(raw)) {
36
+ for (const entry of raw) {
37
+ const find = entry.find;
38
+ const replacement = entry.replacement;
39
+ if (typeof find !== "string" || typeof replacement !== "string") continue;
40
+ aliases.push(makeAlias(rootDir, find, replacement));
41
+ }
42
+ return aliases;
43
+ }
44
+ if (raw === null || typeof raw !== "object") return aliases;
45
+ for (const [find, target] of Object.entries(raw)) {
46
+ for (const value of Array.isArray(target) ? target : [target]) {
47
+ if (typeof value !== "string") continue;
48
+ aliases.push(makeAlias(rootDir, find, value));
49
+ }
50
+ }
51
+ return aliases;
52
+ }
53
+ function makeAlias(rootDir, find, replacement) {
54
+ const exact = find.endsWith("$");
55
+ return {
56
+ find: exact ? find.slice(0, -1) : find,
57
+ replacement: absolute(rootDir, replacement),
58
+ exact
59
+ };
60
+ }
61
+ function aliasesFromTsconfig(rootDir) {
62
+ for (const candidate of TSCONFIG_CANDIDATES) {
63
+ const loaded = loadPathsConfig(path__namespace.join(rootDir, candidate), 0);
64
+ if (loaded === void 0) continue;
65
+ const aliases = pathsToAliases(loaded.base, loaded.paths);
66
+ if (aliases.length > 0) return aliases;
67
+ }
68
+ return [];
69
+ }
70
+ function loadPathsConfig(configPath, depth) {
71
+ if (depth > MAX_EXTENDS_DEPTH) return void 0;
72
+ let parsed;
73
+ try {
74
+ parsed = parseJsonc(fs__namespace.readFileSync(configPath, "utf-8"));
75
+ } catch {
76
+ return void 0;
77
+ }
78
+ const directory = path__namespace.dirname(configPath);
79
+ const compilerOptions = asRecord(parsed.compilerOptions);
80
+ const paths = asRecord(compilerOptions?.paths);
81
+ if (paths !== void 0) {
82
+ const baseUrl = compilerOptions?.baseUrl;
83
+ return {
84
+ base: typeof baseUrl === "string" ? absolute(directory, baseUrl) : absolute(directory, "."),
85
+ paths
86
+ };
87
+ }
88
+ const extended = parsed.extends;
89
+ if (typeof extended !== "string" || !extended.startsWith(".")) return void 0;
90
+ const resolved = path__namespace.resolve(directory, extended);
91
+ return loadPathsConfig(resolved, depth + 1) ?? loadPathsConfig(`${resolved}.json`, depth + 1);
92
+ }
93
+ function pathsToAliases(base, paths) {
94
+ return Object.entries(paths).flatMap(
95
+ ([pattern, targets]) => patternToAliases(base, pattern, targets)
96
+ );
97
+ }
98
+ function patternToAliases(base, pattern, targets) {
99
+ const wildcard = pattern.indexOf("*");
100
+ if (wildcard !== -1 && wildcard !== pattern.length - 1) return [];
101
+ const exact = wildcard === -1;
102
+ const find = exact ? pattern : pattern.slice(0, -1);
103
+ const declared = Array.isArray(targets) ? targets : [targets];
104
+ return declared.filter((target) => typeof target === "string").map((target) => ({
105
+ find,
106
+ replacement: absolute(base, target.endsWith("*") ? target.slice(0, -1) : target),
107
+ exact
108
+ }));
109
+ }
110
+ function aliasedSpecifierBases(specifier, aliases) {
111
+ const bases = [];
112
+ for (const alias of aliases) {
113
+ if (alias.exact) {
114
+ if (specifier === alias.find) bases.push(alias.replacement);
115
+ continue;
116
+ }
117
+ if (!specifier.startsWith(alias.find)) continue;
118
+ bases.push(normalizePathSeparators(alias.replacement + specifier.slice(alias.find.length)));
119
+ }
120
+ return bases;
121
+ }
122
+ function absolute(directory, target) {
123
+ const resolved = normalizePathSeparators(path__namespace.resolve(directory, target));
124
+ const declaredTrailingSlash = target.endsWith("/") || target.endsWith("\\");
125
+ return declaredTrailingSlash && !resolved.endsWith("/") ? `${resolved}/` : resolved;
126
+ }
127
+ function asRecord(value) {
128
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
129
+ }
130
+ function parseJsonc(text) {
131
+ const parsed = JSON.parse(stripComments(text).replace(/,(\s*[}\]])/g, "$1"));
132
+ return asRecord(parsed) ?? {};
133
+ }
134
+ function stripComments(text) {
135
+ const out = [];
136
+ let index = 0;
137
+ while (index < text.length) {
138
+ const run = consumeString(text, index) ?? consumeComment(text, index);
139
+ if (run === void 0) {
140
+ out.push(text[index]);
141
+ index += 1;
142
+ continue;
143
+ }
144
+ out.push(run.keep);
145
+ index = run.next;
146
+ }
147
+ return out.join("");
148
+ }
149
+ function consumeString(text, start) {
150
+ if (text[start] !== '"') return void 0;
151
+ let index = start + 1;
152
+ while (index < text.length) {
153
+ const char = text[index];
154
+ if (char === "\\") {
155
+ index += 2;
156
+ continue;
157
+ }
158
+ index += 1;
159
+ if (char === '"') break;
160
+ }
161
+ return { keep: text.slice(start, index), next: index };
162
+ }
163
+ function consumeComment(text, start) {
164
+ if (text[start] !== "/") return void 0;
165
+ if (text[start + 1] === "/") {
166
+ const end = text.indexOf("\n", start);
167
+ return { keep: "", next: end === -1 ? text.length : end };
168
+ }
169
+ if (text[start + 1] === "*") {
170
+ const end = text.indexOf("*/", start + 2);
171
+ return { keep: "", next: end === -1 ? text.length : end + 2 };
172
+ }
173
+ return void 0;
174
+ }
175
+
176
+ function mayExportSzvFactories(content) {
177
+ return content.includes("szv(") && content.includes("export");
178
+ }
179
+ function recordSzvRegistryFile(registry, filePath, content) {
180
+ const entries = mayExportSzvFactories(content) ? compiler.extractCrossModuleRegistryEntries(content, filePath) : [];
181
+ replaceEntriesOfKind(registry, filePath, "szv-config", entries);
182
+ }
183
+ function recordSzObjectRegistryFile(registry, filePath, content) {
184
+ replaceEntriesOfKind(
185
+ registry,
186
+ filePath,
187
+ "sz-object",
188
+ compiler.extractCrossModuleRegistryEntries(content, filePath)
189
+ );
190
+ }
191
+ function replaceEntriesOfKind(registry, filePath, kind, entries) {
192
+ const key = normalizePathSeparators(filePath);
193
+ const byName = emptyNameIndex();
194
+ for (const [name, recorded] of Object.entries(registry.get(key) ?? {})) {
195
+ if (recorded.kind !== kind) byName[name] = recorded;
196
+ }
197
+ for (const entry of entries) {
198
+ if (entry.kind === kind) byName[entry.exportName] = { kind, value: entry.value };
199
+ }
200
+ if (Object.keys(byName).length === 0) registry.delete(key);
201
+ else registry.set(key, byName);
202
+ }
203
+ function emptyNameIndex() {
204
+ return /* @__PURE__ */ Object.create(null);
205
+ }
206
+ const SPECIFIER_PROBES = ["", ".ts", ".tsx", ".js", ".jsx", "/index.ts", "/index.tsx"];
207
+ const EMITTED_EXTENSION_SOURCES = [
208
+ [".js", [".ts", ".tsx"]],
209
+ [".jsx", [".tsx"]],
210
+ [".mjs", [".mts"]],
211
+ [".cjs", [".cts"]]
212
+ ];
213
+ function resolveCrossModuleStaticsFor(registry, filename, source, aliases = []) {
214
+ if (registry.size === 0 || !source.includes("from")) return {};
215
+ const directory = path__namespace.dirname(filename);
216
+ const resolved = {};
217
+ const seen = /* @__PURE__ */ new Set();
218
+ for (const specifier of importedSpecifiersIn(source)) {
219
+ if (seen.has(specifier)) continue;
220
+ seen.add(specifier);
221
+ const entries = firstRegistryHit(registry, specifier, directory, aliases);
222
+ if (entries !== void 0) fileUnderSpecifier(resolved, specifier, entries);
223
+ }
224
+ return resolved;
225
+ }
226
+ function firstRegistryHit(registry, specifier, directory, aliases) {
227
+ for (const base of specifierBases(specifier, directory, aliases)) {
228
+ const entries = lookupRegistryKey(registry, base);
229
+ if (entries !== void 0) return entries;
230
+ }
231
+ return void 0;
232
+ }
233
+ function recordResolvedEntry(resolved, kind, specifier, name, value) {
234
+ if (specifier === "__proto__" || name === "__proto__") return;
235
+ const channel = kind === "szv-config" ? "szvConfigs" : "szObjects";
236
+ let bySpecifier = resolved[channel];
237
+ if (bySpecifier === void 0) {
238
+ bySpecifier = emptyNameIndex();
239
+ resolved[channel] = bySpecifier;
240
+ }
241
+ let byName = bySpecifier[specifier];
242
+ if (byName === void 0) {
243
+ byName = emptyNameIndex();
244
+ bySpecifier[specifier] = byName;
245
+ }
246
+ byName[name] = value;
247
+ }
248
+ function fileUnderSpecifier(resolved, specifier, entries) {
249
+ for (const [name, recorded] of Object.entries(entries)) {
250
+ recordResolvedEntry(resolved, recorded.kind, specifier, name, recorded.value);
251
+ }
252
+ }
253
+ function importedSpecifiersIn(source) {
254
+ if (!source.includes("from")) return [];
255
+ return [...source.matchAll(/from\s*['"]([^'"]*)['"]/g)].map((match) => match[1]);
256
+ }
257
+ function specifierBases(specifier, directory, aliases) {
258
+ if (specifier.startsWith(".")) {
259
+ return [normalizePathSeparators(path__namespace.resolve(directory, specifier))];
260
+ }
261
+ return aliasedSpecifierBases(specifier, aliases);
262
+ }
263
+ function resolveProviderPath(seenPaths, base) {
264
+ return resolveProviderPathWith(base, (candidate) => seenPaths.has(candidate));
265
+ }
266
+ function resolveProviderPathWith(base, exists) {
267
+ return probeSpecifier(base, (candidate) => exists(candidate) ? candidate : void 0);
268
+ }
269
+ function probeSpecifier(base, lookup) {
270
+ for (const probe of SPECIFIER_PROBES) {
271
+ const found = lookup(`${base}${probe}`);
272
+ if (found !== void 0) return found;
273
+ }
274
+ for (const [emitted, sources] of EMITTED_EXTENSION_SOURCES) {
275
+ if (!base.endsWith(emitted)) continue;
276
+ const stem = base.slice(0, -emitted.length);
277
+ for (const extension of sources) {
278
+ const found = lookup(`${stem}${extension}`);
279
+ if (found !== void 0) return found;
280
+ }
281
+ break;
282
+ }
283
+ return void 0;
284
+ }
285
+ function lookupRegistryKey(registry, base) {
286
+ return probeSpecifier(base, (candidate) => registry.get(candidate));
287
+ }
288
+
289
+ function isReadableProviderFile(candidate) {
290
+ try {
291
+ return fs.existsSync(candidate) && fs.statSync(candidate).isFile();
292
+ } catch {
293
+ return false;
294
+ }
295
+ }
296
+
297
+ const CACHE_SCHEMA_VERSION = 17;
298
+ function resolveTransformCacheDir(rootDir, cacheDir) {
299
+ return path__namespace.resolve(rootDir, cacheDir ?? ".csszyx/cache", "transform");
300
+ }
301
+ function createTransformCacheKey(input) {
302
+ const inputSha256 = node_crypto.createHash("sha256").update(input.source).digest("hex");
303
+ const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
304
+ const keyMaterial = [
305
+ `schema=${CACHE_SCHEMA_VERSION}`,
306
+ `plugin=${input.pluginVersion}`,
307
+ `compiler=${input.compilerVersion}`,
308
+ `native=${input.nativeIdentity ?? "none"}`,
309
+ `parser=${input.parserMode}`,
310
+ `producer=${input.producer}`,
311
+ `astBudget=${input.astBudget ?? "default"}`,
312
+ `mangleVars=${input.mangleVars === true}`,
313
+ `mangleVarHoistMaxDepth=${input.mangleVarHoistMaxDepth ?? "default"}`,
314
+ `globalVarAliases=${JSON.stringify(globalVarAliases)}`,
315
+ `crossModuleStatics=${input.crossModuleStatics ?? "none"}`,
316
+ `crossModuleSzObjects=${input.crossModuleSzObjects ?? "none"}`,
317
+ `filename=${input.filename}`,
318
+ `source=${inputSha256}`
319
+ ].join("\n");
320
+ return {
321
+ key: node_crypto.createHash("sha256").update(keyMaterial).digest("hex").slice(0, 16),
322
+ inputSha256
323
+ };
324
+ }
325
+ function readTransformCache(cacheRoot, input, precomputedKey) {
326
+ const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
327
+ const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
328
+ const file = cacheEntryPath(cacheRoot, key);
329
+ let entry;
330
+ try {
331
+ entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
332
+ } catch {
333
+ return null;
334
+ }
335
+ if (entry.version !== CACHE_SCHEMA_VERSION || entry.pluginVersion !== input.pluginVersion || entry.compilerVersion !== input.compilerVersion || entry.nativeIdentity !== (input.nativeIdentity ?? null) || entry.parserMode !== input.parserMode || entry.producer !== input.producer || entry.astBudget !== (input.astBudget ?? null) || entry.mangleVars !== (input.mangleVars === true) || entry.mangleVarHoistMaxDepth !== (input.mangleVarHoistMaxDepth ?? null) || !sameGlobalVarAliases(entry.globalVarAliases, globalVarAliases) || entry.filename !== input.filename || entry.inputSha256 !== inputSha256) {
336
+ return null;
337
+ }
338
+ return deserializeResult(entry.result);
339
+ }
340
+ function writeTransformCache(cacheRoot, input, result, precomputedKey) {
341
+ const { key, inputSha256 } = precomputedKey ?? createTransformCacheKey(input);
342
+ const globalVarAliases = normalizeGlobalVarAliasEntries(input.globalVarAliases);
343
+ const file = cacheEntryPath(cacheRoot, key);
344
+ const dir = path__namespace.dirname(file);
345
+ const tmp = path__namespace.join(dir, `.tmp-${process.pid}-${Date.now()}-${node_crypto.randomUUID()}.json`);
346
+ const entry = {
347
+ version: CACHE_SCHEMA_VERSION,
348
+ pluginVersion: input.pluginVersion,
349
+ compilerVersion: input.compilerVersion,
350
+ nativeIdentity: input.nativeIdentity ?? null,
351
+ parserMode: input.parserMode,
352
+ producer: input.producer,
353
+ astBudget: input.astBudget ?? null,
354
+ mangleVars: input.mangleVars === true,
355
+ mangleVarHoistMaxDepth: input.mangleVarHoistMaxDepth ?? null,
356
+ globalVarAliases,
357
+ filename: input.filename,
358
+ inputSha256,
359
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
360
+ result: serializeResult(result)
361
+ };
362
+ try {
363
+ fs__namespace.mkdirSync(dir, { recursive: true });
364
+ fs__namespace.writeFileSync(tmp, JSON.stringify(entry), "utf8");
365
+ fs__namespace.renameSync(tmp, file);
366
+ } catch {
367
+ try {
368
+ fs__namespace.rmSync(tmp, { force: true });
369
+ } catch {
370
+ }
371
+ }
372
+ }
373
+ function evictOldTransformCacheEntries(cacheRoot, options) {
374
+ let deleted = 0;
375
+ const now = options.now ?? Date.now();
376
+ const survivors = [];
377
+ for (const file of listJsonFiles(cacheRoot)) {
378
+ try {
379
+ const entry = JSON.parse(fs__namespace.readFileSync(file, "utf8"));
380
+ const timestamp = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : 0;
381
+ if (!Number.isFinite(timestamp) || now - timestamp > options.maxAgeMs) {
382
+ fs__namespace.rmSync(file, { force: true });
383
+ deleted++;
384
+ } else {
385
+ survivors.push({ file, timestamp });
386
+ }
387
+ } catch {
388
+ fs__namespace.rmSync(file, { force: true });
389
+ deleted++;
390
+ }
391
+ }
392
+ const overflow = survivors.length - options.maxEntries ;
393
+ if (overflow > 0) {
394
+ survivors.sort((a, b) => a.timestamp - b.timestamp);
395
+ for (const survivor of survivors.slice(0, overflow)) {
396
+ fs__namespace.rmSync(survivor.file, { force: true });
397
+ deleted++;
398
+ }
399
+ }
400
+ return deleted;
401
+ }
402
+ function cacheEntryPath(cacheRoot, key) {
403
+ return path__namespace.join(cacheRoot, key.slice(0, 2), `${key.slice(2)}.json`);
404
+ }
405
+ function serializeResult(result) {
406
+ return {
407
+ code: result.code,
408
+ transformed: result.transformed,
409
+ usesRuntime: result.usesRuntime,
410
+ usesMerge: result.usesMerge,
411
+ usesSzcn: result.usesSzcn,
412
+ usesSzPart: result.usesSzPart,
413
+ usesSzvPick: result.usesSzvPick,
414
+ usesSzvPick1: result.usesSzvPick1,
415
+ szPartArgsProvable: result.szPartArgsProvable,
416
+ usesColorVar: result.usesColorVar,
417
+ usesSpacingVar: result.usesSpacingVar,
418
+ usesUnitVar: result.usesUnitVar,
419
+ usesBoolClass: result.usesBoolClass,
420
+ classes: [...result.classes],
421
+ rawClassNames: [...result.rawClassNames],
422
+ diagnostics: [...result.diagnostics],
423
+ recoveryTokens: [...result.recoveryTokens],
424
+ cssVariableMap: [...result.cssVariableMap ?? /* @__PURE__ */ new Map()]
425
+ };
426
+ }
427
+ function deserializeResult(result) {
428
+ return {
429
+ code: result.code,
430
+ transformed: result.transformed,
431
+ usesRuntime: result.usesRuntime,
432
+ usesMerge: result.usesMerge,
433
+ usesSzcn: result.usesSzcn,
434
+ usesSzPart: result.usesSzPart,
435
+ usesSzvPick: result.usesSzvPick,
436
+ usesSzvPick1: result.usesSzvPick1,
437
+ szPartArgsProvable: result.szPartArgsProvable,
438
+ usesColorVar: result.usesColorVar,
439
+ usesSpacingVar: result.usesSpacingVar,
440
+ usesUnitVar: result.usesUnitVar,
441
+ usesBoolClass: result.usesBoolClass,
442
+ classes: new Set(result.classes),
443
+ rawClassNames: new Set(result.rawClassNames),
444
+ diagnostics: [...result.diagnostics],
445
+ recoveryTokens: new Map(result.recoveryTokens),
446
+ cssVariableMap: new Map(result.cssVariableMap ?? [])
447
+ };
448
+ }
449
+ function normalizeGlobalVarAliasEntries(aliases) {
450
+ if (!aliases || aliases.length === 0) {
451
+ return [];
452
+ }
453
+ const normalized = /* @__PURE__ */ new Map();
454
+ for (const [original, alias] of aliases) {
455
+ if (typeof original === "string" && typeof alias === "string") {
456
+ normalized.set(original, alias);
457
+ }
458
+ }
459
+ return [...normalized].sort(([left], [right]) => left.localeCompare(right));
460
+ }
461
+ function sameGlobalVarAliases(left, right) {
462
+ if (!Array.isArray(left) || left.length !== right.length) {
463
+ return false;
464
+ }
465
+ for (let index = 0; index < left.length; index++) {
466
+ const leftEntry = left[index];
467
+ const rightEntry = right[index];
468
+ if (leftEntry?.[0] !== rightEntry?.[0] || leftEntry?.[1] !== rightEntry?.[1]) {
469
+ return false;
470
+ }
471
+ }
472
+ return true;
473
+ }
474
+ function listJsonFiles(dir) {
475
+ let entries;
476
+ try {
477
+ entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
478
+ } catch {
479
+ return [];
480
+ }
481
+ const files = [];
482
+ for (const entry of entries) {
483
+ const fullPath = path__namespace.join(dir, entry.name);
484
+ if (entry.isDirectory()) {
485
+ files.push(...listJsonFiles(fullPath));
486
+ } else if (entry.isFile() && entry.name.endsWith(".json")) {
487
+ files.push(fullPath);
488
+ }
489
+ }
490
+ return files;
491
+ }
492
+ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChars) {
493
+ let total = totalCodeChars;
494
+ while (cache.size > maxEntries || total > maxCodeChars && cache.size > 1) {
495
+ const oldest = cache.keys().next().value;
496
+ if (oldest === void 0) {
497
+ break;
498
+ }
499
+ const evicted = cache.get(oldest);
500
+ cache.delete(oldest);
501
+ total -= evicted?.code.length ?? 0;
502
+ }
503
+ return total;
504
+ }
505
+
506
+ exports.collectSpecifierAliases = collectSpecifierAliases;
507
+ exports.createTransformCacheKey = createTransformCacheKey;
508
+ exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
509
+ exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
510
+ exports.importedSpecifiersIn = importedSpecifiersIn;
511
+ exports.isReadableProviderFile = isReadableProviderFile;
512
+ exports.mayExportSzvFactories = mayExportSzvFactories;
513
+ exports.normalizePathSeparators = normalizePathSeparators;
514
+ exports.readTransformCache = readTransformCache;
515
+ exports.recordResolvedEntry = recordResolvedEntry;
516
+ exports.recordSzObjectRegistryFile = recordSzObjectRegistryFile;
517
+ exports.recordSzvRegistryFile = recordSzvRegistryFile;
518
+ exports.resolveCrossModuleStaticsFor = resolveCrossModuleStaticsFor;
519
+ exports.resolveProviderPath = resolveProviderPath;
520
+ exports.resolveProviderPathWith = resolveProviderPathWith;
521
+ exports.resolveTransformCacheDir = resolveTransformCacheDir;
522
+ exports.specifierBases = specifierBases;
523
+ exports.writeTransformCache = writeTransformCache;
@@ -165,11 +165,14 @@ function atomicRenameWithRetry(from, to, options = {}) {
165
165
  function isExistingShardEquivalent(filePath, shard) {
166
166
  try {
167
167
  const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
168
- return parsed.version === 1 && parsed.sourcePath === shard.sourcePath && parsed.sourceHash === shard.sourceHash;
168
+ return parsed.version === 1 && parsed.sourcePath === shard.sourcePath && parsed.sourceHash === shard.sourceHash && sameClasses(parsed.classes, shard.classes);
169
169
  } catch {
170
170
  return false;
171
171
  }
172
172
  }
173
+ function sameClasses(left, right) {
174
+ return Array.isArray(left) && left.length === right.length && left.every((value, index) => value === right[index]);
175
+ }
173
176
  function normalizeShardInput(input) {
174
177
  const sourcePath = path.resolve(input.sourcePath);
175
178
  const classes = sortStrings(