weapp-tailwindcss 5.1.14 → 5.1.16
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/auto-2dg_uhEJ.mjs +13 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
- package/dist/bundlers/gulp/index.d.ts +2 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +43 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +4 -2
- package/dist/bundlers/shared/framework-postcss.d.ts +14 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +18 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +33 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +3 -6
- package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
- package/dist/bundlers/shared/generator-css.d.ts +1 -2
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +3 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
- package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle-runtime.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +12 -0
- package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
- package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +4 -2
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +5 -4
- package/dist/bundlers/vite/source-candidates/collector.d.ts +8 -0
- package/dist/bundlers/vite/source-candidates/store.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/types-and-cache.d.ts +69 -0
- package/dist/bundlers/vite/source-candidates.d.ts +4 -68
- package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -217
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +6 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
- package/dist/cli.js +14 -18
- package/dist/cli.mjs +14 -18
- package/dist/{context-VeFq_8vW.js → context-BtLIID4m.js} +3 -3
- package/dist/{context-BL8Gy71H.mjs → context-JzwzSX36.mjs} +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{generator-CEnUsjed.js → generator-B91GhUJQ.js} +636 -505
- package/dist/{generator-B59OA64h.mjs → generator-Bv7myuhY.mjs} +557 -432
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/{gulp-DUYWxmZC.mjs → gulp-CKSklPlH.mjs} +218 -153
- package/dist/{gulp-C1Q3LRzg.js → gulp-Q1wITegn.js} +218 -153
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-C3ed5vCx.mjs → hmr-timing-BXg7nI8N.mjs} +3406 -3145
- package/dist/{hmr-timing-BZ5sWIqO.js → hmr-timing-CMPaWn9P.js} +3474 -3147
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/shared/mpx-plugin-owner.d.ts +2 -0
- package/dist/shared/mpx.d.ts +4 -1
- package/dist/{source-candidate-scan-signature-R3dzamcm.js → source-candidate-scan-signature-BKZZk_e6.js} +144 -96
- package/dist/{source-candidate-scan-signature-D7RWjWsY.mjs → source-candidate-scan-signature-CtK-mB_C.mjs} +127 -60
- package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
- package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +52 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
- package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-B4phC0kB.js} +2 -2
- package/dist/{tailwindcss-DPcKMLxL.mjs → tailwindcss-BTcXX8Ka.mjs} +2 -2
- package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
- package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
- package/dist/{vite-CBU5NXTX.mjs → vite-BwQWl9ft.mjs} +1269 -878
- package/dist/{vite-BNlPdsGM.js → vite-DhVnXvAQ.js} +1314 -923
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-generation-loader.js +12 -0
- package/dist/weapp-tw-css-import-rewrite-loader-B0tVkJLH.js +10524 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +6 -10255
- package/dist/weapp-tw-runtime-classset-loader.js +10 -4
- package/dist/{webpack-CZ38fMGC.mjs → webpack-Bo1QrFPf.mjs} +1518 -1079
- package/dist/{webpack-Jpe048pQ.js → webpack-kh78iMSS.js} +1519 -1080
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +17 -7
- package/dist/auto-CrJJc5rK.mjs +0 -13
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-B91GhUJQ.js");
|
|
4
4
|
const require_object = require("./object-COs_Mw6p.js");
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-B4phC0kB.js");
|
|
6
6
|
require("./utils-CuKLf1Zv.js");
|
|
7
7
|
const require_wxml = require("./wxml-Ce10eREX.js");
|
|
8
|
-
const require_context = require("./context-
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
8
|
+
const require_context = require("./context-BtLIID4m.js");
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-CMPaWn9P.js");
|
|
10
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BKZZk_e6.js");
|
|
11
11
|
require("./logger-TlKT3xmR.js");
|
|
12
12
|
let node_fs = require("node:fs");
|
|
13
13
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
@@ -21,8 +21,8 @@ let lru_cache = require("lru-cache");
|
|
|
21
21
|
let node_fs_promises = require("node:fs/promises");
|
|
22
22
|
let micromatch = require("micromatch");
|
|
23
23
|
micromatch = require_rolldown_runtime.__toESM(micromatch);
|
|
24
|
-
let node_buffer = require("node:buffer");
|
|
25
24
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
25
|
+
let node_buffer = require("node:buffer");
|
|
26
26
|
let comment_json = require("comment-json");
|
|
27
27
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
28
28
|
//#region src/uni-app-x/style-asset/style-value.ts
|
|
@@ -196,8 +196,28 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
196
196
|
}
|
|
197
197
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
|
|
199
|
+
function resolveReferencePaths(styleSource, sourceId) {
|
|
200
|
+
if (!sourceId || !styleSource.includes("@reference")) return styleSource;
|
|
201
|
+
let root;
|
|
202
|
+
try {
|
|
203
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(styleSource);
|
|
204
|
+
} catch {
|
|
205
|
+
return styleSource;
|
|
206
|
+
}
|
|
207
|
+
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
208
|
+
root.walkAtRules("reference", (rule) => {
|
|
209
|
+
const quote = rule.params[0];
|
|
210
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
211
|
+
const closingQuoteIndex = rule.params.indexOf(quote, 1);
|
|
212
|
+
if (closingQuoteIndex <= 1) return;
|
|
213
|
+
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
214
|
+
if (!referencePath.startsWith(".")) return;
|
|
215
|
+
rule.params = `${quote}${node_path.default.resolve(node_path.default.dirname(cleanSourceId), referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
216
|
+
});
|
|
217
|
+
return root.toString();
|
|
218
|
+
}
|
|
219
|
+
function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
|
|
220
|
+
return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE$2)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => resolveReferencePaths(styleSource.trim(), sourceId)).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
|
|
201
221
|
}
|
|
202
222
|
function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
203
223
|
const utilities = /* @__PURE__ */ new Set();
|
|
@@ -242,7 +262,18 @@ const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
|
|
|
242
262
|
const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
|
|
243
263
|
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v2";
|
|
244
264
|
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
245
|
-
return applyStyleSources.
|
|
265
|
+
return applyStyleSources.map((source) => {
|
|
266
|
+
let root;
|
|
267
|
+
try {
|
|
268
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
269
|
+
} catch {
|
|
270
|
+
return source;
|
|
271
|
+
}
|
|
272
|
+
root.walkAtRules("reference", (rule) => {
|
|
273
|
+
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
274
|
+
});
|
|
275
|
+
return root.toString();
|
|
276
|
+
}).join("\n");
|
|
246
277
|
}
|
|
247
278
|
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
248
279
|
const utilities = /* @__PURE__ */ new Set();
|
|
@@ -471,6 +502,138 @@ function createUniAppXBundleAssetSourceGetter(bundle) {
|
|
|
471
502
|
};
|
|
472
503
|
}
|
|
473
504
|
//#endregion
|
|
505
|
+
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
506
|
+
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
507
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
508
|
+
if (!output.fileName || output.fileName === file) continue;
|
|
509
|
+
const existing = bundle[output.fileName];
|
|
510
|
+
if (existing != null && existing !== output) continue;
|
|
511
|
+
bundle[output.fileName] = output;
|
|
512
|
+
delete bundle[file];
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
517
|
+
function toArray(value) {
|
|
518
|
+
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
519
|
+
}
|
|
520
|
+
function normalizeSourceId(id) {
|
|
521
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
522
|
+
return node_path.default.isAbsolute(file) ? node_path.default.resolve(file) : void 0;
|
|
523
|
+
}
|
|
524
|
+
function collectChunkModuleIds$2(chunk) {
|
|
525
|
+
const ids = /* @__PURE__ */ new Set();
|
|
526
|
+
for (const id of chunk.moduleIds ?? []) {
|
|
527
|
+
const normalized = normalizeSourceId(id);
|
|
528
|
+
if (normalized) ids.add(normalized);
|
|
529
|
+
}
|
|
530
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
531
|
+
const normalized = normalizeSourceId(id);
|
|
532
|
+
if (normalized) ids.add(normalized);
|
|
533
|
+
}
|
|
534
|
+
return ids;
|
|
535
|
+
}
|
|
536
|
+
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
537
|
+
const ids = /* @__PURE__ */ new Set();
|
|
538
|
+
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
539
|
+
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
540
|
+
for (const candidate of candidates) {
|
|
541
|
+
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
542
|
+
const cleanCandidate = (0, _weapp_tailwindcss_shared.cleanUrl)(candidate);
|
|
543
|
+
const resolved = node_path.default.isAbsolute(cleanCandidate) ? node_path.default.resolve(cleanCandidate) : node_path.default.resolve(rootDir, cleanCandidate);
|
|
544
|
+
ids.add(resolved);
|
|
545
|
+
}
|
|
546
|
+
return ids;
|
|
547
|
+
}
|
|
548
|
+
function isStringRuleMatched(rule, id, rootDir) {
|
|
549
|
+
const normalizedId = require_source_candidate_scan_signature.slash(id);
|
|
550
|
+
const normalizedRule = require_source_candidate_scan_signature.slash(rule);
|
|
551
|
+
if (node_path.default.isAbsolute(rule)) return micromatch.default.isMatch(normalizedId, normalizedRule);
|
|
552
|
+
const relative = require_source_candidate_scan_signature.slash(node_path.default.relative(rootDir, id));
|
|
553
|
+
return relative.length > 0 && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizedRule);
|
|
554
|
+
}
|
|
555
|
+
function isRuleMatched(rule, id, rootDir) {
|
|
556
|
+
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
557
|
+
if (rule instanceof RegExp) {
|
|
558
|
+
rule.lastIndex = 0;
|
|
559
|
+
return rule.test(require_source_candidate_scan_signature.slash(id));
|
|
560
|
+
}
|
|
561
|
+
return rule(id) === true;
|
|
562
|
+
}
|
|
563
|
+
function createTransformMatcher(rules, rootDir) {
|
|
564
|
+
const normalizedRules = toArray(rules);
|
|
565
|
+
if (normalizedRules.length === 0) return;
|
|
566
|
+
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
567
|
+
}
|
|
568
|
+
function shouldSkipSourceIds(sourceIds, filter) {
|
|
569
|
+
if (sourceIds.size === 0) return false;
|
|
570
|
+
if (filter.exclude) {
|
|
571
|
+
let excluded = true;
|
|
572
|
+
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
573
|
+
excluded = false;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
if (excluded) return true;
|
|
577
|
+
}
|
|
578
|
+
if (filter.include) {
|
|
579
|
+
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
function createTransformFilter(options, rootDir) {
|
|
585
|
+
const include = createTransformMatcher(options?.include, rootDir);
|
|
586
|
+
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
587
|
+
if (!include && !exclude) return;
|
|
588
|
+
return {
|
|
589
|
+
include,
|
|
590
|
+
exclude
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
594
|
+
if (!filter) return false;
|
|
595
|
+
return shouldSkipSourceIds(collectChunkModuleIds$2(chunk), filter);
|
|
596
|
+
}
|
|
597
|
+
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
598
|
+
if (!filter) return false;
|
|
599
|
+
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
600
|
+
}
|
|
601
|
+
function createRuleSignature(rules) {
|
|
602
|
+
return toArray(rules).map((rule) => {
|
|
603
|
+
if (typeof rule === "string") return `s:${rule}`;
|
|
604
|
+
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
605
|
+
return "f";
|
|
606
|
+
}).join("|") || "none";
|
|
607
|
+
}
|
|
608
|
+
function createTransformFilterSignature(options) {
|
|
609
|
+
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
610
|
+
}
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
|
|
613
|
+
async function collectBundleMarkupCandidates(options) {
|
|
614
|
+
const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
|
|
615
|
+
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, candidates]) => [file, new Set(candidates)])) : /* @__PURE__ */ new Map();
|
|
616
|
+
await Promise.all(snapshot.entries.map(async (entry) => {
|
|
617
|
+
if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
|
|
618
|
+
const sourceFile = resolveSourceCandidateFile(entry.file) ?? node_path.default.resolve(rootDir, entry.file);
|
|
619
|
+
candidatesByFile.set(sourceFile, await extractSourceCandidates(sourceFile, entry.source));
|
|
620
|
+
}));
|
|
621
|
+
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
622
|
+
const values = /* @__PURE__ */ new Set();
|
|
623
|
+
for (const [file, candidates] of candidatesByFile) {
|
|
624
|
+
if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(file, entries)) continue;
|
|
625
|
+
if (filterOptions.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
|
|
626
|
+
for (const candidate of candidates) values.add(candidate);
|
|
627
|
+
}
|
|
628
|
+
return values;
|
|
629
|
+
};
|
|
630
|
+
return {
|
|
631
|
+
candidatesByFile,
|
|
632
|
+
values: valuesForEntries(void 0),
|
|
633
|
+
valuesForEntries
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
474
637
|
//#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
|
|
475
638
|
function collectConfiguredTailwindV4CssSources(opts) {
|
|
476
639
|
const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
@@ -554,7 +717,8 @@ function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
|
554
717
|
//#region src/bundlers/vite/generate-bundle/css-assets.ts
|
|
555
718
|
function createCssAssetEmitter(context, bundle) {
|
|
556
719
|
return (fileName, source) => {
|
|
557
|
-
const
|
|
720
|
+
const fileNameKey = require_source_candidate_scan_signature.normalizeOutputPathKey(fileName);
|
|
721
|
+
const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
|
|
558
722
|
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
|
|
559
723
|
existing.source = source;
|
|
560
724
|
return existing;
|
|
@@ -651,8 +815,9 @@ function resolveMiniProgramStyleOutputExtension(options = {}) {
|
|
|
651
815
|
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;
|
|
652
816
|
}
|
|
653
817
|
function resolveReplayCssOutputFile(rootDir, file) {
|
|
654
|
-
const
|
|
655
|
-
|
|
818
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
819
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.isAbsolute(cleanFile) ? node_path.default.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(cleanFile)) : cleanFile);
|
|
820
|
+
if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.basename(cleanFile));
|
|
656
821
|
return normalizedFile;
|
|
657
822
|
}
|
|
658
823
|
function normalizeViteSourceRoot(rootDir, sourceRoot) {
|
|
@@ -668,9 +833,10 @@ function resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot) {
|
|
|
668
833
|
return outputFile;
|
|
669
834
|
}
|
|
670
835
|
function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssExtension = false, styleOutputExtension, styleOutputFiles) {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
836
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
837
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !require_source_candidate_scan_signature.isCSSRequest(file)) return cleanFile;
|
|
838
|
+
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
839
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
|
|
674
840
|
cssMatcher: opts.cssMatcher,
|
|
675
841
|
fallback: styleOutputExtension,
|
|
676
842
|
files: styleOutputFiles,
|
|
@@ -678,20 +844,40 @@ function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssE
|
|
|
678
844
|
}));
|
|
679
845
|
}
|
|
680
846
|
function resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
681
|
-
const
|
|
682
|
-
const cleanFile =
|
|
847
|
+
const sourceStyleRequest = require_source_candidate_scan_signature.isCSSRequest(file);
|
|
848
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot).replace(/[?#].*$/, "");
|
|
849
|
+
const sourceExtension = node_path.default.extname(cleanFile);
|
|
850
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
851
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
852
|
+
return `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
853
|
+
cssMatcher: opts.cssMatcher,
|
|
854
|
+
fallback: styleOutputExtension,
|
|
855
|
+
files: styleOutputFiles,
|
|
856
|
+
stem
|
|
857
|
+
})}`;
|
|
858
|
+
}
|
|
683
859
|
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
684
860
|
const matchedStyleExtension = !isWebGeneratorTarget && !preserveCssExtension ? resolveStyleOutputExtensionFromFiles(styleOutputFiles, opts.cssMatcher, stem) : void 0;
|
|
685
|
-
if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) &&
|
|
686
|
-
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(
|
|
861
|
+
if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) && sourceStyleRequest) return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, matchedStyleExtension);
|
|
862
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
687
863
|
const fallbackExtension = normalizeStyleOutputExtension(styleOutputExtension);
|
|
688
|
-
if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(
|
|
689
|
-
return
|
|
864
|
+
if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanFile)) return cleanFile;
|
|
865
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, fallbackExtension ?? FALLBACK_STYLE_OUTPUT_EXTENSION);
|
|
690
866
|
}
|
|
691
867
|
function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
692
|
-
const
|
|
693
|
-
const cleanFile =
|
|
694
|
-
|
|
868
|
+
const sourceStyleRequest = require_source_candidate_scan_signature.isCSSRequest(sourceFile);
|
|
869
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, sourceFile, sourceRoot).replace(/[?#].*$/, "");
|
|
870
|
+
const sourceExtension = node_path.default.extname(cleanFile);
|
|
871
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
872
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
873
|
+
return resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem) ?? `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
874
|
+
cssMatcher: opts.cssMatcher,
|
|
875
|
+
fallback: styleOutputExtension,
|
|
876
|
+
files: styleOutputFiles,
|
|
877
|
+
stem
|
|
878
|
+
})}`;
|
|
879
|
+
}
|
|
880
|
+
if (isWebGeneratorTarget || preserveCssExtension || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
695
881
|
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
696
882
|
const matchedStyleFile = resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem);
|
|
697
883
|
if (matchedStyleFile) return matchedStyleFile;
|
|
@@ -701,7 +887,7 @@ function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDi
|
|
|
701
887
|
files: styleOutputFiles,
|
|
702
888
|
stem
|
|
703
889
|
}) ?? normalizeStyleOutputExtension(styleOutputExtension);
|
|
704
|
-
return
|
|
890
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, styleExtension);
|
|
705
891
|
}
|
|
706
892
|
function canProcessViteSourceStyleAsCss(source, file) {
|
|
707
893
|
if (SOURCE_STYLE_NON_CSS_SYNTAX_RE.test(source)) return false;
|
|
@@ -853,7 +1039,8 @@ function createCssHandlerOptionsCache(options) {
|
|
|
853
1039
|
const appType = options.getAppType();
|
|
854
1040
|
const isMainChunk = options.mainCssChunkMatcher(file, appType);
|
|
855
1041
|
const outputRoot = options.getOutputRoot?.();
|
|
856
|
-
const
|
|
1042
|
+
const sourceFile = require_hmr_timing.stripRequestQuery(file);
|
|
1043
|
+
const from = node_path.default.isAbsolute(sourceFile) ? sourceFile : outputRoot ? node_path.default.resolve(outputRoot, sourceFile) : sourceFile;
|
|
857
1044
|
const extraOptions = options.getExtraOptions?.(file) ?? {};
|
|
858
1045
|
const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
|
|
859
1046
|
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
|
|
@@ -865,7 +1052,10 @@ function createCssHandlerOptionsCache(options) {
|
|
|
865
1052
|
...dynamicCssOptions,
|
|
866
1053
|
postcssOptions: { options: { from } },
|
|
867
1054
|
majorVersion: require_context.normalizeStyleHandlerMajorVersion(majorVersion),
|
|
868
|
-
sourceOptions: {
|
|
1055
|
+
sourceOptions: {
|
|
1056
|
+
outputRoot,
|
|
1057
|
+
...sourceFile === file ? {} : { requestFile: file }
|
|
1058
|
+
}
|
|
869
1059
|
};
|
|
870
1060
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
871
1061
|
return created;
|
|
@@ -968,7 +1158,8 @@ function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceF
|
|
|
968
1158
|
const source = rawSource.trim();
|
|
969
1159
|
if (source.length === 0) return false;
|
|
970
1160
|
if (canProcessViteSourceStyleAsCss(source, file)) return false;
|
|
971
|
-
|
|
1161
|
+
if (SOURCE_STYLE_OUTPUT_EXT_RE.test(assetSourceFile.replace(/[?#].*$/, ""))) return true;
|
|
1162
|
+
const isKnownStyleSource = require_hmr_timing.isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
|
|
972
1163
|
return outputFile !== file || !isKnownStyleSource;
|
|
973
1164
|
}
|
|
974
1165
|
function resolveOutputFileFromMatchedCssSource(options) {
|
|
@@ -1525,359 +1716,55 @@ const mix = (del = delimiter) => {
|
|
|
1525
1716
|
const posix = /* @__PURE__ */ mix(":");
|
|
1526
1717
|
const win32 = /* @__PURE__ */ mix(";");
|
|
1527
1718
|
//#endregion
|
|
1528
|
-
//#region src/bundlers/vite/
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
".nvue",
|
|
1533
|
-
".svelte",
|
|
1534
|
-
".mpx"
|
|
1535
|
-
];
|
|
1536
|
-
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
1537
|
-
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
1538
|
-
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
1539
|
-
function extractSfcStyleBlocks(source) {
|
|
1540
|
-
const styleSources = [];
|
|
1541
|
-
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
1542
|
-
let index = 0;
|
|
1543
|
-
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1544
|
-
while (match !== null) {
|
|
1545
|
-
const attrs = match[1] ?? "";
|
|
1546
|
-
styleSources.push({
|
|
1547
|
-
attrs,
|
|
1548
|
-
index,
|
|
1549
|
-
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
1550
|
-
source: match[2] ?? ""
|
|
1551
|
-
});
|
|
1552
|
-
index += 1;
|
|
1553
|
-
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1554
|
-
}
|
|
1555
|
-
return styleSources;
|
|
1719
|
+
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
1720
|
+
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1721
|
+
function isCssOutputFile(file) {
|
|
1722
|
+
return CSS_OUTPUT_FILE_RE.test(file);
|
|
1556
1723
|
}
|
|
1557
|
-
function
|
|
1558
|
-
|
|
1724
|
+
function isRootStyleOutputFile(file) {
|
|
1725
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1726
|
+
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
1559
1727
|
}
|
|
1560
|
-
function
|
|
1561
|
-
return
|
|
1728
|
+
function isMiniProgramStyleOutputFile(file) {
|
|
1729
|
+
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
1562
1730
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1731
|
+
//#endregion
|
|
1732
|
+
//#region src/bundlers/vite/processed-css-assets/markers-imports.ts
|
|
1733
|
+
function createCssAssetPipelineContext(options, file, bundle) {
|
|
1734
|
+
const context = options.createCssPipelineContext?.(file);
|
|
1735
|
+
return context ? {
|
|
1736
|
+
...context,
|
|
1737
|
+
bundle
|
|
1738
|
+
} : void 0;
|
|
1566
1739
|
}
|
|
1567
|
-
function
|
|
1568
|
-
return
|
|
1740
|
+
function getAssetFile$1(bundleFile, asset) {
|
|
1741
|
+
return asset.fileName || bundleFile;
|
|
1569
1742
|
}
|
|
1570
|
-
function
|
|
1571
|
-
|
|
1572
|
-
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
1743
|
+
function readAssetSource$2(asset) {
|
|
1744
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1573
1745
|
}
|
|
1574
|
-
function
|
|
1575
|
-
|
|
1576
|
-
params.set("vue", "");
|
|
1577
|
-
params.set("type", "style");
|
|
1578
|
-
params.set("index", String(styleBlock.index));
|
|
1579
|
-
if (styleBlock.scoped) params.set("scoped", "true");
|
|
1580
|
-
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
1581
|
-
if (lang) params.set("lang", lang);
|
|
1582
|
-
return `${sourceFile}?${params.toString()}`;
|
|
1746
|
+
function clearAssetSource(asset) {
|
|
1747
|
+
asset.source = "";
|
|
1583
1748
|
}
|
|
1584
|
-
function
|
|
1585
|
-
if (
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
1589
|
-
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
1590
|
-
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
1591
|
-
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
1592
|
-
});
|
|
1593
|
-
const styleBlock = matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0;
|
|
1594
|
-
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
1749
|
+
function appendCss$1(baseCss, css) {
|
|
1750
|
+
if (baseCss.length === 0) return css;
|
|
1751
|
+
if (css.length === 0) return baseCss;
|
|
1752
|
+
return `${baseCss}\n${css}`;
|
|
1595
1753
|
}
|
|
1596
|
-
function
|
|
1597
|
-
|
|
1598
|
-
return require_generator.hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindRootDirectives(source, { importFallback: true }) || require_generator.hasTailwindApplyDirective(source);
|
|
1754
|
+
function normalizeCssRecordIdentity(css) {
|
|
1755
|
+
return css.trim();
|
|
1599
1756
|
}
|
|
1600
|
-
function
|
|
1601
|
-
|
|
1602
|
-
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1757
|
+
function hasNonCommentCss(css) {
|
|
1758
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1603
1759
|
}
|
|
1604
|
-
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
return;
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
1613
|
-
return;
|
|
1614
|
-
}
|
|
1615
|
-
const styleBlocks = extractSfcStyleBlocks(source);
|
|
1616
|
-
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
1617
|
-
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1618
|
-
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1619
|
-
return;
|
|
1620
|
-
}
|
|
1621
|
-
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
1622
|
-
return {
|
|
1623
|
-
outputFile,
|
|
1624
|
-
rawSource,
|
|
1625
|
-
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
1626
|
-
};
|
|
1627
|
-
}
|
|
1628
|
-
function normalizeSfcSourceFileForCompare(file) {
|
|
1629
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1630
|
-
}
|
|
1631
|
-
function collectChunkModuleIds$2(output) {
|
|
1632
|
-
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
1633
|
-
return [
|
|
1634
|
-
output.facadeModuleId,
|
|
1635
|
-
...moduleIds,
|
|
1636
|
-
...Object.keys(output.modules ?? {})
|
|
1637
|
-
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
1638
|
-
}
|
|
1639
|
-
function normalizeSourceStyleModuleId(id) {
|
|
1640
|
-
const file = id.replace(/[?#].*$/, "");
|
|
1641
|
-
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
1642
|
-
if (!node_path.default.isAbsolute(file)) return;
|
|
1643
|
-
return node_path.default.resolve(file);
|
|
1644
|
-
}
|
|
1645
|
-
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
1646
|
-
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
1647
|
-
if (cssMatcher?.(normalizedOutputFile)) {
|
|
1648
|
-
const extension = node_path.default.extname(normalizedOutputFile);
|
|
1649
|
-
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
1650
|
-
}
|
|
1651
|
-
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
1652
|
-
}
|
|
1653
|
-
function normalizeSfcModuleId(id) {
|
|
1654
|
-
const file = id.replace(/[?#].*$/, "");
|
|
1655
|
-
if (!SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension))) return;
|
|
1656
|
-
if (!node_path.default.isAbsolute(file)) return;
|
|
1657
|
-
return node_path.default.resolve(file);
|
|
1658
|
-
}
|
|
1659
|
-
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
1660
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
1661
|
-
if (!siblingJsFile) {
|
|
1662
|
-
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
1666
|
-
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1667
|
-
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1668
|
-
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1669
|
-
return;
|
|
1670
|
-
}
|
|
1671
|
-
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1672
|
-
if (sourceFiles.length === 0) {
|
|
1673
|
-
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
1674
|
-
return;
|
|
1675
|
-
}
|
|
1676
|
-
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1677
|
-
sourceFile,
|
|
1678
|
-
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1679
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1680
|
-
debug("sfc style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1681
|
-
const bestScore = scoredSources[0]?.score;
|
|
1682
|
-
if (!bestScore) return;
|
|
1683
|
-
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1684
|
-
if (bestSources.length !== 1) {
|
|
1685
|
-
debug("sfc style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
return bestSources[0]?.sourceFile;
|
|
1689
|
-
}
|
|
1690
|
-
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
1691
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
1692
|
-
if (!siblingJsFile) {
|
|
1693
|
-
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1694
|
-
return;
|
|
1695
|
-
}
|
|
1696
|
-
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
1697
|
-
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1698
|
-
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1699
|
-
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1700
|
-
return;
|
|
1701
|
-
}
|
|
1702
|
-
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1703
|
-
if (sourceFiles.length === 0) {
|
|
1704
|
-
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1705
|
-
return;
|
|
1706
|
-
}
|
|
1707
|
-
if (sourceFiles.length === 1) {
|
|
1708
|
-
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
1709
|
-
return sourceFiles[0];
|
|
1710
|
-
}
|
|
1711
|
-
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1712
|
-
sourceFile,
|
|
1713
|
-
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1714
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1715
|
-
debug("source style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1716
|
-
const bestScore = scoredSources[0]?.score;
|
|
1717
|
-
if (!bestScore) return;
|
|
1718
|
-
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1719
|
-
if (bestSources.length !== 1) {
|
|
1720
|
-
debug("source style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1721
|
-
return;
|
|
1722
|
-
}
|
|
1723
|
-
return bestSources[0]?.sourceFile;
|
|
1724
|
-
}
|
|
1725
|
-
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
1726
|
-
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1727
|
-
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1728
|
-
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1729
|
-
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1730
|
-
file,
|
|
1731
|
-
source,
|
|
1732
|
-
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1733
|
-
outputRoot,
|
|
1734
|
-
projectRoot: sourceRoot
|
|
1735
|
-
})
|
|
1736
|
-
}));
|
|
1737
|
-
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1738
|
-
file,
|
|
1739
|
-
source,
|
|
1740
|
-
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1741
|
-
outputRoot,
|
|
1742
|
-
projectRoot: sourceRoot
|
|
1743
|
-
})
|
|
1744
|
-
}));
|
|
1745
|
-
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1746
|
-
const bestScore = scoredSources[0]?.score;
|
|
1747
|
-
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
1748
|
-
if (bestSources.length === 1) {
|
|
1749
|
-
sourceFile = bestSources[0].file;
|
|
1750
|
-
rawSource = bestSources[0].source;
|
|
1751
|
-
debug("source style source inferred from cache: %s -> %s", outputFile, sourceFile);
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
if (!sourceFile || !rawSource) return;
|
|
1755
|
-
if (!hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1756
|
-
debug("source style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
return {
|
|
1760
|
-
outputFile,
|
|
1761
|
-
rawSource,
|
|
1762
|
-
sourceFile
|
|
1763
|
-
};
|
|
1764
|
-
}
|
|
1765
|
-
//#endregion
|
|
1766
|
-
//#region src/bundlers/vite/generate-bundle/subpackages.ts
|
|
1767
|
-
function readBundleAssetSource(output) {
|
|
1768
|
-
if ("type" in output && output.type !== "asset") return;
|
|
1769
|
-
const source = output.source;
|
|
1770
|
-
if (typeof source === "string") return source;
|
|
1771
|
-
if (typeof source === "function") {
|
|
1772
|
-
const value = source.call(output);
|
|
1773
|
-
return typeof value === "string" ? value : value?.toString();
|
|
1774
|
-
}
|
|
1775
|
-
if (source != null && typeof source.toString === "function") return source.toString();
|
|
1776
|
-
}
|
|
1777
|
-
function normalizePackageRoot(root) {
|
|
1778
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(root).replace(/\/+$/, "");
|
|
1779
|
-
}
|
|
1780
|
-
function collectMiniProgramSubpackageRoots(bundle) {
|
|
1781
|
-
let hasAppJson = false;
|
|
1782
|
-
const roots = /* @__PURE__ */ new Set();
|
|
1783
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
1784
|
-
const outputFile = output.fileName || file;
|
|
1785
|
-
if (node_path.default.basename(outputFile) !== "app.json") continue;
|
|
1786
|
-
const source = readBundleAssetSource(output);
|
|
1787
|
-
if (!source) continue;
|
|
1788
|
-
hasAppJson = true;
|
|
1789
|
-
try {
|
|
1790
|
-
const appJson = JSON.parse(source);
|
|
1791
|
-
const subPackages = Array.isArray(appJson.subPackages) ? appJson.subPackages : Array.isArray(appJson.subpackages) ? appJson.subpackages : [];
|
|
1792
|
-
for (const subPackage of subPackages) {
|
|
1793
|
-
if (typeof subPackage.root !== "string" || subPackage.root.length === 0) continue;
|
|
1794
|
-
roots.add(normalizePackageRoot(subPackage.root));
|
|
1795
|
-
}
|
|
1796
|
-
} catch {}
|
|
1797
|
-
}
|
|
1798
|
-
return hasAppJson ? roots : void 0;
|
|
1799
|
-
}
|
|
1800
|
-
function isSubpackageOutputFile(file, subpackageRoots) {
|
|
1801
|
-
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1802
|
-
for (const root of subpackageRoots) if (root.length > 0 && (normalizedFile === root || normalizedFile.startsWith(`${root}/`) || normalizedFile.endsWith(`/${root}`) || normalizedFile.includes(`/${root}/`))) return true;
|
|
1803
|
-
return false;
|
|
1804
|
-
}
|
|
1805
|
-
function resolveSubpackageSourceRootFromModuleId(moduleId, subpackageRoot) {
|
|
1806
|
-
const file = require_source_candidate_scan_signature.slash(node_path.default.resolve(moduleId.replace(/[?#].*$/, "")));
|
|
1807
|
-
const normalizedRoot = normalizePackageRoot(subpackageRoot);
|
|
1808
|
-
const rootSegment = `/${normalizedRoot}/`;
|
|
1809
|
-
const rootIndex = file.lastIndexOf(rootSegment);
|
|
1810
|
-
if (rootIndex >= 0) return file.slice(0, rootIndex + rootSegment.length - 1);
|
|
1811
|
-
const rootSuffix = `/${normalizedRoot}`;
|
|
1812
|
-
if (file.endsWith(rootSuffix)) return file;
|
|
1813
|
-
}
|
|
1814
|
-
function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, sourceBaseRoots) {
|
|
1815
|
-
const sourceRoots = /* @__PURE__ */ new Set();
|
|
1816
|
-
const sourceEntries = [];
|
|
1817
|
-
for (const entry of snapshot.entries) {
|
|
1818
|
-
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1819
|
-
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
1820
|
-
if (!matchedSubpackageRoot) continue;
|
|
1821
|
-
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1822
|
-
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
1823
|
-
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
1824
|
-
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
1828
|
-
base: sourceRoot,
|
|
1829
|
-
negated: false,
|
|
1830
|
-
pattern: "**/*"
|
|
1831
|
-
})));
|
|
1832
|
-
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => node_path.default.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
1833
|
-
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
1834
|
-
base: baseRoot,
|
|
1835
|
-
negated: false,
|
|
1836
|
-
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
1837
|
-
});
|
|
1838
|
-
return sourceEntries;
|
|
1839
|
-
}
|
|
1840
|
-
//#endregion
|
|
1841
|
-
//#region src/bundlers/vite/processed-css-assets.ts
|
|
1842
|
-
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1843
|
-
function createCssAssetPipelineContext(options, file, bundle) {
|
|
1844
|
-
const context = options.createCssPipelineContext?.(file);
|
|
1845
|
-
return context ? {
|
|
1846
|
-
...context,
|
|
1847
|
-
bundle
|
|
1848
|
-
} : void 0;
|
|
1849
|
-
}
|
|
1850
|
-
function isCssOutputFile(file) {
|
|
1851
|
-
return CSS_OUTPUT_FILE_RE.test(file);
|
|
1852
|
-
}
|
|
1853
|
-
function getAssetFile$1(bundleFile, asset) {
|
|
1854
|
-
return asset.fileName || bundleFile;
|
|
1855
|
-
}
|
|
1856
|
-
function readAssetSource$2(asset) {
|
|
1857
|
-
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1858
|
-
}
|
|
1859
|
-
function clearAssetSource(asset) {
|
|
1860
|
-
asset.source = "";
|
|
1861
|
-
}
|
|
1862
|
-
function appendCss$1(baseCss, css) {
|
|
1863
|
-
if (baseCss.length === 0) return css;
|
|
1864
|
-
if (css.length === 0) return baseCss;
|
|
1865
|
-
return `${baseCss}\n${css}`;
|
|
1866
|
-
}
|
|
1867
|
-
function normalizeCssRecordIdentity(css) {
|
|
1868
|
-
return css.trim();
|
|
1869
|
-
}
|
|
1870
|
-
function hasNonCommentCss(css) {
|
|
1871
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1872
|
-
}
|
|
1873
|
-
function dedupeViteCssResults(records) {
|
|
1874
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1875
|
-
return records.filter((record) => {
|
|
1876
|
-
const key = `${require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
1877
|
-
if (seen.has(key)) return false;
|
|
1878
|
-
seen.add(key);
|
|
1879
|
-
return true;
|
|
1880
|
-
});
|
|
1760
|
+
function dedupeViteCssResults(records) {
|
|
1761
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1762
|
+
return records.filter((record) => {
|
|
1763
|
+
const key = `${require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
1764
|
+
if (seen.has(key)) return false;
|
|
1765
|
+
seen.add(key);
|
|
1766
|
+
return true;
|
|
1767
|
+
});
|
|
1881
1768
|
}
|
|
1882
1769
|
function removeTailwindSourceMediaWrappersRoot(root) {
|
|
1883
1770
|
let changed = false;
|
|
@@ -1982,13 +1869,13 @@ function isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveVitePro
|
|
|
1982
1869
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(targetFile)) === require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile)));
|
|
1983
1870
|
}
|
|
1984
1871
|
function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1985
|
-
const blocks =
|
|
1986
|
-
if (blocks.length <= 1) return
|
|
1872
|
+
const blocks = require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
1873
|
+
if (blocks.length <= 1) return require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1987
1874
|
const matchedCss = blocks.filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.css);
|
|
1988
|
-
return matchedCss.length > 0 ? matchedCss.join("\n") :
|
|
1875
|
+
return matchedCss.length > 0 ? matchedCss.join("\n") : require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1989
1876
|
}
|
|
1990
1877
|
function collectMatchingGeneratedCssMarkerFiles(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1991
|
-
return
|
|
1878
|
+
return require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite").filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.file).filter((markerFile) => typeof markerFile === "string" && markerFile.length > 0);
|
|
1992
1879
|
}
|
|
1993
1880
|
function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
1994
1881
|
const sources = [];
|
|
@@ -1997,7 +1884,7 @@ function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
|
1997
1884
|
if (output.type !== "asset") continue;
|
|
1998
1885
|
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1999
1886
|
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
2000
|
-
const source =
|
|
1887
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2001
1888
|
if (source.length > 0) sources.push(source);
|
|
2002
1889
|
}
|
|
2003
1890
|
return sources;
|
|
@@ -2050,23 +1937,498 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
2050
1937
|
if (output.type !== "asset") continue;
|
|
2051
1938
|
const file = getAssetFile$1(bundleFile, output);
|
|
2052
1939
|
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
2053
|
-
const source =
|
|
1940
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2054
1941
|
if (source.length > 0) linkedSources.add(source);
|
|
2055
1942
|
}
|
|
2056
|
-
if (linkedSources.size === 0) return 0;
|
|
2057
|
-
let removed = 0;
|
|
2058
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2059
|
-
if (output.type !== "asset") continue;
|
|
2060
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2061
|
-
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
2062
|
-
const source =
|
|
2063
|
-
if (!linkedSources.has(source)) continue;
|
|
2064
|
-
delete bundle[bundleFile];
|
|
2065
|
-
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
2066
|
-
removed++;
|
|
1943
|
+
if (linkedSources.size === 0) return 0;
|
|
1944
|
+
let removed = 0;
|
|
1945
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1946
|
+
if (output.type !== "asset") continue;
|
|
1947
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
1948
|
+
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1949
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
1950
|
+
if (!linkedSources.has(source)) continue;
|
|
1951
|
+
delete bundle[bundleFile];
|
|
1952
|
+
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
1953
|
+
removed++;
|
|
1954
|
+
}
|
|
1955
|
+
return removed;
|
|
1956
|
+
}
|
|
1957
|
+
//#endregion
|
|
1958
|
+
//#region src/bundlers/vite/processed-css-assets/cleanup.ts
|
|
1959
|
+
function collectCssImportAtRuleCss(css) {
|
|
1960
|
+
if (!css.includes("@import")) return [];
|
|
1961
|
+
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
1962
|
+
if (fallbackImports.length > 0) return fallbackImports;
|
|
1963
|
+
try {
|
|
1964
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1965
|
+
const imports = [];
|
|
1966
|
+
root.each((node) => {
|
|
1967
|
+
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
1968
|
+
});
|
|
1969
|
+
return imports;
|
|
1970
|
+
} catch {
|
|
1971
|
+
return [];
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
function parseCssImportRequest(importCss) {
|
|
1975
|
+
const trimmed = importCss.trim();
|
|
1976
|
+
if (!trimmed.startsWith("@import")) return;
|
|
1977
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
1978
|
+
}
|
|
1979
|
+
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
1980
|
+
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
1981
|
+
const request = parseCssImportRequest(importCss);
|
|
1982
|
+
if (request === void 0) return false;
|
|
1983
|
+
if ((0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request)) return true;
|
|
1984
|
+
return isStyleImportRequest(request) && !request.includes("/");
|
|
1985
|
+
}
|
|
1986
|
+
function restoreCssImportAtRules(source, filtered, file) {
|
|
1987
|
+
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
1988
|
+
if (imports.length === 0) return filtered;
|
|
1989
|
+
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
1990
|
+
if (missingImports.length === 0) return filtered;
|
|
1991
|
+
return appendCss$1(missingImports.join("\n"), filtered);
|
|
1992
|
+
}
|
|
1993
|
+
function removeCommentOnlyAtRules(css) {
|
|
1994
|
+
if (!css.includes("@")) return css;
|
|
1995
|
+
try {
|
|
1996
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1997
|
+
let changed = false;
|
|
1998
|
+
root.walkAtRules((atRule) => {
|
|
1999
|
+
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2000
|
+
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2001
|
+
atRule.remove();
|
|
2002
|
+
changed = true;
|
|
2003
|
+
});
|
|
2004
|
+
return changed ? root.toString() : css;
|
|
2005
|
+
} catch {
|
|
2006
|
+
return css;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2010
|
+
if (importedStyleFiles.size === 0) return [];
|
|
2011
|
+
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2012
|
+
const importedSources = [];
|
|
2013
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2014
|
+
if (output.type !== "asset") continue;
|
|
2015
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2016
|
+
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2017
|
+
importedSources.push(readAssetSource$2(output));
|
|
2018
|
+
}
|
|
2019
|
+
return importedSources;
|
|
2020
|
+
}
|
|
2021
|
+
function collectBundleAssetFiles(bundle) {
|
|
2022
|
+
const files = /* @__PURE__ */ new Set();
|
|
2023
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2024
|
+
if (output.type !== "asset") continue;
|
|
2025
|
+
files.add(require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2026
|
+
}
|
|
2027
|
+
return files;
|
|
2028
|
+
}
|
|
2029
|
+
function normalizeComparableStyleFile(file) {
|
|
2030
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2031
|
+
}
|
|
2032
|
+
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2033
|
+
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2034
|
+
return [
|
|
2035
|
+
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2036
|
+
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2037
|
+
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2038
|
+
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2039
|
+
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2040
|
+
}
|
|
2041
|
+
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2042
|
+
if (typeof file !== "string" || file.length === 0) return false;
|
|
2043
|
+
const fileKey = normalizeComparableStyleFile(file);
|
|
2044
|
+
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2045
|
+
}
|
|
2046
|
+
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2047
|
+
const opts = options.opts;
|
|
2048
|
+
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2049
|
+
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2050
|
+
if (context === void 0) return;
|
|
2051
|
+
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2052
|
+
...context,
|
|
2053
|
+
bundle,
|
|
2054
|
+
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2055
|
+
isMiniProgramStyleOutputFile,
|
|
2056
|
+
isRootStyleOutputFile,
|
|
2057
|
+
outputFile,
|
|
2058
|
+
sourceFile
|
|
2059
|
+
});
|
|
2060
|
+
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2061
|
+
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2062
|
+
const rootCssFiles = [];
|
|
2063
|
+
const matchedRootCssFiles = [];
|
|
2064
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2065
|
+
if (output.type !== "asset") continue;
|
|
2066
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
2067
|
+
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2068
|
+
rootCssFiles.push(file);
|
|
2069
|
+
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2070
|
+
}
|
|
2071
|
+
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2072
|
+
if (matchedRootCssFiles.length > 1) return;
|
|
2073
|
+
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2074
|
+
}
|
|
2075
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2076
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2077
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2078
|
+
return output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2079
|
+
})?.[1];
|
|
2080
|
+
}
|
|
2081
|
+
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2082
|
+
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2083
|
+
if (importedStyleFiles.size === 0) return false;
|
|
2084
|
+
let hasNonImportNode = false;
|
|
2085
|
+
try {
|
|
2086
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).each((node) => {
|
|
2087
|
+
if (node.type === "comment") return;
|
|
2088
|
+
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2089
|
+
});
|
|
2090
|
+
} catch {
|
|
2091
|
+
return false;
|
|
2092
|
+
}
|
|
2093
|
+
if (hasNonImportNode) return false;
|
|
2094
|
+
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2095
|
+
}
|
|
2096
|
+
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2097
|
+
const resolvedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2098
|
+
return resolvedOutputFile !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2099
|
+
}
|
|
2100
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2101
|
+
const resolvedFromFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2102
|
+
if (!markerFile) return resolvedFromFile;
|
|
2103
|
+
const resolvedFromMarker = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2104
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2105
|
+
return resolvedFromFile;
|
|
2106
|
+
}
|
|
2107
|
+
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2108
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2109
|
+
const outputFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
2110
|
+
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2111
|
+
}
|
|
2112
|
+
//#endregion
|
|
2113
|
+
//#region src/bundlers/vite/generate-bundle/sfc-style-source.ts
|
|
2114
|
+
const SFC_STYLE_SOURCE_EXTENSIONS = [
|
|
2115
|
+
".vue",
|
|
2116
|
+
".uvue",
|
|
2117
|
+
".nvue",
|
|
2118
|
+
".svelte",
|
|
2119
|
+
".mpx"
|
|
2120
|
+
];
|
|
2121
|
+
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
2122
|
+
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
2123
|
+
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
2124
|
+
function isSfcStyleSourceFile(file) {
|
|
2125
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
2126
|
+
return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
|
|
2127
|
+
}
|
|
2128
|
+
function extractSfcStyleBlocks(source) {
|
|
2129
|
+
const styleSources = [];
|
|
2130
|
+
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
2131
|
+
let index = 0;
|
|
2132
|
+
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2133
|
+
while (match !== null) {
|
|
2134
|
+
const attrs = match[1] ?? "";
|
|
2135
|
+
styleSources.push({
|
|
2136
|
+
attrs,
|
|
2137
|
+
index,
|
|
2138
|
+
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
2139
|
+
source: match[2] ?? ""
|
|
2140
|
+
});
|
|
2141
|
+
index += 1;
|
|
2142
|
+
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2143
|
+
}
|
|
2144
|
+
return styleSources;
|
|
2145
|
+
}
|
|
2146
|
+
function extractSfcStyleSources(source) {
|
|
2147
|
+
return extractSfcStyleBlocks(source).map((style) => style.source);
|
|
2148
|
+
}
|
|
2149
|
+
function hasSfcStyleSources(source) {
|
|
2150
|
+
return extractSfcStyleSources(source).length > 0;
|
|
2151
|
+
}
|
|
2152
|
+
function resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks) {
|
|
2153
|
+
const scopedStyleBlock = styleBlocks.find((style) => style.scoped);
|
|
2154
|
+
return scopedStyleBlock ? `${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true` : sourceFile;
|
|
2155
|
+
}
|
|
2156
|
+
function normalizeSfcStyleSourceForCompare(source) {
|
|
2157
|
+
return source.replace(/\r\n?/g, "\n").trim();
|
|
2158
|
+
}
|
|
2159
|
+
function resolveSfcStyleBlockLang(attrs) {
|
|
2160
|
+
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
2161
|
+
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
2162
|
+
}
|
|
2163
|
+
function createSfcStyleRequest(sourceFile, styleBlock) {
|
|
2164
|
+
const params = new URLSearchParams();
|
|
2165
|
+
params.set("vue", "");
|
|
2166
|
+
params.set("type", "style");
|
|
2167
|
+
params.set("index", String(styleBlock.index));
|
|
2168
|
+
if (styleBlock.scoped) params.set("scoped", "true");
|
|
2169
|
+
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
2170
|
+
if (lang) params.set("lang", lang);
|
|
2171
|
+
return `${sourceFile}?${params.toString()}`;
|
|
2172
|
+
}
|
|
2173
|
+
function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource, currentRequest) {
|
|
2174
|
+
if (!sfcSource) return sourceFile;
|
|
2175
|
+
const styleBlocks = extractSfcStyleBlocks(sfcSource);
|
|
2176
|
+
if (styleBlocks.length === 0) return sourceFile;
|
|
2177
|
+
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
2178
|
+
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
2179
|
+
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
2180
|
+
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
2181
|
+
});
|
|
2182
|
+
const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
|
|
2183
|
+
const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
|
|
2184
|
+
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
2185
|
+
}
|
|
2186
|
+
function hasTailwindGenerationSource(source, options = {}) {
|
|
2187
|
+
const allowRootDirectives = options.allowRootDirectives !== false;
|
|
2188
|
+
return require_generator.hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindRootDirectives(source, { importFallback: true }) || require_generator.hasTailwindApplyDirective(source);
|
|
2189
|
+
}
|
|
2190
|
+
function hasTailwindGenerationSourceForFile(file, source) {
|
|
2191
|
+
if (require_generator.isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
2192
|
+
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
2193
|
+
}
|
|
2194
|
+
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
2195
|
+
const sourceFile = resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug);
|
|
2196
|
+
if (!sourceFile) {
|
|
2197
|
+
debug("sfc style source infer skipped: no source file for %s", outputFile);
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
const source = getSfcSource?.(sourceFile);
|
|
2201
|
+
if (source == null) {
|
|
2202
|
+
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
const styleBlocks = extractSfcStyleBlocks(source);
|
|
2206
|
+
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
2207
|
+
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2208
|
+
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
2212
|
+
return {
|
|
2213
|
+
outputFile,
|
|
2214
|
+
rawSource,
|
|
2215
|
+
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
function normalizeSfcSourceFileForCompare(file) {
|
|
2219
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2220
|
+
}
|
|
2221
|
+
function collectChunkModuleIds$1(output) {
|
|
2222
|
+
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
2223
|
+
return [
|
|
2224
|
+
output.facadeModuleId,
|
|
2225
|
+
...moduleIds,
|
|
2226
|
+
...Object.keys(output.modules ?? {})
|
|
2227
|
+
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
2228
|
+
}
|
|
2229
|
+
function normalizeSourceStyleModuleId(id) {
|
|
2230
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2231
|
+
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
2232
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
2233
|
+
return node_path.default.resolve(file);
|
|
2234
|
+
}
|
|
2235
|
+
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
2236
|
+
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
2237
|
+
if (cssMatcher?.(normalizedOutputFile)) {
|
|
2238
|
+
const extension = node_path.default.extname(normalizedOutputFile);
|
|
2239
|
+
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
2240
|
+
}
|
|
2241
|
+
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
2242
|
+
}
|
|
2243
|
+
function normalizeSfcModuleId(id) {
|
|
2244
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2245
|
+
if (!isSfcStyleSourceFile(file)) return;
|
|
2246
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
2247
|
+
return node_path.default.resolve(file);
|
|
2248
|
+
}
|
|
2249
|
+
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
2250
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
2251
|
+
if (!siblingJsFile) {
|
|
2252
|
+
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
2256
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
2257
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
2258
|
+
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
2262
|
+
if (sourceFiles.length === 0) {
|
|
2263
|
+
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
2267
|
+
sourceFile,
|
|
2268
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
2269
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2270
|
+
debug("sfc style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
2271
|
+
const bestScore = scoredSources[0]?.score;
|
|
2272
|
+
if (!bestScore) return;
|
|
2273
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
2274
|
+
if (bestSources.length !== 1) {
|
|
2275
|
+
debug("sfc style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
return bestSources[0]?.sourceFile;
|
|
2279
|
+
}
|
|
2280
|
+
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
2281
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
2282
|
+
if (!siblingJsFile) {
|
|
2283
|
+
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
2287
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
2288
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
2289
|
+
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
2293
|
+
if (sourceFiles.length === 0) {
|
|
2294
|
+
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
if (sourceFiles.length === 1) {
|
|
2298
|
+
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
2299
|
+
return sourceFiles[0];
|
|
2300
|
+
}
|
|
2301
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
2302
|
+
sourceFile,
|
|
2303
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
2304
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2305
|
+
debug("source style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
2306
|
+
const bestScore = scoredSources[0]?.score;
|
|
2307
|
+
if (!bestScore) return;
|
|
2308
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
2309
|
+
if (bestSources.length !== 1) {
|
|
2310
|
+
debug("source style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
return bestSources[0]?.sourceFile;
|
|
2314
|
+
}
|
|
2315
|
+
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
2316
|
+
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
2317
|
+
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
2318
|
+
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2319
|
+
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
2320
|
+
file,
|
|
2321
|
+
source,
|
|
2322
|
+
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
2323
|
+
outputRoot,
|
|
2324
|
+
projectRoot: sourceRoot
|
|
2325
|
+
})
|
|
2326
|
+
}));
|
|
2327
|
+
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
2328
|
+
file,
|
|
2329
|
+
source,
|
|
2330
|
+
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
2331
|
+
outputRoot,
|
|
2332
|
+
projectRoot: sourceRoot
|
|
2333
|
+
})
|
|
2334
|
+
}));
|
|
2335
|
+
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2336
|
+
const bestScore = scoredSources[0]?.score;
|
|
2337
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2338
|
+
if (bestSources.length === 1) {
|
|
2339
|
+
sourceFile = bestSources[0].file;
|
|
2340
|
+
rawSource = bestSources[0].source;
|
|
2341
|
+
debug("source style source inferred from cache: %s -> %s", outputFile, sourceFile);
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
if (!sourceFile || !rawSource) return;
|
|
2345
|
+
if (!hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2346
|
+
debug("source style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
return {
|
|
2350
|
+
outputFile,
|
|
2351
|
+
rawSource,
|
|
2352
|
+
sourceFile
|
|
2353
|
+
};
|
|
2354
|
+
}
|
|
2355
|
+
//#endregion
|
|
2356
|
+
//#region src/bundlers/vite/generate-bundle/subpackages.ts
|
|
2357
|
+
function readBundleAssetSource(output) {
|
|
2358
|
+
if ("type" in output && output.type !== "asset") return;
|
|
2359
|
+
const source = output.source;
|
|
2360
|
+
if (typeof source === "string") return source;
|
|
2361
|
+
if (typeof source === "function") {
|
|
2362
|
+
const value = source.call(output);
|
|
2363
|
+
return typeof value === "string" ? value : value?.toString();
|
|
2364
|
+
}
|
|
2365
|
+
if (source != null && typeof source.toString === "function") return source.toString();
|
|
2366
|
+
}
|
|
2367
|
+
function normalizePackageRoot(root) {
|
|
2368
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(root).replace(/\/+$/, "");
|
|
2369
|
+
}
|
|
2370
|
+
function collectMiniProgramSubpackageRoots(bundle) {
|
|
2371
|
+
let hasAppJson = false;
|
|
2372
|
+
const roots = /* @__PURE__ */ new Set();
|
|
2373
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
2374
|
+
const outputFile = output.fileName || file;
|
|
2375
|
+
if (node_path.default.basename(outputFile) !== "app.json") continue;
|
|
2376
|
+
const source = readBundleAssetSource(output);
|
|
2377
|
+
if (!source) continue;
|
|
2378
|
+
hasAppJson = true;
|
|
2379
|
+
try {
|
|
2380
|
+
const appJson = JSON.parse(source);
|
|
2381
|
+
const subPackages = Array.isArray(appJson.subPackages) ? appJson.subPackages : Array.isArray(appJson.subpackages) ? appJson.subpackages : [];
|
|
2382
|
+
for (const subPackage of subPackages) {
|
|
2383
|
+
if (typeof subPackage.root !== "string" || subPackage.root.length === 0) continue;
|
|
2384
|
+
roots.add(normalizePackageRoot(subPackage.root));
|
|
2385
|
+
}
|
|
2386
|
+
} catch {}
|
|
2387
|
+
}
|
|
2388
|
+
return hasAppJson ? roots : void 0;
|
|
2389
|
+
}
|
|
2390
|
+
function isSubpackageOutputFile(file, subpackageRoots) {
|
|
2391
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2392
|
+
for (const root of subpackageRoots) if (root.length > 0 && (normalizedFile === root || normalizedFile.startsWith(`${root}/`) || normalizedFile.endsWith(`/${root}`) || normalizedFile.includes(`/${root}/`))) return true;
|
|
2393
|
+
return false;
|
|
2394
|
+
}
|
|
2395
|
+
function resolveSubpackageSourceRootFromModuleId(moduleId, subpackageRoot) {
|
|
2396
|
+
const file = require_source_candidate_scan_signature.slash(node_path.default.resolve(moduleId.replace(/[?#].*$/, "")));
|
|
2397
|
+
const normalizedRoot = normalizePackageRoot(subpackageRoot);
|
|
2398
|
+
const rootSegment = `/${normalizedRoot}/`;
|
|
2399
|
+
const rootIndex = file.lastIndexOf(rootSegment);
|
|
2400
|
+
if (rootIndex >= 0) return file.slice(0, rootIndex + rootSegment.length - 1);
|
|
2401
|
+
const rootSuffix = `/${normalizedRoot}`;
|
|
2402
|
+
if (file.endsWith(rootSuffix)) return file;
|
|
2403
|
+
}
|
|
2404
|
+
function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, sourceBaseRoots) {
|
|
2405
|
+
const sourceRoots = /* @__PURE__ */ new Set();
|
|
2406
|
+
const sourceEntries = [];
|
|
2407
|
+
for (const entry of snapshot.entries) {
|
|
2408
|
+
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
2409
|
+
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
2410
|
+
if (!matchedSubpackageRoot) continue;
|
|
2411
|
+
for (const moduleId of collectChunkModuleIds$1(entry.output)) {
|
|
2412
|
+
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
2413
|
+
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
2414
|
+
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
2415
|
+
}
|
|
2067
2416
|
}
|
|
2068
|
-
|
|
2417
|
+
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
2418
|
+
base: sourceRoot,
|
|
2419
|
+
negated: false,
|
|
2420
|
+
pattern: "**/*"
|
|
2421
|
+
})));
|
|
2422
|
+
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => node_path.default.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
2423
|
+
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
2424
|
+
base: baseRoot,
|
|
2425
|
+
negated: false,
|
|
2426
|
+
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
2427
|
+
});
|
|
2428
|
+
return sourceEntries;
|
|
2069
2429
|
}
|
|
2430
|
+
//#endregion
|
|
2431
|
+
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2070
2432
|
const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
2071
2433
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2072
2434
|
function hasVueScopedAttr(value) {
|
|
@@ -2148,9 +2510,11 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2148
2510
|
const rules = /* @__PURE__ */ new Set();
|
|
2149
2511
|
const atRules = /* @__PURE__ */ new Set();
|
|
2150
2512
|
const declarationsBySelector = /* @__PURE__ */ new Map();
|
|
2513
|
+
const normalizedRuleCss = /* @__PURE__ */ new Set();
|
|
2151
2514
|
for (const source of cssSources) try {
|
|
2152
2515
|
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2153
2516
|
root.walkRules((rule) => {
|
|
2517
|
+
normalizedRuleCss.add(normalizeCssSignatureValue(rule.toString()));
|
|
2154
2518
|
const declarations = createDeclarationSignature(rule);
|
|
2155
2519
|
if (declarations.length === 0) return;
|
|
2156
2520
|
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
@@ -2168,7 +2532,16 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2168
2532
|
return {
|
|
2169
2533
|
rules,
|
|
2170
2534
|
atRules,
|
|
2171
|
-
declarationsBySelector
|
|
2535
|
+
declarationsBySelector,
|
|
2536
|
+
normalizedRuleCss
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function prepareImportedCssCoverage(importedCssSources) {
|
|
2540
|
+
const sources = importedCssSources.map((source) => require_hmr_timing.stripBundlerGeneratedCssMarkers(source).trim()).filter(Boolean);
|
|
2541
|
+
if (sources.length === 0) return;
|
|
2542
|
+
return {
|
|
2543
|
+
coverage: collectRootScopedComparableCssCoverage(sources),
|
|
2544
|
+
sources
|
|
2172
2545
|
};
|
|
2173
2546
|
}
|
|
2174
2547
|
function isRuleCoveredByRootCss(rule, coverage) {
|
|
@@ -2224,7 +2597,7 @@ function removeScopedTailwindPreflightCss(css) {
|
|
|
2224
2597
|
return removeScopedCssCoveredByRootStyleSources(css, []);
|
|
2225
2598
|
}
|
|
2226
2599
|
function collectSingleViteGeneratedCssMarkerFile(rawSource) {
|
|
2227
|
-
const blocks =
|
|
2600
|
+
const blocks = require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
2228
2601
|
if (blocks.length !== 1) return;
|
|
2229
2602
|
const file = blocks[0]?.file;
|
|
2230
2603
|
return typeof file === "string" && file.length > 0 ? file : void 0;
|
|
@@ -2236,7 +2609,48 @@ function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile
|
|
|
2236
2609
|
}
|
|
2237
2610
|
function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
2238
2611
|
const rootSources = collectRootStyleBundleCssSources(bundle, file);
|
|
2239
|
-
|
|
2612
|
+
if (css.trim().length === 0) return css;
|
|
2613
|
+
const hasScopedCss = hasVueScopedAttr(css);
|
|
2614
|
+
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2615
|
+
const hasUnscopedMiniProgramPreflight = hasScopedCss && hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2616
|
+
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2617
|
+
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2618
|
+
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2619
|
+
let nextCss = css;
|
|
2620
|
+
try {
|
|
2621
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2622
|
+
let changed = false;
|
|
2623
|
+
root.walkRules((rule) => {
|
|
2624
|
+
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule))) {
|
|
2625
|
+
rule.remove();
|
|
2626
|
+
changed = true;
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2630
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || hasScopedTailwindGeneratedCss && isLikelyTailwindPropertyAtRule(atRule)) {
|
|
2631
|
+
atRule.remove();
|
|
2632
|
+
changed = true;
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
2636
|
+
atRule.remove();
|
|
2637
|
+
changed = true;
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2640
|
+
root.walkComments((comment) => {
|
|
2641
|
+
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
2642
|
+
comment.remove();
|
|
2643
|
+
changed = true;
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
2647
|
+
const next = comment.next();
|
|
2648
|
+
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
2649
|
+
comment.remove();
|
|
2650
|
+
changed = true;
|
|
2651
|
+
});
|
|
2652
|
+
if (changed) nextCss = root.toString().trim();
|
|
2653
|
+
} catch {}
|
|
2240
2654
|
return hasNonCommentCss(nextCss) ? nextCss : "";
|
|
2241
2655
|
}
|
|
2242
2656
|
function removeDanglingCssSourceTraceComments(css) {
|
|
@@ -2276,6 +2690,8 @@ function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
|
2276
2690
|
}
|
|
2277
2691
|
return updated;
|
|
2278
2692
|
}
|
|
2693
|
+
//#endregion
|
|
2694
|
+
//#region src/bundlers/vite/processed-css-assets/injection-plan.ts
|
|
2279
2695
|
function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, options) {
|
|
2280
2696
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(options.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2281
2697
|
if (options.injectIntoMain === false) return false;
|
|
@@ -2291,13 +2707,6 @@ function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputF
|
|
|
2291
2707
|
}
|
|
2292
2708
|
return isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) || isSourceRootPrefixedOutputFile(file, outputFile) && isRootStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType);
|
|
2293
2709
|
}
|
|
2294
|
-
function isRootStyleOutputFile(file) {
|
|
2295
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2296
|
-
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
2297
|
-
}
|
|
2298
|
-
function isMiniProgramStyleOutputFile(file) {
|
|
2299
|
-
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
2300
|
-
}
|
|
2301
2710
|
function shouldPreserveMiniProgramImportShell(options, bundle, file, css) {
|
|
2302
2711
|
const context = createCssAssetPipelineContext(options, file, bundle);
|
|
2303
2712
|
return context !== void 0 && shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
@@ -2381,48 +2790,41 @@ function isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedSt
|
|
|
2381
2790
|
return false;
|
|
2382
2791
|
}
|
|
2383
2792
|
function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, records, options) {
|
|
2384
|
-
let removed = 0;
|
|
2385
2793
|
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2386
2794
|
const targetIsRootWebStyle = isRootStyleOutputFile(targetFileKey) && !isMiniProgramStyleOutputFile(targetFileKey);
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2405
|
-
removed++;
|
|
2406
|
-
}
|
|
2795
|
+
const removableRecords = records.filter((record) => options.shouldRemoveInjectedSourceAsset?.(targetFile, record) === true);
|
|
2796
|
+
if (removableRecords.length === 0) return 0;
|
|
2797
|
+
const recordFileKeys = new Set(removableRecords.map((record) => require_source_candidate_scan_signature.normalizeOutputPathKey(record.file)));
|
|
2798
|
+
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
2799
|
+
let removed = 0;
|
|
2800
|
+
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
2801
|
+
if (candidateOutput.type !== "asset") continue;
|
|
2802
|
+
const candidateKey = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(candidateFile, candidateOutput));
|
|
2803
|
+
if (candidateKey === targetFileKey || !isCssOutputFile(candidateKey)) continue;
|
|
2804
|
+
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
2805
|
+
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
2806
|
+
const candidateSource = readAssetSource$2(candidateOutput).trim();
|
|
2807
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(targetCss, candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !hasNonCommentCss((0, _weapp_tailwindcss_postcss.filterExistingCssRules)(targetCss, candidateSource).trim())))) continue;
|
|
2808
|
+
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
2809
|
+
else clearAssetSource(candidateOutput);
|
|
2810
|
+
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2811
|
+
removed++;
|
|
2407
2812
|
}
|
|
2408
2813
|
return removed;
|
|
2409
2814
|
}
|
|
2410
|
-
function removeCssCoveredByImportedViteResults(css, importedCssSources) {
|
|
2411
|
-
if (
|
|
2412
|
-
|
|
2413
|
-
if (importedCss.length === 0) return css;
|
|
2414
|
-
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, [importedCss], { exactOnly: true }));
|
|
2815
|
+
function removeCssCoveredByImportedViteResults(css, importedCssSources, prepared = prepareImportedCssCoverage(importedCssSources)) {
|
|
2816
|
+
if (!prepared) return css;
|
|
2817
|
+
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, prepared.sources, { exactOnly: true }, prepared.coverage));
|
|
2415
2818
|
}
|
|
2416
|
-
function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
2819
|
+
function removeCssRulesCoveredBySources(css, sources, options = {}, preparedCoverage) {
|
|
2417
2820
|
if (sources.length === 0 || css.trim().length === 0) return css;
|
|
2418
|
-
const coverage = collectRootScopedComparableCssCoverage(sources);
|
|
2419
|
-
|
|
2420
|
-
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coveredRuleCss.size === 0) return css;
|
|
2821
|
+
const coverage = preparedCoverage ?? collectRootScopedComparableCssCoverage(sources);
|
|
2822
|
+
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coverage.normalizedRuleCss.size === 0) return css;
|
|
2421
2823
|
try {
|
|
2422
2824
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2423
2825
|
let changed = false;
|
|
2424
2826
|
root.walkRules((rule) => {
|
|
2425
|
-
if (!
|
|
2827
|
+
if (!coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
|
|
2426
2828
|
rule.remove();
|
|
2427
2829
|
changed = true;
|
|
2428
2830
|
});
|
|
@@ -2431,168 +2833,8 @@ function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
|
2431
2833
|
return css;
|
|
2432
2834
|
}
|
|
2433
2835
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
for (const source of sources) try {
|
|
2437
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
2438
|
-
rules.add(normalizeCssSignatureValue(rule.toString()));
|
|
2439
|
-
});
|
|
2440
|
-
} catch {}
|
|
2441
|
-
return rules;
|
|
2442
|
-
}
|
|
2443
|
-
function collectCssImportAtRuleCss(css) {
|
|
2444
|
-
if (!css.includes("@import")) return [];
|
|
2445
|
-
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
2446
|
-
if (fallbackImports.length > 0) return fallbackImports;
|
|
2447
|
-
try {
|
|
2448
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2449
|
-
const imports = [];
|
|
2450
|
-
root.each((node) => {
|
|
2451
|
-
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
2452
|
-
});
|
|
2453
|
-
return imports;
|
|
2454
|
-
} catch {
|
|
2455
|
-
return [];
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
function parseCssImportRequest(importCss) {
|
|
2459
|
-
const trimmed = importCss.trim();
|
|
2460
|
-
if (!trimmed.startsWith("@import")) return;
|
|
2461
|
-
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
2462
|
-
}
|
|
2463
|
-
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
2464
|
-
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
2465
|
-
const request = parseCssImportRequest(importCss);
|
|
2466
|
-
if (request === void 0) return false;
|
|
2467
|
-
if ((0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request)) return true;
|
|
2468
|
-
return isStyleImportRequest(request) && !request.includes("/");
|
|
2469
|
-
}
|
|
2470
|
-
function restoreCssImportAtRules(source, filtered, file) {
|
|
2471
|
-
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
2472
|
-
if (imports.length === 0) return filtered;
|
|
2473
|
-
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
2474
|
-
if (missingImports.length === 0) return filtered;
|
|
2475
|
-
return appendCss$1(missingImports.join("\n"), filtered);
|
|
2476
|
-
}
|
|
2477
|
-
function removeCommentOnlyAtRules(css) {
|
|
2478
|
-
if (!css.includes("@")) return css;
|
|
2479
|
-
try {
|
|
2480
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2481
|
-
let changed = false;
|
|
2482
|
-
root.walkAtRules((atRule) => {
|
|
2483
|
-
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2484
|
-
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2485
|
-
atRule.remove();
|
|
2486
|
-
changed = true;
|
|
2487
|
-
});
|
|
2488
|
-
return changed ? root.toString() : css;
|
|
2489
|
-
} catch {
|
|
2490
|
-
return css;
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2494
|
-
if (importedStyleFiles.size === 0) return [];
|
|
2495
|
-
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2496
|
-
const importedSources = [];
|
|
2497
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2498
|
-
if (output.type !== "asset") continue;
|
|
2499
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2500
|
-
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2501
|
-
importedSources.push(readAssetSource$2(output));
|
|
2502
|
-
}
|
|
2503
|
-
return importedSources;
|
|
2504
|
-
}
|
|
2505
|
-
function collectBundleAssetFiles(bundle) {
|
|
2506
|
-
const files = /* @__PURE__ */ new Set();
|
|
2507
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2508
|
-
if (output.type !== "asset") continue;
|
|
2509
|
-
files.add(require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2510
|
-
}
|
|
2511
|
-
return files;
|
|
2512
|
-
}
|
|
2513
|
-
function normalizeComparableStyleFile(file) {
|
|
2514
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2515
|
-
}
|
|
2516
|
-
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2517
|
-
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2518
|
-
return [
|
|
2519
|
-
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2520
|
-
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2521
|
-
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2522
|
-
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2523
|
-
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2524
|
-
}
|
|
2525
|
-
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2526
|
-
if (typeof file !== "string" || file.length === 0) return false;
|
|
2527
|
-
const fileKey = normalizeComparableStyleFile(file);
|
|
2528
|
-
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2529
|
-
}
|
|
2530
|
-
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2531
|
-
const opts = options.opts;
|
|
2532
|
-
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2533
|
-
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2534
|
-
if (context === void 0) return;
|
|
2535
|
-
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2536
|
-
...context,
|
|
2537
|
-
bundle,
|
|
2538
|
-
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2539
|
-
isMiniProgramStyleOutputFile,
|
|
2540
|
-
isRootStyleOutputFile,
|
|
2541
|
-
outputFile,
|
|
2542
|
-
sourceFile
|
|
2543
|
-
});
|
|
2544
|
-
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2545
|
-
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2546
|
-
const rootCssFiles = [];
|
|
2547
|
-
const matchedRootCssFiles = [];
|
|
2548
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2549
|
-
if (output.type !== "asset") continue;
|
|
2550
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2551
|
-
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2552
|
-
rootCssFiles.push(file);
|
|
2553
|
-
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2554
|
-
}
|
|
2555
|
-
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2556
|
-
if (matchedRootCssFiles.length > 1) return;
|
|
2557
|
-
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2558
|
-
}
|
|
2559
|
-
function findBundleAssetByOutputFile(bundle, file) {
|
|
2560
|
-
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2561
|
-
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2562
|
-
return output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2563
|
-
})?.[1];
|
|
2564
|
-
}
|
|
2565
|
-
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2566
|
-
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2567
|
-
if (importedStyleFiles.size === 0) return false;
|
|
2568
|
-
let hasNonImportNode = false;
|
|
2569
|
-
try {
|
|
2570
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).each((node) => {
|
|
2571
|
-
if (node.type === "comment") return;
|
|
2572
|
-
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2573
|
-
});
|
|
2574
|
-
} catch {
|
|
2575
|
-
return false;
|
|
2576
|
-
}
|
|
2577
|
-
if (hasNonImportNode) return false;
|
|
2578
|
-
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2579
|
-
}
|
|
2580
|
-
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2581
|
-
const resolvedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2582
|
-
return resolvedOutputFile !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2583
|
-
}
|
|
2584
|
-
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2585
|
-
const resolvedFromFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2586
|
-
if (!markerFile) return resolvedFromFile;
|
|
2587
|
-
const resolvedFromMarker = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2588
|
-
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2589
|
-
return resolvedFromFile;
|
|
2590
|
-
}
|
|
2591
|
-
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2592
|
-
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2593
|
-
const outputFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
2594
|
-
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2595
|
-
}
|
|
2836
|
+
//#endregion
|
|
2837
|
+
//#region src/bundlers/vite/processed-css-assets/collector.ts
|
|
2596
2838
|
function collectViteProcessedCssAssetResults(bundle, options) {
|
|
2597
2839
|
let collected = 0;
|
|
2598
2840
|
const existingAssetFiles = collectBundleAssetFiles(bundle);
|
|
@@ -2662,8 +2904,14 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2662
2904
|
return collected;
|
|
2663
2905
|
}
|
|
2664
2906
|
function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
2907
|
+
const measure = (name, task) => {
|
|
2908
|
+
const startedAt = performance.now();
|
|
2909
|
+
const result = task();
|
|
2910
|
+
options.recordTimingDetail?.(`finalize.processedCss.inject.${name}`, startedAt);
|
|
2911
|
+
return result;
|
|
2912
|
+
};
|
|
2665
2913
|
const transformCss = (css, file) => options.transformCss?.(css, file) ?? css;
|
|
2666
|
-
const viteCssResults = dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2914
|
+
const viteCssResults = measure("prepareResults", () => dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2667
2915
|
return typeof record === "string" ? {
|
|
2668
2916
|
file,
|
|
2669
2917
|
css: record,
|
|
@@ -2677,7 +2925,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2677
2925
|
})).map((record) => ({
|
|
2678
2926
|
...record,
|
|
2679
2927
|
css: transformCss(record.css, record.outputFile ?? record.file)
|
|
2680
|
-
})).filter((record) => record.css.length > 0);
|
|
2928
|
+
})).filter((record) => record.css.length > 0));
|
|
2681
2929
|
let injected = 0;
|
|
2682
2930
|
for (const [bundleFile, bundleOutput] of Object.entries(bundle)) {
|
|
2683
2931
|
let output = bundleOutput;
|
|
@@ -2703,16 +2951,19 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2703
2951
|
}
|
|
2704
2952
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2705
2953
|
const mainFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2706
|
-
const normalizedOriginalCss = normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file);
|
|
2954
|
+
const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file));
|
|
2707
2955
|
let nextCss = normalizedOriginalCss.css;
|
|
2708
2956
|
const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
|
|
2709
2957
|
const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
|
|
2710
|
-
|
|
2958
|
+
const importedBundleCssCoverage = prepareImportedCssCoverage(importedBundleCssSources);
|
|
2959
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, importedBundleCssSources, importedBundleCssCoverage);
|
|
2711
2960
|
const importedViteCssResults = viteCssResults.filter((record) => isViteProcessedCssResultImported(record, importedStyleFiles));
|
|
2712
2961
|
const bundleAssetFiles = collectBundleAssetFiles(bundle);
|
|
2713
2962
|
const uncoveredImportedViteCssResults = importedViteCssResults.filter((record) => !isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedStyleFiles, bundleAssetFiles));
|
|
2714
2963
|
const importedCssSources = [...importedBundleCssSources, ...uncoveredImportedViteCssResults.map((record) => record.css)];
|
|
2715
|
-
|
|
2964
|
+
const uncoveredImportedCssSources = uncoveredImportedViteCssResults.map((record) => record.css);
|
|
2965
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, uncoveredImportedCssSources, prepareImportedCssCoverage(uncoveredImportedCssSources));
|
|
2966
|
+
const importedCssCoverage = prepareImportedCssCoverage(importedCssSources);
|
|
2716
2967
|
const targetViteCssResults = [];
|
|
2717
2968
|
for (const record of viteCssResults) {
|
|
2718
2969
|
if (!isRootStyleOutputFile(file)) {
|
|
@@ -2721,41 +2972,40 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2721
2972
|
if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
|
|
2722
2973
|
if (isViteProcessedCssResultImported(record, importedStyleFiles)) continue;
|
|
2723
2974
|
targetViteCssResults.push(record);
|
|
2724
|
-
let css = normalizeInjectableCssForTarget(
|
|
2725
|
-
css = removeCssCoveredByImportedViteResults(css, importedCssSources).trim();
|
|
2975
|
+
let css = measure("normalizeRecord", () => normalizeInjectableCssForTarget(require_hmr_timing.stripBundlerGeneratedCssMarkers(record.css).trim(), file).trim());
|
|
2976
|
+
css = measure("importCoverage", () => removeCssCoveredByImportedViteResults(css, importedCssSources, importedCssCoverage).trim());
|
|
2726
2977
|
if (css.length === 0) continue;
|
|
2727
|
-
const mergedLayerCss = require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
2978
|
+
const mergedLayerCss = measure("mergeLayers", () => require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css));
|
|
2728
2979
|
if (mergedLayerCss.merged) {
|
|
2729
2980
|
nextCss = mergedLayerCss.css;
|
|
2730
2981
|
css = require_hmr_timing.extractMarkedUserLayerComponentsCss(css).rest.trim();
|
|
2731
2982
|
if (css.length === 0) continue;
|
|
2732
2983
|
}
|
|
2733
|
-
|
|
2734
|
-
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css)) continue;
|
|
2735
|
-
const mergedPreflightDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css);
|
|
2984
|
+
const mergedPreflightDeclarations = measure("mergePreflight", () => (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css));
|
|
2736
2985
|
if (mergedPreflightDeclarations.changed) {
|
|
2737
2986
|
nextCss = mergedPreflightDeclarations.baseCss;
|
|
2738
2987
|
css = mergedPreflightDeclarations.css.trim();
|
|
2739
2988
|
if (css.length === 0) continue;
|
|
2740
2989
|
}
|
|
2741
|
-
const mergedThemeScopeDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramThemeScopeRuleDeclarations)(nextCss, css);
|
|
2990
|
+
const mergedThemeScopeDeclarations = measure("mergeTheme", () => (0, _weapp_tailwindcss_postcss.mergeMiniProgramThemeScopeRuleDeclarations)(nextCss, css));
|
|
2742
2991
|
if (mergedThemeScopeDeclarations.changed) {
|
|
2743
2992
|
nextCss = mergedThemeScopeDeclarations.baseCss;
|
|
2744
2993
|
css = mergedThemeScopeDeclarations.css.trim();
|
|
2745
2994
|
if (css.length === 0) continue;
|
|
2746
2995
|
}
|
|
2747
|
-
const mergedRuleDeclarations = (0, _weapp_tailwindcss_postcss.mergeCoveredCssRuleDeclarations)(nextCss, css);
|
|
2996
|
+
const mergedRuleDeclarations = measure("mergeDeclarations", () => (0, _weapp_tailwindcss_postcss.mergeCoveredCssRuleDeclarations)(nextCss, css));
|
|
2748
2997
|
if (mergedRuleDeclarations.changed) {
|
|
2749
2998
|
nextCss = mergedRuleDeclarations.baseCss;
|
|
2750
2999
|
css = mergedRuleDeclarations.css.trim();
|
|
2751
3000
|
if (css.length === 0) continue;
|
|
2752
3001
|
}
|
|
2753
|
-
const missingCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css);
|
|
2754
|
-
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss)) continue;
|
|
3002
|
+
const missingCss = measure("filterRules", () => (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css));
|
|
3003
|
+
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || measure("containsMissing", () => (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss))) continue;
|
|
2755
3004
|
nextCss = appendCss$1(nextCss, missingCss);
|
|
2756
3005
|
}
|
|
2757
3006
|
const finalImportedCssSources = collectImportedBundleCssSources(bundle, collectImportedStyleFiles(originalSource, file));
|
|
2758
|
-
|
|
3007
|
+
const finalImportedCssCoverage = prepareImportedCssCoverage(finalImportedCssSources);
|
|
3008
|
+
nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
|
|
2759
3009
|
if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
|
|
2760
3010
|
if (nextCss !== originalSource) {
|
|
2761
3011
|
output.source = nextCss;
|
|
@@ -2764,24 +3014,13 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2764
3014
|
options.onUpdate?.(file, originalSource, nextCss);
|
|
2765
3015
|
options.debug?.("inject vite-processed css into main css asset: %s bytes=%d", file, nextCss.length);
|
|
2766
3016
|
}
|
|
2767
|
-
const removedSources = removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options);
|
|
3017
|
+
const removedSources = measure("removeSources", () => removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options));
|
|
2768
3018
|
if (nextCss === originalSource && removedSources === 0) continue;
|
|
2769
3019
|
injected++;
|
|
2770
3020
|
}
|
|
2771
3021
|
return injected;
|
|
2772
3022
|
}
|
|
2773
3023
|
//#endregion
|
|
2774
|
-
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
2775
|
-
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
2776
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
2777
|
-
if (!output.fileName || output.fileName === file) continue;
|
|
2778
|
-
const existing = bundle[output.fileName];
|
|
2779
|
-
if (existing != null && existing !== output) continue;
|
|
2780
|
-
bundle[output.fileName] = output;
|
|
2781
|
-
delete bundle[file];
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
//#endregion
|
|
2785
3024
|
//#region src/bundlers/vite/generate-bundle/final-css-assets.ts
|
|
2786
3025
|
function readAssetSource$1(output) {
|
|
2787
3026
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
@@ -2964,6 +3203,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2964
3203
|
...cssHandlerOptions,
|
|
2965
3204
|
isMainChunk: false
|
|
2966
3205
|
},
|
|
3206
|
+
frameworkPostcssStage: "complete",
|
|
2967
3207
|
getSourceCandidatesForEntries,
|
|
2968
3208
|
styleHandler,
|
|
2969
3209
|
debug
|
|
@@ -3033,7 +3273,7 @@ function pruneLastCssResults(resultByFile, sourceHashByFile, activeFiles) {
|
|
|
3033
3273
|
}
|
|
3034
3274
|
}
|
|
3035
3275
|
//#endregion
|
|
3036
|
-
//#region src/bundlers/vite/generate-bundle/finalize.ts
|
|
3276
|
+
//#region src/bundlers/vite/generate-bundle/finalize/root-import-shell.ts
|
|
3037
3277
|
function readAssetSource(asset) {
|
|
3038
3278
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
3039
3279
|
}
|
|
@@ -3122,6 +3362,8 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
3122
3362
|
}
|
|
3123
3363
|
return updated;
|
|
3124
3364
|
}
|
|
3365
|
+
//#endregion
|
|
3366
|
+
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
3125
3367
|
async function finalizeGenerateBundle(options) {
|
|
3126
3368
|
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, 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, outDir, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
3127
3369
|
const tasksStart = performance.now();
|
|
@@ -3134,6 +3376,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3134
3376
|
await Promise.all(tasks);
|
|
3135
3377
|
recordTimingDetail("tasks", tasksStart);
|
|
3136
3378
|
for (const apply of pendingLinkedUpdates) apply();
|
|
3379
|
+
const uniAppXPostCssStartedAt = performance.now();
|
|
3137
3380
|
const applyStyleSources = await handleUniAppXPostCssTasks({
|
|
3138
3381
|
bundle,
|
|
3139
3382
|
debug,
|
|
@@ -3149,7 +3392,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3149
3392
|
runtimeState,
|
|
3150
3393
|
styleHandler
|
|
3151
3394
|
});
|
|
3395
|
+
recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
|
|
3152
3396
|
const syncViteProcessedCssIntoMainCssAssets = () => {
|
|
3397
|
+
const collectStartedAt = performance.now();
|
|
3153
3398
|
collectViteProcessedCssAssetResults(bundle, {
|
|
3154
3399
|
opts,
|
|
3155
3400
|
cssPipelineStrategy,
|
|
@@ -3163,7 +3408,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3163
3408
|
transformCss: transformWebTargetCss,
|
|
3164
3409
|
debug
|
|
3165
3410
|
});
|
|
3166
|
-
|
|
3411
|
+
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
3412
|
+
const injectStartedAt = performance.now();
|
|
3413
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
3167
3414
|
opts,
|
|
3168
3415
|
cssPipelineStrategy,
|
|
3169
3416
|
createCssPipelineContext,
|
|
@@ -3177,16 +3424,22 @@ async function finalizeGenerateBundle(options) {
|
|
|
3177
3424
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
3178
3425
|
},
|
|
3179
3426
|
debug,
|
|
3180
|
-
onUpdate
|
|
3427
|
+
onUpdate,
|
|
3428
|
+
recordTimingDetail
|
|
3181
3429
|
});
|
|
3430
|
+
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
3431
|
+
return injected;
|
|
3182
3432
|
};
|
|
3433
|
+
const processedCssStartedAt = performance.now();
|
|
3183
3434
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3184
3435
|
if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
|
|
3185
3436
|
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
|
|
3186
3437
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3187
3438
|
}
|
|
3439
|
+
recordTimingDetail("finalize.processedCss", processedCssStartedAt);
|
|
3188
3440
|
const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
|
|
3189
3441
|
const finalizeCssPipelineContext = createFinalizeCssPipelineContext();
|
|
3442
|
+
const rootCssStartedAt = performance.now();
|
|
3190
3443
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
3191
3444
|
cssMatcher: opts.cssMatcher,
|
|
3192
3445
|
debug,
|
|
@@ -3215,6 +3468,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3215
3468
|
isWebGeneratorTarget,
|
|
3216
3469
|
outDir
|
|
3217
3470
|
}) === true) removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, { debug });
|
|
3471
|
+
recordTimingDetail("finalize.rootCss", rootCssStartedAt);
|
|
3472
|
+
const finalCssAssetsStartedAt = performance.now();
|
|
3218
3473
|
await finalizeMiniProgramCssAssets(bundle, {
|
|
3219
3474
|
cssMatcher: opts.cssMatcher,
|
|
3220
3475
|
debug,
|
|
@@ -3225,6 +3480,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3225
3480
|
recordCssAssetResult,
|
|
3226
3481
|
styleHandler
|
|
3227
3482
|
});
|
|
3483
|
+
recordTimingDetail("finalize.cssAssets", finalCssAssetsStartedAt);
|
|
3484
|
+
const webCompatStartedAt = performance.now();
|
|
3228
3485
|
if (finalizeCssPipelineContext !== void 0 && cssPipelineStrategy?.shouldApplyFinalWebviewCssCompat?.({
|
|
3229
3486
|
...finalizeCssPipelineContext,
|
|
3230
3487
|
bundleFiles: Object.keys(bundle),
|
|
@@ -3236,6 +3493,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3236
3493
|
opts,
|
|
3237
3494
|
recordCssAssetResult
|
|
3238
3495
|
});
|
|
3496
|
+
recordTimingDetail("finalize.webCompat", webCompatStartedAt);
|
|
3239
3497
|
const stateUpdateStart = performance.now();
|
|
3240
3498
|
require_source_candidate_scan_signature.updateBundleBuildState(state, snapshot, useIncrementalMode ? linkedByEntry ?? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map(), { incremental: useIncrementalMode });
|
|
3241
3499
|
state.generatorCandidateSignature = generatorCandidateSignature;
|
|
@@ -3349,11 +3607,12 @@ function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
|
3349
3607
|
//#region src/bundlers/vite/generate-bundle/html-processing.ts
|
|
3350
3608
|
function processHtmlBundleEntry(options) {
|
|
3351
3609
|
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
3352
|
-
const
|
|
3353
|
-
const
|
|
3354
|
-
const
|
|
3610
|
+
const currentBundleSource = originalEntrySource;
|
|
3611
|
+
const candidateSource = resolveCurrentSourceCandidateSource(file) ?? currentBundleSource;
|
|
3612
|
+
const currentRawDynamicCandidates = /* @__PURE__ */ new Set([...collectUnescapedDynamicCandidates(candidateSource), ...collectUnescapedDynamicCandidates(currentBundleSource)]);
|
|
3613
|
+
const templateRuntime = currentRawDynamicCandidates.size > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
3355
3614
|
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : require_source_candidate_scan_signature.createCandidateSignature(templateRuntime);
|
|
3356
|
-
const htmlProcessHash = `${cache.computeHash(
|
|
3615
|
+
const htmlProcessHash = `${cache.computeHash(currentBundleSource)}:${cache.computeHash(require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(currentBundleSource, "html"))}:${templateRuntimeSignature}`;
|
|
3357
3616
|
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
3358
3617
|
const hashKey = cacheKey;
|
|
3359
3618
|
rememberProcessCacheKey(cacheKey, hashKey);
|
|
@@ -3371,7 +3630,7 @@ function processHtmlBundleEntry(options) {
|
|
|
3371
3630
|
},
|
|
3372
3631
|
async transform() {
|
|
3373
3632
|
const start = performance.now();
|
|
3374
|
-
let transformed = await templateHandler(
|
|
3633
|
+
let transformed = await templateHandler(currentBundleSource, { runtimeSet: templateRuntime });
|
|
3375
3634
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
3376
3635
|
let retryRuntimeSet;
|
|
3377
3636
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
@@ -3382,13 +3641,13 @@ function processHtmlBundleEntry(options) {
|
|
|
3382
3641
|
}
|
|
3383
3642
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
3384
3643
|
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
3385
|
-
transformed = await templateHandler(
|
|
3644
|
+
transformed = await templateHandler(currentBundleSource, { runtimeSet: retryRuntimeSet });
|
|
3386
3645
|
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
3387
3646
|
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
3388
3647
|
}
|
|
3389
3648
|
metrics.html.elapsed += measureElapsed(start);
|
|
3390
3649
|
metrics.html.transformed++;
|
|
3391
|
-
onUpdate(file,
|
|
3650
|
+
onUpdate(file, currentBundleSource, transformed);
|
|
3392
3651
|
debug("html handle: %s", file);
|
|
3393
3652
|
return { result: transformed };
|
|
3394
3653
|
}
|
|
@@ -3494,7 +3753,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
3494
3753
|
//#region src/uni-app-x/vite.ts
|
|
3495
3754
|
let transformUVuePromise;
|
|
3496
3755
|
function loadTransformUVue() {
|
|
3497
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
3756
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-CcYptivi.js")).then((mod) => mod.transformUVue));
|
|
3498
3757
|
return transformUVuePromise;
|
|
3499
3758
|
}
|
|
3500
3759
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -3535,8 +3794,8 @@ function createUniAppXPlugins(options) {
|
|
|
3535
3794
|
let componentLocalStyleEnabled;
|
|
3536
3795
|
const harmonyApplyStyleSources = /* @__PURE__ */ new Set();
|
|
3537
3796
|
const harmonyApplyUtilities = /* @__PURE__ */ new Set();
|
|
3538
|
-
function rememberHarmonyApplySource(code) {
|
|
3539
|
-
const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code);
|
|
3797
|
+
function rememberHarmonyApplySource(code, id) {
|
|
3798
|
+
const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
3540
3799
|
if (styleSources.length === 0) return;
|
|
3541
3800
|
for (const styleSource of styleSources) {
|
|
3542
3801
|
harmonyApplyStyleSources.add(styleSource);
|
|
@@ -3569,7 +3828,7 @@ function createUniAppXPlugins(options) {
|
|
|
3569
3828
|
if (require_source_candidate_scan_signature.isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
3570
3829
|
if (isCssModuleExport(code)) return;
|
|
3571
3830
|
const shouldGenerateCss = require_generator.hasTailwindSourceDirectives(code, { importFallback: true }) || require_generator.hasTailwindApplyDirective(code);
|
|
3572
|
-
rememberHarmonyApplySource(code);
|
|
3831
|
+
rememberHarmonyApplySource(code, id);
|
|
3573
3832
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
|
|
3574
3833
|
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
|
|
3575
3834
|
const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
|
|
@@ -3629,7 +3888,7 @@ function createUniAppXPlugins(options) {
|
|
|
3629
3888
|
async transform(code, id) {
|
|
3630
3889
|
if (!isEnabled()) return;
|
|
3631
3890
|
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
3632
|
-
rememberHarmonyApplySource(code);
|
|
3891
|
+
rememberHarmonyApplySource(code, id);
|
|
3633
3892
|
const resolvedConfig = getResolvedConfig();
|
|
3634
3893
|
const isServeCommand = resolvedConfig?.command === "serve";
|
|
3635
3894
|
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
@@ -3638,13 +3897,19 @@ function createUniAppXPlugins(options) {
|
|
|
3638
3897
|
const transformUVue = await loadTransformUVue();
|
|
3639
3898
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
3640
3899
|
const enablePageLocalStyle = shouldEnableHarmonyPageLocalStyle();
|
|
3641
|
-
if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle)
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3900
|
+
if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle) {
|
|
3901
|
+
const result = transformUVue(code, id, jsHandler, currentRuntimeSet, require_object.omitUndefined({
|
|
3902
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
3903
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
3904
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
3905
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
3906
|
+
}));
|
|
3907
|
+
if (result?.code) rememberHarmonyApplySource(result.code, id);
|
|
3908
|
+
return result;
|
|
3909
|
+
}
|
|
3910
|
+
const result = transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
3911
|
+
if (result?.code) rememberHarmonyApplySource(result.code, id);
|
|
3912
|
+
return result;
|
|
3648
3913
|
},
|
|
3649
3914
|
async handleHotUpdate(ctx) {
|
|
3650
3915
|
if (!isEnabled()) return;
|
|
@@ -3674,7 +3939,7 @@ function createUniAppXPlugins(options) {
|
|
|
3674
3939
|
const getAssetSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
3675
3940
|
if (isHarmonyTarget) {
|
|
3676
3941
|
const cssSources = [];
|
|
3677
|
-
const applyStyleSources = [...harmonyApplyStyleSources
|
|
3942
|
+
const applyStyleSources = harmonyApplyStyleSources.size > 0 ? [...harmonyApplyStyleSources] : collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
3678
3943
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
3679
3944
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
3680
3945
|
const harmonyApplyCssFile = node_path.default.resolve(getResolvedConfig()?.root ?? node_process.default.cwd(), "uni-app-x-harmony-apply.css");
|
|
@@ -3895,7 +4160,7 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3895
4160
|
if (!sources) return [];
|
|
3896
4161
|
const rememberedSources = [...sources].map(([, remembered]) => remembered);
|
|
3897
4162
|
const source = typeof originalSource.source === "string" ? originalSource.source : originalSource.source.toString();
|
|
3898
|
-
const markerFiles = new Set(
|
|
4163
|
+
const markerFiles = new Set(require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(source).filter((block) => block.bundler === "vite" && typeof block.file === "string" && block.file.length > 0).map((block) => require_source_candidate_scan_signature.normalizeOutputPathKey(block.file)));
|
|
3899
4164
|
if (markerFiles.size > 0) {
|
|
3900
4165
|
const markerMatched = rememberedSources.filter((remembered) => markerFiles.has(normalizeRememberedSourceIdentity(remembered.sourceFile)));
|
|
3901
4166
|
if (markerMatched.length > 0) return selectBestRememberedCssSourceMatches(markerMatched, outputFile, outputRoot, sourceRoot);
|
|
@@ -3912,7 +4177,7 @@ function findRememberedCssSources(sources, outputFile, file, originalSource, out
|
|
|
3912
4177
|
}
|
|
3913
4178
|
const outputMatched = rememberedSources.filter((remembered) => require_source_candidate_scan_signature.normalizeOutputPathKey(remembered.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
3914
4179
|
if (outputMatched.length > 0) return outputMatched;
|
|
3915
|
-
if (!
|
|
4180
|
+
if (!require_hmr_timing.hasBundlerGeneratedCssMarker(source) && !hasTailwindGenerationSource(source)) return [];
|
|
3916
4181
|
const scoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot);
|
|
3917
4182
|
const strongScoredMatches = selectBestRememberedCssSourceMatches(rememberedSources, outputFile, outputRoot, sourceRoot, { minimumScore: 1e5 });
|
|
3918
4183
|
if (strongScoredMatches.length > 0 && strongScoredMatches.length < rememberedSources.length) return strongScoredMatches;
|
|
@@ -3952,17 +4217,25 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
|
|
|
3952
4217
|
}
|
|
3953
4218
|
//#endregion
|
|
3954
4219
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
4220
|
+
function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
4221
|
+
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
4222
|
+
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
4223
|
+
}
|
|
3955
4224
|
async function processRememberedCssReplay(options) {
|
|
3956
4225
|
const { addWatchFile, activeViteCssCacheFiles, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, refreshRememberedCssSource, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
3957
4226
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3958
4227
|
for (const [outputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
3959
4228
|
if (require_source_candidate_scan_signature.isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
3960
|
-
const
|
|
4229
|
+
const replayableRememberedGroup = (await Promise.all(rememberedGroup.map(async (item) => ({
|
|
3961
4230
|
key: item.key,
|
|
3962
4231
|
remembered: await refreshRememberedCssSource?.(item.remembered) ?? item.remembered
|
|
3963
|
-
})))
|
|
3964
|
-
|
|
3965
|
-
|
|
4232
|
+
})))).filter(({ remembered }) => {
|
|
4233
|
+
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
4234
|
+
if (shouldSkip) debug("css replay skip raw source style: %s -> %s", remembered.sourceFile, outputFile);
|
|
4235
|
+
return !shouldSkip;
|
|
4236
|
+
});
|
|
4237
|
+
const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
|
|
4238
|
+
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
3966
4239
|
if (!rememberedCssSource) continue;
|
|
3967
4240
|
const { rawSource, sourceFile } = rememberedCssSource;
|
|
3968
4241
|
const generatorRawSource = isWebGeneratorTarget ? rawSource : require_hmr_timing.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
@@ -4037,6 +4310,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4037
4310
|
outputFile,
|
|
4038
4311
|
cssHandlerOptions,
|
|
4039
4312
|
cssUserHandlerOptions: getCssUserHandlerOptions(sourceFile),
|
|
4313
|
+
frameworkPostcssStage: "complete",
|
|
4040
4314
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
4041
4315
|
generatorPlatform,
|
|
4042
4316
|
styleHandler,
|
|
@@ -4267,13 +4541,12 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
4267
4541
|
function normalizeSourceCandidatePathKey(file) {
|
|
4268
4542
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.resolve(file));
|
|
4269
4543
|
}
|
|
4270
|
-
function
|
|
4271
|
-
const { file,
|
|
4544
|
+
function createSourceCandidateFiles(options) {
|
|
4545
|
+
const { file, outDir, rootDir, sourceRoot } = options;
|
|
4272
4546
|
const cleanedFile = file.replace(/[?#].*$/, "");
|
|
4273
|
-
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(cleanedFile);
|
|
4274
4547
|
const absoluteFile = node_path.default.isAbsolute(cleanedFile) ? cleanedFile : node_path.default.resolve(rootDir, cleanedFile);
|
|
4275
4548
|
const relativeFromOutDir = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.relative(outDir, absoluteFile));
|
|
4276
|
-
|
|
4549
|
+
return [
|
|
4277
4550
|
sourceRoot ? node_path.default.resolve(sourceRoot, file) : void 0,
|
|
4278
4551
|
node_path.default.resolve(rootDir, file),
|
|
4279
4552
|
node_path.default.resolve(node_path.default.dirname(outDir), file),
|
|
@@ -4282,6 +4555,33 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
4282
4555
|
!node_path.default.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? node_path.default.resolve(node_path.default.dirname(outDir), relativeFromOutDir) : void 0,
|
|
4283
4556
|
file
|
|
4284
4557
|
];
|
|
4558
|
+
}
|
|
4559
|
+
function resolveCurrentSourceCandidateFile(options) {
|
|
4560
|
+
const sourceCandidates = createSourceCandidateFiles(options);
|
|
4561
|
+
for (const candidate of sourceCandidates) if (candidate && options.getSourceCandidateSource?.(candidate) !== void 0) return candidate;
|
|
4562
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(options.file.replace(/[?#].*$/, ""));
|
|
4563
|
+
let bestMatch;
|
|
4564
|
+
const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
|
|
4565
|
+
absolute: node_path.default.isAbsolute(candidate),
|
|
4566
|
+
key: normalizeSourceCandidatePathKey(candidate)
|
|
4567
|
+
}));
|
|
4568
|
+
for (const [sourceFile] of options.getSourceCandidateSources?.() ?? []) {
|
|
4569
|
+
const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
|
|
4570
|
+
let score = normalizedSourceCandidates.reduce((current, candidate) => {
|
|
4571
|
+
return normalizedSourceFile === candidate.key ? Math.max(current, candidate.absolute ? 100 : 80) : current;
|
|
4572
|
+
}, 0);
|
|
4573
|
+
if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
|
|
4574
|
+
if (score > (bestMatch?.score ?? 0)) bestMatch = {
|
|
4575
|
+
file: sourceFile,
|
|
4576
|
+
score
|
|
4577
|
+
};
|
|
4578
|
+
}
|
|
4579
|
+
return bestMatch?.file;
|
|
4580
|
+
}
|
|
4581
|
+
function resolveCurrentSourceCandidateSource(options) {
|
|
4582
|
+
const { file, getSourceCandidateSource, getSourceCandidateSources } = options;
|
|
4583
|
+
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
4584
|
+
const sourceCandidates = createSourceCandidateFiles(options);
|
|
4285
4585
|
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
4286
4586
|
if (source || !candidate) return source;
|
|
4287
4587
|
return getSourceCandidateSource?.(candidate);
|
|
@@ -4540,102 +4840,6 @@ function createBundleTaskTimer(recordTimingDetail) {
|
|
|
4540
4840
|
};
|
|
4541
4841
|
}
|
|
4542
4842
|
//#endregion
|
|
4543
|
-
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
4544
|
-
function toArray(value) {
|
|
4545
|
-
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
4546
|
-
}
|
|
4547
|
-
function normalizeSourceId(id) {
|
|
4548
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
4549
|
-
return node_path.default.isAbsolute(file) ? node_path.default.resolve(file) : void 0;
|
|
4550
|
-
}
|
|
4551
|
-
function collectChunkModuleIds$1(chunk) {
|
|
4552
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4553
|
-
for (const id of chunk.moduleIds ?? []) {
|
|
4554
|
-
const normalized = normalizeSourceId(id);
|
|
4555
|
-
if (normalized) ids.add(normalized);
|
|
4556
|
-
}
|
|
4557
|
-
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
4558
|
-
const normalized = normalizeSourceId(id);
|
|
4559
|
-
if (normalized) ids.add(normalized);
|
|
4560
|
-
}
|
|
4561
|
-
return ids;
|
|
4562
|
-
}
|
|
4563
|
-
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
4564
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4565
|
-
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
4566
|
-
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
4567
|
-
for (const candidate of candidates) {
|
|
4568
|
-
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
4569
|
-
const cleanCandidate = (0, _weapp_tailwindcss_shared.cleanUrl)(candidate);
|
|
4570
|
-
const resolved = node_path.default.isAbsolute(cleanCandidate) ? node_path.default.resolve(cleanCandidate) : node_path.default.resolve(rootDir, cleanCandidate);
|
|
4571
|
-
ids.add(resolved);
|
|
4572
|
-
}
|
|
4573
|
-
return ids;
|
|
4574
|
-
}
|
|
4575
|
-
function isStringRuleMatched(rule, id, rootDir) {
|
|
4576
|
-
const normalizedId = require_source_candidate_scan_signature.slash(id);
|
|
4577
|
-
const normalizedRule = require_source_candidate_scan_signature.slash(rule);
|
|
4578
|
-
if (node_path.default.isAbsolute(rule)) return micromatch.default.isMatch(normalizedId, normalizedRule);
|
|
4579
|
-
const relative = require_source_candidate_scan_signature.slash(node_path.default.relative(rootDir, id));
|
|
4580
|
-
return relative.length > 0 && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizedRule);
|
|
4581
|
-
}
|
|
4582
|
-
function isRuleMatched(rule, id, rootDir) {
|
|
4583
|
-
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
4584
|
-
if (rule instanceof RegExp) {
|
|
4585
|
-
rule.lastIndex = 0;
|
|
4586
|
-
return rule.test(require_source_candidate_scan_signature.slash(id));
|
|
4587
|
-
}
|
|
4588
|
-
return rule(id) === true;
|
|
4589
|
-
}
|
|
4590
|
-
function createTransformMatcher(rules, rootDir) {
|
|
4591
|
-
const normalizedRules = toArray(rules);
|
|
4592
|
-
if (normalizedRules.length === 0) return;
|
|
4593
|
-
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
4594
|
-
}
|
|
4595
|
-
function shouldSkipSourceIds(sourceIds, filter) {
|
|
4596
|
-
if (sourceIds.size === 0) return false;
|
|
4597
|
-
if (filter.exclude) {
|
|
4598
|
-
let excluded = true;
|
|
4599
|
-
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
4600
|
-
excluded = false;
|
|
4601
|
-
break;
|
|
4602
|
-
}
|
|
4603
|
-
if (excluded) return true;
|
|
4604
|
-
}
|
|
4605
|
-
if (filter.include) {
|
|
4606
|
-
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
4607
|
-
return true;
|
|
4608
|
-
}
|
|
4609
|
-
return false;
|
|
4610
|
-
}
|
|
4611
|
-
function createTransformFilter(options, rootDir) {
|
|
4612
|
-
const include = createTransformMatcher(options?.include, rootDir);
|
|
4613
|
-
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
4614
|
-
if (!include && !exclude) return;
|
|
4615
|
-
return {
|
|
4616
|
-
include,
|
|
4617
|
-
exclude
|
|
4618
|
-
};
|
|
4619
|
-
}
|
|
4620
|
-
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
4621
|
-
if (!filter) return false;
|
|
4622
|
-
return shouldSkipSourceIds(collectChunkModuleIds$1(chunk), filter);
|
|
4623
|
-
}
|
|
4624
|
-
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
4625
|
-
if (!filter) return false;
|
|
4626
|
-
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
4627
|
-
}
|
|
4628
|
-
function createRuleSignature(rules) {
|
|
4629
|
-
return toArray(rules).map((rule) => {
|
|
4630
|
-
if (typeof rule === "string") return `s:${rule}`;
|
|
4631
|
-
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
4632
|
-
return "f";
|
|
4633
|
-
}).join("|") || "none";
|
|
4634
|
-
}
|
|
4635
|
-
function createTransformFilterSignature(options) {
|
|
4636
|
-
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
4637
|
-
}
|
|
4638
|
-
//#endregion
|
|
4639
4843
|
//#region src/bundlers/vite/weapp-vite-config.ts
|
|
4640
4844
|
function resolveSourceRootCandidate(root, value) {
|
|
4641
4845
|
if (typeof value !== "string" || value.trim().length === 0) return;
|
|
@@ -4703,7 +4907,7 @@ function resolveViteWebCssCompatOptions(context) {
|
|
|
4703
4907
|
return context.currentGeneratorBranch.isWeb ? context.currentGeneratorOptions.webCompat : context.currentGeneratorOptions.webCompat ?? true;
|
|
4704
4908
|
}
|
|
4705
4909
|
//#endregion
|
|
4706
|
-
//#region src/bundlers/vite/generate-bundle.ts
|
|
4910
|
+
//#region src/bundlers/vite/generate-bundle-runtime.ts
|
|
4707
4911
|
function inferPlatformFromViteOutDir$1(outDir) {
|
|
4708
4912
|
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
4709
4913
|
if (!segment) return;
|
|
@@ -4713,7 +4917,7 @@ function inferPlatformFromViteOutDir$1(outDir) {
|
|
|
4713
4917
|
function hasTailwindPluginDirective(source) {
|
|
4714
4918
|
return /@plugin\b/.test(source);
|
|
4715
4919
|
}
|
|
4716
|
-
function createGenerateBundleHook(context) {
|
|
4920
|
+
function createGenerateBundleHook$1(context) {
|
|
4717
4921
|
const state = require_source_candidate_scan_signature.createBundleBuildState();
|
|
4718
4922
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
4719
4923
|
const lastCssSourceHashByFile = /* @__PURE__ */ new Map();
|
|
@@ -4756,8 +4960,11 @@ function createGenerateBundleHook(context) {
|
|
|
4756
4960
|
})
|
|
4757
4961
|
});
|
|
4758
4962
|
return async function generateBundle(_opt, bundle) {
|
|
4963
|
+
if (context.shouldProcessBundle?.() === false) return;
|
|
4964
|
+
const processMarkupAndScripts = context.processMarkupAndScripts !== false;
|
|
4965
|
+
const processStyles = context.shouldProcessStyles?.() ?? context.processStyles !== false;
|
|
4759
4966
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
4760
|
-
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
4967
|
+
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, extractSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
4761
4968
|
const getBundlerSfcSource = (sourceFile) => {
|
|
4762
4969
|
const code = this.getModuleInfo?.(sourceFile)?.code;
|
|
4763
4970
|
return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
|
|
@@ -4815,7 +5022,7 @@ function createGenerateBundleHook(context) {
|
|
|
4815
5022
|
await runtimeState.readyPromise;
|
|
4816
5023
|
debug("start");
|
|
4817
5024
|
onStart();
|
|
4818
|
-
const collectedBundlerGeneratedCssFiles = new Set(Object.entries(bundle).filter(([, output]) => output.type === "asset" &&
|
|
5025
|
+
const collectedBundlerGeneratedCssFiles = new Set(Object.entries(bundle).filter(([, output]) => output.type === "asset" && require_hmr_timing.hasBundlerGeneratedCssMarker(output.source)).map(([file]) => file));
|
|
4819
5026
|
const subpackageRoots = collectMiniProgramSubpackageRoots(bundle);
|
|
4820
5027
|
if (subpackageRoots) currentSubpackageRoots = subpackageRoots;
|
|
4821
5028
|
collectViteProcessedCssAssetResults(bundle, {
|
|
@@ -4975,18 +5182,6 @@ function createGenerateBundleHook(context) {
|
|
|
4975
5182
|
return !require_source_candidate_scan_signature.normalizeOutputPathKey(entryOutputFile.replace(/[?#].*$/, "")).includes("/") || currentSubpackageRoots != null && !isSubpackageOutputFile(entryOutputFile, currentSubpackageRoots);
|
|
4976
5183
|
});
|
|
4977
5184
|
};
|
|
4978
|
-
const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
|
|
4979
|
-
cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
|
|
4980
|
-
getSourceCandidateSourcesForEntries,
|
|
4981
|
-
getSourceCandidatesForEntries,
|
|
4982
|
-
projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
|
|
4983
|
-
rootDir,
|
|
4984
|
-
snapshot,
|
|
4985
|
-
sourceRoot,
|
|
4986
|
-
subpackageRoots: currentSubpackageRoots,
|
|
4987
|
-
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
4988
|
-
useIncrementalMode
|
|
4989
|
-
});
|
|
4990
5185
|
recordTimingDetail("snapshot", snapshotStart);
|
|
4991
5186
|
const useBundleRuntimeClassSet = !isWebGeneratorTarget;
|
|
4992
5187
|
const forceRuntimeRefreshBySource = useIncrementalMode && require_source_candidate_scan_signature.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
@@ -5000,21 +5195,50 @@ function createGenerateBundleHook(context) {
|
|
|
5000
5195
|
const sourceCandidateWaitStart = performance.now();
|
|
5001
5196
|
await waitForSourceCandidateSyncs?.();
|
|
5002
5197
|
recordTimingDetail("sourceCandidates.wait", sourceCandidateWaitStart);
|
|
5003
|
-
const
|
|
5004
|
-
const
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5198
|
+
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
5199
|
+
const bundleMarkupCandidates = await collectBundleMarkupCandidates({
|
|
5200
|
+
extractSourceCandidates: processMarkupAndScripts && !isWebGeneratorTarget ? extractSourceCandidates : void 0,
|
|
5201
|
+
previousCandidatesByFile: useIncrementalMode ? state.bundleMarkupCandidatesByFile : void 0,
|
|
5202
|
+
preserveMissingFiles: useIncrementalMode && snapshot.hasOmittedKnownFiles,
|
|
5203
|
+
resolveSourceCandidateFile: (file) => resolveCurrentSourceCandidateFile({
|
|
5204
|
+
file,
|
|
5205
|
+
getSourceCandidateSource,
|
|
5206
|
+
getSourceCandidateSources,
|
|
5207
|
+
outDir,
|
|
5208
|
+
rootDir,
|
|
5209
|
+
sourceRoot
|
|
5210
|
+
}),
|
|
5211
|
+
rootDir,
|
|
5212
|
+
snapshot,
|
|
5213
|
+
transformFilter
|
|
5214
|
+
});
|
|
5215
|
+
const getCombinedSourceCandidatesForEntries = getSourceCandidatesForEntries || bundleMarkupCandidates.values.size > 0 ? (entries, options) => /* @__PURE__ */ new Set([...getSourceCandidatesForEntries?.(entries, options) ?? [], ...bundleMarkupCandidates.valuesForEntries(entries, options)]) : void 0;
|
|
5216
|
+
const sourceCandidates = /* @__PURE__ */ new Set([...getSourceCandidates?.() ?? [], ...bundleMarkupCandidates.values]);
|
|
5217
|
+
const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
|
|
5218
|
+
cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
|
|
5219
|
+
getSourceCandidateSourcesForEntries,
|
|
5220
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5221
|
+
projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
|
|
5222
|
+
rootDir,
|
|
5223
|
+
snapshot,
|
|
5224
|
+
sourceRoot,
|
|
5225
|
+
subpackageRoots: currentSubpackageRoots,
|
|
5226
|
+
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
5227
|
+
useIncrementalMode
|
|
5228
|
+
});
|
|
5229
|
+
const createScopedGeneratorRuntime$1 = (outputFile, cssHandlerOptions2, runtime2, rawSource, sourceFile) => require_source_candidate_scan_signature.createScopedGeneratorRuntime({
|
|
5230
|
+
cssHandlerOptions: cssHandlerOptions2,
|
|
5231
|
+
fallbackRuntime: runtime2,
|
|
5232
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5008
5233
|
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
5009
5234
|
outputFile,
|
|
5010
5235
|
rawSource,
|
|
5011
5236
|
shouldExcludeSubpackageSourceCandidates,
|
|
5012
5237
|
sourceFile,
|
|
5013
|
-
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile,
|
|
5238
|
+
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile, cssHandlerOptions2)
|
|
5014
5239
|
});
|
|
5015
5240
|
const jsEntries = snapshot.jsEntries;
|
|
5016
5241
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
5017
|
-
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
5018
5242
|
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
5019
5243
|
const moduleGraphOptions = require_source_candidate_scan_signature.createBundleModuleGraphOptions(outDir, jsEntries);
|
|
5020
5244
|
const hasRuntimeAffectingChanges = require_source_candidate_scan_signature.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
@@ -5162,9 +5386,10 @@ function createGenerateBundleHook(context) {
|
|
|
5162
5386
|
const tasks = [];
|
|
5163
5387
|
const cssTaskFactories = [];
|
|
5164
5388
|
const jsTaskFactories = [];
|
|
5389
|
+
const entryPlanningStartedAt = performance.now();
|
|
5165
5390
|
for (const entry of snapshot.entries) {
|
|
5166
5391
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
5167
|
-
if (type === "html" && originalSource.type === "asset") {
|
|
5392
|
+
if (processMarkupAndScripts && type === "html" && originalSource.type === "asset") {
|
|
5168
5393
|
metrics.html.total++;
|
|
5169
5394
|
if (isWebGeneratorTarget) {
|
|
5170
5395
|
debug("html skip web target: %s", file);
|
|
@@ -5187,8 +5412,8 @@ function createGenerateBundleHook(context) {
|
|
|
5187
5412
|
originalEntrySource,
|
|
5188
5413
|
originalSource,
|
|
5189
5414
|
rememberProcessCacheKey,
|
|
5190
|
-
resolveCurrentSourceCandidateSource: (
|
|
5191
|
-
file,
|
|
5415
|
+
resolveCurrentSourceCandidateSource: (file2) => resolveCurrentSourceCandidateSource({
|
|
5416
|
+
file: file2,
|
|
5192
5417
|
getSourceCandidateSource,
|
|
5193
5418
|
getSourceCandidateSources,
|
|
5194
5419
|
outDir,
|
|
@@ -5203,12 +5428,12 @@ function createGenerateBundleHook(context) {
|
|
|
5203
5428
|
});
|
|
5204
5429
|
continue;
|
|
5205
5430
|
}
|
|
5206
|
-
if (type === "css" && originalSource.type === "asset") {
|
|
5431
|
+
if (processStyles && type === "css" && originalSource.type === "asset") {
|
|
5207
5432
|
metrics.css.total++;
|
|
5208
5433
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
5209
5434
|
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
|
|
5210
5435
|
const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
|
|
5211
|
-
const
|
|
5436
|
+
const cssPipelineContext2 = {
|
|
5212
5437
|
...createInitialCssPipelineContext(file),
|
|
5213
5438
|
bundle
|
|
5214
5439
|
};
|
|
@@ -5220,7 +5445,7 @@ function createGenerateBundleHook(context) {
|
|
|
5220
5445
|
isWebGeneratorTarget,
|
|
5221
5446
|
matchesCss: opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file),
|
|
5222
5447
|
shouldKeep: () => context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5223
|
-
...
|
|
5448
|
+
...cssPipelineContext2,
|
|
5224
5449
|
css: rawSource,
|
|
5225
5450
|
file: rootImportShellOutputFile
|
|
5226
5451
|
})
|
|
@@ -5230,16 +5455,16 @@ function createGenerateBundleHook(context) {
|
|
|
5230
5455
|
if (importedFile && isRootMiniProgramStyleOutputFile$1(importedFile)) frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, importedFile);
|
|
5231
5456
|
}
|
|
5232
5457
|
if (!rememberedFrameworkRootImportTarget && !isCurrentFrameworkRootImportShell && !isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(file) && opts.mainCssChunkMatcher(rootImportShellOutputFile, opts.appType) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5233
|
-
...
|
|
5458
|
+
...cssPipelineContext2,
|
|
5234
5459
|
css: rawSource,
|
|
5235
5460
|
file: rootImportShellOutputFile
|
|
5236
5461
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5237
|
-
...
|
|
5462
|
+
...cssPipelineContext2,
|
|
5238
5463
|
file: rootImportShellOutputFile
|
|
5239
5464
|
}))) {
|
|
5240
5465
|
const rootGeneratedTargets = /* @__PURE__ */ new Set();
|
|
5241
|
-
for (const
|
|
5242
|
-
const targetFile = resolveMatchedCssSourceOutputFile(
|
|
5466
|
+
for (const entry2 of getConfiguredTailwindV4CssSourceEntries()) {
|
|
5467
|
+
const targetFile = resolveMatchedCssSourceOutputFile(entry2.file);
|
|
5243
5468
|
if (targetFile && isRootMiniProgramStyleOutputFile$1(targetFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootImportShellOutputFile)) rootGeneratedTargets.add(targetFile);
|
|
5244
5469
|
}
|
|
5245
5470
|
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) {
|
|
@@ -5263,11 +5488,11 @@ function createGenerateBundleHook(context) {
|
|
|
5263
5488
|
file,
|
|
5264
5489
|
isWebGeneratorTarget,
|
|
5265
5490
|
opts,
|
|
5266
|
-
pipelineContext:
|
|
5491
|
+
pipelineContext: cssPipelineContext2,
|
|
5267
5492
|
shouldPreserveAppCssExtension
|
|
5268
5493
|
});
|
|
5269
5494
|
if (rememberedFrameworkRootImportTarget && !isWebGeneratorTarget && (opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file)) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5270
|
-
...
|
|
5495
|
+
...cssPipelineContext2,
|
|
5271
5496
|
css: rawSource,
|
|
5272
5497
|
file: rootImportShellOutputFile
|
|
5273
5498
|
}))) {
|
|
@@ -5280,7 +5505,7 @@ function createGenerateBundleHook(context) {
|
|
|
5280
5505
|
originalFileNames: originalSource.originalFileNames,
|
|
5281
5506
|
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
5282
5507
|
});
|
|
5283
|
-
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((
|
|
5508
|
+
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((entry2) => originalSource.originalFileNames?.some((originalFile) => normalizeConfiguredTailwindV4CssEntryFileKey(originalFile) === normalizeConfiguredTailwindV4CssEntryFileKey(entry2.file)) === true) : void 0;
|
|
5284
5509
|
const configuredOriginalOutputFile = configuredOriginalSourceEntry ? resolveMatchedOutputFileForCurrentAsset(configuredOriginalSourceEntry.file) : void 0;
|
|
5285
5510
|
let resolvedFromConfiguredOriginalCssEntry = false;
|
|
5286
5511
|
if (configuredOriginalOutputFile && require_source_candidate_scan_signature.normalizeOutputPathKey(configuredOriginalOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)) {
|
|
@@ -5305,7 +5530,7 @@ function createGenerateBundleHook(context) {
|
|
|
5305
5530
|
file,
|
|
5306
5531
|
originalSource,
|
|
5307
5532
|
outputFile,
|
|
5308
|
-
pipelineContext:
|
|
5533
|
+
pipelineContext: cssPipelineContext2,
|
|
5309
5534
|
source,
|
|
5310
5535
|
viteProcessedCssAsset
|
|
5311
5536
|
});
|
|
@@ -5381,7 +5606,7 @@ function createGenerateBundleHook(context) {
|
|
|
5381
5606
|
if (!hasUsableRememberedTailwindSource) {
|
|
5382
5607
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
5383
5608
|
const isCurrentRootMiniProgramStyleOutput = opts.cssMatcher(outputFile) && isMiniProgramStyleOutputFile(outputFile) && !require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")).includes("/");
|
|
5384
|
-
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((
|
|
5609
|
+
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((entry2) => hasTailwindPluginDirective(entry2.source)) : configuredTailwindV4CssSourceEntries;
|
|
5385
5610
|
if (isCurrentRootMiniProgramStyleOutput && (hasTailwindGenerationSource(rawSource) || configuredEntriesForCurrentRootMiniProgramStyle.length > 0)) {
|
|
5386
5611
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, configuredEntriesForCurrentRootMiniProgramStyle, rawSource, {
|
|
5387
5612
|
cwd: opts.tailwindcssBasedir,
|
|
@@ -5407,14 +5632,14 @@ function createGenerateBundleHook(context) {
|
|
|
5407
5632
|
}
|
|
5408
5633
|
}
|
|
5409
5634
|
if (!hasUsableRememberedTailwindSource) {
|
|
5410
|
-
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5635
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug);
|
|
5411
5636
|
const inferredWebviewRootSourceEntry = inferredSourceStyle ? void 0 : selectConfiguredRootCssSourceEntry(outputFile, configuredTailwindV4CssSourceEntries, originalSource.originalFileNames);
|
|
5412
5637
|
const inferredWebviewRootSourceStyle = inferredWebviewRootSourceEntry ? {
|
|
5413
5638
|
outputFile,
|
|
5414
5639
|
rawSource: inferredWebviewRootSourceEntry.source,
|
|
5415
5640
|
sourceFile: inferredWebviewRootSourceEntry.file
|
|
5416
5641
|
} : void 0;
|
|
5417
|
-
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5642
|
+
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug)) ?? inferredWebviewRootSourceStyle;
|
|
5418
5643
|
if (inferredOriginalSourceStyle) {
|
|
5419
5644
|
const matchedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(inferredOriginalSourceStyle.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
5420
5645
|
debug("source style output resolved: %s -> %s from %s", outputFile, matchedOutputFile, inferredOriginalSourceStyle.sourceFile);
|
|
@@ -5445,7 +5670,7 @@ function createGenerateBundleHook(context) {
|
|
|
5445
5670
|
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
5446
5671
|
}
|
|
5447
5672
|
} else if (!isCurrentRootMiniProgramStyleOutput && hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
5448
|
-
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((
|
|
5673
|
+
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry2) => !usedConfiguredTailwindV4CssSourceFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(entry2.file)));
|
|
5449
5674
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
5450
5675
|
cwd: opts.tailwindcssBasedir,
|
|
5451
5676
|
outputRoot: outDir,
|
|
@@ -5468,6 +5693,11 @@ function createGenerateBundleHook(context) {
|
|
|
5468
5693
|
}
|
|
5469
5694
|
}
|
|
5470
5695
|
if (currentRawSourceHasExplicitScanContext) rememberedCssSources = rememberedCssSources.filter((remembered) => remembered.rawSource.includes("@source") || remembered.rawSource.includes("@config"));
|
|
5696
|
+
rememberedCssSources = rememberedCssSources.filter((remembered) => {
|
|
5697
|
+
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
5698
|
+
if (shouldSkip) debug("css skip raw remembered source style: %s -> %s", remembered.sourceFile, outputFile);
|
|
5699
|
+
return !shouldSkip;
|
|
5700
|
+
});
|
|
5471
5701
|
let rememberedCssSource = mergeRememberedCssSources(rememberedCssSources, outputFile);
|
|
5472
5702
|
if (rememberedCssSource && viteProcessedCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(rememberedCssSource.sourceFile))) {
|
|
5473
5703
|
const matchedOutputFile = resolveMatchedOutputFileForCurrentAsset(rememberedCssSource.sourceFile);
|
|
@@ -5482,11 +5712,11 @@ function createGenerateBundleHook(context) {
|
|
|
5482
5712
|
}
|
|
5483
5713
|
}
|
|
5484
5714
|
if (!isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && isRootMiniProgramStyleOutputFile$1(outputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(rootImportShellOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5485
|
-
...
|
|
5715
|
+
...cssPipelineContext2,
|
|
5486
5716
|
css: rawSource,
|
|
5487
5717
|
file: rootImportShellOutputFile
|
|
5488
5718
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5489
|
-
...
|
|
5719
|
+
...cssPipelineContext2,
|
|
5490
5720
|
file: rootImportShellOutputFile
|
|
5491
5721
|
}))) {
|
|
5492
5722
|
frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, outputFile);
|
|
@@ -5520,7 +5750,7 @@ function createGenerateBundleHook(context) {
|
|
|
5520
5750
|
usedConfiguredTailwindV4CssSourceFiles.add(require_source_candidate_scan_signature.normalizeOutputPathKey(generatorSourceFile));
|
|
5521
5751
|
temporaryCssAssetSourceResolver.markUsed(generatorSourceFile);
|
|
5522
5752
|
}
|
|
5523
|
-
const
|
|
5753
|
+
const cssHandlerOptions2 = vitePipelineCssAsset ? {
|
|
5524
5754
|
...getCssHandlerOptions(generatorSourceFile),
|
|
5525
5755
|
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
5526
5756
|
} : getCssHandlerOptions(file);
|
|
@@ -5529,9 +5759,9 @@ function createGenerateBundleHook(context) {
|
|
|
5529
5759
|
const shouldUsePipelineSourceAsCssEntry = !isExplicitGeneratorCssEntry && vitePipelineCssAsset && opts.cssMatcher(generatorSourceFile) && hasTailwindGenerationSource(generatorRawSource);
|
|
5530
5760
|
const generatorCssEntries = isExplicitGeneratorCssEntry || shouldUsePipelineSourceAsCssEntry ? [generatorSourceFile] : opts.cssEntries;
|
|
5531
5761
|
const generatorCssHandlerOptions = {
|
|
5532
|
-
...
|
|
5762
|
+
...cssHandlerOptions2,
|
|
5533
5763
|
sourceOptions: {
|
|
5534
|
-
...
|
|
5764
|
+
...cssHandlerOptions2.sourceOptions ?? {},
|
|
5535
5765
|
sourceFile: generatorSourceFile,
|
|
5536
5766
|
cssEntries: generatorCssEntries
|
|
5537
5767
|
}
|
|
@@ -5555,14 +5785,14 @@ function createGenerateBundleHook(context) {
|
|
|
5555
5785
|
const cssRuntimeAffectingSignature = vitePipelineCssAsset ? require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(generatorRawSource, "css") : snapshot.runtimeAffectingSignatureByFile.get(file) ?? require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(generatorRawSource, "css");
|
|
5556
5786
|
const cssRuntimeAffectingHash = vitePipelineCssAsset ? cache.computeHash(cssRuntimeAffectingSignature) : snapshot.runtimeAffectingHashByFile.get(file) ?? cache.computeHash(cssRuntimeAffectingSignature);
|
|
5557
5787
|
const cssShareScope = createCssTransformShareScopeKey(opts, outputFile, generatorRawSource);
|
|
5558
|
-
const shouldRegenerateCollectedViteCss = viteProcessedCssAsset && useIncrementalMode && state.generatorCandidateSignature !== void 0 && generatorCandidatesChanged && (hasTailwindGenerationSource(generatorRawSource) ||
|
|
5788
|
+
const shouldRegenerateCollectedViteCss = viteProcessedCssAsset && useIncrementalMode && state.generatorCandidateSignature !== void 0 && generatorCandidatesChanged && (hasTailwindGenerationSource(generatorRawSource) || require_hmr_timing.hasBundlerGeneratedCssMarker(rawSource) || rememberedCssSource != null && hasTailwindGenerationSource(rememberedCssSource.rawSource));
|
|
5559
5789
|
const shouldRefreshViteProcessedCssByCandidates = viteProcessedCssAsset && useIncrementalMode && state.generatorCandidateSignature !== void 0 && generatorCandidatesChanged;
|
|
5560
5790
|
const vitePipelineCssInjectionOutputFile = webviewRootCssInjectionTarget ?? outputFile;
|
|
5561
5791
|
const shouldRecordVitePipelineCssByOutput = require_source_candidate_scan_signature.normalizeOutputPathKey(vitePipelineCssInjectionOutputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
5562
5792
|
const shouldInjectVitePipelineCssIntoMain = vitePipelineCssAsset && !resolvedFromConfiguredOriginalCssEntry && outputCssHandlerOptions.isMainChunk !== true && (webviewRootCssInjectionTarget != null || shouldInjectCssIntoMainFromOutput(outputFile, generatorSourceFile, outputCssHandlerOptions));
|
|
5563
|
-
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode ||
|
|
5564
|
-
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) ||
|
|
5565
|
-
const strippedViteProcessedCss =
|
|
5793
|
+
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions2.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) || shouldRegenerateCollectedViteCss || hasRuntimeAffectingChanges && (alreadyProcessedCssAsset || vitePipelineCssAsset));
|
|
5794
|
+
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) || require_hmr_timing.hasBundlerGeneratedCssMarker(rawSource));
|
|
5795
|
+
const strippedViteProcessedCss = require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
5566
5796
|
const shouldPreserveStaleGeneratedCssAsset = hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && !strippedViteProcessedCss.includes("weapp-tailwindcss generator-placeholder") && !strippedViteProcessedCss.includes("vite-placeholder") && !hasTailwindGenerationSource(strippedViteProcessedCss) && !require_generator.hasTailwindApplyDirective(strippedViteProcessedCss);
|
|
5567
5797
|
if (alreadyProcessedCssAsset && !shouldRefreshViteProcessedCssByCandidates && (!hasStaleViteProcessedCssSource || shouldPreserveStaleGeneratedCssAsset) && !hasRememberedApplySource && !shouldRegenerateMainPackageCssWithScopedCandidates && (!shouldTrackGeneratorRuntime || shouldPreserveCollectedViteCssAsset)) {
|
|
5568
5798
|
const nextCss = removeRootCoveredCssFromScopedAsset(strippedViteProcessedCss);
|
|
@@ -5593,7 +5823,7 @@ function createGenerateBundleHook(context) {
|
|
|
5593
5823
|
}) : trackedGeneratorCandidateSignature;
|
|
5594
5824
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
5595
5825
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
5596
|
-
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${
|
|
5826
|
+
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions2.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}:${sourceTraceSignature}`;
|
|
5597
5827
|
const cssCacheKey = outputFile;
|
|
5598
5828
|
const cssHashKey = `${outputFile}:css:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}`;
|
|
5599
5829
|
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(":") : "";
|
|
@@ -5644,8 +5874,8 @@ function createGenerateBundleHook(context) {
|
|
|
5644
5874
|
const previousCss = !vitePipelineCssAsset && useIncrementalMode && !generatorCandidatesChanged && !hasRuntimeAffectingChanges && !snapshot.changedByType.css.has(file) ? getLastCssResult(lastCssResultByFile, outputFile, file) : void 0;
|
|
5645
5875
|
const generatorTransformRawSource = generatorRawSource;
|
|
5646
5876
|
const previousGeneratorCss = previousCss && !isWebGeneratorTarget ? normalizeMiniProgramGeneratorRawSource(previousCss, outputFile) : previousCss;
|
|
5647
|
-
const shouldGenerateCssWithCore = hasTailwindGenerationSource(generatorTransformRawSource) ||
|
|
5648
|
-
const bundleUserRawSource = vitePipelineCssAsset && !
|
|
5877
|
+
const shouldGenerateCssWithCore = hasTailwindGenerationSource(generatorTransformRawSource) || require_hmr_timing.hasBundlerGeneratedCssMarker(rawSource);
|
|
5878
|
+
const bundleUserRawSource = vitePipelineCssAsset && !require_hmr_timing.hasBundlerGeneratedCssMarker(rawSource) && normalizeCssSourceForCompare(rawSource) !== normalizeCssSourceForCompare(generatorRawSource) ? normalizeMiniProgramGeneratorRawSource(normalizeGeneratorUserRawSource(rawSource, generatorSourceFile, assetSourceFile), outputFile) : void 0;
|
|
5649
5879
|
const generatorUserRawSource = [generatorUserLayerRawSource, bundleUserRawSource].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
5650
5880
|
const generated = shouldGenerateCssWithCore ? await require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
5651
5881
|
opts,
|
|
@@ -5658,6 +5888,7 @@ function createGenerateBundleHook(context) {
|
|
|
5658
5888
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
5659
5889
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
5660
5890
|
sourceCandidates: scopedGeneratorRuntime,
|
|
5891
|
+
frameworkPostcssStage: "complete",
|
|
5661
5892
|
generatorPlatform,
|
|
5662
5893
|
styleHandler,
|
|
5663
5894
|
debug,
|
|
@@ -5667,24 +5898,24 @@ function createGenerateBundleHook(context) {
|
|
|
5667
5898
|
}) : void 0;
|
|
5668
5899
|
if (generated) {
|
|
5669
5900
|
const outputCss = transformWebTargetCss(generated.css);
|
|
5670
|
-
const
|
|
5901
|
+
const tracedCss2 = removeRootCoveredCssFromScopedAsset(annotateCss(outputCss));
|
|
5671
5902
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
5672
|
-
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource,
|
|
5673
|
-
debug("css generated result: %s bytes=%d", file,
|
|
5903
|
+
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource, tracedCss2));
|
|
5904
|
+
debug("css generated result: %s bytes=%d", file, tracedCss2.length);
|
|
5674
5905
|
for (const candidate of generated.classSet ?? []) transformRuntime.add(candidate);
|
|
5675
|
-
recordCssAssetResult?.(outputFile,
|
|
5676
|
-
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile,
|
|
5906
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5907
|
+
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile, tracedCss2, {
|
|
5677
5908
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
5678
5909
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5679
5910
|
});
|
|
5680
|
-
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file,
|
|
5911
|
+
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file, tracedCss2, {
|
|
5681
5912
|
injectIntoMain: shouldInjectVitePipelineCssIntoMain,
|
|
5682
5913
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5683
5914
|
});
|
|
5684
5915
|
metrics.css.elapsed += measureElapsed(start);
|
|
5685
5916
|
metrics.css.transformed++;
|
|
5686
5917
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, outputFile);
|
|
5687
|
-
return
|
|
5918
|
+
return tracedCss2;
|
|
5688
5919
|
}
|
|
5689
5920
|
if (isWebGeneratorTarget) {
|
|
5690
5921
|
const outputCss = transformWebTargetCss(rawSource);
|
|
@@ -5694,15 +5925,15 @@ function createGenerateBundleHook(context) {
|
|
|
5694
5925
|
return annotateCss(outputCss);
|
|
5695
5926
|
}
|
|
5696
5927
|
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(generatorTransformRawSource)) {
|
|
5697
|
-
const
|
|
5698
|
-
recordCssAssetResult?.(outputFile,
|
|
5928
|
+
const tracedCss2 = annotateCss(generatorTransformRawSource);
|
|
5929
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5699
5930
|
metrics.css.elapsed += measureElapsed(start);
|
|
5700
5931
|
metrics.css.transformed++;
|
|
5701
5932
|
debug("css preserve mini-program import shell: %s", outputFile);
|
|
5702
|
-
return
|
|
5933
|
+
return tracedCss2;
|
|
5703
5934
|
}
|
|
5704
|
-
const { css } = await styleHandler(generatorTransformRawSource,
|
|
5705
|
-
const tracedCss = annotateCss(
|
|
5935
|
+
const { css: css2 } = await styleHandler(generatorTransformRawSource, cssHandlerOptions2);
|
|
5936
|
+
const tracedCss = annotateCss(css2);
|
|
5706
5937
|
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorTransformRawSource, tracedCss));
|
|
5707
5938
|
metrics.css.elapsed += measureElapsed(start);
|
|
5708
5939
|
metrics.css.transformed++;
|
|
@@ -5719,6 +5950,7 @@ function createGenerateBundleHook(context) {
|
|
|
5719
5950
|
continue;
|
|
5720
5951
|
}
|
|
5721
5952
|
if (type !== "js") continue;
|
|
5953
|
+
if (!processMarkupAndScripts) continue;
|
|
5722
5954
|
if (!shouldTransformJsBundle) {
|
|
5723
5955
|
debug("js skip web target: %s", file);
|
|
5724
5956
|
continue;
|
|
@@ -5752,7 +5984,9 @@ function createGenerateBundleHook(context) {
|
|
|
5752
5984
|
useIncrementalMode
|
|
5753
5985
|
});
|
|
5754
5986
|
}
|
|
5755
|
-
|
|
5987
|
+
recordTimingDetail("entries.plan", entryPlanningStartedAt);
|
|
5988
|
+
const rememberedCssStartedAt = performance.now();
|
|
5989
|
+
if (processStyles && (shouldProcessTailwindGeneration || useIncrementalMode || isNativeAppStyleTarget)) await processRememberedCssReplay({
|
|
5756
5990
|
addWatchFile,
|
|
5757
5991
|
activeViteCssCacheFiles,
|
|
5758
5992
|
bundle,
|
|
@@ -5797,6 +6031,7 @@ function createGenerateBundleHook(context) {
|
|
|
5797
6031
|
timeTask,
|
|
5798
6032
|
useIncrementalMode
|
|
5799
6033
|
});
|
|
6034
|
+
recordTimingDetail("rememberedCss.plan", rememberedCssStartedAt);
|
|
5800
6035
|
await finalizeGenerateBundle({
|
|
5801
6036
|
activeProcessCacheKeys,
|
|
5802
6037
|
activeProcessHashKeys,
|
|
@@ -5814,7 +6049,7 @@ function createGenerateBundleHook(context) {
|
|
|
5814
6049
|
generatorRuntime,
|
|
5815
6050
|
getCssHandlerOptions,
|
|
5816
6051
|
getSourceCandidateSourcesForEntries,
|
|
5817
|
-
getSourceCandidatesForEntries,
|
|
6052
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5818
6053
|
getViteCssCacheStats,
|
|
5819
6054
|
getViteProcessedCssAssetResults,
|
|
5820
6055
|
hmrTimingRecorder,
|
|
@@ -5854,10 +6089,16 @@ function createGenerateBundleHook(context) {
|
|
|
5854
6089
|
transformWebTargetCss,
|
|
5855
6090
|
useIncrementalMode
|
|
5856
6091
|
});
|
|
6092
|
+
state.bundleMarkupCandidatesByFile = bundleMarkupCandidates.candidatesByFile;
|
|
5857
6093
|
};
|
|
5858
6094
|
}
|
|
5859
6095
|
//#endregion
|
|
5860
|
-
//#region src/bundlers/vite/
|
|
6096
|
+
//#region src/bundlers/vite/generate-bundle.ts
|
|
6097
|
+
function createGenerateBundleHook(context) {
|
|
6098
|
+
return createGenerateBundleHook$1(context);
|
|
6099
|
+
}
|
|
6100
|
+
//#endregion
|
|
6101
|
+
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
5861
6102
|
function inferPlatformFromViteOutDir(outDir) {
|
|
5862
6103
|
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
5863
6104
|
if (!segment) return;
|
|
@@ -5919,6 +6160,8 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
|
5919
6160
|
shouldApplyWebCssCompat
|
|
5920
6161
|
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
5921
6162
|
}
|
|
6163
|
+
//#endregion
|
|
6164
|
+
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
5922
6165
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
5923
6166
|
return {
|
|
5924
6167
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -6033,6 +6276,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6033
6276
|
...harmonyCssHandlerOptions,
|
|
6034
6277
|
isMainChunk: false
|
|
6035
6278
|
},
|
|
6279
|
+
frameworkPostcssStage: "complete",
|
|
6036
6280
|
getSourceCandidatesForEntries,
|
|
6037
6281
|
generatorPlatform,
|
|
6038
6282
|
styleHandler: opts.styleHandler,
|
|
@@ -6073,10 +6317,15 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6073
6317
|
const file = output.fileName || bundleFile;
|
|
6074
6318
|
const rawSource = output.source.toString();
|
|
6075
6319
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
6076
|
-
const
|
|
6320
|
+
const cleanRawSource = require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
6321
|
+
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
6077
6322
|
...createCssPipelineContext(file),
|
|
6078
6323
|
file
|
|
6079
|
-
}
|
|
6324
|
+
}) ?? {});
|
|
6325
|
+
const nextCss = annotateCss(generatorBranch.isWeb ? finalizeWebCss(cleanRawSource, {
|
|
6326
|
+
...createCssPipelineContext(file),
|
|
6327
|
+
file
|
|
6328
|
+
}, cssPipelineStrategy) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
6080
6329
|
output.source = nextCss;
|
|
6081
6330
|
markCssAssetProcessed(output, file);
|
|
6082
6331
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -6091,7 +6340,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6091
6340
|
...cssHandlerOptions,
|
|
6092
6341
|
isMainChunk: false
|
|
6093
6342
|
};
|
|
6094
|
-
const cleanRawSource =
|
|
6343
|
+
const cleanRawSource = require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
6095
6344
|
if (cleanRawSource !== rawSource && cleanRawSource.trim().length === 0) {
|
|
6096
6345
|
output.source = cleanRawSource;
|
|
6097
6346
|
markCssAssetProcessed(output, file);
|
|
@@ -6123,6 +6372,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6123
6372
|
outputFile: file,
|
|
6124
6373
|
cssHandlerOptions: generatorCssHandlerOptions,
|
|
6125
6374
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
6375
|
+
frameworkPostcssStage: "complete",
|
|
6126
6376
|
getSourceCandidatesForEntries,
|
|
6127
6377
|
generatorPlatform,
|
|
6128
6378
|
styleHandler: opts.styleHandler,
|
|
@@ -6218,7 +6468,7 @@ function normalizeCssSourceIdentity(sourceFile) {
|
|
|
6218
6468
|
const { filename, query } = parseVueRequest(cleanSourceFile);
|
|
6219
6469
|
const normalizedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(filename);
|
|
6220
6470
|
if (query.type === "style") return `${normalizedFile}?type=style&index=${query.index ?? 0}`;
|
|
6221
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(
|
|
6471
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(require_hmr_timing.stripRequestQuery(cleanSourceFile));
|
|
6222
6472
|
}
|
|
6223
6473
|
function hasSfcStyleBlocks(source) {
|
|
6224
6474
|
SFC_STYLE_BLOCK_RE.lastIndex = 0;
|
|
@@ -6321,19 +6571,19 @@ function createViteCssMemory(options) {
|
|
|
6321
6571
|
for (const [rememberedKey, remembered] of relatedRememberedEntries) refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
|
|
6322
6572
|
};
|
|
6323
6573
|
const resolveCachedStyleSource = (sourceFile) => {
|
|
6324
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(
|
|
6574
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_hmr_timing.stripRequestQuery(sourceFile));
|
|
6325
6575
|
if (SFC_COMPONENT_FILE_RE.test(file)) return getKnownSfcSource(file);
|
|
6326
|
-
if (
|
|
6576
|
+
if (require_hmr_timing.isSourceStyleRequest(file)) return options.getSourceCandidateSource(file);
|
|
6327
6577
|
};
|
|
6328
6578
|
const resolveCurrentStyleSource = async (sourceFile) => {
|
|
6329
6579
|
const cached = resolveCachedStyleSource(sourceFile);
|
|
6330
6580
|
if (cached != null) return cached;
|
|
6331
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(
|
|
6581
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_hmr_timing.stripRequestQuery(sourceFile));
|
|
6332
6582
|
const knownSource = knownCssSources.get(normalizeCssSourceIdentity(sourceFile));
|
|
6333
6583
|
if (knownSource != null) return knownSource;
|
|
6334
6584
|
const candidateSource = options.getSourceCandidateSource(file);
|
|
6335
6585
|
if (candidateSource != null) return candidateSource;
|
|
6336
|
-
if (!
|
|
6586
|
+
if (!require_hmr_timing.isSourceStyleRequest(file)) return;
|
|
6337
6587
|
try {
|
|
6338
6588
|
return await (0, node_fs_promises.readFile)(file, "utf8");
|
|
6339
6589
|
} catch (error) {
|
|
@@ -6344,7 +6594,7 @@ function createViteCssMemory(options) {
|
|
|
6344
6594
|
const refreshRememberedCssSourceByCurrentFile = async (sourceFile) => {
|
|
6345
6595
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(sourceFile);
|
|
6346
6596
|
const normalizedSourceFile = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
6347
|
-
const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => require_source_candidate_scan_signature.normalizeOutputPathKey(
|
|
6597
|
+
const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => require_source_candidate_scan_signature.normalizeOutputPathKey(require_hmr_timing.stripRequestQuery((0, _weapp_tailwindcss_shared.cleanUrl)(remembered.sourceFile))) === normalizedSourceFile);
|
|
6348
6598
|
if (matchedRememberedSources.length === 0) return;
|
|
6349
6599
|
const source = await resolveCurrentStyleSource(file);
|
|
6350
6600
|
if (source == null) {
|
|
@@ -6359,10 +6609,10 @@ function createViteCssMemory(options) {
|
|
|
6359
6609
|
}
|
|
6360
6610
|
return;
|
|
6361
6611
|
}
|
|
6362
|
-
if (
|
|
6612
|
+
if (require_hmr_timing.isSourceStyleRequest(file)) refreshRememberedCssSourceBySourceFile(file, source);
|
|
6363
6613
|
};
|
|
6364
6614
|
const refreshRememberedCssSource = async (remembered) => {
|
|
6365
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(
|
|
6615
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_hmr_timing.stripRequestQuery(remembered.sourceFile));
|
|
6366
6616
|
const rememberedKey = [...rememberedCssSources.entries()].find(([, entry]) => entry === remembered)?.[0];
|
|
6367
6617
|
if (!rememberedKey || !node_path.default.isAbsolute(file)) return;
|
|
6368
6618
|
const source = await resolveCurrentStyleSource(file);
|
|
@@ -6375,7 +6625,7 @@ function createViteCssMemory(options) {
|
|
|
6375
6625
|
const styleSource = extractSfcStyleSource(source, query.type === "style" ? query.index : void 0);
|
|
6376
6626
|
return styleSource === void 0 ? void 0 : refreshRememberedCssSourceEntry(rememberedKey, remembered, remembered.sourceFile, styleSource);
|
|
6377
6627
|
}
|
|
6378
|
-
if (
|
|
6628
|
+
if (require_hmr_timing.isSourceStyleRequest(file)) return refreshRememberedCssSourceEntry(rememberedKey, remembered, remembered.sourceFile, source);
|
|
6379
6629
|
};
|
|
6380
6630
|
const prune = (pruneOptions) => {
|
|
6381
6631
|
const activeFiles = new Set([...pruneOptions.activeFiles].map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
@@ -6431,7 +6681,7 @@ function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
|
6431
6681
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
6432
6682
|
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(node_path.default.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
6433
6683
|
const isHotSourceStyleModule = (id) => {
|
|
6434
|
-
if (!
|
|
6684
|
+
if (!require_hmr_timing.isSourceStyleRequest(id)) return false;
|
|
6435
6685
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
6436
6686
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
6437
6687
|
if (outDir && isAbsoluteFilePath(file)) {
|
|
@@ -6464,7 +6714,7 @@ function resolveHotSourceModules(ctx) {
|
|
|
6464
6714
|
const seenModules = /* @__PURE__ */ new Set();
|
|
6465
6715
|
const collectModule = (mod) => {
|
|
6466
6716
|
if (mod == null || seenModules.has(mod)) return;
|
|
6467
|
-
if (
|
|
6717
|
+
if (require_hmr_timing.isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
6468
6718
|
seenModules.add(mod);
|
|
6469
6719
|
modules.push(mod);
|
|
6470
6720
|
};
|
|
@@ -6522,7 +6772,7 @@ function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
|
6522
6772
|
}
|
|
6523
6773
|
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
6524
6774
|
return modules.some((mod) => {
|
|
6525
|
-
return !
|
|
6775
|
+
return !require_hmr_timing.isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
6526
6776
|
});
|
|
6527
6777
|
}
|
|
6528
6778
|
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
@@ -6530,7 +6780,7 @@ function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
|
6530
6780
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
6531
6781
|
const updates = [];
|
|
6532
6782
|
for (const id of fallbackCssIds) {
|
|
6533
|
-
if (!
|
|
6783
|
+
if (!require_hmr_timing.isSourceStyleRequest(id)) continue;
|
|
6534
6784
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
6535
6785
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6536
6786
|
seenUrls.add(hotUrl);
|
|
@@ -6668,7 +6918,7 @@ function joinPosixPath(base, subpath) {
|
|
|
6668
6918
|
function isCssLikeImporter(importer) {
|
|
6669
6919
|
if (!importer) return false;
|
|
6670
6920
|
const normalized = (0, _weapp_tailwindcss_shared.cleanUrl)(importer);
|
|
6671
|
-
return
|
|
6921
|
+
return require_hmr_timing.isSourceStyleRequest(importer) || require_source_candidate_scan_signature.isCSSRequest(normalized) || normalized.endsWith("/*");
|
|
6672
6922
|
}
|
|
6673
6923
|
function stripTailwindConfigDirectives(code) {
|
|
6674
6924
|
return code.replace(/^\s*@config\s+(?:"[^"]+"|'[^']+')[^;\n]*;\s*$/gm, "");
|
|
@@ -6700,7 +6950,11 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
6700
6950
|
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
6701
6951
|
const shouldGenerateInPreTransform = !options.shouldDeferGeneration?.(id, normalizedCode) && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode));
|
|
6702
6952
|
if (options.shouldOwnTailwindGeneration && shouldGenerateInPreTransform) {
|
|
6703
|
-
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode,
|
|
6953
|
+
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, {
|
|
6954
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
6955
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
6956
|
+
frameworkPostcssStage: "pending"
|
|
6957
|
+
});
|
|
6704
6958
|
if (generatedCss !== void 0) return {
|
|
6705
6959
|
code: generatedCss,
|
|
6706
6960
|
map: null
|
|
@@ -6887,57 +7141,91 @@ function replaceViteCssHmrModuleCss(code, css) {
|
|
|
6887
7141
|
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
6888
7142
|
}
|
|
6889
7143
|
function isViteServeStyleRequest(id, command) {
|
|
6890
|
-
return command === "serve" &&
|
|
7144
|
+
return command === "serve" && require_hmr_timing.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
6891
7145
|
}
|
|
6892
7146
|
function isViteServeCssRootRequest(id, command) {
|
|
6893
|
-
return command === "serve" &&
|
|
7147
|
+
return command === "serve" && require_hmr_timing.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
7148
|
+
}
|
|
7149
|
+
function isViteBuildStyleRequest(id, command) {
|
|
7150
|
+
return command === "build" && require_hmr_timing.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
6894
7151
|
}
|
|
6895
7152
|
function isViteCssHmrModule(code, id, command) {
|
|
6896
7153
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && (/[?&](?:direct|vue)(?:&|$)/.test(id) || DEFERRED_CSS_HMR_QUERY_RE.test(id));
|
|
6897
7154
|
}
|
|
6898
|
-
function
|
|
7155
|
+
function hasViteCssGenerationDirective(code) {
|
|
6899
7156
|
return require_generator.hasTailwindRootDirectives(code) || require_generator.hasTailwindSourceDirectives(code, { importFallback: true }) || require_generator.hasTailwindApplyDirective(code);
|
|
6900
7157
|
}
|
|
6901
7158
|
function hasViteServeCssRootDirective(code) {
|
|
6902
7159
|
return require_generator.hasTailwindRootDirectives(code);
|
|
6903
7160
|
}
|
|
6904
|
-
function
|
|
6905
|
-
return [
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
7161
|
+
function createViteCssGenerationPlugins(options) {
|
|
7162
|
+
return [
|
|
7163
|
+
{
|
|
7164
|
+
name: `${require_context.vitePluginName}:generate:serve`,
|
|
7165
|
+
apply: "serve",
|
|
7166
|
+
enforce: "pre",
|
|
7167
|
+
async transform(code, id) {
|
|
7168
|
+
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
7169
|
+
if (!require_generator.hasTailwindRootDirectives(code)) return;
|
|
7170
|
+
if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
|
|
7171
|
+
await options.onTailwindRootCss?.(id, code);
|
|
7172
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7173
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7174
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7175
|
+
frameworkPostcssStage: "pending"
|
|
7176
|
+
});
|
|
7177
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7178
|
+
return {
|
|
7179
|
+
code: generatedCss,
|
|
7180
|
+
map: null
|
|
7181
|
+
};
|
|
7182
|
+
}
|
|
7183
|
+
},
|
|
7184
|
+
{
|
|
7185
|
+
name: `${require_context.vitePluginName}:generate:build`,
|
|
7186
|
+
apply: "build",
|
|
7187
|
+
enforce: "pre",
|
|
7188
|
+
async transform(code, id) {
|
|
7189
|
+
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
7190
|
+
if (!hasViteCssGenerationDirective(code)) return;
|
|
7191
|
+
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
7192
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7193
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7194
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7195
|
+
frameworkPostcssStage: "pending"
|
|
7196
|
+
});
|
|
7197
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7198
|
+
return {
|
|
7199
|
+
code: generatedCss,
|
|
7200
|
+
map: null
|
|
7201
|
+
};
|
|
7202
|
+
}
|
|
7203
|
+
},
|
|
7204
|
+
{
|
|
7205
|
+
name: `${require_context.vitePluginName}:generate:serve-hmr`,
|
|
7206
|
+
apply: "serve",
|
|
7207
|
+
enforce: "post",
|
|
7208
|
+
async transform(code, id) {
|
|
7209
|
+
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
7210
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
7211
|
+
if (!extracted) return;
|
|
7212
|
+
if (!hasViteCssGenerationDirective(extracted.css)) return;
|
|
7213
|
+
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
7214
|
+
const generatedCss = await options.generateCss(id, extracted.css, {
|
|
7215
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7216
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7217
|
+
frameworkPostcssStage: "complete"
|
|
7218
|
+
});
|
|
7219
|
+
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
7220
|
+
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
7221
|
+
if (nextCode === void 0 || nextCode === code) return;
|
|
7222
|
+
return {
|
|
7223
|
+
code: nextCode,
|
|
7224
|
+
map: null
|
|
7225
|
+
};
|
|
7226
|
+
}
|
|
6939
7227
|
}
|
|
6940
|
-
|
|
7228
|
+
];
|
|
6941
7229
|
}
|
|
6942
7230
|
//#endregion
|
|
6943
7231
|
//#region src/bundlers/vite/serve-js-transform.ts
|
|
@@ -7002,7 +7290,41 @@ function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
|
7002
7290
|
return resolvedRoot;
|
|
7003
7291
|
}
|
|
7004
7292
|
//#endregion
|
|
7005
|
-
//#region src/bundlers/vite/
|
|
7293
|
+
//#region src/bundlers/vite/watch-css-post.ts
|
|
7294
|
+
const wrappedCssPostPlugins = /* @__PURE__ */ new WeakSet();
|
|
7295
|
+
function isWebOrNativeAppPlatform$1(platform) {
|
|
7296
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
7297
|
+
}
|
|
7298
|
+
function shouldAdaptFrameworkWatchCssBeforeCache(options) {
|
|
7299
|
+
return options.enabled && options.ownsTailwindGeneration && options.isWatchBuild && (options.platform ? !isWebOrNativeAppPlatform$1(options.platform) : !options.isWebGeneratorBranch);
|
|
7300
|
+
}
|
|
7301
|
+
function resolveTransformHandler(plugin) {
|
|
7302
|
+
const hook = plugin.transform;
|
|
7303
|
+
if (typeof hook === "function") return hook;
|
|
7304
|
+
if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
|
|
7305
|
+
}
|
|
7306
|
+
/**
|
|
7307
|
+
* 在框架的 CSS post hook 持久化样式前完成转换,保证 watch 重放缓存时不会重新输出原始 CSS。
|
|
7308
|
+
*/
|
|
7309
|
+
function wrapViteCssPostTransform(config, transformCss) {
|
|
7310
|
+
const plugin = config.plugins?.find((candidate) => candidate.name === "vite:css-post");
|
|
7311
|
+
if (!plugin || wrappedCssPostPlugins.has(plugin)) return false;
|
|
7312
|
+
const originalHandler = resolveTransformHandler(plugin);
|
|
7313
|
+
if (!originalHandler) return false;
|
|
7314
|
+
const wrappedHandler = async function(code, id, ...args) {
|
|
7315
|
+
const transformedCss = await transformCss(code, id);
|
|
7316
|
+
return originalHandler.call(this, transformedCss, id, ...args);
|
|
7317
|
+
};
|
|
7318
|
+
const originalHook = plugin.transform;
|
|
7319
|
+
plugin.transform = originalHook && typeof originalHook === "object" ? {
|
|
7320
|
+
...originalHook,
|
|
7321
|
+
handler: wrappedHandler
|
|
7322
|
+
} : wrappedHandler;
|
|
7323
|
+
wrappedCssPostPlugins.add(plugin);
|
|
7324
|
+
return true;
|
|
7325
|
+
}
|
|
7326
|
+
//#endregion
|
|
7327
|
+
//#region src/bundlers/vite/shared/create-framework-plugins-runtime.ts
|
|
7006
7328
|
const debug = require_wxml.createDebug();
|
|
7007
7329
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
7008
7330
|
const weappTailwindcssDirPosix = require_source_candidate_scan_signature.slash(weappTailwindcssPackageDir);
|
|
@@ -7045,10 +7367,7 @@ function isWebOrNativeAppPlatform(platform) {
|
|
|
7045
7367
|
function isInternalUserDefinedOptions(options) {
|
|
7046
7368
|
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
7047
7369
|
}
|
|
7048
|
-
|
|
7049
|
-
* Vite 各框架分支共享的组合工厂。框架分支只负责选择和拥有各自入口,公共稳定能力放在这里复用。
|
|
7050
|
-
*/
|
|
7051
|
-
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
7370
|
+
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
7052
7371
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
7053
7372
|
const rawOptions = options.__internalViteRawOptions ?? options;
|
|
7054
7373
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
@@ -7144,7 +7463,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7144
7463
|
await sourceCandidateCollector.syncCss(id, css);
|
|
7145
7464
|
cacheCurrentSourceCandidateScan();
|
|
7146
7465
|
};
|
|
7147
|
-
const registerAutoCssSource = async (id, css,
|
|
7466
|
+
const registerAutoCssSource = async (id, css, options2 = {}) => {
|
|
7148
7467
|
if (!shouldOwnTailwindGeneration) return;
|
|
7149
7468
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
7150
7469
|
if (!node_path.default.isAbsolute(file)) return;
|
|
@@ -7178,7 +7497,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7178
7497
|
})) return;
|
|
7179
7498
|
invalidateSourceCandidateScan();
|
|
7180
7499
|
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
7181
|
-
if (
|
|
7500
|
+
if (options2.refresh === false) return;
|
|
7182
7501
|
autoCssSourcesRefresh = (autoCssSourcesRefresh ?? Promise.resolve()).then(async () => {
|
|
7183
7502
|
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
7184
7503
|
await syncSourceCandidateScan({ force: true });
|
|
@@ -7284,8 +7603,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7284
7603
|
recordedGeneratorCandidates = void 0;
|
|
7285
7604
|
};
|
|
7286
7605
|
const getSourceCandidates = () => sourceCandidateCollector.values();
|
|
7287
|
-
const getSourceCandidatesForEntries = (entries,
|
|
7288
|
-
const getSourceCandidateSourcesForEntries = (entries,
|
|
7606
|
+
const getSourceCandidatesForEntries = (entries, options2) => sourceCandidateCollector.valuesForEntries(entries, options2);
|
|
7607
|
+
const getSourceCandidateSourcesForEntries = (entries, options2) => sourceCandidateCollector.sourcesForEntries(entries, options2);
|
|
7289
7608
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
7290
7609
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
7291
7610
|
const isCurrentWebLikeStylePlatform = () => {
|
|
@@ -7325,10 +7644,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7325
7644
|
}
|
|
7326
7645
|
pendingHmrCssTargetFiles = collectPendingHmrCssTargetFiles(cssModules, fallbackCssIds);
|
|
7327
7646
|
};
|
|
7328
|
-
const createViteSourceCandidateChange = (file, change,
|
|
7647
|
+
const createViteSourceCandidateChange = (file, change, options2 = {}) => ({
|
|
7329
7648
|
...change,
|
|
7330
7649
|
file,
|
|
7331
|
-
runtimeAffecting:
|
|
7650
|
+
runtimeAffecting: options2.runtimeAffecting === true || require_hmr_timing.isSourceStyleRequest(file) || hasWebHmrRuntimeAffectingDirectives(sourceCandidateCollector.source(file))
|
|
7332
7651
|
});
|
|
7333
7652
|
const clearPendingHmrCandidateChange = () => {
|
|
7334
7653
|
pendingHmrCandidateChange = void 0;
|
|
@@ -7360,7 +7679,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7360
7679
|
pendingFullHmrCssRegeneration = true;
|
|
7361
7680
|
};
|
|
7362
7681
|
const applySourceCandidateHmrState = (change) => {
|
|
7363
|
-
if (
|
|
7682
|
+
if (require_hmr_timing.isSourceStyleRequest(change.file)) {
|
|
7364
7683
|
clearPendingHmrCandidateChange();
|
|
7365
7684
|
return change;
|
|
7366
7685
|
}
|
|
@@ -7431,8 +7750,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7431
7750
|
};
|
|
7432
7751
|
const cacheCurrentSourceCandidateScan = () => {
|
|
7433
7752
|
if (sourceCandidateScanSignature) {
|
|
7434
|
-
|
|
7435
|
-
|
|
7753
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7754
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, snapshot);
|
|
7755
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, snapshot);
|
|
7436
7756
|
}
|
|
7437
7757
|
};
|
|
7438
7758
|
const shouldDiscoverAutoCssSources = () => {
|
|
@@ -7440,9 +7760,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7440
7760
|
if (!isWatchLikeBuild()) return true;
|
|
7441
7761
|
return sourceCandidateScanInvalidated;
|
|
7442
7762
|
};
|
|
7443
|
-
async function syncSourceCandidateScan(
|
|
7763
|
+
async function syncSourceCandidateScan(options2 = {}) {
|
|
7444
7764
|
if (!shouldOwnTailwindGeneration) return;
|
|
7445
|
-
if (!
|
|
7765
|
+
if (!options2.force && isWatchLikeBuild() && hasSourceCandidateScanState() && !sourceCandidateScanInvalidated) {
|
|
7446
7766
|
debug("reuse vite source candidate scan definition for watch rebuild");
|
|
7447
7767
|
return;
|
|
7448
7768
|
}
|
|
@@ -7485,8 +7805,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7485
7805
|
sourceCandidateScanSignature = nextScanSignature;
|
|
7486
7806
|
sourceCandidateScanInvalidated = false;
|
|
7487
7807
|
if (isWatchLikeBuild()) {
|
|
7488
|
-
|
|
7489
|
-
|
|
7808
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7809
|
+
sourceCandidateScanCache.set(nextScanSignature, snapshot);
|
|
7810
|
+
sourceCandidateScanSnapshotCache.set(nextScanSignature, snapshot);
|
|
7490
7811
|
}
|
|
7491
7812
|
}
|
|
7492
7813
|
const waitForSourceCandidateSyncs = async () => {
|
|
@@ -7500,7 +7821,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7500
7821
|
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
7501
7822
|
const change = sourceCandidateCollector.remove(file);
|
|
7502
7823
|
cacheCurrentSourceCandidateScan();
|
|
7503
|
-
if (
|
|
7824
|
+
if (require_hmr_timing.isSourceStyleRequest(file)) return (0, node_fs_promises.readFile)(file, "utf8").then((source) => cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
7504
7825
|
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") debug("remembered css source watch refresh failed: %s %O", file, error);
|
|
7505
7826
|
}).then(() => cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => applySourceCandidateHmrState(createViteSourceCandidateChange(file, change, { runtimeAffecting: true })));
|
|
7506
7827
|
return cssMemory.refreshRememberedCssSourceByCurrentFile(file).then(() => applySourceCandidateHmrState(createViteSourceCandidateChange(file, change, { runtimeAffecting: true })));
|
|
@@ -7528,14 +7849,14 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7528
7849
|
const recordCssAssetResult = (file, css) => {
|
|
7529
7850
|
touchMapEntry(cleanGeneratedCssByFile, normalizeVitePersistentCacheKey(file), css);
|
|
7530
7851
|
};
|
|
7531
|
-
const recordViteProcessedCssAssetResult = (file, css,
|
|
7852
|
+
const recordViteProcessedCssAssetResult = (file, css, options2 = {}) => {
|
|
7532
7853
|
const key = normalizeVitePersistentCacheKey(file);
|
|
7533
7854
|
const previous = viteProcessedCssAssetResults.get(key);
|
|
7534
|
-
const injectIntoMain = previous?.injectIntoMain === true ? true :
|
|
7855
|
+
const injectIntoMain = previous?.injectIntoMain === true ? true : options2.injectIntoMain ?? previous?.injectIntoMain;
|
|
7535
7856
|
touchMapEntry(viteProcessedCssAssetResults, key, {
|
|
7536
7857
|
css,
|
|
7537
7858
|
injectIntoMain,
|
|
7538
|
-
outputFile:
|
|
7859
|
+
outputFile: options2.outputFile ?? previous?.outputFile
|
|
7539
7860
|
});
|
|
7540
7861
|
};
|
|
7541
7862
|
const getViteProcessedCssAssetResults = () => viteProcessedCssAssetResults.entries();
|
|
@@ -7553,8 +7874,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7553
7874
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
7554
7875
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size
|
|
7555
7876
|
});
|
|
7556
|
-
const pruneViteCssCaches = (
|
|
7557
|
-
const activeFiles = new Set([...
|
|
7877
|
+
const pruneViteCssCaches = (options2) => {
|
|
7878
|
+
const activeFiles = new Set([...options2.activeFiles].map(normalizeVitePersistentCacheKey));
|
|
7558
7879
|
for (const key of cleanGeneratedCssByFile.keys()) if (!activeFiles.has(key)) cleanGeneratedCssByFile.delete(key);
|
|
7559
7880
|
for (const key of tracedGeneratedCssByFile.keys()) if (!activeFiles.has(key)) tracedGeneratedCssByFile.delete(key);
|
|
7560
7881
|
for (const key of generatedClassSetByFile.keys()) if (!activeFiles.has(key)) generatedClassSetByFile.delete(key);
|
|
@@ -7562,7 +7883,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7562
7883
|
const outputKey = typeof record.outputFile === "string" ? normalizeVitePersistentCacheKey(record.outputFile) : void 0;
|
|
7563
7884
|
if (!activeFiles.has(key) && (outputKey == null || !activeFiles.has(outputKey))) viteProcessedCssAssetResults.delete(key);
|
|
7564
7885
|
}
|
|
7565
|
-
cssMemory.prune(
|
|
7886
|
+
cssMemory.prune(options2);
|
|
7566
7887
|
};
|
|
7567
7888
|
const normalizeViteProcessedCssFile = (file) => node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
7568
7889
|
const markViteProcessedCssSource = (file) => {
|
|
@@ -7572,7 +7893,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7572
7893
|
if (!shouldOwnTailwindGeneration) return;
|
|
7573
7894
|
tailwindRootCssModuleIds.add(id);
|
|
7574
7895
|
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
7575
|
-
if (
|
|
7896
|
+
if (require_hmr_timing.isSourceStyleRequest(cleanId)) tailwindRootCssModuleIds.add(cleanId);
|
|
7576
7897
|
};
|
|
7577
7898
|
const registerTailwindRootCss = async (id, code) => {
|
|
7578
7899
|
rememberTailwindRootCssModule(id);
|
|
@@ -7586,7 +7907,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7586
7907
|
return viteProcessedCssSourceFiles.has(normalized);
|
|
7587
7908
|
};
|
|
7588
7909
|
const isViteProcessedCssAsset = (asset, file) => {
|
|
7589
|
-
if (
|
|
7910
|
+
if (require_hmr_timing.hasBundlerGeneratedCssMarker(asset.source)) return true;
|
|
7590
7911
|
return [
|
|
7591
7912
|
file,
|
|
7592
7913
|
asset.originalFileName,
|
|
@@ -7611,12 +7932,23 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7611
7932
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
7612
7933
|
moduleGraph: void 0
|
|
7613
7934
|
});
|
|
7935
|
+
const shouldAdaptFrameworkWatchCss = () => {
|
|
7936
|
+
const platform = resolveViteStylePlatform();
|
|
7937
|
+
return shouldAdaptFrameworkWatchCssBeforeCache({
|
|
7938
|
+
enabled: frameworkBranch.adaptWatchCssBeforeFrameworkCache === true,
|
|
7939
|
+
ownsTailwindGeneration: shouldOwnTailwindGeneration,
|
|
7940
|
+
isWatchBuild: isWatchBuild(),
|
|
7941
|
+
isWebGeneratorBranch: resolveCurrentGeneratorBranch().isWeb,
|
|
7942
|
+
platform
|
|
7943
|
+
});
|
|
7944
|
+
};
|
|
7614
7945
|
const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
|
|
7615
7946
|
if (!shouldOwnTailwindGeneration) return;
|
|
7616
7947
|
await runtimeState.readyPromise;
|
|
7617
7948
|
await waitForSourceCandidateSyncs();
|
|
7618
7949
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
7619
|
-
const
|
|
7950
|
+
const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
7951
|
+
const requestFile = require_source_candidate_scan_signature.isCSSRequest(id) ? inferredSfcStyleRequest === file ? id : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
7620
7952
|
if (!require_source_candidate_scan_signature.isCSSRequest(requestFile) || opts.htmlMatcher(file) || require_source_candidate_scan_signature.isHTMLRequest(file)) return;
|
|
7621
7953
|
const generatorCode = require_generator.normalizeEmptyTailwindCustomVariants(code);
|
|
7622
7954
|
const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
@@ -7667,7 +7999,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7667
7999
|
const previousTracedCss = tracedGeneratedCssByFile.get(fileKey);
|
|
7668
8000
|
if (previousTracedCss !== void 0) {
|
|
7669
8001
|
finishPendingHmrCssTargetFile(file);
|
|
7670
|
-
return `${
|
|
8002
|
+
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8003
|
+
${previousTracedCss}`;
|
|
7671
8004
|
}
|
|
7672
8005
|
}
|
|
7673
8006
|
const sourceCssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(requestFile);
|
|
@@ -7688,7 +8021,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7688
8021
|
}) ?? true);
|
|
7689
8022
|
const previousCss = pendingHmrChange && !forceFullHmrCssRegeneration ? cleanGeneratedCssByFile.get(fileKey) : void 0;
|
|
7690
8023
|
const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ? require_hmr_timing.normalizeMiniProgramGeneratorCssSource(previousCss, outputFile) : previousCss;
|
|
7691
|
-
const generated = await hmrTimingRecorder.measure(
|
|
8024
|
+
const generated = await hmrTimingRecorder.measure(`generateCss.${resolvedConfig?.command ?? "unknown"}`, () => require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
7692
8025
|
opts,
|
|
7693
8026
|
runtimeState,
|
|
7694
8027
|
runtime,
|
|
@@ -7705,7 +8038,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7705
8038
|
previousCss: previousGeneratorCss,
|
|
7706
8039
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
7707
8040
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
8041
|
+
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7708
8042
|
disableSourceScan: false,
|
|
8043
|
+
frameworkPostcssStage: hookContext?.frameworkPostcssStage,
|
|
7709
8044
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
7710
8045
|
}), {
|
|
7711
8046
|
file,
|
|
@@ -7765,7 +8100,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7765
8100
|
sourceFile: requestFile
|
|
7766
8101
|
});
|
|
7767
8102
|
debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
|
|
7768
|
-
return `${
|
|
8103
|
+
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8104
|
+
${tracedCss}`;
|
|
7769
8105
|
};
|
|
7770
8106
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
7771
8107
|
getAppType: () => opts.appType,
|
|
@@ -7780,7 +8116,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7780
8116
|
weappTailwindcssDirPosix
|
|
7781
8117
|
});
|
|
7782
8118
|
if (disabledOptions.plugin) return rewritePlugins.length ? rewritePlugins : void 0;
|
|
7783
|
-
const
|
|
8119
|
+
const generateBundleContext = {
|
|
7784
8120
|
opts,
|
|
7785
8121
|
runtimeState,
|
|
7786
8122
|
ensureRuntimeClassSet,
|
|
@@ -7797,6 +8133,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7797
8133
|
getSourceCandidates,
|
|
7798
8134
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file),
|
|
7799
8135
|
getSourceCandidateSources: () => sourceCandidateCollector.sources(),
|
|
8136
|
+
extractSourceCandidates: (file, source) => require_hmr_timing.extractCandidatesFromSource(source, node_path.default.extname((0, _weapp_tailwindcss_shared.cleanUrl)(file)).slice(1) || "html", {
|
|
8137
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
8138
|
+
customAttributesEntities,
|
|
8139
|
+
disabledDefaultTemplateHandler
|
|
8140
|
+
}),
|
|
7800
8141
|
getSourceCandidatesForEntries,
|
|
7801
8142
|
getSourceCandidateSourcesForEntries,
|
|
7802
8143
|
waitForSourceCandidateSyncs,
|
|
@@ -7814,6 +8155,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7814
8155
|
hmrTimingRecorder,
|
|
7815
8156
|
cssPipelineStrategy: frameworkCssPipelineStrategy,
|
|
7816
8157
|
frameworkRootImportShellTargetByFile
|
|
8158
|
+
};
|
|
8159
|
+
const shouldSplitGenerateBundlePhases = () => opts.appType === "weapp-vite" && getResolvedConfig()?.mode !== "production";
|
|
8160
|
+
const preGenerateBundleHook = createGenerateBundleHook({
|
|
8161
|
+
...generateBundleContext,
|
|
8162
|
+
processMarkupAndScripts: false,
|
|
8163
|
+
shouldProcessBundle: shouldSplitGenerateBundlePhases
|
|
8164
|
+
});
|
|
8165
|
+
const generateBundleHook = createGenerateBundleHook({
|
|
8166
|
+
...generateBundleContext,
|
|
8167
|
+
shouldProcessStyles: () => !shouldSplitGenerateBundlePhases()
|
|
7817
8168
|
});
|
|
7818
8169
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
7819
8170
|
opts,
|
|
@@ -7860,6 +8211,21 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7860
8211
|
styleHandler,
|
|
7861
8212
|
uniAppX
|
|
7862
8213
|
}) ?? [];
|
|
8214
|
+
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
8215
|
+
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
8216
|
+
if (wrapViteCssPostTransform(config, async (css, id) => {
|
|
8217
|
+
if (!require_source_candidate_scan_signature.isCSSRequest(id)) return css;
|
|
8218
|
+
if (require_hmr_timing.hasBundlerGeneratedCssMarker(css)) {
|
|
8219
|
+
debug("preserve adapted generated css before uni-app watch cache: %s", id);
|
|
8220
|
+
return css;
|
|
8221
|
+
}
|
|
8222
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
8223
|
+
const styleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), css, id) : id;
|
|
8224
|
+
const transformedCss = (await styleHandler(css, transformCssHandlerOptions.getCssHandlerOptions(styleRequest))).css;
|
|
8225
|
+
debug("adapt css before uni-app watch cache: %s inputRaw=%s outputRaw=%s", id, css.includes("\\[") || css.includes("\\:"), transformedCss.includes("\\[") || transformedCss.includes("\\:"));
|
|
8226
|
+
return transformedCss;
|
|
8227
|
+
})) debug("adapt uni-app watch css before vite:css-post cache");
|
|
8228
|
+
};
|
|
7863
8229
|
const plugins = [
|
|
7864
8230
|
...rewritePlugins,
|
|
7865
8231
|
{
|
|
@@ -7927,7 +8293,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7927
8293
|
async handleHotUpdate(ctx) {
|
|
7928
8294
|
return hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
7929
8295
|
const isSourceCandidateHotUpdate = shouldOwnTailwindGeneration && require_hmr_timing.isSourceCandidateRequest(ctx.file);
|
|
7930
|
-
if (isSourceCandidateHotUpdate &&
|
|
8296
|
+
if (isSourceCandidateHotUpdate && require_hmr_timing.isSourceStyleRequest(ctx.file)) for (const mod of ctx.modules) {
|
|
7931
8297
|
if (mod.id) rememberTailwindRootCssModule(mod.id);
|
|
7932
8298
|
if (mod.url) rememberTailwindRootCssModule(mod.url);
|
|
7933
8299
|
if (mod.file) rememberTailwindRootCssModule(mod.file);
|
|
@@ -7941,11 +8307,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7941
8307
|
if (isSourceCandidateHotUpdate) {
|
|
7942
8308
|
invalidateRecordedGeneratorCandidates();
|
|
7943
8309
|
const preserveDeletedCssInHmr = resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
7944
|
-
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !
|
|
8310
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !require_hmr_timing.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
7945
8311
|
if (!canUseHmrCandidateAppend) {
|
|
7946
8312
|
if (sourceCandidateChange === void 0) {
|
|
7947
8313
|
clearPendingHmrCandidateChange();
|
|
7948
|
-
if (!preserveDeletedCssInHmr && !
|
|
8314
|
+
if (!preserveDeletedCssInHmr && !require_hmr_timing.isSourceStyleRequest(ctx.file)) queueFullHmrCssRegeneration();
|
|
7949
8315
|
}
|
|
7950
8316
|
if (isWebLikeHotUpdate) {
|
|
7951
8317
|
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
@@ -7955,22 +8321,22 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7955
8321
|
}
|
|
7956
8322
|
if (isSourceCandidateHotUpdate) await waitForSourceCandidateSyncs();
|
|
7957
8323
|
const cssModules = resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds);
|
|
7958
|
-
const sourceModules = isSourceCandidateHotUpdate && !
|
|
8324
|
+
const sourceModules = isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file) ? resolveHotSourceModules(ctx) : ctx.modules;
|
|
7959
8325
|
const hasHmrCandidateAppend = pendingHmrCandidateChange !== void 0 && !pendingHmrCandidateChange.runtimeAffecting && pendingHmrCandidateChange.addedCandidates.size > 0 || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
7960
|
-
if (isSourceCandidateHotUpdate && !
|
|
8326
|
+
if (isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && isUniViteProject())) {
|
|
7961
8327
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7962
8328
|
return [];
|
|
7963
8329
|
}
|
|
7964
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
8330
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file) && ctx.modules.some((mod) => isNuxtPageMacroHotModule(mod.id ?? mod.url))) {
|
|
7965
8331
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7966
8332
|
return [];
|
|
7967
8333
|
}
|
|
7968
|
-
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
8334
|
+
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file) && resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
7969
8335
|
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...tailwindRootCssModuleIds, ...viteProcessedCssSourceFiles]);
|
|
7970
8336
|
if (hasHmrCandidateAppend) armPendingHmrCssTargetFiles(cssModules, supplementalCssFallbackIds);
|
|
7971
8337
|
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
7972
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
7973
|
-
if (isSourceCandidateHotUpdate && !
|
|
8338
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file)) return;
|
|
8339
|
+
if (isSourceCandidateHotUpdate && !require_hmr_timing.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return [...sourceModules, ...cssModules];
|
|
7974
8340
|
return cssModules.length > 0 ? [...ctx.modules, ...cssModules] : void 0;
|
|
7975
8341
|
}, { emit: false });
|
|
7976
8342
|
},
|
|
@@ -7978,13 +8344,15 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7978
8344
|
await hmrTimingRecorder.measure("sourceCandidates.buildStart", async () => {
|
|
7979
8345
|
await prepareTailwindGeneration();
|
|
7980
8346
|
}, { emit: false });
|
|
7981
|
-
}
|
|
8347
|
+
},
|
|
8348
|
+
generateBundle: preGenerateBundleHook
|
|
7982
8349
|
},
|
|
7983
|
-
...
|
|
8350
|
+
...createViteCssGenerationPlugins({
|
|
7984
8351
|
generateCss: generateTailwindCssForVitePipeline,
|
|
7985
8352
|
getCommand: () => resolvedConfig?.command,
|
|
7986
8353
|
onTailwindRootCss: registerTailwindRootCss,
|
|
7987
|
-
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
8354
|
+
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
8355
|
+
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
7988
8356
|
}),
|
|
7989
8357
|
createViteServeJsTransformPlugin({
|
|
7990
8358
|
createHandlerOptions: (file) => serveJsHandlerOptions(file, frameworkCssPipelineStrategy?.getServeJsHandlerOptions?.({
|
|
@@ -7996,6 +8364,13 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7996
8364
|
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
7997
8365
|
transformRuntime: ensureRuntimeClassSet
|
|
7998
8366
|
}),
|
|
8367
|
+
{
|
|
8368
|
+
name: `${require_context.vitePluginName}:watch-css-cache`,
|
|
8369
|
+
configResolved: {
|
|
8370
|
+
order: "post",
|
|
8371
|
+
handler: installFrameworkWatchCssCacheAdapter
|
|
8372
|
+
}
|
|
8373
|
+
},
|
|
7999
8374
|
{
|
|
8000
8375
|
name: `${require_context.vitePluginName}:post`,
|
|
8001
8376
|
enforce: "post",
|
|
@@ -8003,7 +8378,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8003
8378
|
if (!shouldOwnTailwindGeneration) return;
|
|
8004
8379
|
if (Array.isArray(config.plugins)) {
|
|
8005
8380
|
const removed = disableAndRemoveTailwindVitePlugins(config.plugins);
|
|
8006
|
-
if (removed > 0)
|
|
8381
|
+
if (removed > 0) {
|
|
8382
|
+
_weapp_tailwindcss_logger.logger.warn("检测到 @tailwindcss/vite,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
8383
|
+
debug("disable official tailwind vite plugins in generator mode: %d", removed);
|
|
8384
|
+
}
|
|
8007
8385
|
}
|
|
8008
8386
|
const root = config.root ? node_path.default.resolve(config.root) : node_process.default.cwd();
|
|
8009
8387
|
const baseConfig = { resolve: { alias: [{
|
|
@@ -8011,14 +8389,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8011
8389
|
replacement: node_path.default.join(weappTailwindcssPackageDir, "generator-placeholder.css")
|
|
8012
8390
|
}] } };
|
|
8013
8391
|
if (config.css?.postcss !== void 0) return baseConfig;
|
|
8014
|
-
return (0, _weapp_tailwindcss_postcss.
|
|
8392
|
+
return (0, _weapp_tailwindcss_postcss.resolvePostcssConfig)(root).then((postcssConfig) => {
|
|
8015
8393
|
if (!postcssConfig) return baseConfig;
|
|
8016
|
-
|
|
8394
|
+
const plugins2 = [...postcssConfig.plugins];
|
|
8395
|
+
const removed = (0, _weapp_tailwindcss_postcss.removeTailwindPostcssPlugins)(plugins2);
|
|
8396
|
+
if (removed > 0) debug("inline filtered postcss config without official tailwind plugins in generator mode: %d", removed);
|
|
8017
8397
|
return {
|
|
8018
8398
|
...baseConfig,
|
|
8019
8399
|
css: { postcss: {
|
|
8020
8400
|
...postcssConfig.options,
|
|
8021
|
-
plugins:
|
|
8401
|
+
plugins: plugins2
|
|
8022
8402
|
} }
|
|
8023
8403
|
};
|
|
8024
8404
|
});
|
|
@@ -8057,9 +8437,13 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8057
8437
|
const postcssPlugins = config.css.postcss.plugins;
|
|
8058
8438
|
if (shouldOwnTailwindGeneration) {
|
|
8059
8439
|
const removed = (0, _weapp_tailwindcss_postcss.removeTailwindPostcssPlugins)(postcssPlugins);
|
|
8060
|
-
if (removed > 0)
|
|
8440
|
+
if (removed > 0) {
|
|
8441
|
+
_weapp_tailwindcss_logger.logger.warn("检测到 @tailwindcss/postcss,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
8442
|
+
debug("remove official tailwind postcss plugins in generator mode: %d", removed);
|
|
8443
|
+
}
|
|
8061
8444
|
}
|
|
8062
8445
|
}
|
|
8446
|
+
require_source_candidate_scan_signature.captureFrameworkPostcssOptions(opts, config.css?.postcss && typeof config.css.postcss === "object" ? config.css.postcss : void 0);
|
|
8063
8447
|
}, { emit: false });
|
|
8064
8448
|
},
|
|
8065
8449
|
generateBundle: {
|
|
@@ -8074,6 +8458,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8074
8458
|
return plugins;
|
|
8075
8459
|
}
|
|
8076
8460
|
//#endregion
|
|
8461
|
+
//#region src/bundlers/vite/shared/create-framework-plugins.ts
|
|
8462
|
+
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
8463
|
+
return createViteFrameworkPlugins$1(options, frameworkBranch);
|
|
8464
|
+
}
|
|
8465
|
+
//#endregion
|
|
8077
8466
|
//#region src/bundlers/vite/frameworks/generic/index.ts
|
|
8078
8467
|
function createGenericVitePlugins(options = {}) {
|
|
8079
8468
|
return createViteFrameworkPlugins(options, {
|
|
@@ -8182,6 +8571,7 @@ const uniAppCssPipelineStrategy = {
|
|
|
8182
8571
|
function createUniAppVitePlugins(options = {}) {
|
|
8183
8572
|
return createViteFrameworkPlugins(options, {
|
|
8184
8573
|
frameworkName: "uni-app",
|
|
8574
|
+
adaptWatchCssBeforeFrameworkCache: true,
|
|
8185
8575
|
cssPipelineStrategy: uniAppCssPipelineStrategy,
|
|
8186
8576
|
styleInjectorDelegate: require_source_candidate_scan_signature.viteStyleInjectorDelegates.uniApp
|
|
8187
8577
|
});
|
|
@@ -8307,6 +8697,7 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8307
8697
|
function createUniAppXVitePlugins(options = {}) {
|
|
8308
8698
|
return createViteFrameworkPlugins(options, {
|
|
8309
8699
|
frameworkName: "uni-app-x",
|
|
8700
|
+
adaptWatchCssBeforeFrameworkCache: true,
|
|
8310
8701
|
cssPipelineStrategy: uniAppXCssPipelineStrategy,
|
|
8311
8702
|
getExtraPluginPlatform: () => ({ isIosPlatform: require_generator.resolveUniUtsPlatform().isAppIos }),
|
|
8312
8703
|
styleInjectorDelegate: require_source_candidate_scan_signature.viteStyleInjectorDelegates.uniApp,
|