weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.7

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 (171) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  4. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  5. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  6. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
  8. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  9. package/dist/bundlers/shared/generator-css/directives.d.ts +11 -0
  10. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  11. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  12. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  13. package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
  14. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  15. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +12 -22
  17. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  18. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  19. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  20. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  21. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  22. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  23. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  24. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  25. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  26. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  27. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  28. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  29. package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
  30. package/dist/bundlers/vite/index.d.ts +1 -1
  31. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  32. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  33. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  34. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  35. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
  37. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -1
  38. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
  39. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
  40. package/dist/cache-DPN5yKSX.js +497 -0
  41. package/dist/cache-nq0_XJoS.mjs +429 -0
  42. package/dist/cli/context.d.ts +0 -3
  43. package/dist/cli/helpers.d.ts +1 -2
  44. package/dist/cli/mount-options.d.ts +2 -0
  45. package/dist/cli/types.d.ts +0 -2
  46. package/dist/cli.js +108 -598
  47. package/dist/cli.mjs +119 -608
  48. package/dist/constants.d.ts +1 -2
  49. package/dist/context/tailwindcss.d.ts +1 -1
  50. package/dist/core.js +13 -20
  51. package/dist/core.mjs +8 -14
  52. package/dist/css-macro/postcss.js +1 -1
  53. package/dist/css-macro/postcss.mjs +1 -1
  54. package/dist/css-macro.d.ts +1 -0
  55. package/dist/css-macro.js +2 -2
  56. package/dist/css-macro.mjs +2 -2
  57. package/dist/defaults.d.ts +15 -1
  58. package/dist/defaults.js +33 -14
  59. package/dist/defaults.mjs +30 -15
  60. package/dist/generator/index.d.ts +1 -1
  61. package/dist/generator/options.d.ts +3 -4
  62. package/dist/{generator-Y-Ikv4Fu.mjs → generator-CzfdCZyd.mjs} +277 -23
  63. package/dist/{generator-mmhXzZnv.js → generator-TOp4uz7c.js} +281 -27
  64. package/dist/{generator-css-Bwy_Uz89.mjs → generator-css-B938WI9a.mjs} +694 -506
  65. package/dist/{generator-css-CRLrHW4F.js → generator-css-Dnpl-IY2.js} +699 -505
  66. package/dist/generator.js +1 -1
  67. package/dist/generator.mjs +1 -1
  68. package/dist/gulp.js +29 -28
  69. package/dist/gulp.mjs +25 -24
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.js +6 -6
  72. package/dist/index.mjs +5 -5
  73. package/dist/js/index.d.ts +1 -0
  74. package/dist/js/literal-transform.d.ts +2 -0
  75. package/dist/logger-BRy6XPQ2.js +1 -0
  76. package/dist/logger-Bub1jggA.mjs +2 -0
  77. package/dist/postcss/config-directive.d.ts +1 -0
  78. package/dist/postcss/context.d.ts +9 -0
  79. package/dist/postcss/source-files.d.ts +8 -0
  80. package/dist/postcss/tailwind-version.d.ts +3 -0
  81. package/dist/postcss-BtAP6sQO.mjs +288 -0
  82. package/dist/postcss-WsXlC7A-.js +298 -0
  83. package/dist/postcss.d.ts +2 -2
  84. package/dist/postcss.js +3 -276
  85. package/dist/postcss.mjs +1 -269
  86. package/dist/{recorder-GdTJ3QqX.js → precheck-Dka94ArV.js} +141 -283
  87. package/dist/{recorder-XdFvVASS.mjs → precheck-DlrmwCc-.mjs} +106 -247
  88. package/dist/presets.js +6 -4
  89. package/dist/presets.mjs +4 -2
  90. package/dist/reset.d.ts +1 -0
  91. package/dist/{css-imports-BbrbluP9.js → run-tasks-B50A3pxt.js} +6 -55
  92. package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DdNi-hkk.mjs} +5 -42
  93. package/dist/runtime-patch-pGdCqAEu.mjs +71 -0
  94. package/dist/runtime-patch-qwuisukL.js +85 -0
  95. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  96. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  97. package/dist/tailwindcss/patcher.d.ts +1 -2
  98. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  99. package/dist/tailwindcss/runtime.d.ts +2 -3
  100. package/dist/tailwindcss/targets.d.ts +1 -5
  101. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  102. package/dist/tailwindcss/v4/patcher.d.ts +2 -1
  103. package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
  104. package/dist/tailwindcss/version.d.ts +4 -0
  105. package/dist/{logger-BoVx1Dbt.mjs → tailwindcss-BIJ185GB.mjs} +25 -434
  106. package/dist/{logger-BZ45DZJT.js → tailwindcss-T1U5T-iF.js} +30 -468
  107. package/dist/typedoc.export.d.ts +0 -2
  108. package/dist/types/index.d.ts +2 -9
  109. package/dist/types/shared.d.ts +3 -0
  110. package/dist/types/user-defined-options/general.d.ts +0 -2
  111. package/dist/types/user-defined-options/important.d.ts +3 -3
  112. package/dist/uni-app-x/vite.d.ts +1 -1
  113. package/dist/utils/disabled.d.ts +2 -3
  114. package/dist/{vite-BDywuCjn.mjs → vite-BXChkciE.mjs} +669 -481
  115. package/dist/{vite-DgRh_GXn.js → vite-D0CoRblu.js} +707 -519
  116. package/dist/vite.d.ts +1 -2
  117. package/dist/vite.js +3 -4
  118. package/dist/vite.mjs +2 -2
  119. package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
  120. package/dist/{webpack-CiHqVZTg.mjs → webpack-BNdGm9KL.mjs} +224 -38
  121. package/dist/{webpack-CAJR4hhP.js → webpack-D-sUCY0u.js} +250 -69
  122. package/dist/webpack.js +1 -1
  123. package/dist/webpack.mjs +1 -1
  124. package/package.json +23 -35
  125. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  126. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  127. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  128. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  129. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  130. package/dist/cli/config.d.ts +0 -5
  131. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  132. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  133. package/dist/cli/patch-options.d.ts +0 -6
  134. package/dist/cli/tokens.d.ts +0 -4
  135. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  136. package/dist/cli/workspace/patch-package.d.ts +0 -3
  137. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  138. package/dist/cli/workspace/types.d.ts +0 -11
  139. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  140. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  141. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  142. package/dist/cli/workspace.d.ts +0 -2
  143. package/dist/experimental/index.d.ts +0 -2
  144. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  145. package/dist/experimental/oxc/index.d.ts +0 -2
  146. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  147. package/dist/experimental/shared/cache.d.ts +0 -3
  148. package/dist/experimental/shared/transform.d.ts +0 -3
  149. package/dist/experimental/shared.d.ts +0 -8
  150. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  151. package/dist/experimental/swc/index.d.ts +0 -2
  152. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  153. package/dist/js/syntax.d.ts +0 -10
  154. package/dist/loader-anchors-1MumTAtA.mjs +0 -205
  155. package/dist/loader-anchors-TrFvT6g1.js +0 -273
  156. package/dist/patcher-options-6gJN2EXy.js +0 -115
  157. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  158. package/dist/tailwindcss/recorder.d.ts +0 -13
  159. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  160. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  161. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  162. package/dist/tailwindcss/targets/types.d.ts +0 -35
  163. package/dist/types/disabled-options.d.ts +0 -4
  164. package/dist/webpack4.d.ts +0 -4
  165. package/dist/webpack4.js +0 -387
  166. package/dist/webpack4.mjs +0 -379
  167. package/scripts/postinstall.mjs +0 -59
  168. /package/dist/{constants-p1dyh1x1.js → constants-BoB_6lFw.js} +0 -0
  169. /package/dist/{constants-B-_T5UnW.mjs → constants-E_loJC49.mjs} +0 -0
  170. /package/dist/{utils-7DUGTFED.mjs → utils-BJjKRQgf.mjs} +0 -0
  171. /package/dist/{utils-DmC9_In3.js → utils-VZvGusYs.js} +0 -0
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './bundlers/vite/index';
2
- export { UnifiedViteWeappTailwindcssPlugin as WeappTailwindcss } from './bundlers/vite/index';
3
- export { UnifiedViteWeappTailwindcssPlugin as weappTailwindcss } from './bundlers/vite/index';
2
+ export { WeappTailwindcss as weappTailwindcss } from './bundlers/vite/index';
4
3
  export type { UserDefinedOptions } from './types';
package/dist/vite.js CHANGED
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_vite = require("./vite-DgRh_GXn.js");
3
- exports.UnifiedViteWeappTailwindcssPlugin = require_vite.UnifiedViteWeappTailwindcssPlugin;
4
- exports.WeappTailwindcss = require_vite.UnifiedViteWeappTailwindcssPlugin;
5
- exports.weappTailwindcss = require_vite.UnifiedViteWeappTailwindcssPlugin;
2
+ const require_vite = require("./vite-D0CoRblu.js");
3
+ exports.WeappTailwindcss = require_vite.WeappTailwindcss;
4
+ exports.weappTailwindcss = require_vite.WeappTailwindcss;
package/dist/vite.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as UnifiedViteWeappTailwindcssPlugin } from "./vite-BDywuCjn.mjs";
2
- export { UnifiedViteWeappTailwindcssPlugin, UnifiedViteWeappTailwindcssPlugin as WeappTailwindcss, UnifiedViteWeappTailwindcssPlugin as weappTailwindcss };
1
+ import { t as WeappTailwindcss } from "./vite-BXChkciE.mjs";
2
+ export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
@@ -47,7 +47,7 @@ function joinPosixPath(base, subpath) {
47
47
  return `${base}/${subpath}`;
48
48
  }
49
49
  function applyCssImportRewrite(source, options) {
50
- const rewriteOptions = options?.rewriteCssImports;
50
+ const rewriteOptions = options?.tailwindcssImportRewrite;
51
51
  const pkgDir = rewriteOptions?.pkgDir;
52
52
  if (!pkgDir) return source;
53
53
  return rewriteTailwindcssImportsInCode(source, (0, _weapp_tailwindcss_shared.ensurePosix)(pkgDir), {
@@ -1,18 +1,183 @@
1
- import { r as resolveTailwindcssOptions } from "./patcher-options-DQfR5xxT.mjs";
2
- import { g as ensureRuntimeClassSet, n as shouldSkipJsTransform, p as pluginName, r as getCompilerContext, t as setupPatchRecorder, v as createDebug } from "./recorder-XdFvVASS.mjs";
3
- import { r as getGroupedEntries } from "./utils-7DUGTFED.mjs";
4
- import { d as getRuntimeClassSetSignature } from "./logger-BoVx1Dbt.mjs";
5
- import { i as processCachedTask, t as generateCssByGenerator } from "./generator-css-Bwy_Uz89.mjs";
6
- import { a as resolveDisabledOptions, c as toAbsoluteOutputPath, i as resolvePackageDir, r as pushConcurrentTaskFactories, s as resolveOutputSpecifier } from "./css-imports-CSdPq_Sc.mjs";
7
- import { a as hasLoaderEntry, c as applyTailwindcssCssImportRewrite, d as isMpx, f as patchMpxLoaderResolve, i as getCacheKey, l as ensureMpxTailwindcssAliases, n as __dirname, o as hasWatchChanges, p as setupMpxTailwindcssRedirect, r as createAssetHashByChunkMap, s as isCssLikeModuleResource, t as createLoaderAnchorFinders, u as injectMpxCssRewritePreRules } from "./loader-anchors-1MumTAtA.mjs";
1
+ import { c as resolveTailwindcssOptions, n as getRuntimeClassSetSignature } from "./cache-nq0_XJoS.mjs";
2
+ import { n as createDebug } from "./runtime-patch-pGdCqAEu.mjs";
3
+ import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform } from "./precheck-DlrmwCc-.mjs";
4
+ import { r as getGroupedEntries } from "./utils-BJjKRQgf.mjs";
5
+ import { a as processCachedTask, t as generateCssByGenerator } from "./generator-css-B938WI9a.mjs";
6
+ import { a as resolveOutputSpecifier, n as resolvePackageDir, o as toAbsoluteOutputPath, r as resolvePluginDisabledState, t as pushConcurrentTaskFactories } from "./run-tasks-DdNi-hkk.mjs";
7
+ import Module, { createRequire } from "node:module";
8
8
  import path from "node:path";
9
9
  import process from "node:process";
10
10
  import fs from "node:fs";
11
- //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
12
- function resolveWebpackStaleClassNameFallback(option, _compiler) {
13
- if (typeof option === "boolean") return option;
11
+ import { fileURLToPath } from "node:url";
12
+ //#region src/shared/tailwindcss-css-redirect.ts
13
+ const moduleWithMutableResolve = Module;
14
+ const patched = /* @__PURE__ */ new WeakSet();
15
+ function installTailwindcssCssRedirect(pkgDir) {
16
+ const target = path.join(pkgDir, "index.css");
17
+ const original = moduleWithMutableResolve._resolveFilename;
18
+ if (patched.has(original)) return;
19
+ const replacements = new Set(["tailwindcss", "tailwindcss$"]);
20
+ const resolveTailwindcssCss = (request, parent, isMain, options) => {
21
+ if (replacements.has(request)) return target;
22
+ if (request.startsWith("tailwindcss/")) return path.join(pkgDir, request.slice(12));
23
+ return original(request, parent, isMain, options);
24
+ };
25
+ moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
26
+ patched.add(moduleWithMutableResolve._resolveFilename);
27
+ }
28
+ //#endregion
29
+ //#region src/shared/mpx.ts
30
+ const require = createRequire(import.meta.url);
31
+ const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
32
+ function isMpxStyleResourceQuery(query) {
33
+ if (typeof query !== "string") return false;
34
+ return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
35
+ }
36
+ function isMpx(appType) {
37
+ return appType === "mpx";
38
+ }
39
+ function getTailwindcssCssEntry(pkgDir) {
40
+ return path.join(pkgDir, "index.css");
41
+ }
42
+ function isMpxWebpackPluginRequest(request) {
43
+ return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
44
+ }
45
+ function addMpxWebpackPluginAlias(alias, pkgDir) {
46
+ if (Array.isArray(alias)) alias.push({
47
+ name: /^@mpxjs\/webpack-plugin\//,
48
+ alias: pkgDir
49
+ });
50
+ else {
51
+ alias["@mpxjs/webpack-plugin"] = pkgDir;
52
+ alias["@mpxjs/webpack-plugin$"] = pkgDir;
53
+ }
54
+ }
55
+ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
56
+ compiler.options.resolveLoader = compiler.options.resolveLoader || {};
57
+ const alias = compiler.options.resolveLoader.alias ?? {};
58
+ compiler.options.resolveLoader.alias = alias;
59
+ addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
60
+ }
61
+ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
62
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
63
+ const mpxWebpackPluginDir = path.dirname(require.resolve("@mpxjs/webpack-plugin/package.json"));
64
+ compiler.options = compiler.options || {};
65
+ compiler.options.resolve = compiler.options.resolve || {};
66
+ ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
67
+ const alias = compiler.options.resolve.alias ?? {};
68
+ compiler.options.resolve.alias = alias;
69
+ if (Array.isArray(alias)) alias.push({
70
+ name: /^@mpxjs\/webpack-plugin\//,
71
+ alias: mpxWebpackPluginDir
72
+ }, {
73
+ name: "tailwindcss",
74
+ alias: tailwindcssCssEntry
75
+ }, {
76
+ name: "tailwindcss$",
77
+ alias: tailwindcssCssEntry
78
+ });
79
+ else {
80
+ alias["@mpxjs/webpack-plugin"] = mpxWebpackPluginDir;
81
+ alias["@mpxjs/webpack-plugin$"] = mpxWebpackPluginDir;
82
+ alias.tailwindcss = tailwindcssCssEntry;
83
+ alias.tailwindcss$ = tailwindcssCssEntry;
84
+ }
85
+ return tailwindcssCssEntry;
86
+ }
87
+ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
88
+ if (!enabled || typeof loaderContext.resolve !== "function") return;
89
+ const originalResolve = loaderContext.resolve;
90
+ if (originalResolve.__weappTwPatched) return;
91
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
92
+ const wrappedResolve = function(context, request, callback) {
93
+ if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
94
+ if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
95
+ if (isMpxWebpackPluginRequest(request)) return originalResolve.call(this, process.cwd(), request, callback);
96
+ return originalResolve.call(this, context, request, callback);
97
+ };
98
+ wrappedResolve.__weappTwPatched = true;
99
+ loaderContext.resolve = wrappedResolve;
100
+ }
101
+ function setupMpxTailwindcssRedirect(pkgDir, enabled) {
102
+ if (enabled) installTailwindcssCssRedirect(pkgDir);
103
+ }
104
+ const CSS_EXT_RE = /\.css$/i;
105
+ function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
106
+ var _compiler$options;
107
+ if (!loader) return;
108
+ const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
109
+ moduleOptions.rules = moduleOptions.rules || [];
110
+ const createRule = (match) => ({
111
+ ...match,
112
+ enforce: "pre",
113
+ use: [{
114
+ loader,
115
+ options: loaderOptions
116
+ }]
117
+ });
118
+ moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
119
+ test: CSS_EXT_RE,
120
+ resourceQuery: (query) => !isMpxStyleResourceQuery(query)
121
+ }));
122
+ }
123
+ //#endregion
124
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
125
+ const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
126
+ function getCacheKey(filename) {
127
+ return filename;
128
+ }
129
+ function stripResourceQuery(resource) {
130
+ if (typeof resource !== "string") return resource;
131
+ const queryIndex = resource.indexOf("?");
132
+ if (queryIndex !== -1) return resource.slice(0, queryIndex);
133
+ const hashIndex = resource.indexOf("#");
134
+ if (hashIndex !== -1) return resource.slice(0, hashIndex);
135
+ return resource;
136
+ }
137
+ function isCssLikeModuleResource(resource, cssMatcher, appType) {
138
+ if (typeof resource !== "string") return false;
139
+ const normalizedResource = stripResourceQuery(resource);
140
+ if (normalizedResource && cssMatcher(normalizedResource)) return true;
141
+ if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
14
142
  return false;
15
143
  }
144
+ function hasLoaderEntry(entries, target) {
145
+ if (!target) return false;
146
+ return entries.some((entry) => entry.loader?.includes?.(target));
147
+ }
148
+ function toChunkFiles(files) {
149
+ if (!files) return [];
150
+ if (Array.isArray(files)) return files;
151
+ return [...files];
152
+ }
153
+ function createAssetHashByChunkMap(chunks) {
154
+ const partsByFile = /* @__PURE__ */ new Map();
155
+ for (const chunk of chunks) {
156
+ const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
157
+ if (!hash) continue;
158
+ const chunkId = String(chunk.id ?? chunk.name ?? "");
159
+ for (const file of toChunkFiles(chunk.files)) {
160
+ if (!file) continue;
161
+ let parts = partsByFile.get(file);
162
+ if (!parts) {
163
+ parts = [];
164
+ partsByFile.set(file, parts);
165
+ }
166
+ parts.push(`${chunkId}:${hash}`);
167
+ }
168
+ }
169
+ const hashByFile = /* @__PURE__ */ new Map();
170
+ for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
171
+ return hashByFile;
172
+ }
173
+ function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
174
+ return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
175
+ }
176
+ function hasWatchChanges(compiler) {
177
+ return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
178
+ }
179
+ //#endregion
180
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
16
181
  function setupWebpackV5ProcessAssetsHook(options) {
17
182
  const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, consumeRuntimeRefreshRequirement, debug } = options;
18
183
  const { Compilation, sources } = compiler.webpack;
@@ -26,7 +191,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
26
191
  }, async (assets) => {
27
192
  compilerOptions.onStart();
28
193
  debug("start");
29
- await runtimeState.patchPromise;
194
+ await runtimeState.readyPromise;
30
195
  for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
31
196
  const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
32
197
  const entries = Object.entries(assets);
@@ -95,7 +260,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
95
260
  cssUserHandlerOptionsCache.set(cacheKey, created);
96
261
  return created;
97
262
  };
98
- const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
99
263
  const forceRuntimeRefresh = getRuntimeRefreshRequirement();
100
264
  debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
101
265
  const runtimeSet = await ensureRuntimeClassSet(runtimeState, {
@@ -106,6 +270,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
106
270
  });
107
271
  await refreshRuntimeMetadata(forceRuntimeRefresh);
108
272
  consumeRuntimeRefreshRequirement();
273
+ const runtimeSetHash = compilerOptions.cache.computeHash([getRuntimeClassSetSignature(runtimeState.twPatcher), [...runtimeSet].sort().join("\n")].join("\n\n"));
109
274
  const defaultTemplateHandlerOptions = { runtimeSet };
110
275
  debug("get runtimeSet, class count: %d", runtimeSet.size);
111
276
  const tasks = [];
@@ -161,7 +326,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
161
326
  const currentSourceValue = compilation.getAsset(file)?.source.source();
162
327
  const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
163
328
  const handlerOptions = {
164
- staleClassNameFallback,
165
329
  tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
166
330
  filename: absoluteFile,
167
331
  moduleGraph: moduleGraphOptions,
@@ -182,13 +346,13 @@ function setupWebpackV5ProcessAssetsHook(options) {
182
346
  const [file, originalSource] = element;
183
347
  const rawSource = originalSource.source().toString();
184
348
  const cacheKey = file;
185
- const chunkHash = assetHashByChunk.get(file);
349
+ const runtimeAwareHash = createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash);
186
350
  tasks.push(processCachedTask({
187
351
  cache: compilerOptions.cache,
188
352
  cacheKey,
189
353
  hashKey: `${file}:asset`,
190
354
  rawSource,
191
- hash: chunkHash,
355
+ hash: runtimeAwareHash,
192
356
  applyResult(source) {
193
357
  compilation.updateAsset(file, source);
194
358
  },
@@ -196,7 +360,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
196
360
  debug("css cache hit: %s", file);
197
361
  },
198
362
  transform: async () => {
199
- await runtimeState.patchPromise;
363
+ await runtimeState.readyPromise;
200
364
  const cssHandlerOptions = getCssHandlerOptions(file);
201
365
  const generated = await generateCssByGenerator({
202
366
  opts: compilerOptions,
@@ -226,13 +390,46 @@ function setupWebpackV5ProcessAssetsHook(options) {
226
390
  });
227
391
  }
228
392
  //#endregion
393
+ //#region ../../node_modules/.pnpm/tsdown@0.22.0_tsx@4.21.0_typescript@6.0.3_unrun@0.2.37_synckit@0.11.12__vue-tsc@3.2.8_typescript@6.0.3_/node_modules/tsdown/esm-shims.js
394
+ const getFilename = () => fileURLToPath(import.meta.url);
395
+ const getDirname = () => path.dirname(getFilename());
396
+ const __dirname = /* @__PURE__ */ getDirname();
397
+ //#endregion
398
+ //#region src/bundlers/webpack/shared/loader-anchors.ts
399
+ const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
400
+ const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
401
+ const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
402
+ function createFinder(targets) {
403
+ return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
404
+ }
405
+ function createPrioritizedFinder(targets) {
406
+ return (entries) => {
407
+ for (const target of targets) {
408
+ const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
409
+ if (idx !== -1) return idx;
410
+ }
411
+ return -1;
412
+ };
413
+ }
414
+ function createLoaderAnchorFinders(appType) {
415
+ if (isMpx(appType)) return {
416
+ findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
417
+ findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
418
+ };
419
+ const fallbackFinder = createFinder(["postcss-loader"]);
420
+ return {
421
+ findRewriteAnchor: fallbackFinder,
422
+ findClassSetAnchor: fallbackFinder
423
+ };
424
+ }
425
+ //#endregion
229
426
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
230
427
  function setupWebpackV5Loaders(options) {
231
- const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
428
+ const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
232
429
  const isMpxApp = isMpx(appType);
233
430
  if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
234
431
  const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
235
- const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? runtimeCssImportRewriteLoaderPath ?? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
432
+ const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
236
433
  const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
237
434
  const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
238
435
  const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
@@ -244,7 +441,7 @@ function setupWebpackV5Loaders(options) {
244
441
  getWatchDependencies: getRuntimeWatchDependencies
245
442
  };
246
443
  const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
247
- const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { rewriteCssImports: runtimeLoaderRewriteOptions } : void 0;
444
+ const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewrite: runtimeLoaderRewriteOptions } : void 0;
248
445
  if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
249
446
  const createRuntimeClassSetLoaderEntry = () => ({
250
447
  loader: runtimeClassSetLoader,
@@ -320,33 +517,23 @@ const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
320
517
  */
321
518
  var UnifiedWebpackPluginV5 = class {
322
519
  constructor(options = {}) {
520
+ _defineProperty(this, "options", void 0);
521
+ _defineProperty(this, "appType", void 0);
323
522
  this.options = getCompilerContext(options);
324
523
  this.appType = this.options.appType;
325
524
  }
326
525
  apply(compiler) {
327
526
  compiler.options = compiler.options || {};
328
- const { disabled, onLoad, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
329
- const disabledOptions = resolveDisabledOptions(disabled);
330
- const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
527
+ const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
528
+ const disabledOptions = resolvePluginDisabledState(disabled);
529
+ const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4;
331
530
  const isMpxApp = isMpx(this.appType);
332
- if (shouldRewriteCssImports) {
333
- applyTailwindcssCssImportRewrite(compiler, {
334
- pkgDir: weappTailwindcssPackageDir,
335
- enabled: true,
336
- appType: this.appType
337
- });
338
- setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
339
- }
531
+ if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
340
532
  if (disabledOptions.plugin) return;
341
- const patchRecorderState = setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
342
- source: "runtime",
343
- cwd: this.options.tailwindcssBasedir ?? process.cwd()
344
- });
345
533
  const runtimeState = {
346
534
  twPatcher: initialTwPatcher,
347
- patchPromise: patchRecorderState.patchPromise,
348
- refreshTailwindcssPatcher,
349
- onPatchCompleted: patchRecorderState.onPatchCompleted
535
+ readyPromise: createTailwindRuntimeReadyPromise(initialTwPatcher),
536
+ refreshTailwindcssPatcher
350
537
  };
351
538
  let runtimeSetPrepared = false;
352
539
  let runtimeSetSignature;
@@ -413,7 +600,6 @@ var UnifiedWebpackPluginV5 = class {
413
600
  weappTailwindcssPackageDir,
414
601
  shouldRewriteCssImports,
415
602
  runtimeLoaderPath,
416
- runtimeCssImportRewriteLoaderPath,
417
603
  getClassSetInLoader,
418
604
  getRuntimeWatchDependencies() {
419
605
  return {