weapp-tailwindcss 5.1.14 → 5.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-2dg_uhEJ.mjs +13 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
- package/dist/bundlers/gulp/index.d.ts +2 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +43 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +4 -2
- package/dist/bundlers/shared/framework-postcss.d.ts +14 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +18 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +33 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +3 -6
- package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
- package/dist/bundlers/shared/generator-css.d.ts +1 -2
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +3 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
- package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle-runtime.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +12 -0
- package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
- package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +4 -2
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +5 -4
- package/dist/bundlers/vite/source-candidates/collector.d.ts +8 -0
- package/dist/bundlers/vite/source-candidates/store.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/types-and-cache.d.ts +69 -0
- package/dist/bundlers/vite/source-candidates.d.ts +4 -68
- package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -217
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +6 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
- package/dist/cli.js +14 -18
- package/dist/cli.mjs +14 -18
- package/dist/{context-VeFq_8vW.js → context-BtLIID4m.js} +3 -3
- package/dist/{context-BL8Gy71H.mjs → context-JzwzSX36.mjs} +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{generator-CEnUsjed.js → generator-B91GhUJQ.js} +636 -505
- package/dist/{generator-B59OA64h.mjs → generator-Bv7myuhY.mjs} +557 -432
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/{gulp-DUYWxmZC.mjs → gulp-CKSklPlH.mjs} +218 -153
- package/dist/{gulp-C1Q3LRzg.js → gulp-Q1wITegn.js} +218 -153
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-C3ed5vCx.mjs → hmr-timing-BXg7nI8N.mjs} +3406 -3145
- package/dist/{hmr-timing-BZ5sWIqO.js → hmr-timing-CMPaWn9P.js} +3474 -3147
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/shared/mpx-plugin-owner.d.ts +2 -0
- package/dist/shared/mpx.d.ts +4 -1
- package/dist/{source-candidate-scan-signature-R3dzamcm.js → source-candidate-scan-signature-BKZZk_e6.js} +144 -96
- package/dist/{source-candidate-scan-signature-D7RWjWsY.mjs → source-candidate-scan-signature-CtK-mB_C.mjs} +127 -60
- package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
- package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +52 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
- package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-B4phC0kB.js} +2 -2
- package/dist/{tailwindcss-DPcKMLxL.mjs → tailwindcss-BTcXX8Ka.mjs} +2 -2
- package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
- package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
- package/dist/{vite-CBU5NXTX.mjs → vite-BwQWl9ft.mjs} +1269 -878
- package/dist/{vite-BNlPdsGM.js → vite-DhVnXvAQ.js} +1314 -923
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-generation-loader.js +12 -0
- package/dist/weapp-tw-css-import-rewrite-loader-B0tVkJLH.js +10524 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +6 -10255
- package/dist/weapp-tw-runtime-classset-loader.js +10 -4
- package/dist/{webpack-CZ38fMGC.mjs → webpack-Bo1QrFPf.mjs} +1518 -1079
- package/dist/{webpack-Jpe048pQ.js → webpack-kh78iMSS.js} +1519 -1080
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +17 -7
- package/dist/auto-CrJJc5rK.mjs +0 -13
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { $ as normalizeTailwindConfigDirectives, Ct as isFileMatchedByTailwindSourceEntries, E as resolveTailwindcssOptions, G as hasUserCssLayerBlocks, H as normalizeEmptyTailwindCustomVariants, I as hasMiniProgramCssSpecificityPlaceholders, J as hasLocalCssImport, K as splitUserCssLayerBlocks, Nt as getTailwindV4IncrementalGenerateCacheStats, Ot as resolveTailwindV4CssSourceBase, Pt as filterUnsupportedMiniProgramTailwindV4Candidates, Q as hasTailwindSourceDirectives, X as hasTailwindNonRootGenerationDirectives, Y as hasTailwindApplyDirective, Z as hasTailwindRootDirectives, a as resolveGeneratorRuntimeBranch, b as normalizeCssEntries, c as shouldUseNativeAppCssBranch, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, l as resolveUniUtsPlatform, lt as hasTailwindGeneratedCssMarkers, m as filterTailwindV4CssSourceRoots, nt as parseImportRequest, pt as stripGeneratorPlaceholderMarkers, rt as removeTailwindSourceDirectives, s as shouldUseMiniProgramCssBranch, tt as normalizeTailwindSourceForGenerator, x as findNearestPackageRoot, y as isTailwindV4CssEntry, z as stripMiniProgramCssSpecificityPlaceholders } from "./generator-Bv7myuhY.mjs";
|
|
3
3
|
import { t as omitUndefined } from "./object-BJSWl-E5.mjs";
|
|
4
|
-
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
4
|
+
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-BTcXX8Ka.mjs";
|
|
5
5
|
import "./utils-MVwpU07P.mjs";
|
|
6
6
|
import { g as replaceWxml, y as createDebug } from "./wxml-DdGdeqaH.mjs";
|
|
7
|
-
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-
|
|
8
|
-
import { A as processCachedTask, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, O as createCssTokenSourceMap, S as
|
|
9
|
-
import {
|
|
7
|
+
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-JzwzSX36.mjs";
|
|
8
|
+
import { A as processCachedTask, C as hasBundlerGeneratedCssMarker, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, I as createBundleRuntimeClassSetManager, N as isSourceCandidateRequest, O as createCssTokenSourceMap, P as extractCandidatesFromSource, S as createBundlerGeneratedCssMarker, T as stripBundlerGeneratedCssMarkers, a as extractMarkedUserLayerComponentsCss, d as normalizeMiniProgramGeneratorCssSource, f as normalizeMiniProgramImportShell, g as isSourceStyleRequest, j as createSourceCandidateCollector, o as mergeMarkedUserLayerComponentsCss, r as validateCandidatesByGenerator, t as createHmrTimingRecorder, u as runWithConcurrency, v as stripRequestQuery, w as parseBundlerGeneratedCssMarkerBlocks, y as scoreTailwindV4CssSourceFileMatch, z as isPureLocalCssImportWrapper } from "./hmr-timing-BXg7nI8N.mjs";
|
|
9
|
+
import { C as createBundleModuleGraphOptions, D as toAbsoluteOutputPath, F as viteStyleInjectorDelegates, L as resolveViteFrameworkProfile, M as resolvePluginDisabledState, N as createBuiltinViteStyleInjectorPlugins, O as captureFrameworkPostcssOptions, S as applyLinkedResults, T as normalizeOutputPathKey, _ as isCSSRequest, a as createCandidateSignature, b as slash, c as getSnapshotHash, d as buildBundleSnapshot, g as formatPostcssSourceMap, h as cleanUrl, i as createScopedGeneratorSourceTraceMap, j as resolvePackageDir, l as hasRuntimeAffectingSourceChanges, m as updateBundleBuildState, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as createBundleBuildState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, v as isHTMLRequest, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature, y as normalizePath } from "./source-candidate-scan-signature-CtK-mB_C.mjs";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
11
11
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import process$1 from "node:process";
|
|
14
14
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
15
|
-
import { collectCssImportRequestsRoot, compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, parseTailwindCssDirectiveRequest, postcss, removeTailwindPostcssPlugins, removeTailwindSourceDirectivesRoot, removeUnsupportedMiniProgramCssImportsRoot,
|
|
15
|
+
import { collectCssImportRequestsRoot, compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, parseTailwindCssDirectiveRequest, postcss, removeTailwindPostcssPlugins, removeTailwindSourceDirectivesRoot, removeUnsupportedMiniProgramCssImportsRoot, resolvePostcssConfig, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
|
|
16
16
|
import { LRUCache } from "lru-cache";
|
|
17
17
|
import { readFile } from "node:fs/promises";
|
|
18
18
|
import micromatch from "micromatch";
|
|
19
|
-
import { Buffer } from "node:buffer";
|
|
20
19
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
20
|
+
import { Buffer } from "node:buffer";
|
|
21
21
|
import { parse } from "comment-json";
|
|
22
22
|
//#region src/uni-app-x/style-asset/style-value.ts
|
|
23
23
|
const GEN_APP_STYLES_RE = /const\s+GenAppStyles\s*=\s*\[_uM\(\[([\s\S]*?)\]\)\]/;
|
|
@@ -190,8 +190,28 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
190
190
|
}
|
|
191
191
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
193
|
+
function resolveReferencePaths(styleSource, sourceId) {
|
|
194
|
+
if (!sourceId || !styleSource.includes("@reference")) return styleSource;
|
|
195
|
+
let root;
|
|
196
|
+
try {
|
|
197
|
+
root = postcss.parse(styleSource);
|
|
198
|
+
} catch {
|
|
199
|
+
return styleSource;
|
|
200
|
+
}
|
|
201
|
+
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
202
|
+
root.walkAtRules("reference", (rule) => {
|
|
203
|
+
const quote = rule.params[0];
|
|
204
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
205
|
+
const closingQuoteIndex = rule.params.indexOf(quote, 1);
|
|
206
|
+
if (closingQuoteIndex <= 1) return;
|
|
207
|
+
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
208
|
+
if (!referencePath.startsWith(".")) return;
|
|
209
|
+
rule.params = `${quote}${path.resolve(path.dirname(cleanSourceId), referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
210
|
+
});
|
|
211
|
+
return root.toString();
|
|
212
|
+
}
|
|
213
|
+
function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
|
|
214
|
+
return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE$2)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => resolveReferencePaths(styleSource.trim(), sourceId)).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
|
|
195
215
|
}
|
|
196
216
|
function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
197
217
|
const utilities = /* @__PURE__ */ new Set();
|
|
@@ -236,7 +256,18 @@ const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
|
|
|
236
256
|
const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
|
|
237
257
|
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v2";
|
|
238
258
|
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
239
|
-
return applyStyleSources.
|
|
259
|
+
return applyStyleSources.map((source) => {
|
|
260
|
+
let root;
|
|
261
|
+
try {
|
|
262
|
+
root = postcss.parse(source);
|
|
263
|
+
} catch {
|
|
264
|
+
return source;
|
|
265
|
+
}
|
|
266
|
+
root.walkAtRules("reference", (rule) => {
|
|
267
|
+
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
268
|
+
});
|
|
269
|
+
return root.toString();
|
|
270
|
+
}).join("\n");
|
|
240
271
|
}
|
|
241
272
|
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
242
273
|
const utilities = /* @__PURE__ */ new Set();
|
|
@@ -465,6 +496,138 @@ function createUniAppXBundleAssetSourceGetter(bundle) {
|
|
|
465
496
|
};
|
|
466
497
|
}
|
|
467
498
|
//#endregion
|
|
499
|
+
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
500
|
+
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
501
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
502
|
+
if (!output.fileName || output.fileName === file) continue;
|
|
503
|
+
const existing = bundle[output.fileName];
|
|
504
|
+
if (existing != null && existing !== output) continue;
|
|
505
|
+
bundle[output.fileName] = output;
|
|
506
|
+
delete bundle[file];
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
511
|
+
function toArray(value) {
|
|
512
|
+
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
513
|
+
}
|
|
514
|
+
function normalizeSourceId(id) {
|
|
515
|
+
const file = cleanUrl(id);
|
|
516
|
+
return path.isAbsolute(file) ? path.resolve(file) : void 0;
|
|
517
|
+
}
|
|
518
|
+
function collectChunkModuleIds$2(chunk) {
|
|
519
|
+
const ids = /* @__PURE__ */ new Set();
|
|
520
|
+
for (const id of chunk.moduleIds ?? []) {
|
|
521
|
+
const normalized = normalizeSourceId(id);
|
|
522
|
+
if (normalized) ids.add(normalized);
|
|
523
|
+
}
|
|
524
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
525
|
+
const normalized = normalizeSourceId(id);
|
|
526
|
+
if (normalized) ids.add(normalized);
|
|
527
|
+
}
|
|
528
|
+
return ids;
|
|
529
|
+
}
|
|
530
|
+
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
531
|
+
const ids = /* @__PURE__ */ new Set();
|
|
532
|
+
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
533
|
+
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
534
|
+
for (const candidate of candidates) {
|
|
535
|
+
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
536
|
+
const cleanCandidate = cleanUrl(candidate);
|
|
537
|
+
const resolved = path.isAbsolute(cleanCandidate) ? path.resolve(cleanCandidate) : path.resolve(rootDir, cleanCandidate);
|
|
538
|
+
ids.add(resolved);
|
|
539
|
+
}
|
|
540
|
+
return ids;
|
|
541
|
+
}
|
|
542
|
+
function isStringRuleMatched(rule, id, rootDir) {
|
|
543
|
+
const normalizedId = slash(id);
|
|
544
|
+
const normalizedRule = slash(rule);
|
|
545
|
+
if (path.isAbsolute(rule)) return micromatch.isMatch(normalizedId, normalizedRule);
|
|
546
|
+
const relative = slash(path.relative(rootDir, id));
|
|
547
|
+
return relative.length > 0 && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizedRule);
|
|
548
|
+
}
|
|
549
|
+
function isRuleMatched(rule, id, rootDir) {
|
|
550
|
+
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
551
|
+
if (rule instanceof RegExp) {
|
|
552
|
+
rule.lastIndex = 0;
|
|
553
|
+
return rule.test(slash(id));
|
|
554
|
+
}
|
|
555
|
+
return rule(id) === true;
|
|
556
|
+
}
|
|
557
|
+
function createTransformMatcher(rules, rootDir) {
|
|
558
|
+
const normalizedRules = toArray(rules);
|
|
559
|
+
if (normalizedRules.length === 0) return;
|
|
560
|
+
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
561
|
+
}
|
|
562
|
+
function shouldSkipSourceIds(sourceIds, filter) {
|
|
563
|
+
if (sourceIds.size === 0) return false;
|
|
564
|
+
if (filter.exclude) {
|
|
565
|
+
let excluded = true;
|
|
566
|
+
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
567
|
+
excluded = false;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
if (excluded) return true;
|
|
571
|
+
}
|
|
572
|
+
if (filter.include) {
|
|
573
|
+
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
function createTransformFilter(options, rootDir) {
|
|
579
|
+
const include = createTransformMatcher(options?.include, rootDir);
|
|
580
|
+
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
581
|
+
if (!include && !exclude) return;
|
|
582
|
+
return {
|
|
583
|
+
include,
|
|
584
|
+
exclude
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
588
|
+
if (!filter) return false;
|
|
589
|
+
return shouldSkipSourceIds(collectChunkModuleIds$2(chunk), filter);
|
|
590
|
+
}
|
|
591
|
+
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
592
|
+
if (!filter) return false;
|
|
593
|
+
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
594
|
+
}
|
|
595
|
+
function createRuleSignature(rules) {
|
|
596
|
+
return toArray(rules).map((rule) => {
|
|
597
|
+
if (typeof rule === "string") return `s:${rule}`;
|
|
598
|
+
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
599
|
+
return "f";
|
|
600
|
+
}).join("|") || "none";
|
|
601
|
+
}
|
|
602
|
+
function createTransformFilterSignature(options) {
|
|
603
|
+
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
|
|
607
|
+
async function collectBundleMarkupCandidates(options) {
|
|
608
|
+
const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
|
|
609
|
+
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, candidates]) => [file, new Set(candidates)])) : /* @__PURE__ */ new Map();
|
|
610
|
+
await Promise.all(snapshot.entries.map(async (entry) => {
|
|
611
|
+
if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
|
|
612
|
+
const sourceFile = resolveSourceCandidateFile(entry.file) ?? path.resolve(rootDir, entry.file);
|
|
613
|
+
candidatesByFile.set(sourceFile, await extractSourceCandidates(sourceFile, entry.source));
|
|
614
|
+
}));
|
|
615
|
+
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
616
|
+
const values = /* @__PURE__ */ new Set();
|
|
617
|
+
for (const [file, candidates] of candidatesByFile) {
|
|
618
|
+
if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(file, entries)) continue;
|
|
619
|
+
if (filterOptions.excludeEntries?.length && isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
|
|
620
|
+
for (const candidate of candidates) values.add(candidate);
|
|
621
|
+
}
|
|
622
|
+
return values;
|
|
623
|
+
};
|
|
624
|
+
return {
|
|
625
|
+
candidatesByFile,
|
|
626
|
+
values: valuesForEntries(void 0),
|
|
627
|
+
valuesForEntries
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
//#endregion
|
|
468
631
|
//#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
|
|
469
632
|
function collectConfiguredTailwindV4CssSources(opts) {
|
|
470
633
|
const runtimeCssSources = opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
@@ -548,7 +711,8 @@ function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
|
548
711
|
//#region src/bundlers/vite/generate-bundle/css-assets.ts
|
|
549
712
|
function createCssAssetEmitter(context, bundle) {
|
|
550
713
|
return (fileName, source) => {
|
|
551
|
-
const
|
|
714
|
+
const fileNameKey = normalizeOutputPathKey(fileName);
|
|
715
|
+
const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
|
|
552
716
|
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
|
|
553
717
|
existing.source = source;
|
|
554
718
|
return existing;
|
|
@@ -645,8 +809,9 @@ function resolveMiniProgramStyleOutputExtension(options = {}) {
|
|
|
645
809
|
return resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher, options.stem) ?? resolveStyleOutputExtensionFromFiles(options.files, options.cssMatcher) ?? resolveStyleOutputExtensionFromMatcher(options.cssMatcher, options.stem) ?? normalizeStyleOutputExtension(options.fallback) ?? FALLBACK_STYLE_OUTPUT_EXTENSION;
|
|
646
810
|
}
|
|
647
811
|
function resolveReplayCssOutputFile(rootDir, file) {
|
|
648
|
-
const
|
|
649
|
-
|
|
812
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
813
|
+
const normalizedFile = normalizeOutputPathKey(path.isAbsolute(cleanFile) ? path.relative(resolveCssOutputRealPath(rootDir), resolveCssOutputRealPath(cleanFile)) : cleanFile);
|
|
814
|
+
if (normalizedFile.length === 0 || normalizedFile === "." || normalizedFile === ".." || normalizedFile.startsWith("../")) return normalizeOutputPathKey(path.basename(cleanFile));
|
|
650
815
|
return normalizedFile;
|
|
651
816
|
}
|
|
652
817
|
function normalizeViteSourceRoot(rootDir, sourceRoot) {
|
|
@@ -662,9 +827,10 @@ function resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot) {
|
|
|
662
827
|
return outputFile;
|
|
663
828
|
}
|
|
664
829
|
function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssExtension = false, styleOutputExtension, styleOutputFiles) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
830
|
+
const cleanFile = file.replace(/[?#].*$/, "");
|
|
831
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !isCSSRequest(file)) return cleanFile;
|
|
832
|
+
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
833
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, resolveMiniProgramStyleOutputExtension({
|
|
668
834
|
cssMatcher: opts.cssMatcher,
|
|
669
835
|
fallback: styleOutputExtension,
|
|
670
836
|
files: styleOutputFiles,
|
|
@@ -672,20 +838,40 @@ function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, preserveCssE
|
|
|
672
838
|
}));
|
|
673
839
|
}
|
|
674
840
|
function resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
675
|
-
const
|
|
676
|
-
const cleanFile =
|
|
841
|
+
const sourceStyleRequest = isCSSRequest(file);
|
|
842
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, file, sourceRoot).replace(/[?#].*$/, "");
|
|
843
|
+
const sourceExtension = path.extname(cleanFile);
|
|
844
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
845
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
846
|
+
return `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
847
|
+
cssMatcher: opts.cssMatcher,
|
|
848
|
+
fallback: styleOutputExtension,
|
|
849
|
+
files: styleOutputFiles,
|
|
850
|
+
stem
|
|
851
|
+
})}`;
|
|
852
|
+
}
|
|
677
853
|
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
678
854
|
const matchedStyleExtension = !isWebGeneratorTarget && !preserveCssExtension ? resolveStyleOutputExtensionFromFiles(styleOutputFiles, opts.cssMatcher, stem) : void 0;
|
|
679
|
-
if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) &&
|
|
680
|
-
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(
|
|
855
|
+
if (matchedStyleExtension && CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) && sourceStyleRequest) return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, matchedStyleExtension);
|
|
856
|
+
if (isWebGeneratorTarget || preserveCssExtension || opts.cssMatcher(cleanFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
681
857
|
const fallbackExtension = normalizeStyleOutputExtension(styleOutputExtension);
|
|
682
|
-
if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(
|
|
683
|
-
return
|
|
858
|
+
if (!fallbackExtension && !SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanFile)) return cleanFile;
|
|
859
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, fallbackExtension ?? FALLBACK_STYLE_OUTPUT_EXTENSION);
|
|
684
860
|
}
|
|
685
861
|
function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
686
|
-
const
|
|
687
|
-
const cleanFile =
|
|
688
|
-
|
|
862
|
+
const sourceStyleRequest = isCSSRequest(sourceFile);
|
|
863
|
+
const cleanFile = resolveReplayCssOutputFileFromSourceRoot(rootDir, sourceFile, sourceRoot).replace(/[?#].*$/, "");
|
|
864
|
+
const sourceExtension = path.extname(cleanFile);
|
|
865
|
+
if (sourceStyleRequest && !isWebGeneratorTarget && !preserveCssExtension && sourceExtension.length > 0 && !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile)) {
|
|
866
|
+
const stem = cleanFile.slice(0, -sourceExtension.length);
|
|
867
|
+
return resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem) ?? `${stem}${resolveMiniProgramStyleOutputExtension({
|
|
868
|
+
cssMatcher: opts.cssMatcher,
|
|
869
|
+
fallback: styleOutputExtension,
|
|
870
|
+
files: styleOutputFiles,
|
|
871
|
+
stem
|
|
872
|
+
})}`;
|
|
873
|
+
}
|
|
874
|
+
if (isWebGeneratorTarget || preserveCssExtension || !CSS_SOURCE_OUTPUT_EXT_RE.test(cleanFile) || !sourceStyleRequest) return cleanFile;
|
|
689
875
|
const stem = cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, "");
|
|
690
876
|
const matchedStyleFile = resolveStyleOutputFileFromFiles(styleOutputFiles, opts.cssMatcher, stem);
|
|
691
877
|
if (matchedStyleFile) return matchedStyleFile;
|
|
@@ -695,7 +881,7 @@ function resolveViteCssPipelineOutputFileFromSourceFile(sourceFile, opts, rootDi
|
|
|
695
881
|
files: styleOutputFiles,
|
|
696
882
|
stem
|
|
697
883
|
}) ?? normalizeStyleOutputExtension(styleOutputExtension);
|
|
698
|
-
return
|
|
884
|
+
return cleanFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, styleExtension);
|
|
699
885
|
}
|
|
700
886
|
function canProcessViteSourceStyleAsCss(source, file) {
|
|
701
887
|
if (SOURCE_STYLE_NON_CSS_SYNTAX_RE.test(source)) return false;
|
|
@@ -847,7 +1033,8 @@ function createCssHandlerOptionsCache(options) {
|
|
|
847
1033
|
const appType = options.getAppType();
|
|
848
1034
|
const isMainChunk = options.mainCssChunkMatcher(file, appType);
|
|
849
1035
|
const outputRoot = options.getOutputRoot?.();
|
|
850
|
-
const
|
|
1036
|
+
const sourceFile = stripRequestQuery(file);
|
|
1037
|
+
const from = path.isAbsolute(sourceFile) ? sourceFile : outputRoot ? path.resolve(outputRoot, sourceFile) : sourceFile;
|
|
851
1038
|
const extraOptions = options.getExtraOptions?.(file) ?? {};
|
|
852
1039
|
const dynamicCssOptions = options.getDynamicCssOptions?.() ?? {};
|
|
853
1040
|
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}:${JSON.stringify(dynamicCssOptions)}`;
|
|
@@ -859,7 +1046,10 @@ function createCssHandlerOptionsCache(options) {
|
|
|
859
1046
|
...dynamicCssOptions,
|
|
860
1047
|
postcssOptions: { options: { from } },
|
|
861
1048
|
majorVersion: normalizeStyleHandlerMajorVersion(majorVersion),
|
|
862
|
-
sourceOptions: {
|
|
1049
|
+
sourceOptions: {
|
|
1050
|
+
outputRoot,
|
|
1051
|
+
...sourceFile === file ? {} : { requestFile: file }
|
|
1052
|
+
}
|
|
863
1053
|
};
|
|
864
1054
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
865
1055
|
return created;
|
|
@@ -962,6 +1152,7 @@ function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceF
|
|
|
962
1152
|
const source = rawSource.trim();
|
|
963
1153
|
if (source.length === 0) return false;
|
|
964
1154
|
if (canProcessViteSourceStyleAsCss(source, file)) return false;
|
|
1155
|
+
if (SOURCE_STYLE_OUTPUT_EXT_RE.test(assetSourceFile.replace(/[?#].*$/, ""))) return true;
|
|
965
1156
|
const isKnownStyleSource = isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
|
|
966
1157
|
return outputFile !== file || !isKnownStyleSource;
|
|
967
1158
|
}
|
|
@@ -1519,359 +1710,55 @@ const mix = (del = delimiter) => {
|
|
|
1519
1710
|
const posix = /* @__PURE__ */ mix(":");
|
|
1520
1711
|
const win32 = /* @__PURE__ */ mix(";");
|
|
1521
1712
|
//#endregion
|
|
1522
|
-
//#region src/bundlers/vite/
|
|
1523
|
-
const
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
".nvue",
|
|
1527
|
-
".svelte",
|
|
1528
|
-
".mpx"
|
|
1529
|
-
];
|
|
1530
|
-
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
1531
|
-
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
1532
|
-
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
1533
|
-
function extractSfcStyleBlocks(source) {
|
|
1534
|
-
const styleSources = [];
|
|
1535
|
-
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
1536
|
-
let index = 0;
|
|
1537
|
-
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1538
|
-
while (match !== null) {
|
|
1539
|
-
const attrs = match[1] ?? "";
|
|
1540
|
-
styleSources.push({
|
|
1541
|
-
attrs,
|
|
1542
|
-
index,
|
|
1543
|
-
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
1544
|
-
source: match[2] ?? ""
|
|
1545
|
-
});
|
|
1546
|
-
index += 1;
|
|
1547
|
-
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1548
|
-
}
|
|
1549
|
-
return styleSources;
|
|
1713
|
+
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
1714
|
+
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1715
|
+
function isCssOutputFile(file) {
|
|
1716
|
+
return CSS_OUTPUT_FILE_RE.test(file);
|
|
1550
1717
|
}
|
|
1551
|
-
function
|
|
1552
|
-
|
|
1718
|
+
function isRootStyleOutputFile(file) {
|
|
1719
|
+
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1720
|
+
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
1553
1721
|
}
|
|
1554
|
-
function
|
|
1555
|
-
return
|
|
1722
|
+
function isMiniProgramStyleOutputFile(file) {
|
|
1723
|
+
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
1556
1724
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1725
|
+
//#endregion
|
|
1726
|
+
//#region src/bundlers/vite/processed-css-assets/markers-imports.ts
|
|
1727
|
+
function createCssAssetPipelineContext(options, file, bundle) {
|
|
1728
|
+
const context = options.createCssPipelineContext?.(file);
|
|
1729
|
+
return context ? {
|
|
1730
|
+
...context,
|
|
1731
|
+
bundle
|
|
1732
|
+
} : void 0;
|
|
1560
1733
|
}
|
|
1561
|
-
function
|
|
1562
|
-
return
|
|
1734
|
+
function getAssetFile$1(bundleFile, asset) {
|
|
1735
|
+
return asset.fileName || bundleFile;
|
|
1563
1736
|
}
|
|
1564
|
-
function
|
|
1565
|
-
|
|
1566
|
-
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
1737
|
+
function readAssetSource$2(asset) {
|
|
1738
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1567
1739
|
}
|
|
1568
|
-
function
|
|
1569
|
-
|
|
1570
|
-
params.set("vue", "");
|
|
1571
|
-
params.set("type", "style");
|
|
1572
|
-
params.set("index", String(styleBlock.index));
|
|
1573
|
-
if (styleBlock.scoped) params.set("scoped", "true");
|
|
1574
|
-
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
1575
|
-
if (lang) params.set("lang", lang);
|
|
1576
|
-
return `${sourceFile}?${params.toString()}`;
|
|
1740
|
+
function clearAssetSource(asset) {
|
|
1741
|
+
asset.source = "";
|
|
1577
1742
|
}
|
|
1578
|
-
function
|
|
1579
|
-
if (
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
1583
|
-
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
1584
|
-
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
1585
|
-
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
1586
|
-
});
|
|
1587
|
-
const styleBlock = matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0;
|
|
1588
|
-
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
1743
|
+
function appendCss$1(baseCss, css) {
|
|
1744
|
+
if (baseCss.length === 0) return css;
|
|
1745
|
+
if (css.length === 0) return baseCss;
|
|
1746
|
+
return `${baseCss}\n${css}`;
|
|
1589
1747
|
}
|
|
1590
|
-
function
|
|
1591
|
-
|
|
1592
|
-
return hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
|
|
1748
|
+
function normalizeCssRecordIdentity(css) {
|
|
1749
|
+
return css.trim();
|
|
1593
1750
|
}
|
|
1594
|
-
function
|
|
1595
|
-
|
|
1596
|
-
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1751
|
+
function hasNonCommentCss(css) {
|
|
1752
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1597
1753
|
}
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
return;
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
1607
|
-
return;
|
|
1608
|
-
}
|
|
1609
|
-
const styleBlocks = extractSfcStyleBlocks(source);
|
|
1610
|
-
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
1611
|
-
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1612
|
-
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1613
|
-
return;
|
|
1614
|
-
}
|
|
1615
|
-
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
1616
|
-
return {
|
|
1617
|
-
outputFile,
|
|
1618
|
-
rawSource,
|
|
1619
|
-
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1622
|
-
function normalizeSfcSourceFileForCompare(file) {
|
|
1623
|
-
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1624
|
-
}
|
|
1625
|
-
function collectChunkModuleIds$2(output) {
|
|
1626
|
-
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
1627
|
-
return [
|
|
1628
|
-
output.facadeModuleId,
|
|
1629
|
-
...moduleIds,
|
|
1630
|
-
...Object.keys(output.modules ?? {})
|
|
1631
|
-
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
1632
|
-
}
|
|
1633
|
-
function normalizeSourceStyleModuleId(id) {
|
|
1634
|
-
const file = id.replace(/[?#].*$/, "");
|
|
1635
|
-
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
1636
|
-
if (!path.isAbsolute(file)) return;
|
|
1637
|
-
return path.resolve(file);
|
|
1638
|
-
}
|
|
1639
|
-
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
1640
|
-
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
1641
|
-
if (cssMatcher?.(normalizedOutputFile)) {
|
|
1642
|
-
const extension = path.extname(normalizedOutputFile);
|
|
1643
|
-
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
1644
|
-
}
|
|
1645
|
-
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
1646
|
-
}
|
|
1647
|
-
function normalizeSfcModuleId(id) {
|
|
1648
|
-
const file = id.replace(/[?#].*$/, "");
|
|
1649
|
-
if (!SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension))) return;
|
|
1650
|
-
if (!path.isAbsolute(file)) return;
|
|
1651
|
-
return path.resolve(file);
|
|
1652
|
-
}
|
|
1653
|
-
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
1654
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
1655
|
-
if (!siblingJsFile) {
|
|
1656
|
-
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1657
|
-
return;
|
|
1658
|
-
}
|
|
1659
|
-
const normalizedSiblingJsFile = normalizeOutputPathKey(siblingJsFile);
|
|
1660
|
-
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1661
|
-
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1662
|
-
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1666
|
-
if (sourceFiles.length === 0) {
|
|
1667
|
-
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1671
|
-
sourceFile,
|
|
1672
|
-
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1673
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1674
|
-
debug("sfc style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1675
|
-
const bestScore = scoredSources[0]?.score;
|
|
1676
|
-
if (!bestScore) return;
|
|
1677
|
-
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1678
|
-
if (bestSources.length !== 1) {
|
|
1679
|
-
debug("sfc style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1680
|
-
return;
|
|
1681
|
-
}
|
|
1682
|
-
return bestSources[0]?.sourceFile;
|
|
1683
|
-
}
|
|
1684
|
-
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
1685
|
-
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
1686
|
-
if (!siblingJsFile) {
|
|
1687
|
-
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
1688
|
-
return;
|
|
1689
|
-
}
|
|
1690
|
-
const normalizedSiblingJsFile = normalizeOutputPathKey(siblingJsFile);
|
|
1691
|
-
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
1692
|
-
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
1693
|
-
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
1694
|
-
return;
|
|
1695
|
-
}
|
|
1696
|
-
const sourceFiles = collectChunkModuleIds$2(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
1697
|
-
if (sourceFiles.length === 0) {
|
|
1698
|
-
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
1699
|
-
return;
|
|
1700
|
-
}
|
|
1701
|
-
if (sourceFiles.length === 1) {
|
|
1702
|
-
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
1703
|
-
return sourceFiles[0];
|
|
1704
|
-
}
|
|
1705
|
-
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1706
|
-
sourceFile,
|
|
1707
|
-
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
1708
|
-
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1709
|
-
debug("source style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
1710
|
-
const bestScore = scoredSources[0]?.score;
|
|
1711
|
-
if (!bestScore) return;
|
|
1712
|
-
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
1713
|
-
if (bestSources.length !== 1) {
|
|
1714
|
-
debug("source style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
1715
|
-
return;
|
|
1716
|
-
}
|
|
1717
|
-
return bestSources[0]?.sourceFile;
|
|
1718
|
-
}
|
|
1719
|
-
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
1720
|
-
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
1721
|
-
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
1722
|
-
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1723
|
-
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1724
|
-
file,
|
|
1725
|
-
source,
|
|
1726
|
-
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1727
|
-
outputRoot,
|
|
1728
|
-
projectRoot: sourceRoot
|
|
1729
|
-
})
|
|
1730
|
-
}));
|
|
1731
|
-
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
1732
|
-
file,
|
|
1733
|
-
source,
|
|
1734
|
-
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
1735
|
-
outputRoot,
|
|
1736
|
-
projectRoot: sourceRoot
|
|
1737
|
-
})
|
|
1738
|
-
}));
|
|
1739
|
-
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
1740
|
-
const bestScore = scoredSources[0]?.score;
|
|
1741
|
-
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
1742
|
-
if (bestSources.length === 1) {
|
|
1743
|
-
sourceFile = bestSources[0].file;
|
|
1744
|
-
rawSource = bestSources[0].source;
|
|
1745
|
-
debug("source style source inferred from cache: %s -> %s", outputFile, sourceFile);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
if (!sourceFile || !rawSource) return;
|
|
1749
|
-
if (!hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1750
|
-
debug("source style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
return {
|
|
1754
|
-
outputFile,
|
|
1755
|
-
rawSource,
|
|
1756
|
-
sourceFile
|
|
1757
|
-
};
|
|
1758
|
-
}
|
|
1759
|
-
//#endregion
|
|
1760
|
-
//#region src/bundlers/vite/generate-bundle/subpackages.ts
|
|
1761
|
-
function readBundleAssetSource(output) {
|
|
1762
|
-
if ("type" in output && output.type !== "asset") return;
|
|
1763
|
-
const source = output.source;
|
|
1764
|
-
if (typeof source === "string") return source;
|
|
1765
|
-
if (typeof source === "function") {
|
|
1766
|
-
const value = source.call(output);
|
|
1767
|
-
return typeof value === "string" ? value : value?.toString();
|
|
1768
|
-
}
|
|
1769
|
-
if (source != null && typeof source.toString === "function") return source.toString();
|
|
1770
|
-
}
|
|
1771
|
-
function normalizePackageRoot(root) {
|
|
1772
|
-
return normalizeOutputPathKey(root).replace(/\/+$/, "");
|
|
1773
|
-
}
|
|
1774
|
-
function collectMiniProgramSubpackageRoots(bundle) {
|
|
1775
|
-
let hasAppJson = false;
|
|
1776
|
-
const roots = /* @__PURE__ */ new Set();
|
|
1777
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
1778
|
-
const outputFile = output.fileName || file;
|
|
1779
|
-
if (path.basename(outputFile) !== "app.json") continue;
|
|
1780
|
-
const source = readBundleAssetSource(output);
|
|
1781
|
-
if (!source) continue;
|
|
1782
|
-
hasAppJson = true;
|
|
1783
|
-
try {
|
|
1784
|
-
const appJson = JSON.parse(source);
|
|
1785
|
-
const subPackages = Array.isArray(appJson.subPackages) ? appJson.subPackages : Array.isArray(appJson.subpackages) ? appJson.subpackages : [];
|
|
1786
|
-
for (const subPackage of subPackages) {
|
|
1787
|
-
if (typeof subPackage.root !== "string" || subPackage.root.length === 0) continue;
|
|
1788
|
-
roots.add(normalizePackageRoot(subPackage.root));
|
|
1789
|
-
}
|
|
1790
|
-
} catch {}
|
|
1791
|
-
}
|
|
1792
|
-
return hasAppJson ? roots : void 0;
|
|
1793
|
-
}
|
|
1794
|
-
function isSubpackageOutputFile(file, subpackageRoots) {
|
|
1795
|
-
const normalizedFile = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1796
|
-
for (const root of subpackageRoots) if (root.length > 0 && (normalizedFile === root || normalizedFile.startsWith(`${root}/`) || normalizedFile.endsWith(`/${root}`) || normalizedFile.includes(`/${root}/`))) return true;
|
|
1797
|
-
return false;
|
|
1798
|
-
}
|
|
1799
|
-
function resolveSubpackageSourceRootFromModuleId(moduleId, subpackageRoot) {
|
|
1800
|
-
const file = slash(path.resolve(moduleId.replace(/[?#].*$/, "")));
|
|
1801
|
-
const normalizedRoot = normalizePackageRoot(subpackageRoot);
|
|
1802
|
-
const rootSegment = `/${normalizedRoot}/`;
|
|
1803
|
-
const rootIndex = file.lastIndexOf(rootSegment);
|
|
1804
|
-
if (rootIndex >= 0) return file.slice(0, rootIndex + rootSegment.length - 1);
|
|
1805
|
-
const rootSuffix = `/${normalizedRoot}`;
|
|
1806
|
-
if (file.endsWith(rootSuffix)) return file;
|
|
1807
|
-
}
|
|
1808
|
-
function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, sourceBaseRoots) {
|
|
1809
|
-
const sourceRoots = /* @__PURE__ */ new Set();
|
|
1810
|
-
const sourceEntries = [];
|
|
1811
|
-
for (const entry of snapshot.entries) {
|
|
1812
|
-
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
1813
|
-
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
1814
|
-
if (!matchedSubpackageRoot) continue;
|
|
1815
|
-
for (const moduleId of collectChunkModuleIds$2(entry.output)) {
|
|
1816
|
-
if (!path.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
1817
|
-
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
1818
|
-
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
1822
|
-
base: sourceRoot,
|
|
1823
|
-
negated: false,
|
|
1824
|
-
pattern: "**/*"
|
|
1825
|
-
})));
|
|
1826
|
-
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => path.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
1827
|
-
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
1828
|
-
base: baseRoot,
|
|
1829
|
-
negated: false,
|
|
1830
|
-
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
1831
|
-
});
|
|
1832
|
-
return sourceEntries;
|
|
1833
|
-
}
|
|
1834
|
-
//#endregion
|
|
1835
|
-
//#region src/bundlers/vite/processed-css-assets.ts
|
|
1836
|
-
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1837
|
-
function createCssAssetPipelineContext(options, file, bundle) {
|
|
1838
|
-
const context = options.createCssPipelineContext?.(file);
|
|
1839
|
-
return context ? {
|
|
1840
|
-
...context,
|
|
1841
|
-
bundle
|
|
1842
|
-
} : void 0;
|
|
1843
|
-
}
|
|
1844
|
-
function isCssOutputFile(file) {
|
|
1845
|
-
return CSS_OUTPUT_FILE_RE.test(file);
|
|
1846
|
-
}
|
|
1847
|
-
function getAssetFile$1(bundleFile, asset) {
|
|
1848
|
-
return asset.fileName || bundleFile;
|
|
1849
|
-
}
|
|
1850
|
-
function readAssetSource$2(asset) {
|
|
1851
|
-
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1852
|
-
}
|
|
1853
|
-
function clearAssetSource(asset) {
|
|
1854
|
-
asset.source = "";
|
|
1855
|
-
}
|
|
1856
|
-
function appendCss$1(baseCss, css) {
|
|
1857
|
-
if (baseCss.length === 0) return css;
|
|
1858
|
-
if (css.length === 0) return baseCss;
|
|
1859
|
-
return `${baseCss}\n${css}`;
|
|
1860
|
-
}
|
|
1861
|
-
function normalizeCssRecordIdentity(css) {
|
|
1862
|
-
return css.trim();
|
|
1863
|
-
}
|
|
1864
|
-
function hasNonCommentCss(css) {
|
|
1865
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1866
|
-
}
|
|
1867
|
-
function dedupeViteCssResults(records) {
|
|
1868
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1869
|
-
return records.filter((record) => {
|
|
1870
|
-
const key = `${normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
1871
|
-
if (seen.has(key)) return false;
|
|
1872
|
-
seen.add(key);
|
|
1873
|
-
return true;
|
|
1874
|
-
});
|
|
1754
|
+
function dedupeViteCssResults(records) {
|
|
1755
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1756
|
+
return records.filter((record) => {
|
|
1757
|
+
const key = `${normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
1758
|
+
if (seen.has(key)) return false;
|
|
1759
|
+
seen.add(key);
|
|
1760
|
+
return true;
|
|
1761
|
+
});
|
|
1875
1762
|
}
|
|
1876
1763
|
function removeTailwindSourceMediaWrappersRoot(root) {
|
|
1877
1764
|
let changed = false;
|
|
@@ -2047,20 +1934,495 @@ function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options =
|
|
|
2047
1934
|
const source = stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2048
1935
|
if (source.length > 0) linkedSources.add(source);
|
|
2049
1936
|
}
|
|
2050
|
-
if (linkedSources.size === 0) return 0;
|
|
2051
|
-
let removed = 0;
|
|
2052
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2053
|
-
if (output.type !== "asset") continue;
|
|
2054
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2055
|
-
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
2056
|
-
const source = stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2057
|
-
if (!linkedSources.has(source)) continue;
|
|
2058
|
-
delete bundle[bundleFile];
|
|
2059
|
-
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
2060
|
-
removed++;
|
|
1937
|
+
if (linkedSources.size === 0) return 0;
|
|
1938
|
+
let removed = 0;
|
|
1939
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1940
|
+
if (output.type !== "asset") continue;
|
|
1941
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
1942
|
+
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1943
|
+
const source = stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
1944
|
+
if (!linkedSources.has(source)) continue;
|
|
1945
|
+
delete bundle[bundleFile];
|
|
1946
|
+
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
1947
|
+
removed++;
|
|
1948
|
+
}
|
|
1949
|
+
return removed;
|
|
1950
|
+
}
|
|
1951
|
+
//#endregion
|
|
1952
|
+
//#region src/bundlers/vite/processed-css-assets/cleanup.ts
|
|
1953
|
+
function collectCssImportAtRuleCss(css) {
|
|
1954
|
+
if (!css.includes("@import")) return [];
|
|
1955
|
+
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
1956
|
+
if (fallbackImports.length > 0) return fallbackImports;
|
|
1957
|
+
try {
|
|
1958
|
+
const root = postcss.parse(css);
|
|
1959
|
+
const imports = [];
|
|
1960
|
+
root.each((node) => {
|
|
1961
|
+
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
1962
|
+
});
|
|
1963
|
+
return imports;
|
|
1964
|
+
} catch {
|
|
1965
|
+
return [];
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
function parseCssImportRequest(importCss) {
|
|
1969
|
+
const trimmed = importCss.trim();
|
|
1970
|
+
if (!trimmed.startsWith("@import")) return;
|
|
1971
|
+
return parseTailwindCssDirectiveRequest(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
1972
|
+
}
|
|
1973
|
+
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
1974
|
+
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
1975
|
+
const request = parseCssImportRequest(importCss);
|
|
1976
|
+
if (request === void 0) return false;
|
|
1977
|
+
if (isMiniProgramLocalCssImportRequest(request)) return true;
|
|
1978
|
+
return isStyleImportRequest(request) && !request.includes("/");
|
|
1979
|
+
}
|
|
1980
|
+
function restoreCssImportAtRules(source, filtered, file) {
|
|
1981
|
+
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
1982
|
+
if (imports.length === 0) return filtered;
|
|
1983
|
+
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
1984
|
+
if (missingImports.length === 0) return filtered;
|
|
1985
|
+
return appendCss$1(missingImports.join("\n"), filtered);
|
|
1986
|
+
}
|
|
1987
|
+
function removeCommentOnlyAtRules(css) {
|
|
1988
|
+
if (!css.includes("@")) return css;
|
|
1989
|
+
try {
|
|
1990
|
+
const root = postcss.parse(css);
|
|
1991
|
+
let changed = false;
|
|
1992
|
+
root.walkAtRules((atRule) => {
|
|
1993
|
+
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
1994
|
+
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
1995
|
+
atRule.remove();
|
|
1996
|
+
changed = true;
|
|
1997
|
+
});
|
|
1998
|
+
return changed ? root.toString() : css;
|
|
1999
|
+
} catch {
|
|
2000
|
+
return css;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2004
|
+
if (importedStyleFiles.size === 0) return [];
|
|
2005
|
+
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2006
|
+
const importedSources = [];
|
|
2007
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2008
|
+
if (output.type !== "asset") continue;
|
|
2009
|
+
const file = normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2010
|
+
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2011
|
+
importedSources.push(readAssetSource$2(output));
|
|
2012
|
+
}
|
|
2013
|
+
return importedSources;
|
|
2014
|
+
}
|
|
2015
|
+
function collectBundleAssetFiles(bundle) {
|
|
2016
|
+
const files = /* @__PURE__ */ new Set();
|
|
2017
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2018
|
+
if (output.type !== "asset") continue;
|
|
2019
|
+
files.add(normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2020
|
+
}
|
|
2021
|
+
return files;
|
|
2022
|
+
}
|
|
2023
|
+
function normalizeComparableStyleFile(file) {
|
|
2024
|
+
return normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2025
|
+
}
|
|
2026
|
+
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2027
|
+
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2028
|
+
return [
|
|
2029
|
+
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2030
|
+
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2031
|
+
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2032
|
+
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2033
|
+
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2034
|
+
}
|
|
2035
|
+
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2036
|
+
if (typeof file !== "string" || file.length === 0) return false;
|
|
2037
|
+
const fileKey = normalizeComparableStyleFile(file);
|
|
2038
|
+
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2039
|
+
}
|
|
2040
|
+
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2041
|
+
const opts = options.opts;
|
|
2042
|
+
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2043
|
+
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2044
|
+
if (context === void 0) return;
|
|
2045
|
+
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2046
|
+
...context,
|
|
2047
|
+
bundle,
|
|
2048
|
+
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2049
|
+
isMiniProgramStyleOutputFile,
|
|
2050
|
+
isRootStyleOutputFile,
|
|
2051
|
+
outputFile,
|
|
2052
|
+
sourceFile
|
|
2053
|
+
});
|
|
2054
|
+
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2055
|
+
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2056
|
+
const rootCssFiles = [];
|
|
2057
|
+
const matchedRootCssFiles = [];
|
|
2058
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2059
|
+
if (output.type !== "asset") continue;
|
|
2060
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
2061
|
+
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2062
|
+
rootCssFiles.push(file);
|
|
2063
|
+
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2064
|
+
}
|
|
2065
|
+
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2066
|
+
if (matchedRootCssFiles.length > 1) return;
|
|
2067
|
+
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2068
|
+
}
|
|
2069
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2070
|
+
const fileKey = normalizeOutputPathKey(file);
|
|
2071
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2072
|
+
return output.type === "asset" && normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2073
|
+
})?.[1];
|
|
2074
|
+
}
|
|
2075
|
+
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2076
|
+
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2077
|
+
if (importedStyleFiles.size === 0) return false;
|
|
2078
|
+
let hasNonImportNode = false;
|
|
2079
|
+
try {
|
|
2080
|
+
postcss.parse(css).each((node) => {
|
|
2081
|
+
if (node.type === "comment") return;
|
|
2082
|
+
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2083
|
+
});
|
|
2084
|
+
} catch {
|
|
2085
|
+
return false;
|
|
2086
|
+
}
|
|
2087
|
+
if (hasNonImportNode) return false;
|
|
2088
|
+
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2089
|
+
}
|
|
2090
|
+
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2091
|
+
const resolvedOutputFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2092
|
+
return resolvedOutputFile !== normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2093
|
+
}
|
|
2094
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2095
|
+
const resolvedFromFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2096
|
+
if (!markerFile) return resolvedFromFile;
|
|
2097
|
+
const resolvedFromMarker = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2098
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2099
|
+
return resolvedFromFile;
|
|
2100
|
+
}
|
|
2101
|
+
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2102
|
+
const fileKey = normalizeOutputPathKey(file);
|
|
2103
|
+
const outputFileKey = normalizeOutputPathKey(outputFile);
|
|
2104
|
+
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2105
|
+
}
|
|
2106
|
+
//#endregion
|
|
2107
|
+
//#region src/bundlers/vite/generate-bundle/sfc-style-source.ts
|
|
2108
|
+
const SFC_STYLE_SOURCE_EXTENSIONS = [
|
|
2109
|
+
".vue",
|
|
2110
|
+
".uvue",
|
|
2111
|
+
".nvue",
|
|
2112
|
+
".svelte",
|
|
2113
|
+
".mpx"
|
|
2114
|
+
];
|
|
2115
|
+
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
2116
|
+
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
2117
|
+
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
2118
|
+
function isSfcStyleSourceFile(file) {
|
|
2119
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
2120
|
+
return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
|
|
2121
|
+
}
|
|
2122
|
+
function extractSfcStyleBlocks(source) {
|
|
2123
|
+
const styleSources = [];
|
|
2124
|
+
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
2125
|
+
let index = 0;
|
|
2126
|
+
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2127
|
+
while (match !== null) {
|
|
2128
|
+
const attrs = match[1] ?? "";
|
|
2129
|
+
styleSources.push({
|
|
2130
|
+
attrs,
|
|
2131
|
+
index,
|
|
2132
|
+
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
2133
|
+
source: match[2] ?? ""
|
|
2134
|
+
});
|
|
2135
|
+
index += 1;
|
|
2136
|
+
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2137
|
+
}
|
|
2138
|
+
return styleSources;
|
|
2139
|
+
}
|
|
2140
|
+
function extractSfcStyleSources(source) {
|
|
2141
|
+
return extractSfcStyleBlocks(source).map((style) => style.source);
|
|
2142
|
+
}
|
|
2143
|
+
function hasSfcStyleSources(source) {
|
|
2144
|
+
return extractSfcStyleSources(source).length > 0;
|
|
2145
|
+
}
|
|
2146
|
+
function resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks) {
|
|
2147
|
+
const scopedStyleBlock = styleBlocks.find((style) => style.scoped);
|
|
2148
|
+
return scopedStyleBlock ? `${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true` : sourceFile;
|
|
2149
|
+
}
|
|
2150
|
+
function normalizeSfcStyleSourceForCompare(source) {
|
|
2151
|
+
return source.replace(/\r\n?/g, "\n").trim();
|
|
2152
|
+
}
|
|
2153
|
+
function resolveSfcStyleBlockLang(attrs) {
|
|
2154
|
+
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
2155
|
+
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
2156
|
+
}
|
|
2157
|
+
function createSfcStyleRequest(sourceFile, styleBlock) {
|
|
2158
|
+
const params = new URLSearchParams();
|
|
2159
|
+
params.set("vue", "");
|
|
2160
|
+
params.set("type", "style");
|
|
2161
|
+
params.set("index", String(styleBlock.index));
|
|
2162
|
+
if (styleBlock.scoped) params.set("scoped", "true");
|
|
2163
|
+
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
2164
|
+
if (lang) params.set("lang", lang);
|
|
2165
|
+
return `${sourceFile}?${params.toString()}`;
|
|
2166
|
+
}
|
|
2167
|
+
function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource, currentRequest) {
|
|
2168
|
+
if (!sfcSource) return sourceFile;
|
|
2169
|
+
const styleBlocks = extractSfcStyleBlocks(sfcSource);
|
|
2170
|
+
if (styleBlocks.length === 0) return sourceFile;
|
|
2171
|
+
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
2172
|
+
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
2173
|
+
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
2174
|
+
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
2175
|
+
});
|
|
2176
|
+
const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
|
|
2177
|
+
const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
|
|
2178
|
+
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
2179
|
+
}
|
|
2180
|
+
function hasTailwindGenerationSource(source, options = {}) {
|
|
2181
|
+
const allowRootDirectives = options.allowRootDirectives !== false;
|
|
2182
|
+
return hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
|
|
2183
|
+
}
|
|
2184
|
+
function hasTailwindGenerationSourceForFile(file, source) {
|
|
2185
|
+
if (isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
2186
|
+
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
2187
|
+
}
|
|
2188
|
+
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
2189
|
+
const sourceFile = resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug);
|
|
2190
|
+
if (!sourceFile) {
|
|
2191
|
+
debug("sfc style source infer skipped: no source file for %s", outputFile);
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
const source = getSfcSource?.(sourceFile);
|
|
2195
|
+
if (source == null) {
|
|
2196
|
+
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
const styleBlocks = extractSfcStyleBlocks(source);
|
|
2200
|
+
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
2201
|
+
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2202
|
+
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
2206
|
+
return {
|
|
2207
|
+
outputFile,
|
|
2208
|
+
rawSource,
|
|
2209
|
+
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
function normalizeSfcSourceFileForCompare(file) {
|
|
2213
|
+
return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2214
|
+
}
|
|
2215
|
+
function collectChunkModuleIds$1(output) {
|
|
2216
|
+
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
2217
|
+
return [
|
|
2218
|
+
output.facadeModuleId,
|
|
2219
|
+
...moduleIds,
|
|
2220
|
+
...Object.keys(output.modules ?? {})
|
|
2221
|
+
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
2222
|
+
}
|
|
2223
|
+
function normalizeSourceStyleModuleId(id) {
|
|
2224
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2225
|
+
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
2226
|
+
if (!path.isAbsolute(file)) return;
|
|
2227
|
+
return path.resolve(file);
|
|
2228
|
+
}
|
|
2229
|
+
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
2230
|
+
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
2231
|
+
if (cssMatcher?.(normalizedOutputFile)) {
|
|
2232
|
+
const extension = path.extname(normalizedOutputFile);
|
|
2233
|
+
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
2234
|
+
}
|
|
2235
|
+
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
2236
|
+
}
|
|
2237
|
+
function normalizeSfcModuleId(id) {
|
|
2238
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2239
|
+
if (!isSfcStyleSourceFile(file)) return;
|
|
2240
|
+
if (!path.isAbsolute(file)) return;
|
|
2241
|
+
return path.resolve(file);
|
|
2242
|
+
}
|
|
2243
|
+
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
2244
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
2245
|
+
if (!siblingJsFile) {
|
|
2246
|
+
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
const normalizedSiblingJsFile = normalizeOutputPathKey(siblingJsFile);
|
|
2250
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
2251
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
2252
|
+
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
2256
|
+
if (sourceFiles.length === 0) {
|
|
2257
|
+
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
2261
|
+
sourceFile,
|
|
2262
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
2263
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2264
|
+
debug("sfc style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
2265
|
+
const bestScore = scoredSources[0]?.score;
|
|
2266
|
+
if (!bestScore) return;
|
|
2267
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
2268
|
+
if (bestSources.length !== 1) {
|
|
2269
|
+
debug("sfc style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
return bestSources[0]?.sourceFile;
|
|
2273
|
+
}
|
|
2274
|
+
function resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug) {
|
|
2275
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, void 0);
|
|
2276
|
+
if (!siblingJsFile) {
|
|
2277
|
+
debug("source style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
const normalizedSiblingJsFile = normalizeOutputPathKey(siblingJsFile);
|
|
2281
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
2282
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
2283
|
+
debug("source style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSourceStyleModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
2287
|
+
if (sourceFiles.length === 0) {
|
|
2288
|
+
debug("source style sibling chunk skipped: no source style modules for %s -> %s", outputFile, siblingJsFile);
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
if (sourceFiles.length === 1) {
|
|
2292
|
+
debug("source style sibling chunk inferred from single css module: %s -> %s", outputFile, sourceFiles[0]);
|
|
2293
|
+
return sourceFiles[0];
|
|
2294
|
+
}
|
|
2295
|
+
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
2296
|
+
sourceFile,
|
|
2297
|
+
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
2298
|
+
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2299
|
+
debug("source style sibling chunk candidates: %s -> %s %O", outputFile, siblingJsFile, scoredSources);
|
|
2300
|
+
const bestScore = scoredSources[0]?.score;
|
|
2301
|
+
if (!bestScore) return;
|
|
2302
|
+
const bestSources = scoredSources.filter((item) => item.score === bestScore);
|
|
2303
|
+
if (bestSources.length !== 1) {
|
|
2304
|
+
debug("source style sibling chunk skipped: ambiguous best sources for %s %O", outputFile, bestSources);
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
return bestSources[0]?.sourceFile;
|
|
2308
|
+
}
|
|
2309
|
+
function resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, getSourceStyleSource, getSourceStyleSources, configuredSourceEntries, debug) {
|
|
2310
|
+
let sourceFile = resolveSourceStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, debug);
|
|
2311
|
+
let rawSource = sourceFile ? getSourceStyleSource?.(sourceFile) : void 0;
|
|
2312
|
+
if (!sourceFile || !rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2313
|
+
const cachedSources = [...getSourceStyleSources?.() ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
2314
|
+
file,
|
|
2315
|
+
source,
|
|
2316
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
2317
|
+
outputRoot,
|
|
2318
|
+
projectRoot: sourceRoot
|
|
2319
|
+
})
|
|
2320
|
+
}));
|
|
2321
|
+
const configuredSources = [...configuredSourceEntries ?? []].filter(([file, source]) => CSS_SOURCE_OUTPUT_EXT_RE.test(file) && hasTailwindGenerationSourceForFile(file, source)).map(([file, source]) => ({
|
|
2322
|
+
file,
|
|
2323
|
+
source,
|
|
2324
|
+
score: scoreTailwindV4CssSourceFileMatch(outputFile, file, {
|
|
2325
|
+
outputRoot,
|
|
2326
|
+
projectRoot: sourceRoot
|
|
2327
|
+
})
|
|
2328
|
+
}));
|
|
2329
|
+
const scoredSources = [...cachedSources, ...configuredSources].filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
2330
|
+
const bestScore = scoredSources[0]?.score;
|
|
2331
|
+
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
2332
|
+
if (bestSources.length === 1) {
|
|
2333
|
+
sourceFile = bestSources[0].file;
|
|
2334
|
+
rawSource = bestSources[0].source;
|
|
2335
|
+
debug("source style source inferred from cache: %s -> %s", outputFile, sourceFile);
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
if (!sourceFile || !rawSource) return;
|
|
2339
|
+
if (!hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2340
|
+
debug("source style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
return {
|
|
2344
|
+
outputFile,
|
|
2345
|
+
rawSource,
|
|
2346
|
+
sourceFile
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
//#endregion
|
|
2350
|
+
//#region src/bundlers/vite/generate-bundle/subpackages.ts
|
|
2351
|
+
function readBundleAssetSource(output) {
|
|
2352
|
+
if ("type" in output && output.type !== "asset") return;
|
|
2353
|
+
const source = output.source;
|
|
2354
|
+
if (typeof source === "string") return source;
|
|
2355
|
+
if (typeof source === "function") {
|
|
2356
|
+
const value = source.call(output);
|
|
2357
|
+
return typeof value === "string" ? value : value?.toString();
|
|
2358
|
+
}
|
|
2359
|
+
if (source != null && typeof source.toString === "function") return source.toString();
|
|
2360
|
+
}
|
|
2361
|
+
function normalizePackageRoot(root) {
|
|
2362
|
+
return normalizeOutputPathKey(root).replace(/\/+$/, "");
|
|
2363
|
+
}
|
|
2364
|
+
function collectMiniProgramSubpackageRoots(bundle) {
|
|
2365
|
+
let hasAppJson = false;
|
|
2366
|
+
const roots = /* @__PURE__ */ new Set();
|
|
2367
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
2368
|
+
const outputFile = output.fileName || file;
|
|
2369
|
+
if (path.basename(outputFile) !== "app.json") continue;
|
|
2370
|
+
const source = readBundleAssetSource(output);
|
|
2371
|
+
if (!source) continue;
|
|
2372
|
+
hasAppJson = true;
|
|
2373
|
+
try {
|
|
2374
|
+
const appJson = JSON.parse(source);
|
|
2375
|
+
const subPackages = Array.isArray(appJson.subPackages) ? appJson.subPackages : Array.isArray(appJson.subpackages) ? appJson.subpackages : [];
|
|
2376
|
+
for (const subPackage of subPackages) {
|
|
2377
|
+
if (typeof subPackage.root !== "string" || subPackage.root.length === 0) continue;
|
|
2378
|
+
roots.add(normalizePackageRoot(subPackage.root));
|
|
2379
|
+
}
|
|
2380
|
+
} catch {}
|
|
2381
|
+
}
|
|
2382
|
+
return hasAppJson ? roots : void 0;
|
|
2383
|
+
}
|
|
2384
|
+
function isSubpackageOutputFile(file, subpackageRoots) {
|
|
2385
|
+
const normalizedFile = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2386
|
+
for (const root of subpackageRoots) if (root.length > 0 && (normalizedFile === root || normalizedFile.startsWith(`${root}/`) || normalizedFile.endsWith(`/${root}`) || normalizedFile.includes(`/${root}/`))) return true;
|
|
2387
|
+
return false;
|
|
2388
|
+
}
|
|
2389
|
+
function resolveSubpackageSourceRootFromModuleId(moduleId, subpackageRoot) {
|
|
2390
|
+
const file = slash(path.resolve(moduleId.replace(/[?#].*$/, "")));
|
|
2391
|
+
const normalizedRoot = normalizePackageRoot(subpackageRoot);
|
|
2392
|
+
const rootSegment = `/${normalizedRoot}/`;
|
|
2393
|
+
const rootIndex = file.lastIndexOf(rootSegment);
|
|
2394
|
+
if (rootIndex >= 0) return file.slice(0, rootIndex + rootSegment.length - 1);
|
|
2395
|
+
const rootSuffix = `/${normalizedRoot}`;
|
|
2396
|
+
if (file.endsWith(rootSuffix)) return file;
|
|
2397
|
+
}
|
|
2398
|
+
function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, sourceBaseRoots) {
|
|
2399
|
+
const sourceRoots = /* @__PURE__ */ new Set();
|
|
2400
|
+
const sourceEntries = [];
|
|
2401
|
+
for (const entry of snapshot.entries) {
|
|
2402
|
+
if (entry.output.type !== "chunk" || !isSubpackageOutputFile(entry.file, subpackageRoots)) continue;
|
|
2403
|
+
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
2404
|
+
if (!matchedSubpackageRoot) continue;
|
|
2405
|
+
for (const moduleId of collectChunkModuleIds$1(entry.output)) {
|
|
2406
|
+
if (!path.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
2407
|
+
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
2408
|
+
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
2409
|
+
}
|
|
2061
2410
|
}
|
|
2062
|
-
|
|
2411
|
+
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
2412
|
+
base: sourceRoot,
|
|
2413
|
+
negated: false,
|
|
2414
|
+
pattern: "**/*"
|
|
2415
|
+
})));
|
|
2416
|
+
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => path.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
2417
|
+
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
2418
|
+
base: baseRoot,
|
|
2419
|
+
negated: false,
|
|
2420
|
+
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
2421
|
+
});
|
|
2422
|
+
return sourceEntries;
|
|
2063
2423
|
}
|
|
2424
|
+
//#endregion
|
|
2425
|
+
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2064
2426
|
const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
2065
2427
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2066
2428
|
function hasVueScopedAttr(value) {
|
|
@@ -2142,9 +2504,11 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2142
2504
|
const rules = /* @__PURE__ */ new Set();
|
|
2143
2505
|
const atRules = /* @__PURE__ */ new Set();
|
|
2144
2506
|
const declarationsBySelector = /* @__PURE__ */ new Map();
|
|
2507
|
+
const normalizedRuleCss = /* @__PURE__ */ new Set();
|
|
2145
2508
|
for (const source of cssSources) try {
|
|
2146
2509
|
const root = postcss.parse(source);
|
|
2147
2510
|
root.walkRules((rule) => {
|
|
2511
|
+
normalizedRuleCss.add(normalizeCssSignatureValue(rule.toString()));
|
|
2148
2512
|
const declarations = createDeclarationSignature(rule);
|
|
2149
2513
|
if (declarations.length === 0) return;
|
|
2150
2514
|
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
@@ -2162,7 +2526,16 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2162
2526
|
return {
|
|
2163
2527
|
rules,
|
|
2164
2528
|
atRules,
|
|
2165
|
-
declarationsBySelector
|
|
2529
|
+
declarationsBySelector,
|
|
2530
|
+
normalizedRuleCss
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
function prepareImportedCssCoverage(importedCssSources) {
|
|
2534
|
+
const sources = importedCssSources.map((source) => stripBundlerGeneratedCssMarkers(source).trim()).filter(Boolean);
|
|
2535
|
+
if (sources.length === 0) return;
|
|
2536
|
+
return {
|
|
2537
|
+
coverage: collectRootScopedComparableCssCoverage(sources),
|
|
2538
|
+
sources
|
|
2166
2539
|
};
|
|
2167
2540
|
}
|
|
2168
2541
|
function isRuleCoveredByRootCss(rule, coverage) {
|
|
@@ -2230,7 +2603,48 @@ function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile
|
|
|
2230
2603
|
}
|
|
2231
2604
|
function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
2232
2605
|
const rootSources = collectRootStyleBundleCssSources(bundle, file);
|
|
2233
|
-
|
|
2606
|
+
if (css.trim().length === 0) return css;
|
|
2607
|
+
const hasScopedCss = hasVueScopedAttr(css);
|
|
2608
|
+
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2609
|
+
const hasUnscopedMiniProgramPreflight = hasScopedCss && hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2610
|
+
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2611
|
+
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2612
|
+
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2613
|
+
let nextCss = css;
|
|
2614
|
+
try {
|
|
2615
|
+
const root = postcss.parse(css);
|
|
2616
|
+
let changed = false;
|
|
2617
|
+
root.walkRules((rule) => {
|
|
2618
|
+
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule))) {
|
|
2619
|
+
rule.remove();
|
|
2620
|
+
changed = true;
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2624
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || hasScopedTailwindGeneratedCss && isLikelyTailwindPropertyAtRule(atRule)) {
|
|
2625
|
+
atRule.remove();
|
|
2626
|
+
changed = true;
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2629
|
+
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
2630
|
+
atRule.remove();
|
|
2631
|
+
changed = true;
|
|
2632
|
+
}
|
|
2633
|
+
});
|
|
2634
|
+
root.walkComments((comment) => {
|
|
2635
|
+
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
2636
|
+
comment.remove();
|
|
2637
|
+
changed = true;
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
2641
|
+
const next = comment.next();
|
|
2642
|
+
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
2643
|
+
comment.remove();
|
|
2644
|
+
changed = true;
|
|
2645
|
+
});
|
|
2646
|
+
if (changed) nextCss = root.toString().trim();
|
|
2647
|
+
} catch {}
|
|
2234
2648
|
return hasNonCommentCss(nextCss) ? nextCss : "";
|
|
2235
2649
|
}
|
|
2236
2650
|
function removeDanglingCssSourceTraceComments(css) {
|
|
@@ -2270,6 +2684,8 @@ function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
|
2270
2684
|
}
|
|
2271
2685
|
return updated;
|
|
2272
2686
|
}
|
|
2687
|
+
//#endregion
|
|
2688
|
+
//#region src/bundlers/vite/processed-css-assets/injection-plan.ts
|
|
2273
2689
|
function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, options) {
|
|
2274
2690
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && normalizeOutputPathKey(options.outputFile) === normalizeOutputPathKey(targetFile);
|
|
2275
2691
|
if (options.injectIntoMain === false) return false;
|
|
@@ -2285,13 +2701,6 @@ function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputF
|
|
|
2285
2701
|
}
|
|
2286
2702
|
return isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) || isSourceRootPrefixedOutputFile(file, outputFile) && isRootStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType);
|
|
2287
2703
|
}
|
|
2288
|
-
function isRootStyleOutputFile(file) {
|
|
2289
|
-
const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2290
|
-
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
2291
|
-
}
|
|
2292
|
-
function isMiniProgramStyleOutputFile(file) {
|
|
2293
|
-
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
2294
|
-
}
|
|
2295
2704
|
function shouldPreserveMiniProgramImportShell(options, bundle, file, css) {
|
|
2296
2705
|
const context = createCssAssetPipelineContext(options, file, bundle);
|
|
2297
2706
|
return context !== void 0 && shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
@@ -2375,48 +2784,41 @@ function isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedSt
|
|
|
2375
2784
|
return false;
|
|
2376
2785
|
}
|
|
2377
2786
|
function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, records, options) {
|
|
2378
|
-
let removed = 0;
|
|
2379
2787
|
const targetFileKey = normalizeOutputPathKey(targetFile);
|
|
2380
2788
|
const targetIsRootWebStyle = isRootStyleOutputFile(targetFileKey) && !isMiniProgramStyleOutputFile(targetFileKey);
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2399
|
-
removed++;
|
|
2400
|
-
}
|
|
2789
|
+
const removableRecords = records.filter((record) => options.shouldRemoveInjectedSourceAsset?.(targetFile, record) === true);
|
|
2790
|
+
if (removableRecords.length === 0) return 0;
|
|
2791
|
+
const recordFileKeys = new Set(removableRecords.map((record) => normalizeOutputPathKey(record.file)));
|
|
2792
|
+
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
2793
|
+
let removed = 0;
|
|
2794
|
+
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
2795
|
+
if (candidateOutput.type !== "asset") continue;
|
|
2796
|
+
const candidateKey = normalizeOutputPathKey(getAssetFile$1(candidateFile, candidateOutput));
|
|
2797
|
+
if (candidateKey === targetFileKey || !isCssOutputFile(candidateKey)) continue;
|
|
2798
|
+
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
2799
|
+
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
2800
|
+
const candidateSource = readAssetSource$2(candidateOutput).trim();
|
|
2801
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || containsCssAfterMinify(targetCss, candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !hasNonCommentCss(filterExistingCssRules(targetCss, candidateSource).trim())))) continue;
|
|
2802
|
+
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
2803
|
+
else clearAssetSource(candidateOutput);
|
|
2804
|
+
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2805
|
+
removed++;
|
|
2401
2806
|
}
|
|
2402
2807
|
return removed;
|
|
2403
2808
|
}
|
|
2404
|
-
function removeCssCoveredByImportedViteResults(css, importedCssSources) {
|
|
2405
|
-
if (
|
|
2406
|
-
|
|
2407
|
-
if (importedCss.length === 0) return css;
|
|
2408
|
-
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, [importedCss], { exactOnly: true }));
|
|
2809
|
+
function removeCssCoveredByImportedViteResults(css, importedCssSources, prepared = prepareImportedCssCoverage(importedCssSources)) {
|
|
2810
|
+
if (!prepared) return css;
|
|
2811
|
+
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, prepared.sources, { exactOnly: true }, prepared.coverage));
|
|
2409
2812
|
}
|
|
2410
|
-
function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
2813
|
+
function removeCssRulesCoveredBySources(css, sources, options = {}, preparedCoverage) {
|
|
2411
2814
|
if (sources.length === 0 || css.trim().length === 0) return css;
|
|
2412
|
-
const coverage = collectRootScopedComparableCssCoverage(sources);
|
|
2413
|
-
|
|
2414
|
-
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coveredRuleCss.size === 0) return css;
|
|
2815
|
+
const coverage = preparedCoverage ?? collectRootScopedComparableCssCoverage(sources);
|
|
2816
|
+
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coverage.normalizedRuleCss.size === 0) return css;
|
|
2415
2817
|
try {
|
|
2416
2818
|
const root = postcss.parse(css);
|
|
2417
2819
|
let changed = false;
|
|
2418
2820
|
root.walkRules((rule) => {
|
|
2419
|
-
if (!
|
|
2821
|
+
if (!coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
|
|
2420
2822
|
rule.remove();
|
|
2421
2823
|
changed = true;
|
|
2422
2824
|
});
|
|
@@ -2425,168 +2827,8 @@ function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
|
2425
2827
|
return css;
|
|
2426
2828
|
}
|
|
2427
2829
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
for (const source of sources) try {
|
|
2431
|
-
postcss.parse(source).walkRules((rule) => {
|
|
2432
|
-
rules.add(normalizeCssSignatureValue(rule.toString()));
|
|
2433
|
-
});
|
|
2434
|
-
} catch {}
|
|
2435
|
-
return rules;
|
|
2436
|
-
}
|
|
2437
|
-
function collectCssImportAtRuleCss(css) {
|
|
2438
|
-
if (!css.includes("@import")) return [];
|
|
2439
|
-
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
2440
|
-
if (fallbackImports.length > 0) return fallbackImports;
|
|
2441
|
-
try {
|
|
2442
|
-
const root = postcss.parse(css);
|
|
2443
|
-
const imports = [];
|
|
2444
|
-
root.each((node) => {
|
|
2445
|
-
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
2446
|
-
});
|
|
2447
|
-
return imports;
|
|
2448
|
-
} catch {
|
|
2449
|
-
return [];
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
function parseCssImportRequest(importCss) {
|
|
2453
|
-
const trimmed = importCss.trim();
|
|
2454
|
-
if (!trimmed.startsWith("@import")) return;
|
|
2455
|
-
return parseTailwindCssDirectiveRequest(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
2456
|
-
}
|
|
2457
|
-
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
2458
|
-
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
2459
|
-
const request = parseCssImportRequest(importCss);
|
|
2460
|
-
if (request === void 0) return false;
|
|
2461
|
-
if (isMiniProgramLocalCssImportRequest(request)) return true;
|
|
2462
|
-
return isStyleImportRequest(request) && !request.includes("/");
|
|
2463
|
-
}
|
|
2464
|
-
function restoreCssImportAtRules(source, filtered, file) {
|
|
2465
|
-
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
2466
|
-
if (imports.length === 0) return filtered;
|
|
2467
|
-
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
2468
|
-
if (missingImports.length === 0) return filtered;
|
|
2469
|
-
return appendCss$1(missingImports.join("\n"), filtered);
|
|
2470
|
-
}
|
|
2471
|
-
function removeCommentOnlyAtRules(css) {
|
|
2472
|
-
if (!css.includes("@")) return css;
|
|
2473
|
-
try {
|
|
2474
|
-
const root = postcss.parse(css);
|
|
2475
|
-
let changed = false;
|
|
2476
|
-
root.walkAtRules((atRule) => {
|
|
2477
|
-
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2478
|
-
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2479
|
-
atRule.remove();
|
|
2480
|
-
changed = true;
|
|
2481
|
-
});
|
|
2482
|
-
return changed ? root.toString() : css;
|
|
2483
|
-
} catch {
|
|
2484
|
-
return css;
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2488
|
-
if (importedStyleFiles.size === 0) return [];
|
|
2489
|
-
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2490
|
-
const importedSources = [];
|
|
2491
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2492
|
-
if (output.type !== "asset") continue;
|
|
2493
|
-
const file = normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2494
|
-
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2495
|
-
importedSources.push(readAssetSource$2(output));
|
|
2496
|
-
}
|
|
2497
|
-
return importedSources;
|
|
2498
|
-
}
|
|
2499
|
-
function collectBundleAssetFiles(bundle) {
|
|
2500
|
-
const files = /* @__PURE__ */ new Set();
|
|
2501
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2502
|
-
if (output.type !== "asset") continue;
|
|
2503
|
-
files.add(normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2504
|
-
}
|
|
2505
|
-
return files;
|
|
2506
|
-
}
|
|
2507
|
-
function normalizeComparableStyleFile(file) {
|
|
2508
|
-
return normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2509
|
-
}
|
|
2510
|
-
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2511
|
-
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2512
|
-
return [
|
|
2513
|
-
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2514
|
-
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2515
|
-
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2516
|
-
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2517
|
-
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2518
|
-
}
|
|
2519
|
-
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2520
|
-
if (typeof file !== "string" || file.length === 0) return false;
|
|
2521
|
-
const fileKey = normalizeComparableStyleFile(file);
|
|
2522
|
-
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2523
|
-
}
|
|
2524
|
-
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2525
|
-
const opts = options.opts;
|
|
2526
|
-
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2527
|
-
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2528
|
-
if (context === void 0) return;
|
|
2529
|
-
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2530
|
-
...context,
|
|
2531
|
-
bundle,
|
|
2532
|
-
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2533
|
-
isMiniProgramStyleOutputFile,
|
|
2534
|
-
isRootStyleOutputFile,
|
|
2535
|
-
outputFile,
|
|
2536
|
-
sourceFile
|
|
2537
|
-
});
|
|
2538
|
-
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2539
|
-
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2540
|
-
const rootCssFiles = [];
|
|
2541
|
-
const matchedRootCssFiles = [];
|
|
2542
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2543
|
-
if (output.type !== "asset") continue;
|
|
2544
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2545
|
-
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2546
|
-
rootCssFiles.push(file);
|
|
2547
|
-
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2548
|
-
}
|
|
2549
|
-
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2550
|
-
if (matchedRootCssFiles.length > 1) return;
|
|
2551
|
-
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2552
|
-
}
|
|
2553
|
-
function findBundleAssetByOutputFile(bundle, file) {
|
|
2554
|
-
const fileKey = normalizeOutputPathKey(file);
|
|
2555
|
-
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2556
|
-
return output.type === "asset" && normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2557
|
-
})?.[1];
|
|
2558
|
-
}
|
|
2559
|
-
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2560
|
-
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2561
|
-
if (importedStyleFiles.size === 0) return false;
|
|
2562
|
-
let hasNonImportNode = false;
|
|
2563
|
-
try {
|
|
2564
|
-
postcss.parse(css).each((node) => {
|
|
2565
|
-
if (node.type === "comment") return;
|
|
2566
|
-
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2567
|
-
});
|
|
2568
|
-
} catch {
|
|
2569
|
-
return false;
|
|
2570
|
-
}
|
|
2571
|
-
if (hasNonImportNode) return false;
|
|
2572
|
-
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2573
|
-
}
|
|
2574
|
-
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2575
|
-
const resolvedOutputFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2576
|
-
return resolvedOutputFile !== normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2577
|
-
}
|
|
2578
|
-
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2579
|
-
const resolvedFromFile = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2580
|
-
if (!markerFile) return resolvedFromFile;
|
|
2581
|
-
const resolvedFromMarker = normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2582
|
-
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2583
|
-
return resolvedFromFile;
|
|
2584
|
-
}
|
|
2585
|
-
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2586
|
-
const fileKey = normalizeOutputPathKey(file);
|
|
2587
|
-
const outputFileKey = normalizeOutputPathKey(outputFile);
|
|
2588
|
-
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2589
|
-
}
|
|
2830
|
+
//#endregion
|
|
2831
|
+
//#region src/bundlers/vite/processed-css-assets/collector.ts
|
|
2590
2832
|
function collectViteProcessedCssAssetResults(bundle, options) {
|
|
2591
2833
|
let collected = 0;
|
|
2592
2834
|
const existingAssetFiles = collectBundleAssetFiles(bundle);
|
|
@@ -2656,8 +2898,14 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2656
2898
|
return collected;
|
|
2657
2899
|
}
|
|
2658
2900
|
function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
2901
|
+
const measure = (name, task) => {
|
|
2902
|
+
const startedAt = performance.now();
|
|
2903
|
+
const result = task();
|
|
2904
|
+
options.recordTimingDetail?.(`finalize.processedCss.inject.${name}`, startedAt);
|
|
2905
|
+
return result;
|
|
2906
|
+
};
|
|
2659
2907
|
const transformCss = (css, file) => options.transformCss?.(css, file) ?? css;
|
|
2660
|
-
const viteCssResults = dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2908
|
+
const viteCssResults = measure("prepareResults", () => dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2661
2909
|
return typeof record === "string" ? {
|
|
2662
2910
|
file,
|
|
2663
2911
|
css: record,
|
|
@@ -2671,7 +2919,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2671
2919
|
})).map((record) => ({
|
|
2672
2920
|
...record,
|
|
2673
2921
|
css: transformCss(record.css, record.outputFile ?? record.file)
|
|
2674
|
-
})).filter((record) => record.css.length > 0);
|
|
2922
|
+
})).filter((record) => record.css.length > 0));
|
|
2675
2923
|
let injected = 0;
|
|
2676
2924
|
for (const [bundleFile, bundleOutput] of Object.entries(bundle)) {
|
|
2677
2925
|
let output = bundleOutput;
|
|
@@ -2697,16 +2945,19 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2697
2945
|
}
|
|
2698
2946
|
const fileKey = normalizeOutputPathKey(file);
|
|
2699
2947
|
const mainFileKey = normalizeOutputPathKey(file);
|
|
2700
|
-
const normalizedOriginalCss = normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file);
|
|
2948
|
+
const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file));
|
|
2701
2949
|
let nextCss = normalizedOriginalCss.css;
|
|
2702
2950
|
const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
|
|
2703
2951
|
const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
|
|
2704
|
-
|
|
2952
|
+
const importedBundleCssCoverage = prepareImportedCssCoverage(importedBundleCssSources);
|
|
2953
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, importedBundleCssSources, importedBundleCssCoverage);
|
|
2705
2954
|
const importedViteCssResults = viteCssResults.filter((record) => isViteProcessedCssResultImported(record, importedStyleFiles));
|
|
2706
2955
|
const bundleAssetFiles = collectBundleAssetFiles(bundle);
|
|
2707
2956
|
const uncoveredImportedViteCssResults = importedViteCssResults.filter((record) => !isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedStyleFiles, bundleAssetFiles));
|
|
2708
2957
|
const importedCssSources = [...importedBundleCssSources, ...uncoveredImportedViteCssResults.map((record) => record.css)];
|
|
2709
|
-
|
|
2958
|
+
const uncoveredImportedCssSources = uncoveredImportedViteCssResults.map((record) => record.css);
|
|
2959
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, uncoveredImportedCssSources, prepareImportedCssCoverage(uncoveredImportedCssSources));
|
|
2960
|
+
const importedCssCoverage = prepareImportedCssCoverage(importedCssSources);
|
|
2710
2961
|
const targetViteCssResults = [];
|
|
2711
2962
|
for (const record of viteCssResults) {
|
|
2712
2963
|
if (!isRootStyleOutputFile(file)) {
|
|
@@ -2715,41 +2966,40 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2715
2966
|
if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
|
|
2716
2967
|
if (isViteProcessedCssResultImported(record, importedStyleFiles)) continue;
|
|
2717
2968
|
targetViteCssResults.push(record);
|
|
2718
|
-
let css = normalizeInjectableCssForTarget(stripBundlerGeneratedCssMarkers(record.css).trim(), file).trim();
|
|
2719
|
-
css = removeCssCoveredByImportedViteResults(css, importedCssSources).trim();
|
|
2969
|
+
let css = measure("normalizeRecord", () => normalizeInjectableCssForTarget(stripBundlerGeneratedCssMarkers(record.css).trim(), file).trim());
|
|
2970
|
+
css = measure("importCoverage", () => removeCssCoveredByImportedViteResults(css, importedCssSources, importedCssCoverage).trim());
|
|
2720
2971
|
if (css.length === 0) continue;
|
|
2721
|
-
const mergedLayerCss = mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
2972
|
+
const mergedLayerCss = measure("mergeLayers", () => mergeMarkedUserLayerComponentsCss(nextCss, css));
|
|
2722
2973
|
if (mergedLayerCss.merged) {
|
|
2723
2974
|
nextCss = mergedLayerCss.css;
|
|
2724
2975
|
css = extractMarkedUserLayerComponentsCss(css).rest.trim();
|
|
2725
2976
|
if (css.length === 0) continue;
|
|
2726
2977
|
}
|
|
2727
|
-
|
|
2728
|
-
if (containsCssAfterMinify(nextCss, css)) continue;
|
|
2729
|
-
const mergedPreflightDeclarations = mergeMiniProgramPreflightRuleDeclarations(nextCss, css);
|
|
2978
|
+
const mergedPreflightDeclarations = measure("mergePreflight", () => mergeMiniProgramPreflightRuleDeclarations(nextCss, css));
|
|
2730
2979
|
if (mergedPreflightDeclarations.changed) {
|
|
2731
2980
|
nextCss = mergedPreflightDeclarations.baseCss;
|
|
2732
2981
|
css = mergedPreflightDeclarations.css.trim();
|
|
2733
2982
|
if (css.length === 0) continue;
|
|
2734
2983
|
}
|
|
2735
|
-
const mergedThemeScopeDeclarations = mergeMiniProgramThemeScopeRuleDeclarations(nextCss, css);
|
|
2984
|
+
const mergedThemeScopeDeclarations = measure("mergeTheme", () => mergeMiniProgramThemeScopeRuleDeclarations(nextCss, css));
|
|
2736
2985
|
if (mergedThemeScopeDeclarations.changed) {
|
|
2737
2986
|
nextCss = mergedThemeScopeDeclarations.baseCss;
|
|
2738
2987
|
css = mergedThemeScopeDeclarations.css.trim();
|
|
2739
2988
|
if (css.length === 0) continue;
|
|
2740
2989
|
}
|
|
2741
|
-
const mergedRuleDeclarations = mergeCoveredCssRuleDeclarations(nextCss, css);
|
|
2990
|
+
const mergedRuleDeclarations = measure("mergeDeclarations", () => mergeCoveredCssRuleDeclarations(nextCss, css));
|
|
2742
2991
|
if (mergedRuleDeclarations.changed) {
|
|
2743
2992
|
nextCss = mergedRuleDeclarations.baseCss;
|
|
2744
2993
|
css = mergedRuleDeclarations.css.trim();
|
|
2745
2994
|
if (css.length === 0) continue;
|
|
2746
2995
|
}
|
|
2747
|
-
const missingCss = filterExistingCssRules(nextCss, css);
|
|
2748
|
-
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || containsCssAfterMinify(nextCss, missingCss)) continue;
|
|
2996
|
+
const missingCss = measure("filterRules", () => filterExistingCssRules(nextCss, css));
|
|
2997
|
+
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || measure("containsMissing", () => containsCssAfterMinify(nextCss, missingCss))) continue;
|
|
2749
2998
|
nextCss = appendCss$1(nextCss, missingCss);
|
|
2750
2999
|
}
|
|
2751
3000
|
const finalImportedCssSources = collectImportedBundleCssSources(bundle, collectImportedStyleFiles(originalSource, file));
|
|
2752
|
-
|
|
3001
|
+
const finalImportedCssCoverage = prepareImportedCssCoverage(finalImportedCssSources);
|
|
3002
|
+
nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
|
|
2753
3003
|
if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
|
|
2754
3004
|
if (nextCss !== originalSource) {
|
|
2755
3005
|
output.source = nextCss;
|
|
@@ -2758,24 +3008,13 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2758
3008
|
options.onUpdate?.(file, originalSource, nextCss);
|
|
2759
3009
|
options.debug?.("inject vite-processed css into main css asset: %s bytes=%d", file, nextCss.length);
|
|
2760
3010
|
}
|
|
2761
|
-
const removedSources = removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options);
|
|
3011
|
+
const removedSources = measure("removeSources", () => removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options));
|
|
2762
3012
|
if (nextCss === originalSource && removedSources === 0) continue;
|
|
2763
3013
|
injected++;
|
|
2764
3014
|
}
|
|
2765
3015
|
return injected;
|
|
2766
3016
|
}
|
|
2767
3017
|
//#endregion
|
|
2768
|
-
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
2769
|
-
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
2770
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
2771
|
-
if (!output.fileName || output.fileName === file) continue;
|
|
2772
|
-
const existing = bundle[output.fileName];
|
|
2773
|
-
if (existing != null && existing !== output) continue;
|
|
2774
|
-
bundle[output.fileName] = output;
|
|
2775
|
-
delete bundle[file];
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
//#endregion
|
|
2779
3018
|
//#region src/bundlers/vite/generate-bundle/final-css-assets.ts
|
|
2780
3019
|
function readAssetSource$1(output) {
|
|
2781
3020
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
@@ -2958,6 +3197,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
2958
3197
|
...cssHandlerOptions,
|
|
2959
3198
|
isMainChunk: false
|
|
2960
3199
|
},
|
|
3200
|
+
frameworkPostcssStage: "complete",
|
|
2961
3201
|
getSourceCandidatesForEntries,
|
|
2962
3202
|
styleHandler,
|
|
2963
3203
|
debug
|
|
@@ -3027,7 +3267,7 @@ function pruneLastCssResults(resultByFile, sourceHashByFile, activeFiles) {
|
|
|
3027
3267
|
}
|
|
3028
3268
|
}
|
|
3029
3269
|
//#endregion
|
|
3030
|
-
//#region src/bundlers/vite/generate-bundle/finalize.ts
|
|
3270
|
+
//#region src/bundlers/vite/generate-bundle/finalize/root-import-shell.ts
|
|
3031
3271
|
function readAssetSource(asset) {
|
|
3032
3272
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
3033
3273
|
}
|
|
@@ -3116,6 +3356,8 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
3116
3356
|
}
|
|
3117
3357
|
return updated;
|
|
3118
3358
|
}
|
|
3359
|
+
//#endregion
|
|
3360
|
+
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
3119
3361
|
async function finalizeGenerateBundle(options) {
|
|
3120
3362
|
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
3121
3363
|
const tasksStart = performance.now();
|
|
@@ -3128,6 +3370,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3128
3370
|
await Promise.all(tasks);
|
|
3129
3371
|
recordTimingDetail("tasks", tasksStart);
|
|
3130
3372
|
for (const apply of pendingLinkedUpdates) apply();
|
|
3373
|
+
const uniAppXPostCssStartedAt = performance.now();
|
|
3131
3374
|
const applyStyleSources = await handleUniAppXPostCssTasks({
|
|
3132
3375
|
bundle,
|
|
3133
3376
|
debug,
|
|
@@ -3143,7 +3386,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3143
3386
|
runtimeState,
|
|
3144
3387
|
styleHandler
|
|
3145
3388
|
});
|
|
3389
|
+
recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
|
|
3146
3390
|
const syncViteProcessedCssIntoMainCssAssets = () => {
|
|
3391
|
+
const collectStartedAt = performance.now();
|
|
3147
3392
|
collectViteProcessedCssAssetResults(bundle, {
|
|
3148
3393
|
opts,
|
|
3149
3394
|
cssPipelineStrategy,
|
|
@@ -3157,7 +3402,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3157
3402
|
transformCss: transformWebTargetCss,
|
|
3158
3403
|
debug
|
|
3159
3404
|
});
|
|
3160
|
-
|
|
3405
|
+
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
3406
|
+
const injectStartedAt = performance.now();
|
|
3407
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
3161
3408
|
opts,
|
|
3162
3409
|
cssPipelineStrategy,
|
|
3163
3410
|
createCssPipelineContext,
|
|
@@ -3171,16 +3418,22 @@ async function finalizeGenerateBundle(options) {
|
|
|
3171
3418
|
return normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
3172
3419
|
},
|
|
3173
3420
|
debug,
|
|
3174
|
-
onUpdate
|
|
3421
|
+
onUpdate,
|
|
3422
|
+
recordTimingDetail
|
|
3175
3423
|
});
|
|
3424
|
+
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
3425
|
+
return injected;
|
|
3176
3426
|
};
|
|
3427
|
+
const processedCssStartedAt = performance.now();
|
|
3177
3428
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3178
3429
|
if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
|
|
3179
3430
|
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
|
|
3180
3431
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3181
3432
|
}
|
|
3433
|
+
recordTimingDetail("finalize.processedCss", processedCssStartedAt);
|
|
3182
3434
|
const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
|
|
3183
3435
|
const finalizeCssPipelineContext = createFinalizeCssPipelineContext();
|
|
3436
|
+
const rootCssStartedAt = performance.now();
|
|
3184
3437
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
3185
3438
|
cssMatcher: opts.cssMatcher,
|
|
3186
3439
|
debug,
|
|
@@ -3209,6 +3462,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3209
3462
|
isWebGeneratorTarget,
|
|
3210
3463
|
outDir
|
|
3211
3464
|
}) === true) removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, { debug });
|
|
3465
|
+
recordTimingDetail("finalize.rootCss", rootCssStartedAt);
|
|
3466
|
+
const finalCssAssetsStartedAt = performance.now();
|
|
3212
3467
|
await finalizeMiniProgramCssAssets(bundle, {
|
|
3213
3468
|
cssMatcher: opts.cssMatcher,
|
|
3214
3469
|
debug,
|
|
@@ -3219,6 +3474,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3219
3474
|
recordCssAssetResult,
|
|
3220
3475
|
styleHandler
|
|
3221
3476
|
});
|
|
3477
|
+
recordTimingDetail("finalize.cssAssets", finalCssAssetsStartedAt);
|
|
3478
|
+
const webCompatStartedAt = performance.now();
|
|
3222
3479
|
if (finalizeCssPipelineContext !== void 0 && cssPipelineStrategy?.shouldApplyFinalWebviewCssCompat?.({
|
|
3223
3480
|
...finalizeCssPipelineContext,
|
|
3224
3481
|
bundleFiles: Object.keys(bundle),
|
|
@@ -3230,6 +3487,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3230
3487
|
opts,
|
|
3231
3488
|
recordCssAssetResult
|
|
3232
3489
|
});
|
|
3490
|
+
recordTimingDetail("finalize.webCompat", webCompatStartedAt);
|
|
3233
3491
|
const stateUpdateStart = performance.now();
|
|
3234
3492
|
updateBundleBuildState(state, snapshot, useIncrementalMode ? linkedByEntry ?? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map(), { incremental: useIncrementalMode });
|
|
3235
3493
|
state.generatorCandidateSignature = generatorCandidateSignature;
|
|
@@ -3343,11 +3601,12 @@ function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
|
3343
3601
|
//#region src/bundlers/vite/generate-bundle/html-processing.ts
|
|
3344
3602
|
function processHtmlBundleEntry(options) {
|
|
3345
3603
|
const { cache, context, debug, dynamicRetryCandidates, file, metrics, onUpdate, originalEntrySource, originalSource, rememberProcessCacheKey, resolveCurrentSourceCandidateSource, tasks, templateHandler, timeTask, transformRuntime, transformRuntimeSignature } = options;
|
|
3346
|
-
const
|
|
3347
|
-
const
|
|
3348
|
-
const
|
|
3604
|
+
const currentBundleSource = originalEntrySource;
|
|
3605
|
+
const candidateSource = resolveCurrentSourceCandidateSource(file) ?? currentBundleSource;
|
|
3606
|
+
const currentRawDynamicCandidates = /* @__PURE__ */ new Set([...collectUnescapedDynamicCandidates(candidateSource), ...collectUnescapedDynamicCandidates(currentBundleSource)]);
|
|
3607
|
+
const templateRuntime = currentRawDynamicCandidates.size > 0 ? /* @__PURE__ */ new Set([...transformRuntime, ...currentRawDynamicCandidates]) : transformRuntime;
|
|
3349
3608
|
const templateRuntimeSignature = templateRuntime === transformRuntime ? transformRuntimeSignature : createCandidateSignature(templateRuntime);
|
|
3350
|
-
const htmlProcessHash = `${cache.computeHash(
|
|
3609
|
+
const htmlProcessHash = `${cache.computeHash(currentBundleSource)}:${cache.computeHash(createRuntimeAffectingSourceSignature(currentBundleSource, "html"))}:${templateRuntimeSignature}`;
|
|
3351
3610
|
const cacheKey = `${file}:html:${htmlProcessHash}`;
|
|
3352
3611
|
const hashKey = cacheKey;
|
|
3353
3612
|
rememberProcessCacheKey(cacheKey, hashKey);
|
|
@@ -3365,7 +3624,7 @@ function processHtmlBundleEntry(options) {
|
|
|
3365
3624
|
},
|
|
3366
3625
|
async transform() {
|
|
3367
3626
|
const start = performance.now();
|
|
3368
|
-
let transformed = await templateHandler(
|
|
3627
|
+
let transformed = await templateHandler(currentBundleSource, { runtimeSet: templateRuntime });
|
|
3369
3628
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
3370
3629
|
let retryRuntimeSet;
|
|
3371
3630
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
@@ -3376,13 +3635,13 @@ function processHtmlBundleEntry(options) {
|
|
|
3376
3635
|
}
|
|
3377
3636
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
3378
3637
|
logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
3379
|
-
transformed = await templateHandler(
|
|
3638
|
+
transformed = await templateHandler(currentBundleSource, { runtimeSet: retryRuntimeSet });
|
|
3380
3639
|
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
3381
3640
|
if (unresolvedDynamicCandidates.length > 0) logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
3382
3641
|
}
|
|
3383
3642
|
metrics.html.elapsed += measureElapsed(start);
|
|
3384
3643
|
metrics.html.transformed++;
|
|
3385
|
-
onUpdate(file,
|
|
3644
|
+
onUpdate(file, currentBundleSource, transformed);
|
|
3386
3645
|
debug("html handle: %s", file);
|
|
3387
3646
|
return { result: transformed };
|
|
3388
3647
|
}
|
|
@@ -3488,7 +3747,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
3488
3747
|
//#region src/uni-app-x/vite.ts
|
|
3489
3748
|
let transformUVuePromise;
|
|
3490
3749
|
function loadTransformUVue() {
|
|
3491
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
3750
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-B_KM9sLX.mjs").then((mod) => mod.transformUVue));
|
|
3492
3751
|
return transformUVuePromise;
|
|
3493
3752
|
}
|
|
3494
3753
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -3529,8 +3788,8 @@ function createUniAppXPlugins(options) {
|
|
|
3529
3788
|
let componentLocalStyleEnabled;
|
|
3530
3789
|
const harmonyApplyStyleSources = /* @__PURE__ */ new Set();
|
|
3531
3790
|
const harmonyApplyUtilities = /* @__PURE__ */ new Set();
|
|
3532
|
-
function rememberHarmonyApplySource(code) {
|
|
3533
|
-
const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code);
|
|
3791
|
+
function rememberHarmonyApplySource(code, id) {
|
|
3792
|
+
const styleSources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
3534
3793
|
if (styleSources.length === 0) return;
|
|
3535
3794
|
for (const styleSource of styleSources) {
|
|
3536
3795
|
harmonyApplyStyleSources.add(styleSource);
|
|
@@ -3563,7 +3822,7 @@ function createUniAppXPlugins(options) {
|
|
|
3563
3822
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
3564
3823
|
if (isCssModuleExport(code)) return;
|
|
3565
3824
|
const shouldGenerateCss = hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
3566
|
-
rememberHarmonyApplySource(code);
|
|
3825
|
+
rememberHarmonyApplySource(code, id);
|
|
3567
3826
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
|
|
3568
3827
|
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
|
|
3569
3828
|
const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
|
|
@@ -3623,7 +3882,7 @@ function createUniAppXPlugins(options) {
|
|
|
3623
3882
|
async transform(code, id) {
|
|
3624
3883
|
if (!isEnabled()) return;
|
|
3625
3884
|
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
3626
|
-
rememberHarmonyApplySource(code);
|
|
3885
|
+
rememberHarmonyApplySource(code, id);
|
|
3627
3886
|
const resolvedConfig = getResolvedConfig();
|
|
3628
3887
|
const isServeCommand = resolvedConfig?.command === "serve";
|
|
3629
3888
|
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
@@ -3632,13 +3891,19 @@ function createUniAppXPlugins(options) {
|
|
|
3632
3891
|
const transformUVue = await loadTransformUVue();
|
|
3633
3892
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
3634
3893
|
const enablePageLocalStyle = shouldEnableHarmonyPageLocalStyle();
|
|
3635
|
-
if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle)
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3894
|
+
if (customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle) {
|
|
3895
|
+
const result = transformUVue(code, id, jsHandler, currentRuntimeSet, omitUndefined({
|
|
3896
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
3897
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
3898
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
3899
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
3900
|
+
}));
|
|
3901
|
+
if (result?.code) rememberHarmonyApplySource(result.code, id);
|
|
3902
|
+
return result;
|
|
3903
|
+
}
|
|
3904
|
+
const result = transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
3905
|
+
if (result?.code) rememberHarmonyApplySource(result.code, id);
|
|
3906
|
+
return result;
|
|
3642
3907
|
},
|
|
3643
3908
|
async handleHotUpdate(ctx) {
|
|
3644
3909
|
if (!isEnabled()) return;
|
|
@@ -3668,7 +3933,7 @@ function createUniAppXPlugins(options) {
|
|
|
3668
3933
|
const getAssetSource = createUniAppXBundleAssetSourceGetter(bundle);
|
|
3669
3934
|
if (isHarmonyTarget) {
|
|
3670
3935
|
const cssSources = [];
|
|
3671
|
-
const applyStyleSources = [...harmonyApplyStyleSources
|
|
3936
|
+
const applyStyleSources = harmonyApplyStyleSources.size > 0 ? [...harmonyApplyStyleSources] : collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
3672
3937
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApplyUtilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
3673
3938
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
3674
3939
|
const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process$1.cwd(), "uni-app-x-harmony-apply.css");
|
|
@@ -3946,17 +4211,25 @@ function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGenerator
|
|
|
3946
4211
|
}
|
|
3947
4212
|
//#endregion
|
|
3948
4213
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
4214
|
+
function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
4215
|
+
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
4216
|
+
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
4217
|
+
}
|
|
3949
4218
|
async function processRememberedCssReplay(options) {
|
|
3950
4219
|
const { addWatchFile, activeViteCssCacheFiles, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, refreshRememberedCssSource, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
3951
4220
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
3952
4221
|
for (const [outputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
3953
4222
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
3954
|
-
const
|
|
4223
|
+
const replayableRememberedGroup = (await Promise.all(rememberedGroup.map(async (item) => ({
|
|
3955
4224
|
key: item.key,
|
|
3956
4225
|
remembered: await refreshRememberedCssSource?.(item.remembered) ?? item.remembered
|
|
3957
|
-
})))
|
|
3958
|
-
|
|
3959
|
-
|
|
4226
|
+
})))).filter(({ remembered }) => {
|
|
4227
|
+
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
4228
|
+
if (shouldSkip) debug("css replay skip raw source style: %s -> %s", remembered.sourceFile, outputFile);
|
|
4229
|
+
return !shouldSkip;
|
|
4230
|
+
});
|
|
4231
|
+
const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
|
|
4232
|
+
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
3960
4233
|
if (!rememberedCssSource) continue;
|
|
3961
4234
|
const { rawSource, sourceFile } = rememberedCssSource;
|
|
3962
4235
|
const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
@@ -4031,6 +4304,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4031
4304
|
outputFile,
|
|
4032
4305
|
cssHandlerOptions,
|
|
4033
4306
|
cssUserHandlerOptions: getCssUserHandlerOptions(sourceFile),
|
|
4307
|
+
frameworkPostcssStage: "complete",
|
|
4034
4308
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
4035
4309
|
generatorPlatform,
|
|
4036
4310
|
styleHandler,
|
|
@@ -4261,13 +4535,12 @@ function createSubpackageSourceCandidateScope(options) {
|
|
|
4261
4535
|
function normalizeSourceCandidatePathKey(file) {
|
|
4262
4536
|
return normalizeOutputPathKey(path.resolve(file));
|
|
4263
4537
|
}
|
|
4264
|
-
function
|
|
4265
|
-
const { file,
|
|
4538
|
+
function createSourceCandidateFiles(options) {
|
|
4539
|
+
const { file, outDir, rootDir, sourceRoot } = options;
|
|
4266
4540
|
const cleanedFile = file.replace(/[?#].*$/, "");
|
|
4267
|
-
const normalizedFile = normalizeOutputPathKey(cleanedFile);
|
|
4268
4541
|
const absoluteFile = path.isAbsolute(cleanedFile) ? cleanedFile : path.resolve(rootDir, cleanedFile);
|
|
4269
4542
|
const relativeFromOutDir = normalizeOutputPathKey(path.relative(outDir, absoluteFile));
|
|
4270
|
-
|
|
4543
|
+
return [
|
|
4271
4544
|
sourceRoot ? path.resolve(sourceRoot, file) : void 0,
|
|
4272
4545
|
path.resolve(rootDir, file),
|
|
4273
4546
|
path.resolve(path.dirname(outDir), file),
|
|
@@ -4276,6 +4549,33 @@ function resolveCurrentSourceCandidateSource(options) {
|
|
|
4276
4549
|
!path.isAbsolute(relativeFromOutDir) && !relativeFromOutDir.startsWith("../") ? path.resolve(path.dirname(outDir), relativeFromOutDir) : void 0,
|
|
4277
4550
|
file
|
|
4278
4551
|
];
|
|
4552
|
+
}
|
|
4553
|
+
function resolveCurrentSourceCandidateFile(options) {
|
|
4554
|
+
const sourceCandidates = createSourceCandidateFiles(options);
|
|
4555
|
+
for (const candidate of sourceCandidates) if (candidate && options.getSourceCandidateSource?.(candidate) !== void 0) return candidate;
|
|
4556
|
+
const normalizedFile = normalizeOutputPathKey(options.file.replace(/[?#].*$/, ""));
|
|
4557
|
+
let bestMatch;
|
|
4558
|
+
const normalizedSourceCandidates = sourceCandidates.filter((candidate) => Boolean(candidate)).map((candidate) => ({
|
|
4559
|
+
absolute: path.isAbsolute(candidate),
|
|
4560
|
+
key: normalizeSourceCandidatePathKey(candidate)
|
|
4561
|
+
}));
|
|
4562
|
+
for (const [sourceFile] of options.getSourceCandidateSources?.() ?? []) {
|
|
4563
|
+
const normalizedSourceFile = normalizeSourceCandidatePathKey(sourceFile);
|
|
4564
|
+
let score = normalizedSourceCandidates.reduce((current, candidate) => {
|
|
4565
|
+
return normalizedSourceFile === candidate.key ? Math.max(current, candidate.absolute ? 100 : 80) : current;
|
|
4566
|
+
}, 0);
|
|
4567
|
+
if (normalizedSourceFile.endsWith(`/${normalizedFile}`)) score = Math.max(score, 20);
|
|
4568
|
+
if (score > (bestMatch?.score ?? 0)) bestMatch = {
|
|
4569
|
+
file: sourceFile,
|
|
4570
|
+
score
|
|
4571
|
+
};
|
|
4572
|
+
}
|
|
4573
|
+
return bestMatch?.file;
|
|
4574
|
+
}
|
|
4575
|
+
function resolveCurrentSourceCandidateSource(options) {
|
|
4576
|
+
const { file, getSourceCandidateSource, getSourceCandidateSources } = options;
|
|
4577
|
+
const normalizedFile = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
4578
|
+
const sourceCandidates = createSourceCandidateFiles(options);
|
|
4279
4579
|
const explicitSource = sourceCandidates.reduce((source, candidate) => {
|
|
4280
4580
|
if (source || !candidate) return source;
|
|
4281
4581
|
return getSourceCandidateSource?.(candidate);
|
|
@@ -4534,102 +4834,6 @@ function createBundleTaskTimer(recordTimingDetail) {
|
|
|
4534
4834
|
};
|
|
4535
4835
|
}
|
|
4536
4836
|
//#endregion
|
|
4537
|
-
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
4538
|
-
function toArray(value) {
|
|
4539
|
-
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
4540
|
-
}
|
|
4541
|
-
function normalizeSourceId(id) {
|
|
4542
|
-
const file = cleanUrl(id);
|
|
4543
|
-
return path.isAbsolute(file) ? path.resolve(file) : void 0;
|
|
4544
|
-
}
|
|
4545
|
-
function collectChunkModuleIds$1(chunk) {
|
|
4546
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4547
|
-
for (const id of chunk.moduleIds ?? []) {
|
|
4548
|
-
const normalized = normalizeSourceId(id);
|
|
4549
|
-
if (normalized) ids.add(normalized);
|
|
4550
|
-
}
|
|
4551
|
-
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
4552
|
-
const normalized = normalizeSourceId(id);
|
|
4553
|
-
if (normalized) ids.add(normalized);
|
|
4554
|
-
}
|
|
4555
|
-
return ids;
|
|
4556
|
-
}
|
|
4557
|
-
function collectAssetSourceIds(asset, fallbackFile, rootDir) {
|
|
4558
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4559
|
-
const sourceCandidates = [asset.originalFileName, ...asset.originalFileNames ?? []].filter((candidate) => typeof candidate === "string" && candidate.length > 0);
|
|
4560
|
-
const candidates = sourceCandidates.length > 0 ? sourceCandidates : [fallbackFile];
|
|
4561
|
-
for (const candidate of candidates) {
|
|
4562
|
-
if (typeof candidate !== "string" || candidate.length === 0) continue;
|
|
4563
|
-
const cleanCandidate = cleanUrl(candidate);
|
|
4564
|
-
const resolved = path.isAbsolute(cleanCandidate) ? path.resolve(cleanCandidate) : path.resolve(rootDir, cleanCandidate);
|
|
4565
|
-
ids.add(resolved);
|
|
4566
|
-
}
|
|
4567
|
-
return ids;
|
|
4568
|
-
}
|
|
4569
|
-
function isStringRuleMatched(rule, id, rootDir) {
|
|
4570
|
-
const normalizedId = slash(id);
|
|
4571
|
-
const normalizedRule = slash(rule);
|
|
4572
|
-
if (path.isAbsolute(rule)) return micromatch.isMatch(normalizedId, normalizedRule);
|
|
4573
|
-
const relative = slash(path.relative(rootDir, id));
|
|
4574
|
-
return relative.length > 0 && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizedRule);
|
|
4575
|
-
}
|
|
4576
|
-
function isRuleMatched(rule, id, rootDir) {
|
|
4577
|
-
if (typeof rule === "string") return isStringRuleMatched(rule, id, rootDir);
|
|
4578
|
-
if (rule instanceof RegExp) {
|
|
4579
|
-
rule.lastIndex = 0;
|
|
4580
|
-
return rule.test(slash(id));
|
|
4581
|
-
}
|
|
4582
|
-
return rule(id) === true;
|
|
4583
|
-
}
|
|
4584
|
-
function createTransformMatcher(rules, rootDir) {
|
|
4585
|
-
const normalizedRules = toArray(rules);
|
|
4586
|
-
if (normalizedRules.length === 0) return;
|
|
4587
|
-
return (id) => normalizedRules.some((rule) => isRuleMatched(rule, id, rootDir));
|
|
4588
|
-
}
|
|
4589
|
-
function shouldSkipSourceIds(sourceIds, filter) {
|
|
4590
|
-
if (sourceIds.size === 0) return false;
|
|
4591
|
-
if (filter.exclude) {
|
|
4592
|
-
let excluded = true;
|
|
4593
|
-
for (const id of sourceIds) if (!filter.exclude(id)) {
|
|
4594
|
-
excluded = false;
|
|
4595
|
-
break;
|
|
4596
|
-
}
|
|
4597
|
-
if (excluded) return true;
|
|
4598
|
-
}
|
|
4599
|
-
if (filter.include) {
|
|
4600
|
-
for (const id of sourceIds) if (filter.include(id)) return false;
|
|
4601
|
-
return true;
|
|
4602
|
-
}
|
|
4603
|
-
return false;
|
|
4604
|
-
}
|
|
4605
|
-
function createTransformFilter(options, rootDir) {
|
|
4606
|
-
const include = createTransformMatcher(options?.include, rootDir);
|
|
4607
|
-
const exclude = createTransformMatcher(options?.exclude, rootDir);
|
|
4608
|
-
if (!include && !exclude) return;
|
|
4609
|
-
return {
|
|
4610
|
-
include,
|
|
4611
|
-
exclude
|
|
4612
|
-
};
|
|
4613
|
-
}
|
|
4614
|
-
function shouldSkipViteJsChunkTransform(chunk, filter) {
|
|
4615
|
-
if (!filter) return false;
|
|
4616
|
-
return shouldSkipSourceIds(collectChunkModuleIds$1(chunk), filter);
|
|
4617
|
-
}
|
|
4618
|
-
function shouldSkipViteAssetTransform(asset, file, rootDir, filter) {
|
|
4619
|
-
if (!filter) return false;
|
|
4620
|
-
return shouldSkipSourceIds(collectAssetSourceIds(asset, file, rootDir), filter);
|
|
4621
|
-
}
|
|
4622
|
-
function createRuleSignature(rules) {
|
|
4623
|
-
return toArray(rules).map((rule) => {
|
|
4624
|
-
if (typeof rule === "string") return `s:${rule}`;
|
|
4625
|
-
if (rule instanceof RegExp) return `r:${rule.source}/${rule.flags}`;
|
|
4626
|
-
return "f";
|
|
4627
|
-
}).join("|") || "none";
|
|
4628
|
-
}
|
|
4629
|
-
function createTransformFilterSignature(options) {
|
|
4630
|
-
return [`include:${createRuleSignature(options?.include)}`, `exclude:${createRuleSignature(options?.exclude)}`].join(";");
|
|
4631
|
-
}
|
|
4632
|
-
//#endregion
|
|
4633
4837
|
//#region src/bundlers/vite/weapp-vite-config.ts
|
|
4634
4838
|
function resolveSourceRootCandidate(root, value) {
|
|
4635
4839
|
if (typeof value !== "string" || value.trim().length === 0) return;
|
|
@@ -4697,7 +4901,7 @@ function resolveViteWebCssCompatOptions(context) {
|
|
|
4697
4901
|
return context.currentGeneratorBranch.isWeb ? context.currentGeneratorOptions.webCompat : context.currentGeneratorOptions.webCompat ?? true;
|
|
4698
4902
|
}
|
|
4699
4903
|
//#endregion
|
|
4700
|
-
//#region src/bundlers/vite/generate-bundle.ts
|
|
4904
|
+
//#region src/bundlers/vite/generate-bundle-runtime.ts
|
|
4701
4905
|
function inferPlatformFromViteOutDir$1(outDir) {
|
|
4702
4906
|
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
4703
4907
|
if (!segment) return;
|
|
@@ -4707,7 +4911,7 @@ function inferPlatformFromViteOutDir$1(outDir) {
|
|
|
4707
4911
|
function hasTailwindPluginDirective(source) {
|
|
4708
4912
|
return /@plugin\b/.test(source);
|
|
4709
4913
|
}
|
|
4710
|
-
function createGenerateBundleHook(context) {
|
|
4914
|
+
function createGenerateBundleHook$1(context) {
|
|
4711
4915
|
const state = createBundleBuildState();
|
|
4712
4916
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
4713
4917
|
const lastCssSourceHashByFile = /* @__PURE__ */ new Map();
|
|
@@ -4750,8 +4954,11 @@ function createGenerateBundleHook(context) {
|
|
|
4750
4954
|
})
|
|
4751
4955
|
});
|
|
4752
4956
|
return async function generateBundle(_opt, bundle) {
|
|
4957
|
+
if (context.shouldProcessBundle?.() === false) return;
|
|
4958
|
+
const processMarkupAndScripts = context.processMarkupAndScripts !== false;
|
|
4959
|
+
const processStyles = context.shouldProcessStyles?.() ?? context.processStyles !== false;
|
|
4753
4960
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
4754
|
-
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
4961
|
+
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidateSource, getSourceCandidateSources, extractSourceCandidates, getSourceCandidatesForEntries, getSourceCandidateSourcesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, getKnownCssSource, getKnownSfcSource, getOriginalCssLayerSource, recordGeneratorCandidates, pruneViteCssCaches, getViteCssCacheStats, hmrTimingRecorder } = context;
|
|
4755
4962
|
const getBundlerSfcSource = (sourceFile) => {
|
|
4756
4963
|
const code = this.getModuleInfo?.(sourceFile)?.code;
|
|
4757
4964
|
return typeof code === "string" && hasSfcStyleSources(code) ? code : void 0;
|
|
@@ -4969,18 +5176,6 @@ function createGenerateBundleHook(context) {
|
|
|
4969
5176
|
return !normalizeOutputPathKey(entryOutputFile.replace(/[?#].*$/, "")).includes("/") || currentSubpackageRoots != null && !isSubpackageOutputFile(entryOutputFile, currentSubpackageRoots);
|
|
4970
5177
|
});
|
|
4971
5178
|
};
|
|
4972
|
-
const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
|
|
4973
|
-
cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
|
|
4974
|
-
getSourceCandidateSourcesForEntries,
|
|
4975
|
-
getSourceCandidatesForEntries,
|
|
4976
|
-
projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
|
|
4977
|
-
rootDir,
|
|
4978
|
-
snapshot,
|
|
4979
|
-
sourceRoot,
|
|
4980
|
-
subpackageRoots: currentSubpackageRoots,
|
|
4981
|
-
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
4982
|
-
useIncrementalMode
|
|
4983
|
-
});
|
|
4984
5179
|
recordTimingDetail("snapshot", snapshotStart);
|
|
4985
5180
|
const useBundleRuntimeClassSet = !isWebGeneratorTarget;
|
|
4986
5181
|
const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
@@ -4994,21 +5189,50 @@ function createGenerateBundleHook(context) {
|
|
|
4994
5189
|
const sourceCandidateWaitStart = performance.now();
|
|
4995
5190
|
await waitForSourceCandidateSyncs?.();
|
|
4996
5191
|
recordTimingDetail("sourceCandidates.wait", sourceCandidateWaitStart);
|
|
4997
|
-
const
|
|
4998
|
-
const
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5192
|
+
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
5193
|
+
const bundleMarkupCandidates = await collectBundleMarkupCandidates({
|
|
5194
|
+
extractSourceCandidates: processMarkupAndScripts && !isWebGeneratorTarget ? extractSourceCandidates : void 0,
|
|
5195
|
+
previousCandidatesByFile: useIncrementalMode ? state.bundleMarkupCandidatesByFile : void 0,
|
|
5196
|
+
preserveMissingFiles: useIncrementalMode && snapshot.hasOmittedKnownFiles,
|
|
5197
|
+
resolveSourceCandidateFile: (file) => resolveCurrentSourceCandidateFile({
|
|
5198
|
+
file,
|
|
5199
|
+
getSourceCandidateSource,
|
|
5200
|
+
getSourceCandidateSources,
|
|
5201
|
+
outDir,
|
|
5202
|
+
rootDir,
|
|
5203
|
+
sourceRoot
|
|
5204
|
+
}),
|
|
5205
|
+
rootDir,
|
|
5206
|
+
snapshot,
|
|
5207
|
+
transformFilter
|
|
5208
|
+
});
|
|
5209
|
+
const getCombinedSourceCandidatesForEntries = getSourceCandidatesForEntries || bundleMarkupCandidates.values.size > 0 ? (entries, options) => /* @__PURE__ */ new Set([...getSourceCandidatesForEntries?.(entries, options) ?? [], ...bundleMarkupCandidates.valuesForEntries(entries, options)]) : void 0;
|
|
5210
|
+
const sourceCandidates = /* @__PURE__ */ new Set([...getSourceCandidates?.() ?? [], ...bundleMarkupCandidates.values]);
|
|
5211
|
+
const { createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, shouldExcludeSubpackageSourceCandidates, shouldInjectCssIntoMainFromOutput } = createSubpackageSourceCandidateScope({
|
|
5212
|
+
cssSourceFiles: configuredTailwindV4CssSourceEntriesForScope.map((entry) => entry.file),
|
|
5213
|
+
getSourceCandidateSourcesForEntries,
|
|
5214
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5215
|
+
projectRoot: opts.tailwindcssRuntimeOptions?.projectRoot,
|
|
5216
|
+
rootDir,
|
|
5217
|
+
snapshot,
|
|
5218
|
+
sourceRoot,
|
|
5219
|
+
subpackageRoots: currentSubpackageRoots,
|
|
5220
|
+
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
5221
|
+
useIncrementalMode
|
|
5222
|
+
});
|
|
5223
|
+
const createScopedGeneratorRuntime$1 = (outputFile, cssHandlerOptions2, runtime2, rawSource, sourceFile) => createScopedGeneratorRuntime({
|
|
5224
|
+
cssHandlerOptions: cssHandlerOptions2,
|
|
5225
|
+
fallbackRuntime: runtime2,
|
|
5226
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5002
5227
|
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
5003
5228
|
outputFile,
|
|
5004
5229
|
rawSource,
|
|
5005
5230
|
shouldExcludeSubpackageSourceCandidates,
|
|
5006
5231
|
sourceFile,
|
|
5007
|
-
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile,
|
|
5232
|
+
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile, cssHandlerOptions2)
|
|
5008
5233
|
});
|
|
5009
5234
|
const jsEntries = snapshot.jsEntries;
|
|
5010
5235
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
5011
|
-
const transformFilter = createTransformFilter(opts.transform, rootDir);
|
|
5012
5236
|
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
5013
5237
|
const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
|
|
5014
5238
|
const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
@@ -5156,9 +5380,10 @@ function createGenerateBundleHook(context) {
|
|
|
5156
5380
|
const tasks = [];
|
|
5157
5381
|
const cssTaskFactories = [];
|
|
5158
5382
|
const jsTaskFactories = [];
|
|
5383
|
+
const entryPlanningStartedAt = performance.now();
|
|
5159
5384
|
for (const entry of snapshot.entries) {
|
|
5160
5385
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
5161
|
-
if (type === "html" && originalSource.type === "asset") {
|
|
5386
|
+
if (processMarkupAndScripts && type === "html" && originalSource.type === "asset") {
|
|
5162
5387
|
metrics.html.total++;
|
|
5163
5388
|
if (isWebGeneratorTarget) {
|
|
5164
5389
|
debug("html skip web target: %s", file);
|
|
@@ -5181,8 +5406,8 @@ function createGenerateBundleHook(context) {
|
|
|
5181
5406
|
originalEntrySource,
|
|
5182
5407
|
originalSource,
|
|
5183
5408
|
rememberProcessCacheKey,
|
|
5184
|
-
resolveCurrentSourceCandidateSource: (
|
|
5185
|
-
file,
|
|
5409
|
+
resolveCurrentSourceCandidateSource: (file2) => resolveCurrentSourceCandidateSource({
|
|
5410
|
+
file: file2,
|
|
5186
5411
|
getSourceCandidateSource,
|
|
5187
5412
|
getSourceCandidateSources,
|
|
5188
5413
|
outDir,
|
|
@@ -5197,12 +5422,12 @@ function createGenerateBundleHook(context) {
|
|
|
5197
5422
|
});
|
|
5198
5423
|
continue;
|
|
5199
5424
|
}
|
|
5200
|
-
if (type === "css" && originalSource.type === "asset") {
|
|
5425
|
+
if (processStyles && type === "css" && originalSource.type === "asset") {
|
|
5201
5426
|
metrics.css.total++;
|
|
5202
5427
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
5203
5428
|
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
|
|
5204
5429
|
const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
|
|
5205
|
-
const
|
|
5430
|
+
const cssPipelineContext2 = {
|
|
5206
5431
|
...createInitialCssPipelineContext(file),
|
|
5207
5432
|
bundle
|
|
5208
5433
|
};
|
|
@@ -5214,7 +5439,7 @@ function createGenerateBundleHook(context) {
|
|
|
5214
5439
|
isWebGeneratorTarget,
|
|
5215
5440
|
matchesCss: opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file),
|
|
5216
5441
|
shouldKeep: () => context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5217
|
-
...
|
|
5442
|
+
...cssPipelineContext2,
|
|
5218
5443
|
css: rawSource,
|
|
5219
5444
|
file: rootImportShellOutputFile
|
|
5220
5445
|
})
|
|
@@ -5224,16 +5449,16 @@ function createGenerateBundleHook(context) {
|
|
|
5224
5449
|
if (importedFile && isRootMiniProgramStyleOutputFile$1(importedFile)) frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, importedFile);
|
|
5225
5450
|
}
|
|
5226
5451
|
if (!rememberedFrameworkRootImportTarget && !isCurrentFrameworkRootImportShell && !isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && normalizeOutputPathKey(assetSourceFile) === normalizeOutputPathKey(file) && opts.mainCssChunkMatcher(rootImportShellOutputFile, opts.appType) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5227
|
-
...
|
|
5452
|
+
...cssPipelineContext2,
|
|
5228
5453
|
css: rawSource,
|
|
5229
5454
|
file: rootImportShellOutputFile
|
|
5230
5455
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5231
|
-
...
|
|
5456
|
+
...cssPipelineContext2,
|
|
5232
5457
|
file: rootImportShellOutputFile
|
|
5233
5458
|
}))) {
|
|
5234
5459
|
const rootGeneratedTargets = /* @__PURE__ */ new Set();
|
|
5235
|
-
for (const
|
|
5236
|
-
const targetFile = resolveMatchedCssSourceOutputFile(
|
|
5460
|
+
for (const entry2 of getConfiguredTailwindV4CssSourceEntries()) {
|
|
5461
|
+
const targetFile = resolveMatchedCssSourceOutputFile(entry2.file);
|
|
5237
5462
|
if (targetFile && isRootMiniProgramStyleOutputFile$1(targetFile) && normalizeOutputPathKey(targetFile) !== normalizeOutputPathKey(rootImportShellOutputFile)) rootGeneratedTargets.add(targetFile);
|
|
5238
5463
|
}
|
|
5239
5464
|
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) {
|
|
@@ -5257,11 +5482,11 @@ function createGenerateBundleHook(context) {
|
|
|
5257
5482
|
file,
|
|
5258
5483
|
isWebGeneratorTarget,
|
|
5259
5484
|
opts,
|
|
5260
|
-
pipelineContext:
|
|
5485
|
+
pipelineContext: cssPipelineContext2,
|
|
5261
5486
|
shouldPreserveAppCssExtension
|
|
5262
5487
|
});
|
|
5263
5488
|
if (rememberedFrameworkRootImportTarget && !isWebGeneratorTarget && (opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file)) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5264
|
-
...
|
|
5489
|
+
...cssPipelineContext2,
|
|
5265
5490
|
css: rawSource,
|
|
5266
5491
|
file: rootImportShellOutputFile
|
|
5267
5492
|
}))) {
|
|
@@ -5274,7 +5499,7 @@ function createGenerateBundleHook(context) {
|
|
|
5274
5499
|
originalFileNames: originalSource.originalFileNames,
|
|
5275
5500
|
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
5276
5501
|
});
|
|
5277
|
-
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((
|
|
5502
|
+
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((entry2) => originalSource.originalFileNames?.some((originalFile) => normalizeConfiguredTailwindV4CssEntryFileKey(originalFile) === normalizeConfiguredTailwindV4CssEntryFileKey(entry2.file)) === true) : void 0;
|
|
5278
5503
|
const configuredOriginalOutputFile = configuredOriginalSourceEntry ? resolveMatchedOutputFileForCurrentAsset(configuredOriginalSourceEntry.file) : void 0;
|
|
5279
5504
|
let resolvedFromConfiguredOriginalCssEntry = false;
|
|
5280
5505
|
if (configuredOriginalOutputFile && normalizeOutputPathKey(configuredOriginalOutputFile) !== normalizeOutputPathKey(outputFile)) {
|
|
@@ -5299,7 +5524,7 @@ function createGenerateBundleHook(context) {
|
|
|
5299
5524
|
file,
|
|
5300
5525
|
originalSource,
|
|
5301
5526
|
outputFile,
|
|
5302
|
-
pipelineContext:
|
|
5527
|
+
pipelineContext: cssPipelineContext2,
|
|
5303
5528
|
source,
|
|
5304
5529
|
viteProcessedCssAsset
|
|
5305
5530
|
});
|
|
@@ -5375,7 +5600,7 @@ function createGenerateBundleHook(context) {
|
|
|
5375
5600
|
if (!hasUsableRememberedTailwindSource) {
|
|
5376
5601
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
5377
5602
|
const isCurrentRootMiniProgramStyleOutput = opts.cssMatcher(outputFile) && isMiniProgramStyleOutputFile(outputFile) && !normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")).includes("/");
|
|
5378
|
-
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((
|
|
5603
|
+
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((entry2) => hasTailwindPluginDirective(entry2.source)) : configuredTailwindV4CssSourceEntries;
|
|
5379
5604
|
if (isCurrentRootMiniProgramStyleOutput && (hasTailwindGenerationSource(rawSource) || configuredEntriesForCurrentRootMiniProgramStyle.length > 0)) {
|
|
5380
5605
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, configuredEntriesForCurrentRootMiniProgramStyle, rawSource, {
|
|
5381
5606
|
cwd: opts.tailwindcssBasedir,
|
|
@@ -5401,14 +5626,14 @@ function createGenerateBundleHook(context) {
|
|
|
5401
5626
|
}
|
|
5402
5627
|
}
|
|
5403
5628
|
if (!hasUsableRememberedTailwindSource) {
|
|
5404
|
-
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5629
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug);
|
|
5405
5630
|
const inferredWebviewRootSourceEntry = inferredSourceStyle ? void 0 : selectConfiguredRootCssSourceEntry(outputFile, configuredTailwindV4CssSourceEntries, originalSource.originalFileNames);
|
|
5406
5631
|
const inferredWebviewRootSourceStyle = inferredWebviewRootSourceEntry ? {
|
|
5407
5632
|
outputFile,
|
|
5408
5633
|
rawSource: inferredWebviewRootSourceEntry.source,
|
|
5409
5634
|
sourceFile: inferredWebviewRootSourceEntry.file
|
|
5410
5635
|
} : void 0;
|
|
5411
|
-
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5636
|
+
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug)) ?? inferredWebviewRootSourceStyle;
|
|
5412
5637
|
if (inferredOriginalSourceStyle) {
|
|
5413
5638
|
const matchedOutputFile = normalizeOutputPathKey(inferredOriginalSourceStyle.outputFile) === normalizeOutputPathKey(outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
5414
5639
|
debug("source style output resolved: %s -> %s from %s", outputFile, matchedOutputFile, inferredOriginalSourceStyle.sourceFile);
|
|
@@ -5439,7 +5664,7 @@ function createGenerateBundleHook(context) {
|
|
|
5439
5664
|
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
5440
5665
|
}
|
|
5441
5666
|
} else if (!isCurrentRootMiniProgramStyleOutput && hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
5442
|
-
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((
|
|
5667
|
+
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry2) => !usedConfiguredTailwindV4CssSourceFiles.has(normalizeOutputPathKey(entry2.file)));
|
|
5443
5668
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
5444
5669
|
cwd: opts.tailwindcssBasedir,
|
|
5445
5670
|
outputRoot: outDir,
|
|
@@ -5462,6 +5687,11 @@ function createGenerateBundleHook(context) {
|
|
|
5462
5687
|
}
|
|
5463
5688
|
}
|
|
5464
5689
|
if (currentRawSourceHasExplicitScanContext) rememberedCssSources = rememberedCssSources.filter((remembered) => remembered.rawSource.includes("@source") || remembered.rawSource.includes("@config"));
|
|
5690
|
+
rememberedCssSources = rememberedCssSources.filter((remembered) => {
|
|
5691
|
+
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
5692
|
+
if (shouldSkip) debug("css skip raw remembered source style: %s -> %s", remembered.sourceFile, outputFile);
|
|
5693
|
+
return !shouldSkip;
|
|
5694
|
+
});
|
|
5465
5695
|
let rememberedCssSource = mergeRememberedCssSources(rememberedCssSources, outputFile);
|
|
5466
5696
|
if (rememberedCssSource && viteProcessedCssAsset && outputCssHandlerOptions.isMainChunk !== true && configuredTailwindV4CssSourceFileKeysForScope.has(normalizeConfiguredTailwindV4CssEntryFileKey(rememberedCssSource.sourceFile))) {
|
|
5467
5697
|
const matchedOutputFile = resolveMatchedOutputFileForCurrentAsset(rememberedCssSource.sourceFile);
|
|
@@ -5476,11 +5706,11 @@ function createGenerateBundleHook(context) {
|
|
|
5476
5706
|
}
|
|
5477
5707
|
}
|
|
5478
5708
|
if (!isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && isRootMiniProgramStyleOutputFile$1(outputFile) && normalizeOutputPathKey(rootImportShellOutputFile) !== normalizeOutputPathKey(outputFile) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5479
|
-
...
|
|
5709
|
+
...cssPipelineContext2,
|
|
5480
5710
|
css: rawSource,
|
|
5481
5711
|
file: rootImportShellOutputFile
|
|
5482
5712
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5483
|
-
...
|
|
5713
|
+
...cssPipelineContext2,
|
|
5484
5714
|
file: rootImportShellOutputFile
|
|
5485
5715
|
}))) {
|
|
5486
5716
|
frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, outputFile);
|
|
@@ -5514,7 +5744,7 @@ function createGenerateBundleHook(context) {
|
|
|
5514
5744
|
usedConfiguredTailwindV4CssSourceFiles.add(normalizeOutputPathKey(generatorSourceFile));
|
|
5515
5745
|
temporaryCssAssetSourceResolver.markUsed(generatorSourceFile);
|
|
5516
5746
|
}
|
|
5517
|
-
const
|
|
5747
|
+
const cssHandlerOptions2 = vitePipelineCssAsset ? {
|
|
5518
5748
|
...getCssHandlerOptions(generatorSourceFile),
|
|
5519
5749
|
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
5520
5750
|
} : getCssHandlerOptions(file);
|
|
@@ -5523,9 +5753,9 @@ function createGenerateBundleHook(context) {
|
|
|
5523
5753
|
const shouldUsePipelineSourceAsCssEntry = !isExplicitGeneratorCssEntry && vitePipelineCssAsset && opts.cssMatcher(generatorSourceFile) && hasTailwindGenerationSource(generatorRawSource);
|
|
5524
5754
|
const generatorCssEntries = isExplicitGeneratorCssEntry || shouldUsePipelineSourceAsCssEntry ? [generatorSourceFile] : opts.cssEntries;
|
|
5525
5755
|
const generatorCssHandlerOptions = {
|
|
5526
|
-
...
|
|
5756
|
+
...cssHandlerOptions2,
|
|
5527
5757
|
sourceOptions: {
|
|
5528
|
-
...
|
|
5758
|
+
...cssHandlerOptions2.sourceOptions ?? {},
|
|
5529
5759
|
sourceFile: generatorSourceFile,
|
|
5530
5760
|
cssEntries: generatorCssEntries
|
|
5531
5761
|
}
|
|
@@ -5554,7 +5784,7 @@ function createGenerateBundleHook(context) {
|
|
|
5554
5784
|
const vitePipelineCssInjectionOutputFile = webviewRootCssInjectionTarget ?? outputFile;
|
|
5555
5785
|
const shouldRecordVitePipelineCssByOutput = normalizeOutputPathKey(vitePipelineCssInjectionOutputFile) === normalizeOutputPathKey(outputFile);
|
|
5556
5786
|
const shouldInjectVitePipelineCssIntoMain = vitePipelineCssAsset && !resolvedFromConfiguredOriginalCssEntry && outputCssHandlerOptions.isMainChunk !== true && (webviewRootCssInjectionTarget != null || shouldInjectCssIntoMainFromOutput(outputFile, generatorSourceFile, outputCssHandlerOptions));
|
|
5557
|
-
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode ||
|
|
5787
|
+
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions2.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) || shouldRegenerateCollectedViteCss || hasRuntimeAffectingChanges && (alreadyProcessedCssAsset || vitePipelineCssAsset));
|
|
5558
5788
|
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) || hasBundlerGeneratedCssMarker(rawSource));
|
|
5559
5789
|
const strippedViteProcessedCss = stripBundlerGeneratedCssMarkers(rawSource);
|
|
5560
5790
|
const shouldPreserveStaleGeneratedCssAsset = hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && !strippedViteProcessedCss.includes("weapp-tailwindcss generator-placeholder") && !strippedViteProcessedCss.includes("vite-placeholder") && !hasTailwindGenerationSource(strippedViteProcessedCss) && !hasTailwindApplyDirective(strippedViteProcessedCss);
|
|
@@ -5587,7 +5817,7 @@ function createGenerateBundleHook(context) {
|
|
|
5587
5817
|
}) : trackedGeneratorCandidateSignature;
|
|
5588
5818
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
5589
5819
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
5590
|
-
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${
|
|
5820
|
+
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions2.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}:${sourceTraceSignature}`;
|
|
5591
5821
|
const cssCacheKey = outputFile;
|
|
5592
5822
|
const cssHashKey = `${outputFile}:css:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}`;
|
|
5593
5823
|
const cssLinkedImpactSignature = runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) ? [...[...snapshot.runtimeAffectingChangedByType.html].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? ""), ...[...snapshot.runtimeAffectingChangedByType.js].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? "")].join(":") : "";
|
|
@@ -5652,6 +5882,7 @@ function createGenerateBundleHook(context) {
|
|
|
5652
5882
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
5653
5883
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
5654
5884
|
sourceCandidates: scopedGeneratorRuntime,
|
|
5885
|
+
frameworkPostcssStage: "complete",
|
|
5655
5886
|
generatorPlatform,
|
|
5656
5887
|
styleHandler,
|
|
5657
5888
|
debug,
|
|
@@ -5661,24 +5892,24 @@ function createGenerateBundleHook(context) {
|
|
|
5661
5892
|
}) : void 0;
|
|
5662
5893
|
if (generated) {
|
|
5663
5894
|
const outputCss = transformWebTargetCss(generated.css);
|
|
5664
|
-
const
|
|
5895
|
+
const tracedCss2 = removeRootCoveredCssFromScopedAsset(annotateCss(outputCss));
|
|
5665
5896
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
5666
|
-
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorRawSource,
|
|
5667
|
-
debug("css generated result: %s bytes=%d", file,
|
|
5897
|
+
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorRawSource, tracedCss2));
|
|
5898
|
+
debug("css generated result: %s bytes=%d", file, tracedCss2.length);
|
|
5668
5899
|
for (const candidate of generated.classSet ?? []) transformRuntime.add(candidate);
|
|
5669
|
-
recordCssAssetResult?.(outputFile,
|
|
5670
|
-
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile,
|
|
5900
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5901
|
+
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile, tracedCss2, {
|
|
5671
5902
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
5672
5903
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5673
5904
|
});
|
|
5674
|
-
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file,
|
|
5905
|
+
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file, tracedCss2, {
|
|
5675
5906
|
injectIntoMain: shouldInjectVitePipelineCssIntoMain,
|
|
5676
5907
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5677
5908
|
});
|
|
5678
5909
|
metrics.css.elapsed += measureElapsed(start);
|
|
5679
5910
|
metrics.css.transformed++;
|
|
5680
5911
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, outputFile);
|
|
5681
|
-
return
|
|
5912
|
+
return tracedCss2;
|
|
5682
5913
|
}
|
|
5683
5914
|
if (isWebGeneratorTarget) {
|
|
5684
5915
|
const outputCss = transformWebTargetCss(rawSource);
|
|
@@ -5688,15 +5919,15 @@ function createGenerateBundleHook(context) {
|
|
|
5688
5919
|
return annotateCss(outputCss);
|
|
5689
5920
|
}
|
|
5690
5921
|
if (isPureLocalCssImportWrapper(generatorTransformRawSource)) {
|
|
5691
|
-
const
|
|
5692
|
-
recordCssAssetResult?.(outputFile,
|
|
5922
|
+
const tracedCss2 = annotateCss(generatorTransformRawSource);
|
|
5923
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5693
5924
|
metrics.css.elapsed += measureElapsed(start);
|
|
5694
5925
|
metrics.css.transformed++;
|
|
5695
5926
|
debug("css preserve mini-program import shell: %s", outputFile);
|
|
5696
|
-
return
|
|
5927
|
+
return tracedCss2;
|
|
5697
5928
|
}
|
|
5698
|
-
const { css } = await styleHandler(generatorTransformRawSource,
|
|
5699
|
-
const tracedCss = annotateCss(
|
|
5929
|
+
const { css: css2 } = await styleHandler(generatorTransformRawSource, cssHandlerOptions2);
|
|
5930
|
+
const tracedCss = annotateCss(css2);
|
|
5700
5931
|
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorTransformRawSource, tracedCss));
|
|
5701
5932
|
metrics.css.elapsed += measureElapsed(start);
|
|
5702
5933
|
metrics.css.transformed++;
|
|
@@ -5713,6 +5944,7 @@ function createGenerateBundleHook(context) {
|
|
|
5713
5944
|
continue;
|
|
5714
5945
|
}
|
|
5715
5946
|
if (type !== "js") continue;
|
|
5947
|
+
if (!processMarkupAndScripts) continue;
|
|
5716
5948
|
if (!shouldTransformJsBundle) {
|
|
5717
5949
|
debug("js skip web target: %s", file);
|
|
5718
5950
|
continue;
|
|
@@ -5746,7 +5978,9 @@ function createGenerateBundleHook(context) {
|
|
|
5746
5978
|
useIncrementalMode
|
|
5747
5979
|
});
|
|
5748
5980
|
}
|
|
5749
|
-
|
|
5981
|
+
recordTimingDetail("entries.plan", entryPlanningStartedAt);
|
|
5982
|
+
const rememberedCssStartedAt = performance.now();
|
|
5983
|
+
if (processStyles && (shouldProcessTailwindGeneration || useIncrementalMode || isNativeAppStyleTarget)) await processRememberedCssReplay({
|
|
5750
5984
|
addWatchFile,
|
|
5751
5985
|
activeViteCssCacheFiles,
|
|
5752
5986
|
bundle,
|
|
@@ -5791,6 +6025,7 @@ function createGenerateBundleHook(context) {
|
|
|
5791
6025
|
timeTask,
|
|
5792
6026
|
useIncrementalMode
|
|
5793
6027
|
});
|
|
6028
|
+
recordTimingDetail("rememberedCss.plan", rememberedCssStartedAt);
|
|
5794
6029
|
await finalizeGenerateBundle({
|
|
5795
6030
|
activeProcessCacheKeys,
|
|
5796
6031
|
activeProcessHashKeys,
|
|
@@ -5808,7 +6043,7 @@ function createGenerateBundleHook(context) {
|
|
|
5808
6043
|
generatorRuntime,
|
|
5809
6044
|
getCssHandlerOptions,
|
|
5810
6045
|
getSourceCandidateSourcesForEntries,
|
|
5811
|
-
getSourceCandidatesForEntries,
|
|
6046
|
+
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5812
6047
|
getViteCssCacheStats,
|
|
5813
6048
|
getViteProcessedCssAssetResults,
|
|
5814
6049
|
hmrTimingRecorder,
|
|
@@ -5848,10 +6083,16 @@ function createGenerateBundleHook(context) {
|
|
|
5848
6083
|
transformWebTargetCss,
|
|
5849
6084
|
useIncrementalMode
|
|
5850
6085
|
});
|
|
6086
|
+
state.bundleMarkupCandidatesByFile = bundleMarkupCandidates.candidatesByFile;
|
|
5851
6087
|
};
|
|
5852
6088
|
}
|
|
5853
6089
|
//#endregion
|
|
5854
|
-
//#region src/bundlers/vite/
|
|
6090
|
+
//#region src/bundlers/vite/generate-bundle.ts
|
|
6091
|
+
function createGenerateBundleHook(context) {
|
|
6092
|
+
return createGenerateBundleHook$1(context);
|
|
6093
|
+
}
|
|
6094
|
+
//#endregion
|
|
6095
|
+
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
5855
6096
|
function inferPlatformFromViteOutDir(outDir) {
|
|
5856
6097
|
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
5857
6098
|
if (!segment) return;
|
|
@@ -5913,6 +6154,8 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
|
5913
6154
|
shouldApplyWebCssCompat
|
|
5914
6155
|
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
5915
6156
|
}
|
|
6157
|
+
//#endregion
|
|
6158
|
+
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
5916
6159
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
5917
6160
|
return {
|
|
5918
6161
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -6027,6 +6270,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6027
6270
|
...harmonyCssHandlerOptions,
|
|
6028
6271
|
isMainChunk: false
|
|
6029
6272
|
},
|
|
6273
|
+
frameworkPostcssStage: "complete",
|
|
6030
6274
|
getSourceCandidatesForEntries,
|
|
6031
6275
|
generatorPlatform,
|
|
6032
6276
|
styleHandler: opts.styleHandler,
|
|
@@ -6067,10 +6311,15 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6067
6311
|
const file = output.fileName || bundleFile;
|
|
6068
6312
|
const rawSource = output.source.toString();
|
|
6069
6313
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
6070
|
-
const
|
|
6314
|
+
const cleanRawSource = stripBundlerGeneratedCssMarkers(rawSource);
|
|
6315
|
+
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
6071
6316
|
...createCssPipelineContext(file),
|
|
6072
6317
|
file
|
|
6073
|
-
}
|
|
6318
|
+
}) ?? {});
|
|
6319
|
+
const nextCss = annotateCss(generatorBranch.isWeb ? finalizeWebCss(cleanRawSource, {
|
|
6320
|
+
...createCssPipelineContext(file),
|
|
6321
|
+
file
|
|
6322
|
+
}, cssPipelineStrategy) : (await opts.styleHandler(cleanRawSource, cssHandlerOptions)).css);
|
|
6074
6323
|
output.source = nextCss;
|
|
6075
6324
|
markCssAssetProcessed(output, file);
|
|
6076
6325
|
recordCssAssetResult?.(file, nextCss);
|
|
@@ -6117,6 +6366,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6117
6366
|
outputFile: file,
|
|
6118
6367
|
cssHandlerOptions: generatorCssHandlerOptions,
|
|
6119
6368
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
6369
|
+
frameworkPostcssStage: "complete",
|
|
6120
6370
|
getSourceCandidatesForEntries,
|
|
6121
6371
|
generatorPlatform,
|
|
6122
6372
|
styleHandler: opts.styleHandler,
|
|
@@ -6694,7 +6944,11 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
6694
6944
|
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
6695
6945
|
const shouldGenerateInPreTransform = !options.shouldDeferGeneration?.(id, normalizedCode) && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode));
|
|
6696
6946
|
if (options.shouldOwnTailwindGeneration && shouldGenerateInPreTransform) {
|
|
6697
|
-
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode,
|
|
6947
|
+
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, {
|
|
6948
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
6949
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
6950
|
+
frameworkPostcssStage: "pending"
|
|
6951
|
+
});
|
|
6698
6952
|
if (generatedCss !== void 0) return {
|
|
6699
6953
|
code: generatedCss,
|
|
6700
6954
|
map: null
|
|
@@ -6886,52 +7140,86 @@ function isViteServeStyleRequest(id, command) {
|
|
|
6886
7140
|
function isViteServeCssRootRequest(id, command) {
|
|
6887
7141
|
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
6888
7142
|
}
|
|
7143
|
+
function isViteBuildStyleRequest(id, command) {
|
|
7144
|
+
return command === "build" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE$1.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
7145
|
+
}
|
|
6889
7146
|
function isViteCssHmrModule(code, id, command) {
|
|
6890
7147
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && (/[?&](?:direct|vue)(?:&|$)/.test(id) || DEFERRED_CSS_HMR_QUERY_RE.test(id));
|
|
6891
7148
|
}
|
|
6892
|
-
function
|
|
7149
|
+
function hasViteCssGenerationDirective(code) {
|
|
6893
7150
|
return hasTailwindRootDirectives(code) || hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
6894
7151
|
}
|
|
6895
7152
|
function hasViteServeCssRootDirective(code) {
|
|
6896
7153
|
return hasTailwindRootDirectives(code);
|
|
6897
7154
|
}
|
|
6898
|
-
function
|
|
6899
|
-
return [
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
7155
|
+
function createViteCssGenerationPlugins(options) {
|
|
7156
|
+
return [
|
|
7157
|
+
{
|
|
7158
|
+
name: `${vitePluginName}:generate:serve`,
|
|
7159
|
+
apply: "serve",
|
|
7160
|
+
enforce: "pre",
|
|
7161
|
+
async transform(code, id) {
|
|
7162
|
+
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
7163
|
+
if (!hasTailwindRootDirectives(code)) return;
|
|
7164
|
+
if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
|
|
7165
|
+
await options.onTailwindRootCss?.(id, code);
|
|
7166
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7167
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7168
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7169
|
+
frameworkPostcssStage: "pending"
|
|
7170
|
+
});
|
|
7171
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7172
|
+
return {
|
|
7173
|
+
code: generatedCss,
|
|
7174
|
+
map: null
|
|
7175
|
+
};
|
|
7176
|
+
}
|
|
7177
|
+
},
|
|
7178
|
+
{
|
|
7179
|
+
name: `${vitePluginName}:generate:build`,
|
|
7180
|
+
apply: "build",
|
|
7181
|
+
enforce: "pre",
|
|
7182
|
+
async transform(code, id) {
|
|
7183
|
+
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
7184
|
+
if (!hasViteCssGenerationDirective(code)) return;
|
|
7185
|
+
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
7186
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7187
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7188
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7189
|
+
frameworkPostcssStage: "pending"
|
|
7190
|
+
});
|
|
7191
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7192
|
+
return {
|
|
7193
|
+
code: generatedCss,
|
|
7194
|
+
map: null
|
|
7195
|
+
};
|
|
7196
|
+
}
|
|
7197
|
+
},
|
|
7198
|
+
{
|
|
7199
|
+
name: `${vitePluginName}:generate:serve-hmr`,
|
|
7200
|
+
apply: "serve",
|
|
7201
|
+
enforce: "post",
|
|
7202
|
+
async transform(code, id) {
|
|
7203
|
+
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
7204
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
7205
|
+
if (!extracted) return;
|
|
7206
|
+
if (!hasViteCssGenerationDirective(extracted.css)) return;
|
|
7207
|
+
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
7208
|
+
const generatedCss = await options.generateCss(id, extracted.css, {
|
|
7209
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7210
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7211
|
+
frameworkPostcssStage: "complete"
|
|
7212
|
+
});
|
|
7213
|
+
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
7214
|
+
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
7215
|
+
if (nextCode === void 0 || nextCode === code) return;
|
|
7216
|
+
return {
|
|
7217
|
+
code: nextCode,
|
|
7218
|
+
map: null
|
|
7219
|
+
};
|
|
7220
|
+
}
|
|
6933
7221
|
}
|
|
6934
|
-
|
|
7222
|
+
];
|
|
6935
7223
|
}
|
|
6936
7224
|
//#endregion
|
|
6937
7225
|
//#region src/bundlers/vite/serve-js-transform.ts
|
|
@@ -6996,7 +7284,41 @@ function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
|
6996
7284
|
return resolvedRoot;
|
|
6997
7285
|
}
|
|
6998
7286
|
//#endregion
|
|
6999
|
-
//#region src/bundlers/vite/
|
|
7287
|
+
//#region src/bundlers/vite/watch-css-post.ts
|
|
7288
|
+
const wrappedCssPostPlugins = /* @__PURE__ */ new WeakSet();
|
|
7289
|
+
function isWebOrNativeAppPlatform$1(platform) {
|
|
7290
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
7291
|
+
}
|
|
7292
|
+
function shouldAdaptFrameworkWatchCssBeforeCache(options) {
|
|
7293
|
+
return options.enabled && options.ownsTailwindGeneration && options.isWatchBuild && (options.platform ? !isWebOrNativeAppPlatform$1(options.platform) : !options.isWebGeneratorBranch);
|
|
7294
|
+
}
|
|
7295
|
+
function resolveTransformHandler(plugin) {
|
|
7296
|
+
const hook = plugin.transform;
|
|
7297
|
+
if (typeof hook === "function") return hook;
|
|
7298
|
+
if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
|
|
7299
|
+
}
|
|
7300
|
+
/**
|
|
7301
|
+
* 在框架的 CSS post hook 持久化样式前完成转换,保证 watch 重放缓存时不会重新输出原始 CSS。
|
|
7302
|
+
*/
|
|
7303
|
+
function wrapViteCssPostTransform(config, transformCss) {
|
|
7304
|
+
const plugin = config.plugins?.find((candidate) => candidate.name === "vite:css-post");
|
|
7305
|
+
if (!plugin || wrappedCssPostPlugins.has(plugin)) return false;
|
|
7306
|
+
const originalHandler = resolveTransformHandler(plugin);
|
|
7307
|
+
if (!originalHandler) return false;
|
|
7308
|
+
const wrappedHandler = async function(code, id, ...args) {
|
|
7309
|
+
const transformedCss = await transformCss(code, id);
|
|
7310
|
+
return originalHandler.call(this, transformedCss, id, ...args);
|
|
7311
|
+
};
|
|
7312
|
+
const originalHook = plugin.transform;
|
|
7313
|
+
plugin.transform = originalHook && typeof originalHook === "object" ? {
|
|
7314
|
+
...originalHook,
|
|
7315
|
+
handler: wrappedHandler
|
|
7316
|
+
} : wrappedHandler;
|
|
7317
|
+
wrappedCssPostPlugins.add(plugin);
|
|
7318
|
+
return true;
|
|
7319
|
+
}
|
|
7320
|
+
//#endregion
|
|
7321
|
+
//#region src/bundlers/vite/shared/create-framework-plugins-runtime.ts
|
|
7000
7322
|
const debug = createDebug();
|
|
7001
7323
|
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
7002
7324
|
const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
@@ -7039,10 +7361,7 @@ function isWebOrNativeAppPlatform(platform) {
|
|
|
7039
7361
|
function isInternalUserDefinedOptions(options) {
|
|
7040
7362
|
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
7041
7363
|
}
|
|
7042
|
-
|
|
7043
|
-
* Vite 各框架分支共享的组合工厂。框架分支只负责选择和拥有各自入口,公共稳定能力放在这里复用。
|
|
7044
|
-
*/
|
|
7045
|
-
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
7364
|
+
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
7046
7365
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
7047
7366
|
const rawOptions = options.__internalViteRawOptions ?? options;
|
|
7048
7367
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
@@ -7138,7 +7457,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7138
7457
|
await sourceCandidateCollector.syncCss(id, css);
|
|
7139
7458
|
cacheCurrentSourceCandidateScan();
|
|
7140
7459
|
};
|
|
7141
|
-
const registerAutoCssSource = async (id, css,
|
|
7460
|
+
const registerAutoCssSource = async (id, css, options2 = {}) => {
|
|
7142
7461
|
if (!shouldOwnTailwindGeneration) return;
|
|
7143
7462
|
const file = cleanUrl(id);
|
|
7144
7463
|
if (!path.isAbsolute(file)) return;
|
|
@@ -7172,7 +7491,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7172
7491
|
})) return;
|
|
7173
7492
|
invalidateSourceCandidateScan();
|
|
7174
7493
|
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
7175
|
-
if (
|
|
7494
|
+
if (options2.refresh === false) return;
|
|
7176
7495
|
autoCssSourcesRefresh = (autoCssSourcesRefresh ?? Promise.resolve()).then(async () => {
|
|
7177
7496
|
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
7178
7497
|
await syncSourceCandidateScan({ force: true });
|
|
@@ -7278,8 +7597,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7278
7597
|
recordedGeneratorCandidates = void 0;
|
|
7279
7598
|
};
|
|
7280
7599
|
const getSourceCandidates = () => sourceCandidateCollector.values();
|
|
7281
|
-
const getSourceCandidatesForEntries = (entries,
|
|
7282
|
-
const getSourceCandidateSourcesForEntries = (entries,
|
|
7600
|
+
const getSourceCandidatesForEntries = (entries, options2) => sourceCandidateCollector.valuesForEntries(entries, options2);
|
|
7601
|
+
const getSourceCandidateSourcesForEntries = (entries, options2) => sourceCandidateCollector.sourcesForEntries(entries, options2);
|
|
7283
7602
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
7284
7603
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || process$1.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || process$1.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
7285
7604
|
const isCurrentWebLikeStylePlatform = () => {
|
|
@@ -7319,10 +7638,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7319
7638
|
}
|
|
7320
7639
|
pendingHmrCssTargetFiles = collectPendingHmrCssTargetFiles(cssModules, fallbackCssIds);
|
|
7321
7640
|
};
|
|
7322
|
-
const createViteSourceCandidateChange = (file, change,
|
|
7641
|
+
const createViteSourceCandidateChange = (file, change, options2 = {}) => ({
|
|
7323
7642
|
...change,
|
|
7324
7643
|
file,
|
|
7325
|
-
runtimeAffecting:
|
|
7644
|
+
runtimeAffecting: options2.runtimeAffecting === true || isSourceStyleRequest(file) || hasWebHmrRuntimeAffectingDirectives(sourceCandidateCollector.source(file))
|
|
7326
7645
|
});
|
|
7327
7646
|
const clearPendingHmrCandidateChange = () => {
|
|
7328
7647
|
pendingHmrCandidateChange = void 0;
|
|
@@ -7425,8 +7744,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7425
7744
|
};
|
|
7426
7745
|
const cacheCurrentSourceCandidateScan = () => {
|
|
7427
7746
|
if (sourceCandidateScanSignature) {
|
|
7428
|
-
|
|
7429
|
-
|
|
7747
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7748
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, snapshot);
|
|
7749
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, snapshot);
|
|
7430
7750
|
}
|
|
7431
7751
|
};
|
|
7432
7752
|
const shouldDiscoverAutoCssSources = () => {
|
|
@@ -7434,9 +7754,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7434
7754
|
if (!isWatchLikeBuild()) return true;
|
|
7435
7755
|
return sourceCandidateScanInvalidated;
|
|
7436
7756
|
};
|
|
7437
|
-
async function syncSourceCandidateScan(
|
|
7757
|
+
async function syncSourceCandidateScan(options2 = {}) {
|
|
7438
7758
|
if (!shouldOwnTailwindGeneration) return;
|
|
7439
|
-
if (!
|
|
7759
|
+
if (!options2.force && isWatchLikeBuild() && hasSourceCandidateScanState() && !sourceCandidateScanInvalidated) {
|
|
7440
7760
|
debug("reuse vite source candidate scan definition for watch rebuild");
|
|
7441
7761
|
return;
|
|
7442
7762
|
}
|
|
@@ -7479,8 +7799,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7479
7799
|
sourceCandidateScanSignature = nextScanSignature;
|
|
7480
7800
|
sourceCandidateScanInvalidated = false;
|
|
7481
7801
|
if (isWatchLikeBuild()) {
|
|
7482
|
-
|
|
7483
|
-
|
|
7802
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7803
|
+
sourceCandidateScanCache.set(nextScanSignature, snapshot);
|
|
7804
|
+
sourceCandidateScanSnapshotCache.set(nextScanSignature, snapshot);
|
|
7484
7805
|
}
|
|
7485
7806
|
}
|
|
7486
7807
|
const waitForSourceCandidateSyncs = async () => {
|
|
@@ -7522,14 +7843,14 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7522
7843
|
const recordCssAssetResult = (file, css) => {
|
|
7523
7844
|
touchMapEntry(cleanGeneratedCssByFile, normalizeVitePersistentCacheKey(file), css);
|
|
7524
7845
|
};
|
|
7525
|
-
const recordViteProcessedCssAssetResult = (file, css,
|
|
7846
|
+
const recordViteProcessedCssAssetResult = (file, css, options2 = {}) => {
|
|
7526
7847
|
const key = normalizeVitePersistentCacheKey(file);
|
|
7527
7848
|
const previous = viteProcessedCssAssetResults.get(key);
|
|
7528
|
-
const injectIntoMain = previous?.injectIntoMain === true ? true :
|
|
7849
|
+
const injectIntoMain = previous?.injectIntoMain === true ? true : options2.injectIntoMain ?? previous?.injectIntoMain;
|
|
7529
7850
|
touchMapEntry(viteProcessedCssAssetResults, key, {
|
|
7530
7851
|
css,
|
|
7531
7852
|
injectIntoMain,
|
|
7532
|
-
outputFile:
|
|
7853
|
+
outputFile: options2.outputFile ?? previous?.outputFile
|
|
7533
7854
|
});
|
|
7534
7855
|
};
|
|
7535
7856
|
const getViteProcessedCssAssetResults = () => viteProcessedCssAssetResults.entries();
|
|
@@ -7547,8 +7868,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7547
7868
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
7548
7869
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size
|
|
7549
7870
|
});
|
|
7550
|
-
const pruneViteCssCaches = (
|
|
7551
|
-
const activeFiles = new Set([...
|
|
7871
|
+
const pruneViteCssCaches = (options2) => {
|
|
7872
|
+
const activeFiles = new Set([...options2.activeFiles].map(normalizeVitePersistentCacheKey));
|
|
7552
7873
|
for (const key of cleanGeneratedCssByFile.keys()) if (!activeFiles.has(key)) cleanGeneratedCssByFile.delete(key);
|
|
7553
7874
|
for (const key of tracedGeneratedCssByFile.keys()) if (!activeFiles.has(key)) tracedGeneratedCssByFile.delete(key);
|
|
7554
7875
|
for (const key of generatedClassSetByFile.keys()) if (!activeFiles.has(key)) generatedClassSetByFile.delete(key);
|
|
@@ -7556,7 +7877,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7556
7877
|
const outputKey = typeof record.outputFile === "string" ? normalizeVitePersistentCacheKey(record.outputFile) : void 0;
|
|
7557
7878
|
if (!activeFiles.has(key) && (outputKey == null || !activeFiles.has(outputKey))) viteProcessedCssAssetResults.delete(key);
|
|
7558
7879
|
}
|
|
7559
|
-
cssMemory.prune(
|
|
7880
|
+
cssMemory.prune(options2);
|
|
7560
7881
|
};
|
|
7561
7882
|
const normalizeViteProcessedCssFile = (file) => path.resolve(cleanUrl(file));
|
|
7562
7883
|
const markViteProcessedCssSource = (file) => {
|
|
@@ -7605,12 +7926,23 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7605
7926
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
7606
7927
|
moduleGraph: void 0
|
|
7607
7928
|
});
|
|
7929
|
+
const shouldAdaptFrameworkWatchCss = () => {
|
|
7930
|
+
const platform = resolveViteStylePlatform();
|
|
7931
|
+
return shouldAdaptFrameworkWatchCssBeforeCache({
|
|
7932
|
+
enabled: frameworkBranch.adaptWatchCssBeforeFrameworkCache === true,
|
|
7933
|
+
ownsTailwindGeneration: shouldOwnTailwindGeneration,
|
|
7934
|
+
isWatchBuild: isWatchBuild(),
|
|
7935
|
+
isWebGeneratorBranch: resolveCurrentGeneratorBranch().isWeb,
|
|
7936
|
+
platform
|
|
7937
|
+
});
|
|
7938
|
+
};
|
|
7608
7939
|
const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
|
|
7609
7940
|
if (!shouldOwnTailwindGeneration) return;
|
|
7610
7941
|
await runtimeState.readyPromise;
|
|
7611
7942
|
await waitForSourceCandidateSyncs();
|
|
7612
7943
|
const file = cleanUrl(id);
|
|
7613
|
-
const
|
|
7944
|
+
const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
7945
|
+
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? id : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
7614
7946
|
if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
|
|
7615
7947
|
const generatorCode = normalizeEmptyTailwindCustomVariants(code);
|
|
7616
7948
|
const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
|
|
@@ -7661,7 +7993,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7661
7993
|
const previousTracedCss = tracedGeneratedCssByFile.get(fileKey);
|
|
7662
7994
|
if (previousTracedCss !== void 0) {
|
|
7663
7995
|
finishPendingHmrCssTargetFile(file);
|
|
7664
|
-
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
7996
|
+
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
7997
|
+
${previousTracedCss}`;
|
|
7665
7998
|
}
|
|
7666
7999
|
}
|
|
7667
8000
|
const sourceCssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(requestFile);
|
|
@@ -7682,7 +8015,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7682
8015
|
}) ?? true);
|
|
7683
8016
|
const previousCss = pendingHmrChange && !forceFullHmrCssRegeneration ? cleanGeneratedCssByFile.get(fileKey) : void 0;
|
|
7684
8017
|
const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ? normalizeMiniProgramGeneratorCssSource(previousCss, outputFile) : previousCss;
|
|
7685
|
-
const generated = await hmrTimingRecorder.measure(
|
|
8018
|
+
const generated = await hmrTimingRecorder.measure(`generateCss.${resolvedConfig?.command ?? "unknown"}`, () => generateTailwindV4Css({
|
|
7686
8019
|
opts,
|
|
7687
8020
|
runtimeState,
|
|
7688
8021
|
runtime,
|
|
@@ -7699,7 +8032,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7699
8032
|
previousCss: previousGeneratorCss,
|
|
7700
8033
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
7701
8034
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
8035
|
+
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7702
8036
|
disableSourceScan: false,
|
|
8037
|
+
frameworkPostcssStage: hookContext?.frameworkPostcssStage,
|
|
7703
8038
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
7704
8039
|
}), {
|
|
7705
8040
|
file,
|
|
@@ -7759,7 +8094,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7759
8094
|
sourceFile: requestFile
|
|
7760
8095
|
});
|
|
7761
8096
|
debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
|
|
7762
|
-
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8097
|
+
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8098
|
+
${tracedCss}`;
|
|
7763
8099
|
};
|
|
7764
8100
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
7765
8101
|
getAppType: () => opts.appType,
|
|
@@ -7774,7 +8110,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7774
8110
|
weappTailwindcssDirPosix
|
|
7775
8111
|
});
|
|
7776
8112
|
if (disabledOptions.plugin) return rewritePlugins.length ? rewritePlugins : void 0;
|
|
7777
|
-
const
|
|
8113
|
+
const generateBundleContext = {
|
|
7778
8114
|
opts,
|
|
7779
8115
|
runtimeState,
|
|
7780
8116
|
ensureRuntimeClassSet,
|
|
@@ -7791,6 +8127,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7791
8127
|
getSourceCandidates,
|
|
7792
8128
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file),
|
|
7793
8129
|
getSourceCandidateSources: () => sourceCandidateCollector.sources(),
|
|
8130
|
+
extractSourceCandidates: (file, source) => extractCandidatesFromSource(source, path.extname(cleanUrl(file)).slice(1) || "html", {
|
|
8131
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
8132
|
+
customAttributesEntities,
|
|
8133
|
+
disabledDefaultTemplateHandler
|
|
8134
|
+
}),
|
|
7794
8135
|
getSourceCandidatesForEntries,
|
|
7795
8136
|
getSourceCandidateSourcesForEntries,
|
|
7796
8137
|
waitForSourceCandidateSyncs,
|
|
@@ -7808,6 +8149,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7808
8149
|
hmrTimingRecorder,
|
|
7809
8150
|
cssPipelineStrategy: frameworkCssPipelineStrategy,
|
|
7810
8151
|
frameworkRootImportShellTargetByFile
|
|
8152
|
+
};
|
|
8153
|
+
const shouldSplitGenerateBundlePhases = () => opts.appType === "weapp-vite" && getResolvedConfig()?.mode !== "production";
|
|
8154
|
+
const preGenerateBundleHook = createGenerateBundleHook({
|
|
8155
|
+
...generateBundleContext,
|
|
8156
|
+
processMarkupAndScripts: false,
|
|
8157
|
+
shouldProcessBundle: shouldSplitGenerateBundlePhases
|
|
8158
|
+
});
|
|
8159
|
+
const generateBundleHook = createGenerateBundleHook({
|
|
8160
|
+
...generateBundleContext,
|
|
8161
|
+
shouldProcessStyles: () => !shouldSplitGenerateBundlePhases()
|
|
7811
8162
|
});
|
|
7812
8163
|
const cssFinalizerOutputPlugin = createViteCssFinalizerOutputPlugin({
|
|
7813
8164
|
opts,
|
|
@@ -7854,6 +8205,21 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7854
8205
|
styleHandler,
|
|
7855
8206
|
uniAppX
|
|
7856
8207
|
}) ?? [];
|
|
8208
|
+
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
8209
|
+
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
8210
|
+
if (wrapViteCssPostTransform(config, async (css, id) => {
|
|
8211
|
+
if (!isCSSRequest(id)) return css;
|
|
8212
|
+
if (hasBundlerGeneratedCssMarker(css)) {
|
|
8213
|
+
debug("preserve adapted generated css before uni-app watch cache: %s", id);
|
|
8214
|
+
return css;
|
|
8215
|
+
}
|
|
8216
|
+
const file = cleanUrl(id);
|
|
8217
|
+
const styleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), css, id) : id;
|
|
8218
|
+
const transformedCss = (await styleHandler(css, transformCssHandlerOptions.getCssHandlerOptions(styleRequest))).css;
|
|
8219
|
+
debug("adapt css before uni-app watch cache: %s inputRaw=%s outputRaw=%s", id, css.includes("\\[") || css.includes("\\:"), transformedCss.includes("\\[") || transformedCss.includes("\\:"));
|
|
8220
|
+
return transformedCss;
|
|
8221
|
+
})) debug("adapt uni-app watch css before vite:css-post cache");
|
|
8222
|
+
};
|
|
7857
8223
|
const plugins = [
|
|
7858
8224
|
...rewritePlugins,
|
|
7859
8225
|
{
|
|
@@ -7972,13 +8338,15 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7972
8338
|
await hmrTimingRecorder.measure("sourceCandidates.buildStart", async () => {
|
|
7973
8339
|
await prepareTailwindGeneration();
|
|
7974
8340
|
}, { emit: false });
|
|
7975
|
-
}
|
|
8341
|
+
},
|
|
8342
|
+
generateBundle: preGenerateBundleHook
|
|
7976
8343
|
},
|
|
7977
|
-
...
|
|
8344
|
+
...createViteCssGenerationPlugins({
|
|
7978
8345
|
generateCss: generateTailwindCssForVitePipeline,
|
|
7979
8346
|
getCommand: () => resolvedConfig?.command,
|
|
7980
8347
|
onTailwindRootCss: registerTailwindRootCss,
|
|
7981
|
-
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
8348
|
+
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
8349
|
+
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
7982
8350
|
}),
|
|
7983
8351
|
createViteServeJsTransformPlugin({
|
|
7984
8352
|
createHandlerOptions: (file) => serveJsHandlerOptions(file, frameworkCssPipelineStrategy?.getServeJsHandlerOptions?.({
|
|
@@ -7990,6 +8358,13 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7990
8358
|
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
7991
8359
|
transformRuntime: ensureRuntimeClassSet
|
|
7992
8360
|
}),
|
|
8361
|
+
{
|
|
8362
|
+
name: `${vitePluginName}:watch-css-cache`,
|
|
8363
|
+
configResolved: {
|
|
8364
|
+
order: "post",
|
|
8365
|
+
handler: installFrameworkWatchCssCacheAdapter
|
|
8366
|
+
}
|
|
8367
|
+
},
|
|
7993
8368
|
{
|
|
7994
8369
|
name: `${vitePluginName}:post`,
|
|
7995
8370
|
enforce: "post",
|
|
@@ -7997,7 +8372,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7997
8372
|
if (!shouldOwnTailwindGeneration) return;
|
|
7998
8373
|
if (Array.isArray(config.plugins)) {
|
|
7999
8374
|
const removed = disableAndRemoveTailwindVitePlugins(config.plugins);
|
|
8000
|
-
if (removed > 0)
|
|
8375
|
+
if (removed > 0) {
|
|
8376
|
+
logger.warn("检测到 @tailwindcss/vite,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
8377
|
+
debug("disable official tailwind vite plugins in generator mode: %d", removed);
|
|
8378
|
+
}
|
|
8001
8379
|
}
|
|
8002
8380
|
const root = config.root ? path.resolve(config.root) : process$1.cwd();
|
|
8003
8381
|
const baseConfig = { resolve: { alias: [{
|
|
@@ -8005,14 +8383,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8005
8383
|
replacement: path.join(weappTailwindcssPackageDir, "generator-placeholder.css")
|
|
8006
8384
|
}] } };
|
|
8007
8385
|
if (config.css?.postcss !== void 0) return baseConfig;
|
|
8008
|
-
return
|
|
8386
|
+
return resolvePostcssConfig(root).then((postcssConfig) => {
|
|
8009
8387
|
if (!postcssConfig) return baseConfig;
|
|
8010
|
-
|
|
8388
|
+
const plugins2 = [...postcssConfig.plugins];
|
|
8389
|
+
const removed = removeTailwindPostcssPlugins(plugins2);
|
|
8390
|
+
if (removed > 0) debug("inline filtered postcss config without official tailwind plugins in generator mode: %d", removed);
|
|
8011
8391
|
return {
|
|
8012
8392
|
...baseConfig,
|
|
8013
8393
|
css: { postcss: {
|
|
8014
8394
|
...postcssConfig.options,
|
|
8015
|
-
plugins:
|
|
8395
|
+
plugins: plugins2
|
|
8016
8396
|
} }
|
|
8017
8397
|
};
|
|
8018
8398
|
});
|
|
@@ -8051,9 +8431,13 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8051
8431
|
const postcssPlugins = config.css.postcss.plugins;
|
|
8052
8432
|
if (shouldOwnTailwindGeneration) {
|
|
8053
8433
|
const removed = removeTailwindPostcssPlugins(postcssPlugins);
|
|
8054
|
-
if (removed > 0)
|
|
8434
|
+
if (removed > 0) {
|
|
8435
|
+
logger.warn("检测到 @tailwindcss/postcss,生成模式下已移除该插件以避免 Tailwind CSS 重复生成。");
|
|
8436
|
+
debug("remove official tailwind postcss plugins in generator mode: %d", removed);
|
|
8437
|
+
}
|
|
8055
8438
|
}
|
|
8056
8439
|
}
|
|
8440
|
+
captureFrameworkPostcssOptions(opts, config.css?.postcss && typeof config.css.postcss === "object" ? config.css.postcss : void 0);
|
|
8057
8441
|
}, { emit: false });
|
|
8058
8442
|
},
|
|
8059
8443
|
generateBundle: {
|
|
@@ -8068,6 +8452,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8068
8452
|
return plugins;
|
|
8069
8453
|
}
|
|
8070
8454
|
//#endregion
|
|
8455
|
+
//#region src/bundlers/vite/shared/create-framework-plugins.ts
|
|
8456
|
+
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
8457
|
+
return createViteFrameworkPlugins$1(options, frameworkBranch);
|
|
8458
|
+
}
|
|
8459
|
+
//#endregion
|
|
8071
8460
|
//#region src/bundlers/vite/frameworks/generic/index.ts
|
|
8072
8461
|
function createGenericVitePlugins(options = {}) {
|
|
8073
8462
|
return createViteFrameworkPlugins(options, {
|
|
@@ -8176,6 +8565,7 @@ const uniAppCssPipelineStrategy = {
|
|
|
8176
8565
|
function createUniAppVitePlugins(options = {}) {
|
|
8177
8566
|
return createViteFrameworkPlugins(options, {
|
|
8178
8567
|
frameworkName: "uni-app",
|
|
8568
|
+
adaptWatchCssBeforeFrameworkCache: true,
|
|
8179
8569
|
cssPipelineStrategy: uniAppCssPipelineStrategy,
|
|
8180
8570
|
styleInjectorDelegate: viteStyleInjectorDelegates.uniApp
|
|
8181
8571
|
});
|
|
@@ -8301,6 +8691,7 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8301
8691
|
function createUniAppXVitePlugins(options = {}) {
|
|
8302
8692
|
return createViteFrameworkPlugins(options, {
|
|
8303
8693
|
frameworkName: "uni-app-x",
|
|
8694
|
+
adaptWatchCssBeforeFrameworkCache: true,
|
|
8304
8695
|
cssPipelineStrategy: uniAppXCssPipelineStrategy,
|
|
8305
8696
|
getExtraPluginPlatform: () => ({ isIosPlatform: resolveUniUtsPlatform().isAppIos }),
|
|
8306
8697
|
styleInjectorDelegate: viteStyleInjectorDelegates.uniApp,
|