weapp-tailwindcss 5.1.0 → 5.1.2
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.en.md +2 -0
- package/README.md +2 -0
- package/dist/bundlers/shared/generator-css/class-selectors.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +6 -14
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/vite/css-memory.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +39 -0
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +26 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +25 -0
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +15 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -2
- package/dist/bundlers/vite/plugin-cache.d.ts +15 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +2 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +3 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +34 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +37 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +199 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +11 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
- package/dist/cli.js +15 -8
- package/dist/cli.mjs +15 -8
- package/dist/context/style-options.d.ts +1 -0
- package/dist/{context-Mbzkek1q.mjs → context-C-r8ki7x.mjs} +15 -10
- package/dist/{context-BHxLe743.js → context-CH4HFZP2.js} +20 -9
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/index.d.ts +3 -7
- package/dist/{defaults-ZElj1zKc.mjs → defaults-BhE26nSw.mjs} +7 -3
- package/dist/{defaults-CVcKbXBG.js → defaults-CmFBmxsr.js} +7 -3
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/generator/options.d.ts +3 -1
- package/dist/generator/types.d.ts +1 -1
- package/dist/{generator-9rUz4Hcb.js → generator-B6pUjNdD.js} +3 -1
- package/dist/{generator-Dc4qaPmT.mjs → generator-BsPIaLtV.mjs} +3 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B_sdP6dx.js → gulp-BBCeA7ky.js} +11 -9
- package/dist/{gulp-uM36oIJs.mjs → gulp-CTdcASq8.mjs} +11 -9
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BXMLsF4b.mjs → hmr-timing-BRx-KnBh.mjs} +128 -86
- package/dist/{hmr-timing-CogqkFaF.js → hmr-timing-Da1eI8S0.js} +138 -84
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidate-scan-signature-2ybpptAK.js → source-candidate-scan-signature-BO6JSskQ.js} +3 -3
- package/dist/{source-candidate-scan-signature-Cvb5z1ha.mjs → source-candidate-scan-signature-Dugfplms.mjs} +3 -3
- package/dist/tailwindcss/runtime-types.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +5 -14
- package/dist/tailwindcss/v4-engine/types.d.ts +10 -2
- package/dist/{tailwindcss-wyUHrfil.mjs → tailwindcss-B5mRo0-M.mjs} +12 -7
- package/dist/{tailwindcss-DHIYcqXT.js → tailwindcss-dbrbY4cd.js} +11 -6
- package/dist/{transform-CQVOgmzM.js → transform-BLleu_bA.js} +1 -1
- package/dist/{transform-tExdt40m.mjs → transform-DeqFRp1D.mjs} +1 -1
- package/dist/types/user-defined-options/matcher.d.ts +7 -0
- package/dist/{v4-engine-CF9zt4Cw.mjs → v4-engine-C3qSwQ-e.mjs} +7 -27
- package/dist/{v4-engine-D4ubP7N5.js → v4-engine-ON_oSLfO.js} +5 -31
- package/dist/{vite-CPO83EhA.mjs → vite-CXmUiI9f.mjs} +734 -393
- package/dist/{vite-CP0ylSxZ.js → vite-Da4uEG_u.js} +734 -392
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +130 -85
- package/dist/{webpack-BzqhJ8yK.mjs → webpack-CrFZmdo7.mjs} +923 -671
- package/dist/{webpack-Bsek8VhR.js → webpack-Cwqnznng.js} +923 -671
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_v4_engine = require("./v4-engine-
|
|
4
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_v4_engine = require("./v4-engine-ON_oSLfO.js");
|
|
4
|
+
const require_generator = require("./generator-B6pUjNdD.js");
|
|
5
5
|
const require_utils = require("./utils-BCa37Wqj.js");
|
|
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-
|
|
6
|
+
const require_context = require("./context-CH4HFZP2.js");
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-dbrbY4cd.js");
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-Da1eI8S0.js");
|
|
9
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BO6JSskQ.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -18,6 +18,8 @@ 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
|
+
let micromatch = require("micromatch");
|
|
22
|
+
micromatch = require_chunk.__toESM(micromatch);
|
|
21
23
|
let node_buffer = require("node:buffer");
|
|
22
24
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
23
25
|
let comment_json = require("comment-json");
|
|
@@ -513,7 +515,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
513
515
|
//#region src/uni-app-x/vite.ts
|
|
514
516
|
let transformUVuePromise;
|
|
515
517
|
function loadTransformUVue() {
|
|
516
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
518
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-BLleu_bA.js")).then((mod) => mod.transformUVue));
|
|
517
519
|
return transformUVuePromise;
|
|
518
520
|
}
|
|
519
521
|
const preprocessorLangs = new Set([
|
|
@@ -748,71 +750,6 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
748
750
|
};
|
|
749
751
|
}
|
|
750
752
|
//#endregion
|
|
751
|
-
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
752
|
-
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
753
|
-
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
754
|
-
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
755
|
-
const MUSTACHE_OPEN = "{{";
|
|
756
|
-
const MUSTACHE_CLOSE = "}}";
|
|
757
|
-
function isUrlLikeCandidate(candidate) {
|
|
758
|
-
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
759
|
-
}
|
|
760
|
-
function isArbitraryValueCandidate(candidate) {
|
|
761
|
-
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
762
|
-
}
|
|
763
|
-
function collectClassAttributeValues(source) {
|
|
764
|
-
const values = [];
|
|
765
|
-
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
766
|
-
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
767
|
-
while (matched !== null) {
|
|
768
|
-
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
769
|
-
const quote = source[quoteIndex];
|
|
770
|
-
if (quote !== "\"" && quote !== "'") {
|
|
771
|
-
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
772
|
-
continue;
|
|
773
|
-
}
|
|
774
|
-
let expressionDepth = 0;
|
|
775
|
-
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
776
|
-
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
777
|
-
expressionDepth++;
|
|
778
|
-
index += 1;
|
|
779
|
-
continue;
|
|
780
|
-
}
|
|
781
|
-
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
782
|
-
expressionDepth--;
|
|
783
|
-
index += 1;
|
|
784
|
-
continue;
|
|
785
|
-
}
|
|
786
|
-
if (expressionDepth === 0 && source[index] === quote) {
|
|
787
|
-
values.push(source.slice(quoteIndex + 1, index));
|
|
788
|
-
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
789
|
-
break;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
793
|
-
}
|
|
794
|
-
return values;
|
|
795
|
-
}
|
|
796
|
-
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
797
|
-
const matches = /* @__PURE__ */ new Set();
|
|
798
|
-
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
799
|
-
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
800
|
-
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
801
|
-
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
802
|
-
while (quoted !== null) {
|
|
803
|
-
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
804
|
-
for (const candidate of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal)) {
|
|
805
|
-
const normalized = candidate.trim();
|
|
806
|
-
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
807
|
-
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
808
|
-
matches.add(normalized);
|
|
809
|
-
}
|
|
810
|
-
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return [...matches];
|
|
814
|
-
}
|
|
815
|
-
//#endregion
|
|
816
753
|
//#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
|
|
817
754
|
function collectConfiguredTailwindV4CssSources(opts) {
|
|
818
755
|
const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
@@ -870,16 +807,15 @@ function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
|
870
807
|
//#region src/bundlers/vite/generate-bundle/css-assets.ts
|
|
871
808
|
function createCssAssetEmitter(context) {
|
|
872
809
|
return (fileName, source) => {
|
|
873
|
-
const replayAsset = createReplayCssAsset(fileName, source);
|
|
874
810
|
if (context.emitFile) {
|
|
875
811
|
context.emitFile({
|
|
876
812
|
type: "asset",
|
|
877
813
|
fileName,
|
|
878
814
|
source
|
|
879
815
|
});
|
|
880
|
-
return
|
|
816
|
+
return;
|
|
881
817
|
}
|
|
882
|
-
return
|
|
818
|
+
return createReplayCssAsset(fileName, source);
|
|
883
819
|
};
|
|
884
820
|
}
|
|
885
821
|
function resolveAssetSourceFile(asset, fallbackFile) {
|
|
@@ -899,6 +835,23 @@ const COMMON_MINI_PROGRAM_STYLE_OUTPUT_EXTENSIONS = [
|
|
|
899
835
|
".jxss",
|
|
900
836
|
".tyss"
|
|
901
837
|
];
|
|
838
|
+
function resolveCssOutputRealPath(value) {
|
|
839
|
+
const resolved = node_path.default.resolve(value);
|
|
840
|
+
let current = resolved;
|
|
841
|
+
const pendingSegments = [];
|
|
842
|
+
while (!(0, node_fs.existsSync)(current)) {
|
|
843
|
+
const parent = node_path.default.dirname(current);
|
|
844
|
+
if (parent === current) return resolved;
|
|
845
|
+
pendingSegments.unshift(node_path.default.basename(current));
|
|
846
|
+
current = parent;
|
|
847
|
+
}
|
|
848
|
+
try {
|
|
849
|
+
const realPath = node_fs.realpathSync.native(current);
|
|
850
|
+
return pendingSegments.length > 0 ? node_path.default.join(realPath, ...pendingSegments) : realPath;
|
|
851
|
+
} catch {
|
|
852
|
+
return resolved;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
902
855
|
function normalizeStyleOutputExtension(value) {
|
|
903
856
|
if (typeof value !== "string" || value.trim().length === 0) return;
|
|
904
857
|
const normalized = value.trim().toLowerCase();
|
|
@@ -938,7 +891,7 @@ function resolveStyleOutputFileFromFiles(files, cssMatcher, stem) {
|
|
|
938
891
|
if (!extension || extension === ".css") continue;
|
|
939
892
|
const outputStem = cleanFile.slice(0, -extension.length);
|
|
940
893
|
const outputStemSuffix = `/${outputStem}`;
|
|
941
|
-
if (outputStem === cleanStem || outputStem.endsWith(stemSuffix) || cleanStem.endsWith(outputStemSuffix)) matchedFiles.add(cleanFile);
|
|
894
|
+
if (outputStem === cleanStem || outputStem.endsWith(stemSuffix) || cleanStem.endsWith(outputStemSuffix) || cleanStem.endsWith(`/${outputStem}`)) matchedFiles.add(cleanFile);
|
|
942
895
|
}
|
|
943
896
|
return matchedFiles.size === 1 ? [...matchedFiles][0] : void 0;
|
|
944
897
|
}
|
|
@@ -946,7 +899,7 @@ function resolveMiniProgramStyleOutputExtension(options = {}) {
|
|
|
946
899
|
return resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher, options.stem) ?? resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher) ?? resolveStyleOutputExtensionFromMatcher(options.cssMatcher, options.stem) ?? normalizeStyleOutputExtension(options.fallback) ?? FALLBACK_STYLE_OUTPUT_EXTENSION;
|
|
947
900
|
}
|
|
948
901
|
function resolveReplayCssOutputFile(rootDir, file) {
|
|
949
|
-
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.isAbsolute(file) ? node_path.default.relative(rootDir, file) : file);
|
|
902
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.isAbsolute(file) ? node_path.default.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(file)) : file);
|
|
950
903
|
if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.basename(file));
|
|
951
904
|
return normalizedFile;
|
|
952
905
|
}
|
|
@@ -1017,6 +970,23 @@ function stripStyleFileExtension(file) {
|
|
|
1017
970
|
}
|
|
1018
971
|
//#endregion
|
|
1019
972
|
//#region src/bundlers/vite/generate-bundle/style-matching.ts
|
|
973
|
+
function resolveStyleMatchingRealPath(value) {
|
|
974
|
+
const resolved = node_path.default.resolve(value);
|
|
975
|
+
let current = resolved;
|
|
976
|
+
const pendingSegments = [];
|
|
977
|
+
while (!(0, node_fs.existsSync)(current)) {
|
|
978
|
+
const parent = node_path.default.dirname(current);
|
|
979
|
+
if (parent === current) return resolved;
|
|
980
|
+
pendingSegments.unshift(node_path.default.basename(current));
|
|
981
|
+
current = parent;
|
|
982
|
+
}
|
|
983
|
+
try {
|
|
984
|
+
const realPath = node_fs.realpathSync.native(current);
|
|
985
|
+
return pendingSegments.length > 0 ? node_path.default.join(realPath, ...pendingSegments) : realPath;
|
|
986
|
+
} catch {
|
|
987
|
+
return resolved;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
1020
990
|
function isMatchingCssSourceFile(outputFile, cssSourceFile, outputRoot) {
|
|
1021
991
|
return stripStyleFileExtension(node_path.default.resolve(outputRoot, outputFile)) === stripStyleFileExtension(node_path.default.resolve(cssSourceFile));
|
|
1022
992
|
}
|
|
@@ -1030,7 +1000,7 @@ function collectStyleFileMatchBases(file, roots) {
|
|
|
1030
1000
|
addBase(normalizedFile);
|
|
1031
1001
|
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
|
|
1032
1002
|
if (node_path.default.isAbsolute(normalizedFile)) for (const root of resolvedRoots) {
|
|
1033
|
-
const relative = node_path.default.relative(root, normalizedFile);
|
|
1003
|
+
const relative = node_path.default.relative(resolveStyleMatchingRealPath(root), resolveStyleMatchingRealPath(normalizedFile));
|
|
1034
1004
|
if (relative && !relative.startsWith("..") && !node_path.default.isAbsolute(relative)) addBase(relative);
|
|
1035
1005
|
}
|
|
1036
1006
|
else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
|
|
@@ -1140,7 +1110,7 @@ function createCssHandlerOptionsCache(options) {
|
|
|
1140
1110
|
isMainChunk,
|
|
1141
1111
|
...extraOptions,
|
|
1142
1112
|
postcssOptions: { options: { from } },
|
|
1143
|
-
majorVersion,
|
|
1113
|
+
majorVersion: require_context.normalizeStyleHandlerMajorVersion(majorVersion),
|
|
1144
1114
|
sourceOptions: { outputRoot }
|
|
1145
1115
|
};
|
|
1146
1116
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
@@ -1165,6 +1135,95 @@ function createCssHandlerOptionsCache(options) {
|
|
|
1165
1135
|
};
|
|
1166
1136
|
}
|
|
1167
1137
|
//#endregion
|
|
1138
|
+
//#region src/bundlers/vite/generate-bundle/root-style-output.ts
|
|
1139
|
+
function isRootMiniProgramStyleOutputFile$1(file) {
|
|
1140
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1141
|
+
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
1142
|
+
}
|
|
1143
|
+
function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
1144
|
+
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
1145
|
+
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
1146
|
+
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
1147
|
+
const baseDir = targetDir === "." ? "" : targetDir;
|
|
1148
|
+
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
1149
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
1150
|
+
}
|
|
1151
|
+
function createCssImportShell$1(targetFile, importedFile) {
|
|
1152
|
+
return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
|
|
1153
|
+
}
|
|
1154
|
+
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
1155
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1156
|
+
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
1157
|
+
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
1158
|
+
}
|
|
1159
|
+
function shouldKeepRootMiniProgramStyleAsImportShell(appType) {
|
|
1160
|
+
return appType === "uni-app-vite" || appType === "uni-app-x" || appType === "taro";
|
|
1161
|
+
}
|
|
1162
|
+
function shouldMoveRootMiniProgramStyleToImportShellOrigin(appType) {
|
|
1163
|
+
return appType === "taro";
|
|
1164
|
+
}
|
|
1165
|
+
//#endregion
|
|
1166
|
+
//#region src/bundlers/vite/generate-bundle/css-output-helpers.ts
|
|
1167
|
+
function resolveCssBundleOutputFile(options) {
|
|
1168
|
+
const { bundleFiles, defaultStyleOutputExtension, file, isWebGeneratorTarget, opts, shouldPreserveAppCssExtension } = options;
|
|
1169
|
+
let outputFile = resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, shouldPreserveAppCssExtension, defaultStyleOutputExtension, bundleFiles);
|
|
1170
|
+
if (outputFile === file && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(opts.appType)) outputFile = createRootMiniProgramOriginStyleOutputFile(file);
|
|
1171
|
+
return outputFile;
|
|
1172
|
+
}
|
|
1173
|
+
function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceFile = file, cssMatcher) {
|
|
1174
|
+
const source = rawSource.trim();
|
|
1175
|
+
if (source.length === 0) return false;
|
|
1176
|
+
if (canProcessViteSourceStyleAsCss(source, file)) return false;
|
|
1177
|
+
const isKnownStyleSource = require_source_candidate_scan_signature.isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
|
|
1178
|
+
return outputFile !== file || !isKnownStyleSource;
|
|
1179
|
+
}
|
|
1180
|
+
function resolveOutputFileFromMatchedCssSource(options) {
|
|
1181
|
+
const { bundleFiles, defaultStyleOutputExtension, isWebGeneratorTarget, opts, rootDir, shouldPreserveAppCssExtension, sourceFile, sourceRoot } = options;
|
|
1182
|
+
if (!sourceFile) return;
|
|
1183
|
+
if (isWebGeneratorTarget) return;
|
|
1184
|
+
const outputFile = resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
1185
|
+
return opts.cssMatcher(outputFile) ? outputFile : void 0;
|
|
1186
|
+
}
|
|
1187
|
+
function createMatchedCssSourceOutputResolver(options) {
|
|
1188
|
+
const { assetSourceFile, file, originalFileNames, resolveOutputFileFromMatchedCssSource } = options;
|
|
1189
|
+
return (sourceFile) => {
|
|
1190
|
+
if (!sourceFile) return;
|
|
1191
|
+
if (require_source_candidate_scan_signature.normalizeOutputPathKey(assetSourceFile.replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, "")) || originalFileNames?.some((originalFile) => require_source_candidate_scan_signature.normalizeOutputPathKey(originalFile.replace(/[?#].*$/, "")) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, "")))) return file;
|
|
1192
|
+
return resolveOutputFileFromMatchedCssSource(sourceFile);
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function hasViteProcessedCssResultForSource(sourceFile, getViteProcessedCssAssetResults) {
|
|
1196
|
+
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile);
|
|
1197
|
+
for (const [file] of getViteProcessedCssAssetResults?.() ?? []) if (require_source_candidate_scan_signature.normalizeOutputPathKey(file) === sourceKey) return true;
|
|
1198
|
+
return false;
|
|
1199
|
+
}
|
|
1200
|
+
function applyCssResultToBundle(options) {
|
|
1201
|
+
const { appType, assetSourceFile, bundle, emitOrReplayCssAsset, file, originalSource, outputFile, source, viteProcessedCssAsset } = options;
|
|
1202
|
+
if (outputFile === file) {
|
|
1203
|
+
originalSource.source = source;
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
const importShellSource = isRootMiniProgramStyleOutputFile$1(file) && isRootMiniProgramStyleOutputFile$1(outputFile) && shouldKeepRootMiniProgramStyleAsImportShell(appType) ? createCssImportShell$1(file, outputFile) : void 0;
|
|
1207
|
+
if (bundle[file] === originalSource && originalSource.originalFileNames?.includes(assetSourceFile)) {
|
|
1208
|
+
const existingOutput = bundle[outputFile];
|
|
1209
|
+
if (existingOutput?.type === "asset") existingOutput.source = source;
|
|
1210
|
+
else {
|
|
1211
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1212
|
+
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1213
|
+
}
|
|
1214
|
+
originalSource.source = importShellSource ?? source;
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const existingOutput = bundle[outputFile];
|
|
1218
|
+
if (existingOutput?.type === "asset") existingOutput.source = source;
|
|
1219
|
+
else {
|
|
1220
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1221
|
+
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1222
|
+
}
|
|
1223
|
+
if (!viteProcessedCssAsset && SOURCE_STYLE_OUTPUT_EXT_RE.test(file)) delete bundle[file];
|
|
1224
|
+
else originalSource.source = importShellSource ?? "";
|
|
1225
|
+
}
|
|
1226
|
+
//#endregion
|
|
1168
1227
|
//#region src/bundlers/vite/generate-bundle/css-share-scope.ts
|
|
1169
1228
|
const CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
|
|
1170
1229
|
const CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
|
|
@@ -1205,11 +1264,13 @@ function hasOmittedKnownBundleFiles(currentBundleFiles, previousBundleFiles) {
|
|
|
1205
1264
|
//#endregion
|
|
1206
1265
|
//#region src/bundlers/vite/generate-bundle/env-flags.ts
|
|
1207
1266
|
function resolveGenerateBundleEnvFlags() {
|
|
1267
|
+
const slowJsAstWarnMs = Number(node_process.default.env["WEAPP_TW_VITE_SLOW_JS_AST_WARN_MS"] ?? 1e3);
|
|
1208
1268
|
return {
|
|
1209
1269
|
forceRuntimeRefreshByEnv: node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1",
|
|
1210
1270
|
disableDirtyOptimization: node_process.default.env["WEAPP_TW_VITE_DISABLE_DIRTY"] === "1",
|
|
1211
1271
|
disableJsPrecheck: node_process.default.env["WEAPP_TW_VITE_DISABLE_JS_PRECHECK"] === "1",
|
|
1212
|
-
debugCssDiff: node_process.default.env["WEAPP_TW_VITE_DEBUG_CSS_DIFF"] === "1"
|
|
1272
|
+
debugCssDiff: node_process.default.env["WEAPP_TW_VITE_DEBUG_CSS_DIFF"] === "1",
|
|
1273
|
+
slowJsAstWarnMs: Number.isFinite(slowJsAstWarnMs) && slowJsAstWarnMs >= 0 ? slowJsAstWarnMs : 1e3
|
|
1213
1274
|
};
|
|
1214
1275
|
}
|
|
1215
1276
|
//#endregion
|
|
@@ -1687,7 +1748,6 @@ function hasTailwindGenerationSource(source, options = {}) {
|
|
|
1687
1748
|
}
|
|
1688
1749
|
function hasTailwindGenerationSourceForFile(file, source) {
|
|
1689
1750
|
if (require_v4_engine.isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
1690
|
-
if (require_v4_engine.hasTailwindRootImportDirectives(source, { importFallback: true })) return false;
|
|
1691
1751
|
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1692
1752
|
}
|
|
1693
1753
|
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
@@ -1716,7 +1776,7 @@ async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputR
|
|
|
1716
1776
|
function normalizeSfcSourceFileForCompare(file) {
|
|
1717
1777
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1718
1778
|
}
|
|
1719
|
-
function collectChunkModuleIds$
|
|
1779
|
+
function collectChunkModuleIds$2(output) {
|
|
1720
1780
|
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
1721
1781
|
return [
|
|
1722
1782
|
output.facadeModuleId,
|
|
@@ -1756,7 +1816,7 @@ function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, s
|
|
|
1756
1816
|
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1757
1817
|
return;
|
|
1758
1818
|
}
|
|
1759
|
-
const sourceFiles = collectChunkModuleIds$
|
|
1819
|
+
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1760
1820
|
if (sourceFiles.length === 0) {
|
|
1761
1821
|
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
1762
1822
|
return;
|
|
@@ -1776,7 +1836,7 @@ function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, s
|
|
|
1776
1836
|
return bestSources[0]?.sourceFile;
|
|
1777
1837
|
}
|
|
1778
1838
|
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
1779
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile);
|
|
1839
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
1780
1840
|
if (!siblingJsFile) {
|
|
1781
1841
|
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1782
1842
|
return;
|
|
@@ -1787,7 +1847,7 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
|
|
|
1787
1847
|
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1788
1848
|
return;
|
|
1789
1849
|
}
|
|
1790
|
-
const sourceFiles = collectChunkModuleIds$
|
|
1850
|
+
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1791
1851
|
if (sourceFiles.length === 0) {
|
|
1792
1852
|
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1793
1853
|
return;
|
|
@@ -1809,7 +1869,7 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
|
|
|
1809
1869
|
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
1810
1870
|
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1811
1871
|
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1812
|
-
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1872
|
+
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1813
1873
|
const scoredSources = [...getSourceStyleSources?.() ?? [], ...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1814
1874
|
file,
|
|
1815
1875
|
source,
|
|
@@ -1884,7 +1944,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1884
1944
|
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1885
1945
|
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, new Set([root])));
|
|
1886
1946
|
if (!matchedSubpackageRoot) continue;
|
|
1887
|
-
for (const moduleId of collectChunkModuleIds$
|
|
1947
|
+
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1888
1948
|
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
1889
1949
|
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
1890
1950
|
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
@@ -1918,7 +1978,7 @@ function readAssetSource$2(asset) {
|
|
|
1918
1978
|
function clearAssetSource(asset) {
|
|
1919
1979
|
asset.source = "";
|
|
1920
1980
|
}
|
|
1921
|
-
function appendCss(baseCss, css) {
|
|
1981
|
+
function appendCss$1(baseCss, css) {
|
|
1922
1982
|
if (baseCss.length === 0) return css;
|
|
1923
1983
|
if (css.length === 0) return baseCss;
|
|
1924
1984
|
return `${baseCss}\n${css}`;
|
|
@@ -2068,6 +2128,7 @@ function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
|
2068
2128
|
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2069
2129
|
if (importedStyleFiles.size !== 1) return;
|
|
2070
2130
|
const [importedFile] = importedStyleFiles;
|
|
2131
|
+
if (!importedFile) return;
|
|
2071
2132
|
if (!isRootStyleOutputFile(importedFile)) return;
|
|
2072
2133
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2073
2134
|
if (output.type !== "asset") continue;
|
|
@@ -2250,13 +2311,13 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2250
2311
|
let css = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(record.css).trim();
|
|
2251
2312
|
css = removeCssCoveredByImportedViteResults(css, importedCssSources).trim();
|
|
2252
2313
|
if (css.length === 0) continue;
|
|
2253
|
-
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css) || (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css).length === 0) continue;
|
|
2254
2314
|
const mergedLayerCss = require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
2255
2315
|
if (mergedLayerCss.merged) {
|
|
2256
2316
|
nextCss = mergedLayerCss.css;
|
|
2257
2317
|
css = require_hmr_timing.extractMarkedUserLayerComponentsCss(css).rest.trim();
|
|
2258
2318
|
if (css.length === 0) continue;
|
|
2259
2319
|
}
|
|
2320
|
+
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css) || (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css).length === 0) continue;
|
|
2260
2321
|
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css)) continue;
|
|
2261
2322
|
const mergedPreflightDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css);
|
|
2262
2323
|
if (mergedPreflightDeclarations.changed) {
|
|
@@ -2278,7 +2339,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2278
2339
|
}
|
|
2279
2340
|
const missingCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css);
|
|
2280
2341
|
if (missingCss.length === 0 || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss)) continue;
|
|
2281
|
-
nextCss = appendCss(nextCss, missingCss);
|
|
2342
|
+
nextCss = appendCss$1(nextCss, missingCss);
|
|
2282
2343
|
}
|
|
2283
2344
|
if (nextCss === originalSource) continue;
|
|
2284
2345
|
output.source = nextCss;
|
|
@@ -2351,9 +2412,9 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
2351
2412
|
cssOptions: {
|
|
2352
2413
|
...cssHandlerOptions.cssOptions ?? {},
|
|
2353
2414
|
autoprefixer: false,
|
|
2354
|
-
cssPresetEnv:
|
|
2415
|
+
cssPresetEnv: {}
|
|
2355
2416
|
},
|
|
2356
|
-
cssPresetEnv:
|
|
2417
|
+
cssPresetEnv: {}
|
|
2357
2418
|
});
|
|
2358
2419
|
const outputCss = (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(css);
|
|
2359
2420
|
if (outputCss === rawSource) continue;
|
|
@@ -2455,6 +2516,27 @@ function formatMs(value) {
|
|
|
2455
2516
|
}
|
|
2456
2517
|
//#endregion
|
|
2457
2518
|
//#region src/bundlers/vite/generate-bundle/uni-app-x-postprocess.ts
|
|
2519
|
+
function appendCss(baseCss, css) {
|
|
2520
|
+
if (baseCss.length === 0) return css;
|
|
2521
|
+
if (css.length === 0) return baseCss;
|
|
2522
|
+
return `${baseCss}\n${css}`;
|
|
2523
|
+
}
|
|
2524
|
+
function injectHarmonyCssIntoMainAsset(bundle, cssSources, onUpdate, debug) {
|
|
2525
|
+
const output = bundle["main.css"];
|
|
2526
|
+
if (output?.type !== "asset" || cssSources.length === 0) return false;
|
|
2527
|
+
const currentSource = String(output.source);
|
|
2528
|
+
let nextSource = currentSource;
|
|
2529
|
+
for (const css of cssSources) {
|
|
2530
|
+
const trimmedCss = css.trim();
|
|
2531
|
+
if (trimmedCss.length === 0 || nextSource.includes(trimmedCss)) continue;
|
|
2532
|
+
nextSource = appendCss(nextSource, trimmedCss);
|
|
2533
|
+
}
|
|
2534
|
+
if (nextSource === currentSource) return false;
|
|
2535
|
+
output.source = nextSource;
|
|
2536
|
+
onUpdate("main.css", currentSource, nextSource);
|
|
2537
|
+
debug("uni-app-x harmony main css inject");
|
|
2538
|
+
return true;
|
|
2539
|
+
}
|
|
2458
2540
|
async function handleUniAppXPostCssTasks(options) {
|
|
2459
2541
|
const { bundle, debug, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteProcessedCssAssetResults, isHarmonyAppStyleTarget, isNativeAppStyleTarget, onUpdate, opts, runtimeState, styleHandler } = options;
|
|
2460
2542
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
@@ -2487,6 +2569,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2487
2569
|
}));
|
|
2488
2570
|
}
|
|
2489
2571
|
if (isHarmonyAppStyleTarget && injectUniAppXHarmonyBundleStyles(bundle, { cssSources: viteProcessedCssSources })) debug("uni-app-x harmony bundle styles inject");
|
|
2572
|
+
if (isHarmonyAppStyleTarget) injectHarmonyCssIntoMainAsset(bundle, viteProcessedCssSources, onUpdate, debug);
|
|
2490
2573
|
for (const [file, item] of Object.entries(bundle)) {
|
|
2491
2574
|
if (item.type !== "asset" || !file.endsWith(".uvue.ts")) continue;
|
|
2492
2575
|
const currentSource = String(item.source);
|
|
@@ -2552,11 +2635,11 @@ function readAssetSource(asset) {
|
|
|
2552
2635
|
function getAssetFile(bundleFile, asset) {
|
|
2553
2636
|
return asset.fileName || bundleFile;
|
|
2554
2637
|
}
|
|
2555
|
-
function isRootMiniProgramStyleOutputFile
|
|
2638
|
+
function isRootMiniProgramStyleOutputFile(file) {
|
|
2556
2639
|
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2557
2640
|
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
2558
2641
|
}
|
|
2559
|
-
function createRelativeCssImportRequest
|
|
2642
|
+
function createRelativeCssImportRequest(targetFile, importedFile) {
|
|
2560
2643
|
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
2561
2644
|
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
2562
2645
|
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
@@ -2564,12 +2647,12 @@ function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
|
2564
2647
|
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
2565
2648
|
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
2566
2649
|
}
|
|
2567
|
-
function createCssImportShell
|
|
2568
|
-
return `@import "${createRelativeCssImportRequest
|
|
2650
|
+
function createCssImportShell(targetFile, importedFile) {
|
|
2651
|
+
return `@import "${createRelativeCssImportRequest(targetFile, importedFile)}";\n`;
|
|
2569
2652
|
}
|
|
2570
2653
|
function resolveRootMiniProgramOriginStyleFile(file) {
|
|
2571
2654
|
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2572
|
-
if (!isRootMiniProgramStyleOutputFile
|
|
2655
|
+
if (!isRootMiniProgramStyleOutputFile(normalized)) return;
|
|
2573
2656
|
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return;
|
|
2574
2657
|
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
2575
2658
|
}
|
|
@@ -2594,7 +2677,7 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2594
2677
|
for (const [rootBundleFile, rootOutput] of Object.entries(bundle)) {
|
|
2595
2678
|
if (rootOutput.type !== "asset") continue;
|
|
2596
2679
|
const rootFile = getAssetFile(rootBundleFile, rootOutput);
|
|
2597
|
-
if (!isRootMiniProgramStyleOutputFile
|
|
2680
|
+
if (!isRootMiniProgramStyleOutputFile(rootFile) || !options.cssMatcher(rootFile)) continue;
|
|
2598
2681
|
const originFile = resolveRootMiniProgramOriginStyleFile(rootFile);
|
|
2599
2682
|
if (!originFile || !options.cssMatcher(originFile)) continue;
|
|
2600
2683
|
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];
|
|
@@ -2606,7 +2689,7 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2606
2689
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
2607
2690
|
if (importedFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootFile)) continue;
|
|
2608
2691
|
} else if (originSource.trim().length > 0 && originSource.trim() !== rootSource.trim()) continue;
|
|
2609
|
-
const nextRootSource = createCssImportShell
|
|
2692
|
+
const nextRootSource = createCssImportShell(rootFile, originFile);
|
|
2610
2693
|
if (rootSource === nextRootSource) continue;
|
|
2611
2694
|
rootOutput.source = nextRootSource;
|
|
2612
2695
|
originOutput.source = rootSource;
|
|
@@ -2620,12 +2703,14 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2620
2703
|
return updated;
|
|
2621
2704
|
}
|
|
2622
2705
|
async function finalizeGenerateBundle(options) {
|
|
2623
|
-
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
|
|
2706
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
|
|
2707
|
+
const tasksStart = performance.now();
|
|
2624
2708
|
if (cssTaskFactories.length > 0) {
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2709
|
+
const cssTask = require_hmr_timing.runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
|
|
2710
|
+
if (jsAfterCss) await cssTask;
|
|
2711
|
+
else tasks.push(cssTask);
|
|
2627
2712
|
}
|
|
2628
|
-
|
|
2713
|
+
if (jsTaskFactories.length > 0) tasks.push(require_hmr_timing.runWithConcurrency(jsTaskFactories).then(() => void 0));
|
|
2629
2714
|
await Promise.all(tasks);
|
|
2630
2715
|
recordTimingDetail("tasks", tasksStart);
|
|
2631
2716
|
for (const apply of pendingLinkedUpdates) apply();
|
|
@@ -2745,6 +2830,120 @@ async function finalizeGenerateBundle(options) {
|
|
|
2745
2830
|
debug("end");
|
|
2746
2831
|
}
|
|
2747
2832
|
//#endregion
|
|
2833
|
+
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
2834
|
+
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
2835
|
+
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
2836
|
+
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
2837
|
+
const MUSTACHE_OPEN = "{{";
|
|
2838
|
+
const MUSTACHE_CLOSE = "}}";
|
|
2839
|
+
function isUrlLikeCandidate(candidate) {
|
|
2840
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
2841
|
+
}
|
|
2842
|
+
function isArbitraryValueCandidate(candidate) {
|
|
2843
|
+
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
2844
|
+
}
|
|
2845
|
+
function collectClassAttributeValues(source) {
|
|
2846
|
+
const values = [];
|
|
2847
|
+
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
2848
|
+
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2849
|
+
while (matched !== null) {
|
|
2850
|
+
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
2851
|
+
const quote = source[quoteIndex];
|
|
2852
|
+
if (quote !== "\"" && quote !== "'") {
|
|
2853
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2854
|
+
continue;
|
|
2855
|
+
}
|
|
2856
|
+
let expressionDepth = 0;
|
|
2857
|
+
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
2858
|
+
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
2859
|
+
expressionDepth++;
|
|
2860
|
+
index += 1;
|
|
2861
|
+
continue;
|
|
2862
|
+
}
|
|
2863
|
+
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
2864
|
+
expressionDepth--;
|
|
2865
|
+
index += 1;
|
|
2866
|
+
continue;
|
|
2867
|
+
}
|
|
2868
|
+
if (expressionDepth === 0 && source[index] === quote) {
|
|
2869
|
+
values.push(source.slice(quoteIndex + 1, index));
|
|
2870
|
+
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
2871
|
+
break;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2875
|
+
}
|
|
2876
|
+
return values;
|
|
2877
|
+
}
|
|
2878
|
+
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
2879
|
+
const matches = /* @__PURE__ */ new Set();
|
|
2880
|
+
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
2881
|
+
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
2882
|
+
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
2883
|
+
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
2884
|
+
while (quoted !== null) {
|
|
2885
|
+
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
2886
|
+
for (const candidate of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal)) {
|
|
2887
|
+
const normalized = candidate.trim();
|
|
2888
|
+
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
2889
|
+
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
2890
|
+
matches.add(normalized);
|
|
2891
|
+
}
|
|
2892
|
+
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
return [...matches];
|
|
2896
|
+
}
|
|
2897
|
+
//#endregion
|
|
2898
|
+
//#region src/bundlers/vite/generate-bundle/html-processing.ts
|
|
2899
|
+
function processHtmlBundleEntry(options) {
|
|
2900
|
+
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
2901
|
+
const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
|
|
2902
|
+
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
2903
|
+
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2904
|
+
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : require_source_candidate_scan_signature.createCandidateSignature(templateRuntime);
|
|
2905
|
+
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
2906
|
+
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
2907
|
+
const hashKey = cacheKey;
|
|
2908
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
2909
|
+
tasks.push(timeTask("html", () => require_hmr_timing.processCachedTask({
|
|
2910
|
+
cache,
|
|
2911
|
+
cacheKey,
|
|
2912
|
+
hashKey,
|
|
2913
|
+
hash: htmlProcessHash,
|
|
2914
|
+
applyResult(source) {
|
|
2915
|
+
originalSource.source = source;
|
|
2916
|
+
},
|
|
2917
|
+
onCacheHit() {
|
|
2918
|
+
metrics.html.cacheHits++;
|
|
2919
|
+
debug("html cache hit: %s", file);
|
|
2920
|
+
},
|
|
2921
|
+
async transform() {
|
|
2922
|
+
const start = performance.now();
|
|
2923
|
+
let transformed = await templateHandler(rawSource, { runtimeSet: templateRuntime });
|
|
2924
|
+
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
2925
|
+
let retryRuntimeSet;
|
|
2926
|
+
if (unresolvedDynamicCandidates.length > 0) {
|
|
2927
|
+
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
2928
|
+
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
2929
|
+
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2930
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
2931
|
+
}
|
|
2932
|
+
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
2933
|
+
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
2934
|
+
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
2935
|
+
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
2936
|
+
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
2937
|
+
}
|
|
2938
|
+
metrics.html.elapsed += measureElapsed(start);
|
|
2939
|
+
metrics.html.transformed++;
|
|
2940
|
+
onUpdate(file, rawSource, transformed);
|
|
2941
|
+
debug("html handle: %s", file);
|
|
2942
|
+
return { result: transformed };
|
|
2943
|
+
}
|
|
2944
|
+
})));
|
|
2945
|
+
}
|
|
2946
|
+
//#endregion
|
|
2748
2947
|
//#region src/bundlers/vite/generate-bundle/js-entries.ts
|
|
2749
2948
|
function createJsEntryResolver(jsEntries) {
|
|
2750
2949
|
const normalizedJsEntries = /* @__PURE__ */ new Map();
|
|
@@ -2801,7 +3000,7 @@ function collectLinkedFileNames(linked, getJsEntry, linkedSet) {
|
|
|
2801
3000
|
//#endregion
|
|
2802
3001
|
//#region src/bundlers/vite/generate-bundle/js-processing.ts
|
|
2803
3002
|
function processJsBundleEntry(options) {
|
|
2804
|
-
const { applyLinkedUpdates, bundle, cache, createHandlerOptions, debug, disableJsPrecheck, entry, getJsEntry, jsHandler, jsTaskFactories, linkedByEntry, metrics, onUpdate, outDir, processFiles, rememberProcessCacheKey, runtimeSignature, snapshot, timeTask, transformRuntime, uniAppX, useIncrementalMode } = options;
|
|
3003
|
+
const { applyLinkedUpdates, bundle, cache, createHandlerOptions, debug, disableJsPrecheck, entry, getJsEntry, jsHandler, jsTaskFactories, linkedByEntry, metrics, onUpdate, outDir, processFiles, rememberProcessCacheKey, runtimeSignature, snapshot, shouldSkipAstTransform, slowJsAstWarnMs, timeTask, transformRuntime, transformRuntimeSignature, transformFilterSignature, uniAppX, useIncrementalMode } = options;
|
|
2805
3004
|
const { file, output: originalSource, source: originalEntrySource } = entry;
|
|
2806
3005
|
metrics.js.total++;
|
|
2807
3006
|
const shouldTransformJs = !useIncrementalMode || processFiles.js.has(file);
|
|
@@ -2811,7 +3010,8 @@ function processJsBundleEntry(options) {
|
|
|
2811
3010
|
const initialRawSource = originalEntrySource;
|
|
2812
3011
|
const linkedSet = useIncrementalMode ? /* @__PURE__ */ new Set() : void 0;
|
|
2813
3012
|
if (linkedByEntry && linkedSet) linkedByEntry.set(file, linkedSet);
|
|
2814
|
-
const
|
|
3013
|
+
const linkedImpactSignature = useIncrementalMode ? require_source_candidate_scan_signature.createLinkedImpactSignature(file, snapshot.linkedImpactsByEntry, snapshot.sourceHashByFile) : void 0;
|
|
3014
|
+
const hashSalt = require_source_candidate_scan_signature.createJsHashSalt(`${transformRuntimeSignature}:transform-filter:${transformFilterSignature}`, linkedImpactSignature);
|
|
2815
3015
|
const hashKey = `${file}:js`;
|
|
2816
3016
|
const processHash = `${require_source_candidate_scan_signature.getSnapshotHash(snapshot.sourceHashByFile, file, initialRawSource)}:${hashSalt}`;
|
|
2817
3017
|
rememberProcessCacheKey(file, hashKey);
|
|
@@ -2842,15 +3042,24 @@ function processJsBundleEntry(options) {
|
|
|
2842
3042
|
const start = performance.now();
|
|
2843
3043
|
const rawSource = originalSource.code;
|
|
2844
3044
|
if (!shouldTransformJs) debug("js cache replay miss, fallback transform: %s", file);
|
|
3045
|
+
if (shouldSkipAstTransform?.(originalSource)) {
|
|
3046
|
+
metrics.js.elapsed += measureElapsed(start);
|
|
3047
|
+
metrics.js.transformed++;
|
|
3048
|
+
debug("js skip ast transform (filtered): %s", file);
|
|
3049
|
+
return { result: rawSource };
|
|
3050
|
+
}
|
|
2845
3051
|
const handlerOptions = createHandlerOptions(absoluteFile);
|
|
2846
3052
|
if (!disableJsPrecheck && require_context.shouldSkipJsTransform(rawSource, handlerOptions)) {
|
|
2847
3053
|
metrics.js.elapsed += measureElapsed(start);
|
|
2848
3054
|
metrics.js.transformed++;
|
|
2849
3055
|
return { result: rawSource };
|
|
2850
3056
|
}
|
|
3057
|
+
const handlerStart = performance.now();
|
|
2851
3058
|
const { code, linked } = await jsHandler(rawSource, transformRuntime, handlerOptions);
|
|
3059
|
+
const handlerElapsed = measureElapsed(handlerStart);
|
|
2852
3060
|
metrics.js.elapsed += measureElapsed(start);
|
|
2853
3061
|
metrics.js.transformed++;
|
|
3062
|
+
if (handlerElapsed >= slowJsAstWarnMs) _weapp_tailwindcss_logger.logger.warn("JS AST 转译耗时较长: %s 用时 %sms,源码约 %d bytes。若这是大型生成 TS/JS chunk,请配置 weapp-tailwindcss 的 transform.exclude 排除 generated/openapi 等目录。", file, handlerElapsed.toFixed(1), rawSource.length);
|
|
2854
3063
|
onUpdate(file, rawSource, code);
|
|
2855
3064
|
debug("js handle: %s", file);
|
|
2856
3065
|
collectLinkedFileNames(linked, getJsEntry, linkedSet);
|
|
@@ -2977,7 +3186,8 @@ function mergeRememberedCssSources(sources, outputFile) {
|
|
|
2977
3186
|
function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
2978
3187
|
const groups = /* @__PURE__ */ new Map();
|
|
2979
3188
|
for (const [key, remembered] of sources ?? []) {
|
|
2980
|
-
const
|
|
3189
|
+
const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
|
|
3190
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles));
|
|
2981
3191
|
const group = groups.get(outputKey) ?? [];
|
|
2982
3192
|
group.push({
|
|
2983
3193
|
key,
|
|
@@ -3060,7 +3270,7 @@ async function processRememberedCssReplay(options) {
|
|
|
3060
3270
|
}
|
|
3061
3271
|
if (shouldEmitRememberedReplayCssAsset) {
|
|
3062
3272
|
const replayAsset = emitOrReplayCssAsset(outputFile, css);
|
|
3063
|
-
markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3273
|
+
if (replayAsset) markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3064
3274
|
}
|
|
3065
3275
|
metrics.css.elapsed += measureElapsed(start);
|
|
3066
3276
|
metrics.css.transformed++;
|
|
@@ -3115,6 +3325,26 @@ function collectJsImportedCssFiles(snapshot) {
|
|
|
3115
3325
|
return files;
|
|
3116
3326
|
}
|
|
3117
3327
|
//#endregion
|
|
3328
|
+
//#region src/bundlers/vite/generate-bundle/runtime-linked-source-memory.ts
|
|
3329
|
+
function rememberRuntimeLinkedCssSources(options) {
|
|
3330
|
+
const { bundleFiles, defaultStyleOutputExtension, debug, getConfiguredTailwindV4CssSourceEntries, getSourceCandidateSource, getSourceCandidateSources, isWebGeneratorTarget, jsImportedCssFiles, opts, outDir, rememberCssSource, rootDir, runtimeLinkedCssFiles, shouldPreserveAppCssExtension, snapshot, sourceRoot } = options;
|
|
3331
|
+
for (const file of runtimeLinkedCssFiles) {
|
|
3332
|
+
if (snapshot.sourceHashByFile.has(file)) {
|
|
3333
|
+
snapshot.processFiles.css.add(file);
|
|
3334
|
+
continue;
|
|
3335
|
+
}
|
|
3336
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3337
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getSourceCandidateSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
3338
|
+
const rawSource = inferredSourceStyle?.rawSource ?? getSourceCandidateSource?.(node_path.default.resolve(outDir, file)) ?? getSourceCandidateSource?.(file);
|
|
3339
|
+
if (rawSource === void 0 || !hasTailwindGenerationSource(rawSource)) continue;
|
|
3340
|
+
rememberCssSource?.({
|
|
3341
|
+
outputFile,
|
|
3342
|
+
rawSource,
|
|
3343
|
+
sourceFile: inferredSourceStyle?.sourceFile ?? node_path.default.resolve(outDir, file)
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
//#endregion
|
|
3118
3348
|
//#region src/bundlers/vite/generate-bundle/source-candidate-scope.ts
|
|
3119
3349
|
function intersectCandidateSets(left, right) {
|
|
3120
3350
|
if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
|
|
@@ -3240,6 +3470,111 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3240
3470
|
};
|
|
3241
3471
|
}
|
|
3242
3472
|
//#endregion
|
|
3473
|
+
//#region src/bundlers/vite/generate-bundle/source-candidate-source.ts
|
|
3474
|
+
function normalizeSourceCandidatePathKey(file) {
|
|
3475
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve(file));
|
|
3476
|
+
}
|
|
3477
|
+
function resolveCurrentSourceCandidateSource(options) {
|
|
3478
|
+
const { file, getSourceCandidateSource, getSourceCandidateSources, outDir, rootDir, sourceRoot } = options;
|
|
3479
|
+
const cleanedFile = file.replace(/[?#].*$/, "");
|
|
3480
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(cleanedFile);
|
|
3481
|
+
const absoluteFile = node_path.default.isAbsolute(cleanedFile) ? cleanedFile : node_path.default.resolve(rootDir, cleanedFile);
|
|
3482
|
+
const relativeFromOutDir = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.relative(outDir, absoluteFile));
|
|
3483
|
+
const sourceCandidates = [
|
|
3484
|
+
sourceRoot ? node_path.default.resolve(sourceRoot, file) : void 0,
|
|
3485
|
+
node_path.default.resolve(rootDir, file),
|
|
3486
|
+
node_path.default.resolve(node_path.default.dirname(outDir), file),
|
|
3487
|
+
node_path.default.resolve(outDir, file),
|
|
3488
|
+
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(rootDir, relativeFromOutDir) : void 0,
|
|
3489
|
+
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(node_path.default.dirname(outDir), relativeFromOutDir) : void 0,
|
|
3490
|
+
file
|
|
3491
|
+
];
|
|
3492
|
+
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
3493
|
+
if (source || !candidate) return source;
|
|
3494
|
+
return getSourceCandidateSource?.(candidate);
|
|
3495
|
+
}, void 0);
|
|
3496
|
+
if (explicitSource) return explicitSource;
|
|
3497
|
+
const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
|
|
3498
|
+
absolute: node_path.default.isAbsolute(candidate),
|
|
3499
|
+
key: normalizeSourceCandidatePathKey(candidate)
|
|
3500
|
+
}));
|
|
3501
|
+
let bestSource;
|
|
3502
|
+
for (const [sourceFile, source] of getSourceCandidateSources?.() ?? []) {
|
|
3503
|
+
const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
|
|
3504
|
+
let score = 0;
|
|
3505
|
+
for (const candidate of normalizedSourceCandidates) if (normalizedSourceFile === candidate.key) {
|
|
3506
|
+
score = Math.max(score, candidate.absolute ? 100 : 80);
|
|
3507
|
+
continue;
|
|
3508
|
+
}
|
|
3509
|
+
if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
|
|
3510
|
+
if (score > (bestSource?.score ?? 0)) bestSource = {
|
|
3511
|
+
score,
|
|
3512
|
+
source
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
return bestSource?.source;
|
|
3516
|
+
}
|
|
3517
|
+
//#endregion
|
|
3518
|
+
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3519
|
+
function collectTailwindV4SourceFingerprint(source) {
|
|
3520
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
3521
|
+
const add = (prefix, value) => {
|
|
3522
|
+
tokens.add(`${prefix}:${value.trim()}`);
|
|
3523
|
+
};
|
|
3524
|
+
for (const match of source.matchAll(/@config\s+(["'])(.+?)\1\s*;?/g)) {
|
|
3525
|
+
const configRequest = match[2];
|
|
3526
|
+
add("config", node_path.default.basename(configRequest));
|
|
3527
|
+
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3528
|
+
}
|
|
3529
|
+
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3530
|
+
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3531
|
+
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3532
|
+
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
3533
|
+
for (const match of source.matchAll(/\.([_a-z][\w-]*)\s*[{,]/gi)) add("selector", match[1]);
|
|
3534
|
+
return tokens;
|
|
3535
|
+
}
|
|
3536
|
+
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
3537
|
+
if (!rawSource) return 0;
|
|
3538
|
+
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
3539
|
+
if (rawTokens.size === 0) return 0;
|
|
3540
|
+
const entryTokens = collectTailwindV4SourceFingerprint(entrySource);
|
|
3541
|
+
let score = 0;
|
|
3542
|
+
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
3543
|
+
return score;
|
|
3544
|
+
}
|
|
3545
|
+
function resolveSubpackageRootForFile(file, subpackageRoots) {
|
|
3546
|
+
if (!file || !subpackageRoots) return;
|
|
3547
|
+
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3548
|
+
}
|
|
3549
|
+
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3550
|
+
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
3551
|
+
}
|
|
3552
|
+
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, subpackageRoots) {
|
|
3553
|
+
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
3554
|
+
if (generationSources.length <= 1) return generationSources[0];
|
|
3555
|
+
const selectByRawSourceFingerprint = (candidates) => {
|
|
3556
|
+
const scoredSources = candidates.map((entry) => ({
|
|
3557
|
+
entry,
|
|
3558
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3559
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
3560
|
+
const bestScore = scoredSources[0]?.score;
|
|
3561
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
3562
|
+
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3563
|
+
};
|
|
3564
|
+
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
3565
|
+
if (rawSourceMatched) return rawSourceMatched;
|
|
3566
|
+
const scopedSources = subpackageRoots ? generationSources.filter((entry) => {
|
|
3567
|
+
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
3568
|
+
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, subpackageRoots);
|
|
3569
|
+
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3570
|
+
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, new Set([root])) && isSubpackageOutputFile(entry.file, new Set([root])));
|
|
3571
|
+
}) : generationSources;
|
|
3572
|
+
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3573
|
+
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
3574
|
+
if (candidates.length === 1) return candidates[0];
|
|
3575
|
+
return selectByRawSourceFingerprint(candidates);
|
|
3576
|
+
}
|
|
3577
|
+
//#endregion
|
|
3243
3578
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
3244
3579
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
3245
3580
|
return async (name, task) => {
|
|
@@ -3252,6 +3587,102 @@ function createBundleTaskTimer(recordTimingDetail) {
|
|
|
3252
3587
|
};
|
|
3253
3588
|
}
|
|
3254
3589
|
//#endregion
|
|
3590
|
+
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
3591
|
+
function toArray(value) {
|
|
3592
|
+
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
3593
|
+
}
|
|
3594
|
+
function normalizeSourceId(id) {
|
|
3595
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3596
|
+
return node_path.default.isAbsolute(file) ? node_path.default.resolve(file) : void 0;
|
|
3597
|
+
}
|
|
3598
|
+
function collectChunkModuleIds$1(chunk) {
|
|
3599
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3600
|
+
for (const id of chunk.moduleIds ?? []) {
|
|
3601
|
+
const normalized = normalizeSourceId(id);
|
|
3602
|
+
if (normalized) ids.add(normalized);
|
|
3603
|
+
}
|
|
3604
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
3605
|
+
const normalized = normalizeSourceId(id);
|
|
3606
|
+
if (normalized) ids.add(normalized);
|
|
3607
|
+
}
|
|
3608
|
+
return ids;
|
|
3609
|
+
}
|
|
3610
|
+
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
3611
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3612
|
+
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
3613
|
+
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
3614
|
+
for (const candidate of candidates) {
|
|
3615
|
+
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
3616
|
+
const cleanCandidate = (0, _weapp_tailwindcss_shared.cleanUrl)(candidate);
|
|
3617
|
+
const resolved = node_path.default.isAbsolute(cleanCandidate) ? node_path.default.resolve(cleanCandidate) : node_path.default.resolve(rootDir, cleanCandidate);
|
|
3618
|
+
ids.add(resolved);
|
|
3619
|
+
}
|
|
3620
|
+
return ids;
|
|
3621
|
+
}
|
|
3622
|
+
function isStringRuleMatched(rule, id, rootDir) {
|
|
3623
|
+
const normalizedId = require_source_candidate_scan_signature.slash(id);
|
|
3624
|
+
const normalizedRule = require_source_candidate_scan_signature.slash(rule);
|
|
3625
|
+
if (node_path.default.isAbsolute(rule)) return micromatch.default.isMatch(normalizedId, normalizedRule);
|
|
3626
|
+
const relative = require_source_candidate_scan_signature.slash(node_path.default.relative(rootDir, id));
|
|
3627
|
+
return relative.length > 0 && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizedRule);
|
|
3628
|
+
}
|
|
3629
|
+
function isRuleMatched(rule, id, rootDir) {
|
|
3630
|
+
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
3631
|
+
if (rule instanceof RegExp) {
|
|
3632
|
+
rule.lastIndex = 0;
|
|
3633
|
+
return rule.test(require_source_candidate_scan_signature.slash(id));
|
|
3634
|
+
}
|
|
3635
|
+
return rule(id) === true;
|
|
3636
|
+
}
|
|
3637
|
+
function createTransformMatcher(rules, rootDir) {
|
|
3638
|
+
const normalizedRules = toArray(rules);
|
|
3639
|
+
if (normalizedRules.length === 0) return;
|
|
3640
|
+
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
3641
|
+
}
|
|
3642
|
+
function shouldSkipSourceIds(sourceIds, filter) {
|
|
3643
|
+
if (sourceIds.size === 0) return false;
|
|
3644
|
+
if (filter.exclude) {
|
|
3645
|
+
let excluded = true;
|
|
3646
|
+
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
3647
|
+
excluded = false;
|
|
3648
|
+
break;
|
|
3649
|
+
}
|
|
3650
|
+
if (excluded) return true;
|
|
3651
|
+
}
|
|
3652
|
+
if (filter.include) {
|
|
3653
|
+
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
3654
|
+
return true;
|
|
3655
|
+
}
|
|
3656
|
+
return false;
|
|
3657
|
+
}
|
|
3658
|
+
function createTransformFilter(options, rootDir) {
|
|
3659
|
+
const include = createTransformMatcher(options?.include, rootDir);
|
|
3660
|
+
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
3661
|
+
if (!include && !exclude) return;
|
|
3662
|
+
return {
|
|
3663
|
+
include,
|
|
3664
|
+
exclude
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3667
|
+
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
3668
|
+
if (!filter) return false;
|
|
3669
|
+
return shouldSkipSourceIds(collectChunkModuleIds$1(chunk), filter);
|
|
3670
|
+
}
|
|
3671
|
+
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
3672
|
+
if (!filter) return false;
|
|
3673
|
+
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
3674
|
+
}
|
|
3675
|
+
function createRuleSignature(rules) {
|
|
3676
|
+
return toArray(rules).map((rule) => {
|
|
3677
|
+
if (typeof rule === "string") return `s:${rule}`;
|
|
3678
|
+
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
3679
|
+
return "f";
|
|
3680
|
+
}).join("|") || "none";
|
|
3681
|
+
}
|
|
3682
|
+
function createTransformFilterSignature(options) {
|
|
3683
|
+
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
3684
|
+
}
|
|
3685
|
+
//#endregion
|
|
3255
3686
|
//#region src/bundlers/vite/uni-app-x-css-options.ts
|
|
3256
3687
|
function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
3257
3688
|
const uniUtsPlatform = require_utils.resolveUniUtsPlatform();
|
|
@@ -3284,7 +3715,7 @@ function resolveWeappViteSourceRoot(config, _appType) {
|
|
|
3284
3715
|
const root = typeof viteConfig?.root === "string" && viteConfig.root.length > 0 ? node_path.default.resolve(viteConfig.root) : node_process.default.cwd();
|
|
3285
3716
|
const configuredSrcRoot = resolveSourceRootCandidate(root, viteConfig?.weapp?.srcRoot);
|
|
3286
3717
|
if (configuredSrcRoot) return configuredSrcRoot;
|
|
3287
|
-
const envSrcRoot = resolveSourceRootCandidate(root, node_process.default.env
|
|
3718
|
+
const envSrcRoot = resolveSourceRootCandidate(root, node_process.default.env["UNI_INPUT_DIR"]) ?? resolveSourceRootCandidate(root, node_process.default.env["UNI_INPUT_ROOT"]) ?? resolveSourceRootCandidate(root, node_process.default.env["UNI_APP_INPUT_DIR"]);
|
|
3288
3719
|
if (envSrcRoot) return envSrcRoot;
|
|
3289
3720
|
}
|
|
3290
3721
|
function stripFileExtension(file) {
|
|
@@ -3328,32 +3759,6 @@ function resolveSourceRootFromBundleGraph(config, bundle) {
|
|
|
3328
3759
|
}
|
|
3329
3760
|
//#endregion
|
|
3330
3761
|
//#region src/bundlers/vite/generate-bundle.ts
|
|
3331
|
-
function isRootMiniProgramStyleOutputFile(file) {
|
|
3332
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3333
|
-
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
3334
|
-
}
|
|
3335
|
-
function createRelativeCssImportRequest(targetFile, importedFile) {
|
|
3336
|
-
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
3337
|
-
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
3338
|
-
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
3339
|
-
const baseDir = targetDir === "." ? "" : targetDir;
|
|
3340
|
-
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
3341
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
3342
|
-
}
|
|
3343
|
-
function createCssImportShell(targetFile, importedFile) {
|
|
3344
|
-
return `@import "${createRelativeCssImportRequest(targetFile, importedFile)}";\n`;
|
|
3345
|
-
}
|
|
3346
|
-
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
3347
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
3348
|
-
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
3349
|
-
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
3350
|
-
}
|
|
3351
|
-
function shouldKeepRootMiniProgramStyleAsImportShell(appType) {
|
|
3352
|
-
return appType === "uni-app-vite" || appType === "uni-app-x" || appType === "taro";
|
|
3353
|
-
}
|
|
3354
|
-
function shouldMoveRootMiniProgramStyleToImportShellOrigin(appType) {
|
|
3355
|
-
return appType === "taro";
|
|
3356
|
-
}
|
|
3357
3762
|
function createGenerateBundleHook(context) {
|
|
3358
3763
|
const state = require_source_candidate_scan_signature.createBundleBuildState();
|
|
3359
3764
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
@@ -3443,119 +3848,17 @@ function createGenerateBundleHook(context) {
|
|
|
3443
3848
|
}
|
|
3444
3849
|
}
|
|
3445
3850
|
}, opts.tailwindcssBasedir ?? rootDir);
|
|
3446
|
-
const collectTailwindV4SourceFingerprint = (source) => {
|
|
3447
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
3448
|
-
const add = (prefix, value) => {
|
|
3449
|
-
const normalized = value?.trim();
|
|
3450
|
-
if (normalized) tokens.add(`${prefix}:${normalized}`);
|
|
3451
|
-
};
|
|
3452
|
-
for (const match of source.matchAll(/@config\s+(["'])(.+?)\1\s*;?/g)) {
|
|
3453
|
-
const configRequest = match[2] ?? "";
|
|
3454
|
-
add("config", node_path.default.basename(configRequest));
|
|
3455
|
-
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3456
|
-
}
|
|
3457
|
-
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3458
|
-
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3459
|
-
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3460
|
-
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
3461
|
-
for (const match of source.matchAll(/\.([_a-z][\w-]*)\s*[{,]/gi)) add("selector", match[1]);
|
|
3462
|
-
return tokens;
|
|
3463
|
-
};
|
|
3464
|
-
const scoreConfiguredTailwindV4SourceForRawSource = (rawSource, entrySource) => {
|
|
3465
|
-
if (!rawSource) return 0;
|
|
3466
|
-
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
3467
|
-
if (rawTokens.size === 0) return 0;
|
|
3468
|
-
const entryTokens = collectTailwindV4SourceFingerprint(entrySource);
|
|
3469
|
-
let score = 0;
|
|
3470
|
-
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
3471
|
-
return score;
|
|
3472
|
-
};
|
|
3473
|
-
const selectTailwindV4GenerationCssSourceForOutput = (outputFile, entries, rawSource) => {
|
|
3474
|
-
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
3475
|
-
if (generationSources.length <= 1) return generationSources[0];
|
|
3476
|
-
const selectByRawSourceFingerprint = (candidates) => {
|
|
3477
|
-
const scoredSources = candidates.map((entry) => ({
|
|
3478
|
-
entry,
|
|
3479
|
-
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3480
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
3481
|
-
const bestScore = scoredSources[0]?.score;
|
|
3482
|
-
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
3483
|
-
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3484
|
-
};
|
|
3485
|
-
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
3486
|
-
if (rawSourceMatched) return rawSourceMatched;
|
|
3487
|
-
const scopedSources = currentSubpackageRoots ? generationSources.filter((entry) => {
|
|
3488
|
-
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, currentSubpackageRoots);
|
|
3489
|
-
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, currentSubpackageRoots);
|
|
3490
|
-
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3491
|
-
return sourceMatchesSubpackage && [...currentSubpackageRoots].some((root) => isSubpackageOutputFile(outputFile, new Set([root])) && isSubpackageOutputFile(entry.file, new Set([root])));
|
|
3492
|
-
}) : generationSources;
|
|
3493
|
-
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3494
|
-
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
3495
|
-
if (candidates.length === 1) return candidates[0];
|
|
3496
|
-
return selectByRawSourceFingerprint(candidates);
|
|
3497
|
-
};
|
|
3498
|
-
const resolveSubpackageRootForFile = (file) => {
|
|
3499
|
-
if (!file || !currentSubpackageRoots) return;
|
|
3500
|
-
return [...currentSubpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3501
|
-
};
|
|
3502
|
-
const isSameSubpackageScope = (outputFile, sourceFile) => {
|
|
3503
|
-
return resolveSubpackageRootForFile(outputFile) === resolveSubpackageRootForFile(sourceFile);
|
|
3504
|
-
};
|
|
3505
3851
|
const normalizeGeneratorUserRawSource = (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || fallbackFile, outDir, opts);
|
|
3506
|
-
const
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
node_path.default.resolve(outDir, file),
|
|
3517
|
-
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(rootDir, relativeFromOutDir) : void 0,
|
|
3518
|
-
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(node_path.default.dirname(outDir), relativeFromOutDir) : void 0,
|
|
3519
|
-
file
|
|
3520
|
-
];
|
|
3521
|
-
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
3522
|
-
if (source || !candidate) return source;
|
|
3523
|
-
return getSourceCandidateSource?.(candidate);
|
|
3524
|
-
}, void 0);
|
|
3525
|
-
if (explicitSource) return explicitSource;
|
|
3526
|
-
const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
|
|
3527
|
-
absolute: node_path.default.isAbsolute(candidate),
|
|
3528
|
-
key: normalizeSourceCandidatePathKey(candidate)
|
|
3529
|
-
}));
|
|
3530
|
-
let bestSource;
|
|
3531
|
-
for (const [sourceFile, source] of getSourceCandidateSources?.() ?? []) {
|
|
3532
|
-
const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
|
|
3533
|
-
let score = 0;
|
|
3534
|
-
for (const candidate of normalizedSourceCandidates) {
|
|
3535
|
-
if (normalizedSourceFile === candidate.key) {
|
|
3536
|
-
score = Math.max(score, candidate.absolute ? 100 : 80);
|
|
3537
|
-
continue;
|
|
3538
|
-
}
|
|
3539
|
-
if (normalizedSourceFile.endsWith(`/${candidate.key}`)) score = Math.max(score, candidate.absolute ? 60 : 40);
|
|
3540
|
-
}
|
|
3541
|
-
if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
|
|
3542
|
-
if (score > (bestSource?.score ?? 0)) bestSource = {
|
|
3543
|
-
score,
|
|
3544
|
-
source
|
|
3545
|
-
};
|
|
3546
|
-
}
|
|
3547
|
-
return bestSource?.source;
|
|
3548
|
-
};
|
|
3549
|
-
const resolveOutputFileFromMatchedCssSource = (sourceFile) => {
|
|
3550
|
-
if (!sourceFile) return;
|
|
3551
|
-
const outputFile = resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget, false, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3552
|
-
return opts.cssMatcher(outputFile) ? outputFile : void 0;
|
|
3553
|
-
};
|
|
3554
|
-
const hasViteProcessedCssResultForSource = (sourceFile) => {
|
|
3555
|
-
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile);
|
|
3556
|
-
for (const [file] of getViteProcessedCssAssetResults?.() ?? []) if (require_source_candidate_scan_signature.normalizeOutputPathKey(file) === sourceKey) return true;
|
|
3557
|
-
return false;
|
|
3558
|
-
};
|
|
3852
|
+
const resolveMatchedCssSourceOutputFile = (sourceFile) => resolveOutputFileFromMatchedCssSource({
|
|
3853
|
+
bundleFiles,
|
|
3854
|
+
defaultStyleOutputExtension,
|
|
3855
|
+
isWebGeneratorTarget,
|
|
3856
|
+
opts,
|
|
3857
|
+
rootDir,
|
|
3858
|
+
shouldPreserveAppCssExtension: false,
|
|
3859
|
+
sourceFile,
|
|
3860
|
+
sourceRoot
|
|
3861
|
+
});
|
|
3559
3862
|
const usedConfiguredTailwindV4CssSourceFiles = /* @__PURE__ */ new Set();
|
|
3560
3863
|
const buildCommand = resolvedConfig?.command === "build";
|
|
3561
3864
|
const hasPreviousBundleState = state.iteration > 0 || state.sourceHashByFile.size > 0;
|
|
@@ -3605,33 +3908,47 @@ function createGenerateBundleHook(context) {
|
|
|
3605
3908
|
});
|
|
3606
3909
|
const jsEntries = snapshot.jsEntries;
|
|
3607
3910
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
3911
|
+
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
3912
|
+
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
3608
3913
|
const moduleGraphOptions = require_source_candidate_scan_signature.createBundleModuleGraphOptions(outDir, jsEntries);
|
|
3609
3914
|
const hasRuntimeAffectingChanges = require_source_candidate_scan_signature.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
3610
3915
|
const runtimeStart = performance.now();
|
|
3611
3916
|
const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
|
|
3612
|
-
const runtime = isWebGeneratorTarget
|
|
3917
|
+
const runtime = isWebGeneratorTarget ? /* @__PURE__ */ new Set() : useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, envFlags.forceRuntimeRefreshByEnv, {
|
|
3918
|
+
allowBaselineOnlyInitialSync: buildCommand,
|
|
3919
|
+
refreshBySource: forceV4RuntimeRefreshBySource
|
|
3920
|
+
}) : await context.ensureRuntimeClassSet(envFlags.forceRuntimeRefreshByEnv);
|
|
3613
3921
|
const shouldFilterTailwindV4MiniProgramCandidates = require_generator.shouldUseMiniProgramCssBranch(generatorBranch);
|
|
3614
3922
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
3615
3923
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
3616
|
-
const
|
|
3924
|
+
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
3925
|
+
const transformRuntime = shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
3617
3926
|
const generatorRuntime = filteredGeneratorCandidates;
|
|
3618
3927
|
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
3619
|
-
|
|
3928
|
+
const hasMultipleConfiguredCssEntries = (opts.cssEntries?.length ?? 0) > 1;
|
|
3929
|
+
if (sourceCandidates.size > 0 && !hasMultipleConfiguredCssEntries) {
|
|
3620
3930
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
3621
3931
|
if (mainCssEntry) {
|
|
3622
|
-
const
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3932
|
+
const mainCssRawSource = typeof mainCssEntry.output.source === "string" ? mainCssEntry.output.source : node_buffer.Buffer.from(mainCssEntry.output.source).toString();
|
|
3933
|
+
if (!require_v4_engine.hasTailwindApplyDirective(mainCssRawSource)) {
|
|
3934
|
+
const generatedCssSources = /* @__PURE__ */ new Set();
|
|
3935
|
+
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) if (typeof record === "string") generatedCssSources.add(record);
|
|
3936
|
+
else if (typeof record?.css === "string") generatedCssSources.add(record.css);
|
|
3937
|
+
const validatedSourceRuntime = await require_hmr_timing.validateCandidatesByGenerator({
|
|
3938
|
+
opts,
|
|
3939
|
+
runtimeState,
|
|
3940
|
+
candidates: filteredSourceCandidates,
|
|
3941
|
+
rawSource: mainCssRawSource,
|
|
3942
|
+
generatedCssSources,
|
|
3943
|
+
file: mainCssEntry.file,
|
|
3944
|
+
cssHandlerOptions: getCssHandlerOptions(mainCssEntry.file),
|
|
3945
|
+
cssUserHandlerOptions: getCssUserHandlerOptions(mainCssEntry.file),
|
|
3946
|
+
styleHandler,
|
|
3947
|
+
debug,
|
|
3948
|
+
skipGenerateFallback: false
|
|
3949
|
+
});
|
|
3950
|
+
if (validatedSourceRuntime.size > 0) for (const candidate of validatedSourceRuntime) transformRuntime.add(candidate);
|
|
3951
|
+
}
|
|
3635
3952
|
}
|
|
3636
3953
|
}
|
|
3637
3954
|
const generatorCandidateSignature = require_source_candidate_scan_signature.createCandidateSignature(generatorRuntime);
|
|
@@ -3639,21 +3956,24 @@ function createGenerateBundleHook(context) {
|
|
|
3639
3956
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
3640
3957
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
3641
3958
|
const runtimeLinkedCssFiles = new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3959
|
+
rememberRuntimeLinkedCssSources({
|
|
3960
|
+
bundleFiles,
|
|
3961
|
+
debug,
|
|
3962
|
+
defaultStyleOutputExtension,
|
|
3963
|
+
getConfiguredTailwindV4CssSourceEntries,
|
|
3964
|
+
getSourceCandidateSource,
|
|
3965
|
+
getSourceCandidateSources,
|
|
3966
|
+
isWebGeneratorTarget,
|
|
3967
|
+
jsImportedCssFiles,
|
|
3968
|
+
opts,
|
|
3969
|
+
outDir,
|
|
3970
|
+
rememberCssSource,
|
|
3971
|
+
rootDir,
|
|
3972
|
+
runtimeLinkedCssFiles,
|
|
3973
|
+
shouldPreserveAppCssExtension,
|
|
3974
|
+
snapshot,
|
|
3975
|
+
sourceRoot
|
|
3976
|
+
});
|
|
3657
3977
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
3658
3978
|
const dynamicRetryCandidates = new Set([
|
|
3659
3979
|
...sourceCandidates,
|
|
@@ -3695,90 +4015,86 @@ function createGenerateBundleHook(context) {
|
|
|
3695
4015
|
debug("html skip web target: %s", file);
|
|
3696
4016
|
continue;
|
|
3697
4017
|
}
|
|
4018
|
+
if (shouldSkipViteAssetTransform(originalSource, file, rootDir, transformFilter)) {
|
|
4019
|
+
metrics.html.transformed++;
|
|
4020
|
+
debug("html skip transform (filtered): %s", file);
|
|
4021
|
+
continue;
|
|
4022
|
+
}
|
|
3698
4023
|
if (!processFiles.html.has(file)) continue;
|
|
3699
|
-
|
|
3700
|
-
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
3701
|
-
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
3702
|
-
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : require_source_candidate_scan_signature.createCandidateSignature(templateRuntime);
|
|
3703
|
-
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
3704
|
-
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
3705
|
-
const hashKey = cacheKey;
|
|
3706
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
3707
|
-
tasks.push(timeTask("html", () => require_hmr_timing.processCachedTask({
|
|
4024
|
+
processHtmlBundleEntry({
|
|
3708
4025
|
cache,
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
3733
|
-
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
3734
|
-
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
3735
|
-
}
|
|
3736
|
-
metrics.html.elapsed += measureElapsed(start);
|
|
3737
|
-
metrics.html.transformed++;
|
|
3738
|
-
onUpdate(file, rawSource, transformed);
|
|
3739
|
-
debug("html handle: %s", file);
|
|
3740
|
-
return { result: transformed };
|
|
3741
|
-
}
|
|
3742
|
-
})));
|
|
4026
|
+
context,
|
|
4027
|
+
debug,
|
|
4028
|
+
dynamicRetryCandidates,
|
|
4029
|
+
file,
|
|
4030
|
+
metrics,
|
|
4031
|
+
onUpdate,
|
|
4032
|
+
originalEntrySource,
|
|
4033
|
+
originalSource,
|
|
4034
|
+
rememberProcessCacheKey,
|
|
4035
|
+
resolveCurrentSourceCandidateSource: (file) => resolveCurrentSourceCandidateSource({
|
|
4036
|
+
file,
|
|
4037
|
+
getSourceCandidateSource,
|
|
4038
|
+
getSourceCandidateSources,
|
|
4039
|
+
outDir,
|
|
4040
|
+
rootDir,
|
|
4041
|
+
sourceRoot
|
|
4042
|
+
}),
|
|
4043
|
+
tasks,
|
|
4044
|
+
templateHandler,
|
|
4045
|
+
timeTask,
|
|
4046
|
+
transformRuntime,
|
|
4047
|
+
transformRuntimeSignature
|
|
4048
|
+
});
|
|
3743
4049
|
continue;
|
|
3744
4050
|
}
|
|
3745
4051
|
if (type === "css" && originalSource.type === "asset") {
|
|
3746
4052
|
metrics.css.total++;
|
|
3747
4053
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
3748
4054
|
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
|
|
3749
|
-
let outputFile =
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
};
|
|
4055
|
+
let outputFile = resolveCssBundleOutputFile({
|
|
4056
|
+
bundleFiles,
|
|
4057
|
+
defaultStyleOutputExtension,
|
|
4058
|
+
file,
|
|
4059
|
+
isWebGeneratorTarget,
|
|
4060
|
+
opts,
|
|
4061
|
+
shouldPreserveAppCssExtension
|
|
4062
|
+
});
|
|
4063
|
+
const resolveMatchedOutputFileForCurrentAsset = createMatchedCssSourceOutputResolver({
|
|
4064
|
+
assetSourceFile,
|
|
4065
|
+
file,
|
|
4066
|
+
originalFileNames: originalSource.originalFileNames,
|
|
4067
|
+
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
4068
|
+
});
|
|
3757
4069
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
3758
|
-
if (outputFile
|
|
4070
|
+
if (shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceFile, opts.cssMatcher)) {
|
|
3759
4071
|
delete bundle[file];
|
|
3760
4072
|
debug("css skip raw source style asset: %s -> %s", file, outputFile);
|
|
3761
4073
|
continue;
|
|
3762
4074
|
}
|
|
4075
|
+
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
4076
|
+
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
3763
4077
|
const applyCssResult = (source) => {
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
else emitOrReplayCssAsset(outputFile, source);
|
|
3776
|
-
if (!viteProcessedCssAsset && SOURCE_STYLE_OUTPUT_EXT_RE.test(file)) delete bundle[file];
|
|
3777
|
-
else originalSource.source = importShellSource ?? "";
|
|
3778
|
-
return;
|
|
3779
|
-
}
|
|
3780
|
-
originalSource.source = source;
|
|
4078
|
+
applyCssResultToBundle({
|
|
4079
|
+
appType: opts.appType,
|
|
4080
|
+
assetSourceFile,
|
|
4081
|
+
bundle,
|
|
4082
|
+
emitOrReplayCssAsset,
|
|
4083
|
+
file,
|
|
4084
|
+
originalSource,
|
|
4085
|
+
outputFile,
|
|
4086
|
+
source,
|
|
4087
|
+
viteProcessedCssAsset
|
|
4088
|
+
});
|
|
3781
4089
|
};
|
|
4090
|
+
if (shouldSkipViteAssetTransform(originalSource, file, rootDir, transformFilter)) {
|
|
4091
|
+
applyCssResult(rawSource);
|
|
4092
|
+
markCssAssetProcessed?.(originalSource, outputFile);
|
|
4093
|
+
onUpdate(outputFile, rawSource, rawSource);
|
|
4094
|
+
metrics.css.transformed++;
|
|
4095
|
+
debug("css skip transform (filtered): %s", outputFile);
|
|
4096
|
+
continue;
|
|
4097
|
+
}
|
|
3782
4098
|
if (isWebGeneratorTarget && !shouldGenerateWebCssByGenerator) {
|
|
3783
4099
|
applyCssResult(rawSource);
|
|
3784
4100
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
@@ -3786,12 +4102,12 @@ function createGenerateBundleHook(context) {
|
|
|
3786
4102
|
debug("css skip web target: %s", outputFile);
|
|
3787
4103
|
continue;
|
|
3788
4104
|
}
|
|
3789
|
-
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
3790
|
-
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
3791
4105
|
const cssAssetProcessed = isCssAssetProcessed?.(originalSource, file) === true;
|
|
3792
4106
|
const alreadyProcessedCssAsset = viteProcessedCssAsset || cssAssetProcessed;
|
|
3793
4107
|
let rememberedCssSources = findRememberedCssSources(getRememberedCssSources?.(), outputFile, file, originalSource, outDir, opts.tailwindcssBasedir);
|
|
3794
|
-
if (rememberedCssSources.length > 0) rememberedCssSources = await Promise.all(rememberedCssSources.map(async (remembered) =>
|
|
4108
|
+
if (rememberedCssSources.length > 0) rememberedCssSources = await Promise.all(rememberedCssSources.map(async (remembered) => {
|
|
4109
|
+
return await refreshRememberedCssSource?.(remembered) ?? remembered;
|
|
4110
|
+
}));
|
|
3795
4111
|
let hasUsableRememberedTailwindSource = rememberedCssSources.some((remembered) => hasTailwindGenerationSource(remembered.rawSource) && require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, "")) !== require_source_candidate_scan_signature.normalizeOutputPathKey(file));
|
|
3796
4112
|
const inferredSfcStyleSource = await resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outDir, opts.tailwindcssBasedir, opts.cssMatcher, getSfcSource, debug);
|
|
3797
4113
|
if (inferredSfcStyleSource) {
|
|
@@ -3800,7 +4116,7 @@ function createGenerateBundleHook(context) {
|
|
|
3800
4116
|
if (!hasUsableRememberedTailwindSource || rememberedSourcesBelongToInferredSfc) rememberedCssSources = [inferredSfcStyleSource];
|
|
3801
4117
|
}
|
|
3802
4118
|
let outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
3803
|
-
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile))) {
|
|
4119
|
+
if (currentSubpackageRoots && rememberedCssSources.length > 0 && rememberedCssSources.some((remembered) => configuredTailwindV4CssSourceFileKeysForScope.has(require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.sourceFile.replace(/[?#].*$/, ""))) && !isSameSubpackageScope(outputFile, remembered.sourceFile, currentSubpackageRoots))) {
|
|
3804
4120
|
rememberedCssSources = [];
|
|
3805
4121
|
hasUsableRememberedTailwindSource = false;
|
|
3806
4122
|
}
|
|
@@ -3817,8 +4133,8 @@ function createGenerateBundleHook(context) {
|
|
|
3817
4133
|
}];
|
|
3818
4134
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
3819
4135
|
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry) => !usedConfiguredTailwindV4CssSourceFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file)));
|
|
3820
|
-
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource);
|
|
3821
|
-
if (configuredGenerationSource && !hasViteProcessedCssResultForSource(configuredGenerationSource.file)) {
|
|
4136
|
+
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, currentSubpackageRoots);
|
|
4137
|
+
if (configuredGenerationSource && !hasViteProcessedCssResultForSource(configuredGenerationSource.file, getViteProcessedCssAssetResults)) {
|
|
3822
4138
|
outputFile = resolveMatchedOutputFileForCurrentAsset(configuredGenerationSource.file) ?? outputFile;
|
|
3823
4139
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
3824
4140
|
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
@@ -3898,8 +4214,10 @@ function createGenerateBundleHook(context) {
|
|
|
3898
4214
|
const shouldInjectVitePipelineCssIntoMain = vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && shouldInjectCssIntoMainFromOutput(outputFile, generatorSourceFile, outputCssHandlerOptions);
|
|
3899
4215
|
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) || shouldRegenerateCollectedViteCss || hasRuntimeAffectingChanges && (alreadyProcessedCssAsset || vitePipelineCssAsset));
|
|
3900
4216
|
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) || require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(rawSource));
|
|
3901
|
-
|
|
3902
|
-
|
|
4217
|
+
const strippedViteProcessedCss = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(rawSource);
|
|
4218
|
+
const shouldPreserveStaleGeneratedCssAsset = hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && !strippedViteProcessedCss.includes("weapp-tailwindcss generator-placeholder") && !strippedViteProcessedCss.includes("vite-placeholder") && !hasTailwindGenerationSource(strippedViteProcessedCss) && !require_v4_engine.hasTailwindApplyDirective(strippedViteProcessedCss);
|
|
4219
|
+
if (alreadyProcessedCssAsset && !shouldRefreshViteProcessedCssByCandidates && (!hasStaleViteProcessedCssSource || shouldPreserveStaleGeneratedCssAsset) && !hasRememberedApplySource && !shouldRegenerateMainPackageCssWithScopedCandidates && (!shouldTrackGeneratorRuntime || shouldPreserveCollectedViteCssAsset)) {
|
|
4220
|
+
const nextCss = strippedViteProcessedCss;
|
|
3903
4221
|
applyCssResult(nextCss);
|
|
3904
4222
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
3905
4223
|
recordCssAssetResult?.(outputFile, nextCss);
|
|
@@ -3918,9 +4236,9 @@ function createGenerateBundleHook(context) {
|
|
|
3918
4236
|
}) : trackedGeneratorCandidateSignature;
|
|
3919
4237
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
3920
4238
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
3921
|
-
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${
|
|
3922
|
-
const cssCacheKey =
|
|
3923
|
-
const cssHashKey = `${
|
|
4239
|
+
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}:${sourceTraceSignature}`;
|
|
4240
|
+
const cssCacheKey = outputFile;
|
|
4241
|
+
const cssHashKey = `${outputFile}:css:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}`;
|
|
3924
4242
|
const cssLinkedImpactSignature = runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) ? [...[...snapshot.runtimeAffectingChangedByType.html].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? ""), ...[...snapshot.runtimeAffectingChangedByType.js].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? "")].join(":") : "";
|
|
3925
4243
|
if (!shouldTrackGeneratorRuntime && !runtimeLinkedCssFiles.has(file) && !runtimeLinkedCssFiles.has(outputFile)) {
|
|
3926
4244
|
const lastCss = getLastCssResult(lastCssResultByFile, outputFile, file);
|
|
@@ -3989,6 +4307,7 @@ function createGenerateBundleHook(context) {
|
|
|
3989
4307
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
3990
4308
|
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource, tracedCss));
|
|
3991
4309
|
debug("css generated result: %s bytes=%d", file, tracedCss.length);
|
|
4310
|
+
for (const candidate of generated.classSet ?? []) transformRuntime.add(candidate);
|
|
3992
4311
|
recordCssAssetResult?.(outputFile, tracedCss);
|
|
3993
4312
|
recordViteProcessedCssAssetResult?.(outputFile, tracedCss, {
|
|
3994
4313
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
@@ -4050,8 +4369,12 @@ function createGenerateBundleHook(context) {
|
|
|
4050
4369
|
rememberProcessCacheKey,
|
|
4051
4370
|
runtimeSignature,
|
|
4052
4371
|
snapshot,
|
|
4372
|
+
transformFilterSignature,
|
|
4373
|
+
shouldSkipAstTransform: transformFilter ? (chunk) => shouldSkipViteJsChunkTransform(chunk, transformFilter) : void 0,
|
|
4374
|
+
slowJsAstWarnMs: envFlags.slowJsAstWarnMs,
|
|
4053
4375
|
timeTask,
|
|
4054
4376
|
transformRuntime,
|
|
4377
|
+
transformRuntimeSignature,
|
|
4055
4378
|
uniAppX,
|
|
4056
4379
|
useIncrementalMode
|
|
4057
4380
|
});
|
|
@@ -4062,10 +4385,10 @@ function createGenerateBundleHook(context) {
|
|
|
4062
4385
|
bundle,
|
|
4063
4386
|
bundleFiles,
|
|
4064
4387
|
cache,
|
|
4388
|
+
cssTaskFactories,
|
|
4065
4389
|
createScopedGeneratorRuntime: createScopedGeneratorRuntime$1,
|
|
4066
4390
|
createScopedSourceCandidateGetter,
|
|
4067
4391
|
createScopedSourceCandidateSourceGetter,
|
|
4068
|
-
cssTaskFactories,
|
|
4069
4392
|
debug,
|
|
4070
4393
|
defaultStyleOutputExtension,
|
|
4071
4394
|
emitOrReplayCssAsset,
|
|
@@ -4096,7 +4419,6 @@ function createGenerateBundleHook(context) {
|
|
|
4096
4419
|
timeTask,
|
|
4097
4420
|
useIncrementalMode
|
|
4098
4421
|
});
|
|
4099
|
-
require_hmr_timing.pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
4100
4422
|
await finalizeGenerateBundle({
|
|
4101
4423
|
activeProcessCacheKeys,
|
|
4102
4424
|
activeProcessHashKeys,
|
|
@@ -4121,6 +4443,8 @@ function createGenerateBundleHook(context) {
|
|
|
4121
4443
|
isNativeAppStyleTarget,
|
|
4122
4444
|
isViteProcessedCssAsset,
|
|
4123
4445
|
isWebGeneratorTarget,
|
|
4446
|
+
jsAfterCss: shouldFilterTailwindV4MiniProgramCandidates && cssTaskFactories.length > 0,
|
|
4447
|
+
jsTaskFactories,
|
|
4124
4448
|
lastCssResultByFile,
|
|
4125
4449
|
lastCssSourceHashByFile,
|
|
4126
4450
|
linkedByEntry,
|
|
@@ -4174,7 +4498,7 @@ function createCssHandlerOptions(opts, majorVersion, file) {
|
|
|
4174
4498
|
...resolveUniAppXNativeCssHandlerOptions(opts),
|
|
4175
4499
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
4176
4500
|
postcssOptions: { options: { from: file } },
|
|
4177
|
-
...majorVersion === void 0 ? {} : { majorVersion }
|
|
4501
|
+
...require_context.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
4178
4502
|
};
|
|
4179
4503
|
}
|
|
4180
4504
|
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
@@ -4459,6 +4783,7 @@ function shouldCollectTransformedSourceCandidates(id) {
|
|
|
4459
4783
|
function createViteCssMemory(options) {
|
|
4460
4784
|
const rememberedCssSources = /* @__PURE__ */ new Map();
|
|
4461
4785
|
const rememberedCssSignatureByFile = /* @__PURE__ */ new Map();
|
|
4786
|
+
const knownCssSources = /* @__PURE__ */ new Map();
|
|
4462
4787
|
const knownSfcSources = /* @__PURE__ */ new Map();
|
|
4463
4788
|
const rememberKnownSfcSource = (id, code) => {
|
|
4464
4789
|
if (id.search(/[?#]/) >= 0) return;
|
|
@@ -4510,6 +4835,7 @@ function createViteCssMemory(options) {
|
|
|
4510
4835
|
return nextRemembered;
|
|
4511
4836
|
};
|
|
4512
4837
|
const refreshRememberedCssSourceBySourceFile = (sourceFile, rawSource) => {
|
|
4838
|
+
touchMapEntry(knownCssSources, normalizeCssSourceIdentity(sourceFile), rawSource);
|
|
4513
4839
|
const normalizedSourceFile = normalizeCssSourceIdentity(sourceFile);
|
|
4514
4840
|
const relatedRememberedEntries = [...rememberedCssSources].filter(([, remembered]) => normalizeCssSourceIdentity(remembered.sourceFile) === normalizedSourceFile);
|
|
4515
4841
|
for (const [rememberedKey, remembered] of relatedRememberedEntries) refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
|
|
@@ -4523,6 +4849,10 @@ function createViteCssMemory(options) {
|
|
|
4523
4849
|
const cached = resolveCachedStyleSource(sourceFile);
|
|
4524
4850
|
if (cached != null) return cached;
|
|
4525
4851
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_source_candidate_scan_signature.stripRequestQuery(sourceFile));
|
|
4852
|
+
const knownSource = knownCssSources.get(normalizeCssSourceIdentity(sourceFile));
|
|
4853
|
+
if (knownSource != null) return knownSource;
|
|
4854
|
+
const candidateSource = options.getSourceCandidateSource(file);
|
|
4855
|
+
if (candidateSource != null) return candidateSource;
|
|
4526
4856
|
if (!require_source_candidate_scan_signature.isSourceStyleRequest(file)) return;
|
|
4527
4857
|
try {
|
|
4528
4858
|
return await (0, node_fs_promises.readFile)(file, "utf8");
|
|
@@ -4584,6 +4914,7 @@ function createViteCssMemory(options) {
|
|
|
4584
4914
|
pruneMapToMaxSize(rememberedCssSources, VITE_REMEMBERED_CSS_CACHE_MAX, (rememberedKey) => {
|
|
4585
4915
|
rememberedCssSignatureByFile.delete(String(rememberedKey));
|
|
4586
4916
|
});
|
|
4917
|
+
pruneMapToMaxSize(knownCssSources, VITE_REMEMBERED_CSS_CACHE_MAX);
|
|
4587
4918
|
pruneMapToMaxSize(knownSfcSources, VITE_KNOWN_SFC_SOURCE_CACHE_MAX);
|
|
4588
4919
|
};
|
|
4589
4920
|
return {
|
|
@@ -4595,6 +4926,8 @@ function createViteCssMemory(options) {
|
|
|
4595
4926
|
rememberedCssSources: rememberedCssSources.size,
|
|
4596
4927
|
rememberedCssSourcesRaw: summarizeRememberedCssSources(rememberedCssSources),
|
|
4597
4928
|
rememberedCssSignatureByFile: rememberedCssSignatureByFile.size,
|
|
4929
|
+
knownCssSources: knownCssSources.size,
|
|
4930
|
+
knownCssSourcesRaw: summarizeStringMapCache(knownCssSources),
|
|
4598
4931
|
knownSfcSources: knownSfcSources.size,
|
|
4599
4932
|
knownSfcSourcesRaw: summarizeStringMapCache(knownSfcSources)
|
|
4600
4933
|
}),
|
|
@@ -4721,6 +5054,35 @@ function disableAndRemoveTailwindVitePlugins(plugins) {
|
|
|
4721
5054
|
return removed;
|
|
4722
5055
|
}
|
|
4723
5056
|
//#endregion
|
|
5057
|
+
//#region src/bundlers/vite/plugin-cache.ts
|
|
5058
|
+
function isMissingInternalCssSource(file, packageDir) {
|
|
5059
|
+
return !(0, node_fs.existsSync)(file) && node_path.default.resolve(file).startsWith(`${packageDir}${node_path.default.sep}`);
|
|
5060
|
+
}
|
|
5061
|
+
function normalizeVitePersistentCacheKey(file) {
|
|
5062
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
5063
|
+
}
|
|
5064
|
+
function toMb(bytes) {
|
|
5065
|
+
return Math.round(bytes / 1024 / 1024);
|
|
5066
|
+
}
|
|
5067
|
+
function summarizeStringCache(map) {
|
|
5068
|
+
let bytes = 0;
|
|
5069
|
+
for (const value of map.values()) bytes += value.length;
|
|
5070
|
+
return {
|
|
5071
|
+
bytes,
|
|
5072
|
+
mb: toMb(bytes),
|
|
5073
|
+
size: map.size
|
|
5074
|
+
};
|
|
5075
|
+
}
|
|
5076
|
+
function summarizeViteProcessedCssResults(map) {
|
|
5077
|
+
let bytes = 0;
|
|
5078
|
+
for (const record of map.values()) bytes += record.css.length;
|
|
5079
|
+
return {
|
|
5080
|
+
bytes,
|
|
5081
|
+
mb: toMb(bytes),
|
|
5082
|
+
size: map.size
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
//#endregion
|
|
4724
5086
|
//#region src/bundlers/shared/css-imports.ts
|
|
4725
5087
|
const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
|
|
4726
5088
|
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
@@ -4892,7 +5254,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
4892
5254
|
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
4893
5255
|
}
|
|
4894
5256
|
}
|
|
4895
|
-
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false,
|
|
5257
|
+
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false, options = {}) {
|
|
4896
5258
|
const forceRuntimeRefresh = forceRefresh || node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
4897
5259
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
4898
5260
|
const shouldRefreshRuntime = forceRuntimeRefresh || invalidation.changed;
|
|
@@ -4906,7 +5268,14 @@ function createViteRuntimeClassSet(options) {
|
|
|
4906
5268
|
await transformRuntimeClassSetManager.reset();
|
|
4907
5269
|
}
|
|
4908
5270
|
if (!forceRuntimeRefresh) try {
|
|
4909
|
-
const
|
|
5271
|
+
const baseClassSet = options.baseClassSet ?? runtimeSet ?? await require_context.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
5272
|
+
force: invalidation.changed,
|
|
5273
|
+
clearCache: invalidation.changed
|
|
5274
|
+
});
|
|
5275
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
|
|
5276
|
+
baseClassSet,
|
|
5277
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync
|
|
5278
|
+
});
|
|
4910
5279
|
runtimeSet = nextRuntimeSet;
|
|
4911
5280
|
return nextRuntimeSet;
|
|
4912
5281
|
} catch (error) {
|
|
@@ -5038,33 +5407,6 @@ const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resol
|
|
|
5038
5407
|
const weappTailwindcssDirPosix = require_source_candidate_scan_signature.slash(weappTailwindcssPackageDir);
|
|
5039
5408
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
5040
5409
|
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
5041
|
-
function isMissingInternalCssSource(file) {
|
|
5042
|
-
return !(0, node_fs.existsSync)(file) && node_path.default.resolve(file).startsWith(`${weappTailwindcssPackageDir}${node_path.default.sep}`);
|
|
5043
|
-
}
|
|
5044
|
-
function normalizeVitePersistentCacheKey(file) {
|
|
5045
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
5046
|
-
}
|
|
5047
|
-
function toMb(bytes) {
|
|
5048
|
-
return Math.round(bytes / 1024 / 1024);
|
|
5049
|
-
}
|
|
5050
|
-
function summarizeStringCache(map) {
|
|
5051
|
-
let bytes = 0;
|
|
5052
|
-
for (const value of map.values()) bytes += value.length;
|
|
5053
|
-
return {
|
|
5054
|
-
bytes,
|
|
5055
|
-
mb: toMb(bytes),
|
|
5056
|
-
size: map.size
|
|
5057
|
-
};
|
|
5058
|
-
}
|
|
5059
|
-
function summarizeViteProcessedCssResults(map) {
|
|
5060
|
-
let bytes = 0;
|
|
5061
|
-
for (const record of map.values()) bytes += record.css.length;
|
|
5062
|
-
return {
|
|
5063
|
-
bytes,
|
|
5064
|
-
mb: toMb(bytes),
|
|
5065
|
-
size: map.size
|
|
5066
|
-
};
|
|
5067
|
-
}
|
|
5068
5410
|
/**
|
|
5069
5411
|
* @name WeappTailwindcss
|
|
5070
5412
|
* @description uni-app vite / uni-app-x 版本插件
|
|
@@ -5117,7 +5459,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5117
5459
|
let autoCssSourcesRefresh;
|
|
5118
5460
|
let autoCssSourcesDiscovered = false;
|
|
5119
5461
|
const syncTailwindCssSourceCandidates = async (id, css) => {
|
|
5120
|
-
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource((0, _weapp_tailwindcss_shared.cleanUrl)(id))) return;
|
|
5462
|
+
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource((0, _weapp_tailwindcss_shared.cleanUrl)(id), weappTailwindcssPackageDir)) return;
|
|
5121
5463
|
await sourceCandidateCollector.syncCss(id, css);
|
|
5122
5464
|
cacheCurrentSourceCandidateScan();
|
|
5123
5465
|
};
|
|
@@ -5126,7 +5468,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5126
5468
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5127
5469
|
if (!node_path.default.isAbsolute(file)) return;
|
|
5128
5470
|
if (!require_v4_engine.isTailwindV4CssEntry(file)) return;
|
|
5129
|
-
if (isMissingInternalCssSource(file)) return;
|
|
5471
|
+
if (isMissingInternalCssSource(file, weappTailwindcssPackageDir)) return;
|
|
5130
5472
|
const sourceFile = node_path.default.normalize(file);
|
|
5131
5473
|
const sourceBase = node_path.default.dirname(sourceFile);
|
|
5132
5474
|
const sourceCss = require_v4_engine.normalizeTailwindSourceForGenerator(require_v4_engine.normalizeTailwindConfigDirectives(css, sourceBase), { importFallback: true });
|
|
@@ -5237,7 +5579,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5237
5579
|
recordedGeneratorCandidates = void 0;
|
|
5238
5580
|
};
|
|
5239
5581
|
const getSourceCandidates = () => sourceCandidateCollector.values();
|
|
5240
|
-
const getSourceCandidatesForEntries = (entries) => sourceCandidateCollector.valuesForEntries(entries);
|
|
5582
|
+
const getSourceCandidatesForEntries = (entries, options) => sourceCandidateCollector.valuesForEntries(entries, options);
|
|
5241
5583
|
const getSourceCandidateSourcesForEntries = (entries, options) => sourceCandidateCollector.sourcesForEntries(entries, options);
|
|
5242
5584
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
5243
5585
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|