weapp-tailwindcss 5.1.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/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-BHxLe743.js → context-B6hVF7dr.js} +20 -9
- package/dist/{context-Mbzkek1q.mjs → context-DlpKD7aN.mjs} +15 -10
- 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/types.d.ts +1 -1
- package/dist/{generator-9rUz4Hcb.js → generator-6oMJtTDO.js} +1 -1
- package/dist/{generator-Dc4qaPmT.mjs → generator-CjzBK7h-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B_sdP6dx.js → gulp-BtGq6LP9.js} +11 -9
- package/dist/{gulp-uM36oIJs.mjs → gulp-DNU10Vtc.mjs} +11 -9
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BXMLsF4b.mjs → hmr-timing-B0KuWDjV.mjs} +121 -85
- package/dist/{hmr-timing-CogqkFaF.js → hmr-timing-CegXR9O4.js} +132 -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-Cvb5z1ha.mjs → source-candidate-scan-signature-B5af2Ahe.mjs} +3 -3
- package/dist/{source-candidate-scan-signature-2ybpptAK.js → source-candidate-scan-signature-BKYb9jxa.js} +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-tExdt40m.mjs → transform-fRBeuuK-.mjs} +1 -1
- package/dist/{transform-CQVOgmzM.js → transform-vLwZpiTE.js} +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-CWRooooa.mjs} +730 -393
- package/dist/{vite-CP0ylSxZ.js → vite-w-RkgaTY.js} +730 -392
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +122 -85
- package/dist/{webpack-BzqhJ8yK.mjs → webpack-8PaV1gG3.mjs} +923 -671
- package/dist/{webpack-Bsek8VhR.js → webpack-CGgBOx9l.js} +923 -671
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +5 -5
|
@@ -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-6oMJtTDO.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-B6hVF7dr.js");
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-dbrbY4cd.js");
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-CegXR9O4.js");
|
|
9
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BKYb9jxa.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-vLwZpiTE.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,91 @@ 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) {
|
|
1174
|
+
return rawSource.trim().length > 0 && outputFile !== file && !canProcessViteSourceStyleAsCss(rawSource, file);
|
|
1175
|
+
}
|
|
1176
|
+
function resolveOutputFileFromMatchedCssSource(options) {
|
|
1177
|
+
const { bundleFiles, defaultStyleOutputExtension, isWebGeneratorTarget, opts, rootDir, shouldPreserveAppCssExtension, sourceFile, sourceRoot } = options;
|
|
1178
|
+
if (!sourceFile) return;
|
|
1179
|
+
if (isWebGeneratorTarget) return;
|
|
1180
|
+
const outputFile = resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
1181
|
+
return opts.cssMatcher(outputFile) ? outputFile : void 0;
|
|
1182
|
+
}
|
|
1183
|
+
function createMatchedCssSourceOutputResolver(options) {
|
|
1184
|
+
const { assetSourceFile, file, originalFileNames, resolveOutputFileFromMatchedCssSource } = options;
|
|
1185
|
+
return (sourceFile) => {
|
|
1186
|
+
if (!sourceFile) return;
|
|
1187
|
+
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;
|
|
1188
|
+
return resolveOutputFileFromMatchedCssSource(sourceFile);
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
function hasViteProcessedCssResultForSource(sourceFile, getViteProcessedCssAssetResults) {
|
|
1192
|
+
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile);
|
|
1193
|
+
for (const [file] of getViteProcessedCssAssetResults?.() ?? []) if (require_source_candidate_scan_signature.normalizeOutputPathKey(file) === sourceKey) return true;
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
function applyCssResultToBundle(options) {
|
|
1197
|
+
const { appType, assetSourceFile, bundle, emitOrReplayCssAsset, file, originalSource, outputFile, source, viteProcessedCssAsset } = options;
|
|
1198
|
+
if (outputFile === file) {
|
|
1199
|
+
originalSource.source = source;
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
const importShellSource = isRootMiniProgramStyleOutputFile$1(file) && isRootMiniProgramStyleOutputFile$1(outputFile) && shouldKeepRootMiniProgramStyleAsImportShell(appType) ? createCssImportShell$1(file, outputFile) : void 0;
|
|
1203
|
+
if (bundle[file] === originalSource && originalSource.originalFileNames?.includes(assetSourceFile)) {
|
|
1204
|
+
const existingOutput = bundle[outputFile];
|
|
1205
|
+
if (existingOutput?.type === "asset") existingOutput.source = source;
|
|
1206
|
+
else {
|
|
1207
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1208
|
+
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1209
|
+
}
|
|
1210
|
+
originalSource.source = importShellSource ?? source;
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const existingOutput = bundle[outputFile];
|
|
1214
|
+
if (existingOutput?.type === "asset") existingOutput.source = source;
|
|
1215
|
+
else {
|
|
1216
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, source);
|
|
1217
|
+
if (replayAsset) bundle[outputFile] = replayAsset;
|
|
1218
|
+
}
|
|
1219
|
+
if (!viteProcessedCssAsset && SOURCE_STYLE_OUTPUT_EXT_RE.test(file)) delete bundle[file];
|
|
1220
|
+
else originalSource.source = importShellSource ?? "";
|
|
1221
|
+
}
|
|
1222
|
+
//#endregion
|
|
1168
1223
|
//#region src/bundlers/vite/generate-bundle/css-share-scope.ts
|
|
1169
1224
|
const CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
|
|
1170
1225
|
const CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
|
|
@@ -1205,11 +1260,13 @@ function hasOmittedKnownBundleFiles(currentBundleFiles, previousBundleFiles) {
|
|
|
1205
1260
|
//#endregion
|
|
1206
1261
|
//#region src/bundlers/vite/generate-bundle/env-flags.ts
|
|
1207
1262
|
function resolveGenerateBundleEnvFlags() {
|
|
1263
|
+
const slowJsAstWarnMs = Number(node_process.default.env["WEAPP_TW_VITE_SLOW_JS_AST_WARN_MS"] ?? 1e3);
|
|
1208
1264
|
return {
|
|
1209
1265
|
forceRuntimeRefreshByEnv: node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1",
|
|
1210
1266
|
disableDirtyOptimization: node_process.default.env["WEAPP_TW_VITE_DISABLE_DIRTY"] === "1",
|
|
1211
1267
|
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"
|
|
1268
|
+
debugCssDiff: node_process.default.env["WEAPP_TW_VITE_DEBUG_CSS_DIFF"] === "1",
|
|
1269
|
+
slowJsAstWarnMs: Number.isFinite(slowJsAstWarnMs) && slowJsAstWarnMs >= 0 ? slowJsAstWarnMs : 1e3
|
|
1213
1270
|
};
|
|
1214
1271
|
}
|
|
1215
1272
|
//#endregion
|
|
@@ -1687,7 +1744,6 @@ function hasTailwindGenerationSource(source, options = {}) {
|
|
|
1687
1744
|
}
|
|
1688
1745
|
function hasTailwindGenerationSourceForFile(file, source) {
|
|
1689
1746
|
if (require_v4_engine.isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
1690
|
-
if (require_v4_engine.hasTailwindRootImportDirectives(source, { importFallback: true })) return false;
|
|
1691
1747
|
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1692
1748
|
}
|
|
1693
1749
|
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
@@ -1716,7 +1772,7 @@ async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputR
|
|
|
1716
1772
|
function normalizeSfcSourceFileForCompare(file) {
|
|
1717
1773
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1718
1774
|
}
|
|
1719
|
-
function collectChunkModuleIds$
|
|
1775
|
+
function collectChunkModuleIds$2(output) {
|
|
1720
1776
|
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
1721
1777
|
return [
|
|
1722
1778
|
output.facadeModuleId,
|
|
@@ -1756,7 +1812,7 @@ function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, s
|
|
|
1756
1812
|
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1757
1813
|
return;
|
|
1758
1814
|
}
|
|
1759
|
-
const sourceFiles = collectChunkModuleIds$
|
|
1815
|
+
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1760
1816
|
if (sourceFiles.length === 0) {
|
|
1761
1817
|
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
1762
1818
|
return;
|
|
@@ -1776,7 +1832,7 @@ function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, s
|
|
|
1776
1832
|
return bestSources[0]?.sourceFile;
|
|
1777
1833
|
}
|
|
1778
1834
|
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
1779
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile);
|
|
1835
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
1780
1836
|
if (!siblingJsFile) {
|
|
1781
1837
|
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1782
1838
|
return;
|
|
@@ -1787,7 +1843,7 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
|
|
|
1787
1843
|
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1788
1844
|
return;
|
|
1789
1845
|
}
|
|
1790
|
-
const sourceFiles = collectChunkModuleIds$
|
|
1846
|
+
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1791
1847
|
if (sourceFiles.length === 0) {
|
|
1792
1848
|
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1793
1849
|
return;
|
|
@@ -1809,7 +1865,7 @@ function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot
|
|
|
1809
1865
|
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
1810
1866
|
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1811
1867
|
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1812
|
-
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1868
|
+
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1813
1869
|
const scoredSources = [...getSourceStyleSources?.() ?? [], ...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1814
1870
|
file,
|
|
1815
1871
|
source,
|
|
@@ -1884,7 +1940,7 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1884
1940
|
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1885
1941
|
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, new Set([root])));
|
|
1886
1942
|
if (!matchedSubpackageRoot) continue;
|
|
1887
|
-
for (const moduleId of collectChunkModuleIds$
|
|
1943
|
+
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1888
1944
|
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
1889
1945
|
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
1890
1946
|
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
@@ -1918,7 +1974,7 @@ function readAssetSource$2(asset) {
|
|
|
1918
1974
|
function clearAssetSource(asset) {
|
|
1919
1975
|
asset.source = "";
|
|
1920
1976
|
}
|
|
1921
|
-
function appendCss(baseCss, css) {
|
|
1977
|
+
function appendCss$1(baseCss, css) {
|
|
1922
1978
|
if (baseCss.length === 0) return css;
|
|
1923
1979
|
if (css.length === 0) return baseCss;
|
|
1924
1980
|
return `${baseCss}\n${css}`;
|
|
@@ -2068,6 +2124,7 @@ function resolvePreservedImportShellInjectionTarget(opts, bundle, file, css) {
|
|
|
2068
2124
|
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2069
2125
|
if (importedStyleFiles.size !== 1) return;
|
|
2070
2126
|
const [importedFile] = importedStyleFiles;
|
|
2127
|
+
if (!importedFile) return;
|
|
2071
2128
|
if (!isRootStyleOutputFile(importedFile)) return;
|
|
2072
2129
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2073
2130
|
if (output.type !== "asset") continue;
|
|
@@ -2250,13 +2307,13 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2250
2307
|
let css = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(record.css).trim();
|
|
2251
2308
|
css = removeCssCoveredByImportedViteResults(css, importedCssSources).trim();
|
|
2252
2309
|
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
2310
|
const mergedLayerCss = require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
2255
2311
|
if (mergedLayerCss.merged) {
|
|
2256
2312
|
nextCss = mergedLayerCss.css;
|
|
2257
2313
|
css = require_hmr_timing.extractMarkedUserLayerComponentsCss(css).rest.trim();
|
|
2258
2314
|
if (css.length === 0) continue;
|
|
2259
2315
|
}
|
|
2316
|
+
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css) || (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css).length === 0) continue;
|
|
2260
2317
|
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css)) continue;
|
|
2261
2318
|
const mergedPreflightDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css);
|
|
2262
2319
|
if (mergedPreflightDeclarations.changed) {
|
|
@@ -2278,7 +2335,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2278
2335
|
}
|
|
2279
2336
|
const missingCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css);
|
|
2280
2337
|
if (missingCss.length === 0 || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss)) continue;
|
|
2281
|
-
nextCss = appendCss(nextCss, missingCss);
|
|
2338
|
+
nextCss = appendCss$1(nextCss, missingCss);
|
|
2282
2339
|
}
|
|
2283
2340
|
if (nextCss === originalSource) continue;
|
|
2284
2341
|
output.source = nextCss;
|
|
@@ -2351,9 +2408,9 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
2351
2408
|
cssOptions: {
|
|
2352
2409
|
...cssHandlerOptions.cssOptions ?? {},
|
|
2353
2410
|
autoprefixer: false,
|
|
2354
|
-
cssPresetEnv:
|
|
2411
|
+
cssPresetEnv: {}
|
|
2355
2412
|
},
|
|
2356
|
-
cssPresetEnv:
|
|
2413
|
+
cssPresetEnv: {}
|
|
2357
2414
|
});
|
|
2358
2415
|
const outputCss = (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(css);
|
|
2359
2416
|
if (outputCss === rawSource) continue;
|
|
@@ -2455,6 +2512,27 @@ function formatMs(value) {
|
|
|
2455
2512
|
}
|
|
2456
2513
|
//#endregion
|
|
2457
2514
|
//#region src/bundlers/vite/generate-bundle/uni-app-x-postprocess.ts
|
|
2515
|
+
function appendCss(baseCss, css) {
|
|
2516
|
+
if (baseCss.length === 0) return css;
|
|
2517
|
+
if (css.length === 0) return baseCss;
|
|
2518
|
+
return `${baseCss}\n${css}`;
|
|
2519
|
+
}
|
|
2520
|
+
function injectHarmonyCssIntoMainAsset(bundle, cssSources, onUpdate, debug) {
|
|
2521
|
+
const output = bundle["main.css"];
|
|
2522
|
+
if (output?.type !== "asset" || cssSources.length === 0) return false;
|
|
2523
|
+
const currentSource = String(output.source);
|
|
2524
|
+
let nextSource = currentSource;
|
|
2525
|
+
for (const css of cssSources) {
|
|
2526
|
+
const trimmedCss = css.trim();
|
|
2527
|
+
if (trimmedCss.length === 0 || nextSource.includes(trimmedCss)) continue;
|
|
2528
|
+
nextSource = appendCss(nextSource, trimmedCss);
|
|
2529
|
+
}
|
|
2530
|
+
if (nextSource === currentSource) return false;
|
|
2531
|
+
output.source = nextSource;
|
|
2532
|
+
onUpdate("main.css", currentSource, nextSource);
|
|
2533
|
+
debug("uni-app-x harmony main css inject");
|
|
2534
|
+
return true;
|
|
2535
|
+
}
|
|
2458
2536
|
async function handleUniAppXPostCssTasks(options) {
|
|
2459
2537
|
const { bundle, debug, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteProcessedCssAssetResults, isHarmonyAppStyleTarget, isNativeAppStyleTarget, onUpdate, opts, runtimeState, styleHandler } = options;
|
|
2460
2538
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
@@ -2487,6 +2565,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2487
2565
|
}));
|
|
2488
2566
|
}
|
|
2489
2567
|
if (isHarmonyAppStyleTarget && injectUniAppXHarmonyBundleStyles(bundle, { cssSources: viteProcessedCssSources })) debug("uni-app-x harmony bundle styles inject");
|
|
2568
|
+
if (isHarmonyAppStyleTarget) injectHarmonyCssIntoMainAsset(bundle, viteProcessedCssSources, onUpdate, debug);
|
|
2490
2569
|
for (const [file, item] of Object.entries(bundle)) {
|
|
2491
2570
|
if (item.type !== "asset" || !file.endsWith(".uvue.ts")) continue;
|
|
2492
2571
|
const currentSource = String(item.source);
|
|
@@ -2552,11 +2631,11 @@ function readAssetSource(asset) {
|
|
|
2552
2631
|
function getAssetFile(bundleFile, asset) {
|
|
2553
2632
|
return asset.fileName || bundleFile;
|
|
2554
2633
|
}
|
|
2555
|
-
function isRootMiniProgramStyleOutputFile
|
|
2634
|
+
function isRootMiniProgramStyleOutputFile(file) {
|
|
2556
2635
|
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2557
2636
|
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
2558
2637
|
}
|
|
2559
|
-
function createRelativeCssImportRequest
|
|
2638
|
+
function createRelativeCssImportRequest(targetFile, importedFile) {
|
|
2560
2639
|
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
2561
2640
|
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
2562
2641
|
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
@@ -2564,12 +2643,12 @@ function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
|
2564
2643
|
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
2565
2644
|
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
2566
2645
|
}
|
|
2567
|
-
function createCssImportShell
|
|
2568
|
-
return `@import "${createRelativeCssImportRequest
|
|
2646
|
+
function createCssImportShell(targetFile, importedFile) {
|
|
2647
|
+
return `@import "${createRelativeCssImportRequest(targetFile, importedFile)}";\n`;
|
|
2569
2648
|
}
|
|
2570
2649
|
function resolveRootMiniProgramOriginStyleFile(file) {
|
|
2571
2650
|
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2572
|
-
if (!isRootMiniProgramStyleOutputFile
|
|
2651
|
+
if (!isRootMiniProgramStyleOutputFile(normalized)) return;
|
|
2573
2652
|
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return;
|
|
2574
2653
|
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
2575
2654
|
}
|
|
@@ -2594,7 +2673,7 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2594
2673
|
for (const [rootBundleFile, rootOutput] of Object.entries(bundle)) {
|
|
2595
2674
|
if (rootOutput.type !== "asset") continue;
|
|
2596
2675
|
const rootFile = getAssetFile(rootBundleFile, rootOutput);
|
|
2597
|
-
if (!isRootMiniProgramStyleOutputFile
|
|
2676
|
+
if (!isRootMiniProgramStyleOutputFile(rootFile) || !options.cssMatcher(rootFile)) continue;
|
|
2598
2677
|
const originFile = resolveRootMiniProgramOriginStyleFile(rootFile);
|
|
2599
2678
|
if (!originFile || !options.cssMatcher(originFile)) continue;
|
|
2600
2679
|
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 +2685,7 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2606
2685
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
2607
2686
|
if (importedFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootFile)) continue;
|
|
2608
2687
|
} else if (originSource.trim().length > 0 && originSource.trim() !== rootSource.trim()) continue;
|
|
2609
|
-
const nextRootSource = createCssImportShell
|
|
2688
|
+
const nextRootSource = createCssImportShell(rootFile, originFile);
|
|
2610
2689
|
if (rootSource === nextRootSource) continue;
|
|
2611
2690
|
rootOutput.source = nextRootSource;
|
|
2612
2691
|
originOutput.source = rootSource;
|
|
@@ -2620,12 +2699,14 @@ function normalizeTaroRootImportShellAssets(bundle, options) {
|
|
|
2620
2699
|
return updated;
|
|
2621
2700
|
}
|
|
2622
2701
|
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;
|
|
2702
|
+
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;
|
|
2703
|
+
const tasksStart = performance.now();
|
|
2624
2704
|
if (cssTaskFactories.length > 0) {
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2705
|
+
const cssTask = require_hmr_timing.runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
|
|
2706
|
+
if (jsAfterCss) await cssTask;
|
|
2707
|
+
else tasks.push(cssTask);
|
|
2627
2708
|
}
|
|
2628
|
-
|
|
2709
|
+
if (jsTaskFactories.length > 0) tasks.push(require_hmr_timing.runWithConcurrency(jsTaskFactories).then(() => void 0));
|
|
2629
2710
|
await Promise.all(tasks);
|
|
2630
2711
|
recordTimingDetail("tasks", tasksStart);
|
|
2631
2712
|
for (const apply of pendingLinkedUpdates) apply();
|
|
@@ -2745,6 +2826,120 @@ async function finalizeGenerateBundle(options) {
|
|
|
2745
2826
|
debug("end");
|
|
2746
2827
|
}
|
|
2747
2828
|
//#endregion
|
|
2829
|
+
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
2830
|
+
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
2831
|
+
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
2832
|
+
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
2833
|
+
const MUSTACHE_OPEN = "{{";
|
|
2834
|
+
const MUSTACHE_CLOSE = "}}";
|
|
2835
|
+
function isUrlLikeCandidate(candidate) {
|
|
2836
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
2837
|
+
}
|
|
2838
|
+
function isArbitraryValueCandidate(candidate) {
|
|
2839
|
+
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
2840
|
+
}
|
|
2841
|
+
function collectClassAttributeValues(source) {
|
|
2842
|
+
const values = [];
|
|
2843
|
+
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
2844
|
+
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2845
|
+
while (matched !== null) {
|
|
2846
|
+
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
2847
|
+
const quote = source[quoteIndex];
|
|
2848
|
+
if (quote !== "\"" && quote !== "'") {
|
|
2849
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2850
|
+
continue;
|
|
2851
|
+
}
|
|
2852
|
+
let expressionDepth = 0;
|
|
2853
|
+
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
2854
|
+
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
2855
|
+
expressionDepth++;
|
|
2856
|
+
index += 1;
|
|
2857
|
+
continue;
|
|
2858
|
+
}
|
|
2859
|
+
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
2860
|
+
expressionDepth--;
|
|
2861
|
+
index += 1;
|
|
2862
|
+
continue;
|
|
2863
|
+
}
|
|
2864
|
+
if (expressionDepth === 0 && source[index] === quote) {
|
|
2865
|
+
values.push(source.slice(quoteIndex + 1, index));
|
|
2866
|
+
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
2867
|
+
break;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
2871
|
+
}
|
|
2872
|
+
return values;
|
|
2873
|
+
}
|
|
2874
|
+
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
2875
|
+
const matches = /* @__PURE__ */ new Set();
|
|
2876
|
+
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
2877
|
+
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
2878
|
+
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
2879
|
+
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
2880
|
+
while (quoted !== null) {
|
|
2881
|
+
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
2882
|
+
for (const candidate of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal)) {
|
|
2883
|
+
const normalized = candidate.trim();
|
|
2884
|
+
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
2885
|
+
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
2886
|
+
matches.add(normalized);
|
|
2887
|
+
}
|
|
2888
|
+
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
return [...matches];
|
|
2892
|
+
}
|
|
2893
|
+
//#endregion
|
|
2894
|
+
//#region src/bundlers/vite/generate-bundle/html-processing.ts
|
|
2895
|
+
function processHtmlBundleEntry(options) {
|
|
2896
|
+
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
2897
|
+
const rawSource = resolveCurrentSourceCandidateSource(file) ?? originalEntrySource;
|
|
2898
|
+
const currentRawDynamicCandidates = collectUnescapedDynamicCandidates(rawSource);
|
|
2899
|
+
const templateRuntime = currentRawDynamicCandidates.length > 0 ? new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
2900
|
+
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : require_source_candidate_scan_signature.createCandidateSignature(templateRuntime);
|
|
2901
|
+
const htmlProcessHash = `${cache.computeHash(rawSource)}:${cache.computeHash(require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(rawSource, "html"))}:${templateRuntimeSignature}`;
|
|
2902
|
+
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
2903
|
+
const hashKey = cacheKey;
|
|
2904
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
2905
|
+
tasks.push(timeTask("html", () => require_hmr_timing.processCachedTask({
|
|
2906
|
+
cache,
|
|
2907
|
+
cacheKey,
|
|
2908
|
+
hashKey,
|
|
2909
|
+
hash: htmlProcessHash,
|
|
2910
|
+
applyResult(source) {
|
|
2911
|
+
originalSource.source = source;
|
|
2912
|
+
},
|
|
2913
|
+
onCacheHit() {
|
|
2914
|
+
metrics.html.cacheHits++;
|
|
2915
|
+
debug("html cache hit: %s", file);
|
|
2916
|
+
},
|
|
2917
|
+
async transform() {
|
|
2918
|
+
const start = performance.now();
|
|
2919
|
+
let transformed = await templateHandler(rawSource, { runtimeSet: templateRuntime });
|
|
2920
|
+
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
2921
|
+
let retryRuntimeSet;
|
|
2922
|
+
if (unresolvedDynamicCandidates.length > 0) {
|
|
2923
|
+
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
2924
|
+
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
2925
|
+
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
2926
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
2927
|
+
}
|
|
2928
|
+
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
2929
|
+
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
2930
|
+
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
2931
|
+
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
2932
|
+
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
2933
|
+
}
|
|
2934
|
+
metrics.html.elapsed += measureElapsed(start);
|
|
2935
|
+
metrics.html.transformed++;
|
|
2936
|
+
onUpdate(file, rawSource, transformed);
|
|
2937
|
+
debug("html handle: %s", file);
|
|
2938
|
+
return { result: transformed };
|
|
2939
|
+
}
|
|
2940
|
+
})));
|
|
2941
|
+
}
|
|
2942
|
+
//#endregion
|
|
2748
2943
|
//#region src/bundlers/vite/generate-bundle/js-entries.ts
|
|
2749
2944
|
function createJsEntryResolver(jsEntries) {
|
|
2750
2945
|
const normalizedJsEntries = /* @__PURE__ */ new Map();
|
|
@@ -2801,7 +2996,7 @@ function collectLinkedFileNames(linked, getJsEntry, linkedSet) {
|
|
|
2801
2996
|
//#endregion
|
|
2802
2997
|
//#region src/bundlers/vite/generate-bundle/js-processing.ts
|
|
2803
2998
|
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;
|
|
2999
|
+
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
3000
|
const { file, output: originalSource, source: originalEntrySource } = entry;
|
|
2806
3001
|
metrics.js.total++;
|
|
2807
3002
|
const shouldTransformJs = !useIncrementalMode || processFiles.js.has(file);
|
|
@@ -2811,7 +3006,8 @@ function processJsBundleEntry(options) {
|
|
|
2811
3006
|
const initialRawSource = originalEntrySource;
|
|
2812
3007
|
const linkedSet = useIncrementalMode ? /* @__PURE__ */ new Set() : void 0;
|
|
2813
3008
|
if (linkedByEntry && linkedSet) linkedByEntry.set(file, linkedSet);
|
|
2814
|
-
const
|
|
3009
|
+
const linkedImpactSignature = useIncrementalMode ? require_source_candidate_scan_signature.createLinkedImpactSignature(file, snapshot.linkedImpactsByEntry, snapshot.sourceHashByFile) : void 0;
|
|
3010
|
+
const hashSalt = require_source_candidate_scan_signature.createJsHashSalt(`${transformRuntimeSignature}:transform-filter:${transformFilterSignature}`, linkedImpactSignature);
|
|
2815
3011
|
const hashKey = `${file}:js`;
|
|
2816
3012
|
const processHash = `${require_source_candidate_scan_signature.getSnapshotHash(snapshot.sourceHashByFile, file, initialRawSource)}:${hashSalt}`;
|
|
2817
3013
|
rememberProcessCacheKey(file, hashKey);
|
|
@@ -2842,15 +3038,24 @@ function processJsBundleEntry(options) {
|
|
|
2842
3038
|
const start = performance.now();
|
|
2843
3039
|
const rawSource = originalSource.code;
|
|
2844
3040
|
if (!shouldTransformJs) debug("js cache replay miss, fallback transform: %s", file);
|
|
3041
|
+
if (shouldSkipAstTransform?.(originalSource)) {
|
|
3042
|
+
metrics.js.elapsed += measureElapsed(start);
|
|
3043
|
+
metrics.js.transformed++;
|
|
3044
|
+
debug("js skip ast transform (filtered): %s", file);
|
|
3045
|
+
return { result: rawSource };
|
|
3046
|
+
}
|
|
2845
3047
|
const handlerOptions = createHandlerOptions(absoluteFile);
|
|
2846
3048
|
if (!disableJsPrecheck && require_context.shouldSkipJsTransform(rawSource, handlerOptions)) {
|
|
2847
3049
|
metrics.js.elapsed += measureElapsed(start);
|
|
2848
3050
|
metrics.js.transformed++;
|
|
2849
3051
|
return { result: rawSource };
|
|
2850
3052
|
}
|
|
3053
|
+
const handlerStart = performance.now();
|
|
2851
3054
|
const { code, linked } = await jsHandler(rawSource, transformRuntime, handlerOptions);
|
|
3055
|
+
const handlerElapsed = measureElapsed(handlerStart);
|
|
2852
3056
|
metrics.js.elapsed += measureElapsed(start);
|
|
2853
3057
|
metrics.js.transformed++;
|
|
3058
|
+
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
3059
|
onUpdate(file, rawSource, code);
|
|
2855
3060
|
debug("js handle: %s", file);
|
|
2856
3061
|
collectLinkedFileNames(linked, getJsEntry, linkedSet);
|
|
@@ -2977,7 +3182,8 @@ function mergeRememberedCssSources(sources, outputFile) {
|
|
|
2977
3182
|
function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
2978
3183
|
const groups = /* @__PURE__ */ new Map();
|
|
2979
3184
|
for (const [key, remembered] of sources ?? []) {
|
|
2980
|
-
const
|
|
3185
|
+
const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
|
|
3186
|
+
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
3187
|
const group = groups.get(outputKey) ?? [];
|
|
2982
3188
|
group.push({
|
|
2983
3189
|
key,
|
|
@@ -3060,7 +3266,7 @@ async function processRememberedCssReplay(options) {
|
|
|
3060
3266
|
}
|
|
3061
3267
|
if (shouldEmitRememberedReplayCssAsset) {
|
|
3062
3268
|
const replayAsset = emitOrReplayCssAsset(outputFile, css);
|
|
3063
|
-
markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3269
|
+
if (replayAsset) markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3064
3270
|
}
|
|
3065
3271
|
metrics.css.elapsed += measureElapsed(start);
|
|
3066
3272
|
metrics.css.transformed++;
|
|
@@ -3115,6 +3321,26 @@ function collectJsImportedCssFiles(snapshot) {
|
|
|
3115
3321
|
return files;
|
|
3116
3322
|
}
|
|
3117
3323
|
//#endregion
|
|
3324
|
+
//#region src/bundlers/vite/generate-bundle/runtime-linked-source-memory.ts
|
|
3325
|
+
function rememberRuntimeLinkedCssSources(options) {
|
|
3326
|
+
const { bundleFiles, defaultStyleOutputExtension, debug, getConfiguredTailwindV4CssSourceEntries, getSourceCandidateSource, getSourceCandidateSources, isWebGeneratorTarget, jsImportedCssFiles, opts, outDir, rememberCssSource, rootDir, runtimeLinkedCssFiles, shouldPreserveAppCssExtension, snapshot, sourceRoot } = options;
|
|
3327
|
+
for (const file of runtimeLinkedCssFiles) {
|
|
3328
|
+
if (snapshot.sourceHashByFile.has(file)) {
|
|
3329
|
+
snapshot.processFiles.css.add(file);
|
|
3330
|
+
continue;
|
|
3331
|
+
}
|
|
3332
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3333
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getSourceCandidateSource, jsImportedCssFiles.has(file) ? getSourceCandidateSources : void 0, getConfiguredTailwindV4CssSourceEntries().map((entry) => [entry.file, entry.source]), debug);
|
|
3334
|
+
const rawSource = inferredSourceStyle?.rawSource ?? getSourceCandidateSource?.(node_path.default.resolve(outDir, file)) ?? getSourceCandidateSource?.(file);
|
|
3335
|
+
if (rawSource === void 0 || !hasTailwindGenerationSource(rawSource)) continue;
|
|
3336
|
+
rememberCssSource?.({
|
|
3337
|
+
outputFile,
|
|
3338
|
+
rawSource,
|
|
3339
|
+
sourceFile: inferredSourceStyle?.sourceFile ?? node_path.default.resolve(outDir, file)
|
|
3340
|
+
});
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
//#endregion
|
|
3118
3344
|
//#region src/bundlers/vite/generate-bundle/source-candidate-scope.ts
|
|
3119
3345
|
function intersectCandidateSets(left, right) {
|
|
3120
3346
|
if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
|
|
@@ -3240,6 +3466,111 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
3240
3466
|
};
|
|
3241
3467
|
}
|
|
3242
3468
|
//#endregion
|
|
3469
|
+
//#region src/bundlers/vite/generate-bundle/source-candidate-source.ts
|
|
3470
|
+
function normalizeSourceCandidatePathKey(file) {
|
|
3471
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve(file));
|
|
3472
|
+
}
|
|
3473
|
+
function resolveCurrentSourceCandidateSource(options) {
|
|
3474
|
+
const { file, getSourceCandidateSource, getSourceCandidateSources, outDir, rootDir, sourceRoot } = options;
|
|
3475
|
+
const cleanedFile = file.replace(/[?#].*$/, "");
|
|
3476
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(cleanedFile);
|
|
3477
|
+
const absoluteFile = node_path.default.isAbsolute(cleanedFile) ? cleanedFile : node_path.default.resolve(rootDir, cleanedFile);
|
|
3478
|
+
const relativeFromOutDir = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.relative(outDir, absoluteFile));
|
|
3479
|
+
const sourceCandidates = [
|
|
3480
|
+
sourceRoot ? node_path.default.resolve(sourceRoot, file) : void 0,
|
|
3481
|
+
node_path.default.resolve(rootDir, file),
|
|
3482
|
+
node_path.default.resolve(node_path.default.dirname(outDir), file),
|
|
3483
|
+
node_path.default.resolve(outDir, file),
|
|
3484
|
+
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(rootDir, relativeFromOutDir) : void 0,
|
|
3485
|
+
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(node_path.default.dirname(outDir), relativeFromOutDir) : void 0,
|
|
3486
|
+
file
|
|
3487
|
+
];
|
|
3488
|
+
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
3489
|
+
if (source || !candidate) return source;
|
|
3490
|
+
return getSourceCandidateSource?.(candidate);
|
|
3491
|
+
}, void 0);
|
|
3492
|
+
if (explicitSource) return explicitSource;
|
|
3493
|
+
const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
|
|
3494
|
+
absolute: node_path.default.isAbsolute(candidate),
|
|
3495
|
+
key: normalizeSourceCandidatePathKey(candidate)
|
|
3496
|
+
}));
|
|
3497
|
+
let bestSource;
|
|
3498
|
+
for (const [sourceFile, source] of getSourceCandidateSources?.() ?? []) {
|
|
3499
|
+
const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
|
|
3500
|
+
let score = 0;
|
|
3501
|
+
for (const candidate of normalizedSourceCandidates) if (normalizedSourceFile === candidate.key) {
|
|
3502
|
+
score = Math.max(score, candidate.absolute ? 100 : 80);
|
|
3503
|
+
continue;
|
|
3504
|
+
}
|
|
3505
|
+
if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
|
|
3506
|
+
if (score > (bestSource?.score ?? 0)) bestSource = {
|
|
3507
|
+
score,
|
|
3508
|
+
source
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
return bestSource?.source;
|
|
3512
|
+
}
|
|
3513
|
+
//#endregion
|
|
3514
|
+
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3515
|
+
function collectTailwindV4SourceFingerprint(source) {
|
|
3516
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
3517
|
+
const add = (prefix, value) => {
|
|
3518
|
+
tokens.add(`${prefix}:${value.trim()}`);
|
|
3519
|
+
};
|
|
3520
|
+
for (const match of source.matchAll(/@config\s+(["'])(.+?)\1\s*;?/g)) {
|
|
3521
|
+
const configRequest = match[2];
|
|
3522
|
+
add("config", node_path.default.basename(configRequest));
|
|
3523
|
+
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3524
|
+
}
|
|
3525
|
+
for (const match of source.matchAll(/@source\s+(not\s+)?(["'])(.+?)\2\s*;?/g)) add(match[1] ? "source:not" : "source", match[3]);
|
|
3526
|
+
for (const match of source.matchAll(/@custom-variant\s+([^{\s]+)/g)) add("custom-variant", match[1]);
|
|
3527
|
+
for (const match of source.matchAll(/@(?:theme|utility|variant|layer)\s+([^{;\s]+)/g)) add("directive", match[1]);
|
|
3528
|
+
for (const match of source.matchAll(/--[\w-]+(?=\s*:)/g)) add("theme-token", match[0]);
|
|
3529
|
+
for (const match of source.matchAll(/\.([_a-z][\w-]*)\s*[{,]/gi)) add("selector", match[1]);
|
|
3530
|
+
return tokens;
|
|
3531
|
+
}
|
|
3532
|
+
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
3533
|
+
if (!rawSource) return 0;
|
|
3534
|
+
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
3535
|
+
if (rawTokens.size === 0) return 0;
|
|
3536
|
+
const entryTokens = collectTailwindV4SourceFingerprint(entrySource);
|
|
3537
|
+
let score = 0;
|
|
3538
|
+
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
3539
|
+
return score;
|
|
3540
|
+
}
|
|
3541
|
+
function resolveSubpackageRootForFile(file, subpackageRoots) {
|
|
3542
|
+
if (!file || !subpackageRoots) return;
|
|
3543
|
+
return [...subpackageRoots].find((root) => isSubpackageOutputFile(file, new Set([root])));
|
|
3544
|
+
}
|
|
3545
|
+
function isSameSubpackageScope(outputFile, sourceFile, subpackageRoots) {
|
|
3546
|
+
return resolveSubpackageRootForFile(outputFile, subpackageRoots) === resolveSubpackageRootForFile(sourceFile, subpackageRoots);
|
|
3547
|
+
}
|
|
3548
|
+
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, subpackageRoots) {
|
|
3549
|
+
const generationSources = entries.filter((entry) => hasTailwindGenerationSource(entry.source));
|
|
3550
|
+
if (generationSources.length <= 1) return generationSources[0];
|
|
3551
|
+
const selectByRawSourceFingerprint = (candidates) => {
|
|
3552
|
+
const scoredSources = candidates.map((entry) => ({
|
|
3553
|
+
entry,
|
|
3554
|
+
score: scoreConfiguredTailwindV4SourceForRawSource(rawSource, entry.source)
|
|
3555
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
3556
|
+
const bestScore = scoredSources[0]?.score;
|
|
3557
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
3558
|
+
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3559
|
+
};
|
|
3560
|
+
const rawSourceMatched = selectByRawSourceFingerprint(generationSources);
|
|
3561
|
+
if (rawSourceMatched) return rawSourceMatched;
|
|
3562
|
+
const scopedSources = subpackageRoots ? generationSources.filter((entry) => {
|
|
3563
|
+
const outputMatchesSubpackage = isSubpackageOutputFile(outputFile, subpackageRoots);
|
|
3564
|
+
const sourceMatchesSubpackage = isSubpackageOutputFile(entry.file, subpackageRoots);
|
|
3565
|
+
if (!outputMatchesSubpackage) return !sourceMatchesSubpackage;
|
|
3566
|
+
return sourceMatchesSubpackage && [...subpackageRoots].some((root) => isSubpackageOutputFile(outputFile, new Set([root])) && isSubpackageOutputFile(entry.file, new Set([root])));
|
|
3567
|
+
}) : generationSources;
|
|
3568
|
+
const explicitSources = scopedSources.filter((entry) => /@(?:config|source|plugin|custom-variant|theme|utility|variant|apply)\b/.test(entry.source));
|
|
3569
|
+
const candidates = explicitSources.length === 1 ? explicitSources : scopedSources;
|
|
3570
|
+
if (candidates.length === 1) return candidates[0];
|
|
3571
|
+
return selectByRawSourceFingerprint(candidates);
|
|
3572
|
+
}
|
|
3573
|
+
//#endregion
|
|
3243
3574
|
//#region src/bundlers/vite/generate-bundle/timing.ts
|
|
3244
3575
|
function createBundleTaskTimer(recordTimingDetail) {
|
|
3245
3576
|
return async (name, task) => {
|
|
@@ -3252,6 +3583,102 @@ function createBundleTaskTimer(recordTimingDetail) {
|
|
|
3252
3583
|
};
|
|
3253
3584
|
}
|
|
3254
3585
|
//#endregion
|
|
3586
|
+
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
3587
|
+
function toArray(value) {
|
|
3588
|
+
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
3589
|
+
}
|
|
3590
|
+
function normalizeSourceId(id) {
|
|
3591
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
3592
|
+
return node_path.default.isAbsolute(file) ? node_path.default.resolve(file) : void 0;
|
|
3593
|
+
}
|
|
3594
|
+
function collectChunkModuleIds$1(chunk) {
|
|
3595
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3596
|
+
for (const id of chunk.moduleIds ?? []) {
|
|
3597
|
+
const normalized = normalizeSourceId(id);
|
|
3598
|
+
if (normalized) ids.add(normalized);
|
|
3599
|
+
}
|
|
3600
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
3601
|
+
const normalized = normalizeSourceId(id);
|
|
3602
|
+
if (normalized) ids.add(normalized);
|
|
3603
|
+
}
|
|
3604
|
+
return ids;
|
|
3605
|
+
}
|
|
3606
|
+
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
3607
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3608
|
+
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
3609
|
+
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
3610
|
+
for (const candidate of candidates) {
|
|
3611
|
+
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
3612
|
+
const cleanCandidate = (0, _weapp_tailwindcss_shared.cleanUrl)(candidate);
|
|
3613
|
+
const resolved = node_path.default.isAbsolute(cleanCandidate) ? node_path.default.resolve(cleanCandidate) : node_path.default.resolve(rootDir, cleanCandidate);
|
|
3614
|
+
ids.add(resolved);
|
|
3615
|
+
}
|
|
3616
|
+
return ids;
|
|
3617
|
+
}
|
|
3618
|
+
function isStringRuleMatched(rule, id, rootDir) {
|
|
3619
|
+
const normalizedId = require_source_candidate_scan_signature.slash(id);
|
|
3620
|
+
const normalizedRule = require_source_candidate_scan_signature.slash(rule);
|
|
3621
|
+
if (node_path.default.isAbsolute(rule)) return micromatch.default.isMatch(normalizedId, normalizedRule);
|
|
3622
|
+
const relative = require_source_candidate_scan_signature.slash(node_path.default.relative(rootDir, id));
|
|
3623
|
+
return relative.length > 0 && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizedRule);
|
|
3624
|
+
}
|
|
3625
|
+
function isRuleMatched(rule, id, rootDir) {
|
|
3626
|
+
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
3627
|
+
if (rule instanceof RegExp) {
|
|
3628
|
+
rule.lastIndex = 0;
|
|
3629
|
+
return rule.test(require_source_candidate_scan_signature.slash(id));
|
|
3630
|
+
}
|
|
3631
|
+
return rule(id) === true;
|
|
3632
|
+
}
|
|
3633
|
+
function createTransformMatcher(rules, rootDir) {
|
|
3634
|
+
const normalizedRules = toArray(rules);
|
|
3635
|
+
if (normalizedRules.length === 0) return;
|
|
3636
|
+
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
3637
|
+
}
|
|
3638
|
+
function shouldSkipSourceIds(sourceIds, filter) {
|
|
3639
|
+
if (sourceIds.size === 0) return false;
|
|
3640
|
+
if (filter.exclude) {
|
|
3641
|
+
let excluded = true;
|
|
3642
|
+
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
3643
|
+
excluded = false;
|
|
3644
|
+
break;
|
|
3645
|
+
}
|
|
3646
|
+
if (excluded) return true;
|
|
3647
|
+
}
|
|
3648
|
+
if (filter.include) {
|
|
3649
|
+
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
3650
|
+
return true;
|
|
3651
|
+
}
|
|
3652
|
+
return false;
|
|
3653
|
+
}
|
|
3654
|
+
function createTransformFilter(options, rootDir) {
|
|
3655
|
+
const include = createTransformMatcher(options?.include, rootDir);
|
|
3656
|
+
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
3657
|
+
if (!include && !exclude) return;
|
|
3658
|
+
return {
|
|
3659
|
+
include,
|
|
3660
|
+
exclude
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
3664
|
+
if (!filter) return false;
|
|
3665
|
+
return shouldSkipSourceIds(collectChunkModuleIds$1(chunk), filter);
|
|
3666
|
+
}
|
|
3667
|
+
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
3668
|
+
if (!filter) return false;
|
|
3669
|
+
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
3670
|
+
}
|
|
3671
|
+
function createRuleSignature(rules) {
|
|
3672
|
+
return toArray(rules).map((rule) => {
|
|
3673
|
+
if (typeof rule === "string") return `s:${rule}`;
|
|
3674
|
+
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
3675
|
+
return "f";
|
|
3676
|
+
}).join("|") || "none";
|
|
3677
|
+
}
|
|
3678
|
+
function createTransformFilterSignature(options) {
|
|
3679
|
+
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
3680
|
+
}
|
|
3681
|
+
//#endregion
|
|
3255
3682
|
//#region src/bundlers/vite/uni-app-x-css-options.ts
|
|
3256
3683
|
function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
3257
3684
|
const uniUtsPlatform = require_utils.resolveUniUtsPlatform();
|
|
@@ -3284,7 +3711,7 @@ function resolveWeappViteSourceRoot(config, _appType) {
|
|
|
3284
3711
|
const root = typeof viteConfig?.root === "string" && viteConfig.root.length > 0 ? node_path.default.resolve(viteConfig.root) : node_process.default.cwd();
|
|
3285
3712
|
const configuredSrcRoot = resolveSourceRootCandidate(root, viteConfig?.weapp?.srcRoot);
|
|
3286
3713
|
if (configuredSrcRoot) return configuredSrcRoot;
|
|
3287
|
-
const envSrcRoot = resolveSourceRootCandidate(root, node_process.default.env
|
|
3714
|
+
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
3715
|
if (envSrcRoot) return envSrcRoot;
|
|
3289
3716
|
}
|
|
3290
3717
|
function stripFileExtension(file) {
|
|
@@ -3328,32 +3755,6 @@ function resolveSourceRootFromBundleGraph(config, bundle) {
|
|
|
3328
3755
|
}
|
|
3329
3756
|
//#endregion
|
|
3330
3757
|
//#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
3758
|
function createGenerateBundleHook(context) {
|
|
3358
3759
|
const state = require_source_candidate_scan_signature.createBundleBuildState();
|
|
3359
3760
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
@@ -3443,119 +3844,17 @@ function createGenerateBundleHook(context) {
|
|
|
3443
3844
|
}
|
|
3444
3845
|
}
|
|
3445
3846
|
}, 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
3847
|
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
|
-
};
|
|
3848
|
+
const resolveMatchedCssSourceOutputFile = (sourceFile) => resolveOutputFileFromMatchedCssSource({
|
|
3849
|
+
bundleFiles,
|
|
3850
|
+
defaultStyleOutputExtension,
|
|
3851
|
+
isWebGeneratorTarget,
|
|
3852
|
+
opts,
|
|
3853
|
+
rootDir,
|
|
3854
|
+
shouldPreserveAppCssExtension: false,
|
|
3855
|
+
sourceFile,
|
|
3856
|
+
sourceRoot
|
|
3857
|
+
});
|
|
3559
3858
|
const usedConfiguredTailwindV4CssSourceFiles = /* @__PURE__ */ new Set();
|
|
3560
3859
|
const buildCommand = resolvedConfig?.command === "build";
|
|
3561
3860
|
const hasPreviousBundleState = state.iteration > 0 || state.sourceHashByFile.size > 0;
|
|
@@ -3605,33 +3904,47 @@ function createGenerateBundleHook(context) {
|
|
|
3605
3904
|
});
|
|
3606
3905
|
const jsEntries = snapshot.jsEntries;
|
|
3607
3906
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
3907
|
+
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
3908
|
+
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
3608
3909
|
const moduleGraphOptions = require_source_candidate_scan_signature.createBundleModuleGraphOptions(outDir, jsEntries);
|
|
3609
3910
|
const hasRuntimeAffectingChanges = require_source_candidate_scan_signature.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
3610
3911
|
const runtimeStart = performance.now();
|
|
3611
3912
|
const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
|
|
3612
|
-
const runtime = isWebGeneratorTarget
|
|
3913
|
+
const runtime = isWebGeneratorTarget ? /* @__PURE__ */ new Set() : useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, envFlags.forceRuntimeRefreshByEnv, {
|
|
3914
|
+
allowBaselineOnlyInitialSync: buildCommand,
|
|
3915
|
+
refreshBySource: forceV4RuntimeRefreshBySource
|
|
3916
|
+
}) : await context.ensureRuntimeClassSet(envFlags.forceRuntimeRefreshByEnv);
|
|
3613
3917
|
const shouldFilterTailwindV4MiniProgramCandidates = require_generator.shouldUseMiniProgramCssBranch(generatorBranch);
|
|
3614
3918
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
3615
3919
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
3616
|
-
const
|
|
3920
|
+
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
3921
|
+
const transformRuntime = shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
3617
3922
|
const generatorRuntime = filteredGeneratorCandidates;
|
|
3618
3923
|
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
3619
|
-
|
|
3924
|
+
const hasMultipleConfiguredCssEntries = (opts.cssEntries?.length ?? 0) > 1;
|
|
3925
|
+
if (sourceCandidates.size > 0 && !hasMultipleConfiguredCssEntries) {
|
|
3620
3926
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
3621
3927
|
if (mainCssEntry) {
|
|
3622
|
-
const
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3928
|
+
const mainCssRawSource = typeof mainCssEntry.output.source === "string" ? mainCssEntry.output.source : node_buffer.Buffer.from(mainCssEntry.output.source).toString();
|
|
3929
|
+
if (!require_v4_engine.hasTailwindApplyDirective(mainCssRawSource)) {
|
|
3930
|
+
const generatedCssSources = /* @__PURE__ */ new Set();
|
|
3931
|
+
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) if (typeof record === "string") generatedCssSources.add(record);
|
|
3932
|
+
else if (typeof record?.css === "string") generatedCssSources.add(record.css);
|
|
3933
|
+
const validatedSourceRuntime = await require_hmr_timing.validateCandidatesByGenerator({
|
|
3934
|
+
opts,
|
|
3935
|
+
runtimeState,
|
|
3936
|
+
candidates: filteredSourceCandidates,
|
|
3937
|
+
rawSource: mainCssRawSource,
|
|
3938
|
+
generatedCssSources,
|
|
3939
|
+
file: mainCssEntry.file,
|
|
3940
|
+
cssHandlerOptions: getCssHandlerOptions(mainCssEntry.file),
|
|
3941
|
+
cssUserHandlerOptions: getCssUserHandlerOptions(mainCssEntry.file),
|
|
3942
|
+
styleHandler,
|
|
3943
|
+
debug,
|
|
3944
|
+
skipGenerateFallback: false
|
|
3945
|
+
});
|
|
3946
|
+
if (validatedSourceRuntime.size > 0) for (const candidate of validatedSourceRuntime) transformRuntime.add(candidate);
|
|
3947
|
+
}
|
|
3635
3948
|
}
|
|
3636
3949
|
}
|
|
3637
3950
|
const generatorCandidateSignature = require_source_candidate_scan_signature.createCandidateSignature(generatorRuntime);
|
|
@@ -3639,21 +3952,24 @@ function createGenerateBundleHook(context) {
|
|
|
3639
3952
|
const cssExtensionByStem = collectCssExtensionByStem(bundleFiles, opts.cssMatcher);
|
|
3640
3953
|
const jsImportedCssFiles = collectJsImportedCssFiles(snapshot);
|
|
3641
3954
|
const runtimeLinkedCssFiles = new Set([...collectRuntimeLinkedCssFiles(snapshot, cssExtensionByStem, defaultStyleOutputExtension), ...jsImportedCssFiles]);
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3955
|
+
rememberRuntimeLinkedCssSources({
|
|
3956
|
+
bundleFiles,
|
|
3957
|
+
debug,
|
|
3958
|
+
defaultStyleOutputExtension,
|
|
3959
|
+
getConfiguredTailwindV4CssSourceEntries,
|
|
3960
|
+
getSourceCandidateSource,
|
|
3961
|
+
getSourceCandidateSources,
|
|
3962
|
+
isWebGeneratorTarget,
|
|
3963
|
+
jsImportedCssFiles,
|
|
3964
|
+
opts,
|
|
3965
|
+
outDir,
|
|
3966
|
+
rememberCssSource,
|
|
3967
|
+
rootDir,
|
|
3968
|
+
runtimeLinkedCssFiles,
|
|
3969
|
+
shouldPreserveAppCssExtension,
|
|
3970
|
+
snapshot,
|
|
3971
|
+
sourceRoot
|
|
3972
|
+
});
|
|
3657
3973
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
3658
3974
|
const dynamicRetryCandidates = new Set([
|
|
3659
3975
|
...sourceCandidates,
|
|
@@ -3695,90 +4011,86 @@ function createGenerateBundleHook(context) {
|
|
|
3695
4011
|
debug("html skip web target: %s", file);
|
|
3696
4012
|
continue;
|
|
3697
4013
|
}
|
|
4014
|
+
if (shouldSkipViteAssetTransform(originalSource, file, rootDir, transformFilter)) {
|
|
4015
|
+
metrics.html.transformed++;
|
|
4016
|
+
debug("html skip transform (filtered): %s", file);
|
|
4017
|
+
continue;
|
|
4018
|
+
}
|
|
3698
4019
|
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({
|
|
4020
|
+
processHtmlBundleEntry({
|
|
3708
4021
|
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
|
-
})));
|
|
4022
|
+
context,
|
|
4023
|
+
debug,
|
|
4024
|
+
dynamicRetryCandidates,
|
|
4025
|
+
file,
|
|
4026
|
+
metrics,
|
|
4027
|
+
onUpdate,
|
|
4028
|
+
originalEntrySource,
|
|
4029
|
+
originalSource,
|
|
4030
|
+
rememberProcessCacheKey,
|
|
4031
|
+
resolveCurrentSourceCandidateSource: (file) => resolveCurrentSourceCandidateSource({
|
|
4032
|
+
file,
|
|
4033
|
+
getSourceCandidateSource,
|
|
4034
|
+
getSourceCandidateSources,
|
|
4035
|
+
outDir,
|
|
4036
|
+
rootDir,
|
|
4037
|
+
sourceRoot
|
|
4038
|
+
}),
|
|
4039
|
+
tasks,
|
|
4040
|
+
templateHandler,
|
|
4041
|
+
timeTask,
|
|
4042
|
+
transformRuntime,
|
|
4043
|
+
transformRuntimeSignature
|
|
4044
|
+
});
|
|
3743
4045
|
continue;
|
|
3744
4046
|
}
|
|
3745
4047
|
if (type === "css" && originalSource.type === "asset") {
|
|
3746
4048
|
metrics.css.total++;
|
|
3747
4049
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
3748
4050
|
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
|
|
3749
|
-
let outputFile =
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
};
|
|
4051
|
+
let outputFile = resolveCssBundleOutputFile({
|
|
4052
|
+
bundleFiles,
|
|
4053
|
+
defaultStyleOutputExtension,
|
|
4054
|
+
file,
|
|
4055
|
+
isWebGeneratorTarget,
|
|
4056
|
+
opts,
|
|
4057
|
+
shouldPreserveAppCssExtension
|
|
4058
|
+
});
|
|
4059
|
+
const resolveMatchedOutputFileForCurrentAsset = createMatchedCssSourceOutputResolver({
|
|
4060
|
+
assetSourceFile,
|
|
4061
|
+
file,
|
|
4062
|
+
originalFileNames: originalSource.originalFileNames,
|
|
4063
|
+
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
4064
|
+
});
|
|
3757
4065
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
3758
|
-
if (outputFile
|
|
4066
|
+
if (shouldSkipRawSourceStyleAsset(outputFile, file, rawSource)) {
|
|
3759
4067
|
delete bundle[file];
|
|
3760
4068
|
debug("css skip raw source style asset: %s -> %s", file, outputFile);
|
|
3761
4069
|
continue;
|
|
3762
4070
|
}
|
|
4071
|
+
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
4072
|
+
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
3763
4073
|
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;
|
|
4074
|
+
applyCssResultToBundle({
|
|
4075
|
+
appType: opts.appType,
|
|
4076
|
+
assetSourceFile,
|
|
4077
|
+
bundle,
|
|
4078
|
+
emitOrReplayCssAsset,
|
|
4079
|
+
file,
|
|
4080
|
+
originalSource,
|
|
4081
|
+
outputFile,
|
|
4082
|
+
source,
|
|
4083
|
+
viteProcessedCssAsset
|
|
4084
|
+
});
|
|
3781
4085
|
};
|
|
4086
|
+
if (shouldSkipViteAssetTransform(originalSource, file, rootDir, transformFilter)) {
|
|
4087
|
+
applyCssResult(rawSource);
|
|
4088
|
+
markCssAssetProcessed?.(originalSource, outputFile);
|
|
4089
|
+
onUpdate(outputFile, rawSource, rawSource);
|
|
4090
|
+
metrics.css.transformed++;
|
|
4091
|
+
debug("css skip transform (filtered): %s", outputFile);
|
|
4092
|
+
continue;
|
|
4093
|
+
}
|
|
3782
4094
|
if (isWebGeneratorTarget && !shouldGenerateWebCssByGenerator) {
|
|
3783
4095
|
applyCssResult(rawSource);
|
|
3784
4096
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
@@ -3786,12 +4098,12 @@ function createGenerateBundleHook(context) {
|
|
|
3786
4098
|
debug("css skip web target: %s", outputFile);
|
|
3787
4099
|
continue;
|
|
3788
4100
|
}
|
|
3789
|
-
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
3790
|
-
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
3791
4101
|
const cssAssetProcessed = isCssAssetProcessed?.(originalSource, file) === true;
|
|
3792
4102
|
const alreadyProcessedCssAsset = viteProcessedCssAsset || cssAssetProcessed;
|
|
3793
4103
|
let rememberedCssSources = findRememberedCssSources(getRememberedCssSources?.(), outputFile, file, originalSource, outDir, opts.tailwindcssBasedir);
|
|
3794
|
-
if (rememberedCssSources.length > 0) rememberedCssSources = await Promise.all(rememberedCssSources.map(async (remembered) =>
|
|
4104
|
+
if (rememberedCssSources.length > 0) rememberedCssSources = await Promise.all(rememberedCssSources.map(async (remembered) => {
|
|
4105
|
+
return await refreshRememberedCssSource?.(remembered) ?? remembered;
|
|
4106
|
+
}));
|
|
3795
4107
|
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
4108
|
const inferredSfcStyleSource = await resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outDir, opts.tailwindcssBasedir, opts.cssMatcher, getSfcSource, debug);
|
|
3797
4109
|
if (inferredSfcStyleSource) {
|
|
@@ -3800,7 +4112,7 @@ function createGenerateBundleHook(context) {
|
|
|
3800
4112
|
if (!hasUsableRememberedTailwindSource || rememberedSourcesBelongToInferredSfc) rememberedCssSources = [inferredSfcStyleSource];
|
|
3801
4113
|
}
|
|
3802
4114
|
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))) {
|
|
4115
|
+
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
4116
|
rememberedCssSources = [];
|
|
3805
4117
|
hasUsableRememberedTailwindSource = false;
|
|
3806
4118
|
}
|
|
@@ -3817,8 +4129,8 @@ function createGenerateBundleHook(context) {
|
|
|
3817
4129
|
}];
|
|
3818
4130
|
} else if (hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
3819
4131
|
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)) {
|
|
4132
|
+
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, currentSubpackageRoots);
|
|
4133
|
+
if (configuredGenerationSource && !hasViteProcessedCssResultForSource(configuredGenerationSource.file, getViteProcessedCssAssetResults)) {
|
|
3822
4134
|
outputFile = resolveMatchedOutputFileForCurrentAsset(configuredGenerationSource.file) ?? outputFile;
|
|
3823
4135
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
3824
4136
|
outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
@@ -3898,8 +4210,10 @@ function createGenerateBundleHook(context) {
|
|
|
3898
4210
|
const shouldInjectVitePipelineCssIntoMain = vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && shouldInjectCssIntoMainFromOutput(outputFile, generatorSourceFile, outputCssHandlerOptions);
|
|
3899
4211
|
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
4212
|
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) || require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(rawSource));
|
|
3901
|
-
|
|
3902
|
-
|
|
4213
|
+
const strippedViteProcessedCss = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(rawSource);
|
|
4214
|
+
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);
|
|
4215
|
+
if (alreadyProcessedCssAsset && !shouldRefreshViteProcessedCssByCandidates && (!hasStaleViteProcessedCssSource || shouldPreserveStaleGeneratedCssAsset) && !hasRememberedApplySource && !shouldRegenerateMainPackageCssWithScopedCandidates && (!shouldTrackGeneratorRuntime || shouldPreserveCollectedViteCssAsset)) {
|
|
4216
|
+
const nextCss = strippedViteProcessedCss;
|
|
3903
4217
|
applyCssResult(nextCss);
|
|
3904
4218
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
3905
4219
|
recordCssAssetResult?.(outputFile, nextCss);
|
|
@@ -3918,9 +4232,9 @@ function createGenerateBundleHook(context) {
|
|
|
3918
4232
|
}) : trackedGeneratorCandidateSignature;
|
|
3919
4233
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
3920
4234
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
3921
|
-
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${
|
|
3922
|
-
const cssCacheKey =
|
|
3923
|
-
const cssHashKey = `${
|
|
4235
|
+
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}:${sourceTraceSignature}`;
|
|
4236
|
+
const cssCacheKey = outputFile;
|
|
4237
|
+
const cssHashKey = `${outputFile}:css:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}`;
|
|
3924
4238
|
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
4239
|
if (!shouldTrackGeneratorRuntime && !runtimeLinkedCssFiles.has(file) && !runtimeLinkedCssFiles.has(outputFile)) {
|
|
3926
4240
|
const lastCss = getLastCssResult(lastCssResultByFile, outputFile, file);
|
|
@@ -3989,6 +4303,7 @@ function createGenerateBundleHook(context) {
|
|
|
3989
4303
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
3990
4304
|
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource, tracedCss));
|
|
3991
4305
|
debug("css generated result: %s bytes=%d", file, tracedCss.length);
|
|
4306
|
+
for (const candidate of generated.classSet ?? []) transformRuntime.add(candidate);
|
|
3992
4307
|
recordCssAssetResult?.(outputFile, tracedCss);
|
|
3993
4308
|
recordViteProcessedCssAssetResult?.(outputFile, tracedCss, {
|
|
3994
4309
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
@@ -4050,8 +4365,12 @@ function createGenerateBundleHook(context) {
|
|
|
4050
4365
|
rememberProcessCacheKey,
|
|
4051
4366
|
runtimeSignature,
|
|
4052
4367
|
snapshot,
|
|
4368
|
+
transformFilterSignature,
|
|
4369
|
+
shouldSkipAstTransform: transformFilter ? (chunk) => shouldSkipViteJsChunkTransform(chunk, transformFilter) : void 0,
|
|
4370
|
+
slowJsAstWarnMs: envFlags.slowJsAstWarnMs,
|
|
4053
4371
|
timeTask,
|
|
4054
4372
|
transformRuntime,
|
|
4373
|
+
transformRuntimeSignature,
|
|
4055
4374
|
uniAppX,
|
|
4056
4375
|
useIncrementalMode
|
|
4057
4376
|
});
|
|
@@ -4062,10 +4381,10 @@ function createGenerateBundleHook(context) {
|
|
|
4062
4381
|
bundle,
|
|
4063
4382
|
bundleFiles,
|
|
4064
4383
|
cache,
|
|
4384
|
+
cssTaskFactories,
|
|
4065
4385
|
createScopedGeneratorRuntime: createScopedGeneratorRuntime$1,
|
|
4066
4386
|
createScopedSourceCandidateGetter,
|
|
4067
4387
|
createScopedSourceCandidateSourceGetter,
|
|
4068
|
-
cssTaskFactories,
|
|
4069
4388
|
debug,
|
|
4070
4389
|
defaultStyleOutputExtension,
|
|
4071
4390
|
emitOrReplayCssAsset,
|
|
@@ -4096,7 +4415,6 @@ function createGenerateBundleHook(context) {
|
|
|
4096
4415
|
timeTask,
|
|
4097
4416
|
useIncrementalMode
|
|
4098
4417
|
});
|
|
4099
|
-
require_hmr_timing.pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
4100
4418
|
await finalizeGenerateBundle({
|
|
4101
4419
|
activeProcessCacheKeys,
|
|
4102
4420
|
activeProcessHashKeys,
|
|
@@ -4121,6 +4439,8 @@ function createGenerateBundleHook(context) {
|
|
|
4121
4439
|
isNativeAppStyleTarget,
|
|
4122
4440
|
isViteProcessedCssAsset,
|
|
4123
4441
|
isWebGeneratorTarget,
|
|
4442
|
+
jsAfterCss: shouldFilterTailwindV4MiniProgramCandidates && cssTaskFactories.length > 0,
|
|
4443
|
+
jsTaskFactories,
|
|
4124
4444
|
lastCssResultByFile,
|
|
4125
4445
|
lastCssSourceHashByFile,
|
|
4126
4446
|
linkedByEntry,
|
|
@@ -4174,7 +4494,7 @@ function createCssHandlerOptions(opts, majorVersion, file) {
|
|
|
4174
4494
|
...resolveUniAppXNativeCssHandlerOptions(opts),
|
|
4175
4495
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
4176
4496
|
postcssOptions: { options: { from: file } },
|
|
4177
|
-
...majorVersion === void 0 ? {} : { majorVersion }
|
|
4497
|
+
...require_context.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
4178
4498
|
};
|
|
4179
4499
|
}
|
|
4180
4500
|
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
@@ -4459,6 +4779,7 @@ function shouldCollectTransformedSourceCandidates(id) {
|
|
|
4459
4779
|
function createViteCssMemory(options) {
|
|
4460
4780
|
const rememberedCssSources = /* @__PURE__ */ new Map();
|
|
4461
4781
|
const rememberedCssSignatureByFile = /* @__PURE__ */ new Map();
|
|
4782
|
+
const knownCssSources = /* @__PURE__ */ new Map();
|
|
4462
4783
|
const knownSfcSources = /* @__PURE__ */ new Map();
|
|
4463
4784
|
const rememberKnownSfcSource = (id, code) => {
|
|
4464
4785
|
if (id.search(/[?#]/) >= 0) return;
|
|
@@ -4510,6 +4831,7 @@ function createViteCssMemory(options) {
|
|
|
4510
4831
|
return nextRemembered;
|
|
4511
4832
|
};
|
|
4512
4833
|
const refreshRememberedCssSourceBySourceFile = (sourceFile, rawSource) => {
|
|
4834
|
+
touchMapEntry(knownCssSources, normalizeCssSourceIdentity(sourceFile), rawSource);
|
|
4513
4835
|
const normalizedSourceFile = normalizeCssSourceIdentity(sourceFile);
|
|
4514
4836
|
const relatedRememberedEntries = [...rememberedCssSources].filter(([, remembered]) => normalizeCssSourceIdentity(remembered.sourceFile) === normalizedSourceFile);
|
|
4515
4837
|
for (const [rememberedKey, remembered] of relatedRememberedEntries) refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
|
|
@@ -4523,6 +4845,10 @@ function createViteCssMemory(options) {
|
|
|
4523
4845
|
const cached = resolveCachedStyleSource(sourceFile);
|
|
4524
4846
|
if (cached != null) return cached;
|
|
4525
4847
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_source_candidate_scan_signature.stripRequestQuery(sourceFile));
|
|
4848
|
+
const knownSource = knownCssSources.get(normalizeCssSourceIdentity(sourceFile));
|
|
4849
|
+
if (knownSource != null) return knownSource;
|
|
4850
|
+
const candidateSource = options.getSourceCandidateSource(file);
|
|
4851
|
+
if (candidateSource != null) return candidateSource;
|
|
4526
4852
|
if (!require_source_candidate_scan_signature.isSourceStyleRequest(file)) return;
|
|
4527
4853
|
try {
|
|
4528
4854
|
return await (0, node_fs_promises.readFile)(file, "utf8");
|
|
@@ -4584,6 +4910,7 @@ function createViteCssMemory(options) {
|
|
|
4584
4910
|
pruneMapToMaxSize(rememberedCssSources, VITE_REMEMBERED_CSS_CACHE_MAX, (rememberedKey) => {
|
|
4585
4911
|
rememberedCssSignatureByFile.delete(String(rememberedKey));
|
|
4586
4912
|
});
|
|
4913
|
+
pruneMapToMaxSize(knownCssSources, VITE_REMEMBERED_CSS_CACHE_MAX);
|
|
4587
4914
|
pruneMapToMaxSize(knownSfcSources, VITE_KNOWN_SFC_SOURCE_CACHE_MAX);
|
|
4588
4915
|
};
|
|
4589
4916
|
return {
|
|
@@ -4595,6 +4922,8 @@ function createViteCssMemory(options) {
|
|
|
4595
4922
|
rememberedCssSources: rememberedCssSources.size,
|
|
4596
4923
|
rememberedCssSourcesRaw: summarizeRememberedCssSources(rememberedCssSources),
|
|
4597
4924
|
rememberedCssSignatureByFile: rememberedCssSignatureByFile.size,
|
|
4925
|
+
knownCssSources: knownCssSources.size,
|
|
4926
|
+
knownCssSourcesRaw: summarizeStringMapCache(knownCssSources),
|
|
4598
4927
|
knownSfcSources: knownSfcSources.size,
|
|
4599
4928
|
knownSfcSourcesRaw: summarizeStringMapCache(knownSfcSources)
|
|
4600
4929
|
}),
|
|
@@ -4721,6 +5050,35 @@ function disableAndRemoveTailwindVitePlugins(plugins) {
|
|
|
4721
5050
|
return removed;
|
|
4722
5051
|
}
|
|
4723
5052
|
//#endregion
|
|
5053
|
+
//#region src/bundlers/vite/plugin-cache.ts
|
|
5054
|
+
function isMissingInternalCssSource(file, packageDir) {
|
|
5055
|
+
return !(0, node_fs.existsSync)(file) && node_path.default.resolve(file).startsWith(`${packageDir}${node_path.default.sep}`);
|
|
5056
|
+
}
|
|
5057
|
+
function normalizeVitePersistentCacheKey(file) {
|
|
5058
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
5059
|
+
}
|
|
5060
|
+
function toMb(bytes) {
|
|
5061
|
+
return Math.round(bytes / 1024 / 1024);
|
|
5062
|
+
}
|
|
5063
|
+
function summarizeStringCache(map) {
|
|
5064
|
+
let bytes = 0;
|
|
5065
|
+
for (const value of map.values()) bytes += value.length;
|
|
5066
|
+
return {
|
|
5067
|
+
bytes,
|
|
5068
|
+
mb: toMb(bytes),
|
|
5069
|
+
size: map.size
|
|
5070
|
+
};
|
|
5071
|
+
}
|
|
5072
|
+
function summarizeViteProcessedCssResults(map) {
|
|
5073
|
+
let bytes = 0;
|
|
5074
|
+
for (const record of map.values()) bytes += record.css.length;
|
|
5075
|
+
return {
|
|
5076
|
+
bytes,
|
|
5077
|
+
mb: toMb(bytes),
|
|
5078
|
+
size: map.size
|
|
5079
|
+
};
|
|
5080
|
+
}
|
|
5081
|
+
//#endregion
|
|
4724
5082
|
//#region src/bundlers/shared/css-imports.ts
|
|
4725
5083
|
const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
|
|
4726
5084
|
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
@@ -4892,7 +5250,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
4892
5250
|
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
4893
5251
|
}
|
|
4894
5252
|
}
|
|
4895
|
-
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false,
|
|
5253
|
+
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false, options = {}) {
|
|
4896
5254
|
const forceRuntimeRefresh = forceRefresh || node_process.default.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
4897
5255
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
4898
5256
|
const shouldRefreshRuntime = forceRuntimeRefresh || invalidation.changed;
|
|
@@ -4906,7 +5264,14 @@ function createViteRuntimeClassSet(options) {
|
|
|
4906
5264
|
await transformRuntimeClassSetManager.reset();
|
|
4907
5265
|
}
|
|
4908
5266
|
if (!forceRuntimeRefresh) try {
|
|
4909
|
-
const
|
|
5267
|
+
const baseClassSet = options.baseClassSet ?? runtimeSet ?? await require_context.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
5268
|
+
force: invalidation.changed,
|
|
5269
|
+
clearCache: invalidation.changed
|
|
5270
|
+
});
|
|
5271
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
|
|
5272
|
+
baseClassSet,
|
|
5273
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync
|
|
5274
|
+
});
|
|
4910
5275
|
runtimeSet = nextRuntimeSet;
|
|
4911
5276
|
return nextRuntimeSet;
|
|
4912
5277
|
} catch (error) {
|
|
@@ -5038,33 +5403,6 @@ const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resol
|
|
|
5038
5403
|
const weappTailwindcssDirPosix = require_source_candidate_scan_signature.slash(weappTailwindcssPackageDir);
|
|
5039
5404
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
5040
5405
|
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
5406
|
/**
|
|
5069
5407
|
* @name WeappTailwindcss
|
|
5070
5408
|
* @description uni-app vite / uni-app-x 版本插件
|
|
@@ -5117,7 +5455,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5117
5455
|
let autoCssSourcesRefresh;
|
|
5118
5456
|
let autoCssSourcesDiscovered = false;
|
|
5119
5457
|
const syncTailwindCssSourceCandidates = async (id, css) => {
|
|
5120
|
-
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource((0, _weapp_tailwindcss_shared.cleanUrl)(id))) return;
|
|
5458
|
+
if (tailwindcssMajorVersion === 4 && isMissingInternalCssSource((0, _weapp_tailwindcss_shared.cleanUrl)(id), weappTailwindcssPackageDir)) return;
|
|
5121
5459
|
await sourceCandidateCollector.syncCss(id, css);
|
|
5122
5460
|
cacheCurrentSourceCandidateScan();
|
|
5123
5461
|
};
|
|
@@ -5126,7 +5464,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5126
5464
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5127
5465
|
if (!node_path.default.isAbsolute(file)) return;
|
|
5128
5466
|
if (!require_v4_engine.isTailwindV4CssEntry(file)) return;
|
|
5129
|
-
if (isMissingInternalCssSource(file)) return;
|
|
5467
|
+
if (isMissingInternalCssSource(file, weappTailwindcssPackageDir)) return;
|
|
5130
5468
|
const sourceFile = node_path.default.normalize(file);
|
|
5131
5469
|
const sourceBase = node_path.default.dirname(sourceFile);
|
|
5132
5470
|
const sourceCss = require_v4_engine.normalizeTailwindSourceForGenerator(require_v4_engine.normalizeTailwindConfigDirectives(css, sourceBase), { importFallback: true });
|
|
@@ -5237,7 +5575,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
5237
5575
|
recordedGeneratorCandidates = void 0;
|
|
5238
5576
|
};
|
|
5239
5577
|
const getSourceCandidates = () => sourceCandidateCollector.values();
|
|
5240
|
-
const getSourceCandidatesForEntries = (entries) => sourceCandidateCollector.valuesForEntries(entries);
|
|
5578
|
+
const getSourceCandidatesForEntries = (entries, options) => sourceCandidateCollector.valuesForEntries(entries, options);
|
|
5241
5579
|
const getSourceCandidateSourcesForEntries = (entries, options) => sourceCandidateCollector.sourcesForEntries(entries, options);
|
|
5242
5580
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
5243
5581
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|