weapp-tailwindcss 5.2.13 → 5.3.0
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/README.md +55 -8
- package/README.zh-CN.md +64 -0
- package/dist/bundlers/rspack/rule-match.d.ts +13 -0
- package/dist/bundlers/shared/source-candidates/scan-root.d.ts +1 -1
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +7 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-plugin-order.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -2
- package/dist/{transform-BiHG42Rp.cjs → component-local-style-BirkN5f8.cjs} +33 -168
- package/dist/{transform-52FLRu-0.js → component-local-style-CFL4ClhS.js} +22 -174
- package/dist/generator/index.d.ts +2 -2
- package/dist/generator.cjs +7 -0
- package/dist/generator.js +2 -2
- package/dist/{gulp-DxKLSgXX.cjs → gulp-B0qcNiuP.cjs} +2 -2
- package/dist/{gulp-G--cGMcR.js → gulp-D1vDx4H1.js} +1 -1
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-iTua_Z55.js → hmr-timing-Dq1_msos.js} +19 -15
- package/dist/{hmr-timing-BtqnyxAO.cjs → hmr-timing-pF6k35pP.cjs} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/{pipeline-helpers-DnYpfbat.cjs → pipeline-helpers-DA5-EzbO.cjs} +1 -1
- package/dist/rspack.cjs +124 -7
- package/dist/rspack.js +124 -7
- package/dist/{source-candidate-scan-signature-Ggn8fzkT.cjs → source-candidate-scan-signature-DGQufJk3.cjs} +1 -1
- package/dist/{source-candidate-scan-signature-TKJIs7VF.js → source-candidate-scan-signature-DSsjYtlq.js} +1 -1
- package/dist/tailwindcss/candidates.d.ts +2 -2
- package/dist/transform-BYhgJszj.cjs +200 -0
- package/dist/transform-Ck31voUU.js +201 -0
- package/dist/uni-app-x/component-local-style.d.ts +3 -1
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +1 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +6 -0
- package/dist/{v4-generation-core-D-zVR2mt.cjs → v4-generation-core-BEYGV4eB.cjs} +19 -15
- package/dist/{vite-B577QMUl.js → vite-DBgbFsei.js} +240 -82
- package/dist/{vite-BFWJAH16.cjs → vite-jftHIupF.cjs} +240 -82
- 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-DLJkStre.js → webpack-BSIWFzAA.js} +3 -3
- package/dist/{webpack-DTqFKvcE.cjs → webpack-DhwW2cva.cjs} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +9 -14
- package/README.en.md +0 -17
- package/bin/weapp-tailwindcss.cjs +0 -8
- package/dist/cli/context.d.ts +0 -3
- package/dist/cli/doctor/constants.d.ts +0 -7
- package/dist/cli/doctor/types.d.ts +0 -31
- package/dist/cli/doctor.d.ts +0 -4
- package/dist/cli/helpers/options/format.d.ts +0 -2
- package/dist/cli/helpers/options/parse.d.ts +0 -3
- package/dist/cli/helpers/options/resolve.d.ts +0 -1
- package/dist/cli/helpers/options.d.ts +0 -3
- package/dist/cli/helpers.d.ts +0 -4
- package/dist/cli/mount-options.d.ts +0 -4
- package/dist/cli/types.d.ts +0 -15
- package/dist/cli/vscode-entry.d.ts +0 -14
- package/dist/cli.cjs +0 -37065
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2298
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
2
|
-
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-BP4WmgIo.js";
|
|
2
|
+
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Ot as resolveSourceScanPath, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, lt as hasTailwindGeneratedCss, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-BP4WmgIo.js";
|
|
3
3
|
import { t as omitUndefined } from "./object-B-8IHefx.js";
|
|
4
4
|
import { a as findTailwindConfig, f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-C2K-vjJv.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, st as createSourceCandidateEligibilityMatcher, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-
|
|
6
|
+
import { A as annotateCssSourceTrace, C as stripRequestQuery, D as stripBundlerGeneratedCssMarkers, E as parseBundlerGeneratedCssMarkerBlocks, F as createRuntimeClassSetManager, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, R as isPureLocalCssImportWrapper, S as isSourceStyleRequest, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, a as extractMarkedUserLayerComponentsCss, at as isSourceCandidateRequest, d as runWithConcurrency, f as normalizeMiniProgramGeneratorCssSource, g as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as hasEmptyAtRuleBlockCandidate, m as scoreTailwindV4CssSourceFileMatch, nt as createCompilationDependencyChanges, o as mergeMarkedUserLayerComponentsCss, ot as extractCandidatesFromSource, p as normalizeMiniProgramImportShell, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, s as collectGeneratedRawSourceCandidatesFromCss, st as createSourceCandidateEligibilityMatcher, t as createHmrTimingRecorder, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker } from "./hmr-timing-Dq1_msos.js";
|
|
7
7
|
import { m as createDebug, p as replaceWxml } from "./wxml-B7OAVpXJ.js";
|
|
8
8
|
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-CKQKq4Mv.js";
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-
|
|
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-DSsjYtlq.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
|
+
import { r as shouldEnablePageLocalStyle } from "./component-local-style-CFL4ClhS.js";
|
|
11
12
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import process$1 from "node:process";
|
|
@@ -2811,6 +2812,47 @@ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
2811
2812
|
});
|
|
2812
2813
|
return restored;
|
|
2813
2814
|
}
|
|
2815
|
+
function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
|
|
2816
|
+
const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
2817
|
+
if (output.type !== "chunk") return [];
|
|
2818
|
+
const file = normalizeOutputPathKey(output.fileName || bundleFile);
|
|
2819
|
+
if (file.includes("/")) return [];
|
|
2820
|
+
return [{
|
|
2821
|
+
file,
|
|
2822
|
+
isEntry: output.isEntry === true
|
|
2823
|
+
}];
|
|
2824
|
+
});
|
|
2825
|
+
const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
|
|
2826
|
+
const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => path.posix.parse(chunk.file).name));
|
|
2827
|
+
const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
2828
|
+
if (output.type !== "asset") return [];
|
|
2829
|
+
const file = normalizeOutputPathKey(output.fileName || bundleFile);
|
|
2830
|
+
return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(path.posix.parse(file).name) ? [file] : [];
|
|
2831
|
+
});
|
|
2832
|
+
return candidates.length === 1 ? candidates[0] : void 0;
|
|
2833
|
+
}
|
|
2834
|
+
function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
|
|
2835
|
+
if (options.targetByFile.size === 0) return 0;
|
|
2836
|
+
const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
|
|
2837
|
+
if (!runtimeRootFile) return 0;
|
|
2838
|
+
const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => normalizeOutputPathKey(file) !== normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
|
|
2839
|
+
if (frameworkRootFiles.length !== 1) return 0;
|
|
2840
|
+
const frameworkRootFile = frameworkRootFiles[0];
|
|
2841
|
+
const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(runtimeRootFile))?.[1];
|
|
2842
|
+
const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(frameworkRootFile))?.[1];
|
|
2843
|
+
if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
|
|
2844
|
+
const runtimeSource = runtimeOutput.source.toString();
|
|
2845
|
+
const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
|
|
2846
|
+
if (importedRuntimeFile && normalizeOutputPathKey(importedRuntimeFile) === normalizeOutputPathKey(frameworkRootFile)) return 0;
|
|
2847
|
+
const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
|
|
2848
|
+
if (importedFrameworkFile && normalizeOutputPathKey(importedFrameworkFile) === normalizeOutputPathKey(runtimeRootFile)) return 0;
|
|
2849
|
+
const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
|
|
2850
|
+
runtimeOutput.source = nextSource;
|
|
2851
|
+
options.recordCssAssetResult?.(runtimeRootFile, nextSource);
|
|
2852
|
+
options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
|
|
2853
|
+
options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
|
|
2854
|
+
return 1;
|
|
2855
|
+
}
|
|
2814
2856
|
function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
|
|
2815
2857
|
return enabled === true;
|
|
2816
2858
|
}
|
|
@@ -6169,6 +6211,8 @@ const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
|
6169
6211
|
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
6170
6212
|
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
6171
6213
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
6214
|
+
const RELATIVE_REFERENCE_RE = /@reference\s+(["'])(\.\.?[\\/][^"']+)\1\s*;?/g;
|
|
6215
|
+
const WINDOWS_ABSOLUTE_PATH_RE = /^[a-z]:[\\/]/i;
|
|
6172
6216
|
function isPreprocessorRequest(id, lang) {
|
|
6173
6217
|
const normalizedLang = lang?.toLowerCase();
|
|
6174
6218
|
if (normalizedLang && preprocessorLangs.has(normalizedLang)) return true;
|
|
@@ -6182,6 +6226,15 @@ function resolveUniAppXCssTarget(id) {
|
|
|
6182
6226
|
function isCssModuleExport(code) {
|
|
6183
6227
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
6184
6228
|
}
|
|
6229
|
+
function normalizeRelativeTailwindReferences(code, id) {
|
|
6230
|
+
if (!code.includes("@reference")) return code;
|
|
6231
|
+
const sourceFile = cleanUrl(id);
|
|
6232
|
+
const pathApi = WINDOWS_ABSOLUTE_PATH_RE.test(sourceFile) ? path.win32 : path;
|
|
6233
|
+
const sourceDir = pathApi.dirname(sourceFile);
|
|
6234
|
+
return code.replace(RELATIVE_REFERENCE_RE, (_full, quote, request) => {
|
|
6235
|
+
return `@reference ${quote}${pathApi.resolve(sourceDir, request).replace(/\\/g, "/")}${quote};`;
|
|
6236
|
+
});
|
|
6237
|
+
}
|
|
6185
6238
|
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
6186
6239
|
if (!isPreprocessorRequest(id, lang)) return;
|
|
6187
6240
|
if (options.isIosPlatform) {
|
|
@@ -6194,10 +6247,36 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
6194
6247
|
if (options.isWebGeneratorTarget && !options.isNativeAppStyleTarget) return { result: void 0 };
|
|
6195
6248
|
}
|
|
6196
6249
|
//#endregion
|
|
6250
|
+
//#region src/uni-app-x/vite/web-local-style.ts
|
|
6251
|
+
function isStyleModule(mod) {
|
|
6252
|
+
const request = mod.id ?? mod.url;
|
|
6253
|
+
return typeof request === "string" && /[?&](?:vue&)?type=style(?:&|$)/.test(request);
|
|
6254
|
+
}
|
|
6255
|
+
function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
6256
|
+
const rulesByFile = /* @__PURE__ */ new Map();
|
|
6257
|
+
return {
|
|
6258
|
+
appendToStyle(code, id) {
|
|
6259
|
+
if (!isEnabled()) return code;
|
|
6260
|
+
const rules = rulesByFile.get(cleanUrl(id));
|
|
6261
|
+
return rules ? `${code}\n${rules}` : code;
|
|
6262
|
+
},
|
|
6263
|
+
handleHotUpdate(ctx) {
|
|
6264
|
+
if (!isEnabled() || !/\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file))) return;
|
|
6265
|
+
const styleModules = [...ctx.server.moduleGraph.getModulesByFile?.(ctx.file) ?? []].filter(isStyleModule);
|
|
6266
|
+
if (styleModules.length === 0) return;
|
|
6267
|
+
for (const mod of styleModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
6268
|
+
return [.../* @__PURE__ */ new Set([...ctx.modules, ...styleModules])];
|
|
6269
|
+
},
|
|
6270
|
+
remember(id, rules) {
|
|
6271
|
+
rulesByFile.set(cleanUrl(id), rules);
|
|
6272
|
+
}
|
|
6273
|
+
};
|
|
6274
|
+
}
|
|
6275
|
+
//#endregion
|
|
6197
6276
|
//#region src/uni-app-x/vite.ts
|
|
6198
6277
|
let transformUVuePromise;
|
|
6199
6278
|
function loadTransformUVue() {
|
|
6200
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
6279
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-Ck31voUU.js").then((mod) => mod.transformUVue));
|
|
6201
6280
|
return transformUVuePromise;
|
|
6202
6281
|
}
|
|
6203
6282
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6212,6 +6291,7 @@ function createUniAppXPlugins(options) {
|
|
|
6212
6291
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
6213
6292
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6214
6293
|
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
6294
|
+
const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget);
|
|
6215
6295
|
let componentLocalStyleEnabled;
|
|
6216
6296
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
6217
6297
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
@@ -6236,8 +6316,8 @@ function createUniAppXPlugins(options) {
|
|
|
6236
6316
|
componentLocalStyleEnabled = resolveUniAppXStyleIsolationEnabled(root);
|
|
6237
6317
|
return componentLocalStyleEnabled;
|
|
6238
6318
|
}
|
|
6239
|
-
function
|
|
6240
|
-
return isNativeAppBuildTarget(id)
|
|
6319
|
+
function shouldEnablePageLocalStyleForFile(id) {
|
|
6320
|
+
return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || shouldEnablePageLocalStyle(id));
|
|
6241
6321
|
}
|
|
6242
6322
|
function isHarmonyBuildTarget() {
|
|
6243
6323
|
if (resolveUniUtsPlatform().isAppHarmony) return true;
|
|
@@ -6275,19 +6355,20 @@ function createUniAppXPlugins(options) {
|
|
|
6275
6355
|
const parsed = query ?? parseVueRequest(id).query;
|
|
6276
6356
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
6277
6357
|
if (isCssModuleExport(code)) return;
|
|
6278
|
-
const
|
|
6279
|
-
const
|
|
6358
|
+
const sourceCode = normalizeRelativeTailwindReferences(code, id);
|
|
6359
|
+
const hasTailwindRoot = hasTailwindRootDirectives(sourceCode, { importFallback: true });
|
|
6360
|
+
const hasTailwindApply = hasTailwindApplyDirective(sourceCode);
|
|
6280
6361
|
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
6281
6362
|
const isNativeSfcAuthorStyle = isNativeStyle && resolveUniAppXCssTarget(id) === "uvue";
|
|
6282
6363
|
if (!shouldGenerateCss && (!isNativeStyle || isNativeSfcAuthorStyle)) return;
|
|
6283
|
-
harmonyApply.rememberSource(
|
|
6284
|
-
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(
|
|
6364
|
+
harmonyApply.rememberSource(sourceCode, id);
|
|
6365
|
+
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(sourceCode, id) : sourceCode, {
|
|
6285
6366
|
...hookContext,
|
|
6286
6367
|
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
6287
6368
|
sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
|
|
6288
6369
|
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
6289
6370
|
}) : void 0;
|
|
6290
|
-
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss,
|
|
6371
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode) : generatedCss : sourceCode;
|
|
6291
6372
|
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
6292
6373
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
6293
6374
|
reportStyleWarnings(postcssResult);
|
|
@@ -6322,15 +6403,49 @@ function createUniAppXPlugins(options) {
|
|
|
6322
6403
|
if (!isEnabled()) return;
|
|
6323
6404
|
await runtimeState.readyPromise;
|
|
6324
6405
|
const { query } = parseVueRequest(id);
|
|
6325
|
-
const
|
|
6406
|
+
const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(code, id) : code;
|
|
6407
|
+
const preprocessor = resolvePreprocessorTransform(styleCode, id, query.lang, {
|
|
6326
6408
|
isIosPlatform,
|
|
6327
6409
|
isNativeAppStyleTarget: isNativeAppStyleTarget(),
|
|
6328
6410
|
isWebGeneratorTarget: isWebGeneratorTarget()
|
|
6329
6411
|
});
|
|
6330
|
-
if (preprocessor) return preprocessor.result
|
|
6331
|
-
|
|
6412
|
+
if (preprocessor) return preprocessor.result ?? (styleCode !== code ? {
|
|
6413
|
+
code: styleCode,
|
|
6414
|
+
map: null
|
|
6415
|
+
} : void 0);
|
|
6416
|
+
return transformStyle(styleCode, id, query, this);
|
|
6332
6417
|
}
|
|
6333
6418
|
}];
|
|
6419
|
+
async function transformSfc(code, id, context) {
|
|
6420
|
+
if (isNativeAppBuildTarget(id)) {
|
|
6421
|
+
nativeLocalStyleModuleIds.add(id);
|
|
6422
|
+
nativeLocalStyleModuleIds.add(cleanUrl(id));
|
|
6423
|
+
}
|
|
6424
|
+
harmonyApply.rememberSource(code, id, true);
|
|
6425
|
+
const resolvedConfig = getResolvedConfig();
|
|
6426
|
+
const shouldForceRefresh = resolvedConfig?.command === "serve" || resolvedConfig?.command === "build";
|
|
6427
|
+
const currentRuntimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
|
|
6428
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6429
|
+
const transformUVue = await loadTransformUVue();
|
|
6430
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6431
|
+
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
6432
|
+
const transformOptions = omitUndefined({
|
|
6433
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6434
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6435
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6436
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
6437
|
+
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
6438
|
+
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => webLocalStyle.remember(id, rules) } : {}
|
|
6439
|
+
});
|
|
6440
|
+
const result = Object.keys(transformOptions).length > 0 ? transformUVue(code, id, jsHandler, currentRuntimeSet, transformOptions) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6441
|
+
if (!result?.code) return result;
|
|
6442
|
+
harmonyApply.rememberSource(result.code, id);
|
|
6443
|
+
const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
|
|
6444
|
+
return expandedCode === result.code ? result : {
|
|
6445
|
+
code: expandedCode,
|
|
6446
|
+
map: null
|
|
6447
|
+
};
|
|
6448
|
+
}
|
|
6334
6449
|
const nvuePlugin = {
|
|
6335
6450
|
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
6336
6451
|
enforce: "pre",
|
|
@@ -6343,42 +6458,17 @@ function createUniAppXPlugins(options) {
|
|
|
6343
6458
|
async handler(code, id) {
|
|
6344
6459
|
if (!isEnabled()) return;
|
|
6345
6460
|
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6346
|
-
|
|
6347
|
-
nativeLocalStyleModuleIds.add(id);
|
|
6348
|
-
nativeLocalStyleModuleIds.add(cleanUrl(id));
|
|
6349
|
-
}
|
|
6350
|
-
harmonyApply.rememberSource(code, id, true);
|
|
6351
|
-
const resolvedConfig = getResolvedConfig();
|
|
6352
|
-
const isServeCommand = resolvedConfig?.command === "serve";
|
|
6353
|
-
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
6354
|
-
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
6355
|
-
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6356
|
-
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6357
|
-
const transformUVue = await loadTransformUVue();
|
|
6358
|
-
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6359
|
-
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
6360
|
-
const result = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle ? transformUVue(code, id, jsHandler, currentRuntimeSet, omitUndefined({
|
|
6361
|
-
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6362
|
-
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6363
|
-
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6364
|
-
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
6365
|
-
})) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6366
|
-
if (result?.code) {
|
|
6367
|
-
harmonyApply.rememberSource(result.code, id);
|
|
6368
|
-
const expandedCode = await harmonyApply.expandStyles(result.code, id, this);
|
|
6369
|
-
if (expandedCode !== result.code) return {
|
|
6370
|
-
code: expandedCode,
|
|
6371
|
-
map: null
|
|
6372
|
-
};
|
|
6373
|
-
}
|
|
6374
|
-
return result;
|
|
6461
|
+
return transformSfc(code, id, this);
|
|
6375
6462
|
}
|
|
6376
6463
|
},
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6464
|
+
handleHotUpdate: {
|
|
6465
|
+
order: "post",
|
|
6466
|
+
async handler(ctx) {
|
|
6467
|
+
if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
|
|
6468
|
+
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6469
|
+
if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") await transformSfc(await ctx.read(), ctx.file, this);
|
|
6470
|
+
return webLocalStyle.handleHotUpdate(ctx) ?? nativeHmrReloader.handleHotUpdate(ctx);
|
|
6471
|
+
}
|
|
6382
6472
|
},
|
|
6383
6473
|
async watchChange(id) {
|
|
6384
6474
|
if (!isEnabled()) return;
|
|
@@ -8145,15 +8235,25 @@ function resolveProcessedCssAssets(cssAssets, records, options, bundleFiles) {
|
|
|
8145
8235
|
const recordCss = typeof record === "string" ? record : record.css;
|
|
8146
8236
|
const outputFile = typeof record === "string" ? resolveProcessedCssOutputFile(file, options, bundleFiles) : record.outputFile ?? resolveProcessedCssOutputFile(file, options, bundleFiles);
|
|
8147
8237
|
let output = assetBySourceFile.get(normalizeOutputPathKey(file)) ?? (outputFile ? cssAssets.get(normalizeOutputPathKey(outputFile)) : void 0);
|
|
8238
|
+
let useAssetSource = output !== void 0;
|
|
8148
8239
|
if (!output) {
|
|
8149
8240
|
const matchingAssets = [...cssAssets.values()].filter((candidate) => options.context.isCssAssetProcessed(candidate.asset, candidate.file) && resolveViteProcessedCssAssetSource(candidate.file, candidate.original, (sourceFile) => resolveProcessedCssOutputFile(sourceFile, options, bundleFiles)) === recordCss);
|
|
8150
|
-
if (matchingAssets.length === 1)
|
|
8241
|
+
if (matchingAssets.length === 1) {
|
|
8242
|
+
output = matchingAssets[0];
|
|
8243
|
+
useAssetSource = true;
|
|
8244
|
+
}
|
|
8245
|
+
}
|
|
8246
|
+
if (!output && records.length === 1 && htmlOwnedAssets.length === 1) {
|
|
8247
|
+
output = htmlOwnedAssets[0];
|
|
8248
|
+
useAssetSource = hasTailwindGeneratedCss(output.original) || hasTailwindGeneratedCssMarkers(output.original);
|
|
8151
8249
|
}
|
|
8152
|
-
if (!output && records.length === 1 && htmlOwnedAssets.length === 1) output = htmlOwnedAssets[0];
|
|
8153
8250
|
if (!output) return;
|
|
8154
|
-
const
|
|
8155
|
-
if (
|
|
8156
|
-
processedAssets.set(output,
|
|
8251
|
+
const existing = processedAssets.get(output);
|
|
8252
|
+
if (existing !== void 0 && existing.css !== recordCss) return;
|
|
8253
|
+
processedAssets.set(output, {
|
|
8254
|
+
css: recordCss,
|
|
8255
|
+
useAssetSource
|
|
8256
|
+
});
|
|
8157
8257
|
}
|
|
8158
8258
|
return processedAssets;
|
|
8159
8259
|
}
|
|
@@ -8183,9 +8283,10 @@ function tryFinalizeGenericWebCss(options) {
|
|
|
8183
8283
|
options.recordTiming("processedCss.collect", collectStartedAt);
|
|
8184
8284
|
if (!processedAssets) return false;
|
|
8185
8285
|
const writeStartedAt = performance.now();
|
|
8186
|
-
for (const [{ asset, file, original },
|
|
8286
|
+
for (const [{ asset, file, original }, processed] of processedAssets) {
|
|
8187
8287
|
const finalizeStartedAt = performance.now();
|
|
8188
|
-
const
|
|
8288
|
+
const finalCssSource = processed.useAssetSource ? original : processed.css;
|
|
8289
|
+
const generated = finalizeWebCss(stripBundlerGeneratedCssMarkers(finalCssSource), {
|
|
8189
8290
|
...options.createCssPipelineContext(file),
|
|
8190
8291
|
file
|
|
8191
8292
|
}, context.cssPipelineStrategy);
|
|
@@ -8299,6 +8400,13 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8299
8400
|
}),
|
|
8300
8401
|
targetByFile: frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map()
|
|
8301
8402
|
});
|
|
8403
|
+
if (!isWebGeneratorTarget) linkFrameworkRootStyleToRuntimeEntry(bundle, {
|
|
8404
|
+
debug,
|
|
8405
|
+
matchesCss: opts.cssMatcher,
|
|
8406
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
8407
|
+
recordCssAssetResult,
|
|
8408
|
+
targetByFile: frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map()
|
|
8409
|
+
});
|
|
8302
8410
|
const sourceTraceTokenSources = getSourceCandidateSourcesForEntries ? createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts) : void 0;
|
|
8303
8411
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
8304
8412
|
opts,
|
|
@@ -9357,6 +9465,22 @@ function createViteHmrCandidateState(options) {
|
|
|
9357
9465
|
};
|
|
9358
9466
|
}
|
|
9359
9467
|
//#endregion
|
|
9468
|
+
//#region src/bundlers/vite/shared/framework-plugin-order.ts
|
|
9469
|
+
function orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, beforeExtraPlugin) {
|
|
9470
|
+
const anchor = beforeExtraPlugin ? extraPlugins.findIndex(beforeExtraPlugin) : -1;
|
|
9471
|
+
if (anchor < 0) return [
|
|
9472
|
+
...extraPlugins,
|
|
9473
|
+
...rewritePlugins,
|
|
9474
|
+
sourceCandidatesPlugin
|
|
9475
|
+
];
|
|
9476
|
+
return [
|
|
9477
|
+
...extraPlugins.slice(0, anchor),
|
|
9478
|
+
...rewritePlugins,
|
|
9479
|
+
sourceCandidatesPlugin,
|
|
9480
|
+
...extraPlugins.slice(anchor)
|
|
9481
|
+
];
|
|
9482
|
+
}
|
|
9483
|
+
//#endregion
|
|
9360
9484
|
//#region src/bundlers/vite/official-tailwind-plugins.ts
|
|
9361
9485
|
function isTailwindVitePlugin(plugin) {
|
|
9362
9486
|
if (!plugin || typeof plugin !== "object" || !("name" in plugin)) return false;
|
|
@@ -9697,7 +9821,7 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9697
9821
|
const hotRoot = ctx.server.config?.root ?? process$1.cwd();
|
|
9698
9822
|
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9699
9823
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) {
|
|
9700
|
-
sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
9824
|
+
if (!/\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file))) sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
9701
9825
|
if (sourceModules.some((mod) => {
|
|
9702
9826
|
const id = mod.id ?? mod.url;
|
|
9703
9827
|
return typeof id === "string" && /[?&]macro=true(?:&|$)/.test(id) === false && typeof mod.url === "string" && mod.url.startsWith("/pages/") && /\.vue(?:$|[?#])/i.test(id);
|
|
@@ -9758,6 +9882,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9758
9882
|
const sourceCandidateScanCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9759
9883
|
let sourceScanEntries;
|
|
9760
9884
|
let sourceScanMatcher;
|
|
9885
|
+
let sourceScanBoundaryMatcher;
|
|
9886
|
+
let sourceScanRoots = [];
|
|
9887
|
+
let sourceScanOutDir;
|
|
9888
|
+
let sourceScanEligibleFiles = /* @__PURE__ */ new Set();
|
|
9889
|
+
let sourceScanEligibleFilesRefresh;
|
|
9890
|
+
const sourceScanIneligibleFiles = /* @__PURE__ */ new Set();
|
|
9761
9891
|
let sourceScanDependencies = /* @__PURE__ */ new Set();
|
|
9762
9892
|
let sourceScanExplicit = false;
|
|
9763
9893
|
let sourceCandidateScanSignature;
|
|
@@ -9769,6 +9899,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9769
9899
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9770
9900
|
const invalidate = () => {
|
|
9771
9901
|
sourceCandidateScanInvalidated = true;
|
|
9902
|
+
sourceScanIneligibleFiles.clear();
|
|
9772
9903
|
};
|
|
9773
9904
|
const hasState = () => sourceCandidateScanSignature !== void 0;
|
|
9774
9905
|
const collectRoots = (root, entries) => {
|
|
@@ -9799,9 +9930,32 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9799
9930
|
};
|
|
9800
9931
|
const cacheCurrent = () => {
|
|
9801
9932
|
if (!sourceCandidateScanSignature) return;
|
|
9802
|
-
const
|
|
9803
|
-
|
|
9804
|
-
|
|
9933
|
+
const entry = {
|
|
9934
|
+
eligibleFiles: [...sourceScanEligibleFiles],
|
|
9935
|
+
snapshot: options.sourceCandidateCollector.snapshot()
|
|
9936
|
+
};
|
|
9937
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, entry);
|
|
9938
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, entry);
|
|
9939
|
+
};
|
|
9940
|
+
const updateSourceScanMatchers = (eligibleFiles) => {
|
|
9941
|
+
sourceScanEligibleFiles = new Set(eligibleFiles);
|
|
9942
|
+
const matcherRoots = sourceScanRoots.map((scanRoot) => ({
|
|
9943
|
+
...scanRoot,
|
|
9944
|
+
outDir: sourceScanOutDir
|
|
9945
|
+
}));
|
|
9946
|
+
sourceScanBoundaryMatcher = createSourceCandidateEligibilityMatcher(matcherRoots);
|
|
9947
|
+
sourceScanMatcher = createSourceCandidateEligibilityMatcher(matcherRoots, sourceScanEligibleFiles);
|
|
9948
|
+
};
|
|
9949
|
+
const refreshSourceScanEligibleFiles = async () => {
|
|
9950
|
+
sourceScanEligibleFilesRefresh ?? (sourceScanEligibleFilesRefresh = Promise.all(sourceScanRoots.map((scanRoot) => options.sourceCandidateCollector.resolveScanFiles({
|
|
9951
|
+
entries: scanRoot.entries,
|
|
9952
|
+
explicit: scanRoot.explicit,
|
|
9953
|
+
root: scanRoot.root,
|
|
9954
|
+
outDir: sourceScanOutDir
|
|
9955
|
+
}))).then((files) => updateSourceScanMatchers(files.flat())).finally(() => {
|
|
9956
|
+
sourceScanEligibleFilesRefresh = void 0;
|
|
9957
|
+
}));
|
|
9958
|
+
await sourceScanEligibleFilesRefresh;
|
|
9805
9959
|
};
|
|
9806
9960
|
const shouldDiscoverAutoCssSources = (autoCssSourcesDiscovered) => {
|
|
9807
9961
|
if (!autoCssSourcesDiscovered || !options.isWatchLikeBuild()) return true;
|
|
@@ -9824,10 +9978,8 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9824
9978
|
sourceScanExplicit = sourceScan?.explicit ?? false;
|
|
9825
9979
|
sourceScanDependencies = new Set((sourceScan?.dependencies ?? []).map(normalizeDependency));
|
|
9826
9980
|
const roots = collectRoots(root, sourceScanEntries);
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
outDir
|
|
9830
|
-
})));
|
|
9981
|
+
sourceScanRoots = roots;
|
|
9982
|
+
sourceScanOutDir = outDir;
|
|
9831
9983
|
const nextScanSignature = createSourceCandidateScanSignature({
|
|
9832
9984
|
inlineCandidates: sourceScan?.inlineCandidates,
|
|
9833
9985
|
outDir,
|
|
@@ -9836,14 +9988,16 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9836
9988
|
});
|
|
9837
9989
|
if (hasState() && sourceCandidateScanSignature === nextScanSignature) {
|
|
9838
9990
|
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
9839
|
-
|
|
9991
|
+
cacheCurrent();
|
|
9840
9992
|
options.debug("reuse vite source candidate scan for watch rebuild");
|
|
9841
9993
|
sourceCandidateScanInvalidated = false;
|
|
9842
9994
|
return;
|
|
9843
9995
|
}
|
|
9844
9996
|
const cachedScan = options.isWatchLikeBuild() ? sourceCandidateScanCache.get(nextScanSignature) ?? sourceCandidateScanSnapshotCache.get(nextScanSignature) : void 0;
|
|
9845
9997
|
if (cachedScan) {
|
|
9846
|
-
options.sourceCandidateCollector.restore(cachedScan);
|
|
9998
|
+
options.sourceCandidateCollector.restore(cachedScan.snapshot);
|
|
9999
|
+
sourceScanIneligibleFiles.clear();
|
|
10000
|
+
updateSourceScanMatchers(cachedScan.eligibleFiles);
|
|
9847
10001
|
sourceCandidateScanSignature = nextScanSignature;
|
|
9848
10002
|
options.debug("reuse cached vite source candidate scan for watch rebuild");
|
|
9849
10003
|
sourceCandidateScanInvalidated = false;
|
|
@@ -9852,19 +10006,19 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9852
10006
|
if (options.isWatchLikeBuild()) options.sourceCandidateCollector.resetScan();
|
|
9853
10007
|
else options.sourceCandidateCollector.clearScan();
|
|
9854
10008
|
options.sourceCandidateCollector.syncInline(sourceScan?.inlineCandidates);
|
|
10009
|
+
const eligibleFiles = /* @__PURE__ */ new Set();
|
|
10010
|
+
sourceScanIneligibleFiles.clear();
|
|
9855
10011
|
await Promise.all(roots.map((scanRoot) => options.sourceCandidateCollector.scanRoot({
|
|
9856
10012
|
entries: scanRoot.entries,
|
|
9857
10013
|
explicit: scanRoot.explicit,
|
|
9858
10014
|
root: scanRoot.root,
|
|
9859
|
-
outDir
|
|
10015
|
+
outDir,
|
|
10016
|
+
onFilesResolved: (files) => files.forEach((file) => eligibleFiles.add(file))
|
|
9860
10017
|
})));
|
|
10018
|
+
updateSourceScanMatchers(eligibleFiles);
|
|
9861
10019
|
sourceCandidateScanSignature = nextScanSignature;
|
|
9862
10020
|
sourceCandidateScanInvalidated = false;
|
|
9863
|
-
if (options.isWatchLikeBuild())
|
|
9864
|
-
const snapshot = options.sourceCandidateCollector.snapshot();
|
|
9865
|
-
sourceCandidateScanCache.set(nextScanSignature, snapshot);
|
|
9866
|
-
sourceCandidateScanSnapshotCache.set(nextScanSignature, snapshot);
|
|
9867
|
-
}
|
|
10021
|
+
if (options.isWatchLikeBuild()) cacheCurrent();
|
|
9868
10022
|
};
|
|
9869
10023
|
const waitForPendingSyncs = async () => {
|
|
9870
10024
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
@@ -9889,11 +10043,16 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9889
10043
|
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
9890
10044
|
return previous;
|
|
9891
10045
|
};
|
|
9892
|
-
const syncChangedFile = (id, sourceOverride) => {
|
|
9893
|
-
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return
|
|
10046
|
+
const syncChangedFile = async (id, sourceOverride) => {
|
|
10047
|
+
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return;
|
|
9894
10048
|
const file = cleanUrl(id);
|
|
9895
10049
|
const runtimeAffectingByDependency = isDependency(file);
|
|
9896
10050
|
if (runtimeAffectingByDependency) invalidate();
|
|
10051
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
10052
|
+
if (sourceScanMatcher && !sourceScanMatcher(file) && sourceScanBoundaryMatcher?.(file) && !sourceScanIneligibleFiles.has(resolvedFile)) {
|
|
10053
|
+
await refreshSourceScanEligibleFiles();
|
|
10054
|
+
if (!sourceScanMatcher(file)) sourceScanIneligibleFiles.add(resolvedFile);
|
|
10055
|
+
}
|
|
9897
10056
|
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
9898
10057
|
const change = options.sourceCandidateCollector.remove(file);
|
|
9899
10058
|
cacheCurrent();
|
|
@@ -9902,7 +10061,10 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9902
10061
|
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
9903
10062
|
}
|
|
9904
10063
|
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
9905
|
-
if (existingTask)
|
|
10064
|
+
if (existingTask) {
|
|
10065
|
+
await existingTask;
|
|
10066
|
+
return syncChangedFile(id, sourceOverride);
|
|
10067
|
+
}
|
|
9906
10068
|
const previousSource = options.sourceCandidateCollector.source(file);
|
|
9907
10069
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
9908
10070
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
@@ -9995,9 +10157,6 @@ function collectConfiguredCssEntries(options) {
|
|
|
9995
10157
|
].filter((item) => typeof item === "string" && item.length > 0);
|
|
9996
10158
|
return entries.length > 0 ? [...new Set(entries)] : void 0;
|
|
9997
10159
|
}
|
|
9998
|
-
function normalizeViteStylePlatform(value, appType) {
|
|
9999
|
-
return normalizeFrameworkStylePlatform(value, appType);
|
|
10000
|
-
}
|
|
10001
10160
|
function inferPlatformFromOutDir(outDir) {
|
|
10002
10161
|
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
10003
10162
|
if (!segment) return;
|
|
@@ -10046,10 +10205,10 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10046
10205
|
const shouldRewriteCssImports = opts.rewriteCssImports === true;
|
|
10047
10206
|
let resolvedConfig;
|
|
10048
10207
|
const resolveViteStylePlatform = () => {
|
|
10049
|
-
const explicit =
|
|
10208
|
+
const explicit = normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
10050
10209
|
if (explicit) return explicit;
|
|
10051
10210
|
for (const key of ENV_PLATFORM_KEYS) {
|
|
10052
|
-
const envPlatform =
|
|
10211
|
+
const envPlatform = normalizeFrameworkStylePlatform(process$1.env[key], opts.appType);
|
|
10053
10212
|
if (envPlatform) return envPlatform;
|
|
10054
10213
|
}
|
|
10055
10214
|
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
@@ -10701,9 +10860,7 @@ ${tracedCss}`;
|
|
|
10701
10860
|
syncCssEntriesFromAnchor
|
|
10702
10861
|
});
|
|
10703
10862
|
const plugins = [
|
|
10704
|
-
...extraPlugins,
|
|
10705
|
-
...rewritePlugins,
|
|
10706
|
-
sourceCandidatesPlugin,
|
|
10863
|
+
...orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, frameworkBranch.sourceCandidatesBeforeExtraPlugin),
|
|
10707
10864
|
...createViteCssGenerationPlugins({
|
|
10708
10865
|
generateCss: generateTailwindCssForVitePipeline,
|
|
10709
10866
|
getCommand: () => resolvedConfig?.command,
|
|
@@ -11038,6 +11195,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
11038
11195
|
getExtraPluginPlatform: () => ({ isIosPlatform: resolveUniUtsPlatform().isAppIos }),
|
|
11039
11196
|
styleInjectorDelegate: viteStyleInjectorDelegates.uniApp,
|
|
11040
11197
|
isRuntimeClassSetFeatureEnabled: () => true,
|
|
11198
|
+
sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
|
|
11041
11199
|
createExtraPlugins: (context) => createUniAppXPlugins({
|
|
11042
11200
|
appType: "uni-app-x",
|
|
11043
11201
|
customAttributesEntities: context.customAttributesEntities,
|