weapp-tailwindcss 4.11.0-alpha.1 → 4.11.0-alpha.2

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.
Files changed (73) hide show
  1. package/dist/{chunk-35EI5JMK.mjs → chunk-23K4XDKF.mjs} +3 -1
  2. package/dist/{chunk-W2EMGF7H.js → chunk-2W24MRCQ.js} +10 -12
  3. package/dist/chunk-4AFQP74Z.js +24 -0
  4. package/dist/{chunk-SQG2MOFQ.js → chunk-4TTPYMVM.js} +12 -8
  5. package/dist/{chunk-4LPOQMFS.js → chunk-5KSBT6GU.js} +396 -219
  6. package/dist/{chunk-LD7LZ4IK.mjs → chunk-66E76FQE.mjs} +91 -50
  7. package/dist/{chunk-GWDHNCL2.js → chunk-6O7HJU2F.js} +123 -42
  8. package/dist/{chunk-RRHPTTCP.mjs → chunk-76S2EME4.mjs} +2 -0
  9. package/dist/{chunk-G3G437UE.js → chunk-7LKMJZD2.js} +2 -2
  10. package/dist/{chunk-OV7FX6XR.js → chunk-CRDOWYG4.js} +1 -1
  11. package/dist/{chunk-DOH7FULQ.mjs → chunk-EFBQ4SQR.mjs} +1 -1
  12. package/dist/{chunk-IEZ5RBMG.mjs → chunk-EW2K6CO5.mjs} +365 -188
  13. package/dist/{chunk-FZNYV7VH.mjs → chunk-HADJCWHU.mjs} +212 -258
  14. package/dist/{chunk-CZLXTEHN.js → chunk-K7CZXT46.js} +132 -91
  15. package/dist/{chunk-ACTJYB33.js → chunk-LL3QUKJI.js} +3 -1
  16. package/dist/{chunk-G5NLM3AL.js → chunk-LYGLQCWI.js} +278 -324
  17. package/dist/{chunk-LTJQUORK.js → chunk-OF6MFURR.js} +2 -0
  18. package/dist/{chunk-KKT2DKMW.mjs → chunk-RED7Y22U.mjs} +91 -10
  19. package/dist/{chunk-R6KEYO3F.mjs → chunk-SJ3SG6DU.mjs} +5 -1
  20. package/dist/{chunk-JBM3HGHP.mjs → chunk-UCUAXK7F.mjs} +4 -6
  21. package/dist/cli.js +1006 -147
  22. package/dist/cli.mjs +942 -107
  23. package/dist/core.d.mts +2 -2
  24. package/dist/core.d.ts +2 -2
  25. package/dist/core.js +9 -11
  26. package/dist/core.mjs +6 -8
  27. package/dist/css-macro/postcss.js +1 -1
  28. package/dist/css-macro/postcss.mjs +1 -1
  29. package/dist/css-macro.js +3 -3
  30. package/dist/css-macro.mjs +4 -4
  31. package/dist/defaults.d.mts +2 -2
  32. package/dist/defaults.d.ts +2 -2
  33. package/dist/defaults.js +3 -3
  34. package/dist/defaults.mjs +2 -2
  35. package/dist/gulp.d.mts +2 -2
  36. package/dist/gulp.d.ts +2 -2
  37. package/dist/gulp.js +7 -8
  38. package/dist/gulp.mjs +6 -7
  39. package/dist/{index-t_VBjwYm.d.ts → index-BMwzhITq.d.mts} +6 -6
  40. package/dist/{index-t_VBjwYm.d.mts → index-BMwzhITq.d.ts} +6 -6
  41. package/dist/index.d.mts +2 -2
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.js +11 -12
  44. package/dist/index.mjs +9 -10
  45. package/dist/postcss-html-transform.js +1 -1
  46. package/dist/postcss-html-transform.mjs +1 -1
  47. package/dist/presets.d.mts +2 -2
  48. package/dist/presets.d.ts +2 -2
  49. package/dist/presets.js +5 -5
  50. package/dist/presets.mjs +2 -2
  51. package/dist/reset.js +1 -1
  52. package/dist/reset.mjs +1 -1
  53. package/dist/types.d.mts +4 -4
  54. package/dist/types.d.ts +4 -4
  55. package/dist/types.js +1 -1
  56. package/dist/types.mjs +1 -1
  57. package/dist/vite.d.mts +2 -2
  58. package/dist/vite.d.ts +2 -2
  59. package/dist/vite.js +8 -9
  60. package/dist/vite.mjs +6 -7
  61. package/dist/weapp-tw-css-import-rewrite-loader.js +3 -1
  62. package/dist/weapp-tw-runtime-classset-loader.js +29 -2
  63. package/dist/webpack.d.mts +2 -2
  64. package/dist/webpack.d.ts +2 -2
  65. package/dist/webpack.js +9 -10
  66. package/dist/webpack.mjs +7 -8
  67. package/dist/webpack4.d.mts +2 -2
  68. package/dist/webpack4.d.ts +2 -2
  69. package/dist/webpack4.js +41 -41
  70. package/dist/webpack4.mjs +12 -12
  71. package/package.json +8 -8
  72. package/dist/chunk-NOKJXG3W.js +0 -29
  73. package/dist/chunk-QYZCRG7F.mjs +0 -29
@@ -9,10 +9,7 @@ import {
9
9
  } from "./chunk-F2CKKG6Q.mjs";
10
10
  import {
11
11
  processCachedTask
12
- } from "./chunk-RRHPTTCP.mjs";
13
- import {
14
- setupPatchRecorder
15
- } from "./chunk-QYZCRG7F.mjs";
12
+ } from "./chunk-76S2EME4.mjs";
16
13
  import {
17
14
  babelParse,
18
15
  collectRuntimeClassSet,
@@ -20,17 +17,19 @@ import {
20
17
  createDebug,
21
18
  generateCode,
22
19
  getCompilerContext,
23
- getRuntimeClassSetSignature,
24
20
  refreshTailwindRuntimeState,
25
21
  replaceWxml,
22
+ setupPatchRecorder,
26
23
  toCustomAttributesEntities,
27
24
  traverse,
28
25
  vitePluginName
29
- } from "./chunk-FZNYV7VH.mjs";
26
+ } from "./chunk-HADJCWHU.mjs";
30
27
  import {
31
28
  findNearestPackageRoot,
32
- findTailwindConfig
33
- } from "./chunk-IEZ5RBMG.mjs";
29
+ findTailwindConfig,
30
+ getRuntimeClassSetSignature,
31
+ resolveTailwindcssOptions
32
+ } from "./chunk-EW2K6CO5.mjs";
34
33
  import {
35
34
  resolveUniUtsPlatform
36
35
  } from "./chunk-OOHJLO5M.mjs";
@@ -420,6 +419,8 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
420
419
  // src/bundlers/vite/generate-bundle.ts
421
420
  import path2 from "path";
422
421
  import process2 from "process";
422
+ import { logger } from "@weapp-tailwindcss/logger";
423
+ import { splitCode } from "@weapp-tailwindcss/shared/extractors";
423
424
 
424
425
  // src/bundlers/vite/bundle-entries.ts
425
426
  import { Buffer } from "buffer";
@@ -707,34 +708,6 @@ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
707
708
  linkedImpactsByEntry
708
709
  };
709
710
  }
710
- function buildBundleSnapshotForBuild(bundle, opts, outDir) {
711
- const processFiles = createProcessFiles();
712
- const jsEntries = /* @__PURE__ */ new Map();
713
- const entries = [];
714
- for (const [file, output] of Object.entries(bundle)) {
715
- const type = classifyBundleEntry(file, opts);
716
- const source = readEntrySource(output);
717
- markProcessFile(type, file, processFiles);
718
- collectJsEntries(file, output, outDir, jsEntries);
719
- entries.push({
720
- file,
721
- output,
722
- source,
723
- type
724
- });
725
- }
726
- return {
727
- entries,
728
- jsEntries,
729
- sourceHashByFile: /* @__PURE__ */ new Map(),
730
- runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
731
- runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
732
- changedByType: createChangedByType(),
733
- runtimeAffectingChangedByType: createChangedByType(),
734
- processFiles,
735
- linkedImpactsByEntry: /* @__PURE__ */ new Map()
736
- };
737
- }
738
711
  function invertLinkedByEntry(linkedByEntry) {
739
712
  const dependentsByLinkedFile = /* @__PURE__ */ new Map();
740
713
  for (const [entryFile, linkedFiles] of linkedByEntry.entries()) {
@@ -749,12 +722,22 @@ function invertLinkedByEntry(linkedByEntry) {
749
722
  }
750
723
  return dependentsByLinkedFile;
751
724
  }
752
- function updateBundleBuildState(state, snapshot, linkedByEntry) {
725
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
726
+ const incremental = options.incremental === true;
753
727
  state.iteration += 1;
754
- state.sourceHashByFile = snapshot.sourceHashByFile;
755
- state.runtimeAffectingHashByFile = snapshot.runtimeAffectingHashByFile;
756
- state.linkedByEntry = linkedByEntry;
757
- state.dependentsByLinkedFile = invertLinkedByEntry(linkedByEntry);
728
+ state.sourceHashByFile = incremental ? new Map([
729
+ ...state.sourceHashByFile,
730
+ ...snapshot.sourceHashByFile
731
+ ]) : snapshot.sourceHashByFile;
732
+ state.runtimeAffectingHashByFile = incremental ? new Map([
733
+ ...state.runtimeAffectingHashByFile,
734
+ ...snapshot.runtimeAffectingHashByFile
735
+ ]) : snapshot.runtimeAffectingHashByFile;
736
+ state.linkedByEntry = incremental ? new Map([
737
+ ...state.linkedByEntry,
738
+ ...linkedByEntry
739
+ ]) : linkedByEntry;
740
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
758
741
  }
759
742
 
760
743
  // src/bundlers/vite/js-precheck.ts
@@ -862,6 +845,39 @@ function hasRuntimeAffectingSourceChanges(changedByType) {
862
845
  function canShareCssTransformResult(rawSource) {
863
846
  return !rawSource.includes("@import") && !rawSource.includes("url(");
864
847
  }
848
+ function hasOmittedKnownBundleFiles(currentBundleFiles, previousBundleFiles) {
849
+ const currentFileSet = new Set(currentBundleFiles);
850
+ for (const file of previousBundleFiles) {
851
+ if (!currentFileSet.has(file)) {
852
+ return true;
853
+ }
854
+ }
855
+ return false;
856
+ }
857
+ var MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
858
+ var QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
859
+ function isArbitraryValueCandidate(candidate) {
860
+ return candidate.includes("[") && candidate.includes("]");
861
+ }
862
+ function collectUnescapedDynamicCandidates(source) {
863
+ const matches = /* @__PURE__ */ new Set();
864
+ for (const expression of source.match(MUSTACHE_EXPRESSION_RE) ?? []) {
865
+ QUOTED_LITERAL_RE.lastIndex = 0;
866
+ let quoted = QUOTED_LITERAL_RE.exec(expression);
867
+ while (quoted !== null) {
868
+ const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
869
+ for (const candidate of splitCode(literal, true)) {
870
+ const normalized = candidate.trim();
871
+ if (!normalized || !isArbitraryValueCandidate(normalized)) {
872
+ continue;
873
+ }
874
+ matches.add(normalized);
875
+ }
876
+ quoted = QUOTED_LITERAL_RE.exec(expression);
877
+ }
878
+ }
879
+ return [...matches];
880
+ }
865
881
  function createGenerateBundleHook(context) {
866
882
  const state = createBundleBuildState();
867
883
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
@@ -914,10 +930,12 @@ function createGenerateBundleHook(context) {
914
930
  const disableJsPrecheck = process2.env.WEAPP_TW_VITE_DISABLE_JS_PRECHECK === "1";
915
931
  const debugCssDiff = process2.env.WEAPP_TW_VITE_DEBUG_CSS_DIFF === "1";
916
932
  const resolvedConfig = getResolvedConfig();
917
- const useIncrementalMode = resolvedConfig?.command !== "build";
933
+ const bundleFiles = Object.keys(bundle);
934
+ const buildCommand = resolvedConfig?.command === "build";
935
+ const useIncrementalMode = !buildCommand || hasOmittedKnownBundleFiles(bundleFiles, state.sourceHashByFile.keys());
918
936
  const rootDir = resolvedConfig?.root ? path2.resolve(resolvedConfig.root) : process2.cwd();
919
937
  const outDir = resolvedConfig?.build?.outDir ? path2.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
920
- const snapshot = useIncrementalMode ? buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization) : buildBundleSnapshotForBuild(bundle, opts, outDir);
938
+ const snapshot = buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization || !useIncrementalMode);
921
939
  const useBundleRuntimeClassSet = useIncrementalMode || runtimeState.twPatcher.majorVersion === 4;
922
940
  const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
923
941
  const processFiles = snapshot.processFiles;
@@ -1026,7 +1044,27 @@ function createGenerateBundleHook(context) {
1026
1044
  },
1027
1045
  async transform() {
1028
1046
  const start = performance.now();
1029
- const transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
1047
+ let transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
1048
+ let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
1049
+ if (unresolvedDynamicCandidates.length > 0) {
1050
+ logger.warn(
1051
+ "\u68C0\u6D4B\u5230 WXML \u52A8\u6001\u7C7B\u540D\u672A\u5B8C\u6210\u8F6C\u8BD1\uFF0C\u5DF2\u56DE\u9000\u5230\u5B8C\u6574 runtimeSet \u91CD\u8BD5: %s -> %O",
1052
+ file,
1053
+ unresolvedDynamicCandidates
1054
+ );
1055
+ const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
1056
+ transformed = await templateHandler(rawSource, {
1057
+ runtimeSet: fullRuntimeSet
1058
+ });
1059
+ unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
1060
+ if (unresolvedDynamicCandidates.length > 0) {
1061
+ logger.warn(
1062
+ "WXML \u52A8\u6001\u7C7B\u540D\u5728\u5B8C\u6574 runtimeSet \u91CD\u8BD5\u540E\u4ECD\u672A\u5B8C\u6210\u8F6C\u8BD1: %s -> %O",
1063
+ file,
1064
+ unresolvedDynamicCandidates
1065
+ );
1066
+ }
1067
+ }
1030
1068
  metrics.html.elapsed += measureElapsed(start);
1031
1069
  metrics.html.transformed++;
1032
1070
  onUpdate(file, rawSource, transformed);
@@ -1241,9 +1279,12 @@ function createGenerateBundleHook(context) {
1241
1279
  for (const apply of pendingLinkedUpdates) {
1242
1280
  apply();
1243
1281
  }
1244
- if (useIncrementalMode) {
1245
- updateBundleBuildState(state, snapshot, linkedByEntry ?? /* @__PURE__ */ new Map());
1246
- }
1282
+ updateBundleBuildState(
1283
+ state,
1284
+ snapshot,
1285
+ useIncrementalMode ? linkedByEntry ?? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map(),
1286
+ { incremental: useIncrementalMode }
1287
+ );
1247
1288
  debug3(
1248
1289
  "metrics iteration=%d runtime=%sms html(total=%d transform=%d hit=%d rate=%s elapsed=%sms) js(total=%d transform=%d hit=%d rate=%s elapsed=%sms) css(total=%d transform=%d hit=%d rate=%s elapsed=%sms)",
1249
1290
  useIncrementalMode ? state.iteration : 0,
@@ -1293,7 +1334,7 @@ function isPostcssPluginImportTarget(value) {
1293
1334
  return value === "@tailwindcss/postcss" || value === "@tailwindcss/postcss7-compat" || value.includes("/postcss");
1294
1335
  }
1295
1336
  function resolveTailwindCssImportTarget(patcher) {
1296
- const tailwindOptions = patcher.options?.tailwind;
1337
+ const tailwindOptions = resolveTailwindcssOptions(patcher.options);
1297
1338
  const cssEntries = tailwindOptions?.v4?.cssEntries?.filter((item) => typeof item === "string" && item.length > 0);
1298
1339
  if (cssEntries && cssEntries.length > 0) {
1299
1340
  return createCssImportSource(cssEntries);
@@ -1336,7 +1377,7 @@ function resolveMaybeAbsolute(base, value) {
1336
1377
  }
1337
1378
  async function resolveTailwindCssSource(patcher) {
1338
1379
  const projectRoot = getProjectRoot(patcher);
1339
- const tailwindOptions = patcher.options?.tailwind;
1380
+ const tailwindOptions = resolveTailwindcssOptions(patcher.options);
1340
1381
  const configuredBase = resolveMaybeAbsolute(projectRoot, tailwindOptions?.v4?.base);
1341
1382
  const configDir = tailwindOptions?.config ? path3.dirname(tailwindOptions.config) : void 0;
1342
1383
  const sharedFallbacks = [
@@ -1763,7 +1804,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1763
1804
  let runtimeRefreshOptionsKey;
1764
1805
  const bundleRuntimeClassSetManager = createBundleRuntimeClassSetManager();
1765
1806
  function resolveRuntimeRefreshOptions() {
1766
- const configPath = runtimeState.twPatcher.options?.tailwind?.config;
1807
+ const configPath = resolveTailwindcssOptions(runtimeState.twPatcher.options)?.config;
1767
1808
  const signature = getRuntimeClassSetSignature(runtimeState.twPatcher);
1768
1809
  const optionsKey = JSON.stringify({
1769
1810
  appType,
@@ -10,27 +10,29 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkSQG2MOFQjs = require('./chunk-SQG2MOFQ.js');
14
13
 
14
+ var _chunk4TTPYMVMjs = require('./chunk-4TTPYMVM.js');
15
15
 
16
16
 
17
17
 
18
18
 
19
19
 
20
- var _chunkG3G437UEjs = require('./chunk-G3G437UE.js');
21
20
 
21
+ var _chunk7LKMJZD2js = require('./chunk-7LKMJZD2.js');
22
22
 
23
- var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
24
23
 
24
+ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
25
25
 
26
- var _chunkNOKJXG3Wjs = require('./chunk-NOKJXG3W.js');
27
26
 
28
27
 
29
28
 
30
29
 
31
30
 
31
+ var _chunkLYGLQCWIjs = require('./chunk-LYGLQCWI.js');
32
32
 
33
- var _chunkG5NLM3ALjs = require('./chunk-G5NLM3AL.js');
33
+
34
+
35
+ var _chunk5KSBT6GUjs = require('./chunk-5KSBT6GU.js');
34
36
 
35
37
 
36
38
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
@@ -53,15 +55,18 @@ function setupWebpackV5ProcessAssetsHook(options) {
53
55
  options: compilerOptions,
54
56
  appType,
55
57
  runtimeState,
58
+ getRuntimeRefreshRequirement,
59
+ refreshRuntimeMetadata,
60
+ consumeRuntimeRefreshRequirement,
56
61
  debug: debug2
57
62
  } = options;
58
63
  const { Compilation, sources } = compiler.webpack;
59
64
  const { ConcatSource } = sources;
60
65
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
61
- compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, (compilation) => {
66
+ compiler.hooks.compilation.tap(_chunkLYGLQCWIjs.pluginName, (compilation) => {
62
67
  compilation.hooks.processAssets.tapPromise(
63
68
  {
64
- name: _chunkG5NLM3ALjs.pluginName,
69
+ name: _chunkLYGLQCWIjs.pluginName,
65
70
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
66
71
  },
67
72
  async (assets) => {
@@ -73,20 +78,20 @@ function setupWebpackV5ProcessAssetsHook(options) {
73
78
  compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
74
79
  }
75
80
  }
76
- const assetHashByChunk = _chunkSQG2MOFQjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
81
+ const assetHashByChunk = _chunk4TTPYMVMjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
77
82
  const entries = Object.entries(assets);
78
83
  const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _ => _.compiler, 'optionalAccess', _2 => _2.outputPath]), () => ( compiler.outputPath));
79
84
  const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _3 => _3.outputOptions, 'optionalAccess', _4 => _4.path]), () => ( _process2.default.cwd()));
80
85
  const jsAssets = /* @__PURE__ */ new Map();
81
86
  for (const [file] of entries) {
82
87
  if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
83
- const absolute = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
88
+ const absolute = _chunk7LKMJZD2js.toAbsoluteOutputPath.call(void 0, file, outputDir);
84
89
  jsAssets.set(absolute, file);
85
90
  }
86
91
  }
87
92
  const moduleGraphOptions = {
88
93
  resolve(specifier, importer) {
89
- return _chunkG3G437UEjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
94
+ return _chunk7LKMJZD2js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
90
95
  },
91
96
  load: (id) => {
92
97
  const assetName = jsAssets.get(id);
@@ -150,12 +155,18 @@ function setupWebpackV5ProcessAssetsHook(options) {
150
155
  return created;
151
156
  };
152
157
  const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
153
- const runtimeSet = await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
158
+ const forceRuntimeRefresh = getRuntimeRefreshRequirement();
159
+ debug2("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, _nullishCoalesce(runtimeState.twPatcher.majorVersion, () => ( "unknown")));
160
+ const runtimeSet = await _chunkLYGLQCWIjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
161
+ forceRefresh: forceRuntimeRefresh,
154
162
  // webpack 的 script-only 热更新可能不会触发 runtime classset loader,
155
163
  // 这里强制收集可避免沿用上轮 class set,保证 JS 仅按最新集合精确命中。
156
164
  forceCollect: true,
165
+ clearCache: forceRuntimeRefresh,
157
166
  allowEmpty: false
158
167
  });
168
+ await refreshRuntimeMetadata(forceRuntimeRefresh);
169
+ consumeRuntimeRefreshRequirement();
159
170
  const defaultTemplateHandlerOptions = {
160
171
  runtimeSet
161
172
  };
@@ -168,7 +179,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
168
179
  const cacheKey = file;
169
180
  const chunkHash = assetHashByChunk.get(file);
170
181
  tasks.push(
171
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
182
+ _chunkOF6MFURRjs.processCachedTask.call(void 0, {
172
183
  cache: compilerOptions.cache,
173
184
  cacheKey,
174
185
  hashKey: `${file}:asset`,
@@ -196,17 +207,17 @@ function setupWebpackV5ProcessAssetsHook(options) {
196
207
  const jsTaskFactories = [];
197
208
  if (Array.isArray(groupedEntries.js)) {
198
209
  for (const [file] of groupedEntries.js) {
199
- const cacheKey = _chunkSQG2MOFQjs.getCacheKey.call(void 0, file);
210
+ const cacheKey = _chunk4TTPYMVMjs.getCacheKey.call(void 0, file);
200
211
  const asset = compilation.getAsset(file);
201
212
  if (!asset) {
202
213
  continue;
203
214
  }
204
- const absoluteFile = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
215
+ const absoluteFile = _chunk7LKMJZD2js.toAbsoluteOutputPath.call(void 0, file, outputDir);
205
216
  const initialSource = asset.source.source();
206
217
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
207
218
  const chunkHash = assetHashByChunk.get(file);
208
219
  jsTaskFactories.push(async () => {
209
- await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
220
+ await _chunkOF6MFURRjs.processCachedTask.call(void 0, {
210
221
  cache: compilerOptions.cache,
211
222
  cacheKey,
212
223
  hashKey: `${file}:asset`,
@@ -250,7 +261,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
250
261
  const cacheKey = file;
251
262
  const chunkHash = assetHashByChunk.get(file);
252
263
  tasks.push(
253
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
264
+ _chunkOF6MFURRjs.processCachedTask.call(void 0, {
254
265
  cache: compilerOptions.cache,
255
266
  cacheKey,
256
267
  hashKey: `${file}:asset`,
@@ -276,7 +287,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
276
287
  );
277
288
  }
278
289
  }
279
- _chunkG3G437UEjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
290
+ _chunk7LKMJZD2js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
280
291
  await Promise.all(tasks);
281
292
  debug2("end");
282
293
  compilerOptions.onEnd();
@@ -299,11 +310,12 @@ function setupWebpackV5Loaders(options) {
299
310
  runtimeLoaderPath,
300
311
  runtimeCssImportRewriteLoaderPath,
301
312
  getClassSetInLoader,
313
+ getRuntimeWatchDependencies,
302
314
  debug: debug2
303
315
  } = options;
304
- const isMpxApp = _chunkSQG2MOFQjs.isMpx.call(void 0, appType);
316
+ const isMpxApp = _chunk4TTPYMVMjs.isMpx.call(void 0, appType);
305
317
  if (shouldRewriteCssImports && isMpxApp) {
306
- _chunkSQG2MOFQjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
318
+ _chunk4TTPYMVMjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
307
319
  }
308
320
  const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
309
321
  const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
@@ -314,14 +326,15 @@ function setupWebpackV5Loaders(options) {
314
326
  appType
315
327
  } : void 0;
316
328
  const classSetLoaderOptions = {
317
- getClassSet: getClassSetInLoader
329
+ getClassSet: getClassSetInLoader,
330
+ getWatchDependencies: getRuntimeWatchDependencies
318
331
  };
319
- const { findRewriteAnchor, findClassSetAnchor } = _chunkSQG2MOFQjs.createLoaderAnchorFinders.call(void 0, appType);
332
+ const { findRewriteAnchor, findClassSetAnchor } = _chunk4TTPYMVMjs.createLoaderAnchorFinders.call(void 0, appType);
320
333
  const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
321
334
  rewriteCssImports: runtimeLoaderRewriteOptions
322
335
  } : void 0;
323
336
  if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
324
- _chunkSQG2MOFQjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
337
+ _chunk4TTPYMVMjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
325
338
  }
326
339
  const createRuntimeClassSetLoaderEntry = () => ({
327
340
  loader: runtimeClassSetLoader,
@@ -341,17 +354,17 @@ function setupWebpackV5Loaders(options) {
341
354
  };
342
355
  };
343
356
  const { NormalModule } = compiler.webpack;
344
- compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, (compilation) => {
345
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkG5NLM3ALjs.pluginName, (_loaderContext, module) => {
357
+ compiler.hooks.compilation.tap(_chunkLYGLQCWIjs.pluginName, (compilation) => {
358
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkLYGLQCWIjs.pluginName, (_loaderContext, module) => {
346
359
  const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
347
360
  if (!hasRuntimeLoader) {
348
361
  return;
349
362
  }
350
- _chunkSQG2MOFQjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, shouldRewriteCssImports && isMpxApp);
363
+ _chunk4TTPYMVMjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, shouldRewriteCssImports && isMpxApp);
351
364
  const loaderEntries = module.loaders || [];
352
365
  let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
353
366
  const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
354
- const isCssModule = _chunkSQG2MOFQjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
367
+ const isCssModule = _chunk4TTPYMVMjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
355
368
  if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
356
369
  debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
357
370
  }
@@ -383,7 +396,7 @@ function setupWebpackV5Loaders(options) {
383
396
  rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
384
397
  }
385
398
  }
386
- if (runtimeClassSetLoaderExists && !_chunkSQG2MOFQjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
399
+ if (runtimeClassSetLoaderExists && !_chunk4TTPYMVMjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
387
400
  const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
388
401
  const anchorIndex = findClassSetAnchor(loaderEntries);
389
402
  if (anchorIndex === -1) {
@@ -398,11 +411,11 @@ function setupWebpackV5Loaders(options) {
398
411
  }
399
412
 
400
413
  // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
401
- var debug = _chunkG5NLM3ALjs.createDebug.call(void 0, );
402
- var weappTailwindcssPackageDir = _chunkG3G437UEjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
414
+ var debug = _chunkLYGLQCWIjs.createDebug.call(void 0, );
415
+ var weappTailwindcssPackageDir = _chunk7LKMJZD2js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
403
416
  var UnifiedWebpackPluginV5 = class {
404
417
  constructor(options = {}) {
405
- this.options = _chunkG5NLM3ALjs.getCompilerContext.call(void 0, options);
418
+ this.options = _chunkLYGLQCWIjs.getCompilerContext.call(void 0, options);
406
419
  this.appType = this.options.appType;
407
420
  }
408
421
  apply(compiler) {
@@ -415,22 +428,22 @@ var UnifiedWebpackPluginV5 = class {
415
428
  twPatcher: initialTwPatcher,
416
429
  refreshTailwindcssPatcher
417
430
  } = this.options;
418
- const disabledOptions = _chunkG3G437UEjs.resolveDisabledOptions.call(void 0, disabled);
431
+ const disabledOptions = _chunk7LKMJZD2js.resolveDisabledOptions.call(void 0, disabled);
419
432
  const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
420
433
  const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
421
- const isMpxApp = _chunkSQG2MOFQjs.isMpx.call(void 0, this.appType);
434
+ const isMpxApp = _chunk4TTPYMVMjs.isMpx.call(void 0, this.appType);
422
435
  if (shouldRewriteCssImports) {
423
- _chunkSQG2MOFQjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
436
+ _chunk4TTPYMVMjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
424
437
  pkgDir: weappTailwindcssPackageDir,
425
438
  enabled: true,
426
439
  appType: this.appType
427
440
  });
428
- _chunkSQG2MOFQjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
441
+ _chunk4TTPYMVMjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
429
442
  }
430
443
  if (disabledOptions.plugin) {
431
444
  return;
432
445
  }
433
- const patchRecorderState = _chunkNOKJXG3Wjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
446
+ const patchRecorderState = _chunkLYGLQCWIjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
434
447
  source: "runtime",
435
448
  cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
436
449
  });
@@ -442,28 +455,85 @@ var UnifiedWebpackPluginV5 = class {
442
455
  };
443
456
  let runtimeSetPrepared = false;
444
457
  let runtimeSetSignature;
458
+ let runtimeRefreshRequiredForCompilation = false;
459
+ const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
460
+ const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
461
+ let runtimeMetadataPrepared = false;
462
+ const updateRuntimeWatchDependencies = async () => {
463
+ runtimeWatchDependencyFiles.clear();
464
+ runtimeWatchDependencyContexts.clear();
465
+ const tailwindOptions = _chunk5KSBT6GUjs.resolveTailwindcssOptions.call(void 0, runtimeState.twPatcher.options);
466
+ if (_optionalChain([tailwindOptions, 'optionalAccess', _13 => _13.config])) {
467
+ runtimeWatchDependencyFiles.add(tailwindOptions.config);
468
+ }
469
+ for (const entry of _nullishCoalesce(_optionalChain([tailwindOptions, 'optionalAccess', _14 => _14.v4, 'optionalAccess', _15 => _15.cssEntries]), () => ( []))) {
470
+ runtimeWatchDependencyFiles.add(entry);
471
+ }
472
+ for (const source of _nullishCoalesce(_optionalChain([tailwindOptions, 'optionalAccess', _16 => _16.v4, 'optionalAccess', _17 => _17.sources]), () => ( []))) {
473
+ if (_optionalChain([source, 'optionalAccess', _18 => _18.base])) {
474
+ runtimeWatchDependencyContexts.add(source.base);
475
+ }
476
+ }
477
+ if (typeof runtimeState.twPatcher.collectContentTokens !== "function") {
478
+ return;
479
+ }
480
+ try {
481
+ const report = await runtimeState.twPatcher.collectContentTokens();
482
+ for (const entry of _nullishCoalesce(report.entries, () => ( []))) {
483
+ if (entry.file) {
484
+ runtimeWatchDependencyFiles.add(entry.file);
485
+ }
486
+ }
487
+ for (const source of _nullishCoalesce(report.sources, () => ( []))) {
488
+ if (_optionalChain([source, 'optionalAccess', _19 => _19.base])) {
489
+ runtimeWatchDependencyContexts.add(source.base);
490
+ }
491
+ }
492
+ } catch (error) {
493
+ debug("collect runtime watch dependencies failed: %O", error);
494
+ }
495
+ };
496
+ const ensureRuntimeMetadata = async (force = false) => {
497
+ if (runtimeMetadataPrepared && !force) {
498
+ return;
499
+ }
500
+ await updateRuntimeWatchDependencies();
501
+ runtimeMetadataPrepared = true;
502
+ };
503
+ const syncRuntimeRefreshRequirement = () => {
504
+ runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || _chunk4TTPYMVMjs.hasWatchChanges.call(void 0, compiler);
505
+ };
445
506
  const resetRuntimePreparation = () => {
446
507
  runtimeSetPrepared = false;
508
+ runtimeMetadataPrepared = false;
509
+ syncRuntimeRefreshRequirement();
447
510
  };
448
- if (_optionalChain([compiler, 'access', _13 => _13.hooks, 'access', _14 => _14.thisCompilation, 'optionalAccess', _15 => _15.tap])) {
449
- compiler.hooks.thisCompilation.tap(_chunkG5NLM3ALjs.pluginName, resetRuntimePreparation);
450
- } else if (_optionalChain([compiler, 'access', _16 => _16.hooks, 'access', _17 => _17.compilation, 'optionalAccess', _18 => _18.tap])) {
451
- compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, resetRuntimePreparation);
511
+ _optionalChain([compiler, 'access', _20 => _20.hooks, 'access', _21 => _21.invalid, 'optionalAccess', _22 => _22.tap, 'optionalCall', _23 => _23(_chunkLYGLQCWIjs.pluginName, () => {
512
+ runtimeRefreshRequiredForCompilation = true;
513
+ })]);
514
+ _optionalChain([compiler, 'access', _24 => _24.hooks, 'access', _25 => _25.watchRun, 'optionalAccess', _26 => _26.tap, 'optionalCall', _27 => _27(_chunkLYGLQCWIjs.pluginName, syncRuntimeRefreshRequirement)]);
515
+ if (_optionalChain([compiler, 'access', _28 => _28.hooks, 'access', _29 => _29.thisCompilation, 'optionalAccess', _30 => _30.tap])) {
516
+ compiler.hooks.thisCompilation.tap(_chunkLYGLQCWIjs.pluginName, resetRuntimePreparation);
517
+ } else if (_optionalChain([compiler, 'access', _31 => _31.hooks, 'access', _32 => _32.compilation, 'optionalAccess', _33 => _33.tap])) {
518
+ compiler.hooks.compilation.tap(_chunkLYGLQCWIjs.pluginName, resetRuntimePreparation);
452
519
  }
453
520
  async function getClassSetInLoader() {
454
521
  if (runtimeSetPrepared) {
455
522
  return;
456
523
  }
457
- const signature = _chunkG5NLM3ALjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
458
- const forceRefresh = signature !== runtimeSetSignature;
524
+ const signature = _chunk5KSBT6GUjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
525
+ const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
526
+ debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
459
527
  runtimeSetPrepared = true;
460
- await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
528
+ await _chunkLYGLQCWIjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
461
529
  forceRefresh,
462
530
  forceCollect: true,
463
531
  clearCache: forceRefresh,
464
532
  allowEmpty: true
465
533
  });
534
+ await ensureRuntimeMetadata(forceRefresh);
466
535
  runtimeSetSignature = signature;
536
+ runtimeRefreshRequiredForCompilation = false;
467
537
  }
468
538
  onLoad();
469
539
  setupWebpackV5Loaders({
@@ -475,6 +545,12 @@ var UnifiedWebpackPluginV5 = class {
475
545
  runtimeLoaderPath,
476
546
  runtimeCssImportRewriteLoaderPath,
477
547
  getClassSetInLoader,
548
+ getRuntimeWatchDependencies() {
549
+ return {
550
+ files: runtimeWatchDependencyFiles,
551
+ contexts: runtimeWatchDependencyContexts
552
+ };
553
+ },
478
554
  debug
479
555
  });
480
556
  setupWebpackV5ProcessAssetsHook({
@@ -482,6 +558,11 @@ var UnifiedWebpackPluginV5 = class {
482
558
  options: this.options,
483
559
  appType: this.appType,
484
560
  runtimeState,
561
+ getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
562
+ refreshRuntimeMetadata: ensureRuntimeMetadata,
563
+ consumeRuntimeRefreshRequirement() {
564
+ runtimeRefreshRequiredForCompilation = false;
565
+ },
485
566
  debug
486
567
  });
487
568
  }
@@ -4,6 +4,7 @@ async function processCachedTask({
4
4
  cacheKey,
5
5
  hashKey = cacheKey,
6
6
  rawSource,
7
+ hash,
7
8
  readCache,
8
9
  applyResult,
9
10
  transform,
@@ -14,6 +15,7 @@ async function processCachedTask({
14
15
  key: cacheKey,
15
16
  hashKey,
16
17
  rawSource,
18
+ hash,
17
19
  resolveCache: readCache,
18
20
  async onCacheHit(value) {
19
21
  cacheHit = true;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkOV7FX6XRjs = require('./chunk-OV7FX6XR.js');
3
+ var _chunkCRDOWYG4js = require('./chunk-CRDOWYG4.js');
4
4
 
5
5
  // src/utils/disabled.ts
6
6
  function resolveDisabledOptions(disabled) {
@@ -19,7 +19,7 @@ function resolveDisabledOptions(disabled) {
19
19
  // src/utils/resolve-package.ts
20
20
  var _module = require('module');
21
21
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
22
- var require2 = _module.createRequire.call(void 0, _chunkOV7FX6XRjs.importMetaUrl);
22
+ var require2 = _module.createRequire.call(void 0, _chunkCRDOWYG4js.importMetaUrl);
23
23
  function resolvePackageDir(name) {
24
24
  const pkgPath = require2.resolve(`${name}/package.json`);
25
25
  return _path2.default.dirname(pkgPath);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.12.0__@swc+core@1.15.18_@swc+_6ff00797e53d4229106048f969f94f55/node_modules/tsup/assets/cjs_shims.js
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.12.0__@swc+core@1.15.21_@swc+_5ebcbf8346fe43415c2ec13051ebcdfe/node_modules/tsup/assets/cjs_shims.js
2
2
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
3
3
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
4
4
 
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.12.0__@swc+core@1.15.18_@swc+_6ff00797e53d4229106048f969f94f55/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.12.0__@swc+core@1.15.21_@swc+_5ebcbf8346fe43415c2ec13051ebcdfe/node_modules/tsup/assets/esm_shims.js
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);