tailwind-styled-v4 5.0.33 → 5.0.35

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/vite.js CHANGED
@@ -1190,6 +1190,56 @@ var init_cssCompilationNative = __esm({
1190
1190
  init_nativeBridge();
1191
1191
  }
1192
1192
  });
1193
+ function loadTailwindEngine() {
1194
+ if (_twEngine) return _twEngine;
1195
+ if (_twEngineError) throw _twEngineError;
1196
+ try {
1197
+ const tw = require2("tailwindcss");
1198
+ if (typeof tw.compile !== "function") {
1199
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1200
+ }
1201
+ _twEngine = tw;
1202
+ return _twEngine;
1203
+ } catch (e) {
1204
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1205
+ throw _twEngineError;
1206
+ }
1207
+ }
1208
+ async function generateRawCss(classes, cssEntryContent, root) {
1209
+ if (classes.length === 0) return "";
1210
+ const tw = loadTailwindEngine();
1211
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1212
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1213
+ const { dirname, resolve: resolve2 } = await import('path');
1214
+ const projectRoot = root ?? process.cwd();
1215
+ const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
1216
+ const loadStylesheet = async (id, base) => {
1217
+ try {
1218
+ const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
1219
+ const pkgPath = req.resolve(cssId);
1220
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1221
+ } catch {
1222
+ try {
1223
+ const absPath = resolve2(base, id);
1224
+ if (existsSync3(absPath)) {
1225
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1226
+ }
1227
+ } catch {
1228
+ }
1229
+ return { content: "", base };
1230
+ }
1231
+ };
1232
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1233
+ return compiler.build(classes);
1234
+ }
1235
+ var require2, _twEngine, _twEngineError;
1236
+ var init_tailwindEngine = __esm({
1237
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1238
+ require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
1239
+ _twEngine = null;
1240
+ _twEngineError = null;
1241
+ }
1242
+ });
1193
1243
 
1194
1244
  // packages/domain/compiler/src/compiler/tailwindEngine.ts
1195
1245
  var tailwindEngine_exports = {};
@@ -1323,10 +1373,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1323
1373
  }
1324
1374
  _cacheMisses++;
1325
1375
  let rawCss;
1326
- let usedRustCompiler = false;
1327
- const theme = getThemeConfig();
1328
- rawCss = await generateCssNative(unique, { theme });
1329
- usedRustCompiler = true;
1376
+ try {
1377
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1378
+ } catch {
1379
+ rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
1380
+ }
1330
1381
  let finalCss = rawCss;
1331
1382
  if (minify) {
1332
1383
  if (minifier === "fast") {
@@ -1337,7 +1388,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
1337
1388
  }
1338
1389
  if (process.env.DEBUG?.includes("compiler")) {
1339
1390
  console.log(
1340
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1391
+ `[Compiler] Generated CSS from ${unique.length} classes`,
1341
1392
  `Size: ${finalCss.length} bytes`
1342
1393
  );
1343
1394
  }
@@ -1366,11 +1417,12 @@ function processTailwindCssWithTargets(css, targets) {
1366
1417
  return result.css;
1367
1418
  }
1368
1419
  var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1369
- var init_tailwindEngine = __esm({
1420
+ var init_tailwindEngine2 = __esm({
1370
1421
  "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1371
1422
  init_nativeBridge();
1372
1423
  init_cssGeneratorNative();
1373
1424
  init_cssCompilationNative();
1425
+ init_tailwindEngine();
1374
1426
  module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
1375
1427
  _cssCache = /* @__PURE__ */ new Map();
1376
1428
  _cacheHits = 0;
@@ -2855,7 +2907,7 @@ __export(internal_exports, {
2855
2907
  var init_internal = __esm({
2856
2908
  "packages/domain/compiler/src/internal.ts"() {
2857
2909
  init_src2();
2858
- init_tailwindEngine();
2910
+ init_tailwindEngine2();
2859
2911
  init_compiler();
2860
2912
  init_parser();
2861
2913
  init_analyzer();
@@ -3683,7 +3735,7 @@ var init_src2 = __esm({
3683
3735
  };
3684
3736
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
3685
3737
  try {
3686
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
3738
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
3687
3739
  const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
3688
3740
  return result.css;
3689
3741
  } catch {