weapp-tailwindcss 5.2.11 → 5.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +1 -1
- 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/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/generic-web-production-fast-path.d.ts +28 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -0
- package/dist/cli.cjs +372 -293
- package/dist/cli.js +20 -11
- package/dist/{context-DbL0d-zB.js → context-CKQKq4Mv.js} +19 -8
- package/dist/{context-C3TryIjF.cjs → context-vWlNv-Cf.cjs} +17 -11
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-imports-DfNC3e6a.cjs → css-imports-BFMU7Hpd.cjs} +1 -1
- package/dist/css-macro/postcss.cjs +1 -1
- package/dist/css-macro.cjs +1 -1
- package/dist/defaults.cjs +2 -0
- package/dist/defaults.js +2 -0
- package/dist/framework.cjs +1 -1
- package/dist/{generator-BLpOsd5O.js → generator-BP4WmgIo.js} +36 -15
- package/dist/{generator-B0dCFlP1.cjs → generator-BXrWA7Sj.cjs} +43 -22
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DSrcDQsA.cjs → gulp-DxKLSgXX.cjs} +16 -13
- package/dist/{gulp-BLaGc0MJ.js → gulp-G--cGMcR.js} +12 -9
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-BnGBBJ6S.cjs → hmr-timing-BtqnyxAO.cjs} +5 -5
- package/dist/{hmr-timing-DXyGw6jp.js → hmr-timing-iTua_Z55.js} +47 -16
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{object-Bvy6-w9r.js → object-B-8IHefx.js} +4 -4
- package/dist/{object-C_Vr6_S5.cjs → object-DbHtAXRk.cjs} +4 -4
- package/dist/{options-zpZez7qe.cjs → options-DbYws6lr.cjs} +8 -17
- package/dist/{pipeline-helpers-B5CzvTUJ.cjs → pipeline-helpers-DnYpfbat.cjs} +25 -10
- package/dist/postcss-html-transform.cjs +1 -1
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +6 -5
- package/dist/presets.js +4 -3
- package/dist/reset.cjs +1 -1
- package/dist/{rolldown-runtime-CVvi-lCc.cjs → rolldown-runtime-Ctb5zv51.cjs} +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/{runtime-registry-Y7NrD2WH.cjs → runtime-registry-BlIjpImP.cjs} +10 -0
- package/dist/{source-candidate-scan-signature-GjsLzP8Z.cjs → source-candidate-scan-signature-Ggn8fzkT.cjs} +6 -5
- package/dist/{source-candidate-scan-signature-xgmxO8_F.js → source-candidate-scan-signature-TKJIs7VF.js} +5 -4
- package/dist/{style-options-COpQc8fr.cjs → style-options-Cta1OP3i.cjs} +9 -4
- package/dist/{tailwindcss-2zdmASlM.js → tailwindcss-C2K-vjJv.js} +20 -20
- package/dist/{tailwindcss-LtnGCxF0.cjs → tailwindcss-D1M2xj5O.cjs} +17 -13
- package/dist/{transform-BlsDWgjt.js → transform-52FLRu-0.js} +2 -2
- package/dist/{transform-9wbmvHcC.cjs → transform-BiHG42Rp.cjs} +2 -2
- package/dist/types/user-defined-options/general.d.ts +2 -0
- package/dist/{v4-generation-core-D4zQcQqW.cjs → v4-generation-core-D-zVR2mt.cjs} +53 -16
- package/dist/{vite-BWmBFzgf.js → vite-B577QMUl.js} +317 -82
- package/dist/{vite-DTDbD-95.cjs → vite-BFWJAH16.cjs} +322 -87
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/{watch-dependencies-BZGubvuJ.cjs → watch-dependencies-DLZDrWdH.cjs} +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +14 -12
- package/dist/weapp-tw-runtime-classset-loader.cjs +5 -4
- package/dist/{webpack-CtUyQNqC.js → webpack-DLJkStre.js} +41 -22
- package/dist/{webpack-Bpovb6YE.cjs → webpack-DTqFKvcE.cjs} +46 -36
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/{wxml-CWJc0yY-.js → wxml-B7OAVpXJ.js} +10 -6
- package/dist/{wxml-DUIdXCVa.cjs → wxml-CQmBCjOR.cjs} +386 -311
- package/package.json +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
2
|
-
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-
|
|
3
|
-
import { t as omitUndefined } from "./object-
|
|
4
|
-
import {
|
|
2
|
+
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-BP4WmgIo.js";
|
|
3
|
+
import { t as omitUndefined } from "./object-B-8IHefx.js";
|
|
4
|
+
import { a as findTailwindConfig, f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-C2K-vjJv.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-
|
|
7
|
-
import { m as createDebug, p as replaceWxml } from "./wxml-
|
|
8
|
-
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-
|
|
6
|
+
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, st as createSourceCandidateEligibilityMatcher, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-iTua_Z55.js";
|
|
7
|
+
import { m as createDebug, p as replaceWxml } from "./wxml-B7OAVpXJ.js";
|
|
8
|
+
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-CKQKq4Mv.js";
|
|
9
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-TKJIs7VF.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
11
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
@@ -172,7 +172,13 @@ function createViteCssAssetIdentityResolver(options) {
|
|
|
172
172
|
kind: "generator-placeholder",
|
|
173
173
|
sourceFile: placeholderSourceFile
|
|
174
174
|
};
|
|
175
|
-
else
|
|
175
|
+
else {
|
|
176
|
+
const processedSourceFile = candidates.find(options.isKnownProcessedSource);
|
|
177
|
+
identity = processedSourceFile ? {
|
|
178
|
+
kind: "bundler-generated",
|
|
179
|
+
sourceFile: processedSourceFile
|
|
180
|
+
} : { kind: "user" };
|
|
181
|
+
}
|
|
176
182
|
identityByAsset.set(asset, identity);
|
|
177
183
|
return identity;
|
|
178
184
|
};
|
|
@@ -973,7 +979,7 @@ let _lazyMatch = () => {
|
|
|
973
979
|
}
|
|
974
980
|
return u >= e;
|
|
975
981
|
})));
|
|
976
|
-
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0,
|
|
982
|
+
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
977
983
|
const n = r.map(v);
|
|
978
984
|
return g(_(M((a) => {
|
|
979
985
|
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
|
|
@@ -1357,7 +1363,7 @@ function createCssAssetPipelineContext(options, file, bundle) {
|
|
|
1357
1363
|
function getAssetFile$1(bundleFile, asset) {
|
|
1358
1364
|
return asset.fileName || bundleFile;
|
|
1359
1365
|
}
|
|
1360
|
-
function readAssetSource$
|
|
1366
|
+
function readAssetSource$3(asset) {
|
|
1361
1367
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1362
1368
|
}
|
|
1363
1369
|
function clearAssetSource(asset) {
|
|
@@ -1415,7 +1421,8 @@ function removeUnsupportedMiniProgramCssImportsFallback(css, file) {
|
|
|
1415
1421
|
return css.split(/\r?\n/).filter((line) => {
|
|
1416
1422
|
const trimmed = line.trim();
|
|
1417
1423
|
if (!trimmed.startsWith("@import")) return true;
|
|
1418
|
-
const
|
|
1424
|
+
const params = trimmed.slice(7).trim().replace(/;$/, "").trim();
|
|
1425
|
+
const request = parseTailwindCssDirectiveRequest(params);
|
|
1419
1426
|
return request === void 0 || isMiniProgramLocalCssImportRequest(request);
|
|
1420
1427
|
}).join("\n");
|
|
1421
1428
|
}
|
|
@@ -1501,7 +1508,7 @@ function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
|
1501
1508
|
if (output.type !== "asset") continue;
|
|
1502
1509
|
const file = normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1503
1510
|
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
1504
|
-
const source = stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1511
|
+
const source = stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1505
1512
|
if (source.length > 0) sources.push(source);
|
|
1506
1513
|
}
|
|
1507
1514
|
return sources;
|
|
@@ -1527,7 +1534,7 @@ function collectHtmlLinkedStyleFiles(bundle) {
|
|
|
1527
1534
|
if (output.type !== "asset") continue;
|
|
1528
1535
|
const htmlFile = getAssetFile$1(bundleFile, output);
|
|
1529
1536
|
if (!isHtmlOutputFile(htmlFile)) continue;
|
|
1530
|
-
const html = readAssetSource$
|
|
1537
|
+
const html = readAssetSource$3(output);
|
|
1531
1538
|
for (const match of html.matchAll(linkHrefRE)) {
|
|
1532
1539
|
const href = match[2];
|
|
1533
1540
|
if (!href) continue;
|
|
@@ -1554,7 +1561,7 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
1554
1561
|
if (output.type !== "asset") continue;
|
|
1555
1562
|
const file = getAssetFile$1(bundleFile, output);
|
|
1556
1563
|
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
1557
|
-
const source = stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1564
|
+
const source = stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1558
1565
|
if (source.length > 0) linkedSources.add(source);
|
|
1559
1566
|
}
|
|
1560
1567
|
if (linkedSources.size === 0) return 0;
|
|
@@ -1563,7 +1570,7 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
1563
1570
|
if (output.type !== "asset") continue;
|
|
1564
1571
|
const file = getAssetFile$1(bundleFile, output);
|
|
1565
1572
|
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1566
|
-
const source = stripBundlerGeneratedCssMarkers(readAssetSource$
|
|
1573
|
+
const source = stripBundlerGeneratedCssMarkers(readAssetSource$3(output)).trim();
|
|
1567
1574
|
if (!linkedSources.has(source)) continue;
|
|
1568
1575
|
delete bundle[bundleFile];
|
|
1569
1576
|
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
@@ -1591,7 +1598,8 @@ function collectCssImportAtRuleCss(css) {
|
|
|
1591
1598
|
function parseCssImportRequest(importCss) {
|
|
1592
1599
|
const trimmed = importCss.trim();
|
|
1593
1600
|
if (!trimmed.startsWith("@import")) return;
|
|
1594
|
-
|
|
1601
|
+
const params = trimmed.slice(7).trim().replace(/;$/, "").trim();
|
|
1602
|
+
return parseTailwindCssDirectiveRequest(params);
|
|
1595
1603
|
}
|
|
1596
1604
|
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
1597
1605
|
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
@@ -1631,7 +1639,7 @@ function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
|
1631
1639
|
if (output.type !== "asset") continue;
|
|
1632
1640
|
const file = normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1633
1641
|
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
1634
|
-
importedSources.push(readAssetSource$
|
|
1642
|
+
importedSources.push(readAssetSource$3(output));
|
|
1635
1643
|
}
|
|
1636
1644
|
return importedSources;
|
|
1637
1645
|
}
|
|
@@ -1848,7 +1856,8 @@ function resolveMiniProgramStyleOutputExtension(options = {}) {
|
|
|
1848
1856
|
}
|
|
1849
1857
|
function resolveReplayCssOutputFile(rootDir, file) {
|
|
1850
1858
|
const cleanFile = file.replace(/[?#].*$/, "");
|
|
1851
|
-
const
|
|
1859
|
+
const nextFile = path.isAbsolute(cleanFile) ? path.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(cleanFile)) : cleanFile;
|
|
1860
|
+
const normalizedFile = normalizeOutputPathKey(nextFile);
|
|
1852
1861
|
if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return normalizeOutputPathKey(path.basename(cleanFile));
|
|
1853
1862
|
return normalizedFile;
|
|
1854
1863
|
}
|
|
@@ -2665,7 +2674,7 @@ function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
|
2665
2674
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2666
2675
|
if (output.type !== "asset") continue;
|
|
2667
2676
|
const file = getAssetFile$1(bundleFile, output);
|
|
2668
|
-
const rawSource = readAssetSource$
|
|
2677
|
+
const rawSource = readAssetSource$3(output);
|
|
2669
2678
|
const hasScopedCss = hasVueScopedAttr(rawSource);
|
|
2670
2679
|
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
2671
2680
|
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
|
|
@@ -2888,7 +2897,7 @@ function isViteProcessedRootStyleImportingTargets(bundle, file, targetFiles) {
|
|
|
2888
2897
|
const targetFileSet = new Set(targetFiles.map(normalizeOutputPathKey));
|
|
2889
2898
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2890
2899
|
if (output.type !== "asset" || normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) !== normalizeOutputPathKey(file)) continue;
|
|
2891
|
-
return [...collectImportedStyleFiles(readAssetSource$
|
|
2900
|
+
return [...collectImportedStyleFiles(readAssetSource$3(output), file)].some((importedFile) => targetFileSet.has(normalizeOutputPathKey(importedFile)));
|
|
2892
2901
|
}
|
|
2893
2902
|
return false;
|
|
2894
2903
|
}
|
|
@@ -2918,7 +2927,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
2918
2927
|
if (candidateKey === targetFileKey || !isCssOutputFile(candidateKey)) continue;
|
|
2919
2928
|
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
2920
2929
|
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
2921
|
-
const candidateSource = readAssetSource$
|
|
2930
|
+
const candidateSource = readAssetSource$3(candidateOutput).trim();
|
|
2922
2931
|
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || containsCssAfterMinify(targetCss, candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !hasNonCommentCss(filterExistingCssRules(targetCss, candidateSource).trim())))) continue;
|
|
2923
2932
|
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
2924
2933
|
else clearAssetSource(candidateOutput);
|
|
@@ -2957,7 +2966,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2957
2966
|
if (output.type !== "asset") continue;
|
|
2958
2967
|
const file = getAssetFile$1(bundleFile, output);
|
|
2959
2968
|
if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
2960
|
-
const rawSource = readAssetSource$
|
|
2969
|
+
const rawSource = readAssetSource$3(output);
|
|
2961
2970
|
let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
2962
2971
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
2963
2972
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
@@ -2974,7 +2983,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2974
2983
|
if (singleMarkerFile && normalizeOutputPathKey(resolvedOutputFile) !== normalizeOutputPathKey(file) && !isRootStyleOutputFile(resolvedOutputFile) && existingAssetFiles.has(normalizeOutputPathKey(resolvedOutputFile))) {
|
|
2975
2984
|
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
2976
2985
|
if (targetAsset) {
|
|
2977
|
-
const targetRawSource = readAssetSource$
|
|
2986
|
+
const targetRawSource = readAssetSource$3(targetAsset);
|
|
2978
2987
|
const targetNextCss = appendCss$1(targetRawSource, filterExistingCssRules(targetRawSource, nextCss).trim());
|
|
2979
2988
|
if (targetNextCss !== targetRawSource) {
|
|
2980
2989
|
targetAsset.source = targetNextCss;
|
|
@@ -3052,7 +3061,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
3052
3061
|
if (output.type !== "asset") continue;
|
|
3053
3062
|
let file = getAssetFile$1(bundleFile, output);
|
|
3054
3063
|
if (!options.opts.cssMatcher(file) || !shouldUseCssAssetAsMainInjectionTarget(options.opts, file, viteCssResults, options, bundle)) continue;
|
|
3055
|
-
let originalSource = readAssetSource$
|
|
3064
|
+
let originalSource = readAssetSource$3(output);
|
|
3056
3065
|
if (shouldPreserveMiniProgramImportShell(options, bundle, file, originalSource)) {
|
|
3057
3066
|
const importedTargetFile = resolvePreservedImportShellInjectionTarget(options, bundle, file, originalSource);
|
|
3058
3067
|
if (typeof importedTargetFile === "string") {
|
|
@@ -3061,7 +3070,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
3061
3070
|
if (importedOutput?.type === "asset") {
|
|
3062
3071
|
output = importedOutput;
|
|
3063
3072
|
file = importedTargetFile;
|
|
3064
|
-
originalSource = readAssetSource$
|
|
3073
|
+
originalSource = readAssetSource$3(output);
|
|
3065
3074
|
} else continue;
|
|
3066
3075
|
} else {
|
|
3067
3076
|
options.debug?.("preserve mini-program css import shell asset: %s", file);
|
|
@@ -3525,7 +3534,8 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
|
|
|
3525
3534
|
const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
|
|
3526
3535
|
const resolvedOutputFile = CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles);
|
|
3527
3536
|
const rememberedOutputFile = remembered.outputFile.replace(/[?#].*$/, "");
|
|
3528
|
-
const
|
|
3537
|
+
const outputFile = opts.cssMatcher(rememberedOutputFile) && !normalizeOutputPathKey(rememberedOutputFile).includes("/") && normalizeOutputPathKey(rememberedOutputFile) !== normalizeOutputPathKey(resolvedOutputFile.replace(/[?#].*$/, "")) ? remembered.outputFile : resolvedOutputFile;
|
|
3538
|
+
const outputKey = normalizeOutputPathKey(outputFile);
|
|
3529
3539
|
const group = groups.get(outputKey) ?? [];
|
|
3530
3540
|
group.push({
|
|
3531
3541
|
key,
|
|
@@ -4887,7 +4897,7 @@ function resolveGenerateBundleEnvFlags() {
|
|
|
4887
4897
|
}
|
|
4888
4898
|
//#endregion
|
|
4889
4899
|
//#region src/bundlers/vite/generate-bundle/final-css-assets.ts
|
|
4890
|
-
function readAssetSource$
|
|
4900
|
+
function readAssetSource$2(output) {
|
|
4891
4901
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
4892
4902
|
}
|
|
4893
4903
|
function shouldFinalizeMiniProgramCssAsset(source) {
|
|
@@ -4902,7 +4912,7 @@ function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
|
4902
4912
|
if (output.type !== "asset") continue;
|
|
4903
4913
|
const file = output.fileName || bundleFile;
|
|
4904
4914
|
if (!options.cssMatcher(file) || options.files && !options.files.has(file)) continue;
|
|
4905
|
-
const rawSource = readAssetSource$
|
|
4915
|
+
const rawSource = readAssetSource$2(output);
|
|
4906
4916
|
const outputCss = finalizeMiniProgramCssStructure(rawSource);
|
|
4907
4917
|
if (outputCss === rawSource) continue;
|
|
4908
4918
|
plan.write(file, outputCss);
|
|
@@ -4927,10 +4937,11 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
4927
4937
|
if (output.type !== "asset") continue;
|
|
4928
4938
|
const file = output.fileName || bundleFile;
|
|
4929
4939
|
if (!options.cssMatcher(file)) continue;
|
|
4930
|
-
const rawSource = readAssetSource$
|
|
4940
|
+
const rawSource = readAssetSource$2(output);
|
|
4931
4941
|
if (rawSource.trim().length === 0) continue;
|
|
4932
4942
|
if (options.lastCssResultByFile?.has(file)) {
|
|
4933
|
-
const
|
|
4943
|
+
const structurallyCleanSource = finalizeMiniProgramCssStructure(rawSource);
|
|
4944
|
+
const outputCss = stripMiniProgramCssSpecificityPlaceholders(structurallyCleanSource);
|
|
4934
4945
|
if (outputCss !== rawSource) {
|
|
4935
4946
|
plan.write(file, outputCss);
|
|
4936
4947
|
writeTargets.set(file, output);
|
|
@@ -4964,7 +4975,8 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
4964
4975
|
},
|
|
4965
4976
|
cssPresetEnv: {}
|
|
4966
4977
|
});
|
|
4967
|
-
const
|
|
4978
|
+
const structurallyCleanCss = finalizeMiniProgramCssStructure(css);
|
|
4979
|
+
const outputCss = stripMiniProgramCssSpecificityPlaceholders(structurallyCleanCss);
|
|
4968
4980
|
if (outputCss === rawSource) continue;
|
|
4969
4981
|
plan.write(file, outputCss);
|
|
4970
4982
|
writeTargets.set(file, output);
|
|
@@ -5167,7 +5179,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5167
5179
|
}
|
|
5168
5180
|
//#endregion
|
|
5169
5181
|
//#region src/bundlers/vite/generate-bundle/finalize/root-import-shell.ts
|
|
5170
|
-
function readAssetSource(asset) {
|
|
5182
|
+
function readAssetSource$1(asset) {
|
|
5171
5183
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
5172
5184
|
}
|
|
5173
5185
|
function getAssetFile(bundleFile, asset) {
|
|
@@ -5183,7 +5195,7 @@ function finalizeWebviewCssCompat(bundle, options) {
|
|
|
5183
5195
|
if (output.type !== "asset") continue;
|
|
5184
5196
|
const file = getAssetFile(bundleFile, output);
|
|
5185
5197
|
if (!options.opts.cssMatcher(file) || !/\.css(?:$|[?#])/i.test(file)) continue;
|
|
5186
|
-
const rawSource = readAssetSource(output);
|
|
5198
|
+
const rawSource = readAssetSource$1(output);
|
|
5187
5199
|
const nextCss = transformWebCssSafeSelectors(transformWebCssCompat(rawSource, generatorOptions.webCompat ?? true), { escapeMap: options.opts.escapeMap });
|
|
5188
5200
|
if (nextCss === rawSource) continue;
|
|
5189
5201
|
plan.write(file, nextCss);
|
|
@@ -5233,7 +5245,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5233
5245
|
if (!originFile || !options.cssMatcher(originFile)) continue;
|
|
5234
5246
|
const originOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(getAssetFile(bundleFile, output)) === normalizeOutputPathKey(originFile))?.[1];
|
|
5235
5247
|
if (originOutput?.type !== "asset") continue;
|
|
5236
|
-
const rootSource = readAssetSource(rootOutput);
|
|
5248
|
+
const rootSource = readAssetSource$1(rootOutput);
|
|
5237
5249
|
const importedRootFile = resolveSingleCssImportOutputFile(rootFile, rootSource);
|
|
5238
5250
|
if (importedRootFile && normalizeOutputPathKey(importedRootFile) === normalizeOutputPathKey(originFile)) {
|
|
5239
5251
|
const nextRootSource = createCssImportShell(rootFile, originFile);
|
|
@@ -5247,7 +5259,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5247
5259
|
continue;
|
|
5248
5260
|
}
|
|
5249
5261
|
if (isPureLocalCssImportWrapper(rootSource)) continue;
|
|
5250
|
-
const originSource = readAssetSource(originOutput);
|
|
5262
|
+
const originSource = readAssetSource$1(originOutput);
|
|
5251
5263
|
if (isPureLocalCssImportWrapper(originSource)) {
|
|
5252
5264
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
5253
5265
|
if (importedFile && normalizeOutputPathKey(importedFile) !== normalizeOutputPathKey(rootFile)) continue;
|
|
@@ -5277,7 +5289,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
5277
5289
|
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, pendingRememberedCssReplayUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
5278
5290
|
const tasksStart = performance.now();
|
|
5279
5291
|
if (cssTaskFactories.length > 0) {
|
|
5280
|
-
const
|
|
5292
|
+
const cssConcurrency = resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion);
|
|
5293
|
+
const cssTask = runWithConcurrency(cssTaskFactories, cssConcurrency).then(() => void 0);
|
|
5281
5294
|
if (jsAfterCss) await cssTask;
|
|
5282
5295
|
else tasks.push(cssTask);
|
|
5283
5296
|
}
|
|
@@ -5677,7 +5690,8 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
5677
5690
|
const manifestPath = path.join(normalizedRoot, "manifest.json");
|
|
5678
5691
|
let enabled = false;
|
|
5679
5692
|
try {
|
|
5680
|
-
|
|
5693
|
+
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
5694
|
+
enabled = `${parse(raw)["uni-app-x"]?.styleIsolationVersion ?? ""}` === "2";
|
|
5681
5695
|
} catch {
|
|
5682
5696
|
enabled = false;
|
|
5683
5697
|
}
|
|
@@ -5949,12 +5963,13 @@ async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
|
5949
5963
|
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5950
5964
|
const sourceIds = new Set(ids);
|
|
5951
5965
|
for (const id of ids) {
|
|
5952
|
-
if (typeof id !== "string" || !/\.(?:uvue|nvue)(?:$|[?#])/i.test(id)) continue;
|
|
5966
|
+
if (typeof id !== "string" || !/\.(?:uvue|nvue|vue|tsx?|jsx?)(?:$|[?#])/i.test(id)) continue;
|
|
5953
5967
|
const identity = resolveViteModuleIdentity(id, root);
|
|
5954
5968
|
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${cleanUrl(lookupId)}?import`);
|
|
5955
5969
|
}
|
|
5956
5970
|
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
5957
|
-
|
|
5971
|
+
const modId = mod.id ?? mod.url;
|
|
5972
|
+
return !isSourceStyleRequest(modId);
|
|
5958
5973
|
});
|
|
5959
5974
|
}
|
|
5960
5975
|
async function resolveHotSourceModules(ctx) {
|
|
@@ -5962,7 +5977,8 @@ async function resolveHotSourceModules(ctx) {
|
|
|
5962
5977
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5963
5978
|
const collectModule = (mod) => {
|
|
5964
5979
|
if (mod == null || seenModules.has(mod)) return;
|
|
5965
|
-
|
|
5980
|
+
const modId = mod.id ?? mod.url;
|
|
5981
|
+
if (isSourceStyleRequest(modId)) return;
|
|
5966
5982
|
seenModules.add(mod);
|
|
5967
5983
|
modules.push(mod);
|
|
5968
5984
|
};
|
|
@@ -6046,7 +6062,8 @@ function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
|
6046
6062
|
}
|
|
6047
6063
|
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
6048
6064
|
return modules.some((mod) => {
|
|
6049
|
-
|
|
6065
|
+
const modId = mod.id ?? mod.url;
|
|
6066
|
+
return !isSourceStyleRequest(modId) && mod.isSelfAccepting === true;
|
|
6050
6067
|
});
|
|
6051
6068
|
}
|
|
6052
6069
|
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
@@ -6180,7 +6197,7 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
6180
6197
|
//#region src/uni-app-x/vite.ts
|
|
6181
6198
|
let transformUVuePromise;
|
|
6182
6199
|
function loadTransformUVue() {
|
|
6183
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
6200
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-52FLRu-0.js").then((mod) => mod.transformUVue));
|
|
6184
6201
|
return transformUVuePromise;
|
|
6185
6202
|
}
|
|
6186
6203
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6422,11 +6439,12 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
6422
6439
|
const { cache, hashKey, createHandlerOptions, debug, getAssetSource, getCssSources, injectStylePlaceholder = true, jsHandler, onUpdate, runtimeSet, applyLinkedResults } = options;
|
|
6423
6440
|
const absoluteFile = toAbsoluteOutputPath(file, outDir);
|
|
6424
6441
|
const rawSource = originalSource.source.toString();
|
|
6442
|
+
const rawHashSource = options.hashSalt ? `${rawSource}\n/*${options.hashSalt}*/` : rawSource;
|
|
6425
6443
|
await processCachedTask({
|
|
6426
6444
|
cache,
|
|
6427
6445
|
cacheKey: file,
|
|
6428
6446
|
hashKey,
|
|
6429
|
-
rawSource:
|
|
6447
|
+
rawSource: rawHashSource,
|
|
6430
6448
|
applyResult(source) {
|
|
6431
6449
|
originalSource.source = source;
|
|
6432
6450
|
},
|
|
@@ -6656,16 +6674,18 @@ async function processRememberedCssReplay(options) {
|
|
|
6656
6674
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
6657
6675
|
if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
6658
6676
|
const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
|
|
6659
|
-
if (allRememberedSignaturesFresh)
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6677
|
+
if (allRememberedSignaturesFresh) {
|
|
6678
|
+
if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
6679
|
+
else {
|
|
6680
|
+
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
6681
|
+
if (cachedCss != null) {
|
|
6682
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
6683
|
+
metrics.css.cacheHits++;
|
|
6684
|
+
debug("css replay cached result into framework root target: %s", outputFile);
|
|
6685
|
+
continue;
|
|
6686
|
+
}
|
|
6687
|
+
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
6667
6688
|
}
|
|
6668
|
-
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
6669
6689
|
}
|
|
6670
6690
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
6671
6691
|
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
@@ -7140,7 +7160,8 @@ function resolveCurrentSourceCandidateFile(options) {
|
|
|
7140
7160
|
}
|
|
7141
7161
|
function resolveCurrentSourceCandidateSource(options) {
|
|
7142
7162
|
const { file, getSourceCandidateSource, getSourceCandidateSources } = options;
|
|
7143
|
-
const
|
|
7163
|
+
const cleanedFile = file.replace(/[?#].*$/, "");
|
|
7164
|
+
const normalizedFile = normalizeOutputPathKey(cleanedFile);
|
|
7144
7165
|
const sourceCandidates = createSourceCandidateFiles(options);
|
|
7145
7166
|
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
7146
7167
|
if (source || !candidate) return source;
|
|
@@ -7319,7 +7340,10 @@ function createGenerateBundleHook$1(context) {
|
|
|
7319
7340
|
})
|
|
7320
7341
|
});
|
|
7321
7342
|
return async function generateBundle(_opt, bundle) {
|
|
7322
|
-
if (context.shouldProcessBundle?.() === false)
|
|
7343
|
+
if (context.shouldProcessBundle?.() === false) {
|
|
7344
|
+
await context.onSkipProcessBundle?.();
|
|
7345
|
+
return;
|
|
7346
|
+
}
|
|
7323
7347
|
const processMarkupAndScripts = context.processMarkupAndScripts !== false;
|
|
7324
7348
|
const processStyles = context.shouldProcessStyles?.() ?? context.processStyles !== false;
|
|
7325
7349
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
@@ -7989,6 +8013,41 @@ function createGenerateBundleHook(context) {
|
|
|
7989
8013
|
};
|
|
7990
8014
|
}
|
|
7991
8015
|
//#endregion
|
|
8016
|
+
//#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
|
|
8017
|
+
/**
|
|
8018
|
+
* Generic Web 生产构建的 CSS 已在 Vite transform 阶段生成时,不需要再建立面向小程序的完整产物快照。
|
|
8019
|
+
*/
|
|
8020
|
+
function shouldUseGenericWebProductionFastPath(options) {
|
|
8021
|
+
return options.frameworkName === "generic" && options.command === "build" && options.watch == null && options.isWebGeneratorTarget && options.hasProcessedCss;
|
|
8022
|
+
}
|
|
8023
|
+
/**
|
|
8024
|
+
* Finalizer fast path 只处理无小程序结构语义的 Generic Web 生产产物。
|
|
8025
|
+
*/
|
|
8026
|
+
function shouldUseGenericWebFinalizerFastPath(options) {
|
|
8027
|
+
return shouldUseGenericWebProductionFastPath(options) && !options.hasFrameworkRootImportShells && !options.isHarmonyAppStyleTarget && !options.isNativeAppStyleTarget;
|
|
8028
|
+
}
|
|
8029
|
+
/**
|
|
8030
|
+
* 将 Generic Web fast path 的判定和跳过生命周期集中起来,供 generateBundle hook 直接消费。
|
|
8031
|
+
*/
|
|
8032
|
+
function createGenericWebProductionBundleHooks(options) {
|
|
8033
|
+
return {
|
|
8034
|
+
onSkipProcessBundle: () => {
|
|
8035
|
+
options.onStart();
|
|
8036
|
+
options.onEnd();
|
|
8037
|
+
},
|
|
8038
|
+
shouldProcessBundle: () => {
|
|
8039
|
+
const config = options.getResolvedConfig();
|
|
8040
|
+
return !shouldUseGenericWebProductionFastPath({
|
|
8041
|
+
command: config?.command,
|
|
8042
|
+
frameworkName: options.frameworkName,
|
|
8043
|
+
hasProcessedCss: options.getHasProcessedCss(),
|
|
8044
|
+
isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
|
|
8045
|
+
watch: config?.build?.watch
|
|
8046
|
+
});
|
|
8047
|
+
}
|
|
8048
|
+
};
|
|
8049
|
+
}
|
|
8050
|
+
//#endregion
|
|
7992
8051
|
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
7993
8052
|
function inferPlatformFromViteOutDir(outDir) {
|
|
7994
8053
|
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
@@ -8052,6 +8111,95 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
|
8052
8111
|
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
8053
8112
|
}
|
|
8054
8113
|
//#endregion
|
|
8114
|
+
//#region src/bundlers/vite/css-finalizer/generic-web-fast-path.ts
|
|
8115
|
+
function readAssetSource(asset) {
|
|
8116
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
8117
|
+
}
|
|
8118
|
+
function collectCssAssets(bundle, context) {
|
|
8119
|
+
const assets = /* @__PURE__ */ new Map();
|
|
8120
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
8121
|
+
if (output.type !== "asset") continue;
|
|
8122
|
+
const file = output.fileName || bundleFile;
|
|
8123
|
+
if (!context.opts.cssMatcher(file) || context.opts.htmlMatcher(file)) continue;
|
|
8124
|
+
assets.set(normalizeOutputPathKey(file), {
|
|
8125
|
+
asset: output,
|
|
8126
|
+
file,
|
|
8127
|
+
original: readAssetSource(output)
|
|
8128
|
+
});
|
|
8129
|
+
}
|
|
8130
|
+
return assets;
|
|
8131
|
+
}
|
|
8132
|
+
function resolveProcessedCssOutputFile(file, options, bundleFiles) {
|
|
8133
|
+
return resolveViteCssPipelineOutputFile(file, options.context.opts, options.rootDir, true, false, options.sourceRoot, ".css", bundleFiles);
|
|
8134
|
+
}
|
|
8135
|
+
function resolveProcessedCssAssets(cssAssets, records, options, bundleFiles) {
|
|
8136
|
+
const assetBySourceFile = /* @__PURE__ */ new Map();
|
|
8137
|
+
for (const output of cssAssets.values()) {
|
|
8138
|
+
const identity = options.context.resolveCssAssetIdentity?.(output.asset, output.file);
|
|
8139
|
+
if (identity?.kind === "bundler-generated" && identity.sourceFile) assetBySourceFile.set(normalizeOutputPathKey(identity.sourceFile), output);
|
|
8140
|
+
for (const sourceFile of collectMatchingGeneratedCssMarkerFiles(output.file, output.original, (file) => resolveProcessedCssOutputFile(file, options, bundleFiles))) assetBySourceFile.set(normalizeOutputPathKey(sourceFile), output);
|
|
8141
|
+
}
|
|
8142
|
+
const processedAssets = /* @__PURE__ */ new Map();
|
|
8143
|
+
const htmlOwnedAssets = [...cssAssets.values()].filter((output) => [output.asset.originalFileName, ...output.asset.originalFileNames ?? []].some((file) => typeof file === "string" && /\.html(?:$|[?#])/i.test(file)));
|
|
8144
|
+
for (const [file, record] of records) {
|
|
8145
|
+
const recordCss = typeof record === "string" ? record : record.css;
|
|
8146
|
+
const outputFile = typeof record === "string" ? resolveProcessedCssOutputFile(file, options, bundleFiles) : record.outputFile ?? resolveProcessedCssOutputFile(file, options, bundleFiles);
|
|
8147
|
+
let output = assetBySourceFile.get(normalizeOutputPathKey(file)) ?? (outputFile ? cssAssets.get(normalizeOutputPathKey(outputFile)) : void 0);
|
|
8148
|
+
if (!output) {
|
|
8149
|
+
const matchingAssets = [...cssAssets.values()].filter((candidate) => options.context.isCssAssetProcessed(candidate.asset, candidate.file) && resolveViteProcessedCssAssetSource(candidate.file, candidate.original, (sourceFile) => resolveProcessedCssOutputFile(sourceFile, options, bundleFiles)) === recordCss);
|
|
8150
|
+
if (matchingAssets.length === 1) output = matchingAssets[0];
|
|
8151
|
+
}
|
|
8152
|
+
if (!output && records.length === 1 && htmlOwnedAssets.length === 1) output = htmlOwnedAssets[0];
|
|
8153
|
+
if (!output) return;
|
|
8154
|
+
const existingCss = processedAssets.get(output);
|
|
8155
|
+
if (existingCss !== void 0 && existingCss !== recordCss) return;
|
|
8156
|
+
processedAssets.set(output, recordCss);
|
|
8157
|
+
}
|
|
8158
|
+
return processedAssets;
|
|
8159
|
+
}
|
|
8160
|
+
/**
|
|
8161
|
+
* Generic Web 的 transform 结果能唯一映射到最终 CSS asset 时,只做一次 marker 清理和 Web 兼容收尾。
|
|
8162
|
+
*/
|
|
8163
|
+
function tryFinalizeGenericWebCss(options) {
|
|
8164
|
+
const { bundle, context } = options;
|
|
8165
|
+
const resolvedConfig = context.getResolvedConfig();
|
|
8166
|
+
const collectStartedAt = performance.now();
|
|
8167
|
+
const processedCssResults = [...context.getViteProcessedCssAssetResults?.() ?? []];
|
|
8168
|
+
if (!shouldUseGenericWebFinalizerFastPath({
|
|
8169
|
+
command: resolvedConfig?.command,
|
|
8170
|
+
frameworkName: context.frameworkName ?? "",
|
|
8171
|
+
hasFrameworkRootImportShells: (context.frameworkRootImportShellTargetByFile?.size ?? 0) > 0,
|
|
8172
|
+
hasProcessedCss: processedCssResults.length > 0,
|
|
8173
|
+
isHarmonyAppStyleTarget: options.isHarmonyAppStyleTarget,
|
|
8174
|
+
isNativeAppStyleTarget: options.isNativeAppStyleTarget,
|
|
8175
|
+
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
8176
|
+
watch: resolvedConfig?.build?.watch
|
|
8177
|
+
})) return false;
|
|
8178
|
+
const enumerateStartedAt = performance.now();
|
|
8179
|
+
const cssAssets = collectCssAssets(bundle, context);
|
|
8180
|
+
const bundleFiles = [...cssAssets.values()].map((item) => item.file);
|
|
8181
|
+
options.recordTiming("assets.enumerate", enumerateStartedAt);
|
|
8182
|
+
const processedAssets = resolveProcessedCssAssets(cssAssets, processedCssResults, options, bundleFiles);
|
|
8183
|
+
options.recordTiming("processedCss.collect", collectStartedAt);
|
|
8184
|
+
if (!processedAssets) return false;
|
|
8185
|
+
const writeStartedAt = performance.now();
|
|
8186
|
+
for (const [{ asset, file, original }, processedCss] of processedAssets) {
|
|
8187
|
+
const finalizeStartedAt = performance.now();
|
|
8188
|
+
const generated = finalizeWebCss(stripBundlerGeneratedCssMarkers(processedCss), {
|
|
8189
|
+
...options.createCssPipelineContext(file),
|
|
8190
|
+
file
|
|
8191
|
+
}, context.cssPipelineStrategy);
|
|
8192
|
+
options.recordTiming("finalizeWebCss", finalizeStartedAt);
|
|
8193
|
+
asset.source = generated;
|
|
8194
|
+
context.markCssAssetProcessed(asset, file);
|
|
8195
|
+
context.recordCssAssetResult?.(file, generated);
|
|
8196
|
+
if (generated !== original) context.opts.onUpdate(file, original, generated);
|
|
8197
|
+
}
|
|
8198
|
+
options.recordTiming("processedCss.inject", performance.now());
|
|
8199
|
+
options.recordTiming("assets.markerCleanupWrite", writeStartedAt);
|
|
8200
|
+
return true;
|
|
8201
|
+
}
|
|
8202
|
+
//#endregion
|
|
8055
8203
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
8056
8204
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
8057
8205
|
return {
|
|
@@ -8094,12 +8242,45 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8094
8242
|
resolvedConfig,
|
|
8095
8243
|
resolveStylePlatform: () => generatorPlatform
|
|
8096
8244
|
});
|
|
8245
|
+
const timingDetails = {};
|
|
8246
|
+
const recordTiming = (phase, startedAt) => {
|
|
8247
|
+
timingDetails[phase] = (timingDetails[phase] ?? 0) + Math.max(0, performance.now() - startedAt);
|
|
8248
|
+
};
|
|
8249
|
+
const finishTiming = () => {
|
|
8250
|
+
context.hmrTimingRecorder?.record("cssFinalizer", performance.now() - finalizerStartedAt, { timingDetails });
|
|
8251
|
+
context.hmrTimingRecorder?.emitTotal();
|
|
8252
|
+
};
|
|
8253
|
+
const finalizeWebCssAsset = (css, file) => {
|
|
8254
|
+
const startedAt = performance.now();
|
|
8255
|
+
const finalized = finalizeWebCss(css, {
|
|
8256
|
+
...createCssPipelineContext(file),
|
|
8257
|
+
file
|
|
8258
|
+
}, cssPipelineStrategy);
|
|
8259
|
+
recordTiming("finalizeWebCss", startedAt);
|
|
8260
|
+
return finalized;
|
|
8261
|
+
};
|
|
8097
8262
|
const isHarmonyAppStyleTarget = cssPipelineStrategy?.isHarmonyAppStyleTarget?.(createCssPipelineContext("")) === true;
|
|
8098
8263
|
const isNativeAppStyleTarget = cssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext("")) === true;
|
|
8099
8264
|
if (resolvedConfig?.command !== "build" && !isNativeAppStyleTarget) return;
|
|
8100
8265
|
const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
|
|
8101
8266
|
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
8102
8267
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType) ?? resolveSourceRootFromBundleGraph(resolvedConfig, bundle);
|
|
8268
|
+
const finalizerStartedAt = performance.now();
|
|
8269
|
+
if (tryFinalizeGenericWebCss({
|
|
8270
|
+
bundle,
|
|
8271
|
+
context,
|
|
8272
|
+
createCssPipelineContext,
|
|
8273
|
+
isHarmonyAppStyleTarget,
|
|
8274
|
+
isNativeAppStyleTarget,
|
|
8275
|
+
isWebGeneratorTarget,
|
|
8276
|
+
recordTiming,
|
|
8277
|
+
rootDir,
|
|
8278
|
+
sourceRoot
|
|
8279
|
+
})) {
|
|
8280
|
+
finalizeCompilerShadowRun(runtimeState);
|
|
8281
|
+
finishTiming();
|
|
8282
|
+
return;
|
|
8283
|
+
}
|
|
8103
8284
|
const finalCssAssetFiles = /* @__PURE__ */ new Set();
|
|
8104
8285
|
const trackFinalCssAssetUpdate = (file, original, generated) => {
|
|
8105
8286
|
finalCssAssetFiles.add(file);
|
|
@@ -8124,6 +8305,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8124
8305
|
tokenSources: sourceTraceTokenSources
|
|
8125
8306
|
});
|
|
8126
8307
|
const collectViteProcessedCssAssets = () => {
|
|
8308
|
+
const startedAt = performance.now();
|
|
8127
8309
|
collectViteProcessedCssAssetResults(bundle, {
|
|
8128
8310
|
opts,
|
|
8129
8311
|
cssPipelineStrategy,
|
|
@@ -8134,28 +8316,26 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8134
8316
|
recordViteProcessedCssAssetResult,
|
|
8135
8317
|
onAssetWrite: (file) => finalCssAssetFiles.add(file),
|
|
8136
8318
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
8137
|
-
transformCss:
|
|
8138
|
-
...createCssPipelineContext(file),
|
|
8139
|
-
file
|
|
8140
|
-
}, cssPipelineStrategy),
|
|
8319
|
+
transformCss: finalizeWebCssAsset,
|
|
8141
8320
|
debug
|
|
8142
8321
|
});
|
|
8322
|
+
recordTiming("processedCss.collect", startedAt);
|
|
8143
8323
|
};
|
|
8144
8324
|
const injectViteProcessedCssIntoMainCss = () => {
|
|
8145
|
-
|
|
8325
|
+
const startedAt = performance.now();
|
|
8326
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
8146
8327
|
opts,
|
|
8147
8328
|
cssPipelineStrategy,
|
|
8148
8329
|
createCssPipelineContext,
|
|
8149
8330
|
getViteProcessedCssAssetResults,
|
|
8150
8331
|
markCssAssetProcessed,
|
|
8151
8332
|
recordCssAssetResult,
|
|
8152
|
-
transformCss:
|
|
8153
|
-
...createCssPipelineContext(file),
|
|
8154
|
-
file
|
|
8155
|
-
}, cssPipelineStrategy),
|
|
8333
|
+
transformCss: finalizeWebCssAsset,
|
|
8156
8334
|
debug,
|
|
8157
8335
|
onUpdate: trackFinalCssAssetUpdate
|
|
8158
8336
|
});
|
|
8337
|
+
recordTiming("processedCss.inject", startedAt);
|
|
8338
|
+
return injected;
|
|
8159
8339
|
};
|
|
8160
8340
|
collectViteProcessedCssAssets();
|
|
8161
8341
|
const createHarmonyBundleStyleSources = async () => {
|
|
@@ -8198,7 +8378,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8198
8378
|
const fileName = output.fileName || bundleFile;
|
|
8199
8379
|
return output.type === "asset" && opts.cssMatcher(fileName) && !opts.htmlMatcher(fileName) && !isHTMLRequest(fileName) && !isCssAssetProcessed(output, fileName);
|
|
8200
8380
|
};
|
|
8381
|
+
const enumerateStartedAt = performance.now();
|
|
8201
8382
|
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
8383
|
+
recordTiming("assets.enumerate", enumerateStartedAt);
|
|
8202
8384
|
if (entries.length === 0) {
|
|
8203
8385
|
await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
|
|
8204
8386
|
collectViteProcessedCssAssets();
|
|
@@ -8219,6 +8401,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8219
8401
|
recordCssAssetResult
|
|
8220
8402
|
});
|
|
8221
8403
|
finalizeCompilerShadowRun(runtimeState);
|
|
8404
|
+
finishTiming();
|
|
8222
8405
|
return;
|
|
8223
8406
|
}
|
|
8224
8407
|
await runtimeState.readyPromise;
|
|
@@ -8242,10 +8425,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8242
8425
|
...createCssPipelineContext(file),
|
|
8243
8426
|
file
|
|
8244
8427
|
}) ?? {});
|
|
8245
|
-
const nextCss = annotateCss(generatorBranch.isWeb ?
|
|
8246
|
-
...createCssPipelineContext(file),
|
|
8247
|
-
file
|
|
8248
|
-
}, cssPipelineStrategy) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
8428
|
+
const nextCss = annotateCss(generatorBranch.isWeb ? finalizeWebCssAsset(cleanRawSource, file) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
8249
8429
|
writeCssAsset(file, output, nextCss);
|
|
8250
8430
|
markCssAssetProcessed(output, file);
|
|
8251
8431
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -8309,10 +8489,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8309
8489
|
debug("css finalizer preserve mini-program import shell: %s", file);
|
|
8310
8490
|
return;
|
|
8311
8491
|
}
|
|
8312
|
-
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ?
|
|
8313
|
-
...createCssPipelineContext(file),
|
|
8314
|
-
file
|
|
8315
|
-
}, cssPipelineStrategy) : (await opts.styleHandler(generatorTransformRawSource, cssHandlerOptions)).css));
|
|
8492
|
+
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCssAsset(cleanRawSource, file) : (await opts.styleHandler(generatorTransformRawSource, cssHandlerOptions)).css));
|
|
8316
8493
|
if (generated) {
|
|
8317
8494
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
8318
8495
|
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
@@ -8324,6 +8501,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8324
8501
|
opts.onUpdate(file, rawSource, nextCss);
|
|
8325
8502
|
debug("css finalizer handle: %s", file);
|
|
8326
8503
|
}));
|
|
8504
|
+
const writeStartedAt = performance.now();
|
|
8327
8505
|
applyViteAssetEmissionPlan(emissionPlan, {
|
|
8328
8506
|
bundle,
|
|
8329
8507
|
writeTargets
|
|
@@ -8347,6 +8525,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8347
8525
|
recordCssAssetResult
|
|
8348
8526
|
});
|
|
8349
8527
|
finalizeCompilerShadowRun(runtimeState);
|
|
8528
|
+
recordTiming("assets.write", writeStartedAt);
|
|
8529
|
+
finishTiming();
|
|
8350
8530
|
}
|
|
8351
8531
|
}
|
|
8352
8532
|
};
|
|
@@ -9382,12 +9562,36 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9382
9562
|
const request = mod.url ?? mod.id;
|
|
9383
9563
|
return typeof request === "string" && /\.(?:uvue|nvue)(?:\?import)?$/i.test(request);
|
|
9384
9564
|
});
|
|
9565
|
+
const sendSupplementalSourceHotUpdates = (ctx, modules) => {
|
|
9566
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
9567
|
+
const updates = modules.flatMap((mod) => [mod, ...mod.importedModules ?? []]).filter((mod) => !isSourceStyleRequest(mod.id ?? mod.url)).map((mod) => {
|
|
9568
|
+
let hotPath;
|
|
9569
|
+
if (typeof mod.id === "string" && path.isAbsolute(mod.id)) {
|
|
9570
|
+
const relative = typeof mod.url === "string" && mod.url.startsWith("/pages/") ? path.relative(path.dirname(root), mod.id) : path.relative(root, mod.id);
|
|
9571
|
+
if (relative && !relative.startsWith("..") && !path.isAbsolute(relative)) hotPath = `/${relative.split(path.sep).join("/")}`;
|
|
9572
|
+
}
|
|
9573
|
+
hotPath ?? (hotPath = mod.url ?? (typeof mod.id === "string" && mod.id.startsWith("/") ? mod.id : void 0));
|
|
9574
|
+
return hotPath ? {
|
|
9575
|
+
acceptedPath: hotPath,
|
|
9576
|
+
explicitImportRequired: false,
|
|
9577
|
+
isWithinCircularImport: false,
|
|
9578
|
+
path: hotPath,
|
|
9579
|
+
timestamp: ctx.timestamp,
|
|
9580
|
+
type: "js-update"
|
|
9581
|
+
} : void 0;
|
|
9582
|
+
}).filter((update) => update !== void 0);
|
|
9583
|
+
if (updates.length > 0) ctx.server.ws?.send?.({
|
|
9584
|
+
type: "update",
|
|
9585
|
+
updates
|
|
9586
|
+
});
|
|
9587
|
+
};
|
|
9385
9588
|
return {
|
|
9386
9589
|
name: `${vitePluginName}:source-candidates`,
|
|
9387
9590
|
enforce: "pre",
|
|
9388
9591
|
async load(id) {
|
|
9389
9592
|
if (!options.shouldOwnTailwindGeneration || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
9390
|
-
const
|
|
9593
|
+
const file = cleanUrl(id);
|
|
9594
|
+
const rawCode = await readFile(file, "utf8").catch(() => void 0);
|
|
9391
9595
|
if (typeof rawCode !== "string") return;
|
|
9392
9596
|
options.rememberOriginalCssLayerSource(id, rawCode);
|
|
9393
9597
|
const transformedCode = options.transformEarlyMiniProgramCss(rawCode);
|
|
@@ -9416,7 +9620,10 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9416
9620
|
if (!options.sourceScanSession.matches(file)) {
|
|
9417
9621
|
options.sourceCandidateCollector.remove(file);
|
|
9418
9622
|
options.sourceScanSession.cacheCurrent();
|
|
9419
|
-
return
|
|
9623
|
+
return shouldReturnTransformedCode ? {
|
|
9624
|
+
code: transformedCode,
|
|
9625
|
+
map: null
|
|
9626
|
+
} : void 0;
|
|
9420
9627
|
}
|
|
9421
9628
|
await options.sourceCandidateCollector.merge(id, transformedCode);
|
|
9422
9629
|
options.sourceScanSession.cacheCurrent();
|
|
@@ -9489,12 +9696,22 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9489
9696
|
const cssModules = await resolveHotTailwindCssModules(ctx, isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9490
9697
|
const hotRoot = ctx.server.config?.root ?? process$1.cwd();
|
|
9491
9698
|
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9699
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) {
|
|
9700
|
+
sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
9701
|
+
if (sourceModules.some((mod) => {
|
|
9702
|
+
const id = mod.id ?? mod.url;
|
|
9703
|
+
return typeof id === "string" && /[?&]macro=true(?:&|$)/.test(id) === false && typeof mod.url === "string" && mod.url.startsWith("/pages/") && /\.vue(?:$|[?#])/i.test(id);
|
|
9704
|
+
})) {
|
|
9705
|
+
queueMicrotask(() => sendFullReloadForUnresolvedHotUpdate(ctx));
|
|
9706
|
+
return [];
|
|
9707
|
+
}
|
|
9708
|
+
}
|
|
9492
9709
|
const hasHmrCandidateAppend = options.hmrCandidateState.hasPendingCandidateAppend() || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
9493
9710
|
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && options.isUniViteProject())) {
|
|
9494
9711
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9495
9712
|
return [];
|
|
9496
9713
|
}
|
|
9497
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.
|
|
9714
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.isNuxtPageHotModule?.(mod.id ?? mod.url))) {
|
|
9498
9715
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9499
9716
|
return [];
|
|
9500
9717
|
}
|
|
@@ -9605,9 +9822,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9605
9822
|
});
|
|
9606
9823
|
sourceScanEntries = sourceScan?.entries;
|
|
9607
9824
|
sourceScanExplicit = sourceScan?.explicit ?? false;
|
|
9608
|
-
sourceScanMatcher = createSourceScanMatcher(sourceScanEntries);
|
|
9609
9825
|
sourceScanDependencies = new Set((sourceScan?.dependencies ?? []).map(normalizeDependency));
|
|
9610
9826
|
const roots = collectRoots(root, sourceScanEntries);
|
|
9827
|
+
sourceScanMatcher = createSourceCandidateEligibilityMatcher(roots.map((scanRoot) => ({
|
|
9828
|
+
...scanRoot,
|
|
9829
|
+
outDir
|
|
9830
|
+
})));
|
|
9611
9831
|
const nextScanSignature = createSourceCandidateScanSignature({
|
|
9612
9832
|
inlineCandidates: sourceScan?.inlineCandidates,
|
|
9613
9833
|
outDir,
|
|
@@ -10023,9 +10243,11 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10023
10243
|
const platform = resolveViteStylePlatform();
|
|
10024
10244
|
return platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb;
|
|
10025
10245
|
};
|
|
10026
|
-
const
|
|
10027
|
-
if (typeof id !== "string"
|
|
10028
|
-
const cleanId = cleanUrl(id);
|
|
10246
|
+
const isNuxtPageHotModule = (id) => {
|
|
10247
|
+
if (typeof id !== "string") return false;
|
|
10248
|
+
const cleanId = cleanUrl(id).replace(/%2F/gi, "/");
|
|
10249
|
+
if (cleanId.includes("virtual:nuxt:") && /(?:^|\/)routes\.mjs$/.test(cleanId)) return true;
|
|
10250
|
+
if (!/[?&]macro=true(?:&|$)/.test(id)) return false;
|
|
10029
10251
|
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
10030
10252
|
};
|
|
10031
10253
|
const normalizeGeneratedCssCacheFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
|
|
@@ -10350,6 +10572,14 @@ ${tracedCss}`;
|
|
|
10350
10572
|
});
|
|
10351
10573
|
const generateBundleHook = createGenerateBundleHook({
|
|
10352
10574
|
...generateBundleContext,
|
|
10575
|
+
...createGenericWebProductionBundleHooks({
|
|
10576
|
+
frameworkName: frameworkBranch.frameworkName,
|
|
10577
|
+
getHasProcessedCss: () => processedCssRegistry.getStats().viteProcessedCssAssetResults > 0,
|
|
10578
|
+
getIsWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10579
|
+
getResolvedConfig,
|
|
10580
|
+
onEnd: opts.onEnd,
|
|
10581
|
+
onStart: opts.onStart
|
|
10582
|
+
}),
|
|
10353
10583
|
shouldProcessStyles: () => !shouldSplitGenerateBundlePhases()
|
|
10354
10584
|
});
|
|
10355
10585
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
@@ -10358,10 +10588,13 @@ ${tracedCss}`;
|
|
|
10358
10588
|
ensureRuntimeClassSet,
|
|
10359
10589
|
cssPipelineStrategy: frameworkCssPipelineStrategy,
|
|
10360
10590
|
debug,
|
|
10591
|
+
frameworkName: frameworkBranch.frameworkName,
|
|
10361
10592
|
getResolvedConfig,
|
|
10593
|
+
hmrTimingRecorder,
|
|
10362
10594
|
markCssAssetProcessed,
|
|
10363
10595
|
isCssAssetProcessed,
|
|
10364
10596
|
isViteProcessedCssAsset,
|
|
10597
|
+
resolveCssAssetIdentity,
|
|
10365
10598
|
recordCssAssetResult,
|
|
10366
10599
|
recordViteProcessedCssAssetResult,
|
|
10367
10600
|
getViteProcessedCssAssetResults,
|
|
@@ -10425,7 +10658,7 @@ ${tracedCss}`;
|
|
|
10425
10658
|
hmrTimingRecorder,
|
|
10426
10659
|
invalidateRecordedGeneratorCandidates,
|
|
10427
10660
|
isCurrentWebLikeStylePlatform,
|
|
10428
|
-
|
|
10661
|
+
isNuxtPageHotModule,
|
|
10429
10662
|
isUniViteProject,
|
|
10430
10663
|
isWebOrNativeAppPlatform,
|
|
10431
10664
|
prepareTailwindGeneration,
|
|
@@ -10739,17 +10972,19 @@ function withUniAppXWebPreflightReset(css, enabled) {
|
|
|
10739
10972
|
//#region src/bundlers/vite/uni-app-x-css-options.ts
|
|
10740
10973
|
function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
10741
10974
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
10742
|
-
|
|
10975
|
+
const branch = normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
10743
10976
|
appType: opts.appType,
|
|
10744
10977
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
10745
10978
|
uniAppX: resolveUniAppXOptions(opts.uniAppX),
|
|
10746
10979
|
uniUtsPlatform
|
|
10747
|
-
})
|
|
10980
|
+
});
|
|
10981
|
+
const runtimeBranch = resolveGeneratorRuntimeBranch(branch, {
|
|
10748
10982
|
appType: opts.appType,
|
|
10749
10983
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
10750
10984
|
uniAppX: resolveUniAppXOptions(opts.uniAppX),
|
|
10751
10985
|
uniUtsPlatform
|
|
10752
|
-
})
|
|
10986
|
+
});
|
|
10987
|
+
if (!shouldUseNativeAppCssBranch(runtimeBranch) || !isUniAppXEnabled(opts.uniAppX)) return {};
|
|
10753
10988
|
return {
|
|
10754
10989
|
uniAppX: true,
|
|
10755
10990
|
uniAppXCssTarget: "uvue",
|