weapp-tailwindcss 5.0.0-next.7 → 5.0.0-next.9
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/bundlers/shared/generator-css/directives.d.ts +2 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -0
- package/dist/{cache-DPN5yKSX.js → cache-BVAiJV3J.js} +5 -0
- package/dist/{cache-nq0_XJoS.mjs → cache-CHs4DXui.mjs} +5 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-TOp4uz7c.js → generator-DKkhJbOg.js} +3 -2
- package/dist/{generator-CzfdCZyd.mjs → generator-UBmfduYg.mjs} +3 -2
- package/dist/{generator-css-Dnpl-IY2.js → generator-css-Bwp3nbrl.js} +209 -146
- package/dist/{generator-css-B938WI9a.mjs → generator-css-DeLLmp2N.mjs} +204 -147
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +20 -5
- package/dist/gulp.mjs +20 -5
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-WsXlC7A-.js → postcss-QIXwT40c.js} +2 -2
- package/dist/{postcss-BtAP6sQO.mjs → postcss-w48mGIhe.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-Dka94ArV.js → precheck-B32p-gLI.js} +5 -5
- package/dist/{precheck-DlrmwCc-.mjs → precheck-B4RH6ZNN.mjs} +5 -5
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +3 -3
- package/dist/{runtime-patch-pGdCqAEu.mjs → runtime-patch-CwN5ya72.mjs} +1 -1
- package/dist/{runtime-patch-qwuisukL.js → runtime-patch-D6mBo_KB.js} +1 -1
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/{tailwindcss-T1U5T-iF.js → tailwindcss-Bu-RWIHx.js} +68 -3
- package/dist/{tailwindcss-BIJ185GB.mjs → tailwindcss-C5IgPlQ0.mjs} +57 -4
- package/dist/{vite-D0CoRblu.js → vite-By5KQi9s.js} +59 -27
- package/dist/{vite-BXChkciE.mjs → vite-Cyp42bBf.mjs} +59 -27
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +10 -1
- package/dist/{webpack-D-sUCY0u.js → webpack-BzN2ly34.js} +46 -10
- package/dist/{webpack-BNdGm9KL.mjs → webpack-DJazm5sT.mjs} +46 -10
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
- /package/dist/{utils-VZvGusYs.js → utils-BiShvil9.js} +0 -0
- /package/dist/{utils-BJjKRQgf.mjs → utils-Btw1iOVV.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_cache = require("./cache-
|
|
2
|
+
const require_cache = require("./cache-BVAiJV3J.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TailwindV4CssSource } from 'tailwindcss-patch';
|
|
2
|
+
import type { UserDefinedOptions } from '../../types';
|
|
3
|
+
export declare function hasCssSourcesValue(value: unknown): boolean;
|
|
4
|
+
export declare function hasConfiguredTailwindV4CssRoots(options: Pick<UserDefinedOptions, 'cssEntries' | 'tailwindcss' | 'tailwindcssPatcherOptions'>): boolean;
|
|
5
|
+
export declare function upsertTailwindV4CssSource(opts: UserDefinedOptions, source: TailwindV4CssSource): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_cache = require("./cache-
|
|
3
|
-
require("./utils-
|
|
2
|
+
const require_cache = require("./cache-BVAiJV3J.js");
|
|
3
|
+
require("./utils-BiShvil9.js");
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -10,6 +10,59 @@ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
|
10
10
|
let node_fs = require("node:fs");
|
|
11
11
|
let node_url = require("node:url");
|
|
12
12
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
13
|
+
//#region src/tailwindcss/v4/css-sources.ts
|
|
14
|
+
function hasCssEntriesValue(value) {
|
|
15
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
16
|
+
return Array.isArray(value) && value.some((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
17
|
+
}
|
|
18
|
+
function hasCssSourcesValue(value) {
|
|
19
|
+
return Array.isArray(value) && value.some((source) => {
|
|
20
|
+
return typeof source === "object" && source !== null && typeof source.css === "string" && source.css.trim().length > 0;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function hasConfiguredTailwindV4CssRoots(options) {
|
|
24
|
+
return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources);
|
|
25
|
+
}
|
|
26
|
+
function normalizeCssSourceFile(file) {
|
|
27
|
+
if (!file) return;
|
|
28
|
+
return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
|
|
29
|
+
}
|
|
30
|
+
function normalizeDependencies(dependencies) {
|
|
31
|
+
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
32
|
+
}
|
|
33
|
+
function isSameCssSource(a, b) {
|
|
34
|
+
return a.css === b.css && a.base === b.base && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
35
|
+
}
|
|
36
|
+
function upsertTailwindV4CssSource(opts, source) {
|
|
37
|
+
const normalizedSource = {
|
|
38
|
+
...source,
|
|
39
|
+
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
40
|
+
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
41
|
+
};
|
|
42
|
+
const tailwindcss = opts.tailwindcss ?? {};
|
|
43
|
+
const v4 = tailwindcss.v4 ?? {};
|
|
44
|
+
const cssSources = [...v4.cssSources ?? []];
|
|
45
|
+
const sourceFile = normalizeCssSourceFile(normalizedSource.file);
|
|
46
|
+
const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
|
|
47
|
+
if (existingIndex >= 0) {
|
|
48
|
+
const existing = cssSources[existingIndex];
|
|
49
|
+
const nextSource = {
|
|
50
|
+
...existing,
|
|
51
|
+
...normalizedSource
|
|
52
|
+
};
|
|
53
|
+
if (isSameCssSource(existing, nextSource)) return false;
|
|
54
|
+
cssSources[existingIndex] = nextSource;
|
|
55
|
+
} else cssSources.push(normalizedSource);
|
|
56
|
+
opts.tailwindcss = {
|
|
57
|
+
...tailwindcss,
|
|
58
|
+
v4: {
|
|
59
|
+
...v4,
|
|
60
|
+
cssSources
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
13
66
|
//#region src/tailwindcss/v4/config.ts
|
|
14
67
|
const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
15
68
|
function includesToken(list, token) {
|
|
@@ -71,7 +124,7 @@ let hasWarnedMissingCssEntries = false;
|
|
|
71
124
|
function warnMissingCssEntries(ctx, patcher) {
|
|
72
125
|
if (hasWarnedMissingCssEntries) return;
|
|
73
126
|
if (patcher?.majorVersion !== 4) return;
|
|
74
|
-
if (hasConfiguredCssEntries(ctx)) return;
|
|
127
|
+
if (hasConfiguredCssEntries(ctx) || hasConfiguredTailwindV4CssRoots(ctx)) return;
|
|
75
128
|
hasWarnedMissingCssEntries = true;
|
|
76
129
|
_weapp_tailwindcss_logger.logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
|
|
77
130
|
}
|
|
@@ -539,6 +592,12 @@ Object.defineProperty(exports, "createTailwindcssPatcherFromContext", {
|
|
|
539
592
|
return createTailwindcssPatcherFromContext;
|
|
540
593
|
}
|
|
541
594
|
});
|
|
595
|
+
Object.defineProperty(exports, "hasConfiguredTailwindV4CssRoots", {
|
|
596
|
+
enumerable: true,
|
|
597
|
+
get: function() {
|
|
598
|
+
return hasConfiguredTailwindV4CssRoots;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
542
601
|
Object.defineProperty(exports, "isUniAppXEnabled", {
|
|
543
602
|
enumerable: true,
|
|
544
603
|
get: function() {
|
|
@@ -557,6 +616,12 @@ Object.defineProperty(exports, "resolveUniAppXOptions", {
|
|
|
557
616
|
return resolveUniAppXOptions;
|
|
558
617
|
}
|
|
559
618
|
});
|
|
619
|
+
Object.defineProperty(exports, "upsertTailwindV4CssSource", {
|
|
620
|
+
enumerable: true,
|
|
621
|
+
get: function() {
|
|
622
|
+
return upsertTailwindV4CssSource;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
560
625
|
Object.defineProperty(exports, "warnMissingCssEntries", {
|
|
561
626
|
enumerable: true,
|
|
562
627
|
get: function() {
|
|
@@ -1,11 +1,64 @@
|
|
|
1
|
-
import { a as createTailwindcssPatcher, d as findWorkspaceRoot, i as runtimeSignaturePatchersSymbol, l as findNearestPackageRoot, o as readInstalledPackageMajorVersion, u as findWorkspacePackageDir } from "./cache-
|
|
2
|
-
import { n as defuOverrideArray } from "./utils-
|
|
1
|
+
import { a as createTailwindcssPatcher, d as findWorkspaceRoot, i as runtimeSignaturePatchersSymbol, l as findNearestPackageRoot, o as readInstalledPackageMajorVersion, u as findWorkspacePackageDir } from "./cache-CHs4DXui.mjs";
|
|
2
|
+
import { n as defuOverrideArray } from "./utils-Btw1iOVV.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
+
//#region src/tailwindcss/v4/css-sources.ts
|
|
10
|
+
function hasCssEntriesValue(value) {
|
|
11
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
12
|
+
return Array.isArray(value) && value.some((entry) => typeof entry === "string" && entry.trim().length > 0);
|
|
13
|
+
}
|
|
14
|
+
function hasCssSourcesValue(value) {
|
|
15
|
+
return Array.isArray(value) && value.some((source) => {
|
|
16
|
+
return typeof source === "object" && source !== null && typeof source.css === "string" && source.css.trim().length > 0;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function hasConfiguredTailwindV4CssRoots(options) {
|
|
20
|
+
return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources);
|
|
21
|
+
}
|
|
22
|
+
function normalizeCssSourceFile(file) {
|
|
23
|
+
if (!file) return;
|
|
24
|
+
return path.isAbsolute(file) ? path.normalize(file) : file;
|
|
25
|
+
}
|
|
26
|
+
function normalizeDependencies(dependencies) {
|
|
27
|
+
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
28
|
+
}
|
|
29
|
+
function isSameCssSource(a, b) {
|
|
30
|
+
return a.css === b.css && a.base === b.base && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
31
|
+
}
|
|
32
|
+
function upsertTailwindV4CssSource(opts, source) {
|
|
33
|
+
const normalizedSource = {
|
|
34
|
+
...source,
|
|
35
|
+
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
36
|
+
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
37
|
+
};
|
|
38
|
+
const tailwindcss = opts.tailwindcss ?? {};
|
|
39
|
+
const v4 = tailwindcss.v4 ?? {};
|
|
40
|
+
const cssSources = [...v4.cssSources ?? []];
|
|
41
|
+
const sourceFile = normalizeCssSourceFile(normalizedSource.file);
|
|
42
|
+
const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
|
|
43
|
+
if (existingIndex >= 0) {
|
|
44
|
+
const existing = cssSources[existingIndex];
|
|
45
|
+
const nextSource = {
|
|
46
|
+
...existing,
|
|
47
|
+
...normalizedSource
|
|
48
|
+
};
|
|
49
|
+
if (isSameCssSource(existing, nextSource)) return false;
|
|
50
|
+
cssSources[existingIndex] = nextSource;
|
|
51
|
+
} else cssSources.push(normalizedSource);
|
|
52
|
+
opts.tailwindcss = {
|
|
53
|
+
...tailwindcss,
|
|
54
|
+
v4: {
|
|
55
|
+
...v4,
|
|
56
|
+
cssSources
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
9
62
|
//#region src/tailwindcss/v4/config.ts
|
|
10
63
|
const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
11
64
|
function includesToken(list, token) {
|
|
@@ -67,7 +120,7 @@ let hasWarnedMissingCssEntries = false;
|
|
|
67
120
|
function warnMissingCssEntries(ctx, patcher) {
|
|
68
121
|
if (hasWarnedMissingCssEntries) return;
|
|
69
122
|
if (patcher?.majorVersion !== 4) return;
|
|
70
|
-
if (hasConfiguredCssEntries(ctx)) return;
|
|
123
|
+
if (hasConfiguredCssEntries(ctx) || hasConfiguredTailwindV4CssRoots(ctx)) return;
|
|
71
124
|
hasWarnedMissingCssEntries = true;
|
|
72
125
|
logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
|
|
73
126
|
}
|
|
@@ -523,4 +576,4 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
523
576
|
return createPatcherForBase(resolvedTailwindcssBasedir, normalizedCssEntries ?? rawCssEntries, patcherOptions);
|
|
524
577
|
}
|
|
525
578
|
//#endregion
|
|
526
|
-
export { applyV4CssCalcDefaults as a, resolveUniAppXOptions as i, resolveTailwindcssBasedir as n, warnMissingCssEntries as o, isUniAppXEnabled as r, createTailwindcssPatcherFromContext as t };
|
|
579
|
+
export { applyV4CssCalcDefaults as a, upsertTailwindV4CssSource as c, resolveUniAppXOptions as i, resolveTailwindcssBasedir as n, warnMissingCssEntries as o, isUniAppXEnabled as r, hasConfiguredTailwindV4CssRoots as s, createTailwindcssPatcherFromContext as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_cache = require("./cache-
|
|
3
|
-
const require_runtime_patch = require("./runtime-patch-
|
|
4
|
-
const require_generator = require("./generator-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
2
|
+
const require_cache = require("./cache-BVAiJV3J.js");
|
|
3
|
+
const require_runtime_patch = require("./runtime-patch-D6mBo_KB.js");
|
|
4
|
+
const require_generator = require("./generator-DKkhJbOg.js");
|
|
5
|
+
const require_generator_css = require("./generator-css-Bwp3nbrl.js");
|
|
6
|
+
const require_precheck = require("./precheck-B32p-gLI.js");
|
|
7
|
+
const require_utils = require("./utils-BiShvil9.js");
|
|
8
|
+
const require_tailwindcss = require("./tailwindcss-Bu-RWIHx.js");
|
|
9
9
|
const require_run_tasks = require("./run-tasks-B50A3pxt.js");
|
|
10
10
|
require("./logger-BRy6XPQ2.js");
|
|
11
11
|
let node_path = require("node:path");
|
|
@@ -1232,7 +1232,7 @@ function createGenerateBundleHook(context) {
|
|
|
1232
1232
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1233
1233
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
1234
1234
|
_weapp_tailwindcss_logger.logger.warn("检测到 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
1235
|
-
transformed = await templateHandler(rawSource, { runtimeSet: await context.ensureRuntimeClassSet(true) });
|
|
1235
|
+
transformed = await templateHandler(rawSource, { runtimeSet: new Set([...await context.ensureRuntimeClassSet(true), ...unresolvedDynamicCandidates]) });
|
|
1236
1236
|
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1237
1237
|
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
1238
1238
|
}
|
|
@@ -1667,8 +1667,9 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1667
1667
|
},
|
|
1668
1668
|
transform: {
|
|
1669
1669
|
order: "pre",
|
|
1670
|
-
handler(code, id) {
|
|
1670
|
+
async handler(code, id) {
|
|
1671
1671
|
if (!isCSSRequest(id)) return null;
|
|
1672
|
+
if (require_generator_css.hasTailwindRootDirectives(code)) await options.onTailwindRootCss?.(id, code);
|
|
1672
1673
|
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
1673
1674
|
join: joinPosixPath,
|
|
1674
1675
|
appType: resolveAppType(),
|
|
@@ -1705,9 +1706,10 @@ function collectChangedRuntimeFiles(snapshot) {
|
|
|
1705
1706
|
return new Set([...snapshot.runtimeAffectingChangedByType.html, ...snapshot.runtimeAffectingChangedByType.js]);
|
|
1706
1707
|
}
|
|
1707
1708
|
function resolveEntryExtension(entry) {
|
|
1709
|
+
if (entry.type === "html") return "html";
|
|
1708
1710
|
const ext = entry.file.split(/[?#]/, 1)[0]?.split(".").pop()?.replace(EXTENSION_DOT_PREFIX_RE, "") ?? "";
|
|
1709
1711
|
if (ext.length > 0) return ext;
|
|
1710
|
-
return
|
|
1712
|
+
return "js";
|
|
1711
1713
|
}
|
|
1712
1714
|
function createCandidateValidationSource(candidates) {
|
|
1713
1715
|
return [...new Set(candidates)].sort().join("\n");
|
|
@@ -2140,16 +2142,44 @@ const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
|
2140
2142
|
function WeappTailwindcss(options = {}) {
|
|
2141
2143
|
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
2142
2144
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
2143
|
-
const opts = require_precheck.getCompilerContext(
|
|
2145
|
+
const opts = require_precheck.getCompilerContext({
|
|
2146
|
+
...options,
|
|
2147
|
+
__internalDeferMissingCssEntriesWarning: true
|
|
2148
|
+
});
|
|
2144
2149
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher, uniAppX, disabledDefaultTemplateHandler } = opts;
|
|
2145
2150
|
const uniAppXEnabled = require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
2146
2151
|
const disabledOptions = require_run_tasks.resolvePluginDisabledState(disabled);
|
|
2147
2152
|
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
2148
2153
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
2149
2154
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
2155
|
+
const hasInitialTailwindCssRoots = require_tailwindcss.hasConfiguredTailwindV4CssRoots({
|
|
2156
|
+
...options,
|
|
2157
|
+
cssEntries: opts.cssEntries ?? options.cssEntries
|
|
2158
|
+
});
|
|
2159
|
+
const autoCssSourceContent = /* @__PURE__ */ new Map();
|
|
2160
|
+
let refreshRuntimeStateForAutoCssSources;
|
|
2161
|
+
let autoCssSourcesRefresh;
|
|
2162
|
+
const registerAutoCssSource = async (id, css) => {
|
|
2163
|
+
if (tailwindcssMajorVersion < 4 || !shouldOwnTailwindGeneration || hasInitialTailwindCssRoots) return;
|
|
2164
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
2165
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
2166
|
+
const sourceFile = node_path.default.normalize(file);
|
|
2167
|
+
if (autoCssSourceContent.get(sourceFile) === css) return;
|
|
2168
|
+
autoCssSourceContent.set(sourceFile, css);
|
|
2169
|
+
require_tailwindcss.upsertTailwindV4CssSource(opts, {
|
|
2170
|
+
file: sourceFile,
|
|
2171
|
+
css
|
|
2172
|
+
});
|
|
2173
|
+
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
2174
|
+
autoCssSourcesRefresh = (autoCssSourcesRefresh ?? Promise.resolve()).then(async () => {
|
|
2175
|
+
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
2176
|
+
});
|
|
2177
|
+
await autoCssSourcesRefresh;
|
|
2178
|
+
};
|
|
2150
2179
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
2151
2180
|
getAppType: () => opts.appType,
|
|
2152
2181
|
rootImport: shouldOwnTailwindGeneration ? `${weappTailwindcssDirPosix}/generator-placeholder.css` : void 0,
|
|
2182
|
+
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
2153
2183
|
shouldOwnTailwindGeneration,
|
|
2154
2184
|
shouldRewrite: shouldRewriteCssImports,
|
|
2155
2185
|
weappTailwindcssDirPosix
|
|
@@ -2173,6 +2203,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2173
2203
|
disabledDefaultTemplateHandler,
|
|
2174
2204
|
debug
|
|
2175
2205
|
});
|
|
2206
|
+
refreshRuntimeStateForAutoCssSources = refreshRuntimeState;
|
|
2176
2207
|
onLoad();
|
|
2177
2208
|
const getResolvedConfig = () => resolvedConfig;
|
|
2178
2209
|
const markCssAssetProcessed = (asset, file) => {
|
|
@@ -2210,6 +2241,22 @@ function WeappTailwindcss(options = {}) {
|
|
|
2210
2241
|
const setRememberedMainCssSignature = (file, cssRuntimeSignature) => {
|
|
2211
2242
|
rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
2212
2243
|
};
|
|
2244
|
+
const generateBundleHook = createGenerateBundleHook({
|
|
2245
|
+
opts,
|
|
2246
|
+
runtimeState,
|
|
2247
|
+
ensureRuntimeClassSet,
|
|
2248
|
+
ensureBundleRuntimeClassSet,
|
|
2249
|
+
debug,
|
|
2250
|
+
getResolvedConfig,
|
|
2251
|
+
markCssAssetProcessed,
|
|
2252
|
+
getSourceCandidates,
|
|
2253
|
+
waitForSourceCandidateSyncs,
|
|
2254
|
+
rememberMainCssSource,
|
|
2255
|
+
getRememberedMainCssSources,
|
|
2256
|
+
getRememberedMainCssSignature,
|
|
2257
|
+
setRememberedMainCssSignature,
|
|
2258
|
+
recordGeneratorCandidates
|
|
2259
|
+
});
|
|
2213
2260
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
2214
2261
|
opts,
|
|
2215
2262
|
runtimeState,
|
|
@@ -2349,22 +2396,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2349
2396
|
},
|
|
2350
2397
|
generateBundle: {
|
|
2351
2398
|
order: "post",
|
|
2352
|
-
handler:
|
|
2353
|
-
opts,
|
|
2354
|
-
runtimeState,
|
|
2355
|
-
ensureRuntimeClassSet,
|
|
2356
|
-
ensureBundleRuntimeClassSet,
|
|
2357
|
-
debug,
|
|
2358
|
-
getResolvedConfig,
|
|
2359
|
-
markCssAssetProcessed,
|
|
2360
|
-
getSourceCandidates,
|
|
2361
|
-
waitForSourceCandidateSyncs,
|
|
2362
|
-
rememberMainCssSource,
|
|
2363
|
-
getRememberedMainCssSources,
|
|
2364
|
-
getRememberedMainCssSignature,
|
|
2365
|
-
setRememberedMainCssSignature,
|
|
2366
|
-
recordGeneratorCandidates
|
|
2367
|
-
})
|
|
2399
|
+
handler: generateBundleHook
|
|
2368
2400
|
},
|
|
2369
2401
|
outputOptions(options) {
|
|
2370
2402
|
const plugins = options.plugins;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as resolveTailwindcssOptions, l as findNearestPackageRoot, n as getRuntimeClassSetSignature, s as findTailwindConfig } from "./cache-
|
|
2
|
-
import { n as createDebug } from "./runtime-patch-
|
|
3
|
-
import { d as filterUnsupportedMiniProgramTailwindV4Candidates, f as loadTailwindV4DesignSystem, i as normalizeWeappTailwindcssGeneratorOptions, s as resolveTailwindV4SourceFromPatcher } from "./generator-
|
|
4
|
-
import { a as
|
|
5
|
-
import { o as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { c as resolveTailwindcssOptions, l as findNearestPackageRoot, n as getRuntimeClassSetSignature, s as findTailwindConfig } from "./cache-CHs4DXui.mjs";
|
|
2
|
+
import { n as createDebug } from "./runtime-patch-CwN5ya72.mjs";
|
|
3
|
+
import { d as filterUnsupportedMiniProgramTailwindV4Candidates, f as loadTailwindV4DesignSystem, i as normalizeWeappTailwindcssGeneratorOptions, s as resolveTailwindV4SourceFromPatcher } from "./generator-UBmfduYg.mjs";
|
|
4
|
+
import { a as hasTailwindSourceDirectives, i as hasTailwindRootDirectives, n as validateCandidatesByGenerator, o as hasTailwindGeneratedCssMarkers, r as processCachedTask, t as generateCssByGenerator } from "./generator-css-DeLLmp2N.mjs";
|
|
5
|
+
import { a as analyzeSource, c as isClassContextLiteralPath, d as traverse$1, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-B4RH6ZNN.mjs";
|
|
6
|
+
import { o as resolveUniUtsPlatform } from "./utils-Btw1iOVV.mjs";
|
|
7
|
+
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-C5IgPlQ0.mjs";
|
|
8
8
|
import { a as resolveOutputSpecifier, i as normalizeOutputPathKey, n as resolvePackageDir, o as toAbsoluteOutputPath, r as resolvePluginDisabledState, t as pushConcurrentTaskFactories } from "./run-tasks-DdNi-hkk.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-Bub1jggA.mjs";
|
|
10
10
|
import path from "node:path";
|
|
@@ -1224,7 +1224,7 @@ function createGenerateBundleHook(context) {
|
|
|
1224
1224
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1225
1225
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
1226
1226
|
logger.warn("检测到 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
1227
|
-
transformed = await templateHandler(rawSource, { runtimeSet: await context.ensureRuntimeClassSet(true) });
|
|
1227
|
+
transformed = await templateHandler(rawSource, { runtimeSet: new Set([...await context.ensureRuntimeClassSet(true), ...unresolvedDynamicCandidates]) });
|
|
1228
1228
|
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1229
1229
|
if (unresolvedDynamicCandidates.length > 0) logger.warn("WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
1230
1230
|
}
|
|
@@ -1659,8 +1659,9 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1659
1659
|
},
|
|
1660
1660
|
transform: {
|
|
1661
1661
|
order: "pre",
|
|
1662
|
-
handler(code, id) {
|
|
1662
|
+
async handler(code, id) {
|
|
1663
1663
|
if (!isCSSRequest(id)) return null;
|
|
1664
|
+
if (hasTailwindRootDirectives(code)) await options.onTailwindRootCss?.(id, code);
|
|
1664
1665
|
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
1665
1666
|
join: joinPosixPath,
|
|
1666
1667
|
appType: resolveAppType(),
|
|
@@ -1697,9 +1698,10 @@ function collectChangedRuntimeFiles(snapshot) {
|
|
|
1697
1698
|
return new Set([...snapshot.runtimeAffectingChangedByType.html, ...snapshot.runtimeAffectingChangedByType.js]);
|
|
1698
1699
|
}
|
|
1699
1700
|
function resolveEntryExtension(entry) {
|
|
1701
|
+
if (entry.type === "html") return "html";
|
|
1700
1702
|
const ext = entry.file.split(/[?#]/, 1)[0]?.split(".").pop()?.replace(EXTENSION_DOT_PREFIX_RE, "") ?? "";
|
|
1701
1703
|
if (ext.length > 0) return ext;
|
|
1702
|
-
return
|
|
1704
|
+
return "js";
|
|
1703
1705
|
}
|
|
1704
1706
|
function createCandidateValidationSource(candidates) {
|
|
1705
1707
|
return [...new Set(candidates)].sort().join("\n");
|
|
@@ -2132,16 +2134,44 @@ const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
|
2132
2134
|
function WeappTailwindcss(options = {}) {
|
|
2133
2135
|
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
2134
2136
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
2135
|
-
const opts = getCompilerContext(
|
|
2137
|
+
const opts = getCompilerContext({
|
|
2138
|
+
...options,
|
|
2139
|
+
__internalDeferMissingCssEntriesWarning: true
|
|
2140
|
+
});
|
|
2136
2141
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher, uniAppX, disabledDefaultTemplateHandler } = opts;
|
|
2137
2142
|
const uniAppXEnabled = isUniAppXEnabled(uniAppX);
|
|
2138
2143
|
const disabledOptions = resolvePluginDisabledState(disabled);
|
|
2139
2144
|
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
2140
2145
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
2141
2146
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
2147
|
+
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
2148
|
+
...options,
|
|
2149
|
+
cssEntries: opts.cssEntries ?? options.cssEntries
|
|
2150
|
+
});
|
|
2151
|
+
const autoCssSourceContent = /* @__PURE__ */ new Map();
|
|
2152
|
+
let refreshRuntimeStateForAutoCssSources;
|
|
2153
|
+
let autoCssSourcesRefresh;
|
|
2154
|
+
const registerAutoCssSource = async (id, css) => {
|
|
2155
|
+
if (tailwindcssMajorVersion < 4 || !shouldOwnTailwindGeneration || hasInitialTailwindCssRoots) return;
|
|
2156
|
+
const file = cleanUrl$1(id);
|
|
2157
|
+
if (!path.isAbsolute(file)) return;
|
|
2158
|
+
const sourceFile = path.normalize(file);
|
|
2159
|
+
if (autoCssSourceContent.get(sourceFile) === css) return;
|
|
2160
|
+
autoCssSourceContent.set(sourceFile, css);
|
|
2161
|
+
upsertTailwindV4CssSource(opts, {
|
|
2162
|
+
file: sourceFile,
|
|
2163
|
+
css
|
|
2164
|
+
});
|
|
2165
|
+
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
2166
|
+
autoCssSourcesRefresh = (autoCssSourcesRefresh ?? Promise.resolve()).then(async () => {
|
|
2167
|
+
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
2168
|
+
});
|
|
2169
|
+
await autoCssSourcesRefresh;
|
|
2170
|
+
};
|
|
2142
2171
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
2143
2172
|
getAppType: () => opts.appType,
|
|
2144
2173
|
rootImport: shouldOwnTailwindGeneration ? `${weappTailwindcssDirPosix}/generator-placeholder.css` : void 0,
|
|
2174
|
+
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
2145
2175
|
shouldOwnTailwindGeneration,
|
|
2146
2176
|
shouldRewrite: shouldRewriteCssImports,
|
|
2147
2177
|
weappTailwindcssDirPosix
|
|
@@ -2165,6 +2195,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2165
2195
|
disabledDefaultTemplateHandler,
|
|
2166
2196
|
debug
|
|
2167
2197
|
});
|
|
2198
|
+
refreshRuntimeStateForAutoCssSources = refreshRuntimeState;
|
|
2168
2199
|
onLoad();
|
|
2169
2200
|
const getResolvedConfig = () => resolvedConfig;
|
|
2170
2201
|
const markCssAssetProcessed = (asset, file) => {
|
|
@@ -2202,6 +2233,22 @@ function WeappTailwindcss(options = {}) {
|
|
|
2202
2233
|
const setRememberedMainCssSignature = (file, cssRuntimeSignature) => {
|
|
2203
2234
|
rememberedMainCssSignatureByFile.set(file, cssRuntimeSignature);
|
|
2204
2235
|
};
|
|
2236
|
+
const generateBundleHook = createGenerateBundleHook({
|
|
2237
|
+
opts,
|
|
2238
|
+
runtimeState,
|
|
2239
|
+
ensureRuntimeClassSet,
|
|
2240
|
+
ensureBundleRuntimeClassSet,
|
|
2241
|
+
debug,
|
|
2242
|
+
getResolvedConfig,
|
|
2243
|
+
markCssAssetProcessed,
|
|
2244
|
+
getSourceCandidates,
|
|
2245
|
+
waitForSourceCandidateSyncs,
|
|
2246
|
+
rememberMainCssSource,
|
|
2247
|
+
getRememberedMainCssSources,
|
|
2248
|
+
getRememberedMainCssSignature,
|
|
2249
|
+
setRememberedMainCssSignature,
|
|
2250
|
+
recordGeneratorCandidates
|
|
2251
|
+
});
|
|
2205
2252
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
2206
2253
|
opts,
|
|
2207
2254
|
runtimeState,
|
|
@@ -2341,22 +2388,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2341
2388
|
},
|
|
2342
2389
|
generateBundle: {
|
|
2343
2390
|
order: "post",
|
|
2344
|
-
handler:
|
|
2345
|
-
opts,
|
|
2346
|
-
runtimeState,
|
|
2347
|
-
ensureRuntimeClassSet,
|
|
2348
|
-
ensureBundleRuntimeClassSet,
|
|
2349
|
-
debug,
|
|
2350
|
-
getResolvedConfig,
|
|
2351
|
-
markCssAssetProcessed,
|
|
2352
|
-
getSourceCandidates,
|
|
2353
|
-
waitForSourceCandidateSyncs,
|
|
2354
|
-
rememberMainCssSource,
|
|
2355
|
-
getRememberedMainCssSources,
|
|
2356
|
-
getRememberedMainCssSignature,
|
|
2357
|
-
setRememberedMainCssSignature,
|
|
2358
|
-
recordGeneratorCandidates
|
|
2359
|
-
})
|
|
2391
|
+
handler: generateBundleHook
|
|
2360
2392
|
},
|
|
2361
2393
|
outputOptions(options) {
|
|
2362
2394
|
const plugins = options.plugins;
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-By5KQi9s.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-Cyp42bBf.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -41,6 +41,7 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
|
|
44
|
+
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
44
45
|
const getLoaderOptions = loader_utils.default.getOptions;
|
|
45
46
|
function joinPosixPath(base, subpath) {
|
|
46
47
|
if (base.endsWith("/")) return `${base}${subpath}`;
|
|
@@ -67,7 +68,15 @@ function transformCssImportRewriteSource(source, options) {
|
|
|
67
68
|
}
|
|
68
69
|
const WeappTwCssImportRewriteLoader = function(source) {
|
|
69
70
|
if (node_process.default.env.WEAPP_TW_LOADER_DEBUG) node_process.default.stdout.write(`[weapp-tw-css-import-rewrite-loader] executing for ${this.resourcePath}\n`);
|
|
70
|
-
|
|
71
|
+
const opt = getLoaderOptions(this);
|
|
72
|
+
const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
|
|
73
|
+
const registerTask = typeof input === "string" && TAILWIND_ROOT_DIRECTIVE_RE.test(input) ? opt?.tailwindcssImportRewrite?.registerCssSource?.({
|
|
74
|
+
file: this.resourcePath,
|
|
75
|
+
css: input
|
|
76
|
+
}) : void 0;
|
|
77
|
+
const transform = () => transformCssImportRewriteSource(source, opt);
|
|
78
|
+
if (registerTask && typeof registerTask.then === "function") return Promise.resolve(registerTask).then(transform);
|
|
79
|
+
return transform();
|
|
71
80
|
};
|
|
72
81
|
//#endregion
|
|
73
82
|
exports.default = WeappTwCssImportRewriteLoader;
|