weapp-tailwindcss 5.2.8 → 5.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/class-selectors.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/types.d.ts +6 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +3 -2
- package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
- package/dist/bundlers/vite/utils.d.ts +2 -0
- package/dist/cli.cjs +4 -30
- package/dist/cli.js +4 -30
- package/dist/{context-CByXWyhQ.cjs → context-C3TryIjF.cjs} +8 -13
- package/dist/{context-BMkbwnH8.js → context-DbL0d-zB.js} +8 -13
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{gulp-BWhCahA2.js → gulp-CB_GZky7.js} +3 -3
- package/dist/{gulp-BdoorWb5.cjs → gulp-G6af_vyo.cjs} +4 -4
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CJocHeZr.js → hmr-timing-CZu2ITV8.js} +8 -3
- package/dist/{hmr-timing-DiYnyg_W.cjs → hmr-timing-gbPzjYTj.cjs} +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/js/literal-transform.d.ts +1 -1
- package/dist/{pipeline-helpers-CsNLoEX1.cjs → pipeline-helpers-CtIXw85G.cjs} +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/shared/classname-transform.d.ts +2 -3
- package/dist/{source-candidate-scan-signature-D9FXTD9a.cjs → source-candidate-scan-signature-CTX7eBJX.cjs} +1 -1
- package/dist/{source-candidate-scan-signature-of-TmeOs.js → source-candidate-scan-signature-DFZlYd3t.js} +1 -1
- package/dist/{transform-DzVJW6Dp.cjs → transform-9wbmvHcC.cjs} +107 -8
- package/dist/{transform-DVGsr8cV.js → transform-BlsDWgjt.js} +107 -8
- package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +12 -0
- package/dist/{v4-generation-core-BjHT6qGC.cjs → v4-generation-core-BVd_4348.cjs} +12 -1
- package/dist/{vite-V86H6PZa.cjs → vite-DjU_5LY6.cjs} +216 -59
- package/dist/{vite-BJJqWc_F.js → vite-cIvaBul_.js} +215 -58
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +2 -2
- package/dist/{webpack-CzQrloDg.cjs → webpack-B9lRT1no.cjs} +6 -6
- package/dist/{webpack-CkeFhPY2.js → webpack-CvKV7U7L.js} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/{wxml-IBzZSaQC.js → wxml-CWJc0yY-.js} +5 -31
- package/dist/{wxml-DSMNuUaP.cjs → wxml-DUIdXCVa.cjs} +4 -36
- package/package.json +2 -2
|
@@ -3,10 +3,10 @@ import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPl
|
|
|
3
3
|
import { t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
4
4
|
import { _ as resolveTailwindV4EntriesFromCssCached, a as findTailwindConfig, f as createSourceScanMatcher, h as resolveTailwindV4CssDependencies, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-2zdmASlM.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { A as
|
|
7
|
-
import {
|
|
8
|
-
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-
|
|
6
|
+
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-CZu2ITV8.js";
|
|
7
|
+
import { m as createDebug, p as replaceWxml } from "./wxml-CWJc0yY-.js";
|
|
8
|
+
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-DbL0d-zB.js";
|
|
9
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-DFZlYd3t.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
11
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
@@ -1737,6 +1737,16 @@ const htmlLangRE = /\.html?(?:$|\?)/;
|
|
|
1737
1737
|
function isCSSRequest(request) {
|
|
1738
1738
|
return cssLangRE.test(request) || isSourceStyleRequest(request);
|
|
1739
1739
|
}
|
|
1740
|
+
function isWeappViteSidecarRequest(request) {
|
|
1741
|
+
const queryIndex = request.indexOf("?");
|
|
1742
|
+
if (queryIndex < 0) return false;
|
|
1743
|
+
const hashIndex = request.indexOf("#", queryIndex);
|
|
1744
|
+
const query = request.slice(queryIndex + 1, hashIndex < 0 ? void 0 : hashIndex);
|
|
1745
|
+
return new URLSearchParams(query).has("weapp-vite-sidecar");
|
|
1746
|
+
}
|
|
1747
|
+
function resolveViteCssPipelineRequestFile(request) {
|
|
1748
|
+
return isWeappViteSidecarRequest(request) ? cleanUrl(request) : request;
|
|
1749
|
+
}
|
|
1740
1750
|
function isHTMLRequest(request) {
|
|
1741
1751
|
return htmlLangRE.test(request);
|
|
1742
1752
|
}
|
|
@@ -5264,13 +5274,14 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5264
5274
|
//#endregion
|
|
5265
5275
|
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
5266
5276
|
async function finalizeGenerateBundle(options) {
|
|
5267
|
-
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;
|
|
5277
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pendingRememberedCssReplayUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
5268
5278
|
const tasksStart = performance.now();
|
|
5269
5279
|
if (cssTaskFactories.length > 0) {
|
|
5270
5280
|
const cssTask = runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
|
|
5271
5281
|
if (jsAfterCss) await cssTask;
|
|
5272
5282
|
else tasks.push(cssTask);
|
|
5273
5283
|
}
|
|
5284
|
+
prepareJsTransformRuntime?.();
|
|
5274
5285
|
if (jsTaskFactories.length > 0) tasks.push(runWithConcurrency(jsTaskFactories).then(() => void 0));
|
|
5275
5286
|
await Promise.all(tasks);
|
|
5276
5287
|
recordTimingDetail("tasks", tasksStart);
|
|
@@ -5310,7 +5321,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
5310
5321
|
});
|
|
5311
5322
|
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
5312
5323
|
const injectStartedAt = performance.now();
|
|
5313
|
-
|
|
5324
|
+
let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5314
5325
|
opts,
|
|
5315
5326
|
cssPipelineStrategy,
|
|
5316
5327
|
createCssPipelineContext,
|
|
@@ -5327,6 +5338,26 @@ async function finalizeGenerateBundle(options) {
|
|
|
5327
5338
|
onUpdate,
|
|
5328
5339
|
recordTimingDetail
|
|
5329
5340
|
});
|
|
5341
|
+
if (pendingRememberedCssReplayUpdates.length > 0) {
|
|
5342
|
+
for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
5343
|
+
injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5344
|
+
opts,
|
|
5345
|
+
cssPipelineStrategy,
|
|
5346
|
+
createCssPipelineContext,
|
|
5347
|
+
getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
|
|
5348
|
+
css: update.css,
|
|
5349
|
+
injectIntoMain: update.injectIntoMain,
|
|
5350
|
+
outputFile: update.outputFile
|
|
5351
|
+
}]),
|
|
5352
|
+
markCssAssetProcessed,
|
|
5353
|
+
recordCssAssetResult,
|
|
5354
|
+
transformCss: transformWebTargetCss,
|
|
5355
|
+
debug,
|
|
5356
|
+
onUpdate,
|
|
5357
|
+
recordTimingDetail
|
|
5358
|
+
});
|
|
5359
|
+
debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
|
|
5360
|
+
}
|
|
5330
5361
|
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
5331
5362
|
return injected;
|
|
5332
5363
|
};
|
|
@@ -6134,11 +6165,22 @@ function resolveUniAppXCssTarget(id) {
|
|
|
6134
6165
|
function isCssModuleExport(code) {
|
|
6135
6166
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
6136
6167
|
}
|
|
6168
|
+
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
6169
|
+
if (!isPreprocessorRequest(id, lang)) return;
|
|
6170
|
+
if (options.isIosPlatform) {
|
|
6171
|
+
const normalizedCode = normalizeTailwindcssV4InfinityCalcCss(code);
|
|
6172
|
+
return { result: normalizedCode === code ? void 0 : {
|
|
6173
|
+
code: normalizedCode,
|
|
6174
|
+
map: null
|
|
6175
|
+
} };
|
|
6176
|
+
}
|
|
6177
|
+
if (options.isWebGeneratorTarget && !options.isNativeAppStyleTarget) return { result: void 0 };
|
|
6178
|
+
}
|
|
6137
6179
|
//#endregion
|
|
6138
6180
|
//#region src/uni-app-x/vite.ts
|
|
6139
6181
|
let transformUVuePromise;
|
|
6140
6182
|
function loadTransformUVue() {
|
|
6141
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
6183
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-BlsDWgjt.js").then((mod) => mod.transformUVue));
|
|
6142
6184
|
return transformUVuePromise;
|
|
6143
6185
|
}
|
|
6144
6186
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6147,7 +6189,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
|
6147
6189
|
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
6148
6190
|
}
|
|
6149
6191
|
function createUniAppXPlugins(options) {
|
|
6150
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6192
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6151
6193
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
6152
6194
|
const utsPlatform = resolveUniUtsPlatform();
|
|
6153
6195
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
@@ -6263,14 +6305,12 @@ function createUniAppXPlugins(options) {
|
|
|
6263
6305
|
if (!isEnabled()) return;
|
|
6264
6306
|
await runtimeState.readyPromise;
|
|
6265
6307
|
const { query } = parseVueRequest(id);
|
|
6266
|
-
const
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
};
|
|
6273
|
-
}
|
|
6308
|
+
const preprocessor = resolvePreprocessorTransform(code, id, query.lang, {
|
|
6309
|
+
isIosPlatform,
|
|
6310
|
+
isNativeAppStyleTarget: isNativeAppStyleTarget(),
|
|
6311
|
+
isWebGeneratorTarget: isWebGeneratorTarget()
|
|
6312
|
+
});
|
|
6313
|
+
if (preprocessor) return preprocessor.result;
|
|
6274
6314
|
return transformStyle(code, id, query, this);
|
|
6275
6315
|
}
|
|
6276
6316
|
}];
|
|
@@ -6555,10 +6595,33 @@ function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
|
6555
6595
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
6556
6596
|
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
6557
6597
|
}
|
|
6598
|
+
function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
|
|
6599
|
+
const outputKey = normalizeOutputPathKey(outputFile);
|
|
6600
|
+
for (const [shellFile, targetFile] of targetByFile ?? []) if (normalizeOutputPathKey(shellFile) === outputKey) return targetFile;
|
|
6601
|
+
return outputFile;
|
|
6602
|
+
}
|
|
6603
|
+
function createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain) {
|
|
6604
|
+
const updates = [{
|
|
6605
|
+
css,
|
|
6606
|
+
file: sourceFile,
|
|
6607
|
+
injectIntoMain,
|
|
6608
|
+
outputFile
|
|
6609
|
+
}];
|
|
6610
|
+
if (outputFile !== sourceFile) updates.push({
|
|
6611
|
+
css,
|
|
6612
|
+
file: outputFile,
|
|
6613
|
+
injectIntoMain,
|
|
6614
|
+
outputFile
|
|
6615
|
+
});
|
|
6616
|
+
return updates;
|
|
6617
|
+
}
|
|
6558
6618
|
async function processRememberedCssReplay(options) {
|
|
6559
|
-
const { addWatchFile, activeViteCssCacheFiles, bundle, 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, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
6619
|
+
const { addWatchFile, activeViteCssCacheFiles, bundle, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, frameworkRootImportShellTargetByFile, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, pendingRememberedCssReplayUpdates, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
6560
6620
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
6561
|
-
|
|
6621
|
+
const normalizedBundleFiles = new Set(bundleFiles.map(normalizeOutputPathKey));
|
|
6622
|
+
for (const [rememberedOutputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
6623
|
+
const outputFile = resolveRememberedCssReplayOutputFile(rememberedOutputFile, frameworkRootImportShellTargetByFile);
|
|
6624
|
+
if (outputFile !== rememberedOutputFile) debug("css replay use framework root import shell target: %s -> %s", rememberedOutputFile, outputFile);
|
|
6562
6625
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
6563
6626
|
const replayableRememberedGroup = rememberedGroup.filter(({ remembered }) => {
|
|
6564
6627
|
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
@@ -6572,7 +6635,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6572
6635
|
const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
6573
6636
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
6574
6637
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
6575
|
-
const outputCssHandlerOptions = getCssHandlerOptions(
|
|
6638
|
+
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
6576
6639
|
const cssHandlerOptions = {
|
|
6577
6640
|
...getCssHandlerOptions(sourceFile),
|
|
6578
6641
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
@@ -6591,7 +6654,19 @@ async function processRememberedCssReplay(options) {
|
|
|
6591
6654
|
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
6592
6655
|
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
6593
6656
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
6594
|
-
if (bundleFiles.includes(
|
|
6657
|
+
if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
6658
|
+
const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
|
|
6659
|
+
if (allRememberedSignaturesFresh) if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
6660
|
+
else {
|
|
6661
|
+
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
6662
|
+
if (cachedCss != null) {
|
|
6663
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
6664
|
+
metrics.css.cacheHits++;
|
|
6665
|
+
debug("css replay cached result into framework root target: %s", outputFile);
|
|
6666
|
+
continue;
|
|
6667
|
+
}
|
|
6668
|
+
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
6669
|
+
}
|
|
6595
6670
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
6596
6671
|
const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
6597
6672
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
@@ -6599,7 +6674,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6599
6674
|
tokenSources: sourceTraceTokenSources
|
|
6600
6675
|
});
|
|
6601
6676
|
const shouldRecordRememberedReplayCss = useIncrementalMode || isNativeAppStyleTarget;
|
|
6602
|
-
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss;
|
|
6677
|
+
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss && !shouldMergeReplayIntoFrameworkRootTarget;
|
|
6603
6678
|
if (!shouldRecordRememberedReplayCss) continue;
|
|
6604
6679
|
const shouldPreserveLocalImportWrapper = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
6605
6680
|
css: rawSource,
|
|
@@ -6667,14 +6742,10 @@ async function processRememberedCssReplay(options) {
|
|
|
6667
6742
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
6668
6743
|
recordCssAssetResult?.(outputFile, css);
|
|
6669
6744
|
const shouldInjectReplayCssIntoMain = shouldInjectCssIntoMainFromOutput(outputFile, sourceFile, outputCssHandlerOptions);
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
if (outputFile !== sourceFile) recordViteProcessedCssAssetResult?.(outputFile, css, {
|
|
6675
|
-
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
|
|
6676
|
-
outputFile
|
|
6677
|
-
});
|
|
6745
|
+
const injectIntoMain = shouldMergeReplayIntoFrameworkRootTarget ? true : outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain;
|
|
6746
|
+
const replayUpdates = createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain);
|
|
6747
|
+
if (shouldMergeReplayIntoFrameworkRootTarget) pendingRememberedCssReplayUpdates.push(...replayUpdates);
|
|
6748
|
+
else for (const update of replayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
6678
6749
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
6679
6750
|
}
|
|
6680
6751
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
@@ -7442,7 +7513,8 @@ function createGenerateBundleHook$1(context) {
|
|
|
7442
7513
|
const collectedGeneratorCandidates = /* @__PURE__ */ new Set([...runtime, ...sourceCandidates]);
|
|
7443
7514
|
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
7444
7515
|
const filteredSourceCandidates = shouldFilterTailwindV4MiniProgramCandidates ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceCandidates) : sourceCandidates;
|
|
7445
|
-
const
|
|
7516
|
+
const shouldTransformJsBundle = !isWebGeneratorTarget || context.cssPipelineStrategy?.shouldTransformServeJs?.(cssPipelineContext) === true;
|
|
7517
|
+
const transformRuntime = isWebGeneratorTarget ? /* @__PURE__ */ new Set() : shouldFilterTailwindV4MiniProgramCandidates ? new Set(runtime) : new Set(filteredGeneratorCandidates);
|
|
7446
7518
|
const generatorRuntime = filteredGeneratorCandidates;
|
|
7447
7519
|
await validateRuntimeCandidates({
|
|
7448
7520
|
cssEntries: snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset"),
|
|
@@ -7531,7 +7603,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7531
7603
|
if (forceRuntimeRefreshBySource) debug("runtimeSet forced refresh due to source changes: html=%d js=%d", snapshot.runtimeAffectingChangedByType.html.size, snapshot.runtimeAffectingChangedByType.js.size);
|
|
7532
7604
|
debug("get runtimeSet, class count: %d, transform class count: %d", runtime.size, transformRuntime.size);
|
|
7533
7605
|
const runtimeSignature = getRuntimeClassSetSignature(runtimeState.tailwindRuntime) ?? "runtime:missing";
|
|
7534
|
-
const transformRuntimeSignature = createCandidateSignature(transformRuntime);
|
|
7606
|
+
const transformRuntimeSignature = isWebGeneratorTarget ? generatorCandidateSignature : createCandidateSignature(transformRuntime);
|
|
7535
7607
|
const shouldProcessTailwindGeneration = !useIncrementalMode || hasRuntimeAffectingChanges || generatorCandidatesChanged || snapshot.processFiles.css.size > 0;
|
|
7536
7608
|
const { applyLinkedUpdates, pendingLinkedUpdates } = createLinkedUpdateHelpers({
|
|
7537
7609
|
jsEntries,
|
|
@@ -7554,7 +7626,6 @@ function createGenerateBundleHook$1(context) {
|
|
|
7554
7626
|
...extra
|
|
7555
7627
|
} : void 0);
|
|
7556
7628
|
};
|
|
7557
|
-
const shouldTransformJsBundle = !isWebGeneratorTarget || context.cssPipelineStrategy?.shouldTransformServeJs?.(cssPipelineContext) === true;
|
|
7558
7629
|
const linkedByEntry = useIncrementalMode ? /* @__PURE__ */ new Map() : void 0;
|
|
7559
7630
|
const sharedCssResultCache = /* @__PURE__ */ new Map();
|
|
7560
7631
|
const activeProcessCacheKeys = /* @__PURE__ */ new Set();
|
|
@@ -7566,6 +7637,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7566
7637
|
const tasks = [];
|
|
7567
7638
|
const cssTaskFactories = [];
|
|
7568
7639
|
const jsTaskFactories = [];
|
|
7640
|
+
const pendingRememberedCssReplayUpdates = [];
|
|
7569
7641
|
const entryPlanningStartedAt = performance.now();
|
|
7570
7642
|
for (const entry of snapshot.entries) {
|
|
7571
7643
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
@@ -7791,6 +7863,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7791
7863
|
debug,
|
|
7792
7864
|
defaultStyleOutputExtension,
|
|
7793
7865
|
emitOrReplayCssAsset,
|
|
7866
|
+
frameworkRootImportShellTargetByFile,
|
|
7794
7867
|
generatorPlatform,
|
|
7795
7868
|
generatorRuntime,
|
|
7796
7869
|
getCssHandlerOptions,
|
|
@@ -7807,6 +7880,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7807
7880
|
normalizeViteCssCacheKey,
|
|
7808
7881
|
onUpdate,
|
|
7809
7882
|
opts,
|
|
7883
|
+
pendingRememberedCssReplayUpdates,
|
|
7810
7884
|
recordCssAssetResult,
|
|
7811
7885
|
recordViteProcessedCssAssetResult,
|
|
7812
7886
|
rootDir,
|
|
@@ -7820,6 +7894,17 @@ function createGenerateBundleHook$1(context) {
|
|
|
7820
7894
|
useIncrementalMode
|
|
7821
7895
|
});
|
|
7822
7896
|
recordTimingDetail("rememberedCss.plan", rememberedCssStartedAt);
|
|
7897
|
+
const prepareJsTransformRuntime = isWebGeneratorTarget && shouldTransformJsBundle ? () => {
|
|
7898
|
+
transformRuntime.clear();
|
|
7899
|
+
const cssSources = /* @__PURE__ */ new Set();
|
|
7900
|
+
for (const output of Object.values(bundle)) {
|
|
7901
|
+
if (output.type !== "asset" || !opts.cssMatcher(output.fileName)) continue;
|
|
7902
|
+
cssSources.add(typeof output.source === "string" ? output.source : Buffer.from(output.source).toString());
|
|
7903
|
+
}
|
|
7904
|
+
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) cssSources.add(typeof record === "string" ? record : record.css);
|
|
7905
|
+
for (const candidate of collectGeneratedRawSourceCandidatesFromCss(generatorRuntime, cssSources, opts.escapeMap)) transformRuntime.add(candidate);
|
|
7906
|
+
debug("rebuild webview JS transform class set from generated CSS: %d", transformRuntime.size);
|
|
7907
|
+
} : void 0;
|
|
7823
7908
|
await finalizeGenerateBundle({
|
|
7824
7909
|
activeProcessCacheKeys,
|
|
7825
7910
|
activeProcessHashKeys,
|
|
@@ -7846,7 +7931,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7846
7931
|
isNativeAppStyleTarget,
|
|
7847
7932
|
isViteProcessedCssAsset,
|
|
7848
7933
|
isWebGeneratorTarget,
|
|
7849
|
-
jsAfterCss: shouldFilterTailwindV4MiniProgramCandidates && cssTaskFactories.length > 0,
|
|
7934
|
+
jsAfterCss: (shouldFilterTailwindV4MiniProgramCandidates || isWebGeneratorTarget && shouldTransformJsBundle) && cssTaskFactories.length > 0,
|
|
7850
7935
|
jsTaskFactories,
|
|
7851
7936
|
lastCssResultByFile,
|
|
7852
7937
|
lastCssSourceHashByFile,
|
|
@@ -7858,6 +7943,8 @@ function createGenerateBundleHook$1(context) {
|
|
|
7858
7943
|
opts,
|
|
7859
7944
|
outDir,
|
|
7860
7945
|
pendingLinkedUpdates,
|
|
7946
|
+
pendingRememberedCssReplayUpdates,
|
|
7947
|
+
prepareJsTransformRuntime,
|
|
7861
7948
|
pruneViteCssCaches,
|
|
7862
7949
|
recordCssAssetResult,
|
|
7863
7950
|
recordTimingDetail,
|
|
@@ -8346,6 +8433,7 @@ function normalizeKnownSfcSourceKey(file) {
|
|
|
8346
8433
|
return normalizeOutputPathKey(path.resolve(cleanUrl(file)));
|
|
8347
8434
|
}
|
|
8348
8435
|
function shouldCollectTransformedSourceCandidates(id) {
|
|
8436
|
+
if (isWeappViteSidecarRequest(id)) return false;
|
|
8349
8437
|
if (id.search(/[?#]/) < 0) return true;
|
|
8350
8438
|
const file = cleanUrl(id);
|
|
8351
8439
|
return !SFC_COMPONENT_FILE_RE.test(file);
|
|
@@ -8950,24 +9038,27 @@ function wrapViteCssPostTransform(config, transformCss) {
|
|
|
8950
9038
|
}
|
|
8951
9039
|
//#endregion
|
|
8952
9040
|
//#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
|
|
8953
|
-
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
8954
9041
|
function createViteHmrCandidateState(options) {
|
|
8955
9042
|
let pendingChange;
|
|
8956
9043
|
let pendingCssTargetFiles;
|
|
9044
|
+
let pendingTargetsArmed = false;
|
|
8957
9045
|
let pendingFullRegeneration = false;
|
|
8958
9046
|
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey(cleanUrl(file));
|
|
8959
9047
|
const clear = () => {
|
|
8960
9048
|
pendingChange = void 0;
|
|
8961
9049
|
pendingCssTargetFiles = void 0;
|
|
9050
|
+
pendingTargetsArmed = false;
|
|
8962
9051
|
pendingFullRegeneration = false;
|
|
8963
9052
|
};
|
|
8964
9053
|
const queueFullRegeneration = () => {
|
|
8965
9054
|
pendingChange = void 0;
|
|
8966
9055
|
pendingCssTargetFiles = void 0;
|
|
9056
|
+
pendingTargetsArmed = false;
|
|
8967
9057
|
pendingFullRegeneration = true;
|
|
8968
9058
|
};
|
|
8969
9059
|
const queueChange = (change) => {
|
|
8970
9060
|
var _pendingChange;
|
|
9061
|
+
if (pendingFullRegeneration) return;
|
|
8971
9062
|
pendingFullRegeneration = false;
|
|
8972
9063
|
if (!pendingChange) {
|
|
8973
9064
|
pendingChange = {
|
|
@@ -8989,7 +9080,7 @@ function createViteHmrCandidateState(options) {
|
|
|
8989
9080
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8990
9081
|
...change,
|
|
8991
9082
|
file,
|
|
8992
|
-
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || isSourceStyleRequest(file)
|
|
9083
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || isSourceStyleRequest(file)
|
|
8993
9084
|
});
|
|
8994
9085
|
const apply = (change) => {
|
|
8995
9086
|
if (isSourceStyleRequest(change.file)) {
|
|
@@ -9003,7 +9094,7 @@ function createViteHmrCandidateState(options) {
|
|
|
9003
9094
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
9004
9095
|
if (preserveDeletedCss) {
|
|
9005
9096
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
9006
|
-
else if (!pendingChange) clear();
|
|
9097
|
+
else if (!pendingChange && !pendingFullRegeneration) clear();
|
|
9007
9098
|
return change;
|
|
9008
9099
|
}
|
|
9009
9100
|
clear();
|
|
@@ -9012,28 +9103,26 @@ function createViteHmrCandidateState(options) {
|
|
|
9012
9103
|
};
|
|
9013
9104
|
const resolve = (generatorCode, file) => {
|
|
9014
9105
|
const fileKey = normalizeCssTargetFile(file);
|
|
9015
|
-
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) ||
|
|
9106
|
+
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingTargetsArmed && !pendingCssTargetFiles?.has(fileKey)) return;
|
|
9016
9107
|
return pendingChange;
|
|
9017
9108
|
};
|
|
9018
9109
|
const finishTarget = (file) => {
|
|
9019
|
-
if (!pendingChange) return;
|
|
9020
|
-
if (!pendingCssTargetFiles)
|
|
9021
|
-
clear();
|
|
9022
|
-
return;
|
|
9023
|
-
}
|
|
9110
|
+
if (!pendingChange && !pendingFullRegeneration) return;
|
|
9111
|
+
if (!pendingTargetsArmed || !pendingCssTargetFiles) return;
|
|
9024
9112
|
pendingCssTargetFiles.delete(normalizeCssTargetFile(file));
|
|
9025
9113
|
if (pendingCssTargetFiles.size === 0) clear();
|
|
9026
9114
|
};
|
|
9027
9115
|
const armTargets = (cssModules, fallbackCssIds) => {
|
|
9028
|
-
if (!pendingChange) {
|
|
9116
|
+
if (!pendingChange && !pendingFullRegeneration) {
|
|
9029
9117
|
pendingCssTargetFiles = void 0;
|
|
9118
|
+
pendingTargetsArmed = false;
|
|
9030
9119
|
return;
|
|
9031
9120
|
}
|
|
9032
9121
|
const targets = /* @__PURE__ */ new Set();
|
|
9033
9122
|
const addTarget = (file) => {
|
|
9034
9123
|
if (!file) return;
|
|
9035
9124
|
const key = normalizeCssTargetFile(file);
|
|
9036
|
-
if (options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
9125
|
+
if (pendingFullRegeneration || options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
9037
9126
|
};
|
|
9038
9127
|
for (const module of cssModules) {
|
|
9039
9128
|
addTarget(module.id);
|
|
@@ -9041,7 +9130,28 @@ function createViteHmrCandidateState(options) {
|
|
|
9041
9130
|
addTarget(module.url);
|
|
9042
9131
|
}
|
|
9043
9132
|
for (const id of fallbackCssIds) addTarget(id);
|
|
9044
|
-
pendingCssTargetFiles = targets
|
|
9133
|
+
pendingCssTargetFiles = targets;
|
|
9134
|
+
pendingTargetsArmed = true;
|
|
9135
|
+
};
|
|
9136
|
+
const reconcileRuntimeCandidates = (file, candidates, rootCssIds) => {
|
|
9137
|
+
if (options.getCommand() !== "serve" || pendingFullRegeneration) return;
|
|
9138
|
+
const generatedClassSets = [];
|
|
9139
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
9140
|
+
for (const id of rootCssIds) {
|
|
9141
|
+
const fileKey = normalizeCssTargetFile(id);
|
|
9142
|
+
if (seenFiles.has(fileKey)) continue;
|
|
9143
|
+
seenFiles.add(fileKey);
|
|
9144
|
+
const classSet = options.generatedClassSetByFile.get(fileKey);
|
|
9145
|
+
if (classSet) generatedClassSets.push(classSet);
|
|
9146
|
+
}
|
|
9147
|
+
if (generatedClassSets.length === 0) return;
|
|
9148
|
+
const addedCandidates = /* @__PURE__ */ new Set();
|
|
9149
|
+
for (const candidate of candidates) if (generatedClassSets.some((classSet) => !classSet.has(candidate))) addedCandidates.add(candidate);
|
|
9150
|
+
if (addedCandidates.size === 0) return;
|
|
9151
|
+
apply(createChange(file, {
|
|
9152
|
+
addedCandidates,
|
|
9153
|
+
removedCandidates: /* @__PURE__ */ new Set()
|
|
9154
|
+
}));
|
|
9045
9155
|
};
|
|
9046
9156
|
return {
|
|
9047
9157
|
apply,
|
|
@@ -9050,13 +9160,19 @@ function createViteHmrCandidateState(options) {
|
|
|
9050
9160
|
createChange,
|
|
9051
9161
|
finishTarget,
|
|
9052
9162
|
hasPendingCandidateAppend: () => pendingChange != null && !pendingChange.runtimeAffecting && pendingChange.addedCandidates.size > 0,
|
|
9053
|
-
hasPendingChange: () => pendingChange != null,
|
|
9163
|
+
hasPendingChange: () => pendingChange != null || pendingFullRegeneration,
|
|
9054
9164
|
queueFullRegeneration,
|
|
9165
|
+
reconcileRuntimeCandidates,
|
|
9055
9166
|
resolve,
|
|
9056
|
-
shouldForceFullRegeneration: (resolved) =>
|
|
9167
|
+
shouldForceFullRegeneration: (file, resolved) => {
|
|
9168
|
+
if (options.getCommand() !== "serve") return false;
|
|
9169
|
+
if (pendingFullRegeneration) return pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9170
|
+
return pendingChange != null && !resolved && pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9171
|
+
},
|
|
9057
9172
|
snapshotDebugState: () => ({
|
|
9058
9173
|
pendingAddedCandidates: pendingChange?.addedCandidates.size ?? 0,
|
|
9059
|
-
pendingCssTargets: pendingCssTargetFiles?.size ?? 0
|
|
9174
|
+
pendingCssTargets: pendingCssTargetFiles?.size ?? 0,
|
|
9175
|
+
pendingFullRegeneration
|
|
9060
9176
|
})
|
|
9061
9177
|
};
|
|
9062
9178
|
}
|
|
@@ -9286,7 +9402,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9286
9402
|
let transformedCode = code;
|
|
9287
9403
|
if (options.shouldOwnTailwindGeneration && !options.resolveCurrentGeneratorBranch().isWeb && isCSSRequest(id)) transformedCode = options.transformEarlyMiniProgramCss(code);
|
|
9288
9404
|
const shouldReturnTransformedCode = transformedCode !== code;
|
|
9289
|
-
if (options.shouldOwnTailwindGeneration) {
|
|
9405
|
+
if (options.shouldOwnTailwindGeneration && shouldCollectTransformedSourceCandidates(id)) {
|
|
9290
9406
|
options.cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
9291
9407
|
if (isCSSRequest(id) && hasTailwindRootDirectives(transformedCode, { importFallback: options.resolveCurrentGeneratorOptions().importFallback })) options.rememberTailwindRootCssModule(id);
|
|
9292
9408
|
}
|
|
@@ -9350,6 +9466,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9350
9466
|
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9351
9467
|
}
|
|
9352
9468
|
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9469
|
+
options.sourceScanSession.consumeHotUpdateChange(ctx.file);
|
|
9353
9470
|
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9354
9471
|
let canUseHmrCandidateAppend = false;
|
|
9355
9472
|
if (isSourceCandidateHotUpdate) {
|
|
@@ -9368,6 +9485,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9368
9485
|
}
|
|
9369
9486
|
}
|
|
9370
9487
|
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9488
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
|
|
9371
9489
|
const cssModules = await resolveHotTailwindCssModules(ctx, isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9372
9490
|
const hotRoot = ctx.server.config?.root ?? process$1.cwd();
|
|
9373
9491
|
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
@@ -9386,7 +9504,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9386
9504
|
}
|
|
9387
9505
|
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
9388
9506
|
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9389
|
-
if (
|
|
9507
|
+
if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
|
|
9390
9508
|
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
9391
9509
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
9392
9510
|
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
@@ -9401,6 +9519,16 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9401
9519
|
};
|
|
9402
9520
|
}
|
|
9403
9521
|
//#endregion
|
|
9522
|
+
//#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
|
|
9523
|
+
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
9524
|
+
function createFrameworkHmrRuntimeSignature(file, source) {
|
|
9525
|
+
if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
|
|
9526
|
+
return (isSfcStyleSourceFile(cleanUrl(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
9527
|
+
}
|
|
9528
|
+
function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
|
|
9529
|
+
return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
|
|
9530
|
+
}
|
|
9531
|
+
//#endregion
|
|
9404
9532
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9405
9533
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9406
9534
|
const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
@@ -9419,6 +9547,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9419
9547
|
let sourceCandidateScanInvalidated = true;
|
|
9420
9548
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
9421
9549
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
9550
|
+
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
9422
9551
|
const normalizeDependency = (file) => path.normalize(path.resolve(cleanUrl(file)));
|
|
9423
9552
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9424
9553
|
const invalidate = () => {
|
|
@@ -9520,6 +9649,26 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9520
9649
|
const waitForPendingSyncs = async () => {
|
|
9521
9650
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
9522
9651
|
};
|
|
9652
|
+
const rememberHotUpdateChange = (change) => {
|
|
9653
|
+
if (!change) return;
|
|
9654
|
+
const previous = pendingHotUpdateChangeByFile.get(change.file);
|
|
9655
|
+
if (!previous) {
|
|
9656
|
+
const remembered = {
|
|
9657
|
+
...change,
|
|
9658
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
9659
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
9660
|
+
};
|
|
9661
|
+
pendingHotUpdateChangeByFile.set(change.file, remembered);
|
|
9662
|
+
return remembered;
|
|
9663
|
+
}
|
|
9664
|
+
for (const candidate of change.addedCandidates) {
|
|
9665
|
+
previous.addedCandidates.add(candidate);
|
|
9666
|
+
previous.removedCandidates.delete(candidate);
|
|
9667
|
+
}
|
|
9668
|
+
for (const candidate of change.removedCandidates) if (!previous.addedCandidates.delete(candidate)) previous.removedCandidates.add(candidate);
|
|
9669
|
+
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
9670
|
+
return previous;
|
|
9671
|
+
};
|
|
9523
9672
|
const syncChangedFile = (id, sourceOverride) => {
|
|
9524
9673
|
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return Promise.resolve(void 0);
|
|
9525
9674
|
const file = cleanUrl(id);
|
|
@@ -9530,15 +9679,18 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9530
9679
|
cacheCurrent();
|
|
9531
9680
|
return (isSourceStyleRequest(file) ? readFile(file, "utf8").then((source) => options.cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
9532
9681
|
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") options.debug("remembered css source watch refresh failed: %s %O", file, error);
|
|
9533
|
-
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true })));
|
|
9682
|
+
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
9534
9683
|
}
|
|
9535
9684
|
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
9536
9685
|
if (existingTask) return existingTask.then(() => syncChangedFile(id, sourceOverride));
|
|
9686
|
+
const previousSource = options.sourceCandidateCollector.source(file);
|
|
9537
9687
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
9538
9688
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
9539
9689
|
}).then((change) => {
|
|
9540
9690
|
cacheCurrent();
|
|
9541
|
-
|
|
9691
|
+
const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
|
|
9692
|
+
const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
|
|
9693
|
+
return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
|
|
9542
9694
|
}).finally(() => {
|
|
9543
9695
|
pendingSourceCandidateSyncs.delete(task);
|
|
9544
9696
|
pendingSourceCandidateSyncByFile.delete(file);
|
|
@@ -9552,9 +9704,11 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9552
9704
|
};
|
|
9553
9705
|
return {
|
|
9554
9706
|
cacheCurrent,
|
|
9707
|
+
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete(cleanUrl(id)),
|
|
9555
9708
|
getStats: () => ({
|
|
9556
9709
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
9557
9710
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
9711
|
+
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
9558
9712
|
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
9559
9713
|
}),
|
|
9560
9714
|
invalidate,
|
|
@@ -9880,8 +10034,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9880
10034
|
generatedClassSetByFile,
|
|
9881
10035
|
getCommand: () => resolvedConfig?.command,
|
|
9882
10036
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9883
|
-
|
|
9884
|
-
isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
|
|
10037
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
|
|
9885
10038
|
});
|
|
9886
10039
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9887
10040
|
cssMemory,
|
|
@@ -9971,7 +10124,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9971
10124
|
await sourceScanSession.waitForPendingSyncs();
|
|
9972
10125
|
const file = cleanUrl(id);
|
|
9973
10126
|
const inferredSfcStyleRequest = isSfcStyleSourceFile(file) ? resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
9974
|
-
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? id : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
10127
|
+
const requestFile = isCSSRequest(id) ? inferredSfcStyleRequest === file ? resolveViteCssPipelineRequestFile(id) : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
9975
10128
|
if (!isCSSRequest(requestFile) || opts.htmlMatcher(file) || isHTMLRequest(file)) return;
|
|
9976
10129
|
const generatorCode = normalizeEmptyTailwindCustomVariants(code);
|
|
9977
10130
|
const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
|
|
@@ -9989,7 +10142,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9989
10142
|
const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
|
|
9990
10143
|
const transient = hookContext?.transient === true;
|
|
9991
10144
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9992
|
-
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
10145
|
+
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(file, pendingHmrChange !== void 0);
|
|
9993
10146
|
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9994
10147
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9995
10148
|
css: generatorTransformCode,
|
|
@@ -10009,7 +10162,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10009
10162
|
markViteProcessedCssSource(file);
|
|
10010
10163
|
rememberTailwindRootCssModule(id);
|
|
10011
10164
|
recordGeneratorCandidates(fullRuntime);
|
|
10012
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10165
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
10013
10166
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
10014
10167
|
cssMemory.rememberCssSource({
|
|
10015
10168
|
outputFile,
|
|
@@ -10120,7 +10273,7 @@ ${previousTracedCss}`;
|
|
|
10120
10273
|
markViteProcessedCssSource(file);
|
|
10121
10274
|
if (hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
10122
10275
|
recordGeneratorCandidates(fullRuntime);
|
|
10123
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10276
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
10124
10277
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
10125
10278
|
cssMemory.rememberCssSource({
|
|
10126
10279
|
outputFile,
|
|
@@ -10239,6 +10392,8 @@ ${tracedCss}`;
|
|
|
10239
10392
|
getResolvedConfig,
|
|
10240
10393
|
isEnabled: shouldEnableFrameworkExtraPlugins,
|
|
10241
10394
|
isIosPlatform: extraPluginPlatform.isIosPlatform === true,
|
|
10395
|
+
isNativeAppStyleTarget: () => frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext()) === true,
|
|
10396
|
+
isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10242
10397
|
jsHandler,
|
|
10243
10398
|
mainCssChunkMatcher,
|
|
10244
10399
|
runtimeState,
|
|
@@ -10657,6 +10812,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10657
10812
|
getResolvedConfig: context.getResolvedConfig,
|
|
10658
10813
|
isEnabled: context.isEnabled,
|
|
10659
10814
|
isIosPlatform: context.isIosPlatform,
|
|
10815
|
+
isNativeAppStyleTarget: context.isNativeAppStyleTarget,
|
|
10816
|
+
isWebGeneratorTarget: context.isWebGeneratorTarget,
|
|
10660
10817
|
jsHandler: context.jsHandler,
|
|
10661
10818
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10662
10819
|
runtimeState: context.runtimeState,
|