@csszyx/unplugin 0.10.3 → 0.10.4
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 +4 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/{unplugin.ZUVKukQo.mjs → unplugin.BaRxZXyj.mjs} +72 -53
- package/dist/shared/{unplugin.C369_QDw.d.cts → unplugin.DzA2Mwc7.d.cts} +56 -40
- package/dist/shared/{unplugin.C369_QDw.d.mts → unplugin.DzA2Mwc7.d.mts} +56 -40
- package/dist/shared/{unplugin.B6W7JChH.cjs → unplugin.nVFTcBVL.cjs} +76 -56
- 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.nVFTcBVL.cjs');
|
|
7
7
|
const types = require('@csszyx/types');
|
|
8
8
|
require('postcss');
|
|
9
9
|
require('postcss-selector-parser');
|
|
@@ -44,13 +44,14 @@ exports.default = unplugin.unplugin;
|
|
|
44
44
|
exports.deleteRSCModuleRecord = unplugin.deleteRSCModuleRecord;
|
|
45
45
|
exports.esbuildPlugin = unplugin.esbuildPlugin;
|
|
46
46
|
exports.extractGlobalVarAliasesForManifest = unplugin.extractGlobalVarAliasesForManifest;
|
|
47
|
+
exports.fileMayContainSafelistableSz = unplugin.fileMayContainSafelistableSz;
|
|
47
48
|
exports.findRSCBoundaryViolation = unplugin.findRSCBoundaryViolation;
|
|
48
49
|
exports.findRSCGraphViolation = unplugin.findRSCGraphViolation;
|
|
49
50
|
exports.hasInjectableTailwindCandidate = unplugin.hasInjectableTailwindCandidate;
|
|
50
51
|
exports.hasTokens = unplugin.hasTokens;
|
|
51
52
|
exports.hasUseClientDirective = unplugin.hasUseClientDirective;
|
|
52
53
|
exports.hasUseServerDirective = unplugin.hasUseServerDirective;
|
|
53
|
-
exports.
|
|
54
|
+
exports.isCompileSourceOptedIn = unplugin.isCompileSourceOptedIn;
|
|
54
55
|
exports.isHardIgnoredPath = unplugin.isHardIgnoredPath;
|
|
55
56
|
exports.isMonorepoPackage = unplugin.isMonorepoPackage;
|
|
56
57
|
exports.isPackagesSkippedSource = unplugin.isPackagesSkippedSource;
|
|
@@ -63,7 +64,7 @@ exports.normalizeGlobalVarAliasesForCache = unplugin.normalizeGlobalVarAliasesFo
|
|
|
63
64
|
exports.parseThemeBlocks = unplugin.parseThemeBlocks;
|
|
64
65
|
exports.planGlobalVarAliases = unplugin.planGlobalVarAliases;
|
|
65
66
|
exports.readGlobalVarScanCache = unplugin.readGlobalVarScanCache;
|
|
66
|
-
exports.
|
|
67
|
+
exports.resolveCompileSourceDirs = unplugin.resolveCompileSourceDirs;
|
|
67
68
|
exports.resolveGlobalVarScanCacheDir = unplugin.resolveGlobalVarScanCacheDir;
|
|
68
69
|
exports.resolveNativeCacheIdentity = unplugin.resolveNativeCacheIdentity;
|
|
69
70
|
exports.rewriteGlobalVarCssAliases = unplugin.rewriteGlobalVarCssAliases;
|
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.DzA2Mwc7.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
|
|
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.DzA2Mwc7.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
|
|
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.DzA2Mwc7.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.DzA2Mwc7.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
|
|
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.BaRxZXyj.mjs';
|
|
3
3
|
export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES } from '@csszyx/types';
|
|
4
4
|
import 'postcss';
|
|
5
5
|
import 'postcss-selector-parser';
|
|
@@ -1692,79 +1692,77 @@ function shouldEmitWarning(quiet, devOnly, isProduction) {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
return true;
|
|
1694
1694
|
}
|
|
1695
|
-
function
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1698
|
-
return false;
|
|
1699
|
-
}
|
|
1700
|
-
return compilePackages.some((name) => path2.includes(`/packages/${name}/`));
|
|
1695
|
+
function normalizeForMatch(p) {
|
|
1696
|
+
const n = p.replace(/\\/g, "/");
|
|
1697
|
+
return n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
|
|
1701
1698
|
}
|
|
1702
|
-
function
|
|
1699
|
+
function resolveCompileSourceDirs(root, sources, realpathDir = (p) => {
|
|
1703
1700
|
try {
|
|
1704
|
-
|
|
1701
|
+
const real = fs.realpathSync(p);
|
|
1702
|
+
return fs.statSync(real).isDirectory() ? real : null;
|
|
1705
1703
|
} catch {
|
|
1706
|
-
return
|
|
1704
|
+
return null;
|
|
1707
1705
|
}
|
|
1708
1706
|
}) {
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
const
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
for (const name of [...pending]) {
|
|
1719
|
-
const candidate = path.join(dir, "packages", name);
|
|
1720
|
-
const key = candidate.replace(/\\/g, "/");
|
|
1721
|
-
if (key === normalizedRoot || key.startsWith(`${normalizedRoot}/`)) {
|
|
1722
|
-
continue;
|
|
1723
|
-
}
|
|
1724
|
-
if (dirExists(candidate)) {
|
|
1725
|
-
found.push(candidate);
|
|
1726
|
-
pending.delete(name);
|
|
1727
|
-
}
|
|
1707
|
+
const dirs = [];
|
|
1708
|
+
const missing = [];
|
|
1709
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1710
|
+
for (const entry of sources) {
|
|
1711
|
+
const abs = path.resolve(root, entry);
|
|
1712
|
+
const real = realpathDir(abs);
|
|
1713
|
+
if (!real) {
|
|
1714
|
+
missing.push(entry);
|
|
1715
|
+
continue;
|
|
1728
1716
|
}
|
|
1729
|
-
const
|
|
1730
|
-
if (
|
|
1731
|
-
|
|
1717
|
+
const key = normalizeForMatch(real);
|
|
1718
|
+
if (!seen.has(key)) {
|
|
1719
|
+
seen.add(key);
|
|
1720
|
+
dirs.push(key);
|
|
1732
1721
|
}
|
|
1733
|
-
dir = parent;
|
|
1734
1722
|
}
|
|
1735
|
-
return
|
|
1723
|
+
return { dirs, missing };
|
|
1724
|
+
}
|
|
1725
|
+
function isCompileSourceOptedIn(id, sourceDirs) {
|
|
1726
|
+
const p = normalizeForMatch(id);
|
|
1727
|
+
return sourceDirs.some((dir) => p === dir || p.startsWith(`${dir}/`));
|
|
1736
1728
|
}
|
|
1737
|
-
function isHardIgnoredPath(id,
|
|
1738
|
-
const
|
|
1739
|
-
if (
|
|
1729
|
+
function isHardIgnoredPath(id, sourceDirs = []) {
|
|
1730
|
+
const p = normalizeForMatch(id);
|
|
1731
|
+
if (isCompileSourceOptedIn(p, sourceDirs)) {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
if (p.includes("node_modules")) {
|
|
1740
1735
|
return true;
|
|
1741
1736
|
}
|
|
1742
|
-
if (
|
|
1737
|
+
if (p.includes(".next") && !p.includes("static")) {
|
|
1743
1738
|
return true;
|
|
1744
1739
|
}
|
|
1745
|
-
if (
|
|
1746
|
-
return
|
|
1740
|
+
if (p.includes("/packages/")) {
|
|
1741
|
+
return true;
|
|
1747
1742
|
}
|
|
1748
1743
|
return false;
|
|
1749
1744
|
}
|
|
1750
|
-
function
|
|
1751
|
-
|
|
1752
|
-
|
|
1745
|
+
function fileMayContainSafelistableSz(content) {
|
|
1746
|
+
return content.includes("sz=") || content.includes("sz:") || content.includes("szv(");
|
|
1747
|
+
}
|
|
1748
|
+
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
1749
|
+
const p = normalizeForMatch(id);
|
|
1750
|
+
if (p.includes("node_modules")) {
|
|
1753
1751
|
return false;
|
|
1754
1752
|
}
|
|
1755
|
-
if (
|
|
1753
|
+
if (p.includes(".next") && !p.includes("static")) {
|
|
1756
1754
|
return false;
|
|
1757
1755
|
}
|
|
1758
|
-
if (!
|
|
1756
|
+
if (!p.includes("/packages/")) {
|
|
1759
1757
|
return false;
|
|
1760
1758
|
}
|
|
1761
|
-
return !
|
|
1759
|
+
return !isCompileSourceOptedIn(p, sourceDirs);
|
|
1762
1760
|
}
|
|
1763
1761
|
function skippedSzFilesMessage(files) {
|
|
1764
1762
|
const list = files.map((file) => ` - ${file}`).join("\n");
|
|
1765
1763
|
return `[csszyx] ${files.length} file(s) under packages/ contain \`sz\` but were skipped by ignore rules:
|
|
1766
1764
|
${list}
|
|
1767
|
-
Add the package to \`
|
|
1765
|
+
Add the package directory to \`compileSources\` (or move the file out of packages/) \u2014 otherwise their \`sz\` produces no CSS.`;
|
|
1768
1766
|
}
|
|
1769
1767
|
function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
|
|
1770
1768
|
const safelistPath = path.join(rootDir, safelistFilename).replace(/\\/g, "/");
|
|
@@ -2398,7 +2396,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2398
2396
|
"[csszyx] Transform cache disabled because package versions could not be resolved."
|
|
2399
2397
|
);
|
|
2400
2398
|
}
|
|
2401
|
-
const
|
|
2399
|
+
const compileSources = options.compileSources ?? [];
|
|
2402
2400
|
const quiet = options.quiet === true;
|
|
2403
2401
|
function emitWarning(message, opts = {}) {
|
|
2404
2402
|
if (shouldEmitWarning(quiet, opts.devOnly ?? false, process.env.NODE_ENV === "production")) {
|
|
@@ -2480,8 +2478,24 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2480
2478
|
assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
|
|
2481
2479
|
return result;
|
|
2482
2480
|
}
|
|
2481
|
+
let compileSourceDirs = [];
|
|
2482
|
+
let compileSourceDirsRoot = null;
|
|
2483
|
+
function refreshCompileSourceDirs() {
|
|
2484
|
+
if (compileSources.length === 0 || compileSourceDirsRoot === state.rootDir) {
|
|
2485
|
+
return;
|
|
2486
|
+
}
|
|
2487
|
+
compileSourceDirsRoot = state.rootDir;
|
|
2488
|
+
const { dirs, missing } = resolveCompileSourceDirs(state.rootDir, compileSources);
|
|
2489
|
+
compileSourceDirs = dirs;
|
|
2490
|
+
if (missing.length > 0) {
|
|
2491
|
+
emitWarning(
|
|
2492
|
+
`[csszyx] compileSources: ${missing.length} path(s) did not resolve to a directory (relative to ${state.rootDir}): ${missing.join(", ")}. Their \`sz\`/\`szv\` will not be compiled or safelisted.`
|
|
2493
|
+
);
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2483
2496
|
function isHardIgnored(id) {
|
|
2484
|
-
|
|
2497
|
+
refreshCompileSourceDirs();
|
|
2498
|
+
return isHardIgnoredPath(id, compileSourceDirs);
|
|
2485
2499
|
}
|
|
2486
2500
|
function shouldProcessSource(id) {
|
|
2487
2501
|
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.[tj]sx?(\?.*)?$/.test(id) || id.endsWith(".vue") || id.endsWith(".svelte"));
|
|
@@ -2720,7 +2734,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2720
2734
|
}
|
|
2721
2735
|
}
|
|
2722
2736
|
function recordPackagesSkipIfSz(filePath) {
|
|
2723
|
-
if (!isPackagesSkippedSource(filePath,
|
|
2737
|
+
if (!isPackagesSkippedSource(filePath, compileSourceDirs)) {
|
|
2724
2738
|
return;
|
|
2725
2739
|
}
|
|
2726
2740
|
let content;
|
|
@@ -2734,6 +2748,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2734
2748
|
}
|
|
2735
2749
|
}
|
|
2736
2750
|
function prescanAndWriteClasses() {
|
|
2751
|
+
refreshCompileSourceDirs();
|
|
2737
2752
|
const prescanStarted = performance.now();
|
|
2738
2753
|
const discoveredClasses = /* @__PURE__ */ new Set();
|
|
2739
2754
|
const rawDiscoveredClasses = /* @__PURE__ */ new Set();
|
|
@@ -2762,7 +2777,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2762
2777
|
} catch {
|
|
2763
2778
|
continue;
|
|
2764
2779
|
}
|
|
2765
|
-
if (!
|
|
2780
|
+
if (!fileMayContainSafelistableSz(content)) {
|
|
2766
2781
|
continue;
|
|
2767
2782
|
}
|
|
2768
2783
|
prescanSources.push({ filePath, content });
|
|
@@ -2770,8 +2785,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2770
2785
|
}
|
|
2771
2786
|
}
|
|
2772
2787
|
scanDir(state.rootDir);
|
|
2773
|
-
|
|
2774
|
-
|
|
2788
|
+
const normRoot = normalizeForMatch(state.rootDir);
|
|
2789
|
+
for (const sourceDir of compileSourceDirs) {
|
|
2790
|
+
if (sourceDir === normRoot || sourceDir.startsWith(`${normRoot}/`)) {
|
|
2791
|
+
continue;
|
|
2792
|
+
}
|
|
2793
|
+
scanDir(sourceDir);
|
|
2775
2794
|
}
|
|
2776
2795
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2777
2796
|
if (!result.transformed) {
|
|
@@ -3626,4 +3645,4 @@ const esbuildPlugin = (options = {}) => {
|
|
|
3626
3645
|
};
|
|
3627
3646
|
};
|
|
3628
3647
|
|
|
3629
|
-
export {
|
|
3648
|
+
export { isTailwindReservedGlobalVar as A, mangleCodeClassesSync as B, mergeThemes as C, missingTailwindEntryMessage as D, normalizeGlobalVarAliasesForCache as E, parseThemeBlocks as F, planGlobalVarAliases as G, readGlobalVarScanCache as H, resolveCompileSourceDirs as I, resolveGlobalVarScanCacheDir as J, resolveNativeCacheIdentity as K, rewriteGlobalVarCssAliases as L, rollupPlugin as M, scanGlobalVarCss as N, shouldEmitWarning as O, shouldWarnMissingTailwindEntry as P, shouldWarnUnscopedMonorepo as Q, skippedSzFilesMessage as R, unscopedMonorepoMessage as S, validateGlobalVarAliasInputs as T, vitePlugin as U, webpackPlugin as V, writeGlobalVarScanCache as W, appendTailwindSourceDirective as a, assertNoRSCBoundaryViolation as b, assertNoRSCGraphViolation as c, computeSafelistRelPath as d, createGlobalVarAliasValidationOptions as e, createGlobalVarMapAssetSource as f, createGlobalVarScanCacheKey as g, createRSCModuleRecord as h, cssHasContentScope as i, cssImportsTailwind as j, deleteRSCModuleRecord as k, esbuildPlugin as l, extractGlobalVarAliasesForManifest as m, fileMayContainSafelistableSz as n, findRSCBoundaryViolation as o, findRSCGraphViolation as p, hasInjectableTailwindCandidate as q, hasTokens as r, hasUseClientDirective as s, hasUseServerDirective as t, unplugin as u, isCompileSourceOptedIn as v, isHardIgnoredPath as w, isMonorepoPackage as x, isPackagesSkippedSource as y, isRSCServerModule as z };
|
|
@@ -334,64 +334,80 @@ declare function unscopedMonorepoMessage(): string;
|
|
|
334
334
|
*/
|
|
335
335
|
declare function shouldEmitWarning(quiet: boolean, devOnly: boolean, isProduction: boolean): boolean;
|
|
336
336
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* `
|
|
340
|
-
*
|
|
337
|
+
* Resolve `compileSources` entries to absolute, realpath-resolved directories.
|
|
338
|
+
* Each entry resolves like a Vite config path: relative to the project `root`
|
|
339
|
+
* (`config.root`), absolute passes through. The result is realpath-resolved so a
|
|
340
|
+
* pnpm-symlinked workspace package matches Vite's (realpath'd, since
|
|
341
|
+
* `resolve.preserveSymlinks` defaults to false) module ids. Done ONCE at
|
|
342
|
+
* config-resolved time; the per-module matcher then does pure prefix tests.
|
|
341
343
|
*
|
|
342
|
-
* @param
|
|
343
|
-
* @param
|
|
344
|
-
* @
|
|
344
|
+
* @param root - the resolved project root (Vite `config.root` / build cwd).
|
|
345
|
+
* @param sources - the configured `compileSources` paths (relative or absolute).
|
|
346
|
+
* @param realpathDir - injectable resolver → realpath if it is an existing
|
|
347
|
+
* directory, else `null` (defaults to a real fs realpath + stat).
|
|
348
|
+
* @returns `dirs` (existing, deduped, normalized) and `missing` (entries that did
|
|
349
|
+
* not resolve to a directory) for a build warning.
|
|
345
350
|
*/
|
|
346
|
-
declare function
|
|
351
|
+
declare function resolveCompileSourceDirs(root: string, sources: readonly string[], realpathDir?: (p: string) => string | null): {
|
|
352
|
+
dirs: string[];
|
|
353
|
+
missing: string[];
|
|
354
|
+
};
|
|
347
355
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* is never scanned and its classes never reach the safelist — the per-module
|
|
352
|
-
* transform compiles those files when imported but runs after the safelist is
|
|
353
|
-
* written. Walk up from `rootDir` looking for an ancestor that has
|
|
354
|
-
* `packages/<name>`; that mirrors the `/packages/<name>/` segment the opt-in
|
|
355
|
-
* matches. A directory already inside `rootDir` is skipped — the rootDir walk
|
|
356
|
-
* already covers it. Returns only existing directories; unresolved names are
|
|
357
|
-
* silently ignored (a typo surfaces as the usual skipped-`sz` warning).
|
|
356
|
+
* Whether `id` lives under one of the resolved `compileSources` directories.
|
|
357
|
+
* Pure prefix match on normalized absolute paths — no fs (the fs work was done
|
|
358
|
+
* once in {@link resolveCompileSourceDirs}).
|
|
358
359
|
*
|
|
359
|
-
* @param
|
|
360
|
-
* @param
|
|
361
|
-
* @
|
|
362
|
-
* @returns absolute, deduplicated package directories outside `rootDir`.
|
|
360
|
+
* @param id - bundler file id or filesystem path.
|
|
361
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
362
|
+
* @returns true when the file is in an opted-in source directory.
|
|
363
363
|
*/
|
|
364
|
-
declare function
|
|
364
|
+
declare function isCompileSourceOptedIn(id: string, sourceDirs: readonly string[]): boolean;
|
|
365
365
|
/**
|
|
366
|
-
* Whether a file lives in a
|
|
366
|
+
* Whether a file lives in a directory csszyx never transforms.
|
|
367
367
|
*
|
|
368
|
-
* `
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* (
|
|
368
|
+
* An explicitly opted-in `compileSources` path wins over every default ignore —
|
|
369
|
+
* the developer named the exact directory and takes responsibility for it. Then
|
|
370
|
+
* `node_modules`, `.next` (non-static), and `/packages/` are ignored by default
|
|
371
|
+
* (published libraries ship pre-extracted CSS). Pure so the precedence
|
|
372
|
+
* (opt-in > the default ignores) is unit-tested.
|
|
373
373
|
*
|
|
374
374
|
* @param id - bundler file id or filesystem path.
|
|
375
|
-
* @param
|
|
375
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
376
376
|
* @returns true when the file should be skipped regardless of user filters.
|
|
377
377
|
*/
|
|
378
|
-
declare function isHardIgnoredPath(id: string,
|
|
378
|
+
declare function isHardIgnoredPath(id: string, sourceDirs?: readonly string[]): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Whether a file's text may contain csszyx classes the prescan should extract
|
|
381
|
+
* into the safelist. The prescan reads files instead of parsing every one, so it
|
|
382
|
+
* needs a cheap text proxy for "worth transforming". A `sz=` / `sz:` prop is the
|
|
383
|
+
* obvious case, but a `szv(...)` declaration ALSO produces safelistable classes
|
|
384
|
+
* (the compiler extracts every variant from the config), and a layout component
|
|
385
|
+
* built as a prop API resolves szv via `_sz(...)` with NO `sz=` in the file — so
|
|
386
|
+
* gating on `sz` alone left those variants unsafelisted (silent dead classes).
|
|
387
|
+
* `szv(` is a precise, csszyx-owned token, so including it costs at most an extra
|
|
388
|
+
* file transform (the prescan is fail-open: when in doubt, scan).
|
|
389
|
+
*
|
|
390
|
+
* @param content - The source file text.
|
|
391
|
+
* @returns true when the file should be prescanned for safelist extraction.
|
|
392
|
+
*/
|
|
393
|
+
declare function fileMayContainSafelistableSz(content: string): boolean;
|
|
379
394
|
/**
|
|
380
395
|
* Whether a file is workspace-package source that csszyx skipped only because it
|
|
381
|
-
* lives under `/packages/` and
|
|
382
|
-
* surface the silent no-op (skipped `sz` produces no CSS).
|
|
383
|
-
* `.next` are excluded — those are never workspace source the
|
|
384
|
-
* and scanning `node_modules` for `sz` would be slow and
|
|
396
|
+
* lives under `/packages/` and is not under any opted-in `compileSources`
|
|
397
|
+
* directory. Used to surface the silent no-op (skipped `sz` produces no CSS).
|
|
398
|
+
* `node_modules` and `.next` are excluded — those are never workspace source the
|
|
399
|
+
* developer authors, and scanning `node_modules` for `sz` would be slow and
|
|
400
|
+
* false-positive-prone.
|
|
385
401
|
*
|
|
386
402
|
* @param id - filesystem path of the skipped file.
|
|
387
|
-
* @param
|
|
403
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
388
404
|
* @returns true when the skip is a workspace-package `sz` skip worth warning on.
|
|
389
405
|
*/
|
|
390
|
-
declare function isPackagesSkippedSource(id: string,
|
|
406
|
+
declare function isPackagesSkippedSource(id: string, sourceDirs?: readonly string[]): boolean;
|
|
391
407
|
/**
|
|
392
408
|
* Build the workspace-package skip warning. Lists the skipped files that contain
|
|
393
|
-
* `sz` so the developer can
|
|
394
|
-
* silently shipping no CSS for them.
|
|
409
|
+
* `sz` so the developer can add the package directory to `compileSources`
|
|
410
|
+
* instead of silently shipping no CSS for them.
|
|
395
411
|
*
|
|
396
412
|
* @param files - skipped `/packages/` file paths that contain `sz`.
|
|
397
413
|
* @returns the warning string.
|
|
@@ -483,5 +499,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
483
499
|
*/
|
|
484
500
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
485
501
|
|
|
486
|
-
export {
|
|
502
|
+
export { isMonorepoPackage as A, isPackagesSkippedSource as B, mangleCodeClassesSync as D, missingTailwindEntryMessage as E, normalizeGlobalVarAliasesForCache as F, resolveCompileSourceDirs as H, resolveNativeCacheIdentity as I, rollupPlugin as J, shouldEmitWarning as K, shouldWarnMissingTailwindEntry as L, shouldWarnUnscopedMonorepo as M, skippedSzFilesMessage as N, unscopedMonorepoMessage as O, vitePlugin as Q, webpackPlugin as T, appendTailwindSourceDirective as o, computeSafelistRelPath as p, createGlobalVarMapAssetSource as q, cssHasContentScope as r, cssImportsTailwind as s, esbuildPlugin as t, unplugin as u, extractGlobalVarAliasesForManifest as v, fileMayContainSafelistableSz as w, hasInjectableTailwindCandidate as x, isCompileSourceOptedIn as y, isHardIgnoredPath as z };
|
|
487
503
|
export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n };
|
|
@@ -334,64 +334,80 @@ declare function unscopedMonorepoMessage(): string;
|
|
|
334
334
|
*/
|
|
335
335
|
declare function shouldEmitWarning(quiet: boolean, devOnly: boolean, isProduction: boolean): boolean;
|
|
336
336
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* `
|
|
340
|
-
*
|
|
337
|
+
* Resolve `compileSources` entries to absolute, realpath-resolved directories.
|
|
338
|
+
* Each entry resolves like a Vite config path: relative to the project `root`
|
|
339
|
+
* (`config.root`), absolute passes through. The result is realpath-resolved so a
|
|
340
|
+
* pnpm-symlinked workspace package matches Vite's (realpath'd, since
|
|
341
|
+
* `resolve.preserveSymlinks` defaults to false) module ids. Done ONCE at
|
|
342
|
+
* config-resolved time; the per-module matcher then does pure prefix tests.
|
|
341
343
|
*
|
|
342
|
-
* @param
|
|
343
|
-
* @param
|
|
344
|
-
* @
|
|
344
|
+
* @param root - the resolved project root (Vite `config.root` / build cwd).
|
|
345
|
+
* @param sources - the configured `compileSources` paths (relative or absolute).
|
|
346
|
+
* @param realpathDir - injectable resolver → realpath if it is an existing
|
|
347
|
+
* directory, else `null` (defaults to a real fs realpath + stat).
|
|
348
|
+
* @returns `dirs` (existing, deduped, normalized) and `missing` (entries that did
|
|
349
|
+
* not resolve to a directory) for a build warning.
|
|
345
350
|
*/
|
|
346
|
-
declare function
|
|
351
|
+
declare function resolveCompileSourceDirs(root: string, sources: readonly string[], realpathDir?: (p: string) => string | null): {
|
|
352
|
+
dirs: string[];
|
|
353
|
+
missing: string[];
|
|
354
|
+
};
|
|
347
355
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* is never scanned and its classes never reach the safelist — the per-module
|
|
352
|
-
* transform compiles those files when imported but runs after the safelist is
|
|
353
|
-
* written. Walk up from `rootDir` looking for an ancestor that has
|
|
354
|
-
* `packages/<name>`; that mirrors the `/packages/<name>/` segment the opt-in
|
|
355
|
-
* matches. A directory already inside `rootDir` is skipped — the rootDir walk
|
|
356
|
-
* already covers it. Returns only existing directories; unresolved names are
|
|
357
|
-
* silently ignored (a typo surfaces as the usual skipped-`sz` warning).
|
|
356
|
+
* Whether `id` lives under one of the resolved `compileSources` directories.
|
|
357
|
+
* Pure prefix match on normalized absolute paths — no fs (the fs work was done
|
|
358
|
+
* once in {@link resolveCompileSourceDirs}).
|
|
358
359
|
*
|
|
359
|
-
* @param
|
|
360
|
-
* @param
|
|
361
|
-
* @
|
|
362
|
-
* @returns absolute, deduplicated package directories outside `rootDir`.
|
|
360
|
+
* @param id - bundler file id or filesystem path.
|
|
361
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
362
|
+
* @returns true when the file is in an opted-in source directory.
|
|
363
363
|
*/
|
|
364
|
-
declare function
|
|
364
|
+
declare function isCompileSourceOptedIn(id: string, sourceDirs: readonly string[]): boolean;
|
|
365
365
|
/**
|
|
366
|
-
* Whether a file lives in a
|
|
366
|
+
* Whether a file lives in a directory csszyx never transforms.
|
|
367
367
|
*
|
|
368
|
-
* `
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* (
|
|
368
|
+
* An explicitly opted-in `compileSources` path wins over every default ignore —
|
|
369
|
+
* the developer named the exact directory and takes responsibility for it. Then
|
|
370
|
+
* `node_modules`, `.next` (non-static), and `/packages/` are ignored by default
|
|
371
|
+
* (published libraries ship pre-extracted CSS). Pure so the precedence
|
|
372
|
+
* (opt-in > the default ignores) is unit-tested.
|
|
373
373
|
*
|
|
374
374
|
* @param id - bundler file id or filesystem path.
|
|
375
|
-
* @param
|
|
375
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
376
376
|
* @returns true when the file should be skipped regardless of user filters.
|
|
377
377
|
*/
|
|
378
|
-
declare function isHardIgnoredPath(id: string,
|
|
378
|
+
declare function isHardIgnoredPath(id: string, sourceDirs?: readonly string[]): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Whether a file's text may contain csszyx classes the prescan should extract
|
|
381
|
+
* into the safelist. The prescan reads files instead of parsing every one, so it
|
|
382
|
+
* needs a cheap text proxy for "worth transforming". A `sz=` / `sz:` prop is the
|
|
383
|
+
* obvious case, but a `szv(...)` declaration ALSO produces safelistable classes
|
|
384
|
+
* (the compiler extracts every variant from the config), and a layout component
|
|
385
|
+
* built as a prop API resolves szv via `_sz(...)` with NO `sz=` in the file — so
|
|
386
|
+
* gating on `sz` alone left those variants unsafelisted (silent dead classes).
|
|
387
|
+
* `szv(` is a precise, csszyx-owned token, so including it costs at most an extra
|
|
388
|
+
* file transform (the prescan is fail-open: when in doubt, scan).
|
|
389
|
+
*
|
|
390
|
+
* @param content - The source file text.
|
|
391
|
+
* @returns true when the file should be prescanned for safelist extraction.
|
|
392
|
+
*/
|
|
393
|
+
declare function fileMayContainSafelistableSz(content: string): boolean;
|
|
379
394
|
/**
|
|
380
395
|
* Whether a file is workspace-package source that csszyx skipped only because it
|
|
381
|
-
* lives under `/packages/` and
|
|
382
|
-
* surface the silent no-op (skipped `sz` produces no CSS).
|
|
383
|
-
* `.next` are excluded — those are never workspace source the
|
|
384
|
-
* and scanning `node_modules` for `sz` would be slow and
|
|
396
|
+
* lives under `/packages/` and is not under any opted-in `compileSources`
|
|
397
|
+
* directory. Used to surface the silent no-op (skipped `sz` produces no CSS).
|
|
398
|
+
* `node_modules` and `.next` are excluded — those are never workspace source the
|
|
399
|
+
* developer authors, and scanning `node_modules` for `sz` would be slow and
|
|
400
|
+
* false-positive-prone.
|
|
385
401
|
*
|
|
386
402
|
* @param id - filesystem path of the skipped file.
|
|
387
|
-
* @param
|
|
403
|
+
* @param sourceDirs - resolved, normalized `compileSources` directories.
|
|
388
404
|
* @returns true when the skip is a workspace-package `sz` skip worth warning on.
|
|
389
405
|
*/
|
|
390
|
-
declare function isPackagesSkippedSource(id: string,
|
|
406
|
+
declare function isPackagesSkippedSource(id: string, sourceDirs?: readonly string[]): boolean;
|
|
391
407
|
/**
|
|
392
408
|
* Build the workspace-package skip warning. Lists the skipped files that contain
|
|
393
|
-
* `sz` so the developer can
|
|
394
|
-
* silently shipping no CSS for them.
|
|
409
|
+
* `sz` so the developer can add the package directory to `compileSources`
|
|
410
|
+
* instead of silently shipping no CSS for them.
|
|
395
411
|
*
|
|
396
412
|
* @param files - skipped `/packages/` file paths that contain `sz`.
|
|
397
413
|
* @returns the warning string.
|
|
@@ -483,5 +499,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
483
499
|
*/
|
|
484
500
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
485
501
|
|
|
486
|
-
export {
|
|
502
|
+
export { isMonorepoPackage as A, isPackagesSkippedSource as B, mangleCodeClassesSync as D, missingTailwindEntryMessage as E, normalizeGlobalVarAliasesForCache as F, resolveCompileSourceDirs as H, resolveNativeCacheIdentity as I, rollupPlugin as J, shouldEmitWarning as K, shouldWarnMissingTailwindEntry as L, shouldWarnUnscopedMonorepo as M, skippedSzFilesMessage as N, unscopedMonorepoMessage as O, vitePlugin as Q, webpackPlugin as T, appendTailwindSourceDirective as o, computeSafelistRelPath as p, createGlobalVarMapAssetSource as q, cssHasContentScope as r, cssImportsTailwind as s, esbuildPlugin as t, unplugin as u, extractGlobalVarAliasesForManifest as v, fileMayContainSafelistableSz as w, hasInjectableTailwindCandidate as x, isCompileSourceOptedIn as y, isHardIgnoredPath as z };
|
|
487
503
|
export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n };
|
|
@@ -1594,9 +1594,9 @@ const RUNTIME_HELPER_IMPORT_RE = {
|
|
|
1594
1594
|
};
|
|
1595
1595
|
let _hasWarnedTsConfig = false;
|
|
1596
1596
|
let _hasWarnedTransformCacheVersion = false;
|
|
1597
|
-
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.
|
|
1597
|
+
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.nVFTcBVL.cjs', document.baseURI).href)));
|
|
1598
1598
|
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.
|
|
1599
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.nVFTcBVL.cjs', document.baseURI).href))),
|
|
1600
1600
|
UNKNOWN_PACKAGE_VERSION
|
|
1601
1601
|
);
|
|
1602
1602
|
const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
|
|
@@ -1712,79 +1712,77 @@ function shouldEmitWarning(quiet, devOnly, isProduction) {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
return true;
|
|
1714
1714
|
}
|
|
1715
|
-
function
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
return false;
|
|
1719
|
-
}
|
|
1720
|
-
return compilePackages.some((name) => path2.includes(`/packages/${name}/`));
|
|
1715
|
+
function normalizeForMatch(p) {
|
|
1716
|
+
const n = p.replace(/\\/g, "/");
|
|
1717
|
+
return n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
|
|
1721
1718
|
}
|
|
1722
|
-
function
|
|
1719
|
+
function resolveCompileSourceDirs(root, sources, realpathDir = (p) => {
|
|
1723
1720
|
try {
|
|
1724
|
-
|
|
1721
|
+
const real = fs__namespace.realpathSync(p);
|
|
1722
|
+
return fs__namespace.statSync(real).isDirectory() ? real : null;
|
|
1725
1723
|
} catch {
|
|
1726
|
-
return
|
|
1724
|
+
return null;
|
|
1727
1725
|
}
|
|
1728
1726
|
}) {
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
for (const name of [...pending]) {
|
|
1739
|
-
const candidate = path__namespace.join(dir, "packages", name);
|
|
1740
|
-
const key = candidate.replace(/\\/g, "/");
|
|
1741
|
-
if (key === normalizedRoot || key.startsWith(`${normalizedRoot}/`)) {
|
|
1742
|
-
continue;
|
|
1743
|
-
}
|
|
1744
|
-
if (dirExists(candidate)) {
|
|
1745
|
-
found.push(candidate);
|
|
1746
|
-
pending.delete(name);
|
|
1747
|
-
}
|
|
1727
|
+
const dirs = [];
|
|
1728
|
+
const missing = [];
|
|
1729
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1730
|
+
for (const entry of sources) {
|
|
1731
|
+
const abs = path__namespace.resolve(root, entry);
|
|
1732
|
+
const real = realpathDir(abs);
|
|
1733
|
+
if (!real) {
|
|
1734
|
+
missing.push(entry);
|
|
1735
|
+
continue;
|
|
1748
1736
|
}
|
|
1749
|
-
const
|
|
1750
|
-
if (
|
|
1751
|
-
|
|
1737
|
+
const key = normalizeForMatch(real);
|
|
1738
|
+
if (!seen.has(key)) {
|
|
1739
|
+
seen.add(key);
|
|
1740
|
+
dirs.push(key);
|
|
1752
1741
|
}
|
|
1753
|
-
dir = parent;
|
|
1754
1742
|
}
|
|
1755
|
-
return
|
|
1743
|
+
return { dirs, missing };
|
|
1744
|
+
}
|
|
1745
|
+
function isCompileSourceOptedIn(id, sourceDirs) {
|
|
1746
|
+
const p = normalizeForMatch(id);
|
|
1747
|
+
return sourceDirs.some((dir) => p === dir || p.startsWith(`${dir}/`));
|
|
1756
1748
|
}
|
|
1757
|
-
function isHardIgnoredPath(id,
|
|
1758
|
-
const
|
|
1759
|
-
if (
|
|
1749
|
+
function isHardIgnoredPath(id, sourceDirs = []) {
|
|
1750
|
+
const p = normalizeForMatch(id);
|
|
1751
|
+
if (isCompileSourceOptedIn(p, sourceDirs)) {
|
|
1752
|
+
return false;
|
|
1753
|
+
}
|
|
1754
|
+
if (p.includes("node_modules")) {
|
|
1760
1755
|
return true;
|
|
1761
1756
|
}
|
|
1762
|
-
if (
|
|
1757
|
+
if (p.includes(".next") && !p.includes("static")) {
|
|
1763
1758
|
return true;
|
|
1764
1759
|
}
|
|
1765
|
-
if (
|
|
1766
|
-
return
|
|
1760
|
+
if (p.includes("/packages/")) {
|
|
1761
|
+
return true;
|
|
1767
1762
|
}
|
|
1768
1763
|
return false;
|
|
1769
1764
|
}
|
|
1770
|
-
function
|
|
1771
|
-
|
|
1772
|
-
|
|
1765
|
+
function fileMayContainSafelistableSz(content) {
|
|
1766
|
+
return content.includes("sz=") || content.includes("sz:") || content.includes("szv(");
|
|
1767
|
+
}
|
|
1768
|
+
function isPackagesSkippedSource(id, sourceDirs = []) {
|
|
1769
|
+
const p = normalizeForMatch(id);
|
|
1770
|
+
if (p.includes("node_modules")) {
|
|
1773
1771
|
return false;
|
|
1774
1772
|
}
|
|
1775
|
-
if (
|
|
1773
|
+
if (p.includes(".next") && !p.includes("static")) {
|
|
1776
1774
|
return false;
|
|
1777
1775
|
}
|
|
1778
|
-
if (!
|
|
1776
|
+
if (!p.includes("/packages/")) {
|
|
1779
1777
|
return false;
|
|
1780
1778
|
}
|
|
1781
|
-
return !
|
|
1779
|
+
return !isCompileSourceOptedIn(p, sourceDirs);
|
|
1782
1780
|
}
|
|
1783
1781
|
function skippedSzFilesMessage(files) {
|
|
1784
1782
|
const list = files.map((file) => ` - ${file}`).join("\n");
|
|
1785
1783
|
return `[csszyx] ${files.length} file(s) under packages/ contain \`sz\` but were skipped by ignore rules:
|
|
1786
1784
|
${list}
|
|
1787
|
-
Add the package to \`
|
|
1785
|
+
Add the package directory to \`compileSources\` (or move the file out of packages/) \u2014 otherwise their \`sz\` produces no CSS.`;
|
|
1788
1786
|
}
|
|
1789
1787
|
function computeSafelistRelPath(rootDir, safelistFilename, cssId) {
|
|
1790
1788
|
const safelistPath = path__namespace.join(rootDir, safelistFilename).replace(/\\/g, "/");
|
|
@@ -2418,7 +2416,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2418
2416
|
"[csszyx] Transform cache disabled because package versions could not be resolved."
|
|
2419
2417
|
);
|
|
2420
2418
|
}
|
|
2421
|
-
const
|
|
2419
|
+
const compileSources = options.compileSources ?? [];
|
|
2422
2420
|
const quiet = options.quiet === true;
|
|
2423
2421
|
function emitWarning(message, opts = {}) {
|
|
2424
2422
|
if (shouldEmitWarning(quiet, opts.devOnly ?? false, process.env.NODE_ENV === "production")) {
|
|
@@ -2500,8 +2498,24 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2500
2498
|
assertGlobalVarPlanMatchesEarlyAliases(result, earlyGlobalVarAliasEntries);
|
|
2501
2499
|
return result;
|
|
2502
2500
|
}
|
|
2501
|
+
let compileSourceDirs = [];
|
|
2502
|
+
let compileSourceDirsRoot = null;
|
|
2503
|
+
function refreshCompileSourceDirs() {
|
|
2504
|
+
if (compileSources.length === 0 || compileSourceDirsRoot === state.rootDir) {
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
compileSourceDirsRoot = state.rootDir;
|
|
2508
|
+
const { dirs, missing } = resolveCompileSourceDirs(state.rootDir, compileSources);
|
|
2509
|
+
compileSourceDirs = dirs;
|
|
2510
|
+
if (missing.length > 0) {
|
|
2511
|
+
emitWarning(
|
|
2512
|
+
`[csszyx] compileSources: ${missing.length} path(s) did not resolve to a directory (relative to ${state.rootDir}): ${missing.join(", ")}. Their \`sz\`/\`szv\` will not be compiled or safelisted.`
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2503
2516
|
function isHardIgnored(id) {
|
|
2504
|
-
|
|
2517
|
+
refreshCompileSourceDirs();
|
|
2518
|
+
return isHardIgnoredPath(id, compileSourceDirs);
|
|
2505
2519
|
}
|
|
2506
2520
|
function shouldProcessSource(id) {
|
|
2507
2521
|
return !isHardIgnored(id) && !isUserExcluded(id) && isUserIncluded(id) && (/\.[tj]sx?(\?.*)?$/.test(id) || id.endsWith(".vue") || id.endsWith(".svelte"));
|
|
@@ -2740,7 +2754,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2740
2754
|
}
|
|
2741
2755
|
}
|
|
2742
2756
|
function recordPackagesSkipIfSz(filePath) {
|
|
2743
|
-
if (!isPackagesSkippedSource(filePath,
|
|
2757
|
+
if (!isPackagesSkippedSource(filePath, compileSourceDirs)) {
|
|
2744
2758
|
return;
|
|
2745
2759
|
}
|
|
2746
2760
|
let content;
|
|
@@ -2754,6 +2768,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2754
2768
|
}
|
|
2755
2769
|
}
|
|
2756
2770
|
function prescanAndWriteClasses() {
|
|
2771
|
+
refreshCompileSourceDirs();
|
|
2757
2772
|
const prescanStarted = node_perf_hooks.performance.now();
|
|
2758
2773
|
const discoveredClasses = /* @__PURE__ */ new Set();
|
|
2759
2774
|
const rawDiscoveredClasses = /* @__PURE__ */ new Set();
|
|
@@ -2782,7 +2797,7 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2782
2797
|
} catch {
|
|
2783
2798
|
continue;
|
|
2784
2799
|
}
|
|
2785
|
-
if (!
|
|
2800
|
+
if (!fileMayContainSafelistableSz(content)) {
|
|
2786
2801
|
continue;
|
|
2787
2802
|
}
|
|
2788
2803
|
prescanSources.push({ filePath, content });
|
|
@@ -2790,8 +2805,12 @@ function createCsszyxPlugins(options = {}) {
|
|
|
2790
2805
|
}
|
|
2791
2806
|
}
|
|
2792
2807
|
scanDir(state.rootDir);
|
|
2793
|
-
|
|
2794
|
-
|
|
2808
|
+
const normRoot = normalizeForMatch(state.rootDir);
|
|
2809
|
+
for (const sourceDir of compileSourceDirs) {
|
|
2810
|
+
if (sourceDir === normRoot || sourceDir.startsWith(`${normRoot}/`)) {
|
|
2811
|
+
continue;
|
|
2812
|
+
}
|
|
2813
|
+
scanDir(sourceDir);
|
|
2795
2814
|
}
|
|
2796
2815
|
for (const { filePath, result } of transformPrescanSources(prescanSources)) {
|
|
2797
2816
|
if (!result.transformed) {
|
|
@@ -3659,13 +3678,14 @@ exports.cssImportsTailwind = cssImportsTailwind;
|
|
|
3659
3678
|
exports.deleteRSCModuleRecord = deleteRSCModuleRecord;
|
|
3660
3679
|
exports.esbuildPlugin = esbuildPlugin;
|
|
3661
3680
|
exports.extractGlobalVarAliasesForManifest = extractGlobalVarAliasesForManifest;
|
|
3681
|
+
exports.fileMayContainSafelistableSz = fileMayContainSafelistableSz;
|
|
3662
3682
|
exports.findRSCBoundaryViolation = findRSCBoundaryViolation;
|
|
3663
3683
|
exports.findRSCGraphViolation = findRSCGraphViolation;
|
|
3664
3684
|
exports.hasInjectableTailwindCandidate = hasInjectableTailwindCandidate;
|
|
3665
3685
|
exports.hasTokens = hasTokens;
|
|
3666
3686
|
exports.hasUseClientDirective = hasUseClientDirective;
|
|
3667
3687
|
exports.hasUseServerDirective = hasUseServerDirective;
|
|
3668
|
-
exports.
|
|
3688
|
+
exports.isCompileSourceOptedIn = isCompileSourceOptedIn;
|
|
3669
3689
|
exports.isHardIgnoredPath = isHardIgnoredPath;
|
|
3670
3690
|
exports.isMonorepoPackage = isMonorepoPackage;
|
|
3671
3691
|
exports.isPackagesSkippedSource = isPackagesSkippedSource;
|
|
@@ -3678,7 +3698,7 @@ exports.normalizeGlobalVarAliasesForCache = normalizeGlobalVarAliasesForCache;
|
|
|
3678
3698
|
exports.parseThemeBlocks = parseThemeBlocks;
|
|
3679
3699
|
exports.planGlobalVarAliases = planGlobalVarAliases;
|
|
3680
3700
|
exports.readGlobalVarScanCache = readGlobalVarScanCache;
|
|
3681
|
-
exports.
|
|
3701
|
+
exports.resolveCompileSourceDirs = resolveCompileSourceDirs;
|
|
3682
3702
|
exports.resolveGlobalVarScanCacheDir = resolveGlobalVarScanCacheDir;
|
|
3683
3703
|
exports.resolveNativeCacheIdentity = resolveNativeCacheIdentity;
|
|
3684
3704
|
exports.rewriteGlobalVarCssAliases = rewriteGlobalVarCssAliases;
|
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.4",
|
|
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/
|
|
121
|
-
"@csszyx/core": "0.10.
|
|
122
|
-
"@csszyx/
|
|
123
|
-
"@csszyx/
|
|
124
|
-
"@csszyx/
|
|
120
|
+
"@csszyx/svelte-adapter": "0.10.4",
|
|
121
|
+
"@csszyx/core": "0.10.4",
|
|
122
|
+
"@csszyx/compiler": "0.10.4",
|
|
123
|
+
"@csszyx/types": "0.10.4",
|
|
124
|
+
"@csszyx/vue-adapter": "0.10.4"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@csszyx/runtime": "^0.10.
|
|
127
|
+
"@csszyx/runtime": "^0.10.4"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"@types/node": "^20.11.0",
|