weapp-tailwindcss 5.3.6 → 5.4.1
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 +3 -3
- package/README.zh-CN.md +4 -4
- package/dist/bundlers/shared/framework-postcss.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +3 -1
- package/dist/bundlers/shared/source-candidates/snapshot.d.ts +19 -0
- package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/views.d.ts +12 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +9 -1
- package/dist/bundlers/vite/capability-profile.d.ts +18 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +12 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +2 -2
- package/dist/bundlers/vite/shared/configured-css-entry-observer.d.ts +29 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -0
- package/dist/bundlers/vite/shared/framework-css-generation-queue.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-hmr-module-version.d.ts +9 -0
- package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +5 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +12 -2
- package/dist/compiler/compilation-session-pool.d.ts +1 -0
- package/dist/compiler/framework-compiler-session.d.ts +21 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/{context-DTLRADfE.cjs → compiler-CDAz4SwJ.cjs} +907 -11
- package/dist/{context-4ittVpgt.js → compiler-DWcUgi3A.js} +813 -6
- package/dist/context/handlers.d.ts +1 -1
- package/dist/core/compiler/compiler.d.ts +2 -0
- package/dist/core/compiler/generation-cache.d.ts +30 -0
- package/dist/core/compiler/generation-state.d.ts +17 -0
- package/dist/core/compiler/index.d.ts +2 -0
- package/dist/core/compiler/root-store.d.ts +41 -0
- package/dist/core/compiler/snapshot.d.ts +35 -0
- package/dist/core/compiler/source-fingerprint.d.ts +3 -0
- package/dist/core/compiler/transforms.d.ts +15 -0
- package/dist/core/compiler/types.d.ts +75 -0
- package/dist/core.cjs +34 -8
- package/dist/core.d.ts +4 -1
- package/dist/core.js +3 -2
- package/dist/framework/index.d.ts +3 -1
- package/dist/framework.cjs +6 -1
- package/dist/framework.js +6 -1
- package/dist/{generator-EnTXLBlK.js → generator-BjK5PRR-.js} +28 -10
- package/dist/{generator-DKiYbTFR.cjs → generator-WlhrtNa3.cjs} +26 -8
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DwtrU4V1.js → gulp-BbMMp7vY.js} +7 -7
- package/dist/{gulp-CUysZjW3.cjs → gulp-CBu_waef.cjs} +14 -16
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-utmOgn6p.js → hmr-timing-B_4sAvsk.js} +369 -291
- package/dist/{hmr-timing-Cvh5UgnM.cjs → hmr-timing-CYhNto2U.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CyVXL3h6.cjs → pipeline-helpers-Du8eAtMG.cjs} +6 -6
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -3
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{source-candidate-scan-signature-BNt7NrrI.cjs → source-candidate-scan-signature-ZOm0O17V.cjs} +5 -5
- package/dist/{source-candidate-scan-signature-CDrLxVKu.js → source-candidate-scan-signature-wieibgE7.js} +3 -3
- package/dist/{tailwindcss-ChnpCv25.js → tailwindcss-9xmoCkaR.js} +1 -1
- package/dist/{tailwindcss-CexDJBhx.cjs → tailwindcss-D3jltF7M.cjs} +763 -5
- package/dist/{transform-CL-UZW1U.cjs → transform-C6k9zTQR.cjs} +12 -4
- package/dist/{transform-Bfi1_VgN.js → transform-DQhgAarN.js} +12 -4
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/uni-app-x/component-local-style.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite/asset-task.d.ts +21 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +8 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +2 -1
- package/dist/uni-app-x/vite.d.ts +1 -21
- package/dist/{v4-generation-core-Dhsu9Deu.cjs → v4-generation-core-BhYkeoZ4.cjs} +378 -300
- package/dist/{vite-DMX5zoID.cjs → vite-B0cvyfSY.cjs} +807 -200
- package/dist/{vite-DJkhb8n1.js → vite-Fu6GTjIY.js} +774 -165
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
- package/dist/{webpack-Cpy_yggg.cjs → webpack-Amn5lmnx.cjs} +33 -35
- package/dist/{webpack-CzhrD9p3.js → webpack-BKHO-WSM.js} +10 -10
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/wxml/utils.d.ts +1 -1
- package/dist/{wxml-B7OAVpXJ.js → wxml-CvKyV69S.js} +10 -2
- package/dist/{wxml-PrK-8ARX.cjs → wxml-o-CUulAM.cjs} +40 -32
- package/package.json +12 -11
- package/dist/options-BJrtIQbH.cjs +0 -768
- package/dist/style-options-DW30H5PV.cjs +0 -82
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-WlhrtNa3.cjs");
|
|
4
4
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
5
|
-
const
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-D3jltF7M.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
8
|
-
const require_wxml = require("./wxml-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const require_style_options = require("./style-options-DW30H5PV.cjs");
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BNt7NrrI.cjs");
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-BhYkeoZ4.cjs");
|
|
8
|
+
const require_wxml = require("./wxml-o-CUulAM.cjs");
|
|
9
|
+
const require_compiler = require("./compiler-CDAz4SwJ.cjs");
|
|
10
|
+
const require_hmr_timing = require("./hmr-timing-CYhNto2U.cjs");
|
|
11
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-ZOm0O17V.cjs");
|
|
14
12
|
const require_local_style_matcher = require("./local-style-matcher-DRpFEu1s.cjs");
|
|
15
13
|
require("./logger-TlKT3xmR.cjs");
|
|
16
14
|
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
@@ -27,11 +25,35 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
27
25
|
let micromatch = require("micromatch");
|
|
28
26
|
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
29
27
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
28
|
+
let node_buffer = require("node:buffer");
|
|
30
29
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
31
30
|
let node_url = require("node:url");
|
|
32
|
-
let node_buffer = require("node:buffer");
|
|
33
31
|
let node_async_hooks = require("node:async_hooks");
|
|
34
32
|
let comment_json = require("comment-json");
|
|
33
|
+
//#region src/bundlers/vite/capability-profile.ts
|
|
34
|
+
const frameworkViteCapabilityProfile = {
|
|
35
|
+
name: "framework",
|
|
36
|
+
frameworkName: "generic",
|
|
37
|
+
generatorTarget: void 0,
|
|
38
|
+
platformFamily: "unknown",
|
|
39
|
+
sourceCandidates: true,
|
|
40
|
+
frameworkExtras: true,
|
|
41
|
+
serveJsTransform: true,
|
|
42
|
+
styleInjector: true
|
|
43
|
+
};
|
|
44
|
+
function createGenericWebViteCapabilityProfile(options) {
|
|
45
|
+
return {
|
|
46
|
+
name: "generic-web",
|
|
47
|
+
frameworkName: "generic",
|
|
48
|
+
generatorTarget: "web",
|
|
49
|
+
platformFamily: "web",
|
|
50
|
+
sourceCandidates: options.cssSourceTrace === true || typeof options.cssSourceTrace === "object",
|
|
51
|
+
frameworkExtras: false,
|
|
52
|
+
serveJsTransform: false,
|
|
53
|
+
styleInjector: options.styleInjector !== void 0
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
35
57
|
//#region src/bundlers/vite/source-output-relations.ts
|
|
36
58
|
const activeRelationOwnerStorage = new node_async_hooks.AsyncLocalStorage();
|
|
37
59
|
function normalizeSourceFile$1(sourceFile) {
|
|
@@ -243,6 +265,7 @@ const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
|
243
265
|
const SFC_STYLE_BLOCK_RE$2 = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
244
266
|
const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
|
|
245
267
|
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
268
|
+
const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
246
269
|
function cloneStyleEntry(entry) {
|
|
247
270
|
return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
|
|
248
271
|
}
|
|
@@ -260,14 +283,14 @@ function cloneStyleValue(style) {
|
|
|
260
283
|
function toCamelCase(prop) {
|
|
261
284
|
return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
262
285
|
}
|
|
263
|
-
function normalizeValue(value) {
|
|
286
|
+
function normalizeValue(prop, value) {
|
|
264
287
|
const trimmed = value.trim();
|
|
265
|
-
if (/^-?\d+(?:\.\d+)?px$/.test(trimmed)) return Number(trimmed.slice(0, -2));
|
|
288
|
+
if (!STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) && /^-?\d+(?:\.\d+)?px$/.test(trimmed)) return Number(trimmed.slice(0, -2));
|
|
266
289
|
return trimmed.replace(/\s*,\s*/g, ",");
|
|
267
290
|
}
|
|
268
|
-
function normalizeStyleValue(value) {
|
|
269
|
-
if (typeof value === "number") return value;
|
|
270
|
-
return normalizeValue(value);
|
|
291
|
+
function normalizeStyleValue(prop, value) {
|
|
292
|
+
if (typeof value === "number") return STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) ? String(value) : value;
|
|
293
|
+
return normalizeValue(prop, value);
|
|
271
294
|
}
|
|
272
295
|
function unescapeCssClassSelector(className) {
|
|
273
296
|
return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
|
|
@@ -302,7 +325,7 @@ function styleExportToUtsMap(styleExport) {
|
|
|
302
325
|
const declarations = styleStates[""];
|
|
303
326
|
if (!declarations || Object.keys(declarations).length === 0) continue;
|
|
304
327
|
const declarationEntries = Object.entries(declarations).map(([prop, value]) => {
|
|
305
|
-
return `[${JSON.stringify(toCamelCase(prop))}, ${JSON.stringify(normalizeStyleValue(value))}]`;
|
|
328
|
+
return `[${JSON.stringify(toCamelCase(prop))}, ${JSON.stringify(normalizeStyleValue(prop, value))}]`;
|
|
306
329
|
});
|
|
307
330
|
if (declarationEntries.length === 0) continue;
|
|
308
331
|
classEntries.push(`[${JSON.stringify(className)}, _pS(_uM([${declarationEntries.join(", ")}]))]`);
|
|
@@ -362,7 +385,7 @@ function cssToStyleExport(source) {
|
|
|
362
385
|
if (!match?.[1]) continue;
|
|
363
386
|
const declarations = {};
|
|
364
387
|
rule.walkDecls((decl) => {
|
|
365
|
-
declarations[toCamelCase(decl.prop)] = normalizeValue(decl.value);
|
|
388
|
+
declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
|
|
366
389
|
});
|
|
367
390
|
if (Object.keys(declarations).length > 0) {
|
|
368
391
|
result[match[1]] = { "": declarations };
|
|
@@ -890,7 +913,10 @@ function runWithRemovedBundleFiles(removedFiles, run) {
|
|
|
890
913
|
return removedBundleFilesStorage.run(removedFiles, run);
|
|
891
914
|
}
|
|
892
915
|
function createBundleBuildState() {
|
|
893
|
-
return
|
|
916
|
+
return {
|
|
917
|
+
...require_hmr_timing.createRuntimeCompilationBuildState(),
|
|
918
|
+
entryMetadataByFile: /* @__PURE__ */ new Map()
|
|
919
|
+
};
|
|
894
920
|
}
|
|
895
921
|
function readEntrySource(output) {
|
|
896
922
|
if (output.type === "chunk") return output.code;
|
|
@@ -908,18 +934,24 @@ function collectJsEntry(fileName, output, outDir, store) {
|
|
|
908
934
|
const absolute = require_source_candidate_scan_signature.toAbsoluteOutputPath(fileName, outDir);
|
|
909
935
|
store.set(absolute, entry);
|
|
910
936
|
}
|
|
911
|
-
function collectBundleEntries(bundle, opts, outDir) {
|
|
937
|
+
function collectBundleEntries(bundle, opts, outDir, metadataByFile) {
|
|
912
938
|
const jsEntries = /* @__PURE__ */ new Map();
|
|
913
939
|
const entries = [];
|
|
914
940
|
for (const [file, output] of Object.entries(bundle)) {
|
|
915
|
-
const
|
|
941
|
+
const cachedMetadata = metadataByFile?.get(file);
|
|
942
|
+
const type = cachedMetadata?.outputType === output.type ? cachedMetadata.type : classifyBundleEntry(file, opts);
|
|
916
943
|
const entry = {
|
|
917
944
|
file,
|
|
918
945
|
output,
|
|
919
946
|
source: readEntrySource(output),
|
|
920
947
|
type
|
|
921
948
|
};
|
|
922
|
-
entry.runtimeCandidate = isRuntimeCandidateBundleEntry(entry);
|
|
949
|
+
entry.runtimeCandidate = cachedMetadata?.outputType === output.type ? cachedMetadata.runtimeCandidate : isRuntimeCandidateBundleEntry(entry);
|
|
950
|
+
metadataByFile?.set(file, {
|
|
951
|
+
outputType: output.type,
|
|
952
|
+
runtimeCandidate: entry.runtimeCandidate === true,
|
|
953
|
+
type
|
|
954
|
+
});
|
|
923
955
|
collectJsEntry(file, output, outDir, jsEntries);
|
|
924
956
|
entries.push(entry);
|
|
925
957
|
}
|
|
@@ -929,7 +961,7 @@ function collectBundleEntries(bundle, opts, outDir) {
|
|
|
929
961
|
};
|
|
930
962
|
}
|
|
931
963
|
function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false, options = {}) {
|
|
932
|
-
const { entries, jsEntries } = collectBundleEntries(bundle, opts, outDir);
|
|
964
|
+
const { entries, jsEntries } = collectBundleEntries(bundle, opts, outDir, state.entryMetadataByFile);
|
|
933
965
|
return {
|
|
934
966
|
...require_hmr_timing.buildRuntimeCompilationSnapshot(entries, state, {
|
|
935
967
|
computeHash: (source) => opts.cache.computeHash(source),
|
|
@@ -943,6 +975,11 @@ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false, opti
|
|
|
943
975
|
}
|
|
944
976
|
function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
945
977
|
require_hmr_timing.updateRuntimeCompilationBuildState(state, snapshot, linkedByEntry, options);
|
|
978
|
+
for (const file of snapshot.removedFiles) state.entryMetadataByFile.delete(file);
|
|
979
|
+
if (!snapshot.hasOmittedKnownFiles) {
|
|
980
|
+
const activeFiles = new Set(snapshot.entries.map((entry) => entry.file));
|
|
981
|
+
for (const file of state.entryMetadataByFile.keys()) if (!activeFiles.has(file)) state.entryMetadataByFile.delete(file);
|
|
982
|
+
}
|
|
946
983
|
}
|
|
947
984
|
//#endregion
|
|
948
985
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
@@ -4326,7 +4363,7 @@ function createCssHandlerOptionsCache(options) {
|
|
|
4326
4363
|
...extraOptions,
|
|
4327
4364
|
...dynamicCssOptions,
|
|
4328
4365
|
postcssOptions: { options: { from } },
|
|
4329
|
-
majorVersion:
|
|
4366
|
+
majorVersion: require_compiler.normalizeStyleHandlerMajorVersion(majorVersion),
|
|
4330
4367
|
sourceOptions: {
|
|
4331
4368
|
outputRoot,
|
|
4332
4369
|
...sourceFile === file ? {} : { requestFile: file }
|
|
@@ -5700,7 +5737,7 @@ function createJsEntryResolver(jsEntries) {
|
|
|
5700
5737
|
//#endregion
|
|
5701
5738
|
//#region src/bundlers/vite/generate-bundle/js-handler-options.ts
|
|
5702
5739
|
function resolveUniAppXJsTransformEnabled$1(uniAppX) {
|
|
5703
|
-
return uniAppX === void 0 ? true :
|
|
5740
|
+
return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
5704
5741
|
}
|
|
5705
5742
|
function createJsHandlerOptionsFactory(options) {
|
|
5706
5743
|
return (absoluteFilename, extra) => ({
|
|
@@ -6024,7 +6061,7 @@ async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
|
6024
6061
|
}
|
|
6025
6062
|
return modules;
|
|
6026
6063
|
}
|
|
6027
|
-
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
6064
|
+
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds, selectModules) {
|
|
6028
6065
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
6029
6066
|
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
6030
6067
|
const isHotSourceStyleModule = (id) => {
|
|
@@ -6049,8 +6086,9 @@ async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
|
6049
6086
|
modules.push(importer);
|
|
6050
6087
|
}
|
|
6051
6088
|
}
|
|
6052
|
-
|
|
6053
|
-
|
|
6089
|
+
const selectedModules = selectModules?.(modules) ?? modules;
|
|
6090
|
+
for (const mod of selectedModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
6091
|
+
return selectedModules;
|
|
6054
6092
|
}
|
|
6055
6093
|
async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
6056
6094
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
@@ -6143,6 +6181,13 @@ function includesHotModule(modules, target, root) {
|
|
|
6143
6181
|
].some((moduleIdentity) => hasSameViteModuleIdentity(targetIdentity, moduleIdentity, root)));
|
|
6144
6182
|
});
|
|
6145
6183
|
}
|
|
6184
|
+
function includesHotId(modules, targetId, root) {
|
|
6185
|
+
return modules.some((mod) => [
|
|
6186
|
+
mod.id,
|
|
6187
|
+
mod.url,
|
|
6188
|
+
mod.file
|
|
6189
|
+
].some((moduleId) => hasSameViteModuleIdentity(targetId, moduleId, root)));
|
|
6190
|
+
}
|
|
6146
6191
|
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
6147
6192
|
return {
|
|
6148
6193
|
type: "js-update",
|
|
@@ -6159,25 +6204,26 @@ function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
|
6159
6204
|
return !require_v4_generation_core.isSourceStyleRequest(modId) && mod.isSelfAccepting === true;
|
|
6160
6205
|
});
|
|
6161
6206
|
}
|
|
6162
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
6207
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = [], handledModules = ctx.modules) {
|
|
6163
6208
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
6164
6209
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
6165
6210
|
const updates = [];
|
|
6166
6211
|
for (const id of fallbackSourceIds) {
|
|
6212
|
+
if (includesHotId(handledModules, id, root)) continue;
|
|
6167
6213
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
6168
6214
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6169
6215
|
seenUrls.add(hotUrl);
|
|
6170
6216
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6171
6217
|
}
|
|
6172
6218
|
for (const id of fallbackCssIds) {
|
|
6173
|
-
if (!require_v4_generation_core.isSourceStyleRequest(id)) continue;
|
|
6219
|
+
if (!require_v4_generation_core.isSourceStyleRequest(id) || includesHotId(handledModules, id, root)) continue;
|
|
6174
6220
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
6175
6221
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6176
6222
|
seenUrls.add(hotUrl);
|
|
6177
6223
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6178
6224
|
}
|
|
6179
6225
|
for (const mod of cssModules) {
|
|
6180
|
-
if (includesHotModule(
|
|
6226
|
+
if (includesHotModule(handledModules, mod, root)) continue;
|
|
6181
6227
|
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
6182
6228
|
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
6183
6229
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
@@ -6254,7 +6300,7 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
6254
6300
|
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
6255
6301
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
6256
6302
|
const RELATIVE_REFERENCE_RE = /@reference\s+(["'])(\.\.?[\\/][^"']+)\1\s*;?/g;
|
|
6257
|
-
const WINDOWS_ABSOLUTE_PATH_RE = /^[a-z]:[\\/]/i;
|
|
6303
|
+
const WINDOWS_ABSOLUTE_PATH_RE$1 = /^[a-z]:[\\/]/i;
|
|
6258
6304
|
function isPreprocessorRequest(id, lang) {
|
|
6259
6305
|
return require_v4_generation_core.isSourcePreprocessorRequest(id, lang);
|
|
6260
6306
|
}
|
|
@@ -6267,7 +6313,7 @@ function isCssModuleExport(code) {
|
|
|
6267
6313
|
function normalizeRelativeTailwindReferences(code, id) {
|
|
6268
6314
|
if (!code.includes("@reference")) return code;
|
|
6269
6315
|
const sourceFile = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
6270
|
-
const pathApi = WINDOWS_ABSOLUTE_PATH_RE.test(sourceFile) ? node_path.default.win32 : node_path.default;
|
|
6316
|
+
const pathApi = WINDOWS_ABSOLUTE_PATH_RE$1.test(sourceFile) ? node_path.default.win32 : node_path.default;
|
|
6271
6317
|
const sourceDir = pathApi.dirname(sourceFile);
|
|
6272
6318
|
return code.replace(RELATIVE_REFERENCE_RE, (_full, quote, request) => {
|
|
6273
6319
|
return `@reference ${quote}${pathApi.resolve(sourceDir, request).replace(/\\/g, "/")}${quote};`;
|
|
@@ -6290,7 +6336,7 @@ function isStyleModule(mod) {
|
|
|
6290
6336
|
const request = mod.id ?? mod.url;
|
|
6291
6337
|
return typeof request === "string" && /[?&](?:vue&)?type=style(?:&|$)/.test(request);
|
|
6292
6338
|
}
|
|
6293
|
-
function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
6339
|
+
function createUniAppXWebLocalStyleBridge(isEnabled, hmrCssModuleVersions) {
|
|
6294
6340
|
const rulesByFile = /* @__PURE__ */ new Map();
|
|
6295
6341
|
return {
|
|
6296
6342
|
appendToStyle(code, id) {
|
|
@@ -6300,10 +6346,16 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6300
6346
|
},
|
|
6301
6347
|
handleHotUpdate(ctx) {
|
|
6302
6348
|
if (!isEnabled() || !/\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))) return;
|
|
6303
|
-
const
|
|
6304
|
-
|
|
6349
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
6350
|
+
const sourceModules = ctx.modules.filter((mod) => !isStyleModule(mod));
|
|
6351
|
+
const contextStyleModules = ctx.modules.filter(isStyleModule);
|
|
6352
|
+
const currentContextStyleModules = hmrCssModuleVersions?.filterModules(contextStyleModules, ctx.timestamp, root) ?? contextStyleModules;
|
|
6353
|
+
const resolvedStyleModules = [...ctx.server.moduleGraph.getModulesByFile?.(ctx.file) ?? []].filter(isStyleModule);
|
|
6354
|
+
const currentResolvedStyleModules = hmrCssModuleVersions?.filterModules(resolvedStyleModules, ctx.timestamp, root) ?? resolvedStyleModules;
|
|
6355
|
+
const styleModules = [.../* @__PURE__ */ new Set([...currentContextStyleModules, ...currentResolvedStyleModules])];
|
|
6356
|
+
if (styleModules.length === 0 && sourceModules.length === ctx.modules.length) return;
|
|
6305
6357
|
for (const mod of styleModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
6306
|
-
return [.../* @__PURE__ */ new Set([...
|
|
6358
|
+
return [.../* @__PURE__ */ new Set([...sourceModules, ...styleModules])];
|
|
6307
6359
|
},
|
|
6308
6360
|
remember(id, rules) {
|
|
6309
6361
|
rulesByFile.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), rules);
|
|
@@ -6311,25 +6363,67 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6311
6363
|
};
|
|
6312
6364
|
}
|
|
6313
6365
|
//#endregion
|
|
6366
|
+
//#region src/uni-app-x/vite/asset-task.ts
|
|
6367
|
+
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
6368
|
+
return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
6369
|
+
}
|
|
6370
|
+
function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
6371
|
+
return async () => {
|
|
6372
|
+
const { cache, hashKey, createHandlerOptions, debug, getAssetSource, getCssSources, injectStylePlaceholder = true, jsHandler, onUpdate, runtimeSet, applyLinkedResults } = options;
|
|
6373
|
+
const absoluteFile = require_source_candidate_scan_signature.toAbsoluteOutputPath(file, outDir);
|
|
6374
|
+
const rawSource = originalSource.source.toString();
|
|
6375
|
+
const rawHashSource = options.hashSalt ? `${rawSource}\n/*${options.hashSalt}*/` : rawSource;
|
|
6376
|
+
await require_hmr_timing.processCachedTask({
|
|
6377
|
+
cache,
|
|
6378
|
+
cacheKey: file,
|
|
6379
|
+
hashKey,
|
|
6380
|
+
rawSource: rawHashSource,
|
|
6381
|
+
applyResult(source) {
|
|
6382
|
+
originalSource.source = source;
|
|
6383
|
+
},
|
|
6384
|
+
onCacheHit() {
|
|
6385
|
+
debug("js cache hit: %s", file);
|
|
6386
|
+
},
|
|
6387
|
+
async transform() {
|
|
6388
|
+
const currentSource = originalSource.source.toString();
|
|
6389
|
+
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
6390
|
+
uniAppX: resolveUniAppXJsTransformEnabled(options.uniAppX),
|
|
6391
|
+
babelParserOptions: {
|
|
6392
|
+
plugins: ["typescript"],
|
|
6393
|
+
sourceType: "unambiguous"
|
|
6394
|
+
}
|
|
6395
|
+
}));
|
|
6396
|
+
const nextCode = injectStylePlaceholder ? injectUniAppXStylePlaceholder(file, code, getAssetSource, getCssSources?.()) : code;
|
|
6397
|
+
onUpdate(file, currentSource, nextCode);
|
|
6398
|
+
debug("js handle: %s", file);
|
|
6399
|
+
applyLinkedResults(linked);
|
|
6400
|
+
return { result: nextCode };
|
|
6401
|
+
}
|
|
6402
|
+
});
|
|
6403
|
+
};
|
|
6404
|
+
}
|
|
6405
|
+
//#endregion
|
|
6314
6406
|
//#region src/uni-app-x/vite.ts
|
|
6315
6407
|
let transformUVuePromise;
|
|
6316
6408
|
function loadTransformUVue() {
|
|
6317
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
6409
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-C6k9zTQR.cjs")).then((mod) => mod.transformUVue));
|
|
6318
6410
|
return transformUVuePromise;
|
|
6319
6411
|
}
|
|
6320
6412
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
6321
6413
|
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6322
|
-
function
|
|
6323
|
-
return
|
|
6414
|
+
function hasUniAppXImportantApply(source) {
|
|
6415
|
+
return extractSfcStyleBlocks(source).some((style) => (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source) !== style.source);
|
|
6324
6416
|
}
|
|
6325
6417
|
function createUniAppXPlugins(options) {
|
|
6326
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6327
|
-
const resolvedUniAppXOptions =
|
|
6418
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, hmrCssModuleVersions, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [], webCssEntryDiagnostics } = options;
|
|
6419
|
+
const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
|
|
6328
6420
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
6329
6421
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
6330
6422
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6331
6423
|
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
6332
|
-
const
|
|
6424
|
+
const knownSfcSources = /* @__PURE__ */ new Map();
|
|
6425
|
+
const pendingSfcTransforms = /* @__PURE__ */ new Map();
|
|
6426
|
+
const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
|
|
6333
6427
|
let componentLocalStyleEnabled;
|
|
6334
6428
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
6335
6429
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
@@ -6393,7 +6487,7 @@ function createUniAppXPlugins(options) {
|
|
|
6393
6487
|
const parsed = query ?? parseVueRequest(id).query;
|
|
6394
6488
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
6395
6489
|
if (isCssModuleExport(code)) return;
|
|
6396
|
-
const sourceCode = normalizeRelativeTailwindReferences(code, id);
|
|
6490
|
+
const sourceCode = normalizeRelativeTailwindReferences((0, _weapp_tailwindcss_postcss.restoreUniAppXImportantApplyMarker)(code), id);
|
|
6397
6491
|
const hasTailwindRoot = require_generator.hasTailwindRootDirectives(sourceCode, { importFallback: true });
|
|
6398
6492
|
const hasTailwindApply = require_generator.hasTailwindApplyDirective(sourceCode);
|
|
6399
6493
|
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
@@ -6437,23 +6531,42 @@ function createUniAppXPlugins(options) {
|
|
|
6437
6531
|
}, {
|
|
6438
6532
|
name: "weapp-tailwindcss:uni-app-x:css:pre",
|
|
6439
6533
|
enforce: "pre",
|
|
6534
|
+
load: {
|
|
6535
|
+
order: "pre",
|
|
6536
|
+
async handler(id) {
|
|
6537
|
+
const { filename, query } = parseVueRequest(id);
|
|
6538
|
+
if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
|
|
6539
|
+
const source = knownSfcSources.get(filename);
|
|
6540
|
+
const style = source ? extractSfcStyleBlocks(source)[query.index ?? 0] : void 0;
|
|
6541
|
+
if (!style) return;
|
|
6542
|
+
const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.source);
|
|
6543
|
+
return normalized === style.source ? void 0 : {
|
|
6544
|
+
code: normalized,
|
|
6545
|
+
map: null
|
|
6546
|
+
};
|
|
6547
|
+
}
|
|
6548
|
+
},
|
|
6440
6549
|
async transform(code, id) {
|
|
6441
6550
|
if (!isEnabled()) return;
|
|
6442
6551
|
await runtimeState.readyPromise;
|
|
6443
|
-
const { query } = parseVueRequest(id);
|
|
6552
|
+
const { filename, query } = parseVueRequest(id);
|
|
6553
|
+
if (query.vue && query.type === "style") await pendingSfcTransforms.get((0, _weapp_tailwindcss_shared.cleanUrl)(filename));
|
|
6444
6554
|
const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(code, id) : code;
|
|
6445
|
-
const
|
|
6555
|
+
const preprocessorCode = query.vue && query.type === "style" ? (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(styleCode) : styleCode;
|
|
6556
|
+
const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
|
|
6446
6557
|
isIosPlatform,
|
|
6447
6558
|
isNativeAppStyleTarget: isNativeAppStyleTarget()
|
|
6448
6559
|
});
|
|
6449
|
-
if (preprocessor) return preprocessor.result ?? (
|
|
6450
|
-
code:
|
|
6560
|
+
if (preprocessor) return preprocessor.result ?? (preprocessorCode !== code ? {
|
|
6561
|
+
code: preprocessorCode,
|
|
6451
6562
|
map: null
|
|
6452
6563
|
} : void 0);
|
|
6453
|
-
return transformStyle(
|
|
6564
|
+
return transformStyle(preprocessorCode, id, query, this);
|
|
6454
6565
|
}
|
|
6455
6566
|
}];
|
|
6456
6567
|
async function transformSfc(code, id, context) {
|
|
6568
|
+
knownSfcSources.set((0, _weapp_tailwindcss_shared.cleanUrl)(id), code);
|
|
6569
|
+
if (isWebGeneratorTarget()) for (const style of extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
|
|
6457
6570
|
if (isNativeAppBuildTarget(id)) {
|
|
6458
6571
|
nativeLocalStyleModuleIds.add(id);
|
|
6459
6572
|
nativeLocalStyleModuleIds.add((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
@@ -6474,9 +6587,13 @@ function createUniAppXPlugins(options) {
|
|
|
6474
6587
|
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6475
6588
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6476
6589
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
6590
|
+
native: true,
|
|
6477
6591
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
6478
6592
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
6479
|
-
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) =>
|
|
6593
|
+
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
|
|
6594
|
+
webLocalStyle.remember(id, rules);
|
|
6595
|
+
webCssEntryDiagnostics?.requestCheck();
|
|
6596
|
+
} } : {}
|
|
6480
6597
|
});
|
|
6481
6598
|
const result = Object.keys(transformOptions).length > 0 ? transformUVue(code, id, jsHandler, currentRuntimeSet, transformOptions) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6482
6599
|
if (!result?.code) return result;
|
|
@@ -6487,6 +6604,15 @@ function createUniAppXPlugins(options) {
|
|
|
6487
6604
|
map: null
|
|
6488
6605
|
};
|
|
6489
6606
|
}
|
|
6607
|
+
function runTransformSfc(code, id, context) {
|
|
6608
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
6609
|
+
const pending = transformSfc(code, id, context);
|
|
6610
|
+
pendingSfcTransforms.set(file, pending);
|
|
6611
|
+
pending.finally(() => {
|
|
6612
|
+
if (pendingSfcTransforms.get(file) === pending) pendingSfcTransforms.delete(file);
|
|
6613
|
+
});
|
|
6614
|
+
return pending;
|
|
6615
|
+
}
|
|
6490
6616
|
const nvuePlugin = {
|
|
6491
6617
|
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
6492
6618
|
enforce: "pre",
|
|
@@ -6499,7 +6625,7 @@ function createUniAppXPlugins(options) {
|
|
|
6499
6625
|
async handler(code, id) {
|
|
6500
6626
|
if (!isEnabled()) return;
|
|
6501
6627
|
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6502
|
-
return
|
|
6628
|
+
return runTransformSfc(code, id, this);
|
|
6503
6629
|
}
|
|
6504
6630
|
},
|
|
6505
6631
|
handleHotUpdate: {
|
|
@@ -6507,7 +6633,17 @@ function createUniAppXPlugins(options) {
|
|
|
6507
6633
|
async handler(ctx) {
|
|
6508
6634
|
if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
|
|
6509
6635
|
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6510
|
-
if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function")
|
|
6636
|
+
if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") {
|
|
6637
|
+
const source = await ctx.read();
|
|
6638
|
+
if (hasUniAppXImportantApply(source)) {
|
|
6639
|
+
ctx.server.ws.send({
|
|
6640
|
+
type: "full-reload",
|
|
6641
|
+
path: ctx.file
|
|
6642
|
+
});
|
|
6643
|
+
return [];
|
|
6644
|
+
}
|
|
6645
|
+
await runTransformSfc(source, ctx.file, this);
|
|
6646
|
+
}
|
|
6511
6647
|
return webLocalStyle.handleHotUpdate(ctx) ?? nativeHmrReloader.handleHotUpdate(ctx);
|
|
6512
6648
|
}
|
|
6513
6649
|
},
|
|
@@ -6517,6 +6653,12 @@ function createUniAppXPlugins(options) {
|
|
|
6517
6653
|
if (resolvedConfig?.command !== "build" || !resolvedConfig.build?.watch) return;
|
|
6518
6654
|
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6519
6655
|
await ensureRuntimeClassSet(true);
|
|
6656
|
+
},
|
|
6657
|
+
buildEnd() {
|
|
6658
|
+
if (isWebGeneratorTarget()) webCssEntryDiagnostics?.flush();
|
|
6659
|
+
},
|
|
6660
|
+
closeBundle() {
|
|
6661
|
+
webCssEntryDiagnostics?.dispose();
|
|
6520
6662
|
}
|
|
6521
6663
|
};
|
|
6522
6664
|
const stylePlaceholderPlugin = {
|
|
@@ -6566,43 +6708,23 @@ function createUniAppXPlugins(options) {
|
|
|
6566
6708
|
stylePlaceholderPlugin
|
|
6567
6709
|
];
|
|
6568
6710
|
}
|
|
6569
|
-
function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
6570
|
-
return async () => {
|
|
6571
|
-
const { cache, hashKey, createHandlerOptions, debug, getAssetSource, getCssSources, injectStylePlaceholder = true, jsHandler, onUpdate, runtimeSet, applyLinkedResults } = options;
|
|
6572
|
-
const absoluteFile = require_source_candidate_scan_signature.toAbsoluteOutputPath(file, outDir);
|
|
6573
|
-
const rawSource = originalSource.source.toString();
|
|
6574
|
-
const rawHashSource = options.hashSalt ? `${rawSource}\n/*${options.hashSalt}*/` : rawSource;
|
|
6575
|
-
await require_hmr_timing.processCachedTask({
|
|
6576
|
-
cache,
|
|
6577
|
-
cacheKey: file,
|
|
6578
|
-
hashKey,
|
|
6579
|
-
rawSource: rawHashSource,
|
|
6580
|
-
applyResult(source) {
|
|
6581
|
-
originalSource.source = source;
|
|
6582
|
-
},
|
|
6583
|
-
onCacheHit() {
|
|
6584
|
-
debug("js cache hit: %s", file);
|
|
6585
|
-
},
|
|
6586
|
-
async transform() {
|
|
6587
|
-
const currentSource = originalSource.source.toString();
|
|
6588
|
-
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
6589
|
-
uniAppX: resolveUniAppXJsTransformEnabled(options.uniAppX),
|
|
6590
|
-
babelParserOptions: {
|
|
6591
|
-
plugins: ["typescript"],
|
|
6592
|
-
sourceType: "unambiguous"
|
|
6593
|
-
}
|
|
6594
|
-
}));
|
|
6595
|
-
const nextCode = injectStylePlaceholder ? injectUniAppXStylePlaceholder(file, code, getAssetSource, getCssSources?.()) : code;
|
|
6596
|
-
onUpdate(file, currentSource, nextCode);
|
|
6597
|
-
debug("js handle: %s", file);
|
|
6598
|
-
applyLinkedResults(linked);
|
|
6599
|
-
return { result: nextCode };
|
|
6600
|
-
}
|
|
6601
|
-
});
|
|
6602
|
-
};
|
|
6603
|
-
}
|
|
6604
6711
|
//#endregion
|
|
6605
6712
|
//#region src/bundlers/vite/generate-bundle/js-processing.ts
|
|
6713
|
+
/** 在增量构建中直接回放 clean chunk,避免创建完整 JS 处理任务。 */
|
|
6714
|
+
function replayCleanJsBundleEntry(options) {
|
|
6715
|
+
const { cache, debug, entry, metrics, rememberProcessCacheKey, snapshot, transformFilterSignature, transformRuntimeSignature, useIncrementalMode } = options;
|
|
6716
|
+
if (!useIncrementalMode || entry.output.type !== "chunk" || snapshot.processFiles.js.has(entry.file)) return false;
|
|
6717
|
+
const hashKey = `${entry.file}:js`;
|
|
6718
|
+
const processHash = `${snapshot.sourceHashByFile.get(entry.file) ?? cache.computeHash(entry.source)}:${transformRuntimeSignature}:transform-filter:${transformFilterSignature}`;
|
|
6719
|
+
rememberProcessCacheKey(entry.file, hashKey);
|
|
6720
|
+
const cachedCode = cache.getHashValue(hashKey)?.hash === processHash ? cache.get(entry.file) : void 0;
|
|
6721
|
+
if (cachedCode === void 0) return false;
|
|
6722
|
+
entry.output.code = cachedCode;
|
|
6723
|
+
metrics.js.total++;
|
|
6724
|
+
metrics.js.cacheHits++;
|
|
6725
|
+
debug("js direct replay hit (planned clean): %s", entry.file);
|
|
6726
|
+
return true;
|
|
6727
|
+
}
|
|
6606
6728
|
function processJsBundleEntry(options) {
|
|
6607
6729
|
const { applyLinkedUpdates, bundle, cache, createHandlerOptions, debug, disableJsPrecheck, entry, getJsEntry, deferUniAppXStylePlaceholder, jsHandler, jsTaskFactories, linkedByEntry, metrics, onUpdate, outDir, processFiles, rememberProcessCacheKey, runtimeSignature, snapshot, shouldSkipAstTransform, slowJsAstWarnMs, timeTask, transformRuntime, transformRuntimeSignature, transformFilterSignature, uniAppX, useIncrementalMode } = options;
|
|
6608
6730
|
const { file, output: originalSource, source: originalEntrySource } = entry;
|
|
@@ -6653,7 +6775,7 @@ function processJsBundleEntry(options) {
|
|
|
6653
6775
|
return { result: rawSource };
|
|
6654
6776
|
}
|
|
6655
6777
|
const handlerOptions = createHandlerOptions(absoluteFile);
|
|
6656
|
-
if (!disableJsPrecheck &&
|
|
6778
|
+
if (!disableJsPrecheck && require_compiler.shouldSkipJsTransform(rawSource, handlerOptions)) {
|
|
6657
6779
|
metrics.js.elapsed += measureElapsed(start);
|
|
6658
6780
|
metrics.js.transformed++;
|
|
6659
6781
|
return { result: rawSource };
|
|
@@ -6715,7 +6837,7 @@ function processJsBundleEntry(options) {
|
|
|
6715
6837
|
sourceType: "unambiguous"
|
|
6716
6838
|
}
|
|
6717
6839
|
});
|
|
6718
|
-
if (!disableJsPrecheck &&
|
|
6840
|
+
if (!disableJsPrecheck && require_compiler.shouldSkipJsTransform(currentSource, precheckOptions)) {
|
|
6719
6841
|
metrics.js.elapsed += measureElapsed(start);
|
|
6720
6842
|
metrics.js.transformed++;
|
|
6721
6843
|
return;
|
|
@@ -7971,6 +8093,17 @@ function createGenerateBundleHook$1(context) {
|
|
|
7971
8093
|
debug("js skip web target: %s", file);
|
|
7972
8094
|
continue;
|
|
7973
8095
|
}
|
|
8096
|
+
if (replayCleanJsBundleEntry({
|
|
8097
|
+
cache,
|
|
8098
|
+
debug,
|
|
8099
|
+
entry,
|
|
8100
|
+
metrics,
|
|
8101
|
+
rememberProcessCacheKey,
|
|
8102
|
+
snapshot,
|
|
8103
|
+
transformFilterSignature,
|
|
8104
|
+
transformRuntimeSignature,
|
|
8105
|
+
useIncrementalMode
|
|
8106
|
+
})) continue;
|
|
7974
8107
|
processJsBundleEntry({
|
|
7975
8108
|
applyLinkedUpdates,
|
|
7976
8109
|
bundle,
|
|
@@ -8228,7 +8361,7 @@ function createCssHandlerOptions(opts, majorVersion, file, outputRoot, extraOpti
|
|
|
8228
8361
|
cssPreflight: opts.cssPreflight,
|
|
8229
8362
|
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
8230
8363
|
postcssOptions: { options: { from } },
|
|
8231
|
-
...
|
|
8364
|
+
...require_compiler.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
8232
8365
|
};
|
|
8233
8366
|
}
|
|
8234
8367
|
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
@@ -8980,7 +9113,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
8980
9113
|
const { appType, getAppType, rootImport, shouldOwnTailwindGeneration, weappTailwindcssDirPosix } = options;
|
|
8981
9114
|
const resolveAppType = () => getAppType?.() ?? appType;
|
|
8982
9115
|
return [{
|
|
8983
|
-
name: `${
|
|
9116
|
+
name: `${require_compiler.vitePluginName}:rewrite-css-imports`,
|
|
8984
9117
|
enforce: "pre",
|
|
8985
9118
|
resolveId(id, importer) {
|
|
8986
9119
|
if (!options.shouldRewrite) return null;
|
|
@@ -8996,7 +9129,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
8996
9129
|
async transform(code, id) {
|
|
8997
9130
|
if (!isCSSRequest(id)) return null;
|
|
8998
9131
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
8999
|
-
const normalizedCode = require_generator.hasTailwindRootDirectives(code) || code.includes("@config") ? require_generator.normalizeTailwindConfigDirectives(code, node_path.default.dirname(file)) : code;
|
|
9132
|
+
const normalizedCode = !isSfcStyleSourceFile(file) && (require_generator.hasTailwindRootDirectives(code) || code.includes("@config")) ? require_generator.normalizeTailwindConfigDirectives(code, node_path.default.dirname(file)) : code;
|
|
9000
9133
|
await options.onCssSourceTransform?.(id, normalizedCode);
|
|
9001
9134
|
const hasTailwindRoot = require_generator.hasTailwindRootDirectives(normalizedCode, { importFallback: true });
|
|
9002
9135
|
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
@@ -9042,7 +9175,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
9042
9175
|
const { opts, initialTailwindRuntime, refreshTailwindcssRuntime, uniAppXEnabled, customAttributesEntities, disabledDefaultTemplateHandler, debug } = options;
|
|
9043
9176
|
const runtimeState = {
|
|
9044
9177
|
tailwindRuntime: initialTailwindRuntime,
|
|
9045
|
-
readyPromise:
|
|
9178
|
+
readyPromise: require_compiler.createTailwindRuntimeReadyPromise(initialTailwindRuntime),
|
|
9046
9179
|
refreshTailwindcssRuntime
|
|
9047
9180
|
};
|
|
9048
9181
|
const bundleRuntimeClassSetManager = require_hmr_timing.createRuntimeClassSetManager({
|
|
@@ -9079,7 +9212,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
9079
9212
|
async function refreshRuntimeState(force) {
|
|
9080
9213
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
9081
9214
|
const shouldRefresh = force || invalidation.changed;
|
|
9082
|
-
const refreshed = await
|
|
9215
|
+
const refreshed = await require_compiler.refreshTailwindRuntimeState(runtimeState, {
|
|
9083
9216
|
force: shouldRefresh,
|
|
9084
9217
|
clearCache: force || invalidation.changed
|
|
9085
9218
|
});
|
|
@@ -9096,7 +9229,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
9096
9229
|
if (!forceRuntimeRefresh && runtimeSet) return runtimeSet;
|
|
9097
9230
|
if (forceRuntimeRefresh || !runtimeSetPromise) {
|
|
9098
9231
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
9099
|
-
runtimeSetPromise =
|
|
9232
|
+
runtimeSetPromise = require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
9100
9233
|
force: forceRuntimeRefresh || invalidation.changed,
|
|
9101
9234
|
skipRefresh: forceRuntimeRefresh,
|
|
9102
9235
|
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
@@ -9124,7 +9257,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
9124
9257
|
await transformRuntimeClassSetManager.reset();
|
|
9125
9258
|
}
|
|
9126
9259
|
if (!forceRuntimeRefresh) try {
|
|
9127
|
-
const baseClassSet = options.baseClassSet ?? runtimeSet ?? await
|
|
9260
|
+
const baseClassSet = options.baseClassSet ?? runtimeSet ?? await require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
9128
9261
|
force: invalidation.changed,
|
|
9129
9262
|
clearCache: invalidation.changed
|
|
9130
9263
|
});
|
|
@@ -9139,7 +9272,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
9139
9272
|
await bundleRuntimeClassSetManager.reset();
|
|
9140
9273
|
}
|
|
9141
9274
|
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) return runtimeSet;
|
|
9142
|
-
const task =
|
|
9275
|
+
const task = require_compiler.collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
9143
9276
|
force: forceRuntimeRefresh || invalidation.changed || forceCollectBySource,
|
|
9144
9277
|
skipRefresh: forceRuntimeRefresh,
|
|
9145
9278
|
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
@@ -9213,7 +9346,7 @@ function hasViteServeCssRootDirective(code) {
|
|
|
9213
9346
|
function createViteCssGenerationPlugins(options) {
|
|
9214
9347
|
return [
|
|
9215
9348
|
{
|
|
9216
|
-
name: `${
|
|
9349
|
+
name: `${require_compiler.vitePluginName}:generate:serve`,
|
|
9217
9350
|
apply: "serve",
|
|
9218
9351
|
enforce: "pre",
|
|
9219
9352
|
async transform(code, id) {
|
|
@@ -9234,7 +9367,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
9234
9367
|
}
|
|
9235
9368
|
},
|
|
9236
9369
|
{
|
|
9237
|
-
name: `${
|
|
9370
|
+
name: `${require_compiler.vitePluginName}:generate:build`,
|
|
9238
9371
|
apply: "build",
|
|
9239
9372
|
enforce: "pre",
|
|
9240
9373
|
async transform(code, id) {
|
|
@@ -9255,7 +9388,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
9255
9388
|
}
|
|
9256
9389
|
},
|
|
9257
9390
|
{
|
|
9258
|
-
name: `${
|
|
9391
|
+
name: `${require_compiler.vitePluginName}:generate:serve-hmr`,
|
|
9259
9392
|
apply: "serve",
|
|
9260
9393
|
enforce: "post",
|
|
9261
9394
|
async transform(code, id) {
|
|
@@ -9289,13 +9422,13 @@ function isViteServeJsRequest(id, command) {
|
|
|
9289
9422
|
}
|
|
9290
9423
|
function createViteServeJsTransformPlugin(options) {
|
|
9291
9424
|
return {
|
|
9292
|
-
name: `${
|
|
9425
|
+
name: `${require_compiler.vitePluginName}:js:serve`,
|
|
9293
9426
|
apply: "serve",
|
|
9294
9427
|
enforce: "post",
|
|
9295
9428
|
async transform(code, id) {
|
|
9296
9429
|
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
9297
9430
|
const handlerOptions = options.createHandlerOptions(id);
|
|
9298
|
-
if (
|
|
9431
|
+
if (require_compiler.shouldSkipJsTransform(code, handlerOptions)) return;
|
|
9299
9432
|
const runtime = await options.transformRuntime();
|
|
9300
9433
|
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
9301
9434
|
if (transformed === code) return;
|
|
@@ -9357,6 +9490,96 @@ function wrapViteCssPostTransform(config, transformCss) {
|
|
|
9357
9490
|
return true;
|
|
9358
9491
|
}
|
|
9359
9492
|
//#endregion
|
|
9493
|
+
//#region src/bundlers/vite/shared/configured-css-entry-observer.ts
|
|
9494
|
+
const WINDOWS_ABSOLUTE_PATH_RE = /^[a-z]:[\\/]/i;
|
|
9495
|
+
function createConfiguredCssEntryObserver(options) {
|
|
9496
|
+
const observedEntries = /* @__PURE__ */ new Set();
|
|
9497
|
+
let checkRequested = false;
|
|
9498
|
+
let timer;
|
|
9499
|
+
let warned = false;
|
|
9500
|
+
const resolveEntry = (entry) => resolveViteModuleIdentity(entry, options.getRoot()).key;
|
|
9501
|
+
const observeImport = (request, sourceId) => {
|
|
9502
|
+
if (!request.startsWith(".") && !node_path.default.isAbsolute(request) && !WINDOWS_ABSOLUTE_PATH_RE.test(request)) return;
|
|
9503
|
+
const sourceFile = resolveViteModuleIdentity(sourceId, options.getRoot()).file;
|
|
9504
|
+
if (!sourceFile) return;
|
|
9505
|
+
const pathApi = WINDOWS_ABSOLUTE_PATH_RE.test(sourceFile) ? node_path.default.win32 : node_path.default;
|
|
9506
|
+
observedEntries.add(resolveEntry(pathApi.resolve(pathApi.dirname(sourceFile), request)));
|
|
9507
|
+
};
|
|
9508
|
+
const clearTimer = () => {
|
|
9509
|
+
if (timer !== void 0) {
|
|
9510
|
+
clearTimeout(timer);
|
|
9511
|
+
timer = void 0;
|
|
9512
|
+
}
|
|
9513
|
+
};
|
|
9514
|
+
const missingEntries = () => options.getEntries()?.filter((entry) => !observedEntries.has(resolveEntry(entry))) ?? [];
|
|
9515
|
+
const check = () => {
|
|
9516
|
+
clearTimer();
|
|
9517
|
+
if (!checkRequested || warned) return;
|
|
9518
|
+
const missing = missingEntries();
|
|
9519
|
+
if (missing.length === 0) return;
|
|
9520
|
+
warned = true;
|
|
9521
|
+
options.onMissing(missing);
|
|
9522
|
+
};
|
|
9523
|
+
return {
|
|
9524
|
+
dispose() {
|
|
9525
|
+
clearTimer();
|
|
9526
|
+
},
|
|
9527
|
+
flush: check,
|
|
9528
|
+
observe(id) {
|
|
9529
|
+
observedEntries.add(resolveEntry(id));
|
|
9530
|
+
if (checkRequested && missingEntries().length === 0) clearTimer();
|
|
9531
|
+
},
|
|
9532
|
+
observeSourceImports(source, sourceId) {
|
|
9533
|
+
if (!source.includes("@import")) return;
|
|
9534
|
+
try {
|
|
9535
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("import", (rule) => {
|
|
9536
|
+
const request = (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(rule.params);
|
|
9537
|
+
if (request) observeImport(request, sourceId);
|
|
9538
|
+
});
|
|
9539
|
+
} catch {}
|
|
9540
|
+
},
|
|
9541
|
+
requestCheck() {
|
|
9542
|
+
if (warned) return;
|
|
9543
|
+
checkRequested = true;
|
|
9544
|
+
clearTimer();
|
|
9545
|
+
timer = setTimeout(check, options.delayMs ?? 1e3);
|
|
9546
|
+
}
|
|
9547
|
+
};
|
|
9548
|
+
}
|
|
9549
|
+
function createConfiguredCssEntryDiagnostics(options) {
|
|
9550
|
+
const observer = createConfiguredCssEntryObserver({
|
|
9551
|
+
getEntries: options.getEntries,
|
|
9552
|
+
getRoot: options.getRoot,
|
|
9553
|
+
onMissing(entries) {
|
|
9554
|
+
_weapp_tailwindcss_logger.logger.warn("[uni-app-x Web] cssEntries 中的 Tailwind CSS 入口未进入 Web 样式构建链路:%s。componentLocalStyles 已生成 wtu-* 局部类,但入口中的 @theme/CSS 变量不会投递到浏览器。请在 App.uvue 或应用入口中显式 import 这些 CSS 文件。", entries.join(", "));
|
|
9555
|
+
}
|
|
9556
|
+
});
|
|
9557
|
+
return {
|
|
9558
|
+
observer,
|
|
9559
|
+
plugin: {
|
|
9560
|
+
name: "weapp-tailwindcss:configured-css-entry-observer",
|
|
9561
|
+
transform(_code, id) {
|
|
9562
|
+
if (options.isWeb() && require_v4_generation_core.isSourceStyleRequest(id)) observer.observe(id);
|
|
9563
|
+
}
|
|
9564
|
+
}
|
|
9565
|
+
};
|
|
9566
|
+
}
|
|
9567
|
+
//#endregion
|
|
9568
|
+
//#region src/bundlers/vite/shared/framework-css-generation-queue.ts
|
|
9569
|
+
function createFrameworkCssGenerationQueue(normalizeId, generate) {
|
|
9570
|
+
const pendingByFile = /* @__PURE__ */ new Map();
|
|
9571
|
+
return (id, ...args) => {
|
|
9572
|
+
const fileKey = normalizeId(id);
|
|
9573
|
+
const task = (pendingByFile.get(fileKey) ?? Promise.resolve()).then(() => generate(id, ...args));
|
|
9574
|
+
const tail = task.then(() => void 0, () => void 0);
|
|
9575
|
+
pendingByFile.set(fileKey, tail);
|
|
9576
|
+
tail.then(() => {
|
|
9577
|
+
if (pendingByFile.get(fileKey) === tail) pendingByFile.delete(fileKey);
|
|
9578
|
+
});
|
|
9579
|
+
return task;
|
|
9580
|
+
};
|
|
9581
|
+
}
|
|
9582
|
+
//#endregion
|
|
9360
9583
|
//#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
|
|
9361
9584
|
function createViteHmrCandidateState(options) {
|
|
9362
9585
|
let pendingChange;
|
|
@@ -9497,6 +9720,70 @@ function createViteHmrCandidateState(options) {
|
|
|
9497
9720
|
};
|
|
9498
9721
|
}
|
|
9499
9722
|
//#endregion
|
|
9723
|
+
//#region src/bundlers/vite/shared/framework-hmr-module-version.ts
|
|
9724
|
+
function acceptVersion(versions, keys, timestamp) {
|
|
9725
|
+
if (keys.some((key) => (versions.get(key) ?? 0) > timestamp)) return false;
|
|
9726
|
+
for (const key of keys) versions.set(key, Math.max(versions.get(key) ?? 0, timestamp));
|
|
9727
|
+
return true;
|
|
9728
|
+
}
|
|
9729
|
+
function createViteHmrCssModuleVersionTracker() {
|
|
9730
|
+
const versions = /* @__PURE__ */ new Map();
|
|
9731
|
+
const keysForId = (id, root) => [resolveViteModuleIdentity(id, root).key];
|
|
9732
|
+
const keysForModule = (mod, root) => [...new Set([
|
|
9733
|
+
mod.id,
|
|
9734
|
+
mod.url,
|
|
9735
|
+
mod.file
|
|
9736
|
+
].filter((id) => typeof id === "string" && id.length > 0).flatMap((id) => keysForId(id, root)))];
|
|
9737
|
+
return {
|
|
9738
|
+
clear() {
|
|
9739
|
+
versions.clear();
|
|
9740
|
+
},
|
|
9741
|
+
filterIds(ids, timestamp, root) {
|
|
9742
|
+
return [...ids].filter((id) => acceptVersion(versions, keysForId(id, root), timestamp));
|
|
9743
|
+
},
|
|
9744
|
+
filterModules(modules, timestamp, root) {
|
|
9745
|
+
return modules.filter((mod) => {
|
|
9746
|
+
const keys = keysForModule(mod, root);
|
|
9747
|
+
return keys.length === 0 || acceptVersion(versions, keys, timestamp);
|
|
9748
|
+
});
|
|
9749
|
+
},
|
|
9750
|
+
reserveRefreshTimestamp(modules, timestamp, root) {
|
|
9751
|
+
const moduleKeys = modules.flatMap((mod) => keysForModule(mod, root));
|
|
9752
|
+
const latestTimestamp = moduleKeys.reduce((latest, key) => Math.max(latest, versions.get(key) ?? 0), 0);
|
|
9753
|
+
const refreshTimestamp = Math.max(Date.now(), timestamp + 1, latestTimestamp + 1);
|
|
9754
|
+
for (const key of moduleKeys) versions.set(key, refreshTimestamp);
|
|
9755
|
+
return refreshTimestamp;
|
|
9756
|
+
}
|
|
9757
|
+
};
|
|
9758
|
+
}
|
|
9759
|
+
function createViteHmrCssModuleVersionFilterPlugin(tracker) {
|
|
9760
|
+
return {
|
|
9761
|
+
name: "weapp-tailwindcss:hmr-css-module-version",
|
|
9762
|
+
enforce: "post",
|
|
9763
|
+
handleHotUpdate: {
|
|
9764
|
+
order: "post",
|
|
9765
|
+
handler(ctx) {
|
|
9766
|
+
const styleModules = ctx.modules.filter((mod) => {
|
|
9767
|
+
const request = mod.id ?? mod.url;
|
|
9768
|
+
return require_v4_generation_core.isSourceStyleRequest(request);
|
|
9769
|
+
});
|
|
9770
|
+
if (styleModules.length === 0) return;
|
|
9771
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
9772
|
+
const currentStyleModules = tracker.filterModules(styleModules, ctx.timestamp, root);
|
|
9773
|
+
if (currentStyleModules.length === styleModules.length) return;
|
|
9774
|
+
const droppedStyleModules = styleModules.filter((mod) => !currentStyleModules.includes(mod));
|
|
9775
|
+
for (const mod of droppedStyleModules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
9776
|
+
const refreshTimestamp = tracker.reserveRefreshTimestamp(droppedStyleModules, ctx.timestamp, root);
|
|
9777
|
+
sendSupplementalCssHotUpdates({
|
|
9778
|
+
...ctx,
|
|
9779
|
+
timestamp: refreshTimestamp
|
|
9780
|
+
}, droppedStyleModules, [], [], []);
|
|
9781
|
+
return [...ctx.modules.filter((mod) => !styleModules.includes(mod)), ...currentStyleModules];
|
|
9782
|
+
}
|
|
9783
|
+
}
|
|
9784
|
+
};
|
|
9785
|
+
}
|
|
9786
|
+
//#endregion
|
|
9500
9787
|
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
9501
9788
|
function createFrameworkModuleCandidateRegistrar(options) {
|
|
9502
9789
|
return async (id, source) => {
|
|
@@ -9602,7 +9889,7 @@ function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
|
9602
9889
|
//#region src/bundlers/vite/shared/framework-post-plugin.ts
|
|
9603
9890
|
function createFrameworkPostPlugin(options) {
|
|
9604
9891
|
const plugin = {
|
|
9605
|
-
name: `${
|
|
9892
|
+
name: `${require_compiler.vitePluginName}:post`,
|
|
9606
9893
|
enforce: "post",
|
|
9607
9894
|
config(config) {
|
|
9608
9895
|
if (!options.shouldOwnTailwindGeneration) return;
|
|
@@ -9653,7 +9940,7 @@ function createFrameworkPostPlugin(options) {
|
|
|
9653
9940
|
}
|
|
9654
9941
|
}
|
|
9655
9942
|
if (options.shouldInferAppType && resolvedRoot) {
|
|
9656
|
-
const nextAppType = require_framework.resolveImplicitAppTypeFromViteRoot(resolvedRoot);
|
|
9943
|
+
const nextAppType = require_framework.resolveImplicitAppTypeFromViteRoot(resolvedRoot, { searchUp: false });
|
|
9657
9944
|
if (nextAppType && options.opts.appType !== nextAppType) {
|
|
9658
9945
|
const previousAppType = options.opts.appType;
|
|
9659
9946
|
options.opts.appType = nextAppType;
|
|
@@ -9662,6 +9949,16 @@ function createFrameworkPostPlugin(options) {
|
|
|
9662
9949
|
shouldRefreshRuntime = true;
|
|
9663
9950
|
}
|
|
9664
9951
|
}
|
|
9952
|
+
if (options.frameworkName === "generic" && !options.hasExplicitGeneratorTarget && options.opts.generator !== false && options.opts.appType === void 0 && options.opts.platform === void 0 && options.opts.cssOptions?.platform === void 0 && !options.resolveViteStylePlatform()) {
|
|
9953
|
+
const generator = options.opts.generator && typeof options.opts.generator === "object" ? options.opts.generator : {};
|
|
9954
|
+
options.opts.generator = {
|
|
9955
|
+
...generator,
|
|
9956
|
+
target: "web"
|
|
9957
|
+
};
|
|
9958
|
+
_weapp_tailwindcss_logger.logger.info("Generic Vite 项目未指定目标,自动使用 generator.target -> web");
|
|
9959
|
+
options.debug("default generic vite generator target to web after configResolved");
|
|
9960
|
+
shouldRefreshRuntime = true;
|
|
9961
|
+
}
|
|
9665
9962
|
if (shouldRefreshRuntime) await options.refreshRuntimeState(true);
|
|
9666
9963
|
if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
|
|
9667
9964
|
const postcssPlugins = config.css.postcss.plugins;
|
|
@@ -9734,6 +10031,36 @@ function sameStringList(first, second) {
|
|
|
9734
10031
|
return first.every((item, index) => item === second[index]);
|
|
9735
10032
|
}
|
|
9736
10033
|
//#endregion
|
|
10034
|
+
//#region src/bundlers/vite/shared/framework-runtime-utils.ts
|
|
10035
|
+
function collectConfiguredCssEntries(options) {
|
|
10036
|
+
const runtimeCssEntries = options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries;
|
|
10037
|
+
const entries = [
|
|
10038
|
+
...Array.isArray(options.cssEntries) ? options.cssEntries : [],
|
|
10039
|
+
...Array.isArray(options.tailwindcss?.v4?.cssEntries) ? options.tailwindcss.v4.cssEntries : [],
|
|
10040
|
+
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
10041
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
10042
|
+
return entries.length > 0 ? [...new Set(entries)] : void 0;
|
|
10043
|
+
}
|
|
10044
|
+
function inferPlatformFromOutDir(outDir) {
|
|
10045
|
+
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
10046
|
+
if (!segment) return;
|
|
10047
|
+
const normalized = segment.trim().toLowerCase();
|
|
10048
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
10049
|
+
}
|
|
10050
|
+
function isWebOrNativeAppPlatform(platform) {
|
|
10051
|
+
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
10052
|
+
}
|
|
10053
|
+
function isInternalUserDefinedOptions(options) {
|
|
10054
|
+
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
10055
|
+
}
|
|
10056
|
+
function isNuxtPageHotModule(id) {
|
|
10057
|
+
if (typeof id !== "string") return false;
|
|
10058
|
+
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id).replace(/%2F/gi, "/");
|
|
10059
|
+
if (cleanId.includes("virtual:nuxt:") && /(?:^|\/)routes\.mjs$/.test(cleanId)) return true;
|
|
10060
|
+
if (!/[?&]macro=true(?:&|$)/.test(id)) return false;
|
|
10061
|
+
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
10062
|
+
}
|
|
10063
|
+
//#endregion
|
|
9737
10064
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
9738
10065
|
function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
9739
10066
|
const hasDifferentHotModules = (left, right) => left.length !== right.length || left.some((mod, index) => mod !== right[index]);
|
|
@@ -9765,7 +10092,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9765
10092
|
});
|
|
9766
10093
|
};
|
|
9767
10094
|
return {
|
|
9768
|
-
name: `${
|
|
10095
|
+
name: `${require_compiler.vitePluginName}:source-candidates`,
|
|
9769
10096
|
apply,
|
|
9770
10097
|
enforce: "pre",
|
|
9771
10098
|
async load(id) {
|
|
@@ -9790,7 +10117,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9790
10117
|
options.cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
9791
10118
|
if (isCSSRequest(id) && require_generator.hasTailwindRootDirectives(transformedCode, { importFallback: options.resolveCurrentGeneratorOptions().importFallback })) options.rememberTailwindRootCssModule(id);
|
|
9792
10119
|
}
|
|
9793
|
-
if (!options.shouldOwnTailwindGeneration || !require_v4_generation_core.isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return shouldReturnTransformedCode ? {
|
|
10120
|
+
if (!options.shouldOwnTailwindGeneration || options.collectSourceCandidates === false || !require_v4_generation_core.isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return shouldReturnTransformedCode ? {
|
|
9794
10121
|
code: transformedCode,
|
|
9795
10122
|
map: null
|
|
9796
10123
|
} : void 0;
|
|
@@ -9817,13 +10144,21 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9817
10144
|
async watchChange(id, change) {
|
|
9818
10145
|
require_v4_generation_core.recordCompilationDependencyChanges(options.runtimeState, require_v4_generation_core.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(id))]));
|
|
9819
10146
|
await options.hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
9820
|
-
if (options.shouldOwnTailwindGeneration && require_v4_generation_core.isSourceCandidateRequest(id)) options.invalidateRecordedGeneratorCandidates();
|
|
10147
|
+
if (options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false && require_v4_generation_core.isSourceCandidateRequest(id)) options.invalidateRecordedGeneratorCandidates();
|
|
9821
10148
|
if (options.sourceScanSession.isDependency(id)) options.sourceScanSession.invalidate();
|
|
9822
10149
|
if (change.event === "delete") {
|
|
9823
10150
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
10151
|
+
if (typeof options.sourceScanSession.queueChangedFile === "function") {
|
|
10152
|
+
options.sourceScanSession.queueChangedFile({
|
|
10153
|
+
event: "delete",
|
|
10154
|
+
id: file
|
|
10155
|
+
});
|
|
10156
|
+
queueMicrotask(() => void options.sourceScanSession.flushChangedFiles());
|
|
10157
|
+
} else {
|
|
10158
|
+
const sourceCandidateChange = options.sourceCandidateCollector.remove(file);
|
|
10159
|
+
options.sourceScanSession.cacheCurrent();
|
|
10160
|
+
options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, sourceCandidateChange, { runtimeAffecting: options.sourceScanSession.isDependency(file) }));
|
|
10161
|
+
}
|
|
9827
10162
|
return;
|
|
9828
10163
|
}
|
|
9829
10164
|
const changedSource = options.shouldOwnTailwindGeneration && require_v4_generation_core.isSourceCandidateRequest(id) && isCSSRequest(id) ? await (0, node_fs_promises.readFile)((0, _weapp_tailwindcss_shared.cleanUrl)(id), "utf8").catch(() => void 0) : void 0;
|
|
@@ -9831,7 +10166,14 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9831
10166
|
options.rememberOriginalCssLayerSource(id, changedSource);
|
|
9832
10167
|
await options.refreshTailwindRootCssSource(id, changedSource);
|
|
9833
10168
|
}
|
|
9834
|
-
|
|
10169
|
+
if (typeof options.sourceScanSession.queueChangedFile === "function") {
|
|
10170
|
+
options.sourceScanSession.queueChangedFile({
|
|
10171
|
+
event: change.event === "create" ? "create" : "update",
|
|
10172
|
+
id,
|
|
10173
|
+
source: changedSource
|
|
10174
|
+
});
|
|
10175
|
+
queueMicrotask(() => void options.sourceScanSession.flushChangedFiles());
|
|
10176
|
+
} else await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9835
10177
|
}, { emit: false });
|
|
9836
10178
|
},
|
|
9837
10179
|
handleHotUpdate: {
|
|
@@ -9839,7 +10181,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9839
10181
|
async handler(ctx) {
|
|
9840
10182
|
require_v4_generation_core.recordCompilationDependencyChanges(options.runtimeState, require_v4_generation_core.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))]));
|
|
9841
10183
|
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9842
|
-
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && require_v4_generation_core.isSourceCandidateRequest(ctx.file);
|
|
10184
|
+
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false && require_v4_generation_core.isSourceCandidateRequest(ctx.file);
|
|
9843
10185
|
if (isSourceCandidateHotUpdate && require_v4_generation_core.isSourceStyleRequest(ctx.file)) {
|
|
9844
10186
|
for (const mod of ctx.modules) for (const id of [
|
|
9845
10187
|
mod.id,
|
|
@@ -9852,7 +10194,11 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9852
10194
|
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
9853
10195
|
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9854
10196
|
}
|
|
9855
|
-
const sourceCandidateChange =
|
|
10197
|
+
const sourceCandidateChange = typeof options.sourceScanSession.queueChangedFile === "function" ? (options.sourceScanSession.queueChangedFile({
|
|
10198
|
+
event: "update",
|
|
10199
|
+
id: ctx.file,
|
|
10200
|
+
source: hotSource
|
|
10201
|
+
}), await options.sourceScanSession.flushChangedFiles()).get((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) : await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9856
10202
|
options.sourceScanSession.consumeHotUpdateChange(ctx.file);
|
|
9857
10203
|
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9858
10204
|
let canUseHmrCandidateAppend = false;
|
|
@@ -9873,8 +10219,9 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9873
10219
|
}
|
|
9874
10220
|
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9875
10221
|
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
|
|
9876
|
-
const
|
|
10222
|
+
const hotTailwindCssModuleIds = require_v4_generation_core.isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds;
|
|
9877
10223
|
const hotRoot = ctx.server.config?.root ?? node_process.default.cwd();
|
|
10224
|
+
const cssModules = await resolveHotTailwindCssModules(ctx, hotTailwindCssModuleIds, options.hmrCssModuleVersions ? (modules) => options.hmrCssModuleVersions.filterModules(modules, ctx.timestamp, hotRoot) : void 0);
|
|
9878
10225
|
const sourceModules = isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9879
10226
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) {
|
|
9880
10227
|
if (!/\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))) sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
@@ -9901,14 +10248,18 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
9901
10248
|
}
|
|
9902
10249
|
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
9903
10250
|
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9904
|
-
|
|
9905
|
-
if (
|
|
10251
|
+
const currentSupplementalCssFallbackIds = options.hmrCssModuleVersions?.filterIds(supplementalCssFallbackIds, ctx.timestamp, hotRoot) ?? supplementalCssFallbackIds;
|
|
10252
|
+
if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, currentSupplementalCssFallbackIds);
|
|
10253
|
+
if (shouldSendSupplementalCssHotUpdates && cssModules.length === 0) sendSupplementalCssHotUpdates(ctx, [], currentSupplementalCssFallbackIds);
|
|
9906
10254
|
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
9907
10255
|
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
9908
10256
|
return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, ctx.modules, cssModules) : void 0;
|
|
9909
10257
|
}, { emit: false });
|
|
9910
10258
|
}
|
|
9911
10259
|
},
|
|
10260
|
+
closeBundle() {
|
|
10261
|
+
options.hmrCssModuleVersions?.clear();
|
|
10262
|
+
},
|
|
9912
10263
|
async buildStart() {
|
|
9913
10264
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
9914
10265
|
},
|
|
@@ -9951,6 +10302,11 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9951
10302
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
9952
10303
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
9953
10304
|
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
10305
|
+
const pendingChangedFiles = /* @__PURE__ */ new Map();
|
|
10306
|
+
let pendingChangedFilesFlush;
|
|
10307
|
+
let isFlushingChangedFiles = false;
|
|
10308
|
+
let cacheDirty = false;
|
|
10309
|
+
let cachedCollectorRevision;
|
|
9954
10310
|
const normalizeDependency = (file) => node_path.default.normalize(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
9955
10311
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9956
10312
|
const invalidate = () => {
|
|
@@ -9986,12 +10342,20 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9986
10342
|
};
|
|
9987
10343
|
const cacheCurrent = () => {
|
|
9988
10344
|
if (!sourceCandidateScanSignature) return;
|
|
10345
|
+
if (isFlushingChangedFiles) {
|
|
10346
|
+
cacheDirty = true;
|
|
10347
|
+
return;
|
|
10348
|
+
}
|
|
10349
|
+
const collectorRevision = options.sourceCandidateCollector.getRevision?.();
|
|
10350
|
+
if (!cacheDirty && cachedCollectorRevision !== void 0 && collectorRevision === cachedCollectorRevision) return;
|
|
9989
10351
|
const entry = {
|
|
9990
10352
|
eligibleFiles: [...sourceScanEligibleFiles],
|
|
9991
10353
|
snapshot: options.sourceCandidateCollector.snapshot()
|
|
9992
10354
|
};
|
|
9993
10355
|
sourceCandidateScanCache.set(sourceCandidateScanSignature, entry);
|
|
9994
10356
|
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, entry);
|
|
10357
|
+
cachedCollectorRevision = collectorRevision;
|
|
10358
|
+
cacheDirty = false;
|
|
9995
10359
|
};
|
|
9996
10360
|
const updateSourceScanMatchers = (eligibleFiles) => {
|
|
9997
10361
|
sourceScanEligibleFiles = new Set(eligibleFiles);
|
|
@@ -10026,7 +10390,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10026
10390
|
const resolvedConfig = options.getResolvedConfig();
|
|
10027
10391
|
const root = resolvedConfig?.root ?? node_process.default.cwd();
|
|
10028
10392
|
const outDir = resolvedConfig?.build?.outDir;
|
|
10029
|
-
const sourceScan = await
|
|
10393
|
+
const sourceScan = await require_tailwindcss.resolveSourceScanEntries(options.opts, options.runtimeState.tailwindRuntime, {
|
|
10030
10394
|
outDir,
|
|
10031
10395
|
root
|
|
10032
10396
|
});
|
|
@@ -10077,7 +10441,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10077
10441
|
if (options.isWatchLikeBuild()) cacheCurrent();
|
|
10078
10442
|
};
|
|
10079
10443
|
const waitForPendingSyncs = async () => {
|
|
10080
|
-
while (
|
|
10444
|
+
while (true) {
|
|
10445
|
+
if (!pendingChangedFilesFlush && pendingChangedFiles.size === 0 && pendingSourceCandidateSyncs.size === 0) break;
|
|
10446
|
+
await pendingChangedFilesFlush;
|
|
10447
|
+
if (pendingChangedFiles.size > 0) await flushChangedFiles();
|
|
10448
|
+
if (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
10449
|
+
}
|
|
10081
10450
|
};
|
|
10082
10451
|
const rememberHotUpdateChange = (change) => {
|
|
10083
10452
|
if (!change) return;
|
|
@@ -10099,7 +10468,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10099
10468
|
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
10100
10469
|
return previous;
|
|
10101
10470
|
};
|
|
10102
|
-
const
|
|
10471
|
+
const syncChangedFileNow = async (id, sourceOverride, event = "update") => {
|
|
10103
10472
|
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return;
|
|
10104
10473
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
10105
10474
|
const runtimeAffectingByDependency = isDependency(file);
|
|
@@ -10122,10 +10491,17 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10122
10491
|
return syncChangedFile(id, sourceOverride);
|
|
10123
10492
|
}
|
|
10124
10493
|
const previousSource = options.sourceCandidateCollector.source(file);
|
|
10494
|
+
if (event === "delete") {
|
|
10495
|
+
const change = options.sourceCandidateCollector.remove(file);
|
|
10496
|
+
cacheDirty = true;
|
|
10497
|
+
const appliedChange = options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency }));
|
|
10498
|
+
return rememberHotUpdateChange(appliedChange);
|
|
10499
|
+
}
|
|
10125
10500
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
10126
10501
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
10127
10502
|
}).then((change) => {
|
|
10128
|
-
|
|
10503
|
+
cacheDirty = true;
|
|
10504
|
+
if (!isFlushingChangedFiles) cacheCurrent();
|
|
10129
10505
|
const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
|
|
10130
10506
|
const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
|
|
10131
10507
|
return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
|
|
@@ -10140,18 +10516,59 @@ function createFrameworkSourceScanSession(options) {
|
|
|
10140
10516
|
return change;
|
|
10141
10517
|
});
|
|
10142
10518
|
};
|
|
10519
|
+
const queueChangedFile = (change) => {
|
|
10520
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(change.id);
|
|
10521
|
+
const previous = pendingChangedFiles.get(file);
|
|
10522
|
+
if (!previous) {
|
|
10523
|
+
pendingChangedFiles.set(file, {
|
|
10524
|
+
...change,
|
|
10525
|
+
file
|
|
10526
|
+
});
|
|
10527
|
+
return;
|
|
10528
|
+
}
|
|
10529
|
+
previous.event = change.event;
|
|
10530
|
+
if (change.source !== void 0) previous.source = change.source;
|
|
10531
|
+
};
|
|
10532
|
+
const flushChangedFiles = async () => {
|
|
10533
|
+
if (pendingChangedFilesFlush) {
|
|
10534
|
+
const result = await pendingChangedFilesFlush;
|
|
10535
|
+
return pendingChangedFiles.size > 0 ? flushChangedFiles() : result;
|
|
10536
|
+
}
|
|
10537
|
+
if (pendingChangedFiles.size === 0) return /* @__PURE__ */ new Map();
|
|
10538
|
+
const changes = [...pendingChangedFiles.values()];
|
|
10539
|
+
pendingChangedFiles.clear();
|
|
10540
|
+
isFlushingChangedFiles = true;
|
|
10541
|
+
pendingChangedFilesFlush = Promise.all(changes.map(async (change) => [change.file, await syncChangedFileNow(change.file, change.source, change.event)])).then((entries) => new Map(entries)).finally(() => {
|
|
10542
|
+
isFlushingChangedFiles = false;
|
|
10543
|
+
pendingChangedFilesFlush = void 0;
|
|
10544
|
+
cacheCurrent();
|
|
10545
|
+
});
|
|
10546
|
+
return pendingChangedFilesFlush;
|
|
10547
|
+
};
|
|
10548
|
+
const syncChangedFile = async (id, sourceOverride) => {
|
|
10549
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
10550
|
+
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
10551
|
+
if (existingTask) {
|
|
10552
|
+
await existingTask;
|
|
10553
|
+
return syncChangedFile(id, sourceOverride);
|
|
10554
|
+
}
|
|
10555
|
+
return syncChangedFileNow(file, sourceOverride);
|
|
10556
|
+
};
|
|
10143
10557
|
return {
|
|
10144
10558
|
cacheCurrent,
|
|
10145
10559
|
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
10146
10560
|
getStats: () => ({
|
|
10147
10561
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
10148
10562
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
10563
|
+
pendingChangedFiles: pendingChangedFiles.size,
|
|
10149
10564
|
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
10150
10565
|
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
10151
10566
|
}),
|
|
10152
10567
|
invalidate,
|
|
10153
10568
|
isDependency,
|
|
10154
10569
|
matches: (file) => sourceScanMatcher?.(file) ?? true,
|
|
10570
|
+
queueChangedFile,
|
|
10571
|
+
flushChangedFiles,
|
|
10155
10572
|
shouldDiscoverAutoCssSources,
|
|
10156
10573
|
sync,
|
|
10157
10574
|
syncChangedFile,
|
|
@@ -10204,34 +10621,14 @@ const ENV_PLATFORM_KEYS = [
|
|
|
10204
10621
|
"MPX_CURRENT_TARGET_MODE",
|
|
10205
10622
|
"MPX_CLI_MODE"
|
|
10206
10623
|
];
|
|
10207
|
-
function collectConfiguredCssEntries(options) {
|
|
10208
|
-
const runtimeCssEntries = options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries;
|
|
10209
|
-
const entries = [
|
|
10210
|
-
...Array.isArray(options.cssEntries) ? options.cssEntries : [],
|
|
10211
|
-
...Array.isArray(options.tailwindcss?.v4?.cssEntries) ? options.tailwindcss.v4.cssEntries : [],
|
|
10212
|
-
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
10213
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
10214
|
-
return entries.length > 0 ? [...new Set(entries)] : void 0;
|
|
10215
|
-
}
|
|
10216
|
-
function inferPlatformFromOutDir(outDir) {
|
|
10217
|
-
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
10218
|
-
if (!segment) return;
|
|
10219
|
-
const normalized = segment.trim().toLowerCase();
|
|
10220
|
-
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
10221
|
-
}
|
|
10222
|
-
function isWebOrNativeAppPlatform(platform) {
|
|
10223
|
-
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
10224
|
-
}
|
|
10225
|
-
function isInternalUserDefinedOptions(options) {
|
|
10226
|
-
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
10227
|
-
}
|
|
10228
10624
|
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
10229
10625
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
10626
|
+
const capability = options.__internalViteCapabilityProfile ?? frameworkViteCapabilityProfile;
|
|
10230
10627
|
const rawOptions = options.__internalViteRawOptions ?? options;
|
|
10231
10628
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
10232
10629
|
const hasExplicitTailwindcssBasedir = typeof options.__internalViteRawExplicitTailwindcssBasedir === "boolean" ? options.__internalViteRawExplicitTailwindcssBasedir : typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
10233
10630
|
const rawCssEntries = collectConfiguredCssEntries(rawOptions);
|
|
10234
|
-
const opts = isInternalUserDefinedOptions(options) ? options :
|
|
10631
|
+
const opts = isInternalUserDefinedOptions(options) ? options : require_compiler.getCompilerContext({
|
|
10235
10632
|
...options,
|
|
10236
10633
|
__internalDeferMissingCssEntriesWarning: true
|
|
10237
10634
|
});
|
|
@@ -10254,17 +10651,23 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10254
10651
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
10255
10652
|
const frameworkCssPipelineStrategy = frameworkBranch.cssPipelineStrategy;
|
|
10256
10653
|
const uniAppXEnabled = frameworkBranch.isRuntimeClassSetFeatureEnabled?.({ uniAppX }) === true;
|
|
10257
|
-
const shouldEnableFrameworkExtraPlugins = () => frameworkBranch.createExtraPlugins !== void 0;
|
|
10654
|
+
const shouldEnableFrameworkExtraPlugins = () => capability.frameworkExtras && frameworkBranch.createExtraPlugins !== void 0;
|
|
10258
10655
|
const disabledOptions = require_source_candidate_scan_signature.resolvePluginDisabledState(disabled);
|
|
10259
10656
|
const tailwindcssMajorVersion = initialTailwindRuntime.majorVersion ?? 0;
|
|
10260
10657
|
if (!disabledOptions.plugin && tailwindcssMajorVersion !== 4) throw new Error("weapp-tailwindcss/vite 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
10261
10658
|
const shouldRewriteCssImports = opts.rewriteCssImports === true;
|
|
10262
10659
|
let resolvedConfig;
|
|
10660
|
+
const { observer: webCssEntryDiagnostics, plugin: webCssEntryObserverPlugin } = createConfiguredCssEntryDiagnostics({
|
|
10661
|
+
getEntries: () => opts.cssEntries,
|
|
10662
|
+
getRoot: () => resolvedConfig?.root,
|
|
10663
|
+
isWeb: () => resolveCurrentGeneratorBranch().isWeb
|
|
10664
|
+
});
|
|
10665
|
+
const hmrCssModuleVersions = createViteHmrCssModuleVersionTracker();
|
|
10263
10666
|
const resolveViteStylePlatform = () => {
|
|
10264
|
-
const explicit =
|
|
10667
|
+
const explicit = require_compiler.normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
10265
10668
|
if (explicit) return explicit;
|
|
10266
10669
|
for (const key of ENV_PLATFORM_KEYS) {
|
|
10267
|
-
const envPlatform =
|
|
10670
|
+
const envPlatform = require_compiler.normalizeFrameworkStylePlatform(node_process.default.env[key], opts.appType);
|
|
10268
10671
|
if (envPlatform) return envPlatform;
|
|
10269
10672
|
}
|
|
10270
10673
|
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
@@ -10344,7 +10747,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10344
10747
|
transientAutoCssSources.set(sourceFile, transientSource);
|
|
10345
10748
|
return;
|
|
10346
10749
|
}
|
|
10347
|
-
const dependencies = await
|
|
10750
|
+
const dependencies = await require_tailwindcss.resolveTailwindV4CssDependencies(sourceCss, sourceBase);
|
|
10348
10751
|
transientSource.dependencies = dependencies;
|
|
10349
10752
|
transientAutoCssSources.set(sourceFile, transientSource);
|
|
10350
10753
|
if (!require_generator.upsertTailwindV4CssSource(opts, {
|
|
@@ -10364,7 +10767,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10364
10767
|
};
|
|
10365
10768
|
const discoverAndRegisterAutoCssSources = async () => {
|
|
10366
10769
|
if (!shouldOwnTailwindGeneration || hasInitialTailwindCssRoots || !resolvedConfig?.root) return;
|
|
10367
|
-
const cssEntries = await
|
|
10770
|
+
const cssEntries = await require_tailwindcss.discoverTailwindV4CssEntries(resolvedConfig.root, resolvedConfig.build?.outDir);
|
|
10368
10771
|
autoCssSourcesDiscovered = true;
|
|
10369
10772
|
let changed = false;
|
|
10370
10773
|
for (const cssEntry of cssEntries) {
|
|
@@ -10374,7 +10777,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10374
10777
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) continue;
|
|
10375
10778
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
10376
10779
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
10377
|
-
const resolved = await
|
|
10780
|
+
const resolved = await require_tailwindcss.resolveTailwindV4EntriesFromCssCached(sourceCss, sourceBase);
|
|
10378
10781
|
changed = require_generator.upsertTailwindV4CssSource(opts, {
|
|
10379
10782
|
file: sourceFile,
|
|
10380
10783
|
base: sourceBase,
|
|
@@ -10386,7 +10789,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10386
10789
|
sourceScanSession.invalidate();
|
|
10387
10790
|
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
10388
10791
|
};
|
|
10389
|
-
const customAttributesEntities =
|
|
10792
|
+
const customAttributesEntities = require_compiler.toCustomAttributesEntities(customAttributes);
|
|
10390
10793
|
let recordedGeneratorCandidates;
|
|
10391
10794
|
const sourceCandidateCollector = require_v4_generation_core.createSourceCandidateCollector({
|
|
10392
10795
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
@@ -10458,13 +10861,6 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10458
10861
|
const platform = resolveViteStylePlatform();
|
|
10459
10862
|
return platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb;
|
|
10460
10863
|
};
|
|
10461
|
-
const isNuxtPageHotModule = (id) => {
|
|
10462
|
-
if (typeof id !== "string") return false;
|
|
10463
|
-
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id).replace(/%2F/gi, "/");
|
|
10464
|
-
if (cleanId.includes("virtual:nuxt:") && /(?:^|\/)routes\.mjs$/.test(cleanId)) return true;
|
|
10465
|
-
if (!/[?&]macro=true(?:&|$)/.test(id)) return false;
|
|
10466
|
-
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
10467
|
-
};
|
|
10468
10864
|
const normalizeGeneratedCssCacheFile = (file) => normalizeVitePersistentCacheKey((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
10469
10865
|
const hmrCandidateState = createViteHmrCandidateState({
|
|
10470
10866
|
cleanGeneratedCssByFile,
|
|
@@ -10555,7 +10951,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10555
10951
|
platform
|
|
10556
10952
|
});
|
|
10557
10953
|
};
|
|
10558
|
-
const
|
|
10954
|
+
const generateTailwindCssForVitePipelineNow = async (id, code, hookContext) => {
|
|
10559
10955
|
if (!shouldOwnTailwindGeneration) return;
|
|
10560
10956
|
await runtimeState.readyPromise;
|
|
10561
10957
|
await sourceScanSession.waitForPendingSyncs();
|
|
@@ -10580,7 +10976,13 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
10580
10976
|
const transient = hookContext?.transient === true;
|
|
10581
10977
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
10582
10978
|
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(file, pendingHmrChange !== void 0);
|
|
10583
|
-
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
10979
|
+
const runtime = hookContext?.sourceCandidates === void 0 ? new Set(fullRuntime) : new Set(hookContext.sourceCandidates);
|
|
10980
|
+
if (pendingHmrChange) for (const candidate of pendingHmrChange.addedCandidates) runtime.add(candidate);
|
|
10981
|
+
const getGenerationSourceCandidatesForEntries = pendingHmrChange ? (entries, options2) => {
|
|
10982
|
+
const candidates = new Set(getSourceCandidatesForEntries(entries, options2));
|
|
10983
|
+
for (const candidate of pendingHmrChange.addedCandidates) candidates.add(candidate);
|
|
10984
|
+
return candidates;
|
|
10985
|
+
} : getSourceCandidatesForEntries;
|
|
10584
10986
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
10585
10987
|
css: generatorTransformCode,
|
|
10586
10988
|
cssPipelineContext,
|
|
@@ -10646,7 +11048,7 @@ ${previousTracedCss}`;
|
|
|
10646
11048
|
cssHandlerOptions,
|
|
10647
11049
|
cssUserHandlerOptions: transformCssHandlerOptions.getCssUserHandlerOptions(requestFile),
|
|
10648
11050
|
cssSources: transientCssSource ? [transientCssSource] : void 0,
|
|
10649
|
-
getSourceCandidatesForEntries,
|
|
11051
|
+
getSourceCandidatesForEntries: getGenerationSourceCandidatesForEntries,
|
|
10650
11052
|
generatorPlatform: resolveGeneratorPlatform(),
|
|
10651
11053
|
styleHandler,
|
|
10652
11054
|
debug,
|
|
@@ -10721,6 +11123,7 @@ ${previousTracedCss}`;
|
|
|
10721
11123
|
return `${require_v4_generation_core.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
10722
11124
|
${tracedCss}`;
|
|
10723
11125
|
};
|
|
11126
|
+
const generateTailwindCssForVitePipeline = createFrameworkCssGenerationQueue(normalizeGeneratedCssCacheFile, generateTailwindCssForVitePipelineNow);
|
|
10724
11127
|
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
10725
11128
|
...createCssPipelineContext(),
|
|
10726
11129
|
code,
|
|
@@ -10843,12 +11246,13 @@ ${tracedCss}`;
|
|
|
10843
11246
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
10844
11247
|
await sourceScanSession.sync();
|
|
10845
11248
|
};
|
|
10846
|
-
const extraPlugins = frameworkBranch.createExtraPlugins?.({
|
|
11249
|
+
const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
|
|
10847
11250
|
customAttributesEntities,
|
|
10848
11251
|
disabledDefaultTemplateHandler,
|
|
10849
11252
|
ensureRuntimeClassSet,
|
|
10850
11253
|
generateCss: generateTailwindCssForVitePipeline,
|
|
10851
11254
|
getResolvedConfig,
|
|
11255
|
+
hmrCssModuleVersions,
|
|
10852
11256
|
isEnabled: shouldEnableFrameworkExtraPlugins,
|
|
10853
11257
|
isIosPlatform: extraPluginPlatform.isIosPlatform === true,
|
|
10854
11258
|
isNativeAppStyleTarget: () => frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext()) === true,
|
|
@@ -10861,8 +11265,9 @@ ${tracedCss}`;
|
|
|
10861
11265
|
syncSourceCandidatesForHotUpdate,
|
|
10862
11266
|
tailwindRootCssModuleIds,
|
|
10863
11267
|
uniAppX,
|
|
10864
|
-
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
10865
|
-
|
|
11268
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles,
|
|
11269
|
+
webCssEntryDiagnostics
|
|
11270
|
+
}) ?? [] : [];
|
|
10866
11271
|
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
10867
11272
|
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
10868
11273
|
if (wrapViteCssPostTransform(config, async (css, id) => {
|
|
@@ -10882,6 +11287,7 @@ ${tracedCss}`;
|
|
|
10882
11287
|
cssMemory,
|
|
10883
11288
|
hasUserCssLayerBlocks: require_generator.hasUserCssLayerBlocks,
|
|
10884
11289
|
hmrCandidateState,
|
|
11290
|
+
hmrCssModuleVersions,
|
|
10885
11291
|
hmrTimingRecorder,
|
|
10886
11292
|
invalidateRecordedGeneratorCandidates,
|
|
10887
11293
|
isCurrentWebLikeStylePlatform,
|
|
@@ -10903,7 +11309,8 @@ ${tracedCss}`;
|
|
|
10903
11309
|
sourceScanSession,
|
|
10904
11310
|
tailwindRootCssModuleIds,
|
|
10905
11311
|
transformEarlyMiniProgramCss,
|
|
10906
|
-
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
11312
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles,
|
|
11313
|
+
collectSourceCandidates: capability.sourceCandidates
|
|
10907
11314
|
}, createGenericWebProductionSourceCandidatesApply({
|
|
10908
11315
|
frameworkName: frameworkBranch.frameworkName,
|
|
10909
11316
|
getIsWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
@@ -10921,8 +11328,11 @@ ${tracedCss}`;
|
|
|
10921
11328
|
generateBundleHook,
|
|
10922
11329
|
generatorPlaceholderCssFile,
|
|
10923
11330
|
hasExplicitTailwindcssBasedir,
|
|
11331
|
+
hasExplicitGeneratorTarget: typeof options.__internalViteRawExplicitGeneratorTarget === "boolean" ? options.__internalViteRawExplicitGeneratorTarget : false,
|
|
11332
|
+
frameworkName: frameworkBranch.frameworkName,
|
|
10924
11333
|
hmrTimingRecorder,
|
|
10925
11334
|
opts,
|
|
11335
|
+
resolveViteStylePlatform,
|
|
10926
11336
|
refreshRuntimeState,
|
|
10927
11337
|
setResolvedConfig: (config) => {
|
|
10928
11338
|
resolvedConfig = config;
|
|
@@ -10931,8 +11341,20 @@ ${tracedCss}`;
|
|
|
10931
11341
|
shouldOwnTailwindGeneration,
|
|
10932
11342
|
syncCssEntriesFromAnchor
|
|
10933
11343
|
});
|
|
11344
|
+
const sourceAndRewritePlugins = orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, frameworkBranch.sourceCandidatesBeforeExtraPlugin);
|
|
11345
|
+
const serveJsPlugin = capability.serveJsTransform ? createViteServeJsTransformPlugin({
|
|
11346
|
+
createHandlerOptions: (file) => serveJsHandlerOptions(file, frameworkCssPipelineStrategy?.getServeJsHandlerOptions?.({
|
|
11347
|
+
...createCssPipelineContext(),
|
|
11348
|
+
file
|
|
11349
|
+
})),
|
|
11350
|
+
getCommand: () => resolvedConfig?.command,
|
|
11351
|
+
jsHandler,
|
|
11352
|
+
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
11353
|
+
transformRuntime: ensureRuntimeClassSet
|
|
11354
|
+
}) : void 0;
|
|
10934
11355
|
const plugins = [
|
|
10935
|
-
...
|
|
11356
|
+
...sourceAndRewritePlugins,
|
|
11357
|
+
webCssEntryObserverPlugin,
|
|
10936
11358
|
...createViteCssGenerationPlugins({
|
|
10937
11359
|
generateCss: generateTailwindCssForVitePipeline,
|
|
10938
11360
|
getCommand: () => resolvedConfig?.command,
|
|
@@ -10941,18 +11363,9 @@ ${tracedCss}`;
|
|
|
10941
11363
|
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
10942
11364
|
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
10943
11365
|
}),
|
|
10944
|
-
|
|
10945
|
-
createHandlerOptions: (file) => serveJsHandlerOptions(file, frameworkCssPipelineStrategy?.getServeJsHandlerOptions?.({
|
|
10946
|
-
...createCssPipelineContext(),
|
|
10947
|
-
file
|
|
10948
|
-
})),
|
|
10949
|
-
getCommand: () => resolvedConfig?.command,
|
|
10950
|
-
jsHandler,
|
|
10951
|
-
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
10952
|
-
transformRuntime: ensureRuntimeClassSet
|
|
10953
|
-
}),
|
|
11366
|
+
...serveJsPlugin ? [serveJsPlugin] : [],
|
|
10954
11367
|
{
|
|
10955
|
-
name: `${
|
|
11368
|
+
name: `${require_compiler.vitePluginName}:watch-css-cache`,
|
|
10956
11369
|
configResolved: {
|
|
10957
11370
|
order: "post",
|
|
10958
11371
|
handler: installFrameworkWatchCssCacheAdapter
|
|
@@ -10961,7 +11374,8 @@ ${tracedCss}`;
|
|
|
10961
11374
|
postPlugin
|
|
10962
11375
|
];
|
|
10963
11376
|
plugins.push(cssFinalizerOutputPlugin);
|
|
10964
|
-
plugins.push(
|
|
11377
|
+
plugins.push(createViteHmrCssModuleVersionFilterPlugin(hmrCssModuleVersions));
|
|
11378
|
+
if (capability.styleInjector) plugins.push(...require_source_candidate_scan_signature.createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|
|
10965
11379
|
return plugins;
|
|
10966
11380
|
}
|
|
10967
11381
|
//#endregion
|
|
@@ -11204,20 +11618,20 @@ function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
|
11204
11618
|
const branch = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
11205
11619
|
appType: opts.appType,
|
|
11206
11620
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
11207
|
-
uniAppX:
|
|
11621
|
+
uniAppX: require_tailwindcss.resolveUniAppXOptions(opts.uniAppX),
|
|
11208
11622
|
uniUtsPlatform
|
|
11209
11623
|
});
|
|
11210
11624
|
const runtimeBranch = require_generator.resolveGeneratorRuntimeBranch(branch, {
|
|
11211
11625
|
appType: opts.appType,
|
|
11212
11626
|
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
11213
|
-
uniAppX:
|
|
11627
|
+
uniAppX: require_tailwindcss.resolveUniAppXOptions(opts.uniAppX),
|
|
11214
11628
|
uniUtsPlatform
|
|
11215
11629
|
});
|
|
11216
|
-
if (!require_generator.shouldUseNativeAppCssBranch(runtimeBranch) || !
|
|
11630
|
+
if (!require_generator.shouldUseNativeAppCssBranch(runtimeBranch) || !require_tailwindcss.isUniAppXEnabled(opts.uniAppX)) return {};
|
|
11217
11631
|
return {
|
|
11218
11632
|
uniAppX: true,
|
|
11219
11633
|
uniAppXCssTarget: "uvue",
|
|
11220
|
-
uniAppXUnsupported:
|
|
11634
|
+
uniAppXUnsupported: require_tailwindcss.resolveUniAppXOptions(opts.uniAppX).uvueUnsupported
|
|
11221
11635
|
};
|
|
11222
11636
|
}
|
|
11223
11637
|
//#endregion
|
|
@@ -11275,6 +11689,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
11275
11689
|
ensureRuntimeClassSet: context.ensureRuntimeClassSet,
|
|
11276
11690
|
generateCss: context.generateCss,
|
|
11277
11691
|
getResolvedConfig: context.getResolvedConfig,
|
|
11692
|
+
hmrCssModuleVersions: context.hmrCssModuleVersions,
|
|
11278
11693
|
isEnabled: context.isEnabled,
|
|
11279
11694
|
isIosPlatform: context.isIosPlatform,
|
|
11280
11695
|
isNativeAppStyleTarget: context.isNativeAppStyleTarget,
|
|
@@ -11287,7 +11702,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
11287
11702
|
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
|
11288
11703
|
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
11289
11704
|
uniAppX: context.uniAppX,
|
|
11290
|
-
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|
|
11705
|
+
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles,
|
|
11706
|
+
webCssEntryDiagnostics: context.webCssEntryDiagnostics
|
|
11291
11707
|
})
|
|
11292
11708
|
});
|
|
11293
11709
|
}
|
|
@@ -11301,34 +11717,225 @@ function createWeappVitePlugins(options = {}) {
|
|
|
11301
11717
|
}
|
|
11302
11718
|
//#endregion
|
|
11303
11719
|
//#region src/bundlers/vite/index.ts
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11720
|
+
const hookNames = [
|
|
11721
|
+
"config",
|
|
11722
|
+
"configResolved",
|
|
11723
|
+
"buildStart",
|
|
11724
|
+
"buildEnd",
|
|
11725
|
+
"resolveId",
|
|
11726
|
+
"load",
|
|
11727
|
+
"transform",
|
|
11728
|
+
"configureServer",
|
|
11729
|
+
"handleHotUpdate",
|
|
11730
|
+
"watchChange",
|
|
11731
|
+
"generateBundle",
|
|
11732
|
+
"writeBundle",
|
|
11733
|
+
"closeBundle"
|
|
11734
|
+
];
|
|
11735
|
+
function platformFamily(platform) {
|
|
11736
|
+
const value = platform?.trim().toLowerCase();
|
|
11737
|
+
if (!value) return "unknown";
|
|
11738
|
+
if (value === "h5" || value === "web" || value.startsWith("web-")) return "web";
|
|
11739
|
+
if (value === "app" || value === "app-plus" || value.startsWith("app-")) return "native-app";
|
|
11740
|
+
if (value.startsWith("mp-") || [
|
|
11741
|
+
"weapp",
|
|
11742
|
+
"wechat",
|
|
11743
|
+
"wx",
|
|
11744
|
+
"alipay",
|
|
11745
|
+
"tt",
|
|
11746
|
+
"baidu",
|
|
11747
|
+
"qq",
|
|
11748
|
+
"jd",
|
|
11749
|
+
"swan"
|
|
11750
|
+
].includes(value)) return "mini-program";
|
|
11751
|
+
return "unknown";
|
|
11752
|
+
}
|
|
11753
|
+
function resolveEnvironmentName(context) {
|
|
11754
|
+
const name = context?.environment?.name;
|
|
11755
|
+
return typeof name === "string" && name.length > 0 ? name : "default";
|
|
11756
|
+
}
|
|
11757
|
+
function resolveViteProfile(options, config, environmentName) {
|
|
11758
|
+
const rawTarget = options.generator && typeof options.generator === "object" ? options.generator.target : void 0;
|
|
11759
|
+
const explicitPlatform = options.cssOptions?.platform ?? options.platform;
|
|
11760
|
+
const envPlatform = node_process.default.env["UNI_PLATFORM"] ?? node_process.default.env["UNI_UTS_PLATFORM"];
|
|
11761
|
+
const selectedPlatform = explicitPlatform ?? envPlatform;
|
|
11762
|
+
const explicitAppType = options.appType;
|
|
11763
|
+
const root = config.root ? node_path.default.resolve(config.root) : node_process.default.cwd();
|
|
11764
|
+
let frameworkName = "generic";
|
|
11765
|
+
let appType = explicitAppType;
|
|
11766
|
+
if (explicitAppType) frameworkName = require_source_candidate_scan_signature.resolveViteFrameworkProfile({
|
|
11767
|
+
appType: explicitAppType,
|
|
11768
|
+
uniAppX: options.uniAppX
|
|
11769
|
+
}).frameworkName;
|
|
11770
|
+
else {
|
|
11771
|
+
const detected = require_source_candidate_scan_signature.resolveViteFrameworkProfile({
|
|
11772
|
+
detectEnv: true,
|
|
11773
|
+
env: node_process.default.env,
|
|
11774
|
+
root,
|
|
11775
|
+
searchUp: false,
|
|
11776
|
+
uniAppX: options.uniAppX
|
|
11777
|
+
});
|
|
11778
|
+
frameworkName = detected.frameworkName;
|
|
11779
|
+
appType = detected.appType;
|
|
11780
|
+
if (frameworkName === "generic" && platformFamily(selectedPlatform) !== "web") {
|
|
11781
|
+
appType = require_framework.resolveImplicitAppTypeFromViteRoot(root, { searchUp: false });
|
|
11782
|
+
frameworkName = require_source_candidate_scan_signature.resolveViteFrameworkProfile({
|
|
11783
|
+
appType,
|
|
11784
|
+
uniAppX: options.uniAppX
|
|
11785
|
+
}).frameworkName;
|
|
11786
|
+
}
|
|
11787
|
+
}
|
|
11788
|
+
const family = platformFamily(selectedPlatform ?? (config.build?.outDir ? node_path.default.basename(node_path.default.normalize(config.build.outDir)) : void 0));
|
|
11789
|
+
if (!explicitAppType && !(rawTarget !== "web" && family !== "web")) appType = void 0;
|
|
11790
|
+
const isGenericWeb = frameworkName === "generic" && !explicitAppType && rawTarget !== "weapp" && rawTarget !== "app" && !(Array.isArray(options.cssEntries) && options.cssEntries.length > 0) && family !== "mini-program";
|
|
11791
|
+
const capability = isGenericWeb ? {
|
|
11792
|
+
...createGenericWebViteCapabilityProfile(options),
|
|
11793
|
+
sourceCandidates: options.generator && typeof options.generator === "object" && options.generator.target === "web" ? true : createGenericWebViteCapabilityProfile(options).sourceCandidates
|
|
11794
|
+
} : {
|
|
11795
|
+
...frameworkViteCapabilityProfile,
|
|
11796
|
+
frameworkName,
|
|
11797
|
+
generatorTarget: rawTarget,
|
|
11798
|
+
platformFamily: family
|
|
11799
|
+
};
|
|
11800
|
+
capability.command = config.command;
|
|
11801
|
+
capability.watch = config.build?.watch != null;
|
|
11802
|
+
capability.ssr = Boolean(config.build?.ssr);
|
|
11803
|
+
capability.environmentName = environmentName;
|
|
11804
|
+
return {
|
|
11805
|
+
frameworkName,
|
|
11806
|
+
appType,
|
|
11807
|
+
capability,
|
|
11808
|
+
isGenericWeb
|
|
11809
|
+
};
|
|
11810
|
+
}
|
|
11811
|
+
function invokeHook(plugin, hookName, thisArg, args) {
|
|
11812
|
+
const hook = plugin?.[hookName];
|
|
11813
|
+
if (typeof hook === "function") return hook.apply(thisArg, args);
|
|
11814
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return hook.handler.apply(thisArg, args);
|
|
11815
|
+
}
|
|
11816
|
+
function createDispatcher(options) {
|
|
11817
|
+
const opts = require_compiler.getCompilerContext({
|
|
11313
11818
|
...options,
|
|
11314
11819
|
__internalDeferMissingCssEntriesWarning: true
|
|
11315
11820
|
});
|
|
11316
11821
|
opts.__internalViteRawOptions = options;
|
|
11317
|
-
opts.__internalViteRawExplicitAppType =
|
|
11318
|
-
opts.__internalViteRawExplicitTailwindcssBasedir =
|
|
11319
|
-
|
|
11822
|
+
opts.__internalViteRawExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
11823
|
+
opts.__internalViteRawExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
11824
|
+
opts.__internalViteRawExplicitGeneratorTarget = Boolean(options.generator && typeof options.generator === "object" && Object.hasOwn(options.generator, "target"));
|
|
11825
|
+
const initialProfile = require_source_candidate_scan_signature.resolveViteFrameworkProfile({
|
|
11320
11826
|
appType: opts.appType,
|
|
11321
11827
|
detectEnv: true,
|
|
11322
11828
|
env: node_process.default.env,
|
|
11323
|
-
root:
|
|
11829
|
+
root: typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0 ? node_path.default.resolve(options.tailwindcssBasedir) : void 0,
|
|
11830
|
+
searchUp: false,
|
|
11324
11831
|
uniAppX: opts.uniAppX
|
|
11325
|
-
})
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11832
|
+
});
|
|
11833
|
+
const initialFramework = initialProfile.frameworkName;
|
|
11834
|
+
opts.__internalViteCapabilityProfile = { ...frameworkViteCapabilityProfile };
|
|
11835
|
+
const initialFactory = {
|
|
11836
|
+
"generic": createGenericVitePlugins,
|
|
11837
|
+
"taro": createTaroVitePlugins,
|
|
11838
|
+
"uni-app": createUniAppVitePlugins,
|
|
11839
|
+
"uni-app-x": createUniAppXVitePlugins,
|
|
11840
|
+
"weapp-vite": createWeappVitePlugins
|
|
11841
|
+
}[initialFramework];
|
|
11842
|
+
const initialPlugins = initialFactory(opts);
|
|
11843
|
+
if (!initialPlugins) return;
|
|
11844
|
+
if (opts.__internalViteRawExplicitTailwindcssBasedir && initialFramework !== "generic") return initialPlugins;
|
|
11845
|
+
const knownFrameworkPlugins = [
|
|
11846
|
+
{
|
|
11847
|
+
name: "weapp-tailwindcss:taro-alipay-browserslist-asset",
|
|
11848
|
+
enforce: "pre",
|
|
11849
|
+
generateBundle() {}
|
|
11850
|
+
},
|
|
11851
|
+
{
|
|
11852
|
+
name: "weapp-tailwindcss:uni-app-x:css:pre",
|
|
11853
|
+
enforce: "pre",
|
|
11854
|
+
transform() {}
|
|
11855
|
+
},
|
|
11856
|
+
{
|
|
11857
|
+
name: "weapp-tailwindcss:uni-app-x:css",
|
|
11858
|
+
transform() {}
|
|
11859
|
+
},
|
|
11860
|
+
{
|
|
11861
|
+
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
11862
|
+
enforce: "pre",
|
|
11863
|
+
buildStart() {},
|
|
11864
|
+
transform: {
|
|
11865
|
+
order: "pre",
|
|
11866
|
+
handler() {}
|
|
11867
|
+
},
|
|
11868
|
+
handleHotUpdate: {
|
|
11869
|
+
order: "post",
|
|
11870
|
+
handler() {}
|
|
11871
|
+
},
|
|
11872
|
+
watchChange() {}
|
|
11873
|
+
},
|
|
11874
|
+
{
|
|
11875
|
+
name: "weapp-tailwindcss:uni-app-x:style-placeholder",
|
|
11876
|
+
enforce: "post",
|
|
11877
|
+
generateBundle: {
|
|
11878
|
+
order: "post",
|
|
11879
|
+
handler() {}
|
|
11880
|
+
}
|
|
11881
|
+
}
|
|
11882
|
+
];
|
|
11883
|
+
const initialNames = new Set(initialPlugins.map((plugin) => plugin.name));
|
|
11884
|
+
const pluginTemplates = [...initialPlugins, ...initialFramework === "generic" && !opts.appType && initialPlugins.length > 1 ? knownFrameworkPlugins.filter((plugin) => !initialNames.has(plugin.name)) : []];
|
|
11885
|
+
let activePlugins = initialPlugins;
|
|
11886
|
+
let resolved = false;
|
|
11887
|
+
const ensureBranch = (config, context) => {
|
|
11888
|
+
if (resolved) return;
|
|
11889
|
+
resolved = true;
|
|
11890
|
+
const environmentName = resolveEnvironmentName(context);
|
|
11891
|
+
const effectiveGenerator = options.generator ?? opts.generator;
|
|
11892
|
+
const effectiveAppType = options.appType ?? (effectiveGenerator && typeof effectiveGenerator === "object" && effectiveGenerator.target === "web" ? void 0 : opts.appType);
|
|
11893
|
+
const profile = resolveViteProfile({
|
|
11894
|
+
...options,
|
|
11895
|
+
appType: effectiveAppType,
|
|
11896
|
+
generator: effectiveGenerator,
|
|
11897
|
+
platform: options.platform ?? opts.platform,
|
|
11898
|
+
cssOptions: options.cssOptions ?? opts.cssOptions,
|
|
11899
|
+
uniAppX: options.uniAppX ?? opts.uniAppX
|
|
11900
|
+
}, config, environmentName);
|
|
11901
|
+
if (profile.appType && profile.appType !== initialProfile.appType && !options.appType && effectiveAppType === void 0) {
|
|
11902
|
+
opts.appType = profile.appType;
|
|
11903
|
+
_weapp_tailwindcss_logger.logger.info("根据 Vite 项目根目录自动推断 appType -> %s", profile.appType);
|
|
11904
|
+
}
|
|
11905
|
+
if (profile.isGenericWeb && !opts.generator && opts.generator !== false && !options.platform && !options.cssOptions?.platform && !node_process.default.env["UNI_PLATFORM"] && !node_process.default.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
|
|
11906
|
+
const capability = opts.__internalViteCapabilityProfile;
|
|
11907
|
+
if (capability) Object.assign(capability, profile.capability);
|
|
11908
|
+
else opts.__internalViteCapabilityProfile = profile.capability;
|
|
11909
|
+
const factory = {
|
|
11910
|
+
"generic": createGenericVitePlugins,
|
|
11911
|
+
"taro": createTaroVitePlugins,
|
|
11912
|
+
"uni-app": createUniAppVitePlugins,
|
|
11913
|
+
"uni-app-x": createUniAppXVitePlugins,
|
|
11914
|
+
"weapp-vite": createWeappVitePlugins
|
|
11915
|
+
}[profile.frameworkName];
|
|
11916
|
+
if (profile.frameworkName !== initialFramework) activePlugins = factory(opts) ?? [];
|
|
11917
|
+
};
|
|
11918
|
+
const byName = (name) => activePlugins.find((plugin) => plugin.name === name);
|
|
11919
|
+
return pluginTemplates.map((template) => {
|
|
11920
|
+
const proxy = { ...template };
|
|
11921
|
+
for (const hookName of hookNames) {
|
|
11922
|
+
if (!(hookName in template)) continue;
|
|
11923
|
+
const originalHook = template[hookName];
|
|
11924
|
+
const handler = function(...args) {
|
|
11925
|
+
if (hookName === "configResolved") ensureBranch(args[0], this);
|
|
11926
|
+
return invokeHook(byName(template.name), hookName, this, args);
|
|
11927
|
+
};
|
|
11928
|
+
proxy[hookName] = originalHook && typeof originalHook === "object" ? {
|
|
11929
|
+
...originalHook,
|
|
11930
|
+
handler
|
|
11931
|
+
} : handler;
|
|
11932
|
+
}
|
|
11933
|
+
return proxy;
|
|
11934
|
+
});
|
|
11935
|
+
}
|
|
11936
|
+
/** Vite 单一入口。框架分支在 Vite 完成配置解析后选择,保持原有导入和注册方式。 */
|
|
11937
|
+
function WeappTailwindcss(options = {}) {
|
|
11938
|
+
return createDispatcher(options);
|
|
11332
11939
|
}
|
|
11333
11940
|
//#endregion
|
|
11334
11941
|
Object.defineProperty(exports, "WeappTailwindcss", {
|