tailwind-styled-v4 5.0.34 → 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/compiler.js +60 -8
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +60 -8
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +60 -8
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +60 -8
- package/dist/engine.mjs.map +1 -1
- package/dist/index.js +60 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -8
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +64 -12
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +64 -12
- package/dist/next.mjs.map +1 -1
- package/dist/shared.js +60 -8
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +60 -8
- package/dist/shared.mjs.map +1 -1
- package/dist/turbopackLoader.js +60 -8
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +60 -8
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/vite.js +60 -8
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +60 -8
- package/dist/vite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/compiler.mjs
CHANGED
|
@@ -751,6 +751,56 @@ var init_streamingNative = __esm({
|
|
|
751
751
|
init_nativeBridge();
|
|
752
752
|
}
|
|
753
753
|
});
|
|
754
|
+
function loadTailwindEngine() {
|
|
755
|
+
if (_twEngine) return _twEngine;
|
|
756
|
+
if (_twEngineError) throw _twEngineError;
|
|
757
|
+
try {
|
|
758
|
+
const tw = require2("tailwindcss");
|
|
759
|
+
if (typeof tw.compile !== "function") {
|
|
760
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
761
|
+
}
|
|
762
|
+
_twEngine = tw;
|
|
763
|
+
return _twEngine;
|
|
764
|
+
} catch (e) {
|
|
765
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
766
|
+
throw _twEngineError;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
770
|
+
if (classes.length === 0) return "";
|
|
771
|
+
const tw = loadTailwindEngine();
|
|
772
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
773
|
+
const { readFileSync, existsSync: existsSync2 } = await import('fs');
|
|
774
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
775
|
+
const projectRoot = root ?? process.cwd();
|
|
776
|
+
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
777
|
+
const loadStylesheet = async (id, base) => {
|
|
778
|
+
try {
|
|
779
|
+
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;
|
|
780
|
+
const pkgPath = req.resolve(cssId);
|
|
781
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
|
|
782
|
+
} catch {
|
|
783
|
+
try {
|
|
784
|
+
const absPath = resolve2(base, id);
|
|
785
|
+
if (existsSync2(absPath)) {
|
|
786
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
787
|
+
}
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
return { content: "", base };
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
794
|
+
return compiler.build(classes);
|
|
795
|
+
}
|
|
796
|
+
var require2, _twEngine, _twEngineError;
|
|
797
|
+
var init_tailwindEngine = __esm({
|
|
798
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
799
|
+
require2 = createRequire(import.meta.url);
|
|
800
|
+
_twEngine = null;
|
|
801
|
+
_twEngineError = null;
|
|
802
|
+
}
|
|
803
|
+
});
|
|
754
804
|
|
|
755
805
|
// packages/domain/compiler/src/compiler/tailwindEngine.ts
|
|
756
806
|
var tailwindEngine_exports = {};
|
|
@@ -884,10 +934,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
884
934
|
}
|
|
885
935
|
_cacheMisses++;
|
|
886
936
|
let rawCss;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
937
|
+
try {
|
|
938
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
939
|
+
} catch {
|
|
940
|
+
rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
|
|
941
|
+
}
|
|
891
942
|
let finalCss = rawCss;
|
|
892
943
|
if (minify) {
|
|
893
944
|
if (minifier === "fast") {
|
|
@@ -898,7 +949,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
898
949
|
}
|
|
899
950
|
if (process.env.DEBUG?.includes("compiler")) {
|
|
900
951
|
console.log(
|
|
901
|
-
`[Compiler] Generated CSS from ${unique.length} classes
|
|
952
|
+
`[Compiler] Generated CSS from ${unique.length} classes`,
|
|
902
953
|
`Size: ${finalCss.length} bytes`
|
|
903
954
|
);
|
|
904
955
|
}
|
|
@@ -927,11 +978,12 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
927
978
|
return result.css;
|
|
928
979
|
}
|
|
929
980
|
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
930
|
-
var
|
|
981
|
+
var init_tailwindEngine2 = __esm({
|
|
931
982
|
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
932
983
|
init_nativeBridge();
|
|
933
984
|
init_cssGeneratorNative();
|
|
934
985
|
init_cssCompilationNative();
|
|
986
|
+
init_tailwindEngine();
|
|
935
987
|
createRequire(import.meta.url);
|
|
936
988
|
_cssCache = /* @__PURE__ */ new Map();
|
|
937
989
|
_cacheHits = 0;
|
|
@@ -948,7 +1000,7 @@ var init_compiler = __esm({
|
|
|
948
1000
|
init_cssCompilationNative();
|
|
949
1001
|
init_idRegistryNative();
|
|
950
1002
|
init_streamingNative();
|
|
951
|
-
|
|
1003
|
+
init_tailwindEngine2();
|
|
952
1004
|
}
|
|
953
1005
|
});
|
|
954
1006
|
|
|
@@ -1970,7 +2022,7 @@ var init_src2 = __esm({
|
|
|
1970
2022
|
};
|
|
1971
2023
|
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
1972
2024
|
try {
|
|
1973
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (
|
|
2025
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
|
|
1974
2026
|
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
1975
2027
|
return result.css;
|
|
1976
2028
|
} catch {
|