tailwind-styled-v4 4.0.0 → 5.0.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/dist/animate.cjs +754 -235
- package/dist/animate.cjs.map +1 -1
- package/dist/animate.d.cts +55 -99
- package/dist/animate.d.ts +55 -99
- package/dist/animate.js +742 -235
- package/dist/animate.js.map +1 -1
- package/dist/chunk-VZEJV27B.js +11 -0
- package/dist/chunk-VZEJV27B.js.map +1 -0
- package/dist/chunk-Y5D3E72P.cjs +13 -0
- package/dist/chunk-Y5D3E72P.cjs.map +1 -0
- package/dist/css.cjs +61 -11
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +3 -18
- package/dist/css.d.ts +3 -18
- package/dist/css.js +61 -11
- package/dist/css.js.map +1 -1
- package/dist/devtools.cjs +200 -88
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +200 -88
- package/dist/devtools.js.map +1 -1
- package/dist/index.cjs +430 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -3
- package/dist/index.d.ts +74 -3
- package/dist/index.js +415 -132
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +118 -138
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +28 -19
- package/dist/next.d.ts +28 -19
- package/dist/next.js +111 -131
- package/dist/next.js.map +1 -1
- package/dist/preset.cjs +312 -18
- package/dist/preset.cjs.map +1 -1
- package/dist/preset.d.cts +29 -2
- package/dist/preset.d.ts +29 -2
- package/dist/preset.js +311 -19
- package/dist/preset.js.map +1 -1
- package/dist/turbopackLoader.cjs +24 -2676
- package/dist/turbopackLoader.cjs.map +1 -1
- package/dist/turbopackLoader.d.cts +3 -13
- package/dist/turbopackLoader.d.ts +3 -13
- package/dist/turbopackLoader.js +24 -2670
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/vite.cjs +90 -57
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +35 -6
- package/dist/vite.d.ts +35 -6
- package/dist/vite.js +90 -58
- package/dist/vite.js.map +1 -1
- package/dist/webpackLoader.cjs +27 -2646
- package/dist/webpackLoader.cjs.map +1 -1
- package/dist/webpackLoader.d.cts +3 -10
- package/dist/webpackLoader.d.ts +3 -10
- package/dist/webpackLoader.js +27 -2640
- package/dist/webpackLoader.js.map +1 -1
- package/package.json +31 -28
- package/dist/astTransform-ua-eapqs.d.cts +0 -41
- package/dist/astTransform-ua-eapqs.d.ts +0 -41
- package/dist/compiler.cjs +0 -3594
- package/dist/compiler.cjs.map +0 -1
- package/dist/compiler.d.cts +0 -716
- package/dist/compiler.d.ts +0 -716
- package/dist/compiler.js +0 -3535
- package/dist/compiler.js.map +0 -1
- package/dist/plugins.cjs +0 -396
- package/dist/plugins.cjs.map +0 -1
- package/dist/plugins.d.cts +0 -231
- package/dist/plugins.d.ts +0 -231
- package/dist/plugins.js +0 -381
- package/dist/plugins.js.map +0 -1
- package/dist/theme.cjs +0 -154
- package/dist/theme.cjs.map +0 -1
- package/dist/theme.d.cts +0 -181
- package/dist/theme.d.ts +0 -181
- package/dist/theme.js +0 -148
- package/dist/theme.js.map +0 -1
package/dist/vite.cjs
CHANGED
|
@@ -2,59 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('./chunk-Y5D3E72P.cjs');
|
|
6
|
+
var fs = require('fs');
|
|
5
7
|
var path = require('path');
|
|
6
8
|
var compiler = require('@tailwind-styled/compiler');
|
|
9
|
+
var engine = require('@tailwind-styled/engine');
|
|
10
|
+
var scanner = require('@tailwind-styled/scanner');
|
|
7
11
|
|
|
8
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
13
|
|
|
14
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
10
15
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
11
16
|
|
|
12
17
|
/* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
19
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
20
|
-
var __spreadValues = (a, b) => {
|
|
21
|
-
for (var prop in b || (b = {}))
|
|
22
|
-
if (__hasOwnProp.call(b, prop))
|
|
23
|
-
__defNormalProp(a, prop, b[prop]);
|
|
24
|
-
if (__getOwnPropSymbols)
|
|
25
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
26
|
-
if (__propIsEnum.call(b, prop))
|
|
27
|
-
__defNormalProp(a, prop, b[prop]);
|
|
28
|
-
}
|
|
29
|
-
return a;
|
|
30
|
-
};
|
|
31
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
32
|
-
var __objRest = (source, exclude) => {
|
|
33
|
-
var target = {};
|
|
34
|
-
for (var prop in source)
|
|
35
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
36
|
-
target[prop] = source[prop];
|
|
37
|
-
if (source != null && __getOwnPropSymbols)
|
|
38
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
39
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
40
|
-
target[prop] = source[prop];
|
|
41
|
-
}
|
|
42
|
-
return target;
|
|
43
|
-
};
|
|
18
|
+
function warnDeprecated(options, key, message) {
|
|
19
|
+
if (options[key] !== void 0) {
|
|
20
|
+
console.warn(`[tailwind-styled-v4] Warning: '${key}' is deprecated in v5. ${message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
44
23
|
function tailwindStyledPlugin(opts = {}) {
|
|
45
|
-
|
|
24
|
+
warnDeprecated(opts, "mode", "Only zero-runtime is supported.");
|
|
25
|
+
warnDeprecated(opts, "routeCss", "Use engine's analyzing capabilities.");
|
|
26
|
+
warnDeprecated(opts, "deadStyleElimination", "Use 'analyze: true' option instead.");
|
|
27
|
+
warnDeprecated(opts, "addDataAttr", "Handled by engine internally.");
|
|
28
|
+
warnDeprecated(opts, "autoClientBoundary", "Handled by engine internally.");
|
|
29
|
+
warnDeprecated(opts, "hoist", "Handled by engine internally.");
|
|
30
|
+
warnDeprecated(opts, "incremental", "Handled by engine internally.");
|
|
31
|
+
const {
|
|
46
32
|
include = /\.(tsx|ts|jsx|js)$/,
|
|
47
33
|
exclude = /node_modules/,
|
|
48
34
|
scanDirs = ["src"],
|
|
49
35
|
safelistOutput = ".tailwind-styled-safelist.json",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"generateSafelist"
|
|
57
|
-
]);
|
|
36
|
+
scanReportOutput = ".tailwind-styled-scan-report.json",
|
|
37
|
+
generateSafelist: doSafelist = true,
|
|
38
|
+
useEngineBuild = true,
|
|
39
|
+
analyze = false,
|
|
40
|
+
strict = false
|
|
41
|
+
} = opts;
|
|
58
42
|
let root = process.cwd();
|
|
59
43
|
let isDev = true;
|
|
60
44
|
return {
|
|
@@ -65,33 +49,82 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
65
49
|
isDev = config.command === "serve";
|
|
66
50
|
},
|
|
67
51
|
transform(source, id) {
|
|
68
|
-
var _a2, _b;
|
|
69
52
|
const filepath = id.split("?")[0];
|
|
70
53
|
if (!include.test(filepath)) return null;
|
|
71
54
|
if (exclude.test(filepath)) return null;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
mode:
|
|
75
|
-
addDataAttr:
|
|
76
|
-
filename: filepath
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
const loaderOptions = {
|
|
56
|
+
// v5: Always zero-runtime (mode is deprecated)
|
|
57
|
+
mode: "zero-runtime",
|
|
58
|
+
addDataAttr: isDev,
|
|
59
|
+
filename: filepath,
|
|
60
|
+
// Preserve cv, cx, cn, etc — only tw.* is transformed
|
|
61
|
+
preserveImports: true
|
|
62
|
+
};
|
|
63
|
+
const output = compiler.runLoaderTransform({
|
|
64
|
+
filepath,
|
|
65
|
+
source,
|
|
66
|
+
options: loaderOptions,
|
|
67
|
+
isDev
|
|
68
|
+
});
|
|
69
|
+
if (!output.changed) return null;
|
|
70
|
+
return { code: output.code, map: null };
|
|
80
71
|
},
|
|
81
|
-
buildEnd() {
|
|
82
|
-
if (
|
|
72
|
+
async buildEnd() {
|
|
73
|
+
if (isDev) return;
|
|
74
|
+
if (doSafelist) {
|
|
75
|
+
try {
|
|
76
|
+
compiler.generateSafelist(
|
|
77
|
+
scanDirs.map((d) => path__default.default.resolve(root, d)),
|
|
78
|
+
path__default.default.resolve(root, safelistOutput),
|
|
79
|
+
root
|
|
80
|
+
);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn("[tailwind-styled-v4] Safelist generation failed:", e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
83
85
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const report = await scanner.scanWorkspaceAsync(root);
|
|
87
|
+
const reportPath = path__default.default.resolve(root, scanReportOutput);
|
|
88
|
+
fs__default.default.writeFileSync(
|
|
89
|
+
reportPath,
|
|
90
|
+
JSON.stringify(
|
|
91
|
+
{
|
|
92
|
+
root,
|
|
93
|
+
totalFiles: report.totalFiles,
|
|
94
|
+
uniqueClassCount: report.uniqueClasses.length
|
|
95
|
+
},
|
|
96
|
+
null,
|
|
97
|
+
2
|
|
98
|
+
) + "\n"
|
|
88
99
|
);
|
|
89
100
|
} catch (e) {
|
|
90
|
-
console.warn("[tailwind-styled-v4]
|
|
101
|
+
console.warn("[tailwind-styled-v4] Scan report generation failed:", e);
|
|
102
|
+
}
|
|
103
|
+
if (useEngineBuild) {
|
|
104
|
+
try {
|
|
105
|
+
const engine$1 = await engine.createEngine({
|
|
106
|
+
root,
|
|
107
|
+
compileCss: true,
|
|
108
|
+
analyze,
|
|
109
|
+
scanner: {
|
|
110
|
+
includeExtensions: [".tsx", ".ts", ".jsx", ".js"],
|
|
111
|
+
ignoreDirectories: scanDirs
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
await engine$1.build();
|
|
115
|
+
console.log("[tailwind-styled-v4] \u2713 Engine build complete");
|
|
116
|
+
} catch (e) {
|
|
117
|
+
const msg = `[tailwind-styled-v4] Engine build step failed: ${e}`;
|
|
118
|
+
if (strict) {
|
|
119
|
+
throw new Error(msg);
|
|
120
|
+
} else {
|
|
121
|
+
console.warn(msg);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
},
|
|
93
126
|
handleHotUpdate({ file, server }) {
|
|
94
|
-
if (include.test(file) &&
|
|
127
|
+
if (include.test(file) && !exclude.test(file)) {
|
|
95
128
|
server.ws.send({ type: "full-reload" });
|
|
96
129
|
}
|
|
97
130
|
}
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../vite/src/plugin.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../vite/src/plugin.ts"],"names":["runLoaderTransform","generateSafelist","path","scanWorkspaceAsync","fs","engine","createEngine"],"mappings":";;;;;;;;;;;;;;;;;AA2DA,SAAS,cAAA,CAAe,OAAA,EAA4B,GAAA,EAA8B,OAAA,EAAiB;AACjG,EAAA,IAAI,OAAA,CAAQ,GAAG,CAAA,KAAM,MAAA,EAAW;AAC9B,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,+BAAA,EAAkC,GAAG,CAAA,uBAAA,EAA0B,OAAO,CAAA,CAAE,CAAA;AAAA,EACvF;AACF;AAEO,SAAS,oBAAA,CAAqB,IAAA,GAA0B,EAAC,EAAQ;AACtE,EAAA,cAAA,CAAe,IAAA,EAAM,QAAQ,iCAAiC,CAAA;AAC9D,EAAA,cAAA,CAAe,IAAA,EA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@tailwind-styled/vite\"\n * export default defineConfig({\n * plugins: [react(), tailwindStyledPlugin()]\n * })\n *\n * v5 Changes:\n * - Simplified API (removed deprecated options)\n * - Uses @tailwind-styled/engine for build\n * - Mode always zero-runtime\n */\n\nimport fs from \"node:fs\"\nimport path from \"node:path\"\n\nimport type { LoaderOptions, TransformOptions } from \"@tailwind-styled/compiler\"\nimport { generateSafelist, runLoaderTransform } from \"@tailwind-styled/compiler\"\nimport { createEngine } from \"@tailwind-styled/engine\"\nimport { scanWorkspaceAsync } from \"@tailwind-styled/scanner\"\n\nexport interface VitePluginOptions {\n /** File patterns to include. Default: /\\.(tsx|ts|jsx|js)$/ */\n include?: RegExp\n /** File patterns to exclude. Default: /node_modules/ */\n exclude?: RegExp\n /** Directories to scan. Default: [\"src\"] */\n scanDirs?: string[]\n /** Safelist output path. Default: \".tailwind-styled-safelist.json\" */\n safelistOutput?: string\n /** Generate safelist at build end. Default: true */\n generateSafelist?: boolean\n /** Scan report output path. Default: \".tailwind-styled-scan-report.json\" */\n scanReportOutput?: string\n /** Run engine build at build end. Default: true */\n useEngineBuild?: boolean\n /** Enable analyzer for semantic reports. Default: false */\n analyze?: boolean\n /** Throw error on engine build failure. If true, error will abort Vite build (useful for CI/CD). If false (default), error only shows console.warn. Default: false */\n strict?: boolean\n\n /** @deprecated in v5 - mode is always \"zero-runtime\" */\n mode?: \"zero-runtime\" | \"runtime\"\n /** @deprecated in v5 - handled by engine */\n routeCss?: boolean\n /** @deprecated in v5 - handled by engine with analyze: true */\n deadStyleElimination?: boolean\n /** @deprecated in v5 - no longer used */\n addDataAttr?: boolean\n /** @deprecated in v5 - no longer used */\n autoClientBoundary?: boolean\n /** @deprecated in v5 - no longer used */\n hoist?: boolean\n /** @deprecated in v5 - no longer used */\n incremental?: boolean\n}\n\nfunction warnDeprecated(options: VitePluginOptions, key: keyof VitePluginOptions, message: string) {\n if (options[key] !== undefined) {\n console.warn(`[tailwind-styled-v4] Warning: '${key}' is deprecated in v5. ${message}`)\n }\n}\n\nexport function tailwindStyledPlugin(opts: VitePluginOptions = {}): any {\n warnDeprecated(opts, \"mode\", \"Only zero-runtime is supported.\")\n warnDeprecated(opts, \"routeCss\", \"Use engine's analyzing capabilities.\")\n warnDeprecated(opts, \"deadStyleElimination\", \"Use 'analyze: true' option instead.\")\n warnDeprecated(opts, \"addDataAttr\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"autoClientBoundary\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"hoist\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"incremental\", \"Handled by engine internally.\")\n\n const {\n include = /\\.(tsx|ts|jsx|js)$/,\n exclude = /node_modules/,\n scanDirs = [\"src\"],\n safelistOutput = \".tailwind-styled-safelist.json\",\n scanReportOutput = \".tailwind-styled-scan-report.json\",\n generateSafelist: doSafelist = true,\n useEngineBuild = true,\n analyze = false,\n strict = false,\n } = opts\n\n let root = process.cwd()\n let isDev = true\n\n return {\n name: \"tailwind-styled-v4\",\n enforce: \"pre\" as const,\n\n configResolved(config: any) {\n root = config.root\n isDev = config.command === \"serve\"\n },\n\n transform(source: string, id: string) {\n const filepath = id.split(\"?\")[0]\n if (!include.test(filepath)) return null\n if (exclude.test(filepath)) return null\n\n const loaderOptions: LoaderOptions = {\n // v5: Always zero-runtime (mode is deprecated)\n mode: \"zero-runtime\",\n addDataAttr: isDev,\n filename: filepath,\n // Preserve cv, cx, cn, etc — only tw.* is transformed\n preserveImports: true,\n }\n\n const output = runLoaderTransform({\n filepath,\n source,\n options: loaderOptions,\n isDev,\n })\n\n if (!output.changed) return null\n return { code: output.code, map: null }\n },\n\n async buildEnd() {\n if (isDev) return\n\n if (doSafelist) {\n try {\n generateSafelist(\n scanDirs.map((d) => path.resolve(root, d)),\n path.resolve(root, safelistOutput),\n root\n )\n } catch (e) {\n console.warn(\"[tailwind-styled-v4] Safelist generation failed:\", e)\n }\n }\n\n try {\n const report = await scanWorkspaceAsync(root)\n const reportPath = path.resolve(root, scanReportOutput)\n fs.writeFileSync(\n reportPath,\n JSON.stringify(\n {\n root,\n totalFiles: report.totalFiles,\n uniqueClassCount: report.uniqueClasses.length,\n },\n null,\n 2\n ) + \"\\n\"\n )\n } catch (e) {\n console.warn(\"[tailwind-styled-v4] Scan report generation failed:\", e)\n }\n\n if (useEngineBuild) {\n try {\n const engine = await createEngine({\n root,\n compileCss: true,\n analyze,\n scanner: {\n includeExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n ignoreDirectories: scanDirs,\n },\n })\n await engine.build()\n console.log(\"[tailwind-styled-v4] ✓ Engine build complete\")\n } catch (e) {\n const msg = `[tailwind-styled-v4] Engine build step failed: ${e}`\n if (strict) {\n throw new Error(msg)\n } else {\n console.warn(msg)\n }\n }\n }\n },\n\n handleHotUpdate({ file, server }: any) {\n if (include.test(file) && !exclude.test(file)) {\n server.ws.send({ type: \"full-reload\" })\n }\n },\n }\n}\n\nexport default tailwindStyledPlugin\n"]}
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
import { TransformOptions } from '@tailwind-styled/compiler';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* tailwind-styled-v4 — Vite Plugin
|
|
2
|
+
* tailwind-styled-v4 — Vite Plugin v5
|
|
5
3
|
*
|
|
6
4
|
* Usage in vite.config.ts:
|
|
7
|
-
* import { tailwindStyledPlugin } from "tailwind-styled
|
|
5
|
+
* import { tailwindStyledPlugin } from "@tailwind-styled/vite"
|
|
8
6
|
* export default defineConfig({
|
|
9
7
|
* plugins: [react(), tailwindStyledPlugin()]
|
|
10
8
|
* })
|
|
9
|
+
*
|
|
10
|
+
* v5 Changes:
|
|
11
|
+
* - Simplified API (removed deprecated options)
|
|
12
|
+
* - Uses @tailwind-styled/engine for build
|
|
13
|
+
* - Mode always zero-runtime
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
interface VitePluginOptions {
|
|
16
|
+
/** File patterns to include. Default: /\.(tsx|ts|jsx|js)$/ */
|
|
14
17
|
include?: RegExp;
|
|
18
|
+
/** File patterns to exclude. Default: /node_modules/ */
|
|
15
19
|
exclude?: RegExp;
|
|
20
|
+
/** Directories to scan. Default: ["src"] */
|
|
16
21
|
scanDirs?: string[];
|
|
22
|
+
/** Safelist output path. Default: ".tailwind-styled-safelist.json" */
|
|
17
23
|
safelistOutput?: string;
|
|
24
|
+
/** Generate safelist at build end. Default: true */
|
|
18
25
|
generateSafelist?: boolean;
|
|
26
|
+
/** Scan report output path. Default: ".tailwind-styled-scan-report.json" */
|
|
27
|
+
scanReportOutput?: string;
|
|
28
|
+
/** Run engine build at build end. Default: true */
|
|
29
|
+
useEngineBuild?: boolean;
|
|
30
|
+
/** Enable analyzer for semantic reports. Default: false */
|
|
31
|
+
analyze?: boolean;
|
|
32
|
+
/** Throw error on engine build failure. If true, error will abort Vite build (useful for CI/CD). If false (default), error only shows console.warn. Default: false */
|
|
33
|
+
strict?: boolean;
|
|
34
|
+
/** @deprecated in v5 - mode is always "zero-runtime" */
|
|
35
|
+
mode?: "zero-runtime" | "runtime";
|
|
36
|
+
/** @deprecated in v5 - handled by engine */
|
|
37
|
+
routeCss?: boolean;
|
|
38
|
+
/** @deprecated in v5 - handled by engine with analyze: true */
|
|
39
|
+
deadStyleElimination?: boolean;
|
|
40
|
+
/** @deprecated in v5 - no longer used */
|
|
41
|
+
addDataAttr?: boolean;
|
|
42
|
+
/** @deprecated in v5 - no longer used */
|
|
43
|
+
autoClientBoundary?: boolean;
|
|
44
|
+
/** @deprecated in v5 - no longer used */
|
|
45
|
+
hoist?: boolean;
|
|
46
|
+
/** @deprecated in v5 - no longer used */
|
|
47
|
+
incremental?: boolean;
|
|
19
48
|
}
|
|
20
49
|
declare function tailwindStyledPlugin(opts?: VitePluginOptions): any;
|
|
21
50
|
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
import { TransformOptions } from '@tailwind-styled/compiler';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* tailwind-styled-v4 — Vite Plugin
|
|
2
|
+
* tailwind-styled-v4 — Vite Plugin v5
|
|
5
3
|
*
|
|
6
4
|
* Usage in vite.config.ts:
|
|
7
|
-
* import { tailwindStyledPlugin } from "tailwind-styled
|
|
5
|
+
* import { tailwindStyledPlugin } from "@tailwind-styled/vite"
|
|
8
6
|
* export default defineConfig({
|
|
9
7
|
* plugins: [react(), tailwindStyledPlugin()]
|
|
10
8
|
* })
|
|
9
|
+
*
|
|
10
|
+
* v5 Changes:
|
|
11
|
+
* - Simplified API (removed deprecated options)
|
|
12
|
+
* - Uses @tailwind-styled/engine for build
|
|
13
|
+
* - Mode always zero-runtime
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
interface VitePluginOptions {
|
|
16
|
+
/** File patterns to include. Default: /\.(tsx|ts|jsx|js)$/ */
|
|
14
17
|
include?: RegExp;
|
|
18
|
+
/** File patterns to exclude. Default: /node_modules/ */
|
|
15
19
|
exclude?: RegExp;
|
|
20
|
+
/** Directories to scan. Default: ["src"] */
|
|
16
21
|
scanDirs?: string[];
|
|
22
|
+
/** Safelist output path. Default: ".tailwind-styled-safelist.json" */
|
|
17
23
|
safelistOutput?: string;
|
|
24
|
+
/** Generate safelist at build end. Default: true */
|
|
18
25
|
generateSafelist?: boolean;
|
|
26
|
+
/** Scan report output path. Default: ".tailwind-styled-scan-report.json" */
|
|
27
|
+
scanReportOutput?: string;
|
|
28
|
+
/** Run engine build at build end. Default: true */
|
|
29
|
+
useEngineBuild?: boolean;
|
|
30
|
+
/** Enable analyzer for semantic reports. Default: false */
|
|
31
|
+
analyze?: boolean;
|
|
32
|
+
/** Throw error on engine build failure. If true, error will abort Vite build (useful for CI/CD). If false (default), error only shows console.warn. Default: false */
|
|
33
|
+
strict?: boolean;
|
|
34
|
+
/** @deprecated in v5 - mode is always "zero-runtime" */
|
|
35
|
+
mode?: "zero-runtime" | "runtime";
|
|
36
|
+
/** @deprecated in v5 - handled by engine */
|
|
37
|
+
routeCss?: boolean;
|
|
38
|
+
/** @deprecated in v5 - handled by engine with analyze: true */
|
|
39
|
+
deadStyleElimination?: boolean;
|
|
40
|
+
/** @deprecated in v5 - no longer used */
|
|
41
|
+
addDataAttr?: boolean;
|
|
42
|
+
/** @deprecated in v5 - no longer used */
|
|
43
|
+
autoClientBoundary?: boolean;
|
|
44
|
+
/** @deprecated in v5 - no longer used */
|
|
45
|
+
hoist?: boolean;
|
|
46
|
+
/** @deprecated in v5 - no longer used */
|
|
47
|
+
incremental?: boolean;
|
|
19
48
|
}
|
|
20
49
|
declare function tailwindStyledPlugin(opts?: VitePluginOptions): any;
|
|
21
50
|
|
package/dist/vite.js
CHANGED
|
@@ -1,52 +1,35 @@
|
|
|
1
|
+
import './chunk-VZEJV27B.js';
|
|
2
|
+
import fs from 'fs';
|
|
1
3
|
import path from 'path';
|
|
2
|
-
import {
|
|
4
|
+
import { runLoaderTransform, generateSafelist } from '@tailwind-styled/compiler';
|
|
5
|
+
import { createEngine } from '@tailwind-styled/engine';
|
|
6
|
+
import { scanWorkspaceAsync } from '@tailwind-styled/scanner';
|
|
3
7
|
|
|
4
8
|
/* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
9
|
+
function warnDeprecated(options, key, message) {
|
|
10
|
+
if (options[key] !== void 0) {
|
|
11
|
+
console.warn(`[tailwind-styled-v4] Warning: '${key}' is deprecated in v5. ${message}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
36
14
|
function tailwindStyledPlugin(opts = {}) {
|
|
37
|
-
|
|
15
|
+
warnDeprecated(opts, "mode", "Only zero-runtime is supported.");
|
|
16
|
+
warnDeprecated(opts, "routeCss", "Use engine's analyzing capabilities.");
|
|
17
|
+
warnDeprecated(opts, "deadStyleElimination", "Use 'analyze: true' option instead.");
|
|
18
|
+
warnDeprecated(opts, "addDataAttr", "Handled by engine internally.");
|
|
19
|
+
warnDeprecated(opts, "autoClientBoundary", "Handled by engine internally.");
|
|
20
|
+
warnDeprecated(opts, "hoist", "Handled by engine internally.");
|
|
21
|
+
warnDeprecated(opts, "incremental", "Handled by engine internally.");
|
|
22
|
+
const {
|
|
38
23
|
include = /\.(tsx|ts|jsx|js)$/,
|
|
39
24
|
exclude = /node_modules/,
|
|
40
25
|
scanDirs = ["src"],
|
|
41
26
|
safelistOutput = ".tailwind-styled-safelist.json",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"generateSafelist"
|
|
49
|
-
]);
|
|
27
|
+
scanReportOutput = ".tailwind-styled-scan-report.json",
|
|
28
|
+
generateSafelist: doSafelist = true,
|
|
29
|
+
useEngineBuild = true,
|
|
30
|
+
analyze = false,
|
|
31
|
+
strict = false
|
|
32
|
+
} = opts;
|
|
50
33
|
let root = process.cwd();
|
|
51
34
|
let isDev = true;
|
|
52
35
|
return {
|
|
@@ -57,33 +40,82 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
57
40
|
isDev = config.command === "serve";
|
|
58
41
|
},
|
|
59
42
|
transform(source, id) {
|
|
60
|
-
var _a2, _b;
|
|
61
43
|
const filepath = id.split("?")[0];
|
|
62
44
|
if (!include.test(filepath)) return null;
|
|
63
45
|
if (exclude.test(filepath)) return null;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
mode:
|
|
67
|
-
addDataAttr:
|
|
68
|
-
filename: filepath
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
const loaderOptions = {
|
|
47
|
+
// v5: Always zero-runtime (mode is deprecated)
|
|
48
|
+
mode: "zero-runtime",
|
|
49
|
+
addDataAttr: isDev,
|
|
50
|
+
filename: filepath,
|
|
51
|
+
// Preserve cv, cx, cn, etc — only tw.* is transformed
|
|
52
|
+
preserveImports: true
|
|
53
|
+
};
|
|
54
|
+
const output = runLoaderTransform({
|
|
55
|
+
filepath,
|
|
56
|
+
source,
|
|
57
|
+
options: loaderOptions,
|
|
58
|
+
isDev
|
|
59
|
+
});
|
|
60
|
+
if (!output.changed) return null;
|
|
61
|
+
return { code: output.code, map: null };
|
|
72
62
|
},
|
|
73
|
-
buildEnd() {
|
|
74
|
-
if (
|
|
63
|
+
async buildEnd() {
|
|
64
|
+
if (isDev) return;
|
|
65
|
+
if (doSafelist) {
|
|
66
|
+
try {
|
|
67
|
+
generateSafelist(
|
|
68
|
+
scanDirs.map((d) => path.resolve(root, d)),
|
|
69
|
+
path.resolve(root, safelistOutput),
|
|
70
|
+
root
|
|
71
|
+
);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.warn("[tailwind-styled-v4] Safelist generation failed:", e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
75
76
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const report = await scanWorkspaceAsync(root);
|
|
78
|
+
const reportPath = path.resolve(root, scanReportOutput);
|
|
79
|
+
fs.writeFileSync(
|
|
80
|
+
reportPath,
|
|
81
|
+
JSON.stringify(
|
|
82
|
+
{
|
|
83
|
+
root,
|
|
84
|
+
totalFiles: report.totalFiles,
|
|
85
|
+
uniqueClassCount: report.uniqueClasses.length
|
|
86
|
+
},
|
|
87
|
+
null,
|
|
88
|
+
2
|
|
89
|
+
) + "\n"
|
|
80
90
|
);
|
|
81
91
|
} catch (e) {
|
|
82
|
-
console.warn("[tailwind-styled-v4]
|
|
92
|
+
console.warn("[tailwind-styled-v4] Scan report generation failed:", e);
|
|
93
|
+
}
|
|
94
|
+
if (useEngineBuild) {
|
|
95
|
+
try {
|
|
96
|
+
const engine = await createEngine({
|
|
97
|
+
root,
|
|
98
|
+
compileCss: true,
|
|
99
|
+
analyze,
|
|
100
|
+
scanner: {
|
|
101
|
+
includeExtensions: [".tsx", ".ts", ".jsx", ".js"],
|
|
102
|
+
ignoreDirectories: scanDirs
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
await engine.build();
|
|
106
|
+
console.log("[tailwind-styled-v4] \u2713 Engine build complete");
|
|
107
|
+
} catch (e) {
|
|
108
|
+
const msg = `[tailwind-styled-v4] Engine build step failed: ${e}`;
|
|
109
|
+
if (strict) {
|
|
110
|
+
throw new Error(msg);
|
|
111
|
+
} else {
|
|
112
|
+
console.warn(msg);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
83
115
|
}
|
|
84
116
|
},
|
|
85
117
|
handleHotUpdate({ file, server }) {
|
|
86
|
-
if (include.test(file) &&
|
|
118
|
+
if (include.test(file) && !exclude.test(file)) {
|
|
87
119
|
server.ws.send({ type: "full-reload" });
|
|
88
120
|
}
|
|
89
121
|
}
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../vite/src/plugin.ts"],"names":[
|
|
1
|
+
{"version":3,"sources":["../../vite/src/plugin.ts"],"names":[],"mappings":";;;;;;;;AA2DA,SAAS,cAAA,CAAe,OAAA,EAA4B,GAAA,EAA8B,OAAA,EAAiB;AACjG,EAAA,IAAI,OAAA,CAAQ,GAAG,CAAA,KAAM,MAAA,EAAW;AAC9B,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,+BAAA,EAAkC,GAAG,CAAA,uBAAA,EAA0B,OAAO,CAAA,CAAE,CAAA;AAAA,EACvF;AACF;AAEO,SAAS,oBAAA,CAAqB,IAAA,GAA0B,EAAC,EAAQ;AACtE,EAAA,cAAA,CAAe,IAAA,EAAM,QAAQ,iCAAiC,CAAA;AAC9D,EAAA,cAAA,CAAe,IAAA,EAAM,YAAY,sCAAsC,CAAA;AACvE,EAAA,cAAA,CAAe,IAAA,EAAM,wBAAwB,qCAAqC,CAAA;AAClF,EAAA,cAAA,CAAe,IAAA,EAAM,eAAe,+BAA+B,CAAA;AACnE,EAAA,cAAA,CAAe,IAAA,EAAM,sBAAsB,+BAA+B,CAAA;AAC1E,EAAA,cAAA,CAAe,IAAA,EAAM,SAAS,+BAA+B,CAAA;AAC7D,EAAA,cAAA,CAAe,IAAA,EAAM,eAAe,+BAA+B,CAAA;AAEnE,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,oBAAA;AAAA,IACV,OAAA,GAAU,cAAA;AAAA,IACV,QAAA,GAAW,CAAC,KAAK,CAAA;AAAA,IACjB,cAAA,GAAiB,gCAAA;AAAA,IACjB,gBAAA,GAAmB,mCAAA;AAAA,IACnB,kBAAkB,UAAA,GAAa,IAAA;AAAA,IAC/B,cAAA,GAAiB,I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AAA,MAAM,GAAA,GAAM,kDAAkD,CAAC,CAAA,CAAA;AAC/D,UAAA,IAAI,MAAA,EAAQ;AACV,YAAA,MAAM,IAAI,MAAM,GAAG,CAAA;AAAA,UACrB,CAAA,MAAO;AACL,YAAA,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAA;AAAA,IAEA,eAAA,CAAgB,EAAE,IAAA,EAAM,MAAA,EAAO,EAAQ;AACrC,MAAA,IAAI,OAAA,CAAQ,KAAK,IAAI,CAAA,IAAK,CAAC,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA,EAAG;AAC7C,QAAA,MAAA,CAAO,EAAA,CAAG,IAAA,CAAK,EAAE,IAAA,EAAM,eAAe,CAAA;AAAA,MACxC;AAAA,IACF;AAAA,GACF;AACF;AAEA,IAAO,cAAA,GAAQ","file":"vite.js","sourcesContent":["/**\n * tailwind-styled-v4 — Vite Plugin v5\n *\n * Usage in vite.config.ts:\n * import { tailwindStyledPlugin } from \"@tailwind-styled/vite\"\n * export default defineConfig({\n * plugins: [react(), tailwindStyledPlugin()]\n * })\n *\n * v5 Changes:\n * - Simplified API (removed deprecated options)\n * - Uses @tailwind-styled/engine for build\n * - Mode always zero-runtime\n */\n\nimport fs from \"node:fs\"\nimport path from \"node:path\"\n\nimport type { LoaderOptions, TransformOptions } from \"@tailwind-styled/compiler\"\nimport { generateSafelist, runLoaderTransform } from \"@tailwind-styled/compiler\"\nimport { createEngine } from \"@tailwind-styled/engine\"\nimport { scanWorkspaceAsync } from \"@tailwind-styled/scanner\"\n\nexport interface VitePluginOptions {\n /** File patterns to include. Default: /\\.(tsx|ts|jsx|js)$/ */\n include?: RegExp\n /** File patterns to exclude. Default: /node_modules/ */\n exclude?: RegExp\n /** Directories to scan. Default: [\"src\"] */\n scanDirs?: string[]\n /** Safelist output path. Default: \".tailwind-styled-safelist.json\" */\n safelistOutput?: string\n /** Generate safelist at build end. Default: true */\n generateSafelist?: boolean\n /** Scan report output path. Default: \".tailwind-styled-scan-report.json\" */\n scanReportOutput?: string\n /** Run engine build at build end. Default: true */\n useEngineBuild?: boolean\n /** Enable analyzer for semantic reports. Default: false */\n analyze?: boolean\n /** Throw error on engine build failure. If true, error will abort Vite build (useful for CI/CD). If false (default), error only shows console.warn. Default: false */\n strict?: boolean\n\n /** @deprecated in v5 - mode is always \"zero-runtime\" */\n mode?: \"zero-runtime\" | \"runtime\"\n /** @deprecated in v5 - handled by engine */\n routeCss?: boolean\n /** @deprecated in v5 - handled by engine with analyze: true */\n deadStyleElimination?: boolean\n /** @deprecated in v5 - no longer used */\n addDataAttr?: boolean\n /** @deprecated in v5 - no longer used */\n autoClientBoundary?: boolean\n /** @deprecated in v5 - no longer used */\n hoist?: boolean\n /** @deprecated in v5 - no longer used */\n incremental?: boolean\n}\n\nfunction warnDeprecated(options: VitePluginOptions, key: keyof VitePluginOptions, message: string) {\n if (options[key] !== undefined) {\n console.warn(`[tailwind-styled-v4] Warning: '${key}' is deprecated in v5. ${message}`)\n }\n}\n\nexport function tailwindStyledPlugin(opts: VitePluginOptions = {}): any {\n warnDeprecated(opts, \"mode\", \"Only zero-runtime is supported.\")\n warnDeprecated(opts, \"routeCss\", \"Use engine's analyzing capabilities.\")\n warnDeprecated(opts, \"deadStyleElimination\", \"Use 'analyze: true' option instead.\")\n warnDeprecated(opts, \"addDataAttr\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"autoClientBoundary\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"hoist\", \"Handled by engine internally.\")\n warnDeprecated(opts, \"incremental\", \"Handled by engine internally.\")\n\n const {\n include = /\\.(tsx|ts|jsx|js)$/,\n exclude = /node_modules/,\n scanDirs = [\"src\"],\n safelistOutput = \".tailwind-styled-safelist.json\",\n scanReportOutput = \".tailwind-styled-scan-report.json\",\n generateSafelist: doSafelist = true,\n useEngineBuild = true,\n analyze = false,\n strict = false,\n } = opts\n\n let root = process.cwd()\n let isDev = true\n\n return {\n name: \"tailwind-styled-v4\",\n enforce: \"pre\" as const,\n\n configResolved(config: any) {\n root = config.root\n isDev = config.command === \"serve\"\n },\n\n transform(source: string, id: string) {\n const filepath = id.split(\"?\")[0]\n if (!include.test(filepath)) return null\n if (exclude.test(filepath)) return null\n\n const loaderOptions: LoaderOptions = {\n // v5: Always zero-runtime (mode is deprecated)\n mode: \"zero-runtime\",\n addDataAttr: isDev,\n filename: filepath,\n // Preserve cv, cx, cn, etc — only tw.* is transformed\n preserveImports: true,\n }\n\n const output = runLoaderTransform({\n filepath,\n source,\n options: loaderOptions,\n isDev,\n })\n\n if (!output.changed) return null\n return { code: output.code, map: null }\n },\n\n async buildEnd() {\n if (isDev) return\n\n if (doSafelist) {\n try {\n generateSafelist(\n scanDirs.map((d) => path.resolve(root, d)),\n path.resolve(root, safelistOutput),\n root\n )\n } catch (e) {\n console.warn(\"[tailwind-styled-v4] Safelist generation failed:\", e)\n }\n }\n\n try {\n const report = await scanWorkspaceAsync(root)\n const reportPath = path.resolve(root, scanReportOutput)\n fs.writeFileSync(\n reportPath,\n JSON.stringify(\n {\n root,\n totalFiles: report.totalFiles,\n uniqueClassCount: report.uniqueClasses.length,\n },\n null,\n 2\n ) + \"\\n\"\n )\n } catch (e) {\n console.warn(\"[tailwind-styled-v4] Scan report generation failed:\", e)\n }\n\n if (useEngineBuild) {\n try {\n const engine = await createEngine({\n root,\n compileCss: true,\n analyze,\n scanner: {\n includeExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n ignoreDirectories: scanDirs,\n },\n })\n await engine.build()\n console.log(\"[tailwind-styled-v4] ✓ Engine build complete\")\n } catch (e) {\n const msg = `[tailwind-styled-v4] Engine build step failed: ${e}`\n if (strict) {\n throw new Error(msg)\n } else {\n console.warn(msg)\n }\n }\n }\n },\n\n handleHotUpdate({ file, server }: any) {\n if (include.test(file) && !exclude.test(file)) {\n server.ws.send({ type: \"full-reload\" })\n }\n },\n }\n}\n\nexport default tailwindStyledPlugin\n"]}
|