weapp-tailwindcss 5.1.2 → 5.1.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/README.md +1 -1
- package/dist/auto-CrJJc5rK.mjs +13 -0
- package/dist/bundlers/gulp/index.d.ts +3 -3
- package/dist/bundlers/rspack/index.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +12 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +11 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +4 -1
- package/dist/cli.js +8 -8
- package/dist/cli.mjs +8 -8
- package/dist/{context-C-r8ki7x.mjs → context-Bkpmt3ja.mjs} +62 -36
- package/dist/{context-CH4HFZP2.js → context-DCVMkTRj.js} +76 -44
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro/postcss.js +2 -2
- package/dist/css-macro.js +3 -3
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-CmFBmxsr.js → defaults-DQhgnnn-.js} +1 -1
- package/dist/defaults.js +1 -1
- package/dist/framework/index.d.ts +7 -2
- package/dist/framework/platform.d.ts +2 -0
- package/dist/framework.js +39 -8
- package/dist/framework.mjs +33 -6
- package/dist/{generator-BsPIaLtV.mjs → generator-24-HgU9F.mjs} +5 -3
- package/dist/{generator-B6pUjNdD.js → generator-CilgHtxb.js} +6 -4
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-CTdcASq8.mjs → gulp-0RsqkF_d.mjs} +4 -4
- package/dist/{gulp-BBCeA7ky.js → gulp-Bogfnoki.js} +12 -11
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BRx-KnBh.mjs → hmr-timing-BRNaz8Od.mjs} +62 -166
- package/dist/{hmr-timing-Da1eI8S0.js → hmr-timing-BV6nFPoT.js} +65 -187
- package/dist/index.js +9 -4
- package/dist/index.mjs +7 -6
- package/dist/postcss-html-transform.js +2 -2
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets/shared.d.ts +4 -0
- package/dist/presets.js +32 -16
- package/dist/presets.mjs +28 -14
- package/dist/reset.js +2 -2
- package/dist/rspack.d.ts +3 -0
- package/dist/rspack.js +68 -0
- package/dist/rspack.mjs +62 -0
- package/dist/{source-candidate-scan-signature-Dugfplms.mjs → source-candidate-scan-signature-BB1hvW68.mjs} +12 -6
- package/dist/{source-candidate-scan-signature-BO6JSskQ.js → source-candidate-scan-signature-CaDT0gkj.js} +16 -9
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-B5mRo0-M.mjs → tailwindcss-D0JF0fuZ.mjs} +6 -6
- package/dist/{tailwindcss-dbrbY4cd.js → tailwindcss-D2xs4OEu.js} +11 -11
- package/dist/{transform-DeqFRp1D.mjs → transform-BP86eSZp.mjs} +19 -19
- package/dist/{transform-BLleu_bA.js → transform-CXCQ28Tc.js} +47 -47
- package/dist/{utils-BCa37Wqj.js → utils-D3h8j7Mk.js} +2 -2
- package/dist/{v4-engine-C3qSwQ-e.mjs → v4-engine-BuuYDXt1.mjs} +58 -118
- package/dist/{v4-engine-ON_oSLfO.js → v4-engine-CKtsdKxK.js} +66 -120
- package/dist/{vite-CXmUiI9f.mjs → vite-B1SlBmqO.mjs} +436 -73
- package/dist/{vite-Da4uEG_u.js → vite-BYgT1ir9.js} +443 -80
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +143 -216
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-CrFZmdo7.mjs → webpack-Bg6pefpb.mjs} +109 -18
- package/dist/{webpack-Cwqnznng.js → webpack-khSwkXP5.js} +115 -24
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +9 -4
- package/dist/auto-Ba6hDrse.mjs +0 -13
- /package/dist/{chunk-emK7D4bc.js → rolldown-runtime-emK7D4bc.js} +0 -0
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_v4_engine = require("./v4-engine-
|
|
4
|
-
const require_generator = require("./generator-
|
|
5
|
-
const require_utils = require("./utils-
|
|
6
|
-
const require_context = require("./context-
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
9
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
3
|
+
const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
|
|
4
|
+
const require_generator = require("./generator-CilgHtxb.js");
|
|
5
|
+
const require_utils = require("./utils-D3h8j7Mk.js");
|
|
6
|
+
const require_context = require("./context-DCVMkTRj.js");
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-BV6nFPoT.js");
|
|
9
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-CaDT0gkj.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
|
-
node_fs =
|
|
12
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
13
13
|
let node_path = require("node:path");
|
|
14
|
-
node_path =
|
|
14
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
15
15
|
let node_process = require("node:process");
|
|
16
|
-
node_process =
|
|
16
|
+
node_process = require_rolldown_runtime.__toESM(node_process);
|
|
17
17
|
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
18
18
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
19
19
|
let lru_cache = require("lru-cache");
|
|
20
20
|
let node_fs_promises = require("node:fs/promises");
|
|
21
21
|
let micromatch = require("micromatch");
|
|
22
|
-
micromatch =
|
|
22
|
+
micromatch = require_rolldown_runtime.__toESM(micromatch);
|
|
23
23
|
let node_buffer = require("node:buffer");
|
|
24
24
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
25
25
|
let comment_json = require("comment-json");
|
|
@@ -256,7 +256,7 @@ const UVUE_TS_RE = /\.uvue\.ts$/;
|
|
|
256
256
|
const JS_RE = /\.js$/;
|
|
257
257
|
const APP_JS_RE = /(?:^|\/)App\.js$/;
|
|
258
258
|
const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
|
|
259
|
-
const HARMONY_BUNDLE_MARKER_FILES = new Set([
|
|
259
|
+
const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
|
|
260
260
|
"import/app-service.ets",
|
|
261
261
|
"import/dynamic.ets",
|
|
262
262
|
"uni_modules/oh-package.json5"
|
|
@@ -515,10 +515,10 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
515
515
|
//#region src/uni-app-x/vite.ts
|
|
516
516
|
let transformUVuePromise;
|
|
517
517
|
function loadTransformUVue() {
|
|
518
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
518
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-CXCQ28Tc.js")).then((mod) => mod.transformUVue));
|
|
519
519
|
return transformUVuePromise;
|
|
520
520
|
}
|
|
521
|
-
const preprocessorLangs = new Set([
|
|
521
|
+
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
522
522
|
"scss",
|
|
523
523
|
"sass",
|
|
524
524
|
"less",
|
|
@@ -689,7 +689,7 @@ function createUniAppXPlugins(options) {
|
|
|
689
689
|
if (isHarmonyTarget) {
|
|
690
690
|
const cssSources = [];
|
|
691
691
|
const applyStyleSources = [...harmonyApplyStyleSources, ...collectUniAppXHarmonyApplyStyleSources(bundle)];
|
|
692
|
-
const applyUtilities = new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
692
|
+
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
693
693
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
694
694
|
const harmonyApplyCssFile = node_path.default.resolve(getResolvedConfig()?.root ?? node_process.default.cwd(), "uni-app-x-harmony-apply.css");
|
|
695
695
|
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), this);
|
|
@@ -755,9 +755,31 @@ function collectConfiguredTailwindV4CssSources(opts) {
|
|
|
755
755
|
const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
756
756
|
return require_v4_engine.filterTailwindV4CssSourceRoots([...opts.tailwindcss?.v4?.cssSources ?? [], ...runtimeCssSources]) ?? [];
|
|
757
757
|
}
|
|
758
|
+
function collectExplicitTailwindV4CssEntries(opts) {
|
|
759
|
+
const entries = [
|
|
760
|
+
...opts.cssEntries ?? [],
|
|
761
|
+
...opts.tailwindcss?.v4?.cssEntries ?? [],
|
|
762
|
+
...opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
763
|
+
];
|
|
764
|
+
return [...new Set(entries.filter((entry) => typeof entry === "string" && entry.length > 0))];
|
|
765
|
+
}
|
|
758
766
|
function collectConfiguredTailwindV4CssSourceEntries(opts, fallbackBase) {
|
|
759
767
|
const entries = [];
|
|
760
768
|
const seen = /* @__PURE__ */ new Set();
|
|
769
|
+
const explicitCssEntries = collectExplicitTailwindV4CssEntries(opts);
|
|
770
|
+
for (const cssEntry of explicitCssEntries.length > 1 ? explicitCssEntries : []) {
|
|
771
|
+
if (typeof cssEntry !== "string" || cssEntry.length === 0) continue;
|
|
772
|
+
const resolvedFile = node_path.default.isAbsolute(cssEntry) ? node_path.default.resolve(cssEntry) : node_path.default.resolve(fallbackBase, cssEntry);
|
|
773
|
+
if (!(0, node_fs.existsSync)(resolvedFile)) continue;
|
|
774
|
+
const source = (0, node_fs.readFileSync)(resolvedFile, "utf8");
|
|
775
|
+
const key = `${resolvedFile}\0${source}`;
|
|
776
|
+
if (seen.has(key)) continue;
|
|
777
|
+
seen.add(key);
|
|
778
|
+
entries.push({
|
|
779
|
+
file: resolvedFile,
|
|
780
|
+
source
|
|
781
|
+
});
|
|
782
|
+
}
|
|
761
783
|
for (const cssSource of collectConfiguredTailwindV4CssSources(opts)) {
|
|
762
784
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
763
785
|
const base = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, fallbackBase);
|
|
@@ -1103,12 +1125,14 @@ function createCssHandlerOptionsCache(options) {
|
|
|
1103
1125
|
const outputRoot = options.getOutputRoot?.();
|
|
1104
1126
|
const from = node_path.default.isAbsolute(file) ? file : outputRoot ? node_path.default.resolve(outputRoot, file) : file;
|
|
1105
1127
|
const extraOptions = options.getExtraOptions?.(file) ?? {};
|
|
1106
|
-
const
|
|
1128
|
+
const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
|
|
1129
|
+
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
|
|
1107
1130
|
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
1108
1131
|
if (cached) return cached;
|
|
1109
1132
|
const created = {
|
|
1110
1133
|
isMainChunk,
|
|
1111
1134
|
...extraOptions,
|
|
1135
|
+
...dynamicCssOptions,
|
|
1112
1136
|
postcssOptions: { options: { from } },
|
|
1113
1137
|
majorVersion: require_context.normalizeStyleHandlerMajorVersion(majorVersion),
|
|
1114
1138
|
sourceOptions: { outputRoot }
|
|
@@ -1188,8 +1212,15 @@ function createMatchedCssSourceOutputResolver(options) {
|
|
|
1188
1212
|
const { assetSourceFile, file, originalFileNames, resolveOutputFileFromMatchedCssSource } = options;
|
|
1189
1213
|
return (sourceFile) => {
|
|
1190
1214
|
if (!sourceFile) return;
|
|
1191
|
-
|
|
1192
|
-
|
|
1215
|
+
const cleanAssetSourceFile = assetSourceFile.replace(/[?#].*$/, "");
|
|
1216
|
+
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
1217
|
+
const sourceHasQuery = cleanSourceFile !== sourceFile;
|
|
1218
|
+
const resolvedSourceOutputFile = resolveOutputFileFromMatchedCssSource(sourceFile);
|
|
1219
|
+
if (require_source_candidate_scan_signature.normalizeOutputPathKey(cleanAssetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(cleanSourceFile) || originalFileNames?.some((originalFile) => require_source_candidate_scan_signature.normalizeOutputPathKey(originalFile.replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(cleanSourceFile))) {
|
|
1220
|
+
if (!sourceHasQuery && require_source_candidate_scan_signature.normalizeOutputPathKey(cleanAssetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(cleanSourceFile) && typeof resolvedSourceOutputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedSourceOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(file)) return resolvedSourceOutputFile;
|
|
1221
|
+
return file;
|
|
1222
|
+
}
|
|
1223
|
+
return resolvedSourceOutputFile;
|
|
1193
1224
|
};
|
|
1194
1225
|
}
|
|
1195
1226
|
function hasViteProcessedCssResultForSource(sourceFile, getViteProcessedCssAssetResults) {
|
|
@@ -1211,7 +1242,7 @@ function applyCssResultToBundle(options) {
|
|
|
1211
1242
|
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1212
1243
|
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1213
1244
|
}
|
|
1214
|
-
originalSource.source = importShellSource ??
|
|
1245
|
+
originalSource.source = importShellSource ?? "";
|
|
1215
1246
|
return;
|
|
1216
1247
|
}
|
|
1217
1248
|
const existingOutput = bundle[outputFile];
|
|
@@ -1942,7 +1973,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1942
1973
|
const sourceEntries = [];
|
|
1943
1974
|
for (const entry of snapshot.entries) {
|
|
1944
1975
|
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1945
|
-
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, new Set([root])));
|
|
1976
|
+
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
1946
1977
|
if (!matchedSubpackageRoot) continue;
|
|
1947
1978
|
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1948
1979
|
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
@@ -2111,8 +2142,17 @@ function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, option
|
|
|
2111
2142
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(options.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2112
2143
|
if (options.injectIntoMain === false) return false;
|
|
2113
2144
|
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2145
|
+
if (typeof options.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(options.outputFile) === targetFileKey) return true;
|
|
2114
2146
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || typeof options.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(options.outputFile) !== targetFileKey && opts.mainCssChunkMatcher(options.outputFile, opts.appType));
|
|
2115
2147
|
}
|
|
2148
|
+
function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputFile, subpackageRoots) {
|
|
2149
|
+
if (subpackageRoots) {
|
|
2150
|
+
const sourceIsSubpackage = isSubpackageOutputFile(sourceFile ?? file, subpackageRoots);
|
|
2151
|
+
const outputIsSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
2152
|
+
if (sourceIsSubpackage || outputIsSubpackage) return false;
|
|
2153
|
+
}
|
|
2154
|
+
return isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) || isSourceRootPrefixedOutputFile(file, outputFile) && isRootStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType);
|
|
2155
|
+
}
|
|
2116
2156
|
function isRootStyleOutputFile(file) {
|
|
2117
2157
|
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2118
2158
|
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
@@ -2121,7 +2161,7 @@ function isMiniProgramStyleOutputFile(file) {
|
|
|
2121
2161
|
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
2122
2162
|
}
|
|
2123
2163
|
function shouldPreserveMiniProgramImportShell(opts, file, css) {
|
|
2124
|
-
return (opts.appType === "taro" || opts.appType === "uni-app-vite" || opts.appType === "uni-app-x") && isMiniProgramStyleOutputFile(file) && opts.cssMatcher(file) &&
|
|
2164
|
+
return (opts.appType === "taro" || opts.appType === "uni-app-vite" || opts.appType === "uni-app-x") && isMiniProgramStyleOutputFile(file) && opts.cssMatcher(file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(css);
|
|
2125
2165
|
}
|
|
2126
2166
|
function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
2127
2167
|
if (opts.appType !== "taro") return;
|
|
@@ -2138,7 +2178,7 @@ function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
|
2138
2178
|
}
|
|
2139
2179
|
function shouldUseCssAssetAsMainInjectionTarget(opts, file, records) {
|
|
2140
2180
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2141
|
-
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile) === fileKey)) return
|
|
2181
|
+
if (!isRootStyleOutputFile(file) && records.some((record) => typeof record.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile) === fileKey)) return true;
|
|
2142
2182
|
if (!isRootStyleOutputFile(file)) return records.some((record) => record.injectIntoMain === true && typeof record.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile) === fileKey);
|
|
2143
2183
|
if (records.some((record) => {
|
|
2144
2184
|
if (record.injectIntoMain !== true) return false;
|
|
@@ -2186,6 +2226,12 @@ function collectBundleAssetFiles(bundle) {
|
|
|
2186
2226
|
}
|
|
2187
2227
|
return files;
|
|
2188
2228
|
}
|
|
2229
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2230
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2231
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2232
|
+
return output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2233
|
+
})?.[1];
|
|
2234
|
+
}
|
|
2189
2235
|
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2190
2236
|
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2191
2237
|
if (importedStyleFiles.size === 0) return false;
|
|
@@ -2205,6 +2251,13 @@ function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveVite
|
|
|
2205
2251
|
const resolvedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2206
2252
|
return resolvedOutputFile !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2207
2253
|
}
|
|
2254
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2255
|
+
const resolvedFromFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2256
|
+
if (!markerFile) return resolvedFromFile;
|
|
2257
|
+
const resolvedFromMarker = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2258
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2259
|
+
return resolvedFromFile;
|
|
2260
|
+
}
|
|
2208
2261
|
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2209
2262
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2210
2263
|
const outputFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
@@ -2221,11 +2274,31 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2221
2274
|
let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
2222
2275
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
2223
2276
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
2277
|
+
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
2224
2278
|
if (nextCss !== rawSource) output.source = nextCss;
|
|
2225
2279
|
options.markCssAssetProcessed?.(output, file);
|
|
2226
2280
|
options.recordCssAssetResult?.(file, nextCss);
|
|
2227
|
-
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile
|
|
2228
|
-
|
|
2281
|
+
const resolvedOutputFile = resolveViteGeneratedCssMarkerOutputFile(file, singleMarkerFile, existingAssetFiles, options.resolveViteProcessedCssOutputFile);
|
|
2282
|
+
if (singleMarkerFile && require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && !isRootStyleOutputFile(resolvedOutputFile) && existingAssetFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile))) {
|
|
2283
|
+
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
2284
|
+
if (targetAsset) {
|
|
2285
|
+
const targetRawSource = readAssetSource$2(targetAsset);
|
|
2286
|
+
const targetNextCss = appendCss$1(targetRawSource, (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(targetRawSource, nextCss).trim());
|
|
2287
|
+
if (targetNextCss !== targetRawSource) {
|
|
2288
|
+
targetAsset.source = targetNextCss;
|
|
2289
|
+
options.markCssAssetProcessed?.(targetAsset, resolvedOutputFile);
|
|
2290
|
+
options.recordCssAssetResult?.(resolvedOutputFile, targetNextCss);
|
|
2291
|
+
}
|
|
2292
|
+
clearAssetSource(output);
|
|
2293
|
+
options.recordCssAssetResult?.(file, "");
|
|
2294
|
+
options.recordViteProcessedCssAssetResult?.(resolvedOutputFile, targetNextCss, { outputFile: resolvedOutputFile });
|
|
2295
|
+
if (isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, options.resolveViteProcessedCssOutputFile)) delete bundle[bundleFile];
|
|
2296
|
+
options.debug?.("move vite-generated css asset by marker source: %s -> %s bytes=%d", file, resolvedOutputFile, nextCss.length);
|
|
2297
|
+
collected++;
|
|
2298
|
+
continue;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
const shouldReplayIntoMainCss = options.opts != null && shouldReplayViteProcessedCssIntoMainCss(options.opts, file, singleMarkerFile, resolvedOutputFile, options.subpackageRoots);
|
|
2229
2302
|
options.recordViteProcessedCssAssetResult?.(file, nextCss, {
|
|
2230
2303
|
injectIntoMain: shouldReplayIntoMainCss || void 0,
|
|
2231
2304
|
outputFile: resolvedOutputFile
|
|
@@ -2550,7 +2623,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2550
2623
|
const generated = await require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
2551
2624
|
opts,
|
|
2552
2625
|
runtimeState,
|
|
2553
|
-
runtime: new Set([...generatorRuntime, ...applyUtilities]),
|
|
2626
|
+
runtime: /* @__PURE__ */ new Set([...generatorRuntime, ...applyUtilities]),
|
|
2554
2627
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
2555
2628
|
file: outputFile,
|
|
2556
2629
|
outputFile,
|
|
@@ -2683,9 +2756,9 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2683
2756
|
const originOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile(bundleFile, output)) === require_source_candidate_scan_signature.normalizeOutputPathKey(originFile))?.[1];
|
|
2684
2757
|
if (originOutput?.type !== "asset") continue;
|
|
2685
2758
|
const rootSource = readAssetSource(rootOutput);
|
|
2686
|
-
if (
|
|
2759
|
+
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(rootSource)) continue;
|
|
2687
2760
|
const originSource = readAssetSource(originOutput);
|
|
2688
|
-
if (
|
|
2761
|
+
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(originSource)) {
|
|
2689
2762
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
2690
2763
|
if (importedFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootFile)) continue;
|
|
2691
2764
|
} else if (originSource.trim().length > 0 && originSource.trim() !== rootSource.trim()) continue;
|
|
@@ -2799,7 +2872,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
2799
2872
|
pruneLastCssResults(lastCssResultByFile, lastCssSourceHashByFile, activeViteCssCacheFiles);
|
|
2800
2873
|
pruneViteCssCaches?.({
|
|
2801
2874
|
activeFiles: activeViteCssCacheFiles,
|
|
2802
|
-
activeKnownSfcFiles: new Set([...snapshot.sourceHashByFile.keys(), ...snapshot.entries.map((entry) => entry.file)])
|
|
2875
|
+
activeKnownSfcFiles: /* @__PURE__ */ new Set([...snapshot.sourceHashByFile.keys(), ...snapshot.entries.map((entry) => entry.file)])
|
|
2803
2876
|
});
|
|
2804
2877
|
}
|
|
2805
2878
|
recordTimingDetail("state.update", stateUpdateStart);
|
|
@@ -2900,7 +2973,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2900
2973
|
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
2901
2974
|
const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
|
|
2902
2975
|
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
2903
|
-
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2976
|
+
const templateRuntime = currentRawDynamicCandidates.length > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2904
2977
|
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : require_source_candidate_scan_signature.createCandidateSignature(templateRuntime);
|
|
2905
2978
|
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
2906
2979
|
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
@@ -2926,7 +2999,7 @@ function processHtmlBundleEntry(options) {
|
|
|
2926
2999
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
2927
3000
|
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
2928
3001
|
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
2929
|
-
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
3002
|
+
retryRuntimeSet = /* @__PURE__ */ new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2930
3003
|
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
2931
3004
|
}
|
|
2932
3005
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
@@ -3141,6 +3214,15 @@ function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffe
|
|
|
3141
3214
|
function normalizeRememberedSourceIdentity(file) {
|
|
3142
3215
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3143
3216
|
}
|
|
3217
|
+
function selectBestRememberedCssSourceMatches(sources, outputFile, outputRoot, sourceRoot) {
|
|
3218
|
+
if (sources.length <= 1) return sources;
|
|
3219
|
+
const scoredMatches = sources.map((remembered) => ({
|
|
3220
|
+
remembered,
|
|
3221
|
+
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3222
|
+
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3223
|
+
const bestScore = scoredMatches[0]?.score;
|
|
3224
|
+
return bestScore ? scoredMatches.filter((match) => match.score === bestScore).map((match) => match.remembered) : sources;
|
|
3225
|
+
}
|
|
3144
3226
|
function findRememberedCssSources(sources, outputFile, file, originalSource, outputRoot, sourceRoot) {
|
|
3145
3227
|
if (!sources) return [];
|
|
3146
3228
|
const rememberedSources = [...sources].map(([, remembered]) => remembered);
|
|
@@ -3148,7 +3230,7 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3148
3230
|
const markerFiles = new Set(require_source_candidate_scan_signature.parseBundlerGeneratedCssMarkerBlocks(source).filter((block) => block.bundler === "vite" && typeof block.file === "string" && block.file.length > 0).map((block) => require_source_candidate_scan_signature.normalizeOutputPathKey(block.file)));
|
|
3149
3231
|
if (markerFiles.size > 0) {
|
|
3150
3232
|
const markerMatched = rememberedSources.filter((remembered) => markerFiles.has(normalizeRememberedSourceIdentity(remembered.sourceFile)));
|
|
3151
|
-
if (markerMatched.length > 0) return markerMatched;
|
|
3233
|
+
if (markerMatched.length > 0) return selectBestRememberedCssSourceMatches(markerMatched, outputFile, outputRoot, sourceRoot);
|
|
3152
3234
|
}
|
|
3153
3235
|
const originalFiles = [
|
|
3154
3236
|
file,
|
|
@@ -3160,12 +3242,8 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3160
3242
|
const outputMatched = rememberedSources.filter((remembered) => require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
3161
3243
|
if (outputMatched.length > 0) return outputMatched;
|
|
3162
3244
|
if (!require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(source) && !hasTailwindGenerationSource(source)) return [];
|
|
3163
|
-
const scoredMatches = rememberedSources
|
|
3164
|
-
|
|
3165
|
-
score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
|
|
3166
|
-
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
3167
|
-
const bestScore = scoredMatches[0]?.score;
|
|
3168
|
-
return bestScore ? scoredMatches.filter((match) => match.score === bestScore).map((match) => match.remembered) : [];
|
|
3245
|
+
const scoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot);
|
|
3246
|
+
return scoredMatches.length === rememberedSources.length ? [] : scoredMatches;
|
|
3169
3247
|
}
|
|
3170
3248
|
function mergeRememberedCssSources(sources, outputFile) {
|
|
3171
3249
|
if (sources.length <= 1) return sources[0];
|
|
@@ -3400,7 +3478,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3400
3478
|
const isMainPackageStyleOutputFile = (file) => options.subpackageRoots != null && !isSubpackageOutputFile(file, options.subpackageRoots);
|
|
3401
3479
|
const resolveSubpackageOutputSourceEntries = (outputFile) => {
|
|
3402
3480
|
if (!options.subpackageRoots) return;
|
|
3403
|
-
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, new Set([root])));
|
|
3481
|
+
const matchedRoots = [...options.subpackageRoots].filter((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])));
|
|
3404
3482
|
if (matchedRoots.length !== 1) return;
|
|
3405
3483
|
const root = matchedRoots[0];
|
|
3406
3484
|
if (!root) return;
|
|
@@ -3461,7 +3539,7 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3461
3539
|
excludeEntries: [...filterOptions?.excludeEntries ?? [], ...subpackageSourceExcludeEntries]
|
|
3462
3540
|
}) ?? /* @__PURE__ */ new Map();
|
|
3463
3541
|
};
|
|
3464
|
-
const shouldInjectCssIntoMainFromOutput = (outputFile,
|
|
3542
|
+
const shouldInjectCssIntoMainFromOutput = (outputFile, sourceFile, outputCssHandlerOptions) => outputCssHandlerOptions.isMainChunk === true && !outputFile.replace(/[?#].*$/, "").includes("/") || options.useIncrementalMode && isMainPackageStyleOutputFile(outputFile) && isMainPackageStyleOutputFile(sourceFile);
|
|
3465
3543
|
return {
|
|
3466
3544
|
createScopedSourceCandidateGetter,
|
|
3467
3545
|
createScopedSourceCandidateSourceGetter,
|
|
@@ -3516,6 +3594,14 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
3516
3594
|
}
|
|
3517
3595
|
//#endregion
|
|
3518
3596
|
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3597
|
+
function createStableTextSignature(input) {
|
|
3598
|
+
let hash = 2166136261;
|
|
3599
|
+
for (let i = 0; i < input.length; i++) {
|
|
3600
|
+
hash ^= input.charCodeAt(i);
|
|
3601
|
+
hash = Math.imul(hash, 16777619);
|
|
3602
|
+
}
|
|
3603
|
+
return (hash >>> 0).toString(36);
|
|
3604
|
+
}
|
|
3519
3605
|
function collectTailwindV4SourceFingerprint(source) {
|
|
3520
3606
|
const tokens = /* @__PURE__ */ new Set();
|
|
3521
3607
|
const add = (prefix, value) => {
|
|
@@ -3527,6 +3613,22 @@ function collectTailwindV4SourceFingerprint(source) {
|
|
|
3527
3613
|
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3528
3614
|
}
|
|
3529
3615
|
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3616
|
+
for (const match of source.matchAll(/@plugin\s+(["'])(.+?)\1\s*(?:\{([\s\S]*?)\}|;)/g)) {
|
|
3617
|
+
const request = match[2];
|
|
3618
|
+
const optionBlock = match[3];
|
|
3619
|
+
add("plugin", request);
|
|
3620
|
+
add("plugin-request", request.replace(/\\/g, "/"));
|
|
3621
|
+
if (optionBlock !== void 0) add("plugin-options", `${request}:${createStableTextSignature(optionBlock)}`);
|
|
3622
|
+
}
|
|
3623
|
+
try {
|
|
3624
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("plugin", (rule) => {
|
|
3625
|
+
const request = /^(['"])(.+?)\1/.exec(rule.params.trim())?.[2];
|
|
3626
|
+
if (!request || !rule.nodes?.length) return;
|
|
3627
|
+
rule.walkDecls((decl) => {
|
|
3628
|
+
add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
|
|
3629
|
+
});
|
|
3630
|
+
});
|
|
3631
|
+
} catch {}
|
|
3530
3632
|
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3531
3633
|
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3532
3634
|
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
@@ -3544,7 +3646,7 @@ function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
|
3544
3646
|
}
|
|
3545
3647
|
function resolveSubpackageRootForFile(file, subpackageRoots) {
|
|
3546
3648
|
if (!file || !subpackageRoots) return;
|
|
3547
|
-
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3649
|
+
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, /* @__PURE__ */ new Set([root])));
|
|
3548
3650
|
}
|
|
3549
3651
|
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3550
3652
|
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
@@ -3567,7 +3669,7 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3567
3669
|
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
3568
3670
|
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, subpackageRoots);
|
|
3569
3671
|
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3570
|
-
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, new Set([root])) && isSubpackageOutputFile(entry.file, new Set([root])));
|
|
3672
|
+
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, /* @__PURE__ */ new Set([root])) && isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
3571
3673
|
}) : generationSources;
|
|
3572
3674
|
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3573
3675
|
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
@@ -3575,6 +3677,51 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3575
3677
|
return selectByRawSourceFingerprint(candidates);
|
|
3576
3678
|
}
|
|
3577
3679
|
//#endregion
|
|
3680
|
+
//#region src/bundlers/vite/generate-bundle/temporary-css-assets.ts
|
|
3681
|
+
function isTemporaryCssAssetFile(file) {
|
|
3682
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3683
|
+
return /\.css$/i.test(normalized) && !normalized.includes("/");
|
|
3684
|
+
}
|
|
3685
|
+
function normalizeCssSourceKey(file) {
|
|
3686
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3687
|
+
}
|
|
3688
|
+
function createTemporaryCssAssetSourceResolver(entries) {
|
|
3689
|
+
const seenEntryFiles = /* @__PURE__ */ new Set();
|
|
3690
|
+
const queuedEntries = entries.filter((entry) => {
|
|
3691
|
+
const entryFile = normalizeCssSourceKey(entry.file);
|
|
3692
|
+
const outputFile = normalizeCssSourceKey(entry.outputFile);
|
|
3693
|
+
if (outputFile === entryFile || !outputFile.includes("/") || seenEntryFiles.has(entryFile)) return false;
|
|
3694
|
+
seenEntryFiles.add(entryFile);
|
|
3695
|
+
return true;
|
|
3696
|
+
});
|
|
3697
|
+
const usedEntryFiles = /* @__PURE__ */ new Set();
|
|
3698
|
+
return {
|
|
3699
|
+
entries: queuedEntries,
|
|
3700
|
+
markUsed(sourceFile) {
|
|
3701
|
+
if (!sourceFile) return;
|
|
3702
|
+
usedEntryFiles.add(normalizeCssSourceKey(sourceFile));
|
|
3703
|
+
},
|
|
3704
|
+
resolve(outputFile, rawSource) {
|
|
3705
|
+
if (!isTemporaryCssAssetFile(outputFile)) return;
|
|
3706
|
+
const availableEntries = queuedEntries.filter((item) => !usedEntryFiles.has(normalizeCssSourceKey(item.file)));
|
|
3707
|
+
const scoredEntries = rawSource ? availableEntries.map((entry) => ({
|
|
3708
|
+
entry,
|
|
3709
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3710
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score) : [];
|
|
3711
|
+
const bestScore = scoredEntries[0]?.score;
|
|
3712
|
+
const bestEntries = bestScore ? scoredEntries.filter((item) => item.score === bestScore) : [];
|
|
3713
|
+
const entry = bestEntries.length === 1 ? bestEntries[0]?.entry : availableEntries.find((item) => hasTailwindGenerationSource(item.source));
|
|
3714
|
+
if (!entry) return;
|
|
3715
|
+
usedEntryFiles.add(normalizeCssSourceKey(entry.file));
|
|
3716
|
+
return {
|
|
3717
|
+
outputFile: entry.outputFile,
|
|
3718
|
+
rawSource: entry.source,
|
|
3719
|
+
sourceFile: entry.file
|
|
3720
|
+
};
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
}
|
|
3724
|
+
//#endregion
|
|
3578
3725
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
3579
3726
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
3580
3727
|
return async (name, task) => {
|
|
@@ -3778,12 +3925,13 @@ function createGenerateBundleHook(context) {
|
|
|
3778
3925
|
});
|
|
3779
3926
|
return async function generateBundle(_opt, bundle) {
|
|
3780
3927
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
3781
|
-
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownSfcSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
3928
|
+
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
3782
3929
|
const getBundlerSfcSource = (sourceFile) => {
|
|
3783
3930
|
const code = this.getModuleInfo?.(sourceFile)?.code;
|
|
3784
3931
|
return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
|
|
3785
3932
|
};
|
|
3786
3933
|
const getSfcSource = (sourceFile) => getBundlerSfcSource(sourceFile) ?? getKnownSfcSource?.(sourceFile);
|
|
3934
|
+
const getCssSource = (sourceFile) => getKnownCssSource?.(sourceFile) ?? getSourceCandidateSource?.(sourceFile);
|
|
3787
3935
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
3788
3936
|
const resolvedConfig = getResolvedConfig();
|
|
3789
3937
|
const uniUtsPlatform = require_utils.resolveUniUtsPlatform();
|
|
@@ -3919,7 +4067,7 @@ function createGenerateBundleHook(context) {
|
|
|
3919
4067
|
refreshBySource: forceV4RuntimeRefreshBySource
|
|
3920
4068
|
}) : await context.ensureRuntimeClassSet(envFlags.forceRuntimeRefreshByEnv);
|
|
3921
4069
|
const shouldFilterTailwindV4MiniProgramCandidates = require_generator.shouldUseMiniProgramCssBranch(generatorBranch);
|
|
3922
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
4070
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...sourceCandidates]);
|
|
3923
4071
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
3924
4072
|
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
3925
4073
|
const transformRuntime = shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
@@ -3955,7 +4103,7 @@ function createGenerateBundleHook(context) {
|
|
|
3955
4103
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
3956
4104
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
3957
4105
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
3958
|
-
const runtimeLinkedCssFiles = new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
4106
|
+
const runtimeLinkedCssFiles = /* @__PURE__ */ new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
3959
4107
|
rememberRuntimeLinkedCssSources({
|
|
3960
4108
|
bundleFiles,
|
|
3961
4109
|
debug,
|
|
@@ -3974,8 +4122,40 @@ function createGenerateBundleHook(context) {
|
|
|
3974
4122
|
snapshot,
|
|
3975
4123
|
sourceRoot
|
|
3976
4124
|
});
|
|
4125
|
+
const temporaryCssAssetSourceResolver = createTemporaryCssAssetSourceResolver([
|
|
4126
|
+
...[...runtimeLinkedCssFiles].filter((file) => !snapshot.sourceHashByFile.has(file)).map((file) => {
|
|
4127
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
4128
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
4129
|
+
return inferredSourceStyle && currentSubpackageRoots ? {
|
|
4130
|
+
file: inferredSourceStyle.sourceFile,
|
|
4131
|
+
outputFile,
|
|
4132
|
+
source: inferredSourceStyle.rawSource
|
|
4133
|
+
} : void 0;
|
|
4134
|
+
}).filter((entry) => entry != null),
|
|
4135
|
+
...[...getRememberedCssSources?.() ?? []].map(([, remembered]) => ({
|
|
4136
|
+
file: remembered.sourceFile,
|
|
4137
|
+
outputFile: remembered.outputFile,
|
|
4138
|
+
source: remembered.rawSource
|
|
4139
|
+
})),
|
|
4140
|
+
...getConfiguredTailwindV4CssSourceEntries().map((entry) => {
|
|
4141
|
+
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4142
|
+
return outputFile ? {
|
|
4143
|
+
file: entry.file,
|
|
4144
|
+
outputFile,
|
|
4145
|
+
source: entry.source
|
|
4146
|
+
} : void 0;
|
|
4147
|
+
}).filter((entry) => entry != null),
|
|
4148
|
+
...configuredTailwindV4CssSourceEntriesForScope.map((entry) => {
|
|
4149
|
+
const outputFile = resolveMatchedCssSourceOutputFile(entry.file);
|
|
4150
|
+
return outputFile && currentSubpackageRoots && isSubpackageOutputFile(outputFile, currentSubpackageRoots) ? {
|
|
4151
|
+
file: entry.file,
|
|
4152
|
+
outputFile,
|
|
4153
|
+
source: entry.source
|
|
4154
|
+
} : void 0;
|
|
4155
|
+
}).filter((entry) => entry != null)
|
|
4156
|
+
]);
|
|
3977
4157
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
3978
|
-
const dynamicRetryCandidates = new Set([
|
|
4158
|
+
const dynamicRetryCandidates = /* @__PURE__ */ new Set([
|
|
3979
4159
|
...sourceCandidates,
|
|
3980
4160
|
...generatorRuntime,
|
|
3981
4161
|
...transformRuntime
|
|
@@ -4074,6 +4254,7 @@ function createGenerateBundleHook(context) {
|
|
|
4074
4254
|
}
|
|
4075
4255
|
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
4076
4256
|
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
4257
|
+
let resolvedFromTemporaryCssAsset = false;
|
|
4077
4258
|
const applyCssResult = (source) => {
|
|
4078
4259
|
applyCssResultToBundle({
|
|
4079
4260
|
appType: opts.appType,
|
|
@@ -4115,14 +4296,39 @@ function createGenerateBundleHook(context) {
|
|
|
4115
4296
|
const rememberedSourcesBelongToInferredSfc = rememberedCssSources.length > 0 && rememberedCssSources.every((remembered) => normalizeSfcSourceFileForCompare(remembered.sourceFile) === inferredSourceFile);
|
|
4116
4297
|
if (!hasUsableRememberedTailwindSource || rememberedSourcesBelongToInferredSfc) rememberedCssSources = [inferredSfcStyleSource];
|
|
4117
4298
|
}
|
|
4299
|
+
if (isTemporaryCssAssetFile(outputFile) && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))))) {
|
|
4300
|
+
rememberedCssSources = [];
|
|
4301
|
+
hasUsableRememberedTailwindSource = false;
|
|
4302
|
+
}
|
|
4118
4303
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4119
4304
|
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile, currentSubpackageRoots))) {
|
|
4120
4305
|
rememberedCssSources = [];
|
|
4121
4306
|
hasUsableRememberedTailwindSource = false;
|
|
4122
4307
|
}
|
|
4308
|
+
if (isTemporaryCssAssetFile(outputFile) && hasTailwindGenerationSource(rawSource)) {
|
|
4309
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4310
|
+
if (resolvedTemporarySource) {
|
|
4311
|
+
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4312
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4313
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4314
|
+
outputCssHandlerOptions = {
|
|
4315
|
+
...outputCssHandlerOptions,
|
|
4316
|
+
isMainChunk: false
|
|
4317
|
+
};
|
|
4318
|
+
resolvedFromTemporaryCssAsset = true;
|
|
4319
|
+
usedConfiguredTailwindV4CssSourceFiles.add(require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
4320
|
+
rememberedCssSources = [{
|
|
4321
|
+
outputFile,
|
|
4322
|
+
rawSource: resolvedTemporarySource.rawSource,
|
|
4323
|
+
sourceFile: resolvedTemporarySource.sourceFile
|
|
4324
|
+
}];
|
|
4325
|
+
hasUsableRememberedTailwindSource = true;
|
|
4326
|
+
debug("source style source inferred from temporary remembered tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4123
4329
|
if (!hasUsableRememberedTailwindSource) {
|
|
4124
4330
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
4125
|
-
const inferredOriginalSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot,
|
|
4331
|
+
const inferredOriginalSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug) ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry) => [entry.file, entry.source]), debug));
|
|
4126
4332
|
if (inferredOriginalSourceStyle) {
|
|
4127
4333
|
outputFile = resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
4128
4334
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -4131,6 +4337,25 @@ function createGenerateBundleHook(context) {
|
|
|
4131
4337
|
...inferredOriginalSourceStyle,
|
|
4132
4338
|
outputFile
|
|
4133
4339
|
}];
|
|
4340
|
+
} else if (isTemporaryCssAssetFile(outputFile) && configuredTailwindV4CssSourceEntries.length > 1) {
|
|
4341
|
+
const resolvedTemporarySource = temporaryCssAssetSourceResolver.resolve(outputFile, rawSource);
|
|
4342
|
+
if (resolvedTemporarySource) {
|
|
4343
|
+
outputFile = resolveMatchedOutputFileForCurrentAsset(resolvedTemporarySource.sourceFile) ?? resolvedTemporarySource.outputFile;
|
|
4344
|
+
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
4345
|
+
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
4346
|
+
outputCssHandlerOptions = {
|
|
4347
|
+
...outputCssHandlerOptions,
|
|
4348
|
+
isMainChunk: false
|
|
4349
|
+
};
|
|
4350
|
+
resolvedFromTemporaryCssAsset = true;
|
|
4351
|
+
usedConfiguredTailwindV4CssSourceFiles.add(require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedTemporarySource.sourceFile));
|
|
4352
|
+
rememberedCssSources = [{
|
|
4353
|
+
outputFile,
|
|
4354
|
+
rawSource: resolvedTemporarySource.rawSource,
|
|
4355
|
+
sourceFile: resolvedTemporarySource.sourceFile
|
|
4356
|
+
}];
|
|
4357
|
+
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
4358
|
+
}
|
|
4134
4359
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
4135
4360
|
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file)));
|
|
4136
4361
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, currentSubpackageRoots);
|
|
@@ -4182,10 +4407,13 @@ function createGenerateBundleHook(context) {
|
|
|
4182
4407
|
const hasSameOutputRememberedTailwindGenerationSource = hasRememberedTailwindGenerationSource && rememberedCssSource != null && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedCssSource.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
4183
4408
|
const hasStaleViteProcessedCssSource = vitePipelineCssAsset && hasDifferentRememberedCssSource && (hasCurrentTailwindGenerationDirective || hasRememberedApplyDirective || hasRememberedTailwindGenerationSource);
|
|
4184
4409
|
const generatorSourceFile = vitePipelineCssAsset ? rememberedCssSource?.sourceFile ?? assetSourceFile : assetSourceFile;
|
|
4185
|
-
if (vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(generatorSourceFile.replace(/[?#].*$/, ""))))
|
|
4410
|
+
if (vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(generatorSourceFile.replace(/[?#].*$/, "")))) {
|
|
4411
|
+
usedConfiguredTailwindV4CssSourceFiles.add(require_source_candidate_scan_signature.normalizeOutputPathKey(generatorSourceFile));
|
|
4412
|
+
temporaryCssAssetSourceResolver.markUsed(generatorSourceFile);
|
|
4413
|
+
}
|
|
4186
4414
|
const cssHandlerOptions = vitePipelineCssAsset ? {
|
|
4187
4415
|
...getCssHandlerOptions(generatorSourceFile),
|
|
4188
|
-
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
4416
|
+
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
4189
4417
|
} : getCssHandlerOptions(file);
|
|
4190
4418
|
const generatorCssHandlerOptions = {
|
|
4191
4419
|
...cssHandlerOptions,
|
|
@@ -4496,6 +4724,7 @@ function registerGeneratorDependencies(ctx, dependencies) {
|
|
|
4496
4724
|
function createCssHandlerOptions(opts, majorVersion, file) {
|
|
4497
4725
|
return {
|
|
4498
4726
|
...resolveUniAppXNativeCssHandlerOptions(opts),
|
|
4727
|
+
cssPreflight: opts.cssPreflight,
|
|
4499
4728
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
4500
4729
|
postcssOptions: { options: { from: file } },
|
|
4501
4730
|
...require_context.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
@@ -4519,6 +4748,9 @@ function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
|
4519
4748
|
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
4520
4749
|
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
4521
4750
|
}
|
|
4751
|
+
function finalizeWebCss(css, enabled, webCompat) {
|
|
4752
|
+
return enabled ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
|
|
4753
|
+
}
|
|
4522
4754
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
4523
4755
|
return {
|
|
4524
4756
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -4529,13 +4761,14 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4529
4761
|
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource, isViteProcessedCssAsset } = context;
|
|
4530
4762
|
const resolvedConfig = getResolvedConfig();
|
|
4531
4763
|
const uniUtsPlatform = require_utils.resolveUniUtsPlatform();
|
|
4532
|
-
const
|
|
4764
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
4533
4765
|
appType: opts.appType,
|
|
4534
4766
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4535
4767
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
4536
4768
|
uniAppX: opts.uniAppX,
|
|
4537
4769
|
uniUtsPlatform
|
|
4538
|
-
})
|
|
4770
|
+
});
|
|
4771
|
+
const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
4539
4772
|
appType: opts.appType,
|
|
4540
4773
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
4541
4774
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
@@ -4562,6 +4795,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4562
4795
|
recordCssAssetResult,
|
|
4563
4796
|
recordViteProcessedCssAssetResult,
|
|
4564
4797
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
4798
|
+
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat),
|
|
4565
4799
|
debug
|
|
4566
4800
|
});
|
|
4567
4801
|
};
|
|
@@ -4581,7 +4815,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4581
4815
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
4582
4816
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
4583
4817
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
4584
|
-
const harmonyRuntime = new Set([...runtime, ...applyUtilities]);
|
|
4818
|
+
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
4585
4819
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css");
|
|
4586
4820
|
const generated = await require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
4587
4821
|
opts,
|
|
@@ -4628,13 +4862,13 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4628
4862
|
await runtimeState.readyPromise;
|
|
4629
4863
|
await waitForSourceCandidateSyncs?.();
|
|
4630
4864
|
const runtime = getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet();
|
|
4631
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4865
|
+
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
4632
4866
|
const generatorRuntime = require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
4633
4867
|
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
4634
4868
|
const file = output.fileName || bundleFile;
|
|
4635
4869
|
const rawSource = output.source.toString();
|
|
4636
4870
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
4637
|
-
const nextCss = annotateCss(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(rawSource));
|
|
4871
|
+
const nextCss = annotateCss(finalizeWebCss(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(rawSource), generatorBranch.isWeb, generatorOptions.webCompat));
|
|
4638
4872
|
output.source = nextCss;
|
|
4639
4873
|
markCssAssetProcessed(output, file);
|
|
4640
4874
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -4668,7 +4902,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
4668
4902
|
styleHandler: opts.styleHandler,
|
|
4669
4903
|
debug
|
|
4670
4904
|
}) : void 0;
|
|
4671
|
-
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4905
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(rawSource, true, generatorOptions.webCompat) : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
4672
4906
|
if (generated) {
|
|
4673
4907
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
4674
4908
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -4801,6 +5035,11 @@ function createViteCssMemory(options) {
|
|
|
4801
5035
|
if (source != null) touchMapEntry(knownSfcSources, key, source);
|
|
4802
5036
|
return source;
|
|
4803
5037
|
};
|
|
5038
|
+
const getKnownCssSource = (file) => {
|
|
5039
|
+
const source = knownCssSources.get(normalizeCssSourceIdentity(file));
|
|
5040
|
+
if (source != null) touchMapEntry(knownCssSources, normalizeCssSourceIdentity(file), source);
|
|
5041
|
+
return source;
|
|
5042
|
+
};
|
|
4804
5043
|
const rememberCssSource = (entry, cssRuntimeSignature) => {
|
|
4805
5044
|
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(entry.outputFile);
|
|
4806
5045
|
const normalizedSourceFile = normalizeCssSourceIdentity(entry.sourceFile);
|
|
@@ -4919,6 +5158,7 @@ function createViteCssMemory(options) {
|
|
|
4919
5158
|
};
|
|
4920
5159
|
return {
|
|
4921
5160
|
getKnownSfcSource,
|
|
5161
|
+
getKnownCssSource,
|
|
4922
5162
|
getRememberedCssSignature: (file) => rememberedCssSignatureByFile.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)),
|
|
4923
5163
|
getRememberedCssSourceEntry: (file) => rememberedCssSources.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)),
|
|
4924
5164
|
getRememberedCssSources: () => rememberedCssSources,
|
|
@@ -5305,7 +5545,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
5305
5545
|
}
|
|
5306
5546
|
//#endregion
|
|
5307
5547
|
//#region src/bundlers/vite/serve-css-generation.ts
|
|
5308
|
-
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5548
|
+
const SPECIAL_QUERY_RE$1 = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5309
5549
|
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
5310
5550
|
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
5311
5551
|
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
@@ -5336,10 +5576,10 @@ function replaceViteCssHmrModuleCss(code, css) {
|
|
|
5336
5576
|
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
5337
5577
|
}
|
|
5338
5578
|
function isViteServeStyleRequest(id, command) {
|
|
5339
|
-
return command === "serve" && require_source_candidate_scan_signature.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5579
|
+
return command === "serve" && require_source_candidate_scan_signature.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5340
5580
|
}
|
|
5341
5581
|
function isViteServeCssRootRequest(id, command) {
|
|
5342
|
-
return command === "serve" && require_source_candidate_scan_signature.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5582
|
+
return command === "serve" && require_source_candidate_scan_signature.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
5343
5583
|
}
|
|
5344
5584
|
function isViteCssHmrModule(code, id, command) {
|
|
5345
5585
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
@@ -5381,6 +5621,32 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
5381
5621
|
}];
|
|
5382
5622
|
}
|
|
5383
5623
|
//#endregion
|
|
5624
|
+
//#region src/bundlers/vite/serve-js-transform.ts
|
|
5625
|
+
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
5626
|
+
function isViteServeJsRequest(id, command) {
|
|
5627
|
+
if (command !== "serve" || SPECIAL_QUERY_RE.test(id) || require_source_candidate_scan_signature.isCSSRequest(id) || require_source_candidate_scan_signature.isHTMLRequest(id)) return false;
|
|
5628
|
+
return /\.(?:[cm]?[jt]sx?|vue|svelte)(?:$|\?)/.test(id);
|
|
5629
|
+
}
|
|
5630
|
+
function createViteServeJsTransformPlugin(options) {
|
|
5631
|
+
return {
|
|
5632
|
+
name: `${require_context.vitePluginName}:js:serve`,
|
|
5633
|
+
apply: "serve",
|
|
5634
|
+
enforce: "post",
|
|
5635
|
+
async transform(code, id) {
|
|
5636
|
+
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
5637
|
+
const handlerOptions = options.createHandlerOptions(id);
|
|
5638
|
+
if (require_context.shouldSkipJsTransform(code, handlerOptions)) return;
|
|
5639
|
+
const runtime = await options.transformRuntime();
|
|
5640
|
+
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
5641
|
+
if (transformed === code) return;
|
|
5642
|
+
return {
|
|
5643
|
+
code: transformed,
|
|
5644
|
+
map: null
|
|
5645
|
+
};
|
|
5646
|
+
}
|
|
5647
|
+
};
|
|
5648
|
+
}
|
|
5649
|
+
//#endregion
|
|
5384
5650
|
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
5385
5651
|
const PACKAGE_JSON_FILE = "package.json";
|
|
5386
5652
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
@@ -5407,6 +5673,30 @@ const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resol
|
|
|
5407
5673
|
const weappTailwindcssDirPosix = require_source_candidate_scan_signature.slash(weappTailwindcssPackageDir);
|
|
5408
5674
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
5409
5675
|
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
5676
|
+
const ENV_PLATFORM_KEYS = [
|
|
5677
|
+
"UNI_PLATFORM",
|
|
5678
|
+
"UNI_UTS_PLATFORM",
|
|
5679
|
+
"TARO_ENV",
|
|
5680
|
+
"MPX_CURRENT_TARGET_MODE",
|
|
5681
|
+
"MPX_CLI_MODE"
|
|
5682
|
+
];
|
|
5683
|
+
function sameStringList(first, second) {
|
|
5684
|
+
if (first === second) return true;
|
|
5685
|
+
if (!first || !second || first.length !== second.length) return false;
|
|
5686
|
+
return first.every((item, index) => item === second[index]);
|
|
5687
|
+
}
|
|
5688
|
+
function normalizeViteStylePlatform(value, appType) {
|
|
5689
|
+
return require_context.normalizeFrameworkStylePlatform(value, appType);
|
|
5690
|
+
}
|
|
5691
|
+
function inferPlatformFromOutDir(outDir) {
|
|
5692
|
+
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
5693
|
+
if (!segment) return;
|
|
5694
|
+
const normalized = segment.trim().toLowerCase();
|
|
5695
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
5696
|
+
}
|
|
5697
|
+
function isWebOrNativeAppPlatform(platform) {
|
|
5698
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
5699
|
+
}
|
|
5410
5700
|
/**
|
|
5411
5701
|
* @name WeappTailwindcss
|
|
5412
5702
|
* @description uni-app vite / uni-app-x 版本插件
|
|
@@ -5415,18 +5705,25 @@ const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CA
|
|
|
5415
5705
|
function WeappTailwindcss(options = {}) {
|
|
5416
5706
|
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
5417
5707
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
5708
|
+
const rawCssEntries = Array.isArray(options.cssEntries) ? [...options.cssEntries] : void 0;
|
|
5418
5709
|
const opts = require_context.getCompilerContext({
|
|
5419
5710
|
...options,
|
|
5420
5711
|
__internalDeferMissingCssEntriesWarning: true
|
|
5421
5712
|
});
|
|
5422
|
-
const
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5713
|
+
const syncCssEntriesFromAnchor = (anchor) => {
|
|
5714
|
+
var _opts$tailwindcss;
|
|
5715
|
+
const normalizedCssEntries = require_v4_engine.normalizeCssEntries(rawCssEntries, anchor ?? node_process.default.cwd());
|
|
5716
|
+
if (!normalizedCssEntries) return false;
|
|
5717
|
+
const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
|
|
5718
|
+
opts.cssEntries = normalizedCssEntries;
|
|
5426
5719
|
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
5427
5720
|
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
5428
|
-
|
|
5429
|
-
|
|
5721
|
+
opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5722
|
+
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5723
|
+
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
5724
|
+
return changed;
|
|
5725
|
+
};
|
|
5726
|
+
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
5430
5727
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler } = opts;
|
|
5431
5728
|
const initialTailwindRuntime = tailwindRuntime;
|
|
5432
5729
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
@@ -5448,6 +5745,28 @@ function WeappTailwindcss(options = {}) {
|
|
|
5448
5745
|
tailwindcssMajorVersion,
|
|
5449
5746
|
uniAppX
|
|
5450
5747
|
});
|
|
5748
|
+
const resolveViteStylePlatform = () => {
|
|
5749
|
+
const explicit = normalizeViteStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
5750
|
+
if (explicit) return explicit;
|
|
5751
|
+
for (const key of ENV_PLATFORM_KEYS) {
|
|
5752
|
+
const envPlatform = normalizeViteStylePlatform(node_process.default.env[key], opts.appType);
|
|
5753
|
+
if (envPlatform) return envPlatform;
|
|
5754
|
+
}
|
|
5755
|
+
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
5756
|
+
};
|
|
5757
|
+
const transformEarlyMiniProgramCss = (code) => {
|
|
5758
|
+
const platform = resolveViteStylePlatform();
|
|
5759
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return code;
|
|
5760
|
+
let transformedCode = code;
|
|
5761
|
+
if (transformedCode.includes("#if")) transformedCode = (0, _weapp_tailwindcss_postcss.compileCssMacroConditionalComments)(transformedCode, { platform: resolveViteStylePlatform() });
|
|
5762
|
+
if (transformedCode.includes("@layer")) transformedCode = (0, _weapp_tailwindcss_postcss.unwrapUnsupportedCascadeLayers)(transformedCode);
|
|
5763
|
+
return transformedCode;
|
|
5764
|
+
};
|
|
5765
|
+
const finalizeViteMiniProgramCss = (css) => {
|
|
5766
|
+
const platform = resolveViteStylePlatform();
|
|
5767
|
+
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : generatorBranch.isWeb)) return css;
|
|
5768
|
+
return (0, _weapp_tailwindcss_postcss.unwrapUnsupportedCascadeLayers)(css);
|
|
5769
|
+
};
|
|
5451
5770
|
const shouldInferAppType = !hasExplicitAppType && !generatorBranch.isWeb;
|
|
5452
5771
|
const hasInitialTailwindCssRoots = require_v4_engine.hasConfiguredTailwindV4CssRoots({
|
|
5453
5772
|
...options,
|
|
@@ -5475,6 +5794,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5475
5794
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
|
|
5476
5795
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
5477
5796
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
5797
|
+
cssMemory.refreshRememberedCssSourceBySourceFile(sourceFile, sourceCss);
|
|
5478
5798
|
const transientSource = {
|
|
5479
5799
|
file: sourceFile,
|
|
5480
5800
|
base: sourceBase,
|
|
@@ -5601,7 +5921,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5601
5921
|
root
|
|
5602
5922
|
}];
|
|
5603
5923
|
const normalizedRoot = node_path.default.resolve(root);
|
|
5604
|
-
const seenRoots = new Set([normalizedRoot]);
|
|
5924
|
+
const seenRoots = /* @__PURE__ */ new Set([normalizedRoot]);
|
|
5605
5925
|
const basedir = opts.tailwindcssBasedir ? node_path.default.resolve(opts.tailwindcssBasedir) : void 0;
|
|
5606
5926
|
if (basedir && !seenRoots.has(basedir)) {
|
|
5607
5927
|
roots.push({ root: basedir });
|
|
@@ -5782,7 +6102,12 @@ function WeappTailwindcss(options = {}) {
|
|
|
5782
6102
|
getExtraOptions: (file) => ({
|
|
5783
6103
|
...resolveViteCssHandlerExtraOptions(file),
|
|
5784
6104
|
...resolveUniAppXNativeCssHandlerOptions(opts)
|
|
5785
|
-
})
|
|
6105
|
+
}),
|
|
6106
|
+
getDynamicCssOptions: () => ({ cssPreflight: opts.cssPreflight })
|
|
6107
|
+
});
|
|
6108
|
+
const serveJsHandlerOptions = createJsHandlerOptionsFactory({
|
|
6109
|
+
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
6110
|
+
moduleGraph: void 0
|
|
5786
6111
|
});
|
|
5787
6112
|
const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
|
|
5788
6113
|
if (!shouldOwnTailwindGeneration) return;
|
|
@@ -5802,7 +6127,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
5802
6127
|
...transformCssHandlerOptions.getCssHandlerOptions(file),
|
|
5803
6128
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
5804
6129
|
};
|
|
5805
|
-
const transientCssSource = transientAutoCssSources.get(file)
|
|
6130
|
+
const transientCssSource = transientAutoCssSources.get(file) ?? (require_v4_engine.hasTailwindRootDirectives(code, { importFallback: generatorOptions.importFallback }) || require_v4_engine.hasTailwindSourceDirectives(code, { importFallback: generatorOptions.importFallback }) || require_v4_engine.hasTailwindApplyDirective(code) ? {
|
|
6131
|
+
base: node_path.default.dirname(node_path.default.resolve(file)),
|
|
6132
|
+
css: code,
|
|
6133
|
+
file: node_path.default.resolve(file)
|
|
6134
|
+
} : void 0);
|
|
5806
6135
|
const shouldDeferEmptyScopedCssSource = transientCssSource == null && !(opts.appType === "uni-app-x" && !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(code));
|
|
5807
6136
|
const generated = await require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
5808
6137
|
opts,
|
|
@@ -5821,7 +6150,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5821
6150
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource
|
|
5822
6151
|
});
|
|
5823
6152
|
if (!generated) return;
|
|
5824
|
-
const tracedCss = require_hmr_timing.annotateCssSourceTrace(generated.css, {
|
|
6153
|
+
const tracedCss = require_hmr_timing.annotateCssSourceTrace(finalizeViteMiniProgramCss(generated.css), {
|
|
5825
6154
|
opts,
|
|
5826
6155
|
tokenSources: require_hmr_timing.createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
5827
6156
|
});
|
|
@@ -5890,6 +6219,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5890
6219
|
getRememberedCssSources: cssMemory.getRememberedCssSources,
|
|
5891
6220
|
getRememberedCssSignature: cssMemory.getRememberedCssSignature,
|
|
5892
6221
|
setRememberedCssSignature: cssMemory.setRememberedCssSignature,
|
|
6222
|
+
getKnownCssSource: cssMemory.getKnownCssSource,
|
|
5893
6223
|
getKnownSfcSource: cssMemory.getKnownSfcSource,
|
|
5894
6224
|
recordGeneratorCandidates,
|
|
5895
6225
|
pruneViteCssCaches,
|
|
@@ -5944,20 +6274,45 @@ function WeappTailwindcss(options = {}) {
|
|
|
5944
6274
|
{
|
|
5945
6275
|
name: `${require_context.vitePluginName}:source-candidates`,
|
|
5946
6276
|
enforce: "pre",
|
|
5947
|
-
async
|
|
5948
|
-
if (shouldOwnTailwindGeneration)
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
6277
|
+
async load(id) {
|
|
6278
|
+
if (!shouldOwnTailwindGeneration || isWebOrNativeAppPlatform(resolveViteStylePlatform()) || !require_source_candidate_scan_signature.isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
6279
|
+
const rawCode = await (0, node_fs_promises.readFile)((0, _weapp_tailwindcss_shared.cleanUrl)(id), "utf8").catch(() => void 0);
|
|
6280
|
+
if (typeof rawCode !== "string") return;
|
|
6281
|
+
const transformedCode = transformEarlyMiniProgramCss(rawCode);
|
|
6282
|
+
if (transformedCode === rawCode) return;
|
|
6283
|
+
cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6284
|
+
return transformedCode;
|
|
6285
|
+
},
|
|
6286
|
+
transform: {
|
|
6287
|
+
order: "pre",
|
|
6288
|
+
async handler(code, id) {
|
|
6289
|
+
let transformedCode = code;
|
|
6290
|
+
if (shouldOwnTailwindGeneration && !generatorBranch.isWeb && require_source_candidate_scan_signature.isCSSRequest(id)) transformedCode = transformEarlyMiniProgramCss(code);
|
|
6291
|
+
const shouldReturnTransformedCode = transformedCode !== code;
|
|
6292
|
+
if (shouldOwnTailwindGeneration) cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
6293
|
+
if (!shouldOwnTailwindGeneration || !require_hmr_timing.isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) {
|
|
6294
|
+
if (shouldReturnTransformedCode) return {
|
|
6295
|
+
code: transformedCode,
|
|
6296
|
+
map: null
|
|
6297
|
+
};
|
|
5956
6298
|
return;
|
|
5957
6299
|
}
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
6300
|
+
return hmrTimingRecorder.measure("sourceCandidates.transform", async () => {
|
|
6301
|
+
invalidateRecordedGeneratorCandidates();
|
|
6302
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
6303
|
+
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
6304
|
+
sourceCandidateCollector.remove(file);
|
|
6305
|
+
cacheCurrentSourceCandidateScan();
|
|
6306
|
+
return;
|
|
6307
|
+
}
|
|
6308
|
+
await sourceCandidateCollector.merge(id, transformedCode);
|
|
6309
|
+
cacheCurrentSourceCandidateScan();
|
|
6310
|
+
if (shouldReturnTransformedCode) return {
|
|
6311
|
+
code: transformedCode,
|
|
6312
|
+
map: null
|
|
6313
|
+
};
|
|
6314
|
+
}, { emit: false });
|
|
6315
|
+
}
|
|
5961
6316
|
},
|
|
5962
6317
|
async watchChange(id, change) {
|
|
5963
6318
|
await hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
@@ -5997,6 +6352,13 @@ function WeappTailwindcss(options = {}) {
|
|
|
5997
6352
|
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
5998
6353
|
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
5999
6354
|
}),
|
|
6355
|
+
createViteServeJsTransformPlugin({
|
|
6356
|
+
createHandlerOptions: serveJsHandlerOptions,
|
|
6357
|
+
getCommand: () => resolvedConfig?.command,
|
|
6358
|
+
jsHandler,
|
|
6359
|
+
shouldTransform: () => shouldOwnTailwindGeneration && !generatorBranch.isWeb,
|
|
6360
|
+
transformRuntime: ensureRuntimeClassSet
|
|
6361
|
+
}),
|
|
6000
6362
|
{
|
|
6001
6363
|
name: `${require_context.vitePluginName}:post`,
|
|
6002
6364
|
enforce: "post",
|
|
@@ -6038,6 +6400,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6038
6400
|
if (opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
|
|
6039
6401
|
const previousBasedir = opts.tailwindcssBasedir;
|
|
6040
6402
|
opts.tailwindcssBasedir = nextTailwindcssBasedir;
|
|
6403
|
+
shouldRefreshRuntime = syncCssEntriesFromAnchor(nextTailwindcssBasedir) || shouldRefreshRuntime;
|
|
6041
6404
|
debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", nextTailwindcssBasedir);
|
|
6042
6405
|
shouldRefreshRuntime = true;
|
|
6043
6406
|
}
|