@csszyx/unplugin 0.10.5 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{unplugin.nVFTcBVL.cjs → unplugin.CaH_X1dP.cjs} +48 -12
- package/dist/shared/{unplugin.BaRxZXyj.mjs → unplugin.D_GIYc2p.mjs} +47 -11
- package/dist/shared/{unplugin.DzA2Mwc7.d.cts → unplugin.DjIGzbic.d.cts} +6 -1
- package/dist/shared/{unplugin.DzA2Mwc7.d.mts → unplugin.DjIGzbic.d.mts} +6 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const cssMangler = require('./css-mangler.cjs');
|
|
6
|
-
const unplugin = require('./shared/unplugin.
|
|
6
|
+
const unplugin = require('./shared/unplugin.CaH_X1dP.cjs');
|
|
7
7
|
const types = require('@csszyx/types');
|
|
8
8
|
require('postcss');
|
|
9
9
|
require('postcss-selector-parser');
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.cjs';
|
|
2
2
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
3
|
-
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.
|
|
3
|
+
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.DjIGzbic.cjs';
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
export = undefined;
|
|
6
|
-
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, o as appendTailwindSourceDirective, p as computeSafelistRelPath, q as createGlobalVarMapAssetSource, r as cssHasContentScope, s as cssImportsTailwind, t as esbuildPlugin, v as extractGlobalVarAliasesForManifest, w as fileMayContainSafelistableSz, x as hasInjectableTailwindCandidate, y as isCompileSourceOptedIn, z as isHardIgnoredPath, A as isMonorepoPackage, B as isPackagesSkippedSource, D as mangleCodeClassesSync, E as missingTailwindEntryMessage, F as normalizeGlobalVarAliasesForCache, H as resolveCompileSourceDirs, I as resolveNativeCacheIdentity, J as rollupPlugin, K as shouldEmitWarning, L as shouldWarnMissingTailwindEntry, M as shouldWarnUnscopedMonorepo, N as skippedSzFilesMessage, u as unplugin, O as unscopedMonorepoMessage, Q as vitePlugin, T as webpackPlugin } from './shared/unplugin.
|
|
6
|
+
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, o as appendTailwindSourceDirective, p as computeSafelistRelPath, q as createGlobalVarMapAssetSource, r as cssHasContentScope, s as cssImportsTailwind, t as esbuildPlugin, v as extractGlobalVarAliasesForManifest, w as fileMayContainSafelistableSz, x as hasInjectableTailwindCandidate, y as isCompileSourceOptedIn, z as isHardIgnoredPath, A as isMonorepoPackage, B as isPackagesSkippedSource, D as mangleCodeClassesSync, E as missingTailwindEntryMessage, F as normalizeGlobalVarAliasesForCache, H as resolveCompileSourceDirs, I as resolveNativeCacheIdentity, J as rollupPlugin, K as shouldEmitWarning, L as shouldWarnMissingTailwindEntry, M as shouldWarnUnscopedMonorepo, N as skippedSzFilesMessage, u as unplugin, O as unscopedMonorepoMessage, Q as vitePlugin, T as webpackPlugin } from './shared/unplugin.DjIGzbic.cjs';
|
|
7
7
|
import 'postcss';
|
|
8
8
|
import '@csszyx/compiler';
|
|
9
9
|
import 'esbuild';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.mjs';
|
|
2
2
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
3
|
-
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.
|
|
4
|
-
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, o as appendTailwindSourceDirective, p as computeSafelistRelPath, q as createGlobalVarMapAssetSource, r as cssHasContentScope, s as cssImportsTailwind, u as default, t as esbuildPlugin, v as extractGlobalVarAliasesForManifest, w as fileMayContainSafelistableSz, x as hasInjectableTailwindCandidate, y as isCompileSourceOptedIn, z as isHardIgnoredPath, A as isMonorepoPackage, B as isPackagesSkippedSource, D as mangleCodeClassesSync, E as missingTailwindEntryMessage, F as normalizeGlobalVarAliasesForCache, H as resolveCompileSourceDirs, I as resolveNativeCacheIdentity, J as rollupPlugin, K as shouldEmitWarning, L as shouldWarnMissingTailwindEntry, M as shouldWarnUnscopedMonorepo, N as skippedSzFilesMessage, u as unplugin, O as unscopedMonorepoMessage, Q as vitePlugin, T as webpackPlugin } from './shared/unplugin.
|
|
3
|
+
import { G as GlobalVarScanCacheKeyInput, C as CssVarScanResult, S as ScanGlobalVarCssOptions, P as PlanGlobalVarAliasesInput, a as GlobalVarAliasPlan, R as RewriteGlobalVarCssAliasesOptions, b as GlobalVarCssAliasRewriteResult, c as CreateGlobalVarAliasValidationOptionsInput, V as ValidateGlobalVarAliasInputsOptions, d as GlobalVarAliasValidationResult } from './shared/unplugin.DjIGzbic.mjs';
|
|
4
|
+
export { e as CssVarDefinition, f as CssVarLocation, g as CssVarReference, h as GlobalVarAliasDiagnostic, i as GlobalVarAliasDiagnosticSeverity, j as GlobalVarAliasEntry, k as GlobalVarCodeSource, l as GlobalVarCssAssetSource, m as GlobalVarCssSource, n as GlobalVarScanCacheEntry, o as appendTailwindSourceDirective, p as computeSafelistRelPath, q as createGlobalVarMapAssetSource, r as cssHasContentScope, s as cssImportsTailwind, u as default, t as esbuildPlugin, v as extractGlobalVarAliasesForManifest, w as fileMayContainSafelistableSz, x as hasInjectableTailwindCandidate, y as isCompileSourceOptedIn, z as isHardIgnoredPath, A as isMonorepoPackage, B as isPackagesSkippedSource, D as mangleCodeClassesSync, E as missingTailwindEntryMessage, F as normalizeGlobalVarAliasesForCache, H as resolveCompileSourceDirs, I as resolveNativeCacheIdentity, J as rollupPlugin, K as shouldEmitWarning, L as shouldWarnMissingTailwindEntry, M as shouldWarnUnscopedMonorepo, N as skippedSzFilesMessage, u as unplugin, O as unscopedMonorepoMessage, Q as vitePlugin, T as webpackPlugin } from './shared/unplugin.DjIGzbic.mjs';
|
|
5
5
|
import 'postcss';
|
|
6
6
|
import '@csszyx/compiler';
|
|
7
7
|
import 'esbuild';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.mjs';
|
|
2
|
-
export { a as appendTailwindSourceDirective, b as assertNoRSCBoundaryViolation, c as assertNoRSCGraphViolation, d as computeSafelistRelPath, e as createGlobalVarAliasValidationOptions, f as createGlobalVarMapAssetSource, g as createGlobalVarScanCacheKey, h as createRSCModuleRecord, i as cssHasContentScope, j as cssImportsTailwind, u as default, k as deleteRSCModuleRecord, l as esbuildPlugin, m as extractGlobalVarAliasesForManifest, n as fileMayContainSafelistableSz, o as findRSCBoundaryViolation, p as findRSCGraphViolation, q as hasInjectableTailwindCandidate, r as hasTokens, s as hasUseClientDirective, t as hasUseServerDirective, v as isCompileSourceOptedIn, w as isHardIgnoredPath, x as isMonorepoPackage, y as isPackagesSkippedSource, z as isRSCServerModule, A as isTailwindReservedGlobalVar, B as mangleCodeClassesSync, C as mergeThemes, D as missingTailwindEntryMessage, E as normalizeGlobalVarAliasesForCache, F as parseThemeBlocks, G as planGlobalVarAliases, H as readGlobalVarScanCache, I as resolveCompileSourceDirs, J as resolveGlobalVarScanCacheDir, K as resolveNativeCacheIdentity, L as rewriteGlobalVarCssAliases, M as rollupPlugin, N as scanGlobalVarCss, O as shouldEmitWarning, P as shouldWarnMissingTailwindEntry, Q as shouldWarnUnscopedMonorepo, R as skippedSzFilesMessage, u as unplugin, S as unscopedMonorepoMessage, T as validateGlobalVarAliasInputs, U as vitePlugin, V as webpackPlugin, W as writeGlobalVarScanCache } from './shared/unplugin.
|
|
2
|
+
export { a as appendTailwindSourceDirective, b as assertNoRSCBoundaryViolation, c as assertNoRSCGraphViolation, d as computeSafelistRelPath, e as createGlobalVarAliasValidationOptions, f as createGlobalVarMapAssetSource, g as createGlobalVarScanCacheKey, h as createRSCModuleRecord, i as cssHasContentScope, j as cssImportsTailwind, u as default, k as deleteRSCModuleRecord, l as esbuildPlugin, m as extractGlobalVarAliasesForManifest, n as fileMayContainSafelistableSz, o as findRSCBoundaryViolation, p as findRSCGraphViolation, q as hasInjectableTailwindCandidate, r as hasTokens, s as hasUseClientDirective, t as hasUseServerDirective, v as isCompileSourceOptedIn, w as isHardIgnoredPath, x as isMonorepoPackage, y as isPackagesSkippedSource, z as isRSCServerModule, A as isTailwindReservedGlobalVar, B as mangleCodeClassesSync, C as mergeThemes, D as missingTailwindEntryMessage, E as normalizeGlobalVarAliasesForCache, F as parseThemeBlocks, G as planGlobalVarAliases, H as readGlobalVarScanCache, I as resolveCompileSourceDirs, J as resolveGlobalVarScanCacheDir, K as resolveNativeCacheIdentity, L as rewriteGlobalVarCssAliases, M as rollupPlugin, N as scanGlobalVarCss, O as shouldEmitWarning, P as shouldWarnMissingTailwindEntry, Q as shouldWarnUnscopedMonorepo, R as skippedSzFilesMessage, u as unplugin, S as unscopedMonorepoMessage, T as validateGlobalVarAliasInputs, U as vitePlugin, V as webpackPlugin, W as writeGlobalVarScanCache } from './shared/unplugin.D_GIYc2p.mjs';
|
|
3
3
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
4
4
|
import 'postcss';
|
|
5
5
|
import 'postcss-selector-parser';
|
|
@@ -1425,6 +1425,20 @@ function escapeForDoubleQuotedString(value) {
|
|
|
1425
1425
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1426
1426
|
}
|
|
1427
1427
|
|
|
1428
|
+
function isParserMode(value) {
|
|
1429
|
+
return value === "rust" || value === "oxc" || value === "babel";
|
|
1430
|
+
}
|
|
1431
|
+
function resolveParserMode(input) {
|
|
1432
|
+
const { configParser, envParser, defaultParser, isRustAvailable } = input;
|
|
1433
|
+
const envValid = isParserMode(envParser);
|
|
1434
|
+
const explicit = envValid || configParser != null;
|
|
1435
|
+
const parser = envValid ? envParser : configParser ?? defaultParser;
|
|
1436
|
+
if (parser === "rust" && !explicit && !isRustAvailable()) {
|
|
1437
|
+
return { parser: "oxc", degraded: true, explicit: false };
|
|
1438
|
+
}
|
|
1439
|
+
return { parser, degraded: false, explicit };
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1428
1442
|
const DEFAULT_MAX_ATTEMPTS = 3;
|
|
1429
1443
|
const NODE_FS = {
|
|
1430
1444
|
openSync: fs__namespace.openSync,
|
|
@@ -1594,9 +1608,10 @@ const RUNTIME_HELPER_IMPORT_RE = {
|
|
|
1594
1608
|
};
|
|
1595
1609
|
let _hasWarnedTsConfig = false;
|
|
1596
1610
|
let _hasWarnedTransformCacheVersion = false;
|
|
1597
|
-
|
|
1611
|
+
let _hasWarnedNativeFallback = false;
|
|
1612
|
+
const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.CaH_X1dP.cjs', document.baseURI).href)));
|
|
1598
1613
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
1599
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.
|
|
1614
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.CaH_X1dP.cjs', document.baseURI).href))),
|
|
1600
1615
|
UNKNOWN_PACKAGE_VERSION
|
|
1601
1616
|
);
|
|
1602
1617
|
const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
|
|
@@ -1667,8 +1682,8 @@ function hasInjectableTailwindCandidate(classes) {
|
|
|
1667
1682
|
}
|
|
1668
1683
|
return false;
|
|
1669
1684
|
}
|
|
1670
|
-
function shouldWarnMissingTailwindEntry(ownedClassCount, sawTailwindEntry) {
|
|
1671
|
-
return ownedClassCount > 0 && !sawTailwindEntry;
|
|
1685
|
+
function shouldWarnMissingTailwindEntry(ownedClassCount, sawTailwindEntry, sawAnyCss) {
|
|
1686
|
+
return ownedClassCount > 0 && sawAnyCss && !sawTailwindEntry;
|
|
1672
1687
|
}
|
|
1673
1688
|
function missingTailwindEntryMessage(ownedClassCount) {
|
|
1674
1689
|
return `[csszyx] generated ${ownedClassCount} sz class(es) but found no CSS entry importing "tailwindcss" \u2014 those classes will produce no CSS. Import "tailwindcss" in a CSS file (csszyx auto-injects @source for the generated classes) so Tailwind emits their styles.`;
|
|
@@ -2397,7 +2412,7 @@ ${errors.join("\n")}`
|
|
|
2397
2412
|
}
|
|
2398
2413
|
function createCsszyxPlugins(options = {}) {
|
|
2399
2414
|
assertGlobalVarMangleConfig(options);
|
|
2400
|
-
|
|
2415
|
+
let manglingEnabled = options.production?.mangle !== false;
|
|
2401
2416
|
const astBudgetOverride = options.build?.astBudgetLimit;
|
|
2402
2417
|
const cacheRequested = (options.build?.cache ?? types.DEFAULT_BUILD_CONFIG.cache) !== false;
|
|
2403
2418
|
const cacheVersionsKnown = PLUGIN_VERSION !== UNKNOWN_PACKAGE_VERSION && COMPILER_VERSION !== UNKNOWN_PACKAGE_VERSION;
|
|
@@ -2423,14 +2438,24 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2423
2438
|
console.warn(message);
|
|
2424
2439
|
}
|
|
2425
2440
|
}
|
|
2426
|
-
const
|
|
2427
|
-
|
|
2428
|
-
|
|
2441
|
+
const { parser: parserMode, degraded: parserDegraded } = resolveParserMode({
|
|
2442
|
+
configParser: options.build?.parser,
|
|
2443
|
+
envParser: process.env.CSSZYX_PARSER,
|
|
2444
|
+
defaultParser: types.DEFAULT_BUILD_CONFIG.parser ?? "rust",
|
|
2445
|
+
isRustAvailable: compiler.isRustTransformAvailable
|
|
2446
|
+
});
|
|
2447
|
+
if (parserDegraded && !_hasWarnedNativeFallback) {
|
|
2448
|
+
_hasWarnedNativeFallback = true;
|
|
2449
|
+
console.warn(
|
|
2450
|
+
"[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to `oxc`. Output classes are identical (parity-tested); only parse speed differs. To use the native engine, install the matching @csszyx/core-<platform> package (or do not omit optional dependencies). Set `build.parser` explicitly to silence this."
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2429
2453
|
let evictedCacheRoot = null;
|
|
2430
2454
|
const transformMemoryCache = /* @__PURE__ */ new Map();
|
|
2431
2455
|
const state = {
|
|
2432
2456
|
classes: /* @__PURE__ */ new Set(),
|
|
2433
2457
|
sawTailwindEntry: false,
|
|
2458
|
+
sawAnyCss: false,
|
|
2434
2459
|
tailwindWarningEmitted: false,
|
|
2435
2460
|
tailwindEntryScoped: false,
|
|
2436
2461
|
contentScopeWarningEmitted: false,
|
|
@@ -2580,7 +2605,9 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2580
2605
|
astBudget: astBudgetOverride,
|
|
2581
2606
|
mangleVars: options.production?.mangleVars === true,
|
|
2582
2607
|
mangleVarHoistMaxDepth: options.production?.mangleVarHoistMaxDepth,
|
|
2583
|
-
globalVarAliases: earlyGlobalVarAliasEntries.length > 0 ? earlyGlobalVarAliasEntries : void 0
|
|
2608
|
+
globalVarAliases: earlyGlobalVarAliasEntries.length > 0 ? earlyGlobalVarAliasEntries : void 0,
|
|
2609
|
+
// Render dev-mode unknown-property warnings relative to the project root.
|
|
2610
|
+
rootDir: state.rootDir
|
|
2584
2611
|
};
|
|
2585
2612
|
}
|
|
2586
2613
|
function createConfiguredTransformCacheInput(source, effectiveFilename, compilerOptions) {
|
|
@@ -2813,7 +2840,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2813
2840
|
scanDir(sourceDir);
|
|
2814
2841
|
}
|
|
2815
2842
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2816
|
-
if (!result.transformed) {
|
|
2843
|
+
if (!result.transformed && result.classes.size === 0) {
|
|
2817
2844
|
continue;
|
|
2818
2845
|
}
|
|
2819
2846
|
collectPrescanResult(result, filePath, discoveredClasses, rawDiscoveredClasses);
|
|
@@ -3049,6 +3076,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3049
3076
|
assertNoRSCBoundaryViolation(code, id);
|
|
3050
3077
|
}
|
|
3051
3078
|
if (/\.css(\?.*)?$/.test(id)) {
|
|
3079
|
+
state.sawAnyCss = true;
|
|
3052
3080
|
if (cssImportsTailwind(code)) {
|
|
3053
3081
|
state.sawTailwindEntry = true;
|
|
3054
3082
|
if (cssHasContentScope(code)) {
|
|
@@ -3194,7 +3222,11 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3194
3222
|
buildEnd() {
|
|
3195
3223
|
finalizeMangleMap();
|
|
3196
3224
|
assertNoRSCGraphViolation(state.rscModules);
|
|
3197
|
-
if (!state.tailwindWarningEmitted && shouldWarnMissingTailwindEntry(
|
|
3225
|
+
if (!state.tailwindWarningEmitted && shouldWarnMissingTailwindEntry(
|
|
3226
|
+
state.ownedClasses.size,
|
|
3227
|
+
state.sawTailwindEntry,
|
|
3228
|
+
state.sawAnyCss
|
|
3229
|
+
)) {
|
|
3198
3230
|
state.tailwindWarningEmitted = true;
|
|
3199
3231
|
emitWarning(missingTailwindEntryMessage(state.ownedClasses.size));
|
|
3200
3232
|
}
|
|
@@ -3270,6 +3302,9 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3270
3302
|
configResolved(config) {
|
|
3271
3303
|
const root = config.root || process.cwd();
|
|
3272
3304
|
state.rootDir = root;
|
|
3305
|
+
if (config.command === "serve") {
|
|
3306
|
+
manglingEnabled = false;
|
|
3307
|
+
}
|
|
3273
3308
|
evictTransformCacheOnce();
|
|
3274
3309
|
prescanAndWriteClasses();
|
|
3275
3310
|
runThemeScan(root, options.build?.scanCss);
|
|
@@ -3349,7 +3384,8 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3349
3384
|
*/
|
|
3350
3385
|
handler(html) {
|
|
3351
3386
|
finalizeMangleMap();
|
|
3352
|
-
|
|
3387
|
+
const injectedMangleMap = manglingEnabled ? state.mangleMap : {};
|
|
3388
|
+
let result = transformIndexHtml(html, injectedMangleMap, state.checksum, {
|
|
3353
3389
|
mode: options.production?.injectChecksum === false ? "script" : "script",
|
|
3354
3390
|
minify: process.env.NODE_ENV === "production",
|
|
3355
3391
|
varMangleMap: state.varMangleMap,
|
|
@@ -5,7 +5,7 @@ import * as path from 'node:path';
|
|
|
5
5
|
import { dirname } from 'node:path';
|
|
6
6
|
import { performance } from 'node:perf_hooks';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { scanGlobalVarUsages, ensureRustTransformAvailable, transformSourceCode, transformRust, transformOxc, transformRustBatch, transform } from '@csszyx/compiler';
|
|
8
|
+
import { scanGlobalVarUsages, ensureRustTransformAvailable, transformSourceCode, transformRust, transformOxc, transformRustBatch, transform, isRustTransformAvailable } from '@csszyx/compiler';
|
|
9
9
|
import { encode, compute_mangle_checksum } from '@csszyx/core';
|
|
10
10
|
import { getNativePackageName } from '@csszyx/core/native';
|
|
11
11
|
import { preprocess as preprocess$1 } from '@csszyx/svelte-adapter';
|
|
@@ -1405,6 +1405,20 @@ function escapeForDoubleQuotedString(value) {
|
|
|
1405
1405
|
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
|
+
function isParserMode(value) {
|
|
1409
|
+
return value === "rust" || value === "oxc" || value === "babel";
|
|
1410
|
+
}
|
|
1411
|
+
function resolveParserMode(input) {
|
|
1412
|
+
const { configParser, envParser, defaultParser, isRustAvailable } = input;
|
|
1413
|
+
const envValid = isParserMode(envParser);
|
|
1414
|
+
const explicit = envValid || configParser != null;
|
|
1415
|
+
const parser = envValid ? envParser : configParser ?? defaultParser;
|
|
1416
|
+
if (parser === "rust" && !explicit && !isRustAvailable()) {
|
|
1417
|
+
return { parser: "oxc", degraded: true, explicit: false };
|
|
1418
|
+
}
|
|
1419
|
+
return { parser, degraded: false, explicit };
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1408
1422
|
const DEFAULT_MAX_ATTEMPTS = 3;
|
|
1409
1423
|
const NODE_FS = {
|
|
1410
1424
|
openSync: fs.openSync,
|
|
@@ -1574,6 +1588,7 @@ const RUNTIME_HELPER_IMPORT_RE = {
|
|
|
1574
1588
|
};
|
|
1575
1589
|
let _hasWarnedTsConfig = false;
|
|
1576
1590
|
let _hasWarnedTransformCacheVersion = false;
|
|
1591
|
+
let _hasWarnedNativeFallback = false;
|
|
1577
1592
|
const requireFromHere = createRequire(import.meta.url);
|
|
1578
1593
|
const PLUGIN_VERSION = findPackageVersionFromFile(
|
|
1579
1594
|
fileURLToPath(import.meta.url),
|
|
@@ -1647,8 +1662,8 @@ function hasInjectableTailwindCandidate(classes) {
|
|
|
1647
1662
|
}
|
|
1648
1663
|
return false;
|
|
1649
1664
|
}
|
|
1650
|
-
function shouldWarnMissingTailwindEntry(ownedClassCount, sawTailwindEntry) {
|
|
1651
|
-
return ownedClassCount > 0 && !sawTailwindEntry;
|
|
1665
|
+
function shouldWarnMissingTailwindEntry(ownedClassCount, sawTailwindEntry, sawAnyCss) {
|
|
1666
|
+
return ownedClassCount > 0 && sawAnyCss && !sawTailwindEntry;
|
|
1652
1667
|
}
|
|
1653
1668
|
function missingTailwindEntryMessage(ownedClassCount) {
|
|
1654
1669
|
return `[csszyx] generated ${ownedClassCount} sz class(es) but found no CSS entry importing "tailwindcss" \u2014 those classes will produce no CSS. Import "tailwindcss" in a CSS file (csszyx auto-injects @source for the generated classes) so Tailwind emits their styles.`;
|
|
@@ -2377,7 +2392,7 @@ ${errors.join("\n")}`
|
|
|
2377
2392
|
}
|
|
2378
2393
|
function createCsszyxPlugins(options = {}) {
|
|
2379
2394
|
assertGlobalVarMangleConfig(options);
|
|
2380
|
-
|
|
2395
|
+
let manglingEnabled = options.production?.mangle !== false;
|
|
2381
2396
|
const astBudgetOverride = options.build?.astBudgetLimit;
|
|
2382
2397
|
const cacheRequested = (options.build?.cache ?? DEFAULT_BUILD_CONFIG.cache) !== false;
|
|
2383
2398
|
const cacheVersionsKnown = PLUGIN_VERSION !== UNKNOWN_PACKAGE_VERSION && COMPILER_VERSION !== UNKNOWN_PACKAGE_VERSION;
|
|
@@ -2403,14 +2418,24 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2403
2418
|
console.warn(message);
|
|
2404
2419
|
}
|
|
2405
2420
|
}
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2421
|
+
const { parser: parserMode, degraded: parserDegraded } = resolveParserMode({
|
|
2422
|
+
configParser: options.build?.parser,
|
|
2423
|
+
envParser: process.env.CSSZYX_PARSER,
|
|
2424
|
+
defaultParser: DEFAULT_BUILD_CONFIG.parser ?? "rust",
|
|
2425
|
+
isRustAvailable: isRustTransformAvailable
|
|
2426
|
+
});
|
|
2427
|
+
if (parserDegraded && !_hasWarnedNativeFallback) {
|
|
2428
|
+
_hasWarnedNativeFallback = true;
|
|
2429
|
+
console.warn(
|
|
2430
|
+
"[csszyx] No prebuilt native binary (@csszyx/core-*) is available for this platform, so the default `rust` parser fell back to `oxc`. Output classes are identical (parity-tested); only parse speed differs. To use the native engine, install the matching @csszyx/core-<platform> package (or do not omit optional dependencies). Set `build.parser` explicitly to silence this."
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2409
2433
|
let evictedCacheRoot = null;
|
|
2410
2434
|
const transformMemoryCache = /* @__PURE__ */ new Map();
|
|
2411
2435
|
const state = {
|
|
2412
2436
|
classes: /* @__PURE__ */ new Set(),
|
|
2413
2437
|
sawTailwindEntry: false,
|
|
2438
|
+
sawAnyCss: false,
|
|
2414
2439
|
tailwindWarningEmitted: false,
|
|
2415
2440
|
tailwindEntryScoped: false,
|
|
2416
2441
|
contentScopeWarningEmitted: false,
|
|
@@ -2560,7 +2585,9 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2560
2585
|
astBudget: astBudgetOverride,
|
|
2561
2586
|
mangleVars: options.production?.mangleVars === true,
|
|
2562
2587
|
mangleVarHoistMaxDepth: options.production?.mangleVarHoistMaxDepth,
|
|
2563
|
-
globalVarAliases: earlyGlobalVarAliasEntries.length > 0 ? earlyGlobalVarAliasEntries : void 0
|
|
2588
|
+
globalVarAliases: earlyGlobalVarAliasEntries.length > 0 ? earlyGlobalVarAliasEntries : void 0,
|
|
2589
|
+
// Render dev-mode unknown-property warnings relative to the project root.
|
|
2590
|
+
rootDir: state.rootDir
|
|
2564
2591
|
};
|
|
2565
2592
|
}
|
|
2566
2593
|
function createConfiguredTransformCacheInput(source, effectiveFilename, compilerOptions) {
|
|
@@ -2793,7 +2820,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2793
2820
|
scanDir(sourceDir);
|
|
2794
2821
|
}
|
|
2795
2822
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2796
|
-
if (!result.transformed) {
|
|
2823
|
+
if (!result.transformed && result.classes.size === 0) {
|
|
2797
2824
|
continue;
|
|
2798
2825
|
}
|
|
2799
2826
|
collectPrescanResult(result, filePath, discoveredClasses, rawDiscoveredClasses);
|
|
@@ -3029,6 +3056,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3029
3056
|
assertNoRSCBoundaryViolation(code, id);
|
|
3030
3057
|
}
|
|
3031
3058
|
if (/\.css(\?.*)?$/.test(id)) {
|
|
3059
|
+
state.sawAnyCss = true;
|
|
3032
3060
|
if (cssImportsTailwind(code)) {
|
|
3033
3061
|
state.sawTailwindEntry = true;
|
|
3034
3062
|
if (cssHasContentScope(code)) {
|
|
@@ -3174,7 +3202,11 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3174
3202
|
buildEnd() {
|
|
3175
3203
|
finalizeMangleMap();
|
|
3176
3204
|
assertNoRSCGraphViolation(state.rscModules);
|
|
3177
|
-
if (!state.tailwindWarningEmitted && shouldWarnMissingTailwindEntry(
|
|
3205
|
+
if (!state.tailwindWarningEmitted && shouldWarnMissingTailwindEntry(
|
|
3206
|
+
state.ownedClasses.size,
|
|
3207
|
+
state.sawTailwindEntry,
|
|
3208
|
+
state.sawAnyCss
|
|
3209
|
+
)) {
|
|
3178
3210
|
state.tailwindWarningEmitted = true;
|
|
3179
3211
|
emitWarning(missingTailwindEntryMessage(state.ownedClasses.size));
|
|
3180
3212
|
}
|
|
@@ -3250,6 +3282,9 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3250
3282
|
configResolved(config) {
|
|
3251
3283
|
const root = config.root || process.cwd();
|
|
3252
3284
|
state.rootDir = root;
|
|
3285
|
+
if (config.command === "serve") {
|
|
3286
|
+
manglingEnabled = false;
|
|
3287
|
+
}
|
|
3253
3288
|
evictTransformCacheOnce();
|
|
3254
3289
|
prescanAndWriteClasses();
|
|
3255
3290
|
runThemeScan(root, options.build?.scanCss);
|
|
@@ -3329,7 +3364,8 @@ function createCsszyxPlugins(options = {}) {
|
|
|
3329
3364
|
*/
|
|
3330
3365
|
handler(html) {
|
|
3331
3366
|
finalizeMangleMap();
|
|
3332
|
-
|
|
3367
|
+
const injectedMangleMap = manglingEnabled ? state.mangleMap : {};
|
|
3368
|
+
let result = transformIndexHtml(html, injectedMangleMap, state.checksum, {
|
|
3333
3369
|
mode: options.production?.injectChecksum === false ? "script" : "script",
|
|
3334
3370
|
minify: process.env.NODE_ENV === "production",
|
|
3335
3371
|
varMangleMap: state.varMangleMap,
|
|
@@ -271,9 +271,14 @@ declare function hasInjectableTailwindCandidate(classes: Iterable<string>): bool
|
|
|
271
271
|
*
|
|
272
272
|
* @param ownedClassCount - number of csszyx-generated classes this build produced.
|
|
273
273
|
* @param sawTailwindEntry - whether any processed CSS imported tailwindcss.
|
|
274
|
+
* @param sawAnyCss - whether ANY CSS file passed through the transform hook. When
|
|
275
|
+
* false, csszyx never observed the CSS pipeline (e.g. `astro check`, an early
|
|
276
|
+
* Astro build phase, or CSS handled outside this hook) and cannot conclude the
|
|
277
|
+
* entry is missing — so it stays silent rather than false-positive on a build
|
|
278
|
+
* that does emit valid CSS.
|
|
274
279
|
* @returns true when the missing-entry warning should fire.
|
|
275
280
|
*/
|
|
276
|
-
declare function shouldWarnMissingTailwindEntry(ownedClassCount: number, sawTailwindEntry: boolean): boolean;
|
|
281
|
+
declare function shouldWarnMissingTailwindEntry(ownedClassCount: number, sawTailwindEntry: boolean, sawAnyCss: boolean): boolean;
|
|
277
282
|
/**
|
|
278
283
|
* Build the missing-Tailwind-entry warning message.
|
|
279
284
|
* @param ownedClassCount - number of csszyx-generated classes this build produced.
|
|
@@ -271,9 +271,14 @@ declare function hasInjectableTailwindCandidate(classes: Iterable<string>): bool
|
|
|
271
271
|
*
|
|
272
272
|
* @param ownedClassCount - number of csszyx-generated classes this build produced.
|
|
273
273
|
* @param sawTailwindEntry - whether any processed CSS imported tailwindcss.
|
|
274
|
+
* @param sawAnyCss - whether ANY CSS file passed through the transform hook. When
|
|
275
|
+
* false, csszyx never observed the CSS pipeline (e.g. `astro check`, an early
|
|
276
|
+
* Astro build phase, or CSS handled outside this hook) and cannot conclude the
|
|
277
|
+
* entry is missing — so it stays silent rather than false-positive on a build
|
|
278
|
+
* that does emit valid CSS.
|
|
274
279
|
* @returns true when the missing-entry warning should fire.
|
|
275
280
|
*/
|
|
276
|
-
declare function shouldWarnMissingTailwindEntry(ownedClassCount: number, sawTailwindEntry: boolean): boolean;
|
|
281
|
+
declare function shouldWarnMissingTailwindEntry(ownedClassCount: number, sawTailwindEntry: boolean, sawAnyCss: boolean): boolean;
|
|
277
282
|
/**
|
|
278
283
|
* Build the missing-Tailwind-entry warning message.
|
|
279
284
|
* @param ownedClassCount - number of csszyx-generated classes this build produced.
|
package/dist/vite.cjs
CHANGED
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
package/dist/webpack.cjs
CHANGED
package/dist/webpack.d.cts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/unplugin",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7",
|
|
4
4
|
"description": "Vite and Webpack integration for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
"postcss-value-parser": "^4.2.0",
|
|
118
118
|
"proper-lockfile": "^4.1.2",
|
|
119
119
|
"unplugin": "^1.10.1",
|
|
120
|
-
"@csszyx/compiler": "0.10.
|
|
121
|
-
"@csszyx/
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/vue-adapter": "0.10.
|
|
124
|
-
"@csszyx/types": "0.10.
|
|
120
|
+
"@csszyx/compiler": "0.10.7",
|
|
121
|
+
"@csszyx/svelte-adapter": "0.10.7",
|
|
122
|
+
"@csszyx/core": "0.10.7",
|
|
123
|
+
"@csszyx/vue-adapter": "0.10.7",
|
|
124
|
+
"@csszyx/types": "0.10.7"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.10.
|
|
127
|
+
"@csszyx/runtime": "^0.10.7"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@types/node": "^20.11.0",
|