@csszyx/unplugin 0.13.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.
- package/README.md +8 -10
- package/dist/index.cjs +9 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/next-config.d.cts +3 -2
- package/dist/next-config.d.mts +3 -2
- package/dist/next-prebuild.cjs +3 -4
- package/dist/next-prebuild.d.cts +1 -2
- package/dist/next-prebuild.d.mts +1 -2
- package/dist/next-prebuild.mjs +3 -4
- package/dist/next-turbo-loader.cjs +5 -7
- package/dist/next-turbo-loader.d.cts +1 -2
- package/dist/next-turbo-loader.d.mts +1 -2
- package/dist/next-turbo-loader.mjs +5 -7
- package/dist/shared/{unplugin.CXV7fOa2.d.cts → unplugin.B32Exn-K.d.cts} +2 -2
- package/dist/shared/{unplugin.CXV7fOa2.d.mts → unplugin.B32Exn-K.d.mts} +2 -2
- package/dist/shared/{unplugin.CUTa6bY9.cjs → unplugin.BJiWWF6w.cjs} +5 -23
- package/dist/shared/{unplugin.4du3qMst.cjs → unplugin.BKGCkMgM.cjs} +4 -10
- package/dist/shared/{unplugin.5l4RHMQh.mjs → unplugin.BcsvXjIV.mjs} +1 -0
- package/dist/shared/{unplugin.DCT7DDG6.d.cts → unplugin.BsjD3mtb.d.cts} +91 -4
- package/dist/shared/{unplugin.DCT7DDG6.d.mts → unplugin.BsjD3mtb.d.mts} +91 -4
- package/dist/shared/{unplugin.X9a9SL_s.cjs → unplugin.CkNQjA4G.cjs} +1 -0
- package/dist/shared/{unplugin.BB0iWSds.mjs → unplugin.DKcwO8O4.mjs} +5 -10
- package/dist/shared/{unplugin.CogPHmDs.mjs → unplugin.DjRylBC_.mjs} +6 -24
- package/dist/shared/{unplugin.Bf4fNbp7.cjs → unplugin.ZMa9YE1H.cjs} +309 -89
- package/dist/shared/{unplugin.ymMe428s.mjs → unplugin.gR_h2DVG.mjs} +303 -89
- package/dist/vite.cjs +3 -3
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +3 -3
- package/dist/webpack.cjs +3 -3
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +3 -3
- package/package.json +9 -9
|
@@ -6,16 +6,16 @@ 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, szFallbackConsequenceOf,
|
|
9
|
+
import { scanGlobalVarUsages, sortStrings as sortStrings$1, szFallbackConsequenceOf, isWasmTransformAvailable, isRustTransformAvailable, ensureRustTransformAvailable, transformRust, transformWasm, ASTBudgetExceededError, transformRustBatch, transform } 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
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, c as collectSpecifierAliases,
|
|
16
|
+
import { n as normalizePathSeparators, c as collectSpecifierAliases, g as recordSzvRegistryFile, h as recordSzObjectRegistryFile, j as resolveCrossModuleStaticsFor, r as resolveTransformCacheDir, e as createTransformCacheKey, w as writeTransformCache, k as evictOldTransformCacheEntries, m as mayExportSzvFactories, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, f as readTransformCache, l as evictMemoryCacheToBudget, o as resolveProviderPath, d as isReadableProviderFile } from './unplugin.DKcwO8O4.mjs';
|
|
17
17
|
import { mangleCSSSync } from '../css-mangler.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.
|
|
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.BcsvXjIV.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
20
|
import { gzipSync } from 'node:zlib';
|
|
21
21
|
import postcss from 'postcss';
|
|
@@ -1823,11 +1823,13 @@ function escapeForDoubleQuotedString(value) {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
1825
|
function createMangleSizeAccount() {
|
|
1826
|
-
return { cssGzBefore: 0, cssGzAfter: 0, channels: /* @__PURE__ */ new Set() };
|
|
1826
|
+
return { cssGzBefore: 0, cssGzAfter: 0, codeGzBefore: 0, codeGzAfter: 0, channels: /* @__PURE__ */ new Set() };
|
|
1827
1827
|
}
|
|
1828
1828
|
function resetMangleSizeAccount(account) {
|
|
1829
1829
|
account.cssGzBefore = 0;
|
|
1830
1830
|
account.cssGzAfter = 0;
|
|
1831
|
+
account.codeGzBefore = 0;
|
|
1832
|
+
account.codeGzAfter = 0;
|
|
1831
1833
|
account.channels.clear();
|
|
1832
1834
|
}
|
|
1833
1835
|
function gzipBytes(text) {
|
|
@@ -1844,30 +1846,53 @@ function recordCssPair(account, before, after) {
|
|
|
1844
1846
|
account.cssGzBefore += gzipBytes(before);
|
|
1845
1847
|
account.cssGzAfter += gzipBytes(after);
|
|
1846
1848
|
}
|
|
1849
|
+
function recordCodePair(account, before, after) {
|
|
1850
|
+
if (before === after) {
|
|
1851
|
+
const bytes = gzipBytes(before);
|
|
1852
|
+
account.codeGzBefore += bytes;
|
|
1853
|
+
account.codeGzAfter += bytes;
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
account.codeGzBefore += gzipBytes(before);
|
|
1857
|
+
account.codeGzAfter += gzipBytes(after);
|
|
1858
|
+
}
|
|
1847
1859
|
function computeMangleSizeVerdict(account, mapPayload) {
|
|
1848
1860
|
const channels = sortStrings(account.channels);
|
|
1849
1861
|
const mapCost = gzipBytes(mapPayload) * channels.length;
|
|
1850
1862
|
const cssSaving = account.cssGzBefore - account.cssGzAfter;
|
|
1851
|
-
|
|
1863
|
+
const codeSaving = account.codeGzBefore - account.codeGzAfter;
|
|
1864
|
+
return { mapCost, cssSaving, codeSaving, net: mapCost - cssSaving - codeSaving, channels };
|
|
1852
1865
|
}
|
|
1853
1866
|
function mangleSizeMessage(verdict) {
|
|
1854
1867
|
if (verdict.channels.length === 0) return null;
|
|
1855
1868
|
if (verdict.net <= 0) return null;
|
|
1856
1869
|
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)`;
|
|
1870
|
+
const codePart = verdict.codeSaving >= 0 ? `the shortened classes in code save ${verdict.codeSaving} B` : `the shortened classes in code COST ${-verdict.codeSaving} B`;
|
|
1857
1871
|
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
|
|
1872
|
+
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} and ${codePart}. 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.`;
|
|
1859
1873
|
}
|
|
1860
1874
|
|
|
1861
1875
|
function isParserMode(value) {
|
|
1862
|
-
return value === "rust" || value === "
|
|
1876
|
+
return value === "rust" || value === "wasm";
|
|
1863
1877
|
}
|
|
1864
1878
|
function resolveParserMode(input) {
|
|
1865
1879
|
const { configParser, envParser, defaultParser, isRustAvailable } = input;
|
|
1866
1880
|
const envValid = isParserMode(envParser);
|
|
1867
|
-
const
|
|
1868
|
-
const
|
|
1881
|
+
const configValid = isParserMode(configParser);
|
|
1882
|
+
const explicit = envValid || configValid;
|
|
1883
|
+
let parser;
|
|
1884
|
+
if (envValid) {
|
|
1885
|
+
parser = envParser;
|
|
1886
|
+
} else if (configValid) {
|
|
1887
|
+
parser = configParser;
|
|
1888
|
+
} else {
|
|
1889
|
+
parser = defaultParser;
|
|
1890
|
+
}
|
|
1869
1891
|
if (parser === "rust" && !explicit && !isRustAvailable()) {
|
|
1870
|
-
|
|
1892
|
+
if (input.isWasmAvailable()) {
|
|
1893
|
+
return { parser: "wasm", degraded: true, explicit: false };
|
|
1894
|
+
}
|
|
1895
|
+
return { parser: "rust", degraded: false, explicit: false };
|
|
1871
1896
|
}
|
|
1872
1897
|
return { parser, degraded: false, explicit };
|
|
1873
1898
|
}
|
|
@@ -2014,7 +2039,6 @@ let _hasWarnedTsConfig = false;
|
|
|
2014
2039
|
let _hasWarnedTransformCacheVersion = false;
|
|
2015
2040
|
let _hasWarnedNativeFallback = false;
|
|
2016
2041
|
const _loggedActiveParsers = /* @__PURE__ */ new Set();
|
|
2017
|
-
const _babelFallbackFiles = /* @__PURE__ */ new Set();
|
|
2018
2042
|
const requireFromHere = createRequire(import.meta.url);
|
|
2019
2043
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
2020
2044
|
fileURLToPath(import.meta.url),
|
|
@@ -2131,9 +2155,20 @@ function mangleHybridHazardMessage(hazards) {
|
|
|
2131
2155
|
}
|
|
2132
2156
|
return parts.join("");
|
|
2133
2157
|
}
|
|
2158
|
+
const TAILWIND_IMPORT_SPECIFIER = /@import\s+["']tailwindcss(?:\/[^"']*)?["']/g;
|
|
2159
|
+
const SOURCE_MODIFIER = /\bsource\(/;
|
|
2160
|
+
function tailwindImportScopesContent(css) {
|
|
2161
|
+
for (const match of css.matchAll(TAILWIND_IMPORT_SPECIFIER)) {
|
|
2162
|
+
const modifiersStart = match.index + match[0].length;
|
|
2163
|
+
const terminator = css.indexOf(";", modifiersStart);
|
|
2164
|
+
const modifiers = terminator === -1 ? css.slice(modifiersStart) : css.slice(modifiersStart, terminator);
|
|
2165
|
+
if (SOURCE_MODIFIER.test(modifiers)) return true;
|
|
2166
|
+
}
|
|
2167
|
+
return false;
|
|
2168
|
+
}
|
|
2134
2169
|
function cssHasContentScope(code) {
|
|
2135
2170
|
const s = stripCssBlockComments(code);
|
|
2136
|
-
return
|
|
2171
|
+
return tailwindImportScopesContent(s) || /@source\s+not\b/.test(s);
|
|
2137
2172
|
}
|
|
2138
2173
|
function isMonorepoPackage(root) {
|
|
2139
2174
|
let dir = path.dirname(path.resolve(root));
|
|
@@ -2159,7 +2194,15 @@ function shouldWarnUnscopedMonorepo(sawTailwindEntry, tailwindEntryScoped, inMon
|
|
|
2159
2194
|
return sawTailwindEntry && !tailwindEntryScoped && inMonorepo;
|
|
2160
2195
|
}
|
|
2161
2196
|
function unscopedMonorepoMessage() {
|
|
2162
|
-
return '[csszyx] Tailwind content detection is UNSCOPED in a monorepo. Tailwind v4
|
|
2197
|
+
return '[csszyx] Tailwind content detection is UNSCOPED in a monorepo. Tailwind v4 scans every file under its detection base \u2014 .md/.mdx/.txt included \u2014 so a doc or fixture holding class-shaped strings becomes CSS, which can generate phantom or broken url() classes and fail the build. That base is as wide as the build makes it: a Vite build roots it at the Vite root, other setups at the workspace root. Scope it in your Tailwind CSS entry:\n @import "tailwindcss" source(none);\n @source ".";\nThat @source is your package, relative to the CSS file; csszyx auto-injects one for the classes it generates, 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 }).';
|
|
2198
|
+
}
|
|
2199
|
+
function isAdvisoryDiagnostic(message) {
|
|
2200
|
+
return !(message.includes("unresolvable sz spread") || message.includes("AST budget exceeded") || szFallbackConsequenceOf(message) === "missing-css");
|
|
2201
|
+
}
|
|
2202
|
+
function suppressedAdvisoryMessage(count) {
|
|
2203
|
+
if (count <= 0) return null;
|
|
2204
|
+
const held = count === 1 ? "1 advisory sz fallback" : `${count} advisory sz fallbacks`;
|
|
2205
|
+
return `[csszyx] ${held} not listed above. At an sz prop a fallback is advisory \u2014 the runtime path works and the classes are collected \u2014 so a production build keeps the list short. A development build prints each one with its file and position.`;
|
|
2163
2206
|
}
|
|
2164
2207
|
function resolveQuietMode(quiet) {
|
|
2165
2208
|
if (quiet === true || quiet === "all") return "all";
|
|
@@ -2295,6 +2338,22 @@ ${szvExportFiles.length} of them may export \`szv\` factories, so they stay out
|
|
|
2295
2338
|
${list}
|
|
2296
2339
|
Add the package directory to \`compileSources\` (or move the file out of packages/) \u2014 otherwise their classes never reach the safelist.` + registryClause;
|
|
2297
2340
|
}
|
|
2341
|
+
function lateMangleCensusMessage(lateOwned, lateAuthored) {
|
|
2342
|
+
const sections = [
|
|
2343
|
+
lateOwned.length > 0 ? `csszyx-owned classes: ${lateOwned.join(", ")}` : "",
|
|
2344
|
+
lateAuthored.length > 0 ? `author classes: ${lateAuthored.join(", ")}` : ""
|
|
2345
|
+
].filter(Boolean);
|
|
2346
|
+
const found = sections.length > 0 ? sections.join("\n") : "the class census changed";
|
|
2347
|
+
return `[csszyx] production.mangle: classes appeared after the mangle map was frozen, so the emitted CSS was hashed against a different map:
|
|
2348
|
+
${found}
|
|
2349
|
+
The prescan walks the project root and every \`compileSources\` directory. Move the file that owns these classes under one of them, or turn off \`production.mangle\` for this build.`;
|
|
2350
|
+
}
|
|
2351
|
+
function watchModeMangleMessage() {
|
|
2352
|
+
return "[csszyx] production.mangle is disabled for this watch build. Mangling needs the whole-project prescan that only runs once per process, and a watch rebuild cannot repeat it \u2014 the map would go stale against the files you edit. Run a one-shot build to get mangled output.";
|
|
2353
|
+
}
|
|
2354
|
+
function realContentHashDisabledMessage() {
|
|
2355
|
+
return "[csszyx] optimization.realContentHash is off while production.mangle is on. csszyx mangles assets after webpack computes their content hashes, and realContentHash is what recomputes those hashes from the final bytes. Without it, two builds that differ only by mangling emit the same filenames with different contents and caches keep serving the old file.";
|
|
2356
|
+
}
|
|
2298
2357
|
function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
|
|
2299
2358
|
const safelistPath = normalizePathSeparators(path.join(rootDir, safelistFilename));
|
|
2300
2359
|
const cssDir = normalizePathSeparators(path.dirname(cssId));
|
|
@@ -2370,6 +2429,20 @@ function collectConfiguredGlobalVarCssSources(rootDir, scanCss) {
|
|
|
2370
2429
|
}
|
|
2371
2430
|
});
|
|
2372
2431
|
}
|
|
2432
|
+
const MANGLEABLE_CSS_ID_RE = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
2433
|
+
const NON_STYLESHEET_CSS_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)(?:&|=|$)/;
|
|
2434
|
+
const COMMONJS_PROXY_RE = /\?commonjs-proxy/;
|
|
2435
|
+
function isMangleableCssId(id) {
|
|
2436
|
+
return MANGLEABLE_CSS_ID_RE.test(id) && !NON_STYLESHEET_CSS_QUERY_RE.test(id) && !COMMONJS_PROXY_RE.test(id);
|
|
2437
|
+
}
|
|
2438
|
+
function dedupeCssAssetsByName(assets) {
|
|
2439
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2440
|
+
return assets.filter((asset) => {
|
|
2441
|
+
if (seen.has(asset.fileName)) return false;
|
|
2442
|
+
seen.add(asset.fileName);
|
|
2443
|
+
return true;
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2373
2446
|
function collectWebpackGlobalVarCssAssets(assets) {
|
|
2374
2447
|
return Object.entries(assets).flatMap(([fileName, asset]) => {
|
|
2375
2448
|
if (!/\.css(?:$|\?)/.test(fileName)) {
|
|
@@ -2952,6 +3025,13 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2952
3025
|
const szObjectProvidersExamined = /* @__PURE__ */ new Set();
|
|
2953
3026
|
let specifierAliases = [];
|
|
2954
3027
|
const mangleReserved = new Set(options.production?.mangleExclude ?? []);
|
|
3028
|
+
let mangleMapFrozen = false;
|
|
3029
|
+
let frozenOwnedClasses = /* @__PURE__ */ new Set();
|
|
3030
|
+
let frozenAuthoredClasses = /* @__PURE__ */ new Set();
|
|
3031
|
+
let cssRewrittenInTransform = false;
|
|
3032
|
+
let projectCssFiles = [];
|
|
3033
|
+
const transformMangledSources = /* @__PURE__ */ new Set();
|
|
3034
|
+
const transformExternalClasses = /* @__PURE__ */ new Set();
|
|
2955
3035
|
const mangleMapDelivery = options.production?.mangleMapDelivery ?? "both";
|
|
2956
3036
|
if (!["both", "html", "bundle"].includes(mangleMapDelivery)) {
|
|
2957
3037
|
throw new Error(
|
|
@@ -2996,22 +3076,27 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2996
3076
|
configParser: options.build?.parser,
|
|
2997
3077
|
envParser: process.env.CSSZYX_PARSER,
|
|
2998
3078
|
defaultParser: DEFAULT_BUILD_CONFIG.parser ?? "rust",
|
|
2999
|
-
isRustAvailable: isRustTransformAvailable
|
|
3079
|
+
isRustAvailable: isRustTransformAvailable,
|
|
3080
|
+
isWasmAvailable: isWasmTransformAvailable
|
|
3000
3081
|
});
|
|
3001
3082
|
function announceActiveParser() {
|
|
3002
3083
|
if (parserDegraded && !_hasWarnedNativeFallback) {
|
|
3003
3084
|
_hasWarnedNativeFallback = true;
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3085
|
+
if (parserMode === "wasm") {
|
|
3086
|
+
console.warn(
|
|
3087
|
+
"[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to its wasm build. Same engine, same output; 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."
|
|
3088
|
+
);
|
|
3089
|
+
}
|
|
3007
3090
|
}
|
|
3008
3091
|
if (!_loggedActiveParsers.has(parserMode)) {
|
|
3009
3092
|
_loggedActiveParsers.add(parserMode);
|
|
3010
3093
|
let detail = parserMode;
|
|
3011
3094
|
if (parserDegraded) {
|
|
3012
|
-
detail = "
|
|
3095
|
+
detail = "wasm (degraded from default `rust`: same engine, wasm build)";
|
|
3013
3096
|
} else if (parserMode === "rust") {
|
|
3014
3097
|
detail = "rust (native engine)";
|
|
3098
|
+
} else if (parserMode === "wasm") {
|
|
3099
|
+
detail = "wasm (wasm build of the native engine)";
|
|
3015
3100
|
}
|
|
3016
3101
|
console.warn(`[csszyx] active parser: ${detail}`);
|
|
3017
3102
|
}
|
|
@@ -3031,6 +3116,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3031
3116
|
tailwindEntryScoped: false,
|
|
3032
3117
|
contentScopeWarningEmitted: false,
|
|
3033
3118
|
spreadWarnings: /* @__PURE__ */ new Set(),
|
|
3119
|
+
suppressedAdvisories: 0,
|
|
3034
3120
|
skippedSzFiles: /* @__PURE__ */ new Set(),
|
|
3035
3121
|
skippedSzvExportFiles: /* @__PURE__ */ new Set(),
|
|
3036
3122
|
skipWarningEmitted: false,
|
|
@@ -3092,7 +3178,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3092
3178
|
const result = validateGlobalVarAliasInputs(
|
|
3093
3179
|
createGlobalVarAliasValidationOptions({
|
|
3094
3180
|
rootDir: state.rootDir,
|
|
3095
|
-
cssAssets: [...configuredCssAssets, ...cssAssets],
|
|
3181
|
+
cssAssets: dedupeCssAssetsByName([...configuredCssAssets, ...cssAssets]),
|
|
3096
3182
|
sourceFiles: buildGlobalVarSourceFiles(state),
|
|
3097
3183
|
tokens: globalVarMangleConfig.tokens,
|
|
3098
3184
|
autoPrefix: globalVarMangleConfig.autoPrefix,
|
|
@@ -3105,6 +3191,25 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3105
3191
|
assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
|
|
3106
3192
|
return result;
|
|
3107
3193
|
}
|
|
3194
|
+
function revalidateFrozenGlobalVarPlan() {
|
|
3195
|
+
if (!cssRewrittenInTransform) return;
|
|
3196
|
+
validateGlobalVarBundleInputs(collectProjectGlobalVarCssSources());
|
|
3197
|
+
}
|
|
3198
|
+
function collectProjectGlobalVarCssSources() {
|
|
3199
|
+
const sources = [];
|
|
3200
|
+
for (const file of sortStrings$1(projectCssFiles)) {
|
|
3201
|
+
try {
|
|
3202
|
+
const snapshot = readStableTextFileSnapshotSync(file);
|
|
3203
|
+
sources.push({
|
|
3204
|
+
fileName: file,
|
|
3205
|
+
source: snapshot.source,
|
|
3206
|
+
mtimeMs: snapshot.mtimeMs
|
|
3207
|
+
});
|
|
3208
|
+
} catch {
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
return sources;
|
|
3212
|
+
}
|
|
3108
3213
|
function trackGlobalVarSourceFile(filename, code) {
|
|
3109
3214
|
if (!globalVarSourceTrackingEnabled) {
|
|
3110
3215
|
return;
|
|
@@ -3130,6 +3235,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3130
3235
|
refreshCompileSourceDirs();
|
|
3131
3236
|
const discovered = discoverProjectTheme(rootDir, [...compileSourceDirs]);
|
|
3132
3237
|
state.autoThemeCssFiles = discovered.files;
|
|
3238
|
+
projectCssFiles = discovered.scanned;
|
|
3133
3239
|
const sources = [state.scanCssTheme, discovered.theme].filter(
|
|
3134
3240
|
(theme) => theme !== null
|
|
3135
3241
|
);
|
|
@@ -3211,43 +3317,16 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3211
3317
|
return handoff.inputSha256 === cacheKey.inputSha256 ? handoff.result : null;
|
|
3212
3318
|
}
|
|
3213
3319
|
function runConfiguredParser(source, effectiveFilename, compilerOptions) {
|
|
3214
|
-
if (parserMode === "babel") {
|
|
3215
|
-
return {
|
|
3216
|
-
result: transformSourceCode(source, effectiveFilename, compilerOptions),
|
|
3217
|
-
cacheable: true
|
|
3218
|
-
};
|
|
3219
|
-
}
|
|
3220
3320
|
if (parserMode === "rust") {
|
|
3221
3321
|
return {
|
|
3222
3322
|
result: transformRust(source, effectiveFilename, compilerOptions),
|
|
3223
3323
|
cacheable: true
|
|
3224
3324
|
};
|
|
3225
3325
|
}
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
};
|
|
3231
|
-
} catch (error) {
|
|
3232
|
-
return {
|
|
3233
|
-
result: runBabelFallback(source, effectiveFilename, compilerOptions, error),
|
|
3234
|
-
cacheable: false
|
|
3235
|
-
};
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
function runBabelFallback(source, effectiveFilename, compilerOptions, error) {
|
|
3239
|
-
const result = transformSourceCode(source, effectiveFilename, compilerOptions);
|
|
3240
|
-
const reason = babelFallbackReason(error);
|
|
3241
|
-
result.diagnostics.push(
|
|
3242
|
-
`[csszyx] oxc parser fell back to Babel for ${effectiveFilename}: ${reason}`
|
|
3243
|
-
);
|
|
3244
|
-
if (!_babelFallbackFiles.has(effectiveFilename)) {
|
|
3245
|
-
_babelFallbackFiles.add(effectiveFilename);
|
|
3246
|
-
console.warn(
|
|
3247
|
-
`[csszyx] oxc parser fell back to Babel for ${effectiveFilename}: ${reason} (${_babelFallbackFiles.size} file(s) so far). Output is still correct; this usually means the file uses a syntax the oxc lane does not yet handle.`
|
|
3248
|
-
);
|
|
3249
|
-
}
|
|
3250
|
-
return result;
|
|
3326
|
+
return {
|
|
3327
|
+
result: transformWasm(source, effectiveFilename, compilerOptions),
|
|
3328
|
+
cacheable: true
|
|
3329
|
+
};
|
|
3251
3330
|
}
|
|
3252
3331
|
function createCompilerOptions(astBudget = astBudgetOverride) {
|
|
3253
3332
|
return {
|
|
@@ -3763,16 +3842,39 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3763
3842
|
state.authoredClasses.add(className);
|
|
3764
3843
|
}
|
|
3765
3844
|
}
|
|
3766
|
-
function
|
|
3845
|
+
function computeMangleMap() {
|
|
3767
3846
|
const forbiddenTokens = /* @__PURE__ */ new Set([
|
|
3768
3847
|
...mangleReserved,
|
|
3769
3848
|
...state.authoredClasses,
|
|
3770
3849
|
...state.ownedClasses
|
|
3771
3850
|
]);
|
|
3772
|
-
|
|
3851
|
+
return allocateMangleTokens(
|
|
3773
3852
|
mangleEligibleClasses(state.ownedClasses, state.authoredClasses),
|
|
3774
3853
|
forbiddenTokens
|
|
3775
3854
|
);
|
|
3855
|
+
}
|
|
3856
|
+
function freezeMangleMap() {
|
|
3857
|
+
state.mangleMap = computeMangleMap();
|
|
3858
|
+
frozenOwnedClasses = new Set(state.ownedClasses);
|
|
3859
|
+
frozenAuthoredClasses = new Set(state.authoredClasses);
|
|
3860
|
+
mangleMapFrozen = true;
|
|
3861
|
+
}
|
|
3862
|
+
function assertMangleCensusUnchanged() {
|
|
3863
|
+
if (!mangleMapFrozen) return;
|
|
3864
|
+
const current = computeMangleMap();
|
|
3865
|
+
if (JSON.stringify(current) === JSON.stringify(state.mangleMap)) return;
|
|
3866
|
+
const lateOwned = sortStrings$1(
|
|
3867
|
+
[...state.ownedClasses].filter((className) => !frozenOwnedClasses.has(className))
|
|
3868
|
+
);
|
|
3869
|
+
const lateAuthored = sortStrings$1(
|
|
3870
|
+
[...state.authoredClasses].filter((className) => !frozenAuthoredClasses.has(className))
|
|
3871
|
+
);
|
|
3872
|
+
throw new Error(lateMangleCensusMessage(lateOwned, lateAuthored));
|
|
3873
|
+
}
|
|
3874
|
+
function finalizeMangleMap() {
|
|
3875
|
+
if (!mangleMapFrozen) {
|
|
3876
|
+
state.mangleMap = computeMangleMap();
|
|
3877
|
+
}
|
|
3776
3878
|
assertVarMangleMapSize(state.varMangleMap, varMangleMapMaxBytes);
|
|
3777
3879
|
state.checksum = compute_mangle_checksum(
|
|
3778
3880
|
createHydrationMangleMap(state.mangleMap, state.varMangleMap)
|
|
@@ -3831,7 +3933,8 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3831
3933
|
szPartArgsProvable: true,
|
|
3832
3934
|
usesColorVar: false,
|
|
3833
3935
|
usesSpacingVar: false,
|
|
3834
|
-
usesUnitVar: false
|
|
3936
|
+
usesUnitVar: false,
|
|
3937
|
+
usesBoolClass: false
|
|
3835
3938
|
};
|
|
3836
3939
|
}
|
|
3837
3940
|
function transformTailwindCssEntry(code, id) {
|
|
@@ -3858,13 +3961,13 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3858
3961
|
}
|
|
3859
3962
|
emitMissingCssFallback(quiet, message, id, console.warn);
|
|
3860
3963
|
}
|
|
3861
|
-
|
|
3964
|
+
const advisories = result.diagnostics.filter(isAdvisoryDiagnostic);
|
|
3965
|
+
if (advisories.length === 0) return;
|
|
3966
|
+
if (quiet !== "off" || process.env.NODE_ENV === "production") {
|
|
3967
|
+
state.suppressedAdvisories += advisories.length;
|
|
3862
3968
|
return;
|
|
3863
3969
|
}
|
|
3864
|
-
for (const message of
|
|
3865
|
-
if (message.includes("unresolvable sz spread") || message.includes("AST budget exceeded") || szFallbackConsequenceOf(message) === "missing-css") {
|
|
3866
|
-
continue;
|
|
3867
|
-
}
|
|
3970
|
+
for (const message of advisories) {
|
|
3868
3971
|
warn(`[csszyx] ${id}
|
|
3869
3972
|
${message}`);
|
|
3870
3973
|
}
|
|
@@ -3883,6 +3986,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3883
3986
|
usesColorVar: result.usesColorVar,
|
|
3884
3987
|
usesSpacingVar: result.usesSpacingVar,
|
|
3885
3988
|
usesUnitVar: result.usesUnitVar,
|
|
3989
|
+
usesBoolClass: result.usesBoolClass,
|
|
3886
3990
|
szClasses: result.classes
|
|
3887
3991
|
};
|
|
3888
3992
|
}
|
|
@@ -4140,6 +4244,8 @@ ${transformedCode}`;
|
|
|
4140
4244
|
/** Finalizes the mangle map after all source modules have been processed. */
|
|
4141
4245
|
buildEnd() {
|
|
4142
4246
|
finalizeMangleMap();
|
|
4247
|
+
assertMangleCensusUnchanged();
|
|
4248
|
+
revalidateFrozenGlobalVarPlan();
|
|
4143
4249
|
assertNoRSCGraphViolation(state.rscModules);
|
|
4144
4250
|
if (!state.tailwindWarningEmitted && shouldWarnMissingTailwindEntry(
|
|
4145
4251
|
state.ownedClasses.size,
|
|
@@ -4264,10 +4370,22 @@ ${transformedCode}`;
|
|
|
4264
4370
|
if (config.command === "serve") {
|
|
4265
4371
|
manglingEnabled = false;
|
|
4266
4372
|
}
|
|
4373
|
+
if (manglingEnabled && config.build?.watch) {
|
|
4374
|
+
manglingEnabled = false;
|
|
4375
|
+
emitWarning(watchModeMangleMessage());
|
|
4376
|
+
}
|
|
4267
4377
|
evictTransformCacheOnce();
|
|
4268
4378
|
prescanAndWriteClasses();
|
|
4269
4379
|
state.scanCssTheme = runThemeScan(root, options.build?.scanCss) ?? state.scanCssTheme;
|
|
4270
4380
|
runAutoThemeScan(root);
|
|
4381
|
+
if (config.command === "build") {
|
|
4382
|
+
state.globalVarValidationResult = validateGlobalVarBundleInputs(
|
|
4383
|
+
collectProjectGlobalVarCssSources()
|
|
4384
|
+
);
|
|
4385
|
+
}
|
|
4386
|
+
if (manglingEnabled && config.command === "build") {
|
|
4387
|
+
freezeMangleMap();
|
|
4388
|
+
}
|
|
4271
4389
|
},
|
|
4272
4390
|
/**
|
|
4273
4391
|
* Vite HMR hook: re-runs theme scan when a watched CSS file changes,
|
|
@@ -4421,6 +4539,13 @@ ${transformedCode}`;
|
|
|
4421
4539
|
}
|
|
4422
4540
|
return manifest;
|
|
4423
4541
|
}
|
|
4542
|
+
function rewriteCodeAsset(source, shouldMangle) {
|
|
4543
|
+
if (!shouldMangle) return replacePlaceholders(source);
|
|
4544
|
+
const before = replacePlaceholders(source);
|
|
4545
|
+
const after = replacePlaceholders(mangleCodeClasses(source));
|
|
4546
|
+
recordCodePair(sizeAccount, before, after);
|
|
4547
|
+
return after;
|
|
4548
|
+
}
|
|
4424
4549
|
function rewriteOutputCss(source, file, shouldMangle, mangledSources, externalClasses) {
|
|
4425
4550
|
const css = rewriteCssWithValidatedGlobalVarPlan(
|
|
4426
4551
|
source,
|
|
@@ -4449,7 +4574,14 @@ ${transformedCode}`;
|
|
|
4449
4574
|
collectMangleHybridHazards(state.mangleMap, mangledSources, externalClasses)
|
|
4450
4575
|
);
|
|
4451
4576
|
if (message) console.warn(message);
|
|
4577
|
+
}
|
|
4578
|
+
function reportBuildSummary() {
|
|
4452
4579
|
reportMangleSize();
|
|
4580
|
+
if (resolveQuietMode(quiet) !== "all") {
|
|
4581
|
+
const message = suppressedAdvisoryMessage(state.suppressedAdvisories);
|
|
4582
|
+
if (message) console.warn(message);
|
|
4583
|
+
}
|
|
4584
|
+
state.suppressedAdvisories = 0;
|
|
4453
4585
|
}
|
|
4454
4586
|
function reportMangleSize() {
|
|
4455
4587
|
const verdict = computeMangleSizeVerdict(
|
|
@@ -4469,7 +4601,7 @@ ${transformedCode}`;
|
|
|
4469
4601
|
return;
|
|
4470
4602
|
}
|
|
4471
4603
|
if (!file.endsWith(".js")) return;
|
|
4472
|
-
const rewritten =
|
|
4604
|
+
const rewritten = rewriteCodeAsset(source, shouldMangle);
|
|
4473
4605
|
if (rewritten !== source) {
|
|
4474
4606
|
compilation.updateAsset(file, new compiler.webpack.sources.RawSource(rewritten));
|
|
4475
4607
|
}
|
|
@@ -4518,29 +4650,40 @@ ${transformedCode}`;
|
|
|
4518
4650
|
}
|
|
4519
4651
|
}
|
|
4520
4652
|
reportOutputMangleHazards(shouldMangle, mangledSources, externalClasses);
|
|
4653
|
+
reportBuildSummary();
|
|
4521
4654
|
}
|
|
4522
4655
|
function rewriteViteBundleEntry(chunk, file, shouldMangle, mangledSources, externalClasses) {
|
|
4523
|
-
if (chunk.type
|
|
4524
|
-
const originalCss = chunk.source.toString();
|
|
4525
|
-
const css = rewriteOutputCss(
|
|
4526
|
-
originalCss,
|
|
4527
|
-
file,
|
|
4528
|
-
shouldMangle,
|
|
4529
|
-
mangledSources,
|
|
4530
|
-
externalClasses
|
|
4531
|
-
);
|
|
4532
|
-
if (css !== originalCss) chunk.source = css;
|
|
4656
|
+
if (chunk.type !== "asset" || !chunk.fileName.endsWith(".css") || chunk.source === void 0) {
|
|
4533
4657
|
return;
|
|
4534
4658
|
}
|
|
4535
|
-
|
|
4536
|
-
const
|
|
4537
|
-
|
|
4659
|
+
const originalCss = chunk.source.toString();
|
|
4660
|
+
const css = rewriteOutputCss(
|
|
4661
|
+
originalCss,
|
|
4662
|
+
file,
|
|
4663
|
+
shouldMangle,
|
|
4664
|
+
mangledSources,
|
|
4665
|
+
externalClasses
|
|
4666
|
+
);
|
|
4667
|
+
if (css !== originalCss) chunk.source = css;
|
|
4668
|
+
}
|
|
4669
|
+
function mangleCssModule(code, id) {
|
|
4670
|
+
const shouldMangle = manglingEnabled && mangleMapFrozen && Object.keys(state.mangleMap).length > 0;
|
|
4671
|
+
const css = rewriteOutputCss(
|
|
4672
|
+
code,
|
|
4673
|
+
id,
|
|
4674
|
+
shouldMangle,
|
|
4675
|
+
transformMangledSources,
|
|
4676
|
+
transformExternalClasses
|
|
4677
|
+
);
|
|
4678
|
+
return css === code ? null : { code: css, map: null };
|
|
4538
4679
|
}
|
|
4539
4680
|
function processRollupBundle(bundle, emitAsset) {
|
|
4540
4681
|
finalizeMangleMap();
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4682
|
+
if (!cssRewrittenInTransform) {
|
|
4683
|
+
state.globalVarValidationResult = validateGlobalVarBundleInputs(
|
|
4684
|
+
collectRollupGlobalVarCssAssets(bundle)
|
|
4685
|
+
);
|
|
4686
|
+
}
|
|
4544
4687
|
const shouldMangle = manglingEnabled && Object.keys(state.mangleMap).length > 0;
|
|
4545
4688
|
if (options.build?.emitManifest === true) {
|
|
4546
4689
|
emitAsset("csszyx-manifest.json", JSON.stringify(createBundleManifest(shouldMangle)));
|
|
@@ -4553,16 +4696,18 @@ ${transformedCode}`;
|
|
|
4553
4696
|
);
|
|
4554
4697
|
if (globalVarMap) emitAsset(".csszyx/global-var-map.json", globalVarMap);
|
|
4555
4698
|
}
|
|
4556
|
-
const mangledSources =
|
|
4557
|
-
const externalClasses =
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4699
|
+
const mangledSources = new Set(transformMangledSources);
|
|
4700
|
+
const externalClasses = new Set(transformExternalClasses);
|
|
4701
|
+
if (!cssRewrittenInTransform) {
|
|
4702
|
+
for (const file in bundle) {
|
|
4703
|
+
rewriteViteBundleEntry(
|
|
4704
|
+
bundle[file],
|
|
4705
|
+
file,
|
|
4706
|
+
shouldMangle,
|
|
4707
|
+
mangledSources,
|
|
4708
|
+
externalClasses
|
|
4709
|
+
);
|
|
4710
|
+
}
|
|
4566
4711
|
}
|
|
4567
4712
|
reportOutputMangleHazards(shouldMangle, mangledSources, externalClasses);
|
|
4568
4713
|
}
|
|
@@ -4576,8 +4721,38 @@ ${transformedCode}`;
|
|
|
4576
4721
|
* @param compiler - the Webpack compiler instance
|
|
4577
4722
|
*/
|
|
4578
4723
|
webpack(compiler) {
|
|
4724
|
+
if (manglingEnabled && compiler.options?.optimization?.realContentHash === false) {
|
|
4725
|
+
emitWarning(realContentHashDisabledMessage());
|
|
4726
|
+
}
|
|
4579
4727
|
registerWebpackAssetProcessor(compiler, processWebpackAssets);
|
|
4580
4728
|
},
|
|
4729
|
+
/**
|
|
4730
|
+
* Settle the map once, before the first chunk is rendered.
|
|
4731
|
+
*
|
|
4732
|
+
* `renderChunk` is where the class rewrite has to happen, and Rollup
|
|
4733
|
+
* offers no ordering guarantee among chunks — so the map is completed
|
|
4734
|
+
* here rather than from whichever chunk arrives first.
|
|
4735
|
+
*/
|
|
4736
|
+
renderStart() {
|
|
4737
|
+
finalizeMangleMap();
|
|
4738
|
+
},
|
|
4739
|
+
/**
|
|
4740
|
+
* Rewrite a JS chunk while its bytes still decide its filename hash.
|
|
4741
|
+
*
|
|
4742
|
+
* Rollup renders every chunk, hashes the result, substitutes the
|
|
4743
|
+
* filename placeholders and only then calls `generateBundle` — so the
|
|
4744
|
+
* rewrite this used to do there produced a file whose name described
|
|
4745
|
+
* the un-mangled bytes. The map is complete by `buildEnd`, which is
|
|
4746
|
+
* before the render phase, so nothing forces the later hook.
|
|
4747
|
+
*
|
|
4748
|
+
* @param code Rendered chunk source.
|
|
4749
|
+
* @returns Rewritten chunk, or null when nothing changed.
|
|
4750
|
+
*/
|
|
4751
|
+
renderChunk(code) {
|
|
4752
|
+
const shouldMangle = manglingEnabled && Object.keys(state.mangleMap).length > 0;
|
|
4753
|
+
const rewritten = rewriteCodeAsset(code, shouldMangle);
|
|
4754
|
+
return rewritten === code ? null : { code: rewritten, map: null };
|
|
4755
|
+
},
|
|
4581
4756
|
/**
|
|
4582
4757
|
* Rollup-compatible hook used by both pure Rollup and Vite adapters.
|
|
4583
4758
|
*
|
|
@@ -4590,15 +4765,54 @@ ${transformedCode}`;
|
|
|
4590
4765
|
processRollupBundle(bundle, (fileName, source) => {
|
|
4591
4766
|
this.emitFile({ type: "asset", fileName, source });
|
|
4592
4767
|
});
|
|
4768
|
+
},
|
|
4769
|
+
/**
|
|
4770
|
+
* Report what mangling cost, after the bundler has printed its assets.
|
|
4771
|
+
*
|
|
4772
|
+
* Vite's reporter prints the asset table from `writeBundle`, which runs
|
|
4773
|
+
* before this hook — so the size verdict lands where a reader is
|
|
4774
|
+
* already looking at sizes, instead of scrolling past mid-build among
|
|
4775
|
+
* the other diagnostics.
|
|
4776
|
+
*/
|
|
4777
|
+
closeBundle() {
|
|
4778
|
+
reportBuildSummary();
|
|
4779
|
+
}
|
|
4780
|
+
}));
|
|
4781
|
+
const cssPlugin = createUnplugin(() => ({
|
|
4782
|
+
name: "csszyx:css-mangle",
|
|
4783
|
+
transformInclude(id) {
|
|
4784
|
+
return cssRewrittenInTransform && isMangleableCssId(id);
|
|
4785
|
+
},
|
|
4786
|
+
transform(code, id) {
|
|
4787
|
+
return mangleCssModule(code, id);
|
|
4788
|
+
},
|
|
4789
|
+
vite: {
|
|
4790
|
+
/**
|
|
4791
|
+
* Claim the CSS rewrite for the transform phase on this lane.
|
|
4792
|
+
*
|
|
4793
|
+
* A dev server never reaches an output hook, and mangling is off
|
|
4794
|
+
* there anyway; claiming it only for `build` keeps `vite serve`
|
|
4795
|
+
* exactly as it was.
|
|
4796
|
+
*
|
|
4797
|
+
* @param config - the resolved Vite configuration object
|
|
4798
|
+
* @param config.command - `'build'` or `'serve'`
|
|
4799
|
+
*/
|
|
4800
|
+
configResolved(config) {
|
|
4801
|
+
cssRewrittenInTransform = config.command === "build";
|
|
4802
|
+
}
|
|
4593
4803
|
}
|
|
4594
4804
|
}));
|
|
4595
|
-
return { prePlugin, postPlugin };
|
|
4805
|
+
return { prePlugin, postPlugin, cssPlugin };
|
|
4596
4806
|
}
|
|
4597
4807
|
const defaultInstance = createCsszyxPlugins();
|
|
4598
4808
|
const unplugin = defaultInstance.prePlugin;
|
|
4599
4809
|
const vitePlugin = (options = {}) => {
|
|
4600
|
-
const { prePlugin, postPlugin } = createCsszyxPlugins(options);
|
|
4601
|
-
return [
|
|
4810
|
+
const { prePlugin, postPlugin, cssPlugin } = createCsszyxPlugins(options);
|
|
4811
|
+
return [
|
|
4812
|
+
prePlugin.vite(options),
|
|
4813
|
+
cssPlugin.vite(options),
|
|
4814
|
+
postPlugin.vite(options)
|
|
4815
|
+
];
|
|
4602
4816
|
};
|
|
4603
4817
|
const webpackPlugin = (options = {}) => {
|
|
4604
4818
|
const { prePlugin, postPlugin } = createCsszyxPlugins(options);
|
|
@@ -4645,4 +4859,4 @@ const esbuildPlugin = (options = {}) => {
|
|
|
4645
4859
|
};
|
|
4646
4860
|
};
|
|
4647
4861
|
|
|
4648
|
-
export {
|
|
4862
|
+
export { shouldWarnUnscopedMonorepo as $, isHardIgnoredPath as A, isMangleableCssId as B, isMonorepoPackage as C, isPackagesSkippedSource as D, isRSCServerModule as E, isTailwindReservedGlobalVar as F, lateMangleCensusMessage as G, mangleCodeClassesSync as H, mangleEligibleClasses as I, mangleHybridHazardMessage as J, missingTailwindEntryMessage as K, normalizeGlobalVarAliasesForCache as L, planGlobalVarAliases as M, readGlobalVarScanCache as N, realContentHashDisabledMessage as O, recordGlobalVarSourceFile as P, resolveCompileSourceDirs as Q, resolveGlobalVarScanCacheDir as R, resolveNativeCacheIdentity as S, resolveQuietMode as T, rewriteGlobalVarCssAliases as U, rollupPlugin as V, scanGlobalVarCss as W, shouldEmitMissingCssFallback as X, shouldEmitWarning as Y, shouldTrackGlobalVarSources as Z, shouldWarnMissingTailwindEntry as _, allocateMangleTokens as a, skippedSzFilesMessage as a0, suppressedAdvisoryMessage as a1, unscopedMonorepoMessage as a2, validateGlobalVarAliasInputs as a3, vitePlugin as a4, watchModeMangleMessage as a5, webpackPlugin as a6, writeGlobalVarScanCache as a7, 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, isAdvisoryDiagnostic as y, isCompileSourceOptedIn as z };
|