weapp-tailwindcss 5.2.12 → 5.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/hmr-timing.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/scan-root.d.ts +2 -0
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +2 -0
- package/dist/bundlers/vite/css-finalizer/generic-web-fast-path.d.ts +16 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -2
- package/dist/bundlers/vite/shared/generic-web-production-fast-path.d.ts +28 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -0
- package/dist/{context-DW4ukjx4.js → context-CKQKq4Mv.js} +2 -2
- package/dist/{context-zWINV_E2.cjs → context-vWlNv-Cf.cjs} +5 -5
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-C2UFjlZ1.js → generator-BP4WmgIo.js} +1 -5
- package/dist/{generator-CwMI20jy.cjs → generator-BXrWA7Sj.cjs} +6 -10
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-CltYkglj.js → gulp-DG6cWPF4.js} +4 -4
- package/dist/{gulp-CWFxs2lE.cjs → gulp-DzIR7eO3.cjs} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-BjOxhci8.cjs → hmr-timing-BIPr9t9m.cjs} +3 -3
- package/dist/{hmr-timing-D6JKLBCD.js → hmr-timing-CoyM6Dg2.js} +35 -8
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-CSqLm6U2.cjs → options-DbYws6lr.cjs} +7 -16
- package/dist/{pipeline-helpers-Cj9ZzHaY.cjs → pipeline-helpers-Bp343-ik.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{runtime-registry-Y7NrD2WH.cjs → runtime-registry-BlIjpImP.cjs} +10 -0
- package/dist/{source-candidate-scan-signature-DQZ_DkgW.js → source-candidate-scan-signature-BLXoEZN5.js} +3 -3
- package/dist/{source-candidate-scan-signature-uRHl5Ne9.cjs → source-candidate-scan-signature-J9EW91KX.cjs} +3 -3
- package/dist/{style-options-D0NukP02.cjs → style-options-Cta1OP3i.cjs} +2 -2
- package/dist/{tailwindcss-vbApajUH.js → tailwindcss-C2K-vjJv.js} +8 -11
- package/dist/{tailwindcss-B3lqgbln.cjs → tailwindcss-D1M2xj5O.cjs} +2 -2
- package/dist/{v4-generation-core-2AuNMweK.cjs → v4-generation-core-CCnEsAgV.cjs} +40 -7
- package/dist/{vite-q3ilYV7x.js → vite-DNTQV3gN.js} +280 -60
- package/dist/{vite-BLB7vjKQ.cjs → vite-RJpkDte7.cjs} +283 -63
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +9 -8
- package/dist/weapp-tw-runtime-classset-loader.cjs +1 -1
- package/dist/{webpack-Jn4FJT6y.cjs → webpack-BY5y7f0X.cjs} +15 -14
- package/dist/{webpack-DExB8tzB.js → webpack-DYoIysDo.js} +11 -10
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +2 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
4
4
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-DbYws6lr.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-CCnEsAgV.cjs");
|
|
8
8
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_context = require("./context-
|
|
11
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
12
|
-
const require_style_options = require("./style-options-
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-BIPr9t9m.cjs");
|
|
10
|
+
const require_context = require("./context-vWlNv-Cf.cjs");
|
|
11
|
+
const require_tailwindcss = require("./tailwindcss-D1M2xj5O.cjs");
|
|
12
|
+
const require_style_options = require("./style-options-Cta1OP3i.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-J9EW91KX.cjs");
|
|
14
14
|
require("./logger-TlKT3xmR.cjs");
|
|
15
15
|
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
16
16
|
let node_fs = require("node:fs");
|
|
@@ -181,7 +181,13 @@ function createViteCssAssetIdentityResolver(options) {
|
|
|
181
181
|
kind: "generator-placeholder",
|
|
182
182
|
sourceFile: placeholderSourceFile
|
|
183
183
|
};
|
|
184
|
-
else
|
|
184
|
+
else {
|
|
185
|
+
const processedSourceFile = candidates.find(options.isKnownProcessedSource);
|
|
186
|
+
identity = processedSourceFile ? {
|
|
187
|
+
kind: "bundler-generated",
|
|
188
|
+
sourceFile: processedSourceFile
|
|
189
|
+
} : { kind: "user" };
|
|
190
|
+
}
|
|
185
191
|
identityByAsset.set(asset, identity);
|
|
186
192
|
return identity;
|
|
187
193
|
};
|
|
@@ -1366,7 +1372,7 @@ function createCssAssetPipelineContext(options, file, bundle) {
|
|
|
1366
1372
|
function getAssetFile$1(bundleFile, asset) {
|
|
1367
1373
|
return asset.fileName || bundleFile;
|
|
1368
1374
|
}
|
|
1369
|
-
function readAssetSource$
|
|
1375
|
+
function readAssetSource$3(asset) {
|
|
1370
1376
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1371
1377
|
}
|
|
1372
1378
|
function clearAssetSource(asset) {
|
|
@@ -1511,7 +1517,7 @@ function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
|
1511
1517
|
if (output.type !== "asset") continue;
|
|
1512
1518
|
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1513
1519
|
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
1514
|
-
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1520
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1515
1521
|
if (source.length > 0) sources.push(source);
|
|
1516
1522
|
}
|
|
1517
1523
|
return sources;
|
|
@@ -1537,7 +1543,7 @@ function collectHtmlLinkedStyleFiles(bundle) {
|
|
|
1537
1543
|
if (output.type !== "asset") continue;
|
|
1538
1544
|
const htmlFile = getAssetFile$1(bundleFile, output);
|
|
1539
1545
|
if (!isHtmlOutputFile(htmlFile)) continue;
|
|
1540
|
-
const html = readAssetSource$
|
|
1546
|
+
const html = readAssetSource$3(output);
|
|
1541
1547
|
for (const match of html.matchAll(linkHrefRE)) {
|
|
1542
1548
|
const href = match[2];
|
|
1543
1549
|
if (!href) continue;
|
|
@@ -1564,7 +1570,7 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
1564
1570
|
if (output.type !== "asset") continue;
|
|
1565
1571
|
const file = getAssetFile$1(bundleFile, output);
|
|
1566
1572
|
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
1567
|
-
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1573
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1568
1574
|
if (source.length > 0) linkedSources.add(source);
|
|
1569
1575
|
}
|
|
1570
1576
|
if (linkedSources.size === 0) return 0;
|
|
@@ -1573,7 +1579,7 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
1573
1579
|
if (output.type !== "asset") continue;
|
|
1574
1580
|
const file = getAssetFile$1(bundleFile, output);
|
|
1575
1581
|
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1576
|
-
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1582
|
+
const source = require_v4_generation_core.stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1577
1583
|
if (!linkedSources.has(source)) continue;
|
|
1578
1584
|
delete bundle[bundleFile];
|
|
1579
1585
|
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
@@ -1642,7 +1648,7 @@ function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
|
1642
1648
|
if (output.type !== "asset") continue;
|
|
1643
1649
|
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1644
1650
|
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
1645
|
-
importedSources.push(readAssetSource$
|
|
1651
|
+
importedSources.push(readAssetSource$3(output));
|
|
1646
1652
|
}
|
|
1647
1653
|
return importedSources;
|
|
1648
1654
|
}
|
|
@@ -2677,7 +2683,7 @@ function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
|
2677
2683
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2678
2684
|
if (output.type !== "asset") continue;
|
|
2679
2685
|
const file = getAssetFile$1(bundleFile, output);
|
|
2680
|
-
const rawSource = readAssetSource$
|
|
2686
|
+
const rawSource = readAssetSource$3(output);
|
|
2681
2687
|
const hasScopedCss = hasVueScopedAttr(rawSource);
|
|
2682
2688
|
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
2683
2689
|
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
|
|
@@ -2900,7 +2906,7 @@ function isViteProcessedRootStyleImportingTargets(bundle, file, targetFiles) {
|
|
|
2900
2906
|
const targetFileSet = new Set(targetFiles.map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
2901
2907
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2902
2908
|
if (output.type !== "asset" || require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) !== require_source_candidate_scan_signature.normalizeOutputPathKey(file)) continue;
|
|
2903
|
-
return [...collectImportedStyleFiles(readAssetSource$
|
|
2909
|
+
return [...collectImportedStyleFiles(readAssetSource$3(output), file)].some((importedFile) => targetFileSet.has(require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile)));
|
|
2904
2910
|
}
|
|
2905
2911
|
return false;
|
|
2906
2912
|
}
|
|
@@ -2930,7 +2936,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
2930
2936
|
if (candidateKey === targetFileKey || !isCssOutputFile(candidateKey)) continue;
|
|
2931
2937
|
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
2932
2938
|
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
2933
|
-
const candidateSource = readAssetSource$
|
|
2939
|
+
const candidateSource = readAssetSource$3(candidateOutput).trim();
|
|
2934
2940
|
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;
|
|
2935
2941
|
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
2936
2942
|
else clearAssetSource(candidateOutput);
|
|
@@ -2969,7 +2975,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2969
2975
|
if (output.type !== "asset") continue;
|
|
2970
2976
|
const file = getAssetFile$1(bundleFile, output);
|
|
2971
2977
|
if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
2972
|
-
const rawSource = readAssetSource$
|
|
2978
|
+
const rawSource = readAssetSource$3(output);
|
|
2973
2979
|
let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
2974
2980
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
2975
2981
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
@@ -2986,7 +2992,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2986
2992
|
if (singleMarkerFile && require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && !isRootStyleOutputFile(resolvedOutputFile) && existingAssetFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile))) {
|
|
2987
2993
|
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
2988
2994
|
if (targetAsset) {
|
|
2989
|
-
const targetRawSource = readAssetSource$
|
|
2995
|
+
const targetRawSource = readAssetSource$3(targetAsset);
|
|
2990
2996
|
const targetNextCss = appendCss$1(targetRawSource, (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(targetRawSource, nextCss).trim());
|
|
2991
2997
|
if (targetNextCss !== targetRawSource) {
|
|
2992
2998
|
targetAsset.source = targetNextCss;
|
|
@@ -3064,7 +3070,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
3064
3070
|
if (output.type !== "asset") continue;
|
|
3065
3071
|
let file = getAssetFile$1(bundleFile, output);
|
|
3066
3072
|
if (!options.opts.cssMatcher(file) || !shouldUseCssAssetAsMainInjectionTarget(options.opts, file, viteCssResults, options, bundle)) continue;
|
|
3067
|
-
let originalSource = readAssetSource$
|
|
3073
|
+
let originalSource = readAssetSource$3(output);
|
|
3068
3074
|
if (shouldPreserveMiniProgramImportShell(options, bundle, file, originalSource)) {
|
|
3069
3075
|
const importedTargetFile = resolvePreservedImportShellInjectionTarget(options, bundle, file, originalSource);
|
|
3070
3076
|
if (typeof importedTargetFile === "string") {
|
|
@@ -3073,7 +3079,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
3073
3079
|
if (importedOutput?.type === "asset") {
|
|
3074
3080
|
output = importedOutput;
|
|
3075
3081
|
file = importedTargetFile;
|
|
3076
|
-
originalSource = readAssetSource$
|
|
3082
|
+
originalSource = readAssetSource$3(output);
|
|
3077
3083
|
} else continue;
|
|
3078
3084
|
} else {
|
|
3079
3085
|
options.debug?.("preserve mini-program css import shell asset: %s", file);
|
|
@@ -4900,7 +4906,7 @@ function resolveGenerateBundleEnvFlags() {
|
|
|
4900
4906
|
}
|
|
4901
4907
|
//#endregion
|
|
4902
4908
|
//#region src/bundlers/vite/generate-bundle/final-css-assets.ts
|
|
4903
|
-
function readAssetSource$
|
|
4909
|
+
function readAssetSource$2(output) {
|
|
4904
4910
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
4905
4911
|
}
|
|
4906
4912
|
function shouldFinalizeMiniProgramCssAsset(source) {
|
|
@@ -4915,7 +4921,7 @@ function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
|
4915
4921
|
if (output.type !== "asset") continue;
|
|
4916
4922
|
const file = output.fileName || bundleFile;
|
|
4917
4923
|
if (!options.cssMatcher(file) || options.files && !options.files.has(file)) continue;
|
|
4918
|
-
const rawSource = readAssetSource$
|
|
4924
|
+
const rawSource = readAssetSource$2(output);
|
|
4919
4925
|
const outputCss = require_v4_generation_core.finalizeMiniProgramCssStructure(rawSource);
|
|
4920
4926
|
if (outputCss === rawSource) continue;
|
|
4921
4927
|
plan.write(file, outputCss);
|
|
@@ -4940,7 +4946,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
4940
4946
|
if (output.type !== "asset") continue;
|
|
4941
4947
|
const file = output.fileName || bundleFile;
|
|
4942
4948
|
if (!options.cssMatcher(file)) continue;
|
|
4943
|
-
const rawSource = readAssetSource$
|
|
4949
|
+
const rawSource = readAssetSource$2(output);
|
|
4944
4950
|
if (rawSource.trim().length === 0) continue;
|
|
4945
4951
|
if (options.lastCssResultByFile?.has(file)) {
|
|
4946
4952
|
const structurallyCleanSource = require_v4_generation_core.finalizeMiniProgramCssStructure(rawSource);
|
|
@@ -5182,7 +5188,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5182
5188
|
}
|
|
5183
5189
|
//#endregion
|
|
5184
5190
|
//#region src/bundlers/vite/generate-bundle/finalize/root-import-shell.ts
|
|
5185
|
-
function readAssetSource(asset) {
|
|
5191
|
+
function readAssetSource$1(asset) {
|
|
5186
5192
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
5187
5193
|
}
|
|
5188
5194
|
function getAssetFile(bundleFile, asset) {
|
|
@@ -5198,7 +5204,7 @@ function finalizeWebviewCssCompat(bundle, options) {
|
|
|
5198
5204
|
if (output.type !== "asset") continue;
|
|
5199
5205
|
const file = getAssetFile(bundleFile, output);
|
|
5200
5206
|
if (!options.opts.cssMatcher(file) || !/\.css(?:$|[?#])/i.test(file)) continue;
|
|
5201
|
-
const rawSource = readAssetSource(output);
|
|
5207
|
+
const rawSource = readAssetSource$1(output);
|
|
5202
5208
|
const nextCss = (0, _weapp_tailwindcss_postcss.transformWebCssSafeSelectors)((0, _weapp_tailwindcss_postcss.transformWebCssCompat)(rawSource, generatorOptions.webCompat ?? true), { escapeMap: options.opts.escapeMap });
|
|
5203
5209
|
if (nextCss === rawSource) continue;
|
|
5204
5210
|
plan.write(file, nextCss);
|
|
@@ -5248,7 +5254,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5248
5254
|
if (!originFile || !options.cssMatcher(originFile)) continue;
|
|
5249
5255
|
const originOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile(bundleFile, output)) === require_source_candidate_scan_signature.normalizeOutputPathKey(originFile))?.[1];
|
|
5250
5256
|
if (originOutput?.type !== "asset") continue;
|
|
5251
|
-
const rootSource = readAssetSource(rootOutput);
|
|
5257
|
+
const rootSource = readAssetSource$1(rootOutput);
|
|
5252
5258
|
const importedRootFile = resolveSingleCssImportOutputFile(rootFile, rootSource);
|
|
5253
5259
|
if (importedRootFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedRootFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(originFile)) {
|
|
5254
5260
|
const nextRootSource = createCssImportShell(rootFile, originFile);
|
|
@@ -5262,7 +5268,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5262
5268
|
continue;
|
|
5263
5269
|
}
|
|
5264
5270
|
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(rootSource)) continue;
|
|
5265
|
-
const originSource = readAssetSource(originOutput);
|
|
5271
|
+
const originSource = readAssetSource$1(originOutput);
|
|
5266
5272
|
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(originSource)) {
|
|
5267
5273
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
5268
5274
|
if (importedFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootFile)) continue;
|
|
@@ -7343,7 +7349,10 @@ function createGenerateBundleHook$1(context) {
|
|
|
7343
7349
|
})
|
|
7344
7350
|
});
|
|
7345
7351
|
return async function generateBundle(_opt, bundle) {
|
|
7346
|
-
if (context.shouldProcessBundle?.() === false)
|
|
7352
|
+
if (context.shouldProcessBundle?.() === false) {
|
|
7353
|
+
await context.onSkipProcessBundle?.();
|
|
7354
|
+
return;
|
|
7355
|
+
}
|
|
7347
7356
|
const processMarkupAndScripts = context.processMarkupAndScripts !== false;
|
|
7348
7357
|
const processStyles = context.shouldProcessStyles?.() ?? context.processStyles !== false;
|
|
7349
7358
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
@@ -8013,6 +8022,41 @@ function createGenerateBundleHook(context) {
|
|
|
8013
8022
|
};
|
|
8014
8023
|
}
|
|
8015
8024
|
//#endregion
|
|
8025
|
+
//#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
|
|
8026
|
+
/**
|
|
8027
|
+
* Generic Web 生产构建的 CSS 已在 Vite transform 阶段生成时,不需要再建立面向小程序的完整产物快照。
|
|
8028
|
+
*/
|
|
8029
|
+
function shouldUseGenericWebProductionFastPath(options) {
|
|
8030
|
+
return options.frameworkName === "generic" && options.command === "build" && options.watch == null && options.isWebGeneratorTarget && options.hasProcessedCss;
|
|
8031
|
+
}
|
|
8032
|
+
/**
|
|
8033
|
+
* Finalizer fast path 只处理无小程序结构语义的 Generic Web 生产产物。
|
|
8034
|
+
*/
|
|
8035
|
+
function shouldUseGenericWebFinalizerFastPath(options) {
|
|
8036
|
+
return shouldUseGenericWebProductionFastPath(options) && !options.hasFrameworkRootImportShells && !options.isHarmonyAppStyleTarget && !options.isNativeAppStyleTarget;
|
|
8037
|
+
}
|
|
8038
|
+
/**
|
|
8039
|
+
* 将 Generic Web fast path 的判定和跳过生命周期集中起来,供 generateBundle hook 直接消费。
|
|
8040
|
+
*/
|
|
8041
|
+
function createGenericWebProductionBundleHooks(options) {
|
|
8042
|
+
return {
|
|
8043
|
+
onSkipProcessBundle: () => {
|
|
8044
|
+
options.onStart();
|
|
8045
|
+
options.onEnd();
|
|
8046
|
+
},
|
|
8047
|
+
shouldProcessBundle: () => {
|
|
8048
|
+
const config = options.getResolvedConfig();
|
|
8049
|
+
return !shouldUseGenericWebProductionFastPath({
|
|
8050
|
+
command: config?.command,
|
|
8051
|
+
frameworkName: options.frameworkName,
|
|
8052
|
+
hasProcessedCss: options.getHasProcessedCss(),
|
|
8053
|
+
isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
|
|
8054
|
+
watch: config?.build?.watch
|
|
8055
|
+
});
|
|
8056
|
+
}
|
|
8057
|
+
};
|
|
8058
|
+
}
|
|
8059
|
+
//#endregion
|
|
8016
8060
|
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
8017
8061
|
function inferPlatformFromViteOutDir(outDir) {
|
|
8018
8062
|
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
@@ -8076,6 +8120,95 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
|
8076
8120
|
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
8077
8121
|
}
|
|
8078
8122
|
//#endregion
|
|
8123
|
+
//#region src/bundlers/vite/css-finalizer/generic-web-fast-path.ts
|
|
8124
|
+
function readAssetSource(asset) {
|
|
8125
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
8126
|
+
}
|
|
8127
|
+
function collectCssAssets(bundle, context) {
|
|
8128
|
+
const assets = /* @__PURE__ */ new Map();
|
|
8129
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
8130
|
+
if (output.type !== "asset") continue;
|
|
8131
|
+
const file = output.fileName || bundleFile;
|
|
8132
|
+
if (!context.opts.cssMatcher(file) || context.opts.htmlMatcher(file)) continue;
|
|
8133
|
+
assets.set(require_source_candidate_scan_signature.normalizeOutputPathKey(file), {
|
|
8134
|
+
asset: output,
|
|
8135
|
+
file,
|
|
8136
|
+
original: readAssetSource(output)
|
|
8137
|
+
});
|
|
8138
|
+
}
|
|
8139
|
+
return assets;
|
|
8140
|
+
}
|
|
8141
|
+
function resolveProcessedCssOutputFile(file, options, bundleFiles) {
|
|
8142
|
+
return resolveViteCssPipelineOutputFile(file, options.context.opts, options.rootDir, true, false, options.sourceRoot, ".css", bundleFiles);
|
|
8143
|
+
}
|
|
8144
|
+
function resolveProcessedCssAssets(cssAssets, records, options, bundleFiles) {
|
|
8145
|
+
const assetBySourceFile = /* @__PURE__ */ new Map();
|
|
8146
|
+
for (const output of cssAssets.values()) {
|
|
8147
|
+
const identity = options.context.resolveCssAssetIdentity?.(output.asset, output.file);
|
|
8148
|
+
if (identity?.kind === "bundler-generated" && identity.sourceFile) assetBySourceFile.set(require_source_candidate_scan_signature.normalizeOutputPathKey(identity.sourceFile), output);
|
|
8149
|
+
for (const sourceFile of collectMatchingGeneratedCssMarkerFiles(output.file, output.original, (file) => resolveProcessedCssOutputFile(file, options, bundleFiles))) assetBySourceFile.set(require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile), output);
|
|
8150
|
+
}
|
|
8151
|
+
const processedAssets = /* @__PURE__ */ new Map();
|
|
8152
|
+
const htmlOwnedAssets = [...cssAssets.values()].filter((output) => [output.asset.originalFileName, ...output.asset.originalFileNames ?? []].some((file) => typeof file === "string" && /\.html(?:$|[?#])/i.test(file)));
|
|
8153
|
+
for (const [file, record] of records) {
|
|
8154
|
+
const recordCss = typeof record === "string" ? record : record.css;
|
|
8155
|
+
const outputFile = typeof record === "string" ? resolveProcessedCssOutputFile(file, options, bundleFiles) : record.outputFile ?? resolveProcessedCssOutputFile(file, options, bundleFiles);
|
|
8156
|
+
let output = assetBySourceFile.get(require_source_candidate_scan_signature.normalizeOutputPathKey(file)) ?? (outputFile ? cssAssets.get(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)) : void 0);
|
|
8157
|
+
if (!output) {
|
|
8158
|
+
const matchingAssets = [...cssAssets.values()].filter((candidate) => options.context.isCssAssetProcessed(candidate.asset, candidate.file) && resolveViteProcessedCssAssetSource(candidate.file, candidate.original, (sourceFile) => resolveProcessedCssOutputFile(sourceFile, options, bundleFiles)) === recordCss);
|
|
8159
|
+
if (matchingAssets.length === 1) output = matchingAssets[0];
|
|
8160
|
+
}
|
|
8161
|
+
if (!output && records.length === 1 && htmlOwnedAssets.length === 1) output = htmlOwnedAssets[0];
|
|
8162
|
+
if (!output) return;
|
|
8163
|
+
const existingCss = processedAssets.get(output);
|
|
8164
|
+
if (existingCss !== void 0 && existingCss !== recordCss) return;
|
|
8165
|
+
processedAssets.set(output, recordCss);
|
|
8166
|
+
}
|
|
8167
|
+
return processedAssets;
|
|
8168
|
+
}
|
|
8169
|
+
/**
|
|
8170
|
+
* Generic Web 的 transform 结果能唯一映射到最终 CSS asset 时,只做一次 marker 清理和 Web 兼容收尾。
|
|
8171
|
+
*/
|
|
8172
|
+
function tryFinalizeGenericWebCss(options) {
|
|
8173
|
+
const { bundle, context } = options;
|
|
8174
|
+
const resolvedConfig = context.getResolvedConfig();
|
|
8175
|
+
const collectStartedAt = performance.now();
|
|
8176
|
+
const processedCssResults = [...context.getViteProcessedCssAssetResults?.() ?? []];
|
|
8177
|
+
if (!shouldUseGenericWebFinalizerFastPath({
|
|
8178
|
+
command: resolvedConfig?.command,
|
|
8179
|
+
frameworkName: context.frameworkName ?? "",
|
|
8180
|
+
hasFrameworkRootImportShells: (context.frameworkRootImportShellTargetByFile?.size ?? 0) > 0,
|
|
8181
|
+
hasProcessedCss: processedCssResults.length > 0,
|
|
8182
|
+
isHarmonyAppStyleTarget: options.isHarmonyAppStyleTarget,
|
|
8183
|
+
isNativeAppStyleTarget: options.isNativeAppStyleTarget,
|
|
8184
|
+
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
8185
|
+
watch: resolvedConfig?.build?.watch
|
|
8186
|
+
})) return false;
|
|
8187
|
+
const enumerateStartedAt = performance.now();
|
|
8188
|
+
const cssAssets = collectCssAssets(bundle, context);
|
|
8189
|
+
const bundleFiles = [...cssAssets.values()].map((item) => item.file);
|
|
8190
|
+
options.recordTiming("assets.enumerate", enumerateStartedAt);
|
|
8191
|
+
const processedAssets = resolveProcessedCssAssets(cssAssets, processedCssResults, options, bundleFiles);
|
|
8192
|
+
options.recordTiming("processedCss.collect", collectStartedAt);
|
|
8193
|
+
if (!processedAssets) return false;
|
|
8194
|
+
const writeStartedAt = performance.now();
|
|
8195
|
+
for (const [{ asset, file, original }, processedCss] of processedAssets) {
|
|
8196
|
+
const finalizeStartedAt = performance.now();
|
|
8197
|
+
const generated = finalizeWebCss(require_v4_generation_core.stripBundlerGeneratedCssMarkers(processedCss), {
|
|
8198
|
+
...options.createCssPipelineContext(file),
|
|
8199
|
+
file
|
|
8200
|
+
}, context.cssPipelineStrategy);
|
|
8201
|
+
options.recordTiming("finalizeWebCss", finalizeStartedAt);
|
|
8202
|
+
asset.source = generated;
|
|
8203
|
+
context.markCssAssetProcessed(asset, file);
|
|
8204
|
+
context.recordCssAssetResult?.(file, generated);
|
|
8205
|
+
if (generated !== original) context.opts.onUpdate(file, original, generated);
|
|
8206
|
+
}
|
|
8207
|
+
options.recordTiming("processedCss.inject", performance.now());
|
|
8208
|
+
options.recordTiming("assets.markerCleanupWrite", writeStartedAt);
|
|
8209
|
+
return true;
|
|
8210
|
+
}
|
|
8211
|
+
//#endregion
|
|
8079
8212
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
8080
8213
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
8081
8214
|
return {
|
|
@@ -8118,12 +8251,45 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8118
8251
|
resolvedConfig,
|
|
8119
8252
|
resolveStylePlatform: () => generatorPlatform
|
|
8120
8253
|
});
|
|
8254
|
+
const timingDetails = {};
|
|
8255
|
+
const recordTiming = (phase, startedAt) => {
|
|
8256
|
+
timingDetails[phase] = (timingDetails[phase] ?? 0) + Math.max(0, performance.now() - startedAt);
|
|
8257
|
+
};
|
|
8258
|
+
const finishTiming = () => {
|
|
8259
|
+
context.hmrTimingRecorder?.record("cssFinalizer", performance.now() - finalizerStartedAt, { timingDetails });
|
|
8260
|
+
context.hmrTimingRecorder?.emitTotal();
|
|
8261
|
+
};
|
|
8262
|
+
const finalizeWebCssAsset = (css, file) => {
|
|
8263
|
+
const startedAt = performance.now();
|
|
8264
|
+
const finalized = finalizeWebCss(css, {
|
|
8265
|
+
...createCssPipelineContext(file),
|
|
8266
|
+
file
|
|
8267
|
+
}, cssPipelineStrategy);
|
|
8268
|
+
recordTiming("finalizeWebCss", startedAt);
|
|
8269
|
+
return finalized;
|
|
8270
|
+
};
|
|
8121
8271
|
const isHarmonyAppStyleTarget = cssPipelineStrategy?.isHarmonyAppStyleTarget?.(createCssPipelineContext("")) === true;
|
|
8122
8272
|
const isNativeAppStyleTarget = cssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext("")) === true;
|
|
8123
8273
|
if (resolvedConfig?.command !== "build" && !isNativeAppStyleTarget) return;
|
|
8124
8274
|
const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
8125
8275
|
const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
8126
8276
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType) ?? resolveSourceRootFromBundleGraph(resolvedConfig, bundle);
|
|
8277
|
+
const finalizerStartedAt = performance.now();
|
|
8278
|
+
if (tryFinalizeGenericWebCss({
|
|
8279
|
+
bundle,
|
|
8280
|
+
context,
|
|
8281
|
+
createCssPipelineContext,
|
|
8282
|
+
isHarmonyAppStyleTarget,
|
|
8283
|
+
isNativeAppStyleTarget,
|
|
8284
|
+
isWebGeneratorTarget,
|
|
8285
|
+
recordTiming,
|
|
8286
|
+
rootDir,
|
|
8287
|
+
sourceRoot
|
|
8288
|
+
})) {
|
|
8289
|
+
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
8290
|
+
finishTiming();
|
|
8291
|
+
return;
|
|
8292
|
+
}
|
|
8127
8293
|
const finalCssAssetFiles = /* @__PURE__ */ new Set();
|
|
8128
8294
|
const trackFinalCssAssetUpdate = (file, original, generated) => {
|
|
8129
8295
|
finalCssAssetFiles.add(file);
|
|
@@ -8148,6 +8314,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8148
8314
|
tokenSources: sourceTraceTokenSources
|
|
8149
8315
|
});
|
|
8150
8316
|
const collectViteProcessedCssAssets = () => {
|
|
8317
|
+
const startedAt = performance.now();
|
|
8151
8318
|
collectViteProcessedCssAssetResults(bundle, {
|
|
8152
8319
|
opts,
|
|
8153
8320
|
cssPipelineStrategy,
|
|
@@ -8158,28 +8325,26 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8158
8325
|
recordViteProcessedCssAssetResult,
|
|
8159
8326
|
onAssetWrite: (file) => finalCssAssetFiles.add(file),
|
|
8160
8327
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
8161
|
-
transformCss:
|
|
8162
|
-
...createCssPipelineContext(file),
|
|
8163
|
-
file
|
|
8164
|
-
}, cssPipelineStrategy),
|
|
8328
|
+
transformCss: finalizeWebCssAsset,
|
|
8165
8329
|
debug
|
|
8166
8330
|
});
|
|
8331
|
+
recordTiming("processedCss.collect", startedAt);
|
|
8167
8332
|
};
|
|
8168
8333
|
const injectViteProcessedCssIntoMainCss = () => {
|
|
8169
|
-
|
|
8334
|
+
const startedAt = performance.now();
|
|
8335
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
8170
8336
|
opts,
|
|
8171
8337
|
cssPipelineStrategy,
|
|
8172
8338
|
createCssPipelineContext,
|
|
8173
8339
|
getViteProcessedCssAssetResults,
|
|
8174
8340
|
markCssAssetProcessed,
|
|
8175
8341
|
recordCssAssetResult,
|
|
8176
|
-
transformCss:
|
|
8177
|
-
...createCssPipelineContext(file),
|
|
8178
|
-
file
|
|
8179
|
-
}, cssPipelineStrategy),
|
|
8342
|
+
transformCss: finalizeWebCssAsset,
|
|
8180
8343
|
debug,
|
|
8181
8344
|
onUpdate: trackFinalCssAssetUpdate
|
|
8182
8345
|
});
|
|
8346
|
+
recordTiming("processedCss.inject", startedAt);
|
|
8347
|
+
return injected;
|
|
8183
8348
|
};
|
|
8184
8349
|
collectViteProcessedCssAssets();
|
|
8185
8350
|
const createHarmonyBundleStyleSources = async () => {
|
|
@@ -8222,7 +8387,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8222
8387
|
const fileName = output.fileName || bundleFile;
|
|
8223
8388
|
return output.type === "asset" && opts.cssMatcher(fileName) && !opts.htmlMatcher(fileName) && !isHTMLRequest(fileName) && !isCssAssetProcessed(output, fileName);
|
|
8224
8389
|
};
|
|
8390
|
+
const enumerateStartedAt = performance.now();
|
|
8225
8391
|
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
8392
|
+
recordTiming("assets.enumerate", enumerateStartedAt);
|
|
8226
8393
|
if (entries.length === 0) {
|
|
8227
8394
|
await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
|
|
8228
8395
|
collectViteProcessedCssAssets();
|
|
@@ -8243,6 +8410,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8243
8410
|
recordCssAssetResult
|
|
8244
8411
|
});
|
|
8245
8412
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
8413
|
+
finishTiming();
|
|
8246
8414
|
return;
|
|
8247
8415
|
}
|
|
8248
8416
|
await runtimeState.readyPromise;
|
|
@@ -8266,10 +8434,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8266
8434
|
...createCssPipelineContext(file),
|
|
8267
8435
|
file
|
|
8268
8436
|
}) ?? {});
|
|
8269
|
-
const nextCss = annotateCss(generatorBranch.isWeb ?
|
|
8270
|
-
...createCssPipelineContext(file),
|
|
8271
|
-
file
|
|
8272
|
-
}, cssPipelineStrategy) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
8437
|
+
const nextCss = annotateCss(generatorBranch.isWeb ? finalizeWebCssAsset(cleanRawSource, file) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
8273
8438
|
writeCssAsset(file, output, nextCss);
|
|
8274
8439
|
markCssAssetProcessed(output, file);
|
|
8275
8440
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -8333,10 +8498,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8333
8498
|
debug("css finalizer preserve mini-program import shell: %s", file);
|
|
8334
8499
|
return;
|
|
8335
8500
|
}
|
|
8336
|
-
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ?
|
|
8337
|
-
...createCssPipelineContext(file),
|
|
8338
|
-
file
|
|
8339
|
-
}, cssPipelineStrategy) : (await opts.styleHandler(generatorTransformRawSource, cssHandlerOptions)).css));
|
|
8501
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCssAsset(cleanRawSource, file) : (await opts.styleHandler(generatorTransformRawSource, cssHandlerOptions)).css));
|
|
8340
8502
|
if (generated) {
|
|
8341
8503
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
8342
8504
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -8348,6 +8510,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8348
8510
|
opts.onUpdate(file, rawSource, nextCss);
|
|
8349
8511
|
debug("css finalizer handle: %s", file);
|
|
8350
8512
|
}));
|
|
8513
|
+
const writeStartedAt = performance.now();
|
|
8351
8514
|
applyViteAssetEmissionPlan(emissionPlan, {
|
|
8352
8515
|
bundle,
|
|
8353
8516
|
writeTargets
|
|
@@ -8371,6 +8534,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8371
8534
|
recordCssAssetResult
|
|
8372
8535
|
});
|
|
8373
8536
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
8537
|
+
recordTiming("assets.write", writeStartedAt);
|
|
8538
|
+
finishTiming();
|
|
8374
8539
|
}
|
|
8375
8540
|
}
|
|
8376
8541
|
};
|
|
@@ -9436,7 +9601,10 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9436
9601
|
if (!options.sourceScanSession.matches(file)) {
|
|
9437
9602
|
options.sourceCandidateCollector.remove(file);
|
|
9438
9603
|
options.sourceScanSession.cacheCurrent();
|
|
9439
|
-
return
|
|
9604
|
+
return shouldReturnTransformedCode ? {
|
|
9605
|
+
code: transformedCode,
|
|
9606
|
+
map: null
|
|
9607
|
+
} : void 0;
|
|
9440
9608
|
}
|
|
9441
9609
|
await options.sourceCandidateCollector.merge(id, transformedCode);
|
|
9442
9610
|
options.sourceScanSession.cacheCurrent();
|
|
@@ -9571,6 +9739,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9571
9739
|
const sourceCandidateScanCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9572
9740
|
let sourceScanEntries;
|
|
9573
9741
|
let sourceScanMatcher;
|
|
9742
|
+
let sourceScanBoundaryMatcher;
|
|
9743
|
+
let sourceScanRoots = [];
|
|
9744
|
+
let sourceScanOutDir;
|
|
9745
|
+
let sourceScanEligibleFiles = /* @__PURE__ */ new Set();
|
|
9746
|
+
let sourceScanEligibleFilesRefresh;
|
|
9747
|
+
const sourceScanIneligibleFiles = /* @__PURE__ */ new Set();
|
|
9574
9748
|
let sourceScanDependencies = /* @__PURE__ */ new Set();
|
|
9575
9749
|
let sourceScanExplicit = false;
|
|
9576
9750
|
let sourceCandidateScanSignature;
|
|
@@ -9582,6 +9756,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9582
9756
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9583
9757
|
const invalidate = () => {
|
|
9584
9758
|
sourceCandidateScanInvalidated = true;
|
|
9759
|
+
sourceScanIneligibleFiles.clear();
|
|
9585
9760
|
};
|
|
9586
9761
|
const hasState = () => sourceCandidateScanSignature !== void 0;
|
|
9587
9762
|
const collectRoots = (root, entries) => {
|
|
@@ -9612,9 +9787,32 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9612
9787
|
};
|
|
9613
9788
|
const cacheCurrent = () => {
|
|
9614
9789
|
if (!sourceCandidateScanSignature) return;
|
|
9615
|
-
const
|
|
9616
|
-
|
|
9617
|
-
|
|
9790
|
+
const entry = {
|
|
9791
|
+
eligibleFiles: [...sourceScanEligibleFiles],
|
|
9792
|
+
snapshot: options.sourceCandidateCollector.snapshot()
|
|
9793
|
+
};
|
|
9794
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, entry);
|
|
9795
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, entry);
|
|
9796
|
+
};
|
|
9797
|
+
const updateSourceScanMatchers = (eligibleFiles) => {
|
|
9798
|
+
sourceScanEligibleFiles = new Set(eligibleFiles);
|
|
9799
|
+
const matcherRoots = sourceScanRoots.map((scanRoot) => ({
|
|
9800
|
+
...scanRoot,
|
|
9801
|
+
outDir: sourceScanOutDir
|
|
9802
|
+
}));
|
|
9803
|
+
sourceScanBoundaryMatcher = require_v4_generation_core.createSourceCandidateEligibilityMatcher(matcherRoots);
|
|
9804
|
+
sourceScanMatcher = require_v4_generation_core.createSourceCandidateEligibilityMatcher(matcherRoots, sourceScanEligibleFiles);
|
|
9805
|
+
};
|
|
9806
|
+
const refreshSourceScanEligibleFiles = async () => {
|
|
9807
|
+
sourceScanEligibleFilesRefresh ?? (sourceScanEligibleFilesRefresh = Promise.all(sourceScanRoots.map((scanRoot) => options.sourceCandidateCollector.resolveScanFiles({
|
|
9808
|
+
entries: scanRoot.entries,
|
|
9809
|
+
explicit: scanRoot.explicit,
|
|
9810
|
+
root: scanRoot.root,
|
|
9811
|
+
outDir: sourceScanOutDir
|
|
9812
|
+
}))).then((files) => updateSourceScanMatchers(files.flat())).finally(() => {
|
|
9813
|
+
sourceScanEligibleFilesRefresh = void 0;
|
|
9814
|
+
}));
|
|
9815
|
+
await sourceScanEligibleFilesRefresh;
|
|
9618
9816
|
};
|
|
9619
9817
|
const shouldDiscoverAutoCssSources = (autoCssSourcesDiscovered) => {
|
|
9620
9818
|
if (!autoCssSourcesDiscovered || !options.isWatchLikeBuild()) return true;
|
|
@@ -9635,9 +9833,10 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9635
9833
|
});
|
|
9636
9834
|
sourceScanEntries = sourceScan?.entries;
|
|
9637
9835
|
sourceScanExplicit = sourceScan?.explicit ?? false;
|
|
9638
|
-
sourceScanMatcher = require_options.createSourceScanMatcher(sourceScanEntries);
|
|
9639
9836
|
sourceScanDependencies = new Set((sourceScan?.dependencies ?? []).map(normalizeDependency));
|
|
9640
9837
|
const roots = collectRoots(root, sourceScanEntries);
|
|
9838
|
+
sourceScanRoots = roots;
|
|
9839
|
+
sourceScanOutDir = outDir;
|
|
9641
9840
|
const nextScanSignature = require_source_candidate_scan_signature.createSourceCandidateScanSignature({
|
|
9642
9841
|
inlineCandidates: sourceScan?.inlineCandidates,
|
|
9643
9842
|
outDir,
|
|
@@ -9646,14 +9845,16 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9646
9845
|
});
|
|
9647
9846
|
if (hasState() && sourceCandidateScanSignature === nextScanSignature) {
|
|
9648
9847
|
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
9649
|
-
|
|
9848
|
+
cacheCurrent();
|
|
9650
9849
|
options.debug("reuse vite source candidate scan for watch rebuild");
|
|
9651
9850
|
sourceCandidateScanInvalidated = false;
|
|
9652
9851
|
return;
|
|
9653
9852
|
}
|
|
9654
9853
|
const cachedScan = options.isWatchLikeBuild() ? sourceCandidateScanCache.get(nextScanSignature) ?? sourceCandidateScanSnapshotCache.get(nextScanSignature) : void 0;
|
|
9655
9854
|
if (cachedScan) {
|
|
9656
|
-
options.sourceCandidateCollector.restore(cachedScan);
|
|
9855
|
+
options.sourceCandidateCollector.restore(cachedScan.snapshot);
|
|
9856
|
+
sourceScanIneligibleFiles.clear();
|
|
9857
|
+
updateSourceScanMatchers(cachedScan.eligibleFiles);
|
|
9657
9858
|
sourceCandidateScanSignature = nextScanSignature;
|
|
9658
9859
|
options.debug("reuse cached vite source candidate scan for watch rebuild");
|
|
9659
9860
|
sourceCandidateScanInvalidated = false;
|
|
@@ -9662,19 +9863,19 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9662
9863
|
if (options.isWatchLikeBuild()) options.sourceCandidateCollector.resetScan();
|
|
9663
9864
|
else options.sourceCandidateCollector.clearScan();
|
|
9664
9865
|
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
9866
|
+
const eligibleFiles = /* @__PURE__ */ new Set();
|
|
9867
|
+
sourceScanIneligibleFiles.clear();
|
|
9665
9868
|
await Promise.all(roots.map((scanRoot) => options.sourceCandidateCollector.scanRoot({
|
|
9666
9869
|
entries: scanRoot.entries,
|
|
9667
9870
|
explicit: scanRoot.explicit,
|
|
9668
9871
|
root: scanRoot.root,
|
|
9669
|
-
outDir
|
|
9872
|
+
outDir,
|
|
9873
|
+
onFilesResolved: (files) => files.forEach((file) => eligibleFiles.add(file))
|
|
9670
9874
|
})));
|
|
9875
|
+
updateSourceScanMatchers(eligibleFiles);
|
|
9671
9876
|
sourceCandidateScanSignature = nextScanSignature;
|
|
9672
9877
|
sourceCandidateScanInvalidated = false;
|
|
9673
|
-
if (options.isWatchLikeBuild())
|
|
9674
|
-
const snapshot = options.sourceCandidateCollector.snapshot();
|
|
9675
|
-
sourceCandidateScanCache.set(nextScanSignature, snapshot);
|
|
9676
|
-
sourceCandidateScanSnapshotCache.set(nextScanSignature, snapshot);
|
|
9677
|
-
}
|
|
9878
|
+
if (options.isWatchLikeBuild()) cacheCurrent();
|
|
9678
9879
|
};
|
|
9679
9880
|
const waitForPendingSyncs = async () => {
|
|
9680
9881
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
@@ -9699,11 +9900,16 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9699
9900
|
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
9700
9901
|
return previous;
|
|
9701
9902
|
};
|
|
9702
|
-
const syncChangedFile = (id, sourceOverride) => {
|
|
9703
|
-
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return
|
|
9903
|
+
const syncChangedFile = async (id, sourceOverride) => {
|
|
9904
|
+
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return;
|
|
9704
9905
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
9705
9906
|
const runtimeAffectingByDependency = isDependency(file);
|
|
9706
9907
|
if (runtimeAffectingByDependency) invalidate();
|
|
9908
|
+
const resolvedFile = require_generator.resolveSourceScanPath(file);
|
|
9909
|
+
if (sourceScanMatcher && !sourceScanMatcher(file) && sourceScanBoundaryMatcher?.(file) && !sourceScanIneligibleFiles.has(resolvedFile)) {
|
|
9910
|
+
await refreshSourceScanEligibleFiles();
|
|
9911
|
+
if (!sourceScanMatcher(file)) sourceScanIneligibleFiles.add(resolvedFile);
|
|
9912
|
+
}
|
|
9707
9913
|
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
9708
9914
|
const change = options.sourceCandidateCollector.remove(file);
|
|
9709
9915
|
cacheCurrent();
|
|
@@ -9712,7 +9918,10 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9712
9918
|
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
9713
9919
|
}
|
|
9714
9920
|
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
9715
|
-
if (existingTask)
|
|
9921
|
+
if (existingTask) {
|
|
9922
|
+
await existingTask;
|
|
9923
|
+
return syncChangedFile(id, sourceOverride);
|
|
9924
|
+
}
|
|
9716
9925
|
const previousSource = options.sourceCandidateCollector.source(file);
|
|
9717
9926
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
9718
9927
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
@@ -10382,6 +10591,14 @@ ${tracedCss}`;
|
|
|
10382
10591
|
});
|
|
10383
10592
|
const generateBundleHook = createGenerateBundleHook({
|
|
10384
10593
|
...generateBundleContext,
|
|
10594
|
+
...createGenericWebProductionBundleHooks({
|
|
10595
|
+
frameworkName: frameworkBranch.frameworkName,
|
|
10596
|
+
getHasProcessedCss: () => processedCssRegistry.getStats().viteProcessedCssAssetResults > 0,
|
|
10597
|
+
getIsWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10598
|
+
getResolvedConfig,
|
|
10599
|
+
onEnd: opts.onEnd,
|
|
10600
|
+
onStart: opts.onStart
|
|
10601
|
+
}),
|
|
10385
10602
|
shouldProcessStyles: () => !shouldSplitGenerateBundlePhases()
|
|
10386
10603
|
});
|
|
10387
10604
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
@@ -10390,10 +10607,13 @@ ${tracedCss}`;
|
|
|
10390
10607
|
ensureRuntimeClassSet,
|
|
10391
10608
|
cssPipelineStrategy: frameworkCssPipelineStrategy,
|
|
10392
10609
|
debug,
|
|
10610
|
+
frameworkName: frameworkBranch.frameworkName,
|
|
10393
10611
|
getResolvedConfig,
|
|
10612
|
+
hmrTimingRecorder,
|
|
10394
10613
|
markCssAssetProcessed,
|
|
10395
10614
|
isCssAssetProcessed,
|
|
10396
10615
|
isViteProcessedCssAsset,
|
|
10616
|
+
resolveCssAssetIdentity,
|
|
10397
10617
|
recordCssAssetResult,
|
|
10398
10618
|
recordViteProcessedCssAssetResult,
|
|
10399
10619
|
getViteProcessedCssAssetResults,
|