weapp-tailwindcss 5.1.15 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/README.en.md +6 -0
  2. package/README.md +6 -0
  3. package/bin/{weapp-tailwindcss.js → weapp-tailwindcss.cjs} +1 -1
  4. package/dist/bundlers/framework-selector.d.ts +2 -2
  5. package/dist/bundlers/gulp/asset-emission-plan.d.ts +10 -0
  6. package/dist/bundlers/gulp/frameworks/native/index.d.ts +10 -3
  7. package/dist/bundlers/gulp/index.d.ts +10 -3
  8. package/dist/bundlers/gulp/module-graph.d.ts +1 -1
  9. package/dist/bundlers/gulp/runtime-snapshot.d.ts +4 -2
  10. package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
  11. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +45 -0
  12. package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +9 -2
  13. package/dist/bundlers/rspack/index.d.ts +2 -2
  14. package/dist/bundlers/shared/cache.d.ts +1 -1
  15. package/dist/bundlers/shared/css-imports.d.ts +1 -1
  16. package/dist/bundlers/shared/css-source-trace.d.ts +2 -2
  17. package/dist/bundlers/shared/framework-postcss.d.ts +21 -0
  18. package/dist/bundlers/shared/generator-css/candidates.d.ts +2 -0
  19. package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +19 -0
  20. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
  21. package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
  22. package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
  23. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
  24. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +5 -3
  25. package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +58 -0
  26. package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +3 -0
  27. package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +3 -0
  28. package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +3 -0
  29. package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +3 -0
  30. package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
  31. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
  32. package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
  33. package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +32 -0
  34. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +1 -1
  35. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +13 -5
  36. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +1 -1
  37. package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
  38. package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +5 -0
  39. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
  40. package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
  41. package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
  42. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +4 -4
  43. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +7 -9
  44. package/dist/bundlers/shared/generator-css/types.d.ts +12 -3
  45. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
  46. package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
  47. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
  48. package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
  49. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
  50. package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
  51. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
  52. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -1
  53. package/dist/bundlers/shared/generator-css.d.ts +9 -10
  54. package/dist/bundlers/shared/runtime-class-set/entries.d.ts +4 -0
  55. package/dist/bundlers/shared/runtime-class-set/escaped-candidates.d.ts +9 -0
  56. package/dist/bundlers/shared/runtime-class-set.d.ts +30 -0
  57. package/dist/bundlers/shared/runtime-entry-type.d.ts +8 -0
  58. package/dist/bundlers/shared/runtime-signatures.d.ts +8 -0
  59. package/dist/bundlers/shared/source-candidate-scan-signature.d.ts +13 -0
  60. package/dist/bundlers/shared/source-candidates/collector.d.ts +8 -0
  61. package/dist/bundlers/shared/source-candidates/scan-root.d.ts +10 -0
  62. package/dist/bundlers/{vite → shared}/source-candidates/script.d.ts +1 -1
  63. package/dist/bundlers/shared/source-candidates/store.d.ts +2 -0
  64. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +69 -0
  65. package/dist/bundlers/shared/source-candidates.d.ts +4 -0
  66. package/dist/bundlers/shared/source-scan/css-entries.d.ts +18 -0
  67. package/dist/bundlers/shared/source-scan.d.ts +16 -0
  68. package/dist/bundlers/shared/static-config-content.d.ts +5 -0
  69. package/dist/bundlers/shared/v4-generation-core.d.ts +9 -1
  70. package/dist/bundlers/vite/bundle-entries.d.ts +1 -1
  71. package/dist/bundlers/vite/bundle-state.d.ts +11 -38
  72. package/dist/bundlers/vite/css-asset-identity.d.ts +11 -0
  73. package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
  74. package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
  75. package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
  76. package/dist/bundlers/vite/css-memory.d.ts +1 -2
  77. package/dist/bundlers/vite/frameworks/generic/index.d.ts +2 -2
  78. package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -2
  79. package/dist/bundlers/vite/frameworks/uni-app/index.d.ts +3 -3
  80. package/dist/bundlers/vite/frameworks/uni-app-x/index.d.ts +3 -3
  81. package/dist/bundlers/vite/frameworks/weapp-vite/index.d.ts +2 -2
  82. package/dist/bundlers/vite/generate-bundle/asset-emission-plan.d.ts +8 -0
  83. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +4 -4
  84. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  85. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
  86. package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +34 -0
  87. package/dist/bundlers/vite/generate-bundle/css-composition-plan.d.ts +58 -0
  88. package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +1 -1
  89. package/dist/bundlers/vite/generate-bundle/css-entry-processing.d.ts +1 -0
  90. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
  91. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +21 -2
  92. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -1
  93. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -1
  94. package/dist/bundlers/vite/generate-bundle/css-source-plan.d.ts +19 -0
  95. package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +61 -0
  96. package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +23 -0
  97. package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +42 -0
  98. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +3 -2
  99. package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
  100. package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
  101. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
  102. package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +2 -2
  103. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +1 -1
  104. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +2 -1
  105. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +2 -2
  106. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +6 -5
  107. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +1 -1
  108. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +1 -1
  109. package/dist/bundlers/vite/generate-bundle/remembered-css-plan.d.ts +35 -0
  110. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +5 -6
  111. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +2 -2
  112. package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +20 -0
  113. package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +54 -0
  114. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +1 -1
  115. package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +3 -3
  116. package/dist/bundlers/vite/generate-bundle/runtime.d.ts +6 -0
  117. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +2 -2
  118. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -2
  119. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +1 -8
  120. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +3 -3
  121. package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +5 -0
  122. package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +2 -2
  123. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +14 -1
  124. package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +1 -1
  125. package/dist/bundlers/vite/generate-bundle/transform-scheduling.d.ts +1 -0
  126. package/dist/bundlers/vite/generate-bundle/types.d.ts +8 -7
  127. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +3 -2
  128. package/dist/bundlers/vite/generate-bundle/validate-runtime-candidates.d.ts +22 -0
  129. package/dist/bundlers/vite/generate-bundle.d.ts +7 -7
  130. package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +1 -4
  131. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -3
  132. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +2 -30
  133. package/dist/bundlers/vite/index.d.ts +3 -3
  134. package/dist/bundlers/vite/js-precheck.d.ts +1 -1
  135. package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +13 -0
  136. package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
  137. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
  138. package/dist/bundlers/vite/processed-css-assets/empty-at-rule.d.ts +1 -0
  139. package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
  140. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
  141. package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
  142. package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
  143. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -1
  144. package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -1
  145. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +1 -2
  146. package/dist/bundlers/vite/runtime-candidate-entry.d.ts +9 -0
  147. package/dist/bundlers/vite/runtime-class-set.d.ts +4 -4
  148. package/dist/bundlers/vite/serve-css-generation.d.ts +2 -0
  149. package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
  150. package/dist/bundlers/vite/serve-root-import-shell.d.ts +1 -1
  151. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
  152. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -8
  153. package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +45 -0
  154. package/dist/bundlers/vite/shared/framework-post-plugin.d.ts +2 -0
  155. package/dist/bundlers/vite/shared/framework-processed-css-registry.d.ts +22 -0
  156. package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +1 -0
  157. package/dist/bundlers/vite/shared/framework-source-candidates-plugin.d.ts +2 -0
  158. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +38 -0
  159. package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -4
  160. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +2 -13
  161. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +1 -10
  162. package/dist/bundlers/vite/source-candidates.d.ts +1 -68
  163. package/dist/bundlers/vite/source-output-relations.d.ts +24 -0
  164. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -18
  165. package/dist/bundlers/vite/source-scan.d.ts +2 -16
  166. package/dist/bundlers/vite/static-config-content.d.ts +1 -5
  167. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  168. package/dist/bundlers/vite/web-css-compat.d.ts +1 -1
  169. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/asset-emission-plan.d.ts +18 -0
  170. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +2 -2
  171. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
  172. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
  173. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
  174. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -41
  175. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
  176. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +4 -10
  177. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
  178. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
  179. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
  180. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
  181. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
  182. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
  183. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
  184. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
  185. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
  186. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -219
  187. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
  188. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +3 -3
  189. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +3 -3
  190. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +2 -2
  191. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -4
  192. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -2
  193. package/dist/bundlers/webpack/frameworks/generic/index.d.ts +2 -2
  194. package/dist/bundlers/webpack/frameworks/index.d.ts +7 -7
  195. package/dist/bundlers/webpack/frameworks/mpx/index.d.ts +2 -2
  196. package/dist/bundlers/webpack/frameworks/taro/index.d.ts +2 -2
  197. package/dist/bundlers/webpack/frameworks/uni-app/index.d.ts +2 -2
  198. package/dist/bundlers/webpack/frameworks/weapp-vite/index.d.ts +2 -2
  199. package/dist/bundlers/webpack/index.d.ts +1 -1
  200. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +7 -2
  201. package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +1 -1
  202. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
  203. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +1 -1
  204. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
  205. package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
  206. package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
  207. package/dist/cli/context.d.ts +2 -2
  208. package/dist/cli/doctor.d.ts +1 -1
  209. package/dist/cli/helpers/options.d.ts +3 -3
  210. package/dist/cli/helpers.d.ts +1 -1
  211. package/dist/cli.cjs +37012 -0
  212. package/dist/cli.js +145 -176
  213. package/dist/compiler/artifact.d.ts +14 -0
  214. package/dist/compiler/candidate-index.d.ts +10 -0
  215. package/dist/compiler/compilation-change-coordinator.d.ts +28 -0
  216. package/dist/compiler/compilation-dependency-state.d.ts +16 -0
  217. package/dist/compiler/compilation-scope-graph.d.ts +31 -0
  218. package/dist/compiler/compilation-session-pool.d.ts +54 -0
  219. package/dist/compiler/compiler-owner-state.d.ts +3 -0
  220. package/dist/compiler/composition.d.ts +8 -0
  221. package/dist/compiler/emission-plan.d.ts +26 -0
  222. package/dist/compiler/index.d.ts +23 -0
  223. package/dist/compiler/invalidation.d.ts +3 -0
  224. package/dist/compiler/mode.d.ts +3 -0
  225. package/dist/compiler/owner-lifecycle.d.ts +1 -0
  226. package/dist/compiler/platform-adapter.d.ts +9 -0
  227. package/dist/compiler/runtime-affecting-signature.d.ts +2 -0
  228. package/dist/compiler/runtime-build-state.d.ts +6 -0
  229. package/dist/compiler/runtime-snapshot.d.ts +53 -0
  230. package/dist/compiler/scope-planner.d.ts +6 -0
  231. package/dist/compiler/semantic-css.d.ts +66 -0
  232. package/dist/compiler/session.d.ts +13 -0
  233. package/dist/compiler/shadow-gate.d.ts +26 -0
  234. package/dist/compiler/shadow-report-session.d.ts +37 -0
  235. package/dist/compiler/shadow-report.d.ts +15 -0
  236. package/dist/compiler/source-graph.d.ts +32 -0
  237. package/dist/compiler/tailwind-generation-session-pool.d.ts +22 -0
  238. package/dist/compiler/types.d.ts +95 -0
  239. package/dist/constants.d.ts +2 -2
  240. package/dist/context/compiler-context-cache.d.ts +1 -1
  241. package/dist/context/custom-attributes.d.ts +1 -1
  242. package/dist/context/handlers.d.ts +3 -3
  243. package/dist/context/index.d.ts +1 -1
  244. package/dist/context/runtime-package-replacements.d.ts +1 -1
  245. package/dist/context/style-options.d.ts +1 -1
  246. package/dist/context/tailwindcss.d.ts +3 -3
  247. package/dist/{context-VeFq_8vW.js → context-PZXBqrAJ.cjs} +32 -94
  248. package/dist/{context-BgGWVAmN.mjs → context-oTkxC5aZ.js} +23 -12
  249. package/dist/{core.mjs → core.cjs} +13 -12
  250. package/dist/core.d.ts +2 -2
  251. package/dist/core.js +12 -13
  252. package/dist/css-imports-DfNC3e6a.cjs +43 -0
  253. package/dist/css-loader-runtime-CSv0lKqV.cjs +11 -0
  254. package/dist/css-macro/postcss.cjs +19 -0
  255. package/dist/css-macro/postcss.js +2 -19
  256. package/dist/{css-macro.mjs → css-macro.cjs} +11 -8
  257. package/dist/css-macro.d.ts +2 -2
  258. package/dist/css-macro.js +8 -11
  259. package/dist/{defaults.mjs → defaults.cjs} +16 -11
  260. package/dist/defaults.d.ts +1 -1
  261. package/dist/defaults.js +11 -16
  262. package/dist/{escape.mjs → escape.cjs} +18 -4
  263. package/dist/escape.js +4 -18
  264. package/dist/framework/platform.d.ts +1 -1
  265. package/dist/{framework.mjs → framework.cjs} +47 -25
  266. package/dist/framework.d.ts +1 -1
  267. package/dist/framework.js +25 -47
  268. package/dist/generator/index.d.ts +6 -6
  269. package/dist/generator/options.d.ts +3 -3
  270. package/dist/generator/types.d.ts +2 -2
  271. package/dist/{generator-CEnUsjed.js → generator-C8D5cnbe.cjs} +730 -468
  272. package/dist/{generator-CEo920So.mjs → generator-CDdzqf1S.js} +747 -497
  273. package/dist/generator.cjs +12 -0
  274. package/dist/generator.d.ts +1 -1
  275. package/dist/generator.js +2 -12
  276. package/dist/{gulp-3m1dAiig.js → gulp-Cjcss8T_.cjs} +326 -241
  277. package/dist/{gulp-DP71z1jG.mjs → gulp-DNXQvDUw.js} +316 -234
  278. package/dist/gulp.cjs +5 -0
  279. package/dist/gulp.d.ts +4 -4
  280. package/dist/gulp.js +2 -5
  281. package/dist/{hmr-timing-1aS6--U7.mjs → hmr-timing-CuJwQzDc.js} +5230 -3259
  282. package/dist/hmr-timing-DMLfNfGG.cjs +555 -0
  283. package/dist/index.cjs +45 -0
  284. package/dist/index.d.ts +9 -9
  285. package/dist/index.js +9 -45
  286. package/dist/js/JsTokenUpdater.d.ts +1 -1
  287. package/dist/js/ModuleGraph.d.ts +3 -3
  288. package/dist/js/NodePathWalker.d.ts +2 -2
  289. package/dist/js/babel/process.d.ts +2 -2
  290. package/dist/js/babel.d.ts +8 -8
  291. package/dist/js/evalTransforms.d.ts +2 -2
  292. package/dist/js/fast-path/oxc.d.ts +1 -1
  293. package/dist/js/handlers.d.ts +2 -2
  294. package/dist/js/index.d.ts +3 -3
  295. package/dist/js/literal-transform.d.ts +1 -1
  296. package/dist/js/module-graph/ignored-exports.d.ts +4 -4
  297. package/dist/js/module-graph/types.d.ts +2 -2
  298. package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
  299. package/dist/js/precheck.d.ts +1 -1
  300. package/dist/js/replacement-cache.d.ts +1 -1
  301. package/dist/js/sourceAnalysis.d.ts +3 -3
  302. package/dist/js/taggedTemplateIgnore.d.ts +1 -1
  303. package/dist/object-Bvy6-w9r.js +47 -0
  304. package/dist/object-C_Vr6_S5.cjs +58 -0
  305. package/dist/options-DlvhQwWB.cjs +775 -0
  306. package/dist/pipeline-helpers-XtUmUlci.cjs +955 -0
  307. package/dist/postcss-html-transform.cjs +7 -0
  308. package/dist/postcss-html-transform.js +3 -5
  309. package/dist/postcss.cjs +15 -0
  310. package/dist/postcss.js +7 -11
  311. package/dist/presets/hbuilderx.d.ts +2 -2
  312. package/dist/presets/index.d.ts +4 -4
  313. package/dist/presets/shared.d.ts +1 -1
  314. package/dist/presets/taro.d.ts +2 -2
  315. package/dist/presets/uni-app-x.d.ts +1 -1
  316. package/dist/presets/uni-app.d.ts +2 -2
  317. package/dist/{presets.mjs → presets.cjs} +37 -24
  318. package/dist/presets.d.ts +1 -1
  319. package/dist/presets.js +24 -36
  320. package/dist/reset.cjs +19 -0
  321. package/dist/reset.d.ts +2 -2
  322. package/dist/reset.js +2 -19
  323. package/dist/{rolldown-runtime-emK7D4bc.js → rolldown-runtime-CVvi-lCc.cjs} +15 -0
  324. package/dist/{rspack.mjs → rspack.cjs} +10 -4
  325. package/dist/rspack.d.ts +3 -3
  326. package/dist/rspack.js +4 -10
  327. package/dist/runtime-branch/create-branch.d.ts +1 -1
  328. package/dist/runtime-branch/generator-target-env.d.ts +1 -1
  329. package/dist/runtime-branch/index.d.ts +2 -2
  330. package/dist/runtime-branch/mini-program.d.ts +1 -1
  331. package/dist/runtime-branch/native-app.d.ts +1 -1
  332. package/dist/runtime-branch/platform.d.ts +2 -2
  333. package/dist/runtime-branch/tailwind-version.d.ts +1 -1
  334. package/dist/runtime-branch/types.d.ts +2 -2
  335. package/dist/runtime-branch/web.d.ts +1 -1
  336. package/dist/runtime-branch.d.ts +1 -1
  337. package/dist/runtime-registry-Y7NrD2WH.cjs +31 -0
  338. package/dist/shared/classname-transform.d.ts +1 -1
  339. package/dist/shared/mpx-plugin-owner.d.ts +2 -0
  340. package/dist/shared/mpx.d.ts +1 -1
  341. package/dist/{source-candidate-scan-signature-Cf7259PR.mjs → source-candidate-scan-signature-B0S7f5P7.js} +26 -336
  342. package/dist/{source-candidate-scan-signature-BAahhiwb.js → source-candidate-scan-signature-BmSuoxR9.cjs} +31 -414
  343. package/dist/style-injector/internal.d.ts +6 -6
  344. package/dist/style-options-CEfXwZzX.cjs +75 -0
  345. package/dist/tailwindcss/candidates.d.ts +2 -2
  346. package/dist/tailwindcss/index.d.ts +1 -1
  347. package/dist/tailwindcss/runtime/cache.d.ts +1 -1
  348. package/dist/tailwindcss/runtime-factory.d.ts +2 -2
  349. package/dist/tailwindcss/runtime-options.d.ts +1 -1
  350. package/dist/tailwindcss/runtime-types.d.ts +2 -2
  351. package/dist/tailwindcss/runtime.d.ts +2 -2
  352. package/dist/tailwindcss/source-scan.d.ts +2 -2
  353. package/dist/tailwindcss/targets.d.ts +1 -1
  354. package/dist/tailwindcss/v4/config.d.ts +1 -1
  355. package/dist/tailwindcss/v4/css-sources.d.ts +2 -1
  356. package/dist/tailwindcss/v4/index.d.ts +2 -2
  357. package/dist/tailwindcss/v4/multi-runtime.d.ts +1 -1
  358. package/dist/tailwindcss/v4/runtime-factory.d.ts +5 -5
  359. package/dist/tailwindcss/v4/runtime-options.d.ts +1 -1
  360. package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +1 -1
  361. package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
  362. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  363. package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
  364. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +51 -0
  365. package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +17 -0
  366. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -1
  367. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
  368. package/dist/tailwindcss/v4-engine/index.d.ts +5 -5
  369. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +2 -2
  370. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  371. package/dist/tailwindcss/v4-engine/types.d.ts +1 -0
  372. package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-Cs94gJgf.cjs} +10 -770
  373. package/dist/{tailwindcss-xs704TRw.mjs → tailwindcss-D7TGiZR2.js} +23 -23
  374. package/dist/transform-BUEyOCT7.cjs +341 -0
  375. package/dist/transform-BbaPIji9.js +342 -0
  376. package/dist/typedoc.export.d.ts +4 -4
  377. package/dist/types/index.d.ts +7 -7
  378. package/dist/types/shared.d.ts +1 -1
  379. package/dist/types/typedoc-tailwindcss-runtime.d.ts +3 -3
  380. package/dist/types/user-defined-options/general.d.ts +5 -5
  381. package/dist/types/user-defined-options/important.d.ts +2 -2
  382. package/dist/types/user-defined-options/index.d.ts +9 -9
  383. package/dist/types/user-defined-options/matcher.d.ts +2 -2
  384. package/dist/types.cjs +0 -0
  385. package/dist/types.d.ts +1 -1
  386. package/dist/types.js +1 -0
  387. package/dist/uni-app-x/harmony.d.ts +1 -0
  388. package/dist/uni-app-x/index.d.ts +2 -2
  389. package/dist/uni-app-x/options.d.ts +1 -1
  390. package/dist/uni-app-x/style-asset/harmony-apply.d.ts +1 -0
  391. package/dist/uni-app-x/style-asset/style-value.d.ts +3 -0
  392. package/dist/uni-app-x/style-asset.d.ts +5 -4
  393. package/dist/uni-app-x/transform.d.ts +1 -1
  394. package/dist/uni-app-x/vite/harmony-apply.d.ts +19 -0
  395. package/dist/uni-app-x/vite/native-target.d.ts +2 -0
  396. package/dist/uni-app-x/vite.d.ts +5 -2
  397. package/dist/unocss/index.d.ts +1 -1
  398. package/dist/utils/disabled.d.ts +1 -1
  399. package/dist/utils/index.d.ts +3 -3
  400. package/dist/{hmr-timing-B8p4f0ca.js → v4-generation-core-D7MuR5ZF.cjs} +4886 -3330
  401. package/dist/{vite-nXZEiwG0.mjs → vite-BI1TeUPO.js} +6148 -4522
  402. package/dist/{vite-DUVjMduj.js → vite-CBzmUTu-.cjs} +6267 -4666
  403. package/dist/vite.cjs +4 -0
  404. package/dist/vite.d.ts +3 -3
  405. package/dist/vite.js +2 -4
  406. package/dist/watch-dependencies-BZGubvuJ.cjs +40 -0
  407. package/dist/{weapp-tw-css-generation-loader.js → weapp-tw-css-generation-loader.cjs} +3 -2
  408. package/dist/weapp-tw-css-import-rewrite-loader.cjs +201 -0
  409. package/dist/{weapp-tw-runtime-classset-loader.js → weapp-tw-runtime-classset-loader.cjs} +19 -15
  410. package/dist/{webpack-nppysF4B.js → webpack-Dao6bWEj.cjs} +1000 -1473
  411. package/dist/{webpack-C_UUFRgj.mjs → webpack-dAY9h8r8.js} +1462 -1185
  412. package/dist/webpack.cjs +5 -0
  413. package/dist/webpack.d.ts +2 -2
  414. package/dist/webpack.js +2 -5
  415. package/dist/wxml/Tokenizer.d.ts +2 -2
  416. package/dist/wxml/custom-attributes.d.ts +1 -1
  417. package/dist/wxml/index.d.ts +2 -2
  418. package/dist/wxml/shared.d.ts +1 -1
  419. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +1 -1
  420. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
  421. package/dist/wxml/utils/codegen.d.ts +1 -1
  422. package/dist/wxml/utils/custom-template.d.ts +2 -2
  423. package/dist/wxml/utils/fragment-helpers.d.ts +2 -2
  424. package/dist/wxml/utils/fragment-updater.d.ts +2 -2
  425. package/dist/wxml/utils/template-fragments.d.ts +2 -2
  426. package/dist/wxml/utils.d.ts +5 -5
  427. package/dist/wxml-DSMNuUaP.cjs +38609 -0
  428. package/dist/{cli.mjs → wxml-IBzZSaQC.js} +237 -718
  429. package/package.json +59 -54
  430. package/dist/css-macro/postcss.mjs +0 -2
  431. package/dist/generator.mjs +0 -2
  432. package/dist/gulp.mjs +0 -2
  433. package/dist/index.mjs +0 -9
  434. package/dist/object-BJSWl-E5.mjs +0 -9
  435. package/dist/object-COs_Mw6p.js +0 -14
  436. package/dist/postcss-html-transform.mjs +0 -5
  437. package/dist/postcss.mjs +0 -11
  438. package/dist/reset.mjs +0 -2
  439. package/dist/transform-B_KM9sLX.mjs +0 -14930
  440. package/dist/transform-CcYptivi.js +0 -14927
  441. package/dist/types.mjs +0 -1
  442. package/dist/vite.mjs +0 -2
  443. package/dist/watch-dependencies-bpG6kmAf.js +0 -80
  444. package/dist/weapp-tw-css-import-rewrite-loader-DNk0IxAt.js +0 -10198
  445. package/dist/weapp-tw-css-import-rewrite-loader.js +0 -10
  446. package/dist/webpack.mjs +0 -2
  447. package/dist/wxml-Ce10eREX.js +0 -3979
  448. package/dist/wxml-DdGdeqaH.mjs +0 -3861
  449. /package/dist/{auto-2dg_uhEJ.mjs → auto-2dg_uhEJ.js} +0 -0
  450. /package/dist/{auto-DtU6f3X6.js → auto-DtU6f3X6.cjs} +0 -0
  451. /package/dist/bundlers/{vite → shared}/source-scan/dependencies.d.ts +0 -0
  452. /package/dist/{cache-options-DavPxrhC.js → cache-options-DavPxrhC.cjs} +0 -0
  453. /package/dist/{cache-options-DwBtLwQe.mjs → cache-options-DwBtLwQe.js} +0 -0
  454. /package/dist/{logger-BNzxZbZj.mjs → logger-BNzxZbZj.js} +0 -0
  455. /package/dist/{logger-TlKT3xmR.js → logger-TlKT3xmR.cjs} +0 -0
  456. /package/dist/{utils-CuKLf1Zv.js → utils-CuKLf1Zv.cjs} +0 -0
  457. /package/dist/{utils-MVwpU07P.mjs → utils-MVwpU07P.js} +0 -0
@@ -1,11 +1,12 @@
1
- import { B as stripUnmatchedTailwindSourceMediaCloseFragments, E as resolveTailwindcssOptions, F as removeTailwindV4GeneratedUserCssArtifacts, H as finalizeMiniProgramCss, I as removeTailwindV4GeneratorAtRules, J as hasTailwindApplyDirective, K as stripMiniProgramCssSpecificityPlaceholders, M as isCommentOnlyCss, P as removeMiniProgramHoverSelectors, Q as normalizeTailwindConfigDirectives, W as pruneMiniProgramGeneratedCss, X as hasTailwindRootDirectives, Z as hasTailwindSourceDirectives, ct as hasTailwindGeneratedCssMarkers, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveSourceScanPath, nt as removeTailwindSourceDirectives, o as resolveRuntimeBranch, st as hasTailwindGeneratedCss, tt as parseImportRequest, vt as getTailwindV4IncrementalGenerateCacheStats, z as stripTailwindSourceMediaFragments } from "./generator-CEo920So.mjs";
2
- import { g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-xs704TRw.mjs";
3
- import { r as getGroupedEntries } from "./utils-MVwpU07P.mjs";
4
- import { b as md5Hash, c as _defineProperty, y as createDebug } from "./wxml-DdGdeqaH.mjs";
5
- import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-BgGWVAmN.mjs";
6
- import { getDefaultCssPreflight } from "./defaults.mjs";
7
- import { A as collectRawSourceClassSelectors, C as scoreTailwindV4CssSourceFileMatch, D as hasMiniProgramTailwindV4PreflightReset, F as annotateCssSourceTrace, I as createCssSourceTraceCacheSignature, L as createCssTokenSourceMap, M as hasBundlerGeneratedCssMarker, O as isSourceStyleRequest, P as stripBundlerGeneratedCssMarkers, R as isCssSourceTraceEnabled, T as createCssSourceOrderAppend, a as isSourceCandidateRequest, b as isPureLocalCssImportWrapper, c as createBundleRuntimeClassSetManager, i as createSourceCandidateStore, k as stripRequestQuery, l as collectStrictEscapedRuntimeCandidates, m as resolveTaskConcurrency, n as emitHmrTiming, o as resolveSourceCandidateScanFiles, p as pushConcurrentTaskFactories, u as createEscapeFragments, w as removeGeneratedSelectorCompatCss, z as processCachedTask } from "./hmr-timing-1aS6--U7.mjs";
8
- import { D as toAbsoluteOutputPath, E as resolveOutputSpecifier, F as resolveWebpackFrameworkProfile, N as webpackStyleInjectorDelegates, O as resolvePackageDir, a as createCandidateSignature, f as classifyBundleEntry, j as createBuiltinWebpackStyleInjectorPlugin, k as resolvePluginDisabledState, m as updateBundleBuildState, p as createBundleBuildState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature } from "./source-candidate-scan-signature-Cf7259PR.mjs";
1
+ import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, F as stripUnmatchedTailwindSourceMediaCloseFragments, I as finalizeMiniProgramCss, M as removeMiniProgramHoverSelectors, N as removeTailwindV4GeneratorAtRules, Ot as resolveSourceScanPath, P as stripTailwindSourceMediaFragments, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, R as pruneMiniProgramGeneratedCss, V as removeTailwindV4GeneratedUserCssArtifacts, X as hasTailwindApplyDirective, _ as upsertTailwindV4CssSource, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, j as isCommentOnlyCss, lt as hasTailwindGeneratedCss, o as resolveRuntimeBranch, rt as parseImportRequest, ut as hasTailwindGeneratedCssMarkers } from "./generator-CDdzqf1S.js";
2
+ import { n as _defineProperty } from "./object-Bvy6-w9r.js";
3
+ import { _ as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, p as resolveSourceScanEntries } from "./tailwindcss-D7TGiZR2.js";
4
+ import { r as getGroupedEntries } from "./utils-MVwpU07P.js";
5
+ import { $ as createCompilationDependencyChanges, A as isCssSourceTraceEnabled, B as createRuntimeCompilationAffectingSignature, D as annotateCssSourceTrace, E as stripBundlerGeneratedCssMarkers, F as isPureLocalCssImportWrapper, G as createRuntimeAffectingSourceSignature, K as disposeCompilerOwner, M as createRuntimeClassSetManager, N as collectStrictEscapedRuntimeCandidates, O as createCssSourceTraceCacheSignature, P as createEscapeFragments, Q as recordCompilationDependencyChanges, R as finalizeCompilerShadowRun, S as stripRequestQuery, U as resetRuntimeCompilationBuildState, V as createRuntimeCompilationBuildState, W as updateRuntimeCompilationBuildState, X as getCompilationScopeDependencyRevision, Y as AssetEmissionPlan, _ as collectFrameworkPostcssOptionsFromLoaderEntries, b as hasMiniProgramTailwindV4PreflightReset, c as pushConcurrentTaskFactories, g as captureResolvedFrameworkPostcssOptions, it as resolveSourceCandidateScanFiles, j as processCachedTask, k as createCssTokenSourceMap, l as resolveTaskConcurrency, m as removeGeneratedSelectorCompatCss, n as emitHmrTiming, nt as isSourceCandidateRequest, p as scoreTailwindV4CssSourceFileMatch, q as beginCompilerShadowRun, r as generateTailwindV4Css, s as collectRawSourceClassSelectors, tt as createSourceCandidateStore, v as createCssSourceOrderAppend, w as hasBundlerGeneratedCssMarker, x as isSourceStyleRequest, z as buildRuntimeCompilationSnapshot } from "./hmr-timing-CuJwQzDc.js";
6
+ import { h as createDebug, v as md5Hash } from "./wxml-IBzZSaQC.js";
7
+ import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-oTkxC5aZ.js";
8
+ import { getDefaultCssPreflight } from "./defaults.js";
9
+ import { S as resolveWebpackFrameworkProfile, a as createCandidateSignature, b as webpackStyleInjectorDelegates, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, v as createBuiltinWebpackStyleInjectorPlugin } from "./source-candidate-scan-signature-B0S7f5P7.js";
9
10
  import Module, { createRequire } from "node:module";
10
11
  import fs from "node:fs";
11
12
  import path from "node:path";
@@ -153,13 +154,243 @@ function isWatchFileInRuntimeDependencies(file, dependencies) {
153
154
  return false;
154
155
  }
155
156
  //#endregion
156
- //#region src/bundlers/webpack/shared/css-loader-runtime.ts
157
- function isWebpackCssLoaderRuntimeSource(source) {
158
- return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && source.includes("module.exports = ___CSS_LOADER_EXPORT___");
157
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.ts
158
+ function isRuntimeTransformCandidate(candidate) {
159
+ return candidate.length > 0 && !candidate.includes("=") && !candidate.includes("<") && !candidate.includes(">") && !candidate.includes("${");
160
+ }
161
+ //#endregion
162
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.ts
163
+ function collectWebpackAssetUserCssMarkers(source) {
164
+ const markers = /* @__PURE__ */ new Set();
165
+ for (const match of source.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
166
+ for (const match of source.matchAll(/@(?:-[\w-]+-)?keyframes\s+((?:\\.|[-\w\u00A0-\uFFFF])+)/gi)) markers.add(`keyframes:${match[1]}`);
167
+ try {
168
+ const root = postcss.parse(source);
169
+ root.walkRules((rule) => {
170
+ for (const selector of rule.selectors) if (!/(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector)) markers.add(`selector:${selector.trim().replace(/\s+/g, " ")}`);
171
+ rule.walkDecls((decl) => {
172
+ if (decl.prop.startsWith("--")) markers.add(`custom-property:${decl.prop}`);
173
+ });
174
+ });
175
+ root.walkAtRules("font-face", (rule) => {
176
+ rule.walkDecls("font-family", (decl) => {
177
+ markers.add(`font-face:${decl.value.trim()}`);
178
+ });
179
+ });
180
+ } catch {}
181
+ return markers;
159
182
  }
160
183
  //#endregion
161
- //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.ts
162
- const WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX = 128;
184
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.ts
185
+ const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
186
+ "theme",
187
+ "base",
188
+ "utilities"
189
+ ]);
190
+ const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
191
+ const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
192
+ const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
193
+ const WEBPACK_TAILWIND_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
194
+ "*",
195
+ ":after",
196
+ ":before",
197
+ "::after",
198
+ "::before",
199
+ "::backdrop",
200
+ "view",
201
+ "text"
202
+ ]);
203
+ const WEBPACK_TAILWIND_PREFLIGHT_PROPS = /* @__PURE__ */ new Set([
204
+ "box-sizing",
205
+ "border",
206
+ "border-width",
207
+ "border-style",
208
+ "border-color",
209
+ "margin",
210
+ "padding"
211
+ ]);
212
+ const WEBPACK_TAILWIND_THEME_TOKEN_RE = /^--(?:tw-|color-|spacing|breakpoint-|container-|text-|font-|tracking-|leading-|radius-|shadow-|inset-shadow-|drop-shadow-|ease-|animate-|blur-|perspective-|aspect-|default-)/;
213
+ function parseWebpackCssLayerNames(params) {
214
+ return params.split(",").map((name) => name.trim()).filter(Boolean);
215
+ }
216
+ function removeWebpackTailwindGeneratedAssetCss(source) {
217
+ const cleaned = removeTailwindV4GeneratedUserCssArtifacts(source);
218
+ try {
219
+ const root = postcss.parse(cleaned);
220
+ let changed = false;
221
+ let removingBannerPrefix = false;
222
+ for (const node of [...root.nodes]) {
223
+ if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
224
+ node.remove();
225
+ changed = true;
226
+ removingBannerPrefix = true;
227
+ continue;
228
+ }
229
+ if (!removingBannerPrefix) continue;
230
+ if (isWebpackTailwindGeneratedPrefixNode(node)) {
231
+ node.remove();
232
+ changed = true;
233
+ continue;
234
+ }
235
+ removingBannerPrefix = false;
236
+ }
237
+ root.walkAtRules("layer", (rule) => {
238
+ const names = parseWebpackCssLayerNames(rule.params);
239
+ const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
240
+ const isLayerDeclaration = rule.nodes === void 0;
241
+ const shouldRemoveLayer = isLayerDeclaration ? hasGeneratedLayerName : names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
242
+ if (shouldRemoveLayer && isLayerDeclaration) {
243
+ rule.remove();
244
+ changed = true;
245
+ return;
246
+ }
247
+ if (shouldRemoveLayer && !names.includes("utilities")) {
248
+ for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
249
+ child.remove();
250
+ changed = true;
251
+ }
252
+ if (rule.nodes?.length === 0) {
253
+ rule.remove();
254
+ changed = true;
255
+ }
256
+ return;
257
+ }
258
+ if (shouldRemoveLayer) {
259
+ for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
260
+ child.remove();
261
+ changed = true;
262
+ }
263
+ if (rule.nodes?.length === 0) {
264
+ rule.remove();
265
+ changed = true;
266
+ }
267
+ }
268
+ });
269
+ root.walkRules((rule) => {
270
+ if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
271
+ const selector = rule.selector.trim();
272
+ if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || isWebpackTailwindGeneratedPreflightRule(rule)) {
273
+ rule.remove();
274
+ changed = true;
275
+ }
276
+ });
277
+ root.walkComments((comment) => {
278
+ if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
279
+ comment.remove();
280
+ changed = true;
281
+ }
282
+ });
283
+ root.walkAtRules((rule) => {
284
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) {
285
+ rule.remove();
286
+ changed = true;
287
+ }
288
+ });
289
+ return changed ? root.toString() : cleaned;
290
+ } catch {
291
+ return cleaned;
292
+ }
293
+ }
294
+ function isWebpackTailwindGeneratedPrefixNode(node) {
295
+ if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, [
296
+ "theme",
297
+ "base",
298
+ "utilities"
299
+ ], true);
300
+ if (node.type !== "atrule") return false;
301
+ const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
302
+ if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
303
+ if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) {
304
+ if (node.nodes === void 0) return true;
305
+ return node.nodes.length > 0 && node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, names));
306
+ }
307
+ if (node.nodes === void 0 || node.nodes.length === 0) return false;
308
+ return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
309
+ }
310
+ function isWebpackTailwindGeneratedLayerNode(node, layerNames) {
311
+ if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, layerNames, false);
312
+ if (node.type !== "atrule") return false;
313
+ if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
314
+ if (node.nodes === void 0 || node.nodes.length === 0) return false;
315
+ return node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, layerNames));
316
+ }
317
+ function isWebpackTailwindGeneratedRule(rule, layerNames, includePrefix) {
318
+ const selectors = rule.selectors ?? [rule.selector];
319
+ if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), includePrefix))) return true;
320
+ if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true))) return true;
321
+ if (layerNames.includes("theme") && isWebpackTailwindGeneratedThemeRule(rule)) return true;
322
+ if (layerNames.includes("base") && isWebpackTailwindGeneratedPreflightRule(rule)) return true;
323
+ return false;
324
+ }
325
+ function isWebpackTailwindGeneratedThemeRule(rule) {
326
+ const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
327
+ return declarations.length > 0 && declarations.every((decl) => WEBPACK_TAILWIND_THEME_TOKEN_RE.test(decl.prop) || decl.value.includes("--theme("));
328
+ }
329
+ function isWebpackTailwindGeneratedPreflightRule(rule) {
330
+ const selectors = rule.selectors ?? [rule.selector];
331
+ const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
332
+ return selectors.length > 0 && declarations.length > 0 && selectors.every((selector) => {
333
+ const normalized = selector.trim().replace(/\s+/g, " ");
334
+ return WEBPACK_TAILWIND_PREFLIGHT_SELECTORS.has(normalized);
335
+ }) && declarations.every((decl) => WEBPACK_TAILWIND_PREFLIGHT_PROPS.has(decl.prop));
336
+ }
337
+ function isOnlyWebpackTailwindGeneratedPreflightCss(source) {
338
+ try {
339
+ const nodes = postcss.parse(source).nodes ?? [];
340
+ return nodes.length > 0 && nodes.every((node) => {
341
+ if (node.type === "rule") return isWebpackTailwindGeneratedPreflightRule(node);
342
+ return node.type === "atrule" && (node.nodes === void 0 || node.nodes.length === 0);
343
+ });
344
+ } catch {
345
+ return false;
346
+ }
347
+ }
348
+ function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
349
+ return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
350
+ }
351
+ function collectWebpackCssRuleIdentityMarkers(source) {
352
+ const markers = /* @__PURE__ */ new Set();
353
+ try {
354
+ const root = postcss.parse(source);
355
+ root.walkRules((rule) => {
356
+ for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
357
+ });
358
+ root.walkAtRules("keyframes", (rule) => {
359
+ if (rule.params) markers.add(`keyframes:${rule.params}`);
360
+ });
361
+ } catch {}
362
+ return markers;
363
+ }
364
+ function unescapeCssIdentifier(value) {
365
+ return value.replace(/\\([0-9a-f]{1,6}\s?|.)/gi, (_match, escaped) => {
366
+ const hex = escaped.trim();
367
+ if (/^[0-9a-f]+$/i.test(hex)) return String.fromCodePoint(Number.parseInt(hex, 16));
368
+ return escaped;
369
+ });
370
+ }
371
+ function collectGeneratedCssRuntimeCandidates(source) {
372
+ const candidates = /* @__PURE__ */ new Set();
373
+ if (hasBundlerGeneratedCssMarker(source) || !hasTailwindGeneratedCss(source) && !hasTailwindGeneratedCssMarkers(source)) return candidates;
374
+ try {
375
+ postcss.parse(source).walkRules((rule) => {
376
+ for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[\w\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/g)) {
377
+ const candidate = unescapeCssIdentifier(match[1]);
378
+ if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
379
+ }
380
+ });
381
+ } catch {}
382
+ return candidates;
383
+ }
384
+ function hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource) {
385
+ const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
386
+ if (rawMarkers.size === 0) return false;
387
+ const generatorMarkers = collectWebpackAssetUserCssMarkers(generatorRawSource);
388
+ for (const marker of rawMarkers) if (!generatorMarkers.has(marker)) return true;
389
+ return false;
390
+ }
391
+ function hasWebpackTailwindSourceDirectives(source) {
392
+ return Boolean(source) && (hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source) || hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source));
393
+ }
163
394
  function resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) {
164
395
  return styleOptions.cssPreflight ?? compilerOptions.cssPreflight ?? getDefaultCssPreflight();
165
396
  }
@@ -269,9 +500,6 @@ function removeTailwindV4StandaloneHostPreflightRule(source) {
269
500
  return source;
270
501
  }
271
502
  }
272
- function isRuntimeTransformCandidate(candidate) {
273
- return candidate.length > 0 && !candidate.includes("=") && !candidate.includes("<") && !candidate.includes(">") && !candidate.includes("${");
274
- }
275
503
  function collectRuntimeTokenSignatureParts(source) {
276
504
  return source.match(/[\w-]+_[A-Z][\w-]*/gi) ?? [];
277
505
  }
@@ -315,27 +543,242 @@ function pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandl
315
543
  const activeSuffixes = [...activeCssFiles].map((file) => `:${file}`);
316
544
  for (const key of cssHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssHandlerOptionsCache.delete(key);
317
545
  for (const key of cssUserHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssUserHandlerOptionsCache.delete(key);
318
- pruneMapToMaxSize(cssHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
319
- pruneMapToMaxSize(cssUserHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
320
- }
321
- function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
322
- const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
323
- if (sourceCss && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss) || hasTailwindGeneratedCss(sourceCss) || hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
324
- return rawSource;
325
- }
326
- function shouldConsumeWebpackLoaderGeneratedCss(options) {
327
- if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
328
- if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
329
- if (options.hasBundlerGeneratedCssMarker) return true;
330
- if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
331
- return Boolean(options.allowMarkerlessRegistryMatch && options.loaderGeneratedClassSet && options.sourceCandidates && !hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates) && !hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates));
332
- }
333
- function hasDeferredWebpackGeneratedCss(source, generatedClassSets) {
334
- const selectors = collectRawSourceClassSelectors(source);
335
- for (const classSet of generatedClassSets) for (const candidate of classSet) if (selectors.has(candidate)) return true;
336
- return false;
546
+ pruneMapToMaxSize(cssHandlerOptionsCache, 128);
547
+ pruneMapToMaxSize(cssUserHandlerOptionsCache, 128);
337
548
  }
338
- function hasUsableWebpackGeneratorCssSources(cssSources) {
549
+ //#endregion
550
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.ts
551
+ function resolveWebpackMemoryDebugStats(context) {
552
+ if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
553
+ const memory = process.memoryUsage();
554
+ const processCacheInstanceSize = context.cache.instance.size;
555
+ const processCacheHashMapSize = context.cache.hashMap.size;
556
+ return {
557
+ phase: context.phase,
558
+ process: {
559
+ rssMb: toMb(memory.rss),
560
+ heapTotalMb: toMb(memory.heapTotal),
561
+ heapUsedMb: toMb(memory.heapUsed),
562
+ externalMb: toMb(memory.external),
563
+ arrayBuffersMb: toMb(memory.arrayBuffers)
564
+ },
565
+ assets: {
566
+ active: context.activeAssetFiles,
567
+ activeCss: context.activeCssFiles
568
+ },
569
+ processCache: {
570
+ instance: processCacheInstanceSize,
571
+ hashMap: processCacheHashMapSize,
572
+ activeCacheKeys: context.activeProcessCacheKeys.size,
573
+ activeHashKeys: context.activeProcessHashKeys.size,
574
+ staleCacheKeys: Math.max(0, processCacheInstanceSize - context.activeProcessCacheKeys.size),
575
+ staleHashKeys: Math.max(0, processCacheHashMapSize - context.activeProcessHashKeys.size),
576
+ pruned: true,
577
+ pruneSkipped: false
578
+ },
579
+ webpackCss: {
580
+ handlerOptions: context.cssHandlerOptionsCache.size,
581
+ userHandlerOptions: context.cssUserHandlerOptionsCache.size,
582
+ maxHandlerOptions: 128
583
+ },
584
+ sourceCandidateScan: context.sourceCandidateScan,
585
+ tailwind: { v4: getTailwindV4IncrementalGenerateCacheStats() }
586
+ };
587
+ }
588
+ function shouldInjectWebpackCssTracePreflight(_appType, cssHandlerOptions) {
589
+ if (includesTailwindPreflightImport(cssHandlerOptions.sourceOptions?.sourceCss)) return true;
590
+ return cssHandlerOptions.isMainChunk !== false;
591
+ }
592
+ function includesTailwindPreflightImport(source) {
593
+ if (!source) return false;
594
+ try {
595
+ let includesPreflight = false;
596
+ postcss.parse(source).walkAtRules((rule) => {
597
+ if (rule.name === "tailwind") {
598
+ includesPreflight || (includesPreflight = rule.params.trim() === "base");
599
+ return;
600
+ }
601
+ if (rule.name !== "import") return;
602
+ const request = parseImportRequest(rule.params)?.replaceAll("\\", "/");
603
+ includesPreflight || (includesPreflight = request === "tailwindcss" || request === "tailwindcss/preflight.css" || request?.endsWith("/tailwindcss/index.css") === true || request?.endsWith("/tailwindcss/preflight.css") === true);
604
+ });
605
+ return includesPreflight;
606
+ } catch {
607
+ return false;
608
+ }
609
+ }
610
+ function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
611
+ const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
612
+ if (isWebGeneratorTarget) return source;
613
+ return stripMiniProgramCssSpecificityPlaceholders(removeTailwindV4StandaloneHostPreflightRule(finalizeMiniProgramCss(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
614
+ cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0,
615
+ isTailwindcssV4: true,
616
+ tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
617
+ })));
618
+ }
619
+ function shouldFallbackToWebpackUserCssOnGeneratorError(options) {
620
+ return !hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindSourceDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindApplyDirective(options.generatorRawSource) && !options.hasExplicitTailwindV4SourceCss && options.configuredMainCssEntryFilesLength === 0;
621
+ }
622
+ //#endregion
623
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.ts
624
+ function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
625
+ if (options.finalized === true) return options.annotateCss(css);
626
+ if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return options.annotateCss(css);
627
+ const finalized = finalizeMiniProgramUserCssAssetSource(css, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
628
+ return options.annotateCss(finalized);
629
+ }
630
+ function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
631
+ const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
632
+ if (isWebGeneratorTarget) {
633
+ if (options.generatedCss === true) return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(stripBundlerGeneratedCssMarkers(source))));
634
+ return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
635
+ }
636
+ let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
637
+ if (options.generatedCss !== true) {
638
+ finalized = finalizeMiniProgramCss(finalized, {
639
+ cssPreflight: false,
640
+ isTailwindcssV4: true,
641
+ tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
642
+ });
643
+ finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
644
+ return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
645
+ }
646
+ try {
647
+ finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: options.cssPreflight !== false });
648
+ } catch {}
649
+ const shouldRemoveExistingPreflight = options.cssPreflight === false && options.preserveExistingPreflight === false;
650
+ if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
651
+ const hasExistingMiniProgramPreflight = options.preserveExistingPreflight !== false && hasMiniProgramPreflightSelector(source);
652
+ finalized = finalizeMiniProgramCss(finalized, {
653
+ cssPreflight: options.cssPreflight === false && !hasExistingMiniProgramPreflight ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) : void 0,
654
+ isTailwindcssV4: true,
655
+ tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
656
+ });
657
+ finalized = ensureWebpackMiniProgramTwContentInit(finalized);
658
+ if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
659
+ else finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
660
+ return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
661
+ }
662
+ function finalizeWebpackCssAssetOutputSource(source, compilerOptions, isWebGeneratorTarget) {
663
+ if (isWebGeneratorTarget) return source;
664
+ const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
665
+ return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(dedupeCoveredCssRules(dedupeMiniProgramPreflightSelectorRules(source)), styleOptions.cssRemoveHoverPseudoClass));
666
+ }
667
+ function collectWebpackJsRuntimeCandidatesFromAssets(options) {
668
+ if (options.isWebGeneratorTarget) return;
669
+ const candidates = /* @__PURE__ */ new Set();
670
+ for (const file of options.jsAssets) {
671
+ const sourceLike = options.getAssetSource(file);
672
+ if (sourceLike === void 0) continue;
673
+ const source = stringifyWebpackSourceLike(sourceLike);
674
+ for (const candidate of collectStrictEscapedRuntimeCandidates(source, MappingChars2String, options.escapeFragments)) if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
675
+ }
676
+ return candidates;
677
+ }
678
+ function collectWebpackJsRuntimeTokenSignature(options) {
679
+ if (options.isWebGeneratorTarget) return "";
680
+ const tokens = [];
681
+ for (const file of options.jsAssets) {
682
+ const sourceLike = options.getAssetSource(file);
683
+ if (sourceLike === void 0) continue;
684
+ tokens.push(...collectRuntimeTokenSignatureParts(stringifyWebpackSourceLike(sourceLike)));
685
+ }
686
+ return tokens.sort().join("\n");
687
+ }
688
+ function addRuntimeTransformCandidates(target, candidates) {
689
+ if (!candidates?.size) return;
690
+ for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate)) target.add(candidate);
691
+ }
692
+ function createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates) {
693
+ if (!isCssSourceTraceEnabled(compilerOptions) || !webpackSourceCandidates) return;
694
+ return createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions);
695
+ }
696
+ function stringifyOptionalWebpackSourceValue(value) {
697
+ return typeof value === "string" ? value : value?.toString() ?? "";
698
+ }
699
+ function stringifyWebpackSourceLike(source) {
700
+ if (typeof source === "string") return source;
701
+ const value = source.source();
702
+ return typeof value === "string" ? value : value.toString();
703
+ }
704
+ //#endregion
705
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.ts
706
+ function isWindowsAbsoluteResourcePath(file) {
707
+ return /^[a-z]:[\\/]/i.test(file) || /^[/\\]{2}[^/\\]/.test(file);
708
+ }
709
+ function isPosixAbsoluteResourcePath(file) {
710
+ return file.startsWith("/");
711
+ }
712
+ function resolveWebpackResourcePath(file, base) {
713
+ if (isWindowsAbsoluteResourcePath(file)) return path.win32.resolve(file);
714
+ if (isPosixAbsoluteResourcePath(file)) return path.posix.resolve(file);
715
+ if (base) {
716
+ if (isWindowsAbsoluteResourcePath(base)) return path.win32.resolve(base, file);
717
+ if (isPosixAbsoluteResourcePath(base)) return path.posix.resolve(base, file);
718
+ return path.resolve(base, file);
719
+ }
720
+ }
721
+ function dirnameWebpackResourcePath(file) {
722
+ if (isWindowsAbsoluteResourcePath(file)) return path.win32.dirname(file);
723
+ if (isPosixAbsoluteResourcePath(file)) return path.posix.dirname(file);
724
+ return path.dirname(file);
725
+ }
726
+ function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
727
+ if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
728
+ const normalized = stripResourceQuery(resource);
729
+ if (!normalized) return;
730
+ const absoluteResource = resolveWebpackResourcePath(normalized);
731
+ if (absoluteResource) return absoluteResource;
732
+ const issuerResource = issuer?.resource ? stripResourceQuery(issuer.resource) : void 0;
733
+ const issuerResourcePath = issuerResource ? resolveWebpackResourcePath(issuerResource) : void 0;
734
+ return resolveWebpackResourcePath(normalized, issuerResourcePath ? dirnameWebpackResourcePath(issuerResourcePath) : issuer?.context);
735
+ }
736
+ function isSameWebpackCssSourceScope(options) {
737
+ if (!options.currentSourceFile) return false;
738
+ const candidateKey = resolveWebpackResourcePath(options.candidateSourceFile) ?? path.resolve(options.candidateSourceFile);
739
+ if (candidateKey === (resolveWebpackResourcePath(options.currentSourceFile) ?? path.resolve(options.currentSourceFile))) return true;
740
+ const outputResources = options.resourcesByAsset.get(options.outputFile);
741
+ if (!outputResources) return false;
742
+ return [...outputResources].some((resource) => {
743
+ return (resolveWebpackResourcePath(resource) ?? path.resolve(resource)) === candidateKey;
744
+ });
745
+ }
746
+ function shouldAppendCurrentWebpackAssetUserCss(options) {
747
+ const hasGeneratedAssetUserCss = options.currentAssetLooksGenerated && options.currentAssetHasUserCss;
748
+ return !options.currentAssetHasBundlerGeneratedMarker && !options.shouldPreserveGeneratedWebAssetUserCss && (hasGeneratedAssetUserCss || !options.sourceCssProcessed || options.registeredUserRawSource === void 0 || options.currentAssetHasUserCss) && !(options.sourceCssProcessed && options.currentAssetLooksGenerated && !options.currentAssetHasUserCss);
749
+ }
750
+ function createWebpackCurrentAssetUserRawSource(options) {
751
+ if (!options.shouldAppendCurrentAssetUserCss) return;
752
+ if (options.sourceCssProcessed) return {
753
+ css: options.currentAssetUserCssSource,
754
+ processed: true
755
+ };
756
+ if (!options.currentAssetHasUserCss) return;
757
+ return {
758
+ css: options.currentAssetUserCssSource,
759
+ processed: options.currentAssetLooksGenerated
760
+ };
761
+ }
762
+ //#endregion
763
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.ts
764
+ function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
765
+ const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
766
+ if (sourceCss && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss) || hasTailwindGeneratedCss(sourceCss) || hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
767
+ return rawSource;
768
+ }
769
+ function shouldConsumeWebpackLoaderGeneratedCss(options) {
770
+ if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
771
+ if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
772
+ if (options.hasBundlerGeneratedCssMarker) return true;
773
+ if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
774
+ return Boolean(options.allowMarkerlessRegistryMatch && options.loaderGeneratedClassSet && options.sourceCandidates && !hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates) && !hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates));
775
+ }
776
+ function hasDeferredWebpackGeneratedCss(source, generatedClassSets) {
777
+ const selectors = collectRawSourceClassSelectors(source);
778
+ for (const classSet of generatedClassSets) for (const candidate of classSet) if (selectors.has(candidate)) return true;
779
+ return false;
780
+ }
781
+ function hasUsableWebpackGeneratorCssSources(cssSources) {
339
782
  return Array.isArray(cssSources) && cssSources.some((source) => typeof source?.css === "string" && source.css.length > 0);
340
783
  }
341
784
  function normalizeWebpackGeneratorCssSources(cssSources) {
@@ -389,26 +832,6 @@ function shouldUseWebpackAssetAsGeneratorUserCss(rawSource, generatorRawSource,
389
832
  const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
390
833
  return rawSource !== generatorRawSource && (options.processed === true || !rawSource.includes("data:")) && !hasTailwindRootDirectives(rawSource, { importFallback: true }) && !hasTailwindSourceDirectives(rawSource, { importFallback: true }) && !hasTailwindApplyDirective(rawSource) && rawMarkers.size > 0 && !isOnlyWebpackTailwindGeneratedPreflightCss(rawSource) && (!hasTailwindGeneratedCssMarkers(rawSource) || hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource));
391
834
  }
392
- function collectWebpackAssetUserCssMarkers(source) {
393
- const markers = /* @__PURE__ */ new Set();
394
- for (const match of source.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
395
- for (const match of source.matchAll(/@(?:-[\w-]+-)?keyframes\s+((?:\\.|[-\w\u00A0-\uFFFF])+)/gi)) markers.add(`keyframes:${match[1]}`);
396
- try {
397
- const root = postcss.parse(source);
398
- root.walkRules((rule) => {
399
- for (const selector of rule.selectors) if (!/(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector)) markers.add(`selector:${selector.trim().replace(/\s+/g, " ")}`);
400
- rule.walkDecls((decl) => {
401
- if (decl.prop.startsWith("--")) markers.add(`custom-property:${decl.prop}`);
402
- });
403
- });
404
- root.walkAtRules("font-face", (rule) => {
405
- rule.walkDecls("font-family", (decl) => {
406
- markers.add(`font-face:${decl.value.trim()}`);
407
- });
408
- });
409
- } catch {}
410
- return markers;
411
- }
412
835
  function hasWebpackClassSelector(selector) {
413
836
  return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
414
837
  }
@@ -448,215 +871,8 @@ function collectWebpackBareSelectorUserCss(source) {
448
871
  return "";
449
872
  }
450
873
  }
451
- const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
452
- "theme",
453
- "base",
454
- "utilities"
455
- ]);
456
- const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
457
- const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
458
- const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
459
- const WEBPACK_TAILWIND_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
460
- "*",
461
- ":after",
462
- ":before",
463
- "::after",
464
- "::before",
465
- "::backdrop",
466
- "view",
467
- "text"
468
- ]);
469
- const WEBPACK_TAILWIND_PREFLIGHT_PROPS = /* @__PURE__ */ new Set([
470
- "box-sizing",
471
- "border",
472
- "border-width",
473
- "border-style",
474
- "border-color",
475
- "margin",
476
- "padding"
477
- ]);
478
- const WEBPACK_TAILWIND_THEME_TOKEN_RE = /^--(?:tw-|color-|spacing|breakpoint-|container-|text-|font-|tracking-|leading-|radius-|shadow-|inset-shadow-|drop-shadow-|ease-|animate-|blur-|perspective-|aspect-|default-)/;
479
- function parseWebpackCssLayerNames(params) {
480
- return params.split(",").map((name) => name.trim()).filter(Boolean);
481
- }
482
- function removeWebpackTailwindGeneratedAssetCss(source) {
483
- const cleaned = removeTailwindV4GeneratedUserCssArtifacts(source);
484
- try {
485
- const root = postcss.parse(cleaned);
486
- let changed = false;
487
- let removingBannerPrefix = false;
488
- for (const node of [...root.nodes]) {
489
- if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
490
- node.remove();
491
- changed = true;
492
- removingBannerPrefix = true;
493
- continue;
494
- }
495
- if (!removingBannerPrefix) continue;
496
- if (isWebpackTailwindGeneratedPrefixNode(node)) {
497
- node.remove();
498
- changed = true;
499
- continue;
500
- }
501
- removingBannerPrefix = false;
502
- }
503
- root.walkAtRules("layer", (rule) => {
504
- const names = parseWebpackCssLayerNames(rule.params);
505
- const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
506
- const isLayerDeclaration = rule.nodes === void 0;
507
- const shouldRemoveLayer = isLayerDeclaration ? hasGeneratedLayerName : names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
508
- if (shouldRemoveLayer && isLayerDeclaration) {
509
- rule.remove();
510
- changed = true;
511
- return;
512
- }
513
- if (shouldRemoveLayer && !names.includes("utilities")) {
514
- for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
515
- child.remove();
516
- changed = true;
517
- }
518
- if (rule.nodes?.length === 0) {
519
- rule.remove();
520
- changed = true;
521
- }
522
- return;
523
- }
524
- if (shouldRemoveLayer) {
525
- for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
526
- child.remove();
527
- changed = true;
528
- }
529
- if (rule.nodes?.length === 0) {
530
- rule.remove();
531
- changed = true;
532
- }
533
- }
534
- });
535
- root.walkRules((rule) => {
536
- if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
537
- const selector = rule.selector.trim();
538
- if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || isWebpackTailwindGeneratedPreflightRule(rule)) {
539
- rule.remove();
540
- changed = true;
541
- }
542
- });
543
- root.walkComments((comment) => {
544
- if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
545
- comment.remove();
546
- changed = true;
547
- }
548
- });
549
- root.walkAtRules((rule) => {
550
- if (rule.nodes !== void 0 && rule.nodes.length === 0) {
551
- rule.remove();
552
- changed = true;
553
- }
554
- });
555
- return changed ? root.toString() : cleaned;
556
- } catch {
557
- return cleaned;
558
- }
559
- }
560
- function isWebpackTailwindGeneratedPrefixNode(node) {
561
- if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, [
562
- "theme",
563
- "base",
564
- "utilities"
565
- ], true);
566
- if (node.type !== "atrule") return false;
567
- const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
568
- if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
569
- if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) {
570
- if (node.nodes === void 0) return true;
571
- return node.nodes.length > 0 && node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, names));
572
- }
573
- if (node.nodes === void 0 || node.nodes.length === 0) return false;
574
- return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
575
- }
576
- function isWebpackTailwindGeneratedLayerNode(node, layerNames) {
577
- if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, layerNames, false);
578
- if (node.type !== "atrule") return false;
579
- if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
580
- if (node.nodes === void 0 || node.nodes.length === 0) return false;
581
- return node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, layerNames));
582
- }
583
- function isWebpackTailwindGeneratedRule(rule, layerNames, includePrefix) {
584
- const selectors = rule.selectors ?? [rule.selector];
585
- if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), includePrefix))) return true;
586
- if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true))) return true;
587
- if (layerNames.includes("theme") && isWebpackTailwindGeneratedThemeRule(rule)) return true;
588
- if (layerNames.includes("base") && isWebpackTailwindGeneratedPreflightRule(rule)) return true;
589
- return false;
590
- }
591
- function isWebpackTailwindGeneratedThemeRule(rule) {
592
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
593
- return declarations.length > 0 && declarations.every((decl) => WEBPACK_TAILWIND_THEME_TOKEN_RE.test(decl.prop) || decl.value.includes("--theme("));
594
- }
595
- function isWebpackTailwindGeneratedPreflightRule(rule) {
596
- const selectors = rule.selectors ?? [rule.selector];
597
- const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
598
- return selectors.length > 0 && declarations.length > 0 && selectors.every((selector) => {
599
- const normalized = selector.trim().replace(/\s+/g, " ");
600
- return WEBPACK_TAILWIND_PREFLIGHT_SELECTORS.has(normalized);
601
- }) && declarations.every((decl) => WEBPACK_TAILWIND_PREFLIGHT_PROPS.has(decl.prop));
602
- }
603
- function isOnlyWebpackTailwindGeneratedPreflightCss(source) {
604
- try {
605
- const nodes = postcss.parse(source).nodes ?? [];
606
- return nodes.length > 0 && nodes.every((node) => {
607
- if (node.type === "rule") return isWebpackTailwindGeneratedPreflightRule(node);
608
- return node.type === "atrule" && (node.nodes === void 0 || node.nodes.length === 0);
609
- });
610
- } catch {
611
- return false;
612
- }
613
- }
614
- function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
615
- return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
616
- }
617
- function collectWebpackCssRuleIdentityMarkers(source) {
618
- const markers = /* @__PURE__ */ new Set();
619
- try {
620
- const root = postcss.parse(source);
621
- root.walkRules((rule) => {
622
- for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
623
- });
624
- root.walkAtRules("keyframes", (rule) => {
625
- if (rule.params) markers.add(`keyframes:${rule.params}`);
626
- });
627
- } catch {}
628
- return markers;
629
- }
630
- function unescapeCssIdentifier(value) {
631
- return value.replace(/\\([0-9a-f]{1,6}\s?|.)/gi, (_match, escaped) => {
632
- const hex = escaped.trim();
633
- if (/^[0-9a-f]+$/i.test(hex)) return String.fromCodePoint(Number.parseInt(hex, 16));
634
- return escaped;
635
- });
636
- }
637
- function collectGeneratedCssRuntimeCandidates(source) {
638
- const candidates = /* @__PURE__ */ new Set();
639
- if (hasBundlerGeneratedCssMarker(source) || !hasTailwindGeneratedCss(source) && !hasTailwindGeneratedCssMarkers(source)) return candidates;
640
- try {
641
- postcss.parse(source).walkRules((rule) => {
642
- for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[\w\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/g)) {
643
- const candidate = unescapeCssIdentifier(match[1]);
644
- if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
645
- }
646
- });
647
- } catch {}
648
- return candidates;
649
- }
650
- function hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource) {
651
- const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
652
- if (rawMarkers.size === 0) return false;
653
- const generatorMarkers = collectWebpackAssetUserCssMarkers(generatorRawSource);
654
- for (const marker of rawMarkers) if (!generatorMarkers.has(marker)) return true;
655
- return false;
656
- }
657
- function hasWebpackTailwindSourceDirectives(source) {
658
- return Boolean(source) && (hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source) || hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source));
659
- }
874
+ //#endregion
875
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.ts
660
876
  function isWebpackTailwindImportRequest(request) {
661
877
  return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/") || request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
662
878
  }
@@ -699,248 +915,41 @@ function createWebpackUserCssSourceAppend(sources, generatorRawSource, currentSo
699
915
  const css = source.css;
700
916
  if (!css || seen.has(css)) continue;
701
917
  if (shouldIncludeSource && !shouldIncludeSource(source.file)) continue;
702
- seen.add(css);
703
- if ((source.processed === true || !css.includes("data:")) && hasAdditionalWebpackAssetUserCssMarkers(css, generatorRawSource)) matchedSources.push({
704
- css,
705
- file: source.file,
706
- processed: source.processed === true
707
- });
708
- }
709
- const currentFile = currentSourceFile ? path.resolve(currentSourceFile) : void 0;
710
- const parts = matchedSources.sort((a, b) => {
711
- const aCurrent = currentFile !== void 0 && path.resolve(a.file) === currentFile;
712
- if (aCurrent !== (currentFile !== void 0 && path.resolve(b.file) === currentFile)) return aCurrent ? -1 : 1;
713
- return a.file.localeCompare(b.file);
714
- }).map((source) => source.css);
715
- return parts.length > 0 ? {
716
- css: parts.join("\n"),
717
- processed: matchedSources.every((source) => source.processed)
718
- } : void 0;
719
- }
720
- function createWebpackGeneratorUserCssSourceAppend(...sources) {
721
- const parts = sources.filter((source) => source !== void 0 && source.css.trim().length > 0);
722
- if (parts.length === 0) return;
723
- let css = "";
724
- const usedParts = [];
725
- for (const source of parts) {
726
- const merged = css.trim().length > 0 ? mergeCoveredCssRuleDeclarations(css, source.css) : void 0;
727
- if (merged?.changed) css = merged.baseCss;
728
- const nextCss = css.trim().length > 0 ? filterExistingCssRules(css, merged?.css ?? source.css) : source.css;
729
- if (!(nextCss.trim().length > 0)) continue;
730
- css = createCssSourceOrderAppend(css, nextCss);
731
- usedParts.push(source);
732
- }
733
- return {
734
- css,
735
- processed: usedParts.every((source) => source.processed)
736
- };
737
- }
738
- function resolveWebpackMemoryDebugStats(context) {
739
- if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
740
- const memory = process.memoryUsage();
741
- const processCacheInstanceSize = context.cache.instance.size;
742
- const processCacheHashMapSize = context.cache.hashMap.size;
743
- return {
744
- phase: context.phase,
745
- process: {
746
- rssMb: toMb(memory.rss),
747
- heapTotalMb: toMb(memory.heapTotal),
748
- heapUsedMb: toMb(memory.heapUsed),
749
- externalMb: toMb(memory.external),
750
- arrayBuffersMb: toMb(memory.arrayBuffers)
751
- },
752
- assets: {
753
- active: context.activeAssetFiles,
754
- activeCss: context.activeCssFiles
755
- },
756
- processCache: {
757
- instance: processCacheInstanceSize,
758
- hashMap: processCacheHashMapSize,
759
- activeCacheKeys: context.activeProcessCacheKeys.size,
760
- activeHashKeys: context.activeProcessHashKeys.size,
761
- staleCacheKeys: Math.max(0, processCacheInstanceSize - context.activeProcessCacheKeys.size),
762
- staleHashKeys: Math.max(0, processCacheHashMapSize - context.activeProcessHashKeys.size),
763
- pruned: true,
764
- pruneSkipped: false
765
- },
766
- webpackCss: {
767
- handlerOptions: context.cssHandlerOptionsCache.size,
768
- userHandlerOptions: context.cssUserHandlerOptionsCache.size,
769
- maxHandlerOptions: WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX
770
- },
771
- sourceCandidateScan: context.sourceCandidateScan,
772
- tailwind: { v4: getTailwindV4IncrementalGenerateCacheStats() }
773
- };
774
- }
775
- function shouldInjectWebpackCssTracePreflight(_appType, cssHandlerOptions) {
776
- if (includesTailwindPreflightImport(cssHandlerOptions.sourceOptions?.sourceCss)) return true;
777
- return cssHandlerOptions.isMainChunk !== false;
778
- }
779
- function includesTailwindPreflightImport(source) {
780
- if (!source) return false;
781
- try {
782
- let includesPreflight = false;
783
- postcss.parse(source).walkAtRules((rule) => {
784
- if (rule.name === "tailwind") {
785
- includesPreflight || (includesPreflight = rule.params.trim() === "base");
786
- return;
787
- }
788
- if (rule.name !== "import") return;
789
- const request = parseImportRequest(rule.params)?.replaceAll("\\", "/");
790
- includesPreflight || (includesPreflight = request === "tailwindcss" || request === "tailwindcss/preflight.css" || request?.endsWith("/tailwindcss/index.css") === true || request?.endsWith("/tailwindcss/preflight.css") === true);
791
- });
792
- return includesPreflight;
793
- } catch {
794
- return false;
795
- }
796
- }
797
- function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
798
- const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
799
- if (isWebGeneratorTarget) return source;
800
- return stripMiniProgramCssSpecificityPlaceholders(removeTailwindV4StandaloneHostPreflightRule(finalizeMiniProgramCss(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
801
- cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0,
802
- isTailwindcssV4: true,
803
- tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
804
- })));
805
- }
806
- function shouldFallbackToWebpackUserCssOnGeneratorError(options) {
807
- return !hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindSourceDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindApplyDirective(options.generatorRawSource) && !options.hasExplicitTailwindV4SourceCss && options.configuredMainCssEntryFilesLength === 0;
808
- }
809
- function isWindowsAbsoluteResourcePath(file) {
810
- return /^[a-z]:[\\/]/i.test(file) || /^[/\\]{2}[^/\\]/.test(file);
811
- }
812
- function isPosixAbsoluteResourcePath(file) {
813
- return file.startsWith("/");
814
- }
815
- function resolveWebpackResourcePath(file, base) {
816
- if (isWindowsAbsoluteResourcePath(file)) return path.win32.resolve(file);
817
- if (isPosixAbsoluteResourcePath(file)) return path.posix.resolve(file);
818
- if (base) {
819
- if (isWindowsAbsoluteResourcePath(base)) return path.win32.resolve(base, file);
820
- if (isPosixAbsoluteResourcePath(base)) return path.posix.resolve(base, file);
821
- return path.resolve(base, file);
822
- }
823
- }
824
- function dirnameWebpackResourcePath(file) {
825
- if (isWindowsAbsoluteResourcePath(file)) return path.win32.dirname(file);
826
- if (isPosixAbsoluteResourcePath(file)) return path.posix.dirname(file);
827
- return path.dirname(file);
828
- }
829
- function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
830
- if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
831
- const normalized = stripResourceQuery(resource);
832
- if (!normalized) return;
833
- const absoluteResource = resolveWebpackResourcePath(normalized);
834
- if (absoluteResource) return absoluteResource;
835
- const issuerResource = issuer?.resource ? stripResourceQuery(issuer.resource) : void 0;
836
- const issuerResourcePath = issuerResource ? resolveWebpackResourcePath(issuerResource) : void 0;
837
- return resolveWebpackResourcePath(normalized, issuerResourcePath ? dirnameWebpackResourcePath(issuerResourcePath) : issuer?.context);
838
- }
839
- function isSameWebpackCssSourceScope(options) {
840
- if (!options.currentSourceFile) return false;
841
- const candidateKey = resolveWebpackResourcePath(options.candidateSourceFile) ?? path.resolve(options.candidateSourceFile);
842
- if (candidateKey === (resolveWebpackResourcePath(options.currentSourceFile) ?? path.resolve(options.currentSourceFile))) return true;
843
- const outputResources = options.resourcesByAsset.get(options.outputFile);
844
- if (!outputResources) return false;
845
- return [...outputResources].some((resource) => {
846
- return (resolveWebpackResourcePath(resource) ?? path.resolve(resource)) === candidateKey;
847
- });
848
- }
849
- function shouldAppendCurrentWebpackAssetUserCss(options) {
850
- const hasGeneratedAssetUserCss = options.currentAssetLooksGenerated && options.currentAssetHasUserCss;
851
- return !options.currentAssetHasBundlerGeneratedMarker && !options.shouldPreserveGeneratedWebAssetUserCss && (hasGeneratedAssetUserCss || !options.sourceCssProcessed || options.registeredUserRawSource === void 0 || options.currentAssetHasUserCss) && !(options.sourceCssProcessed && options.currentAssetLooksGenerated && !options.currentAssetHasUserCss);
852
- }
853
- function createWebpackCurrentAssetUserRawSource(options) {
854
- if (!options.shouldAppendCurrentAssetUserCss) return;
855
- if (options.sourceCssProcessed) return {
856
- css: options.currentAssetUserCssSource,
857
- processed: true
858
- };
859
- if (!options.currentAssetHasUserCss) return;
860
- return {
861
- css: options.currentAssetUserCssSource,
862
- processed: options.currentAssetLooksGenerated
863
- };
864
- }
865
- function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
866
- if (options.finalized === true) return options.annotateCss(css);
867
- if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return options.annotateCss(css);
868
- const finalized = finalizeMiniProgramUserCssAssetSource(css, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
869
- return options.annotateCss(finalized);
870
- }
871
- function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
872
- const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
873
- if (isWebGeneratorTarget) {
874
- if (options.generatedCss === true) return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(stripBundlerGeneratedCssMarkers(source))));
875
- return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
876
- }
877
- let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
878
- if (options.generatedCss !== true) {
879
- finalized = finalizeMiniProgramCss(finalized, {
880
- cssPreflight: false,
881
- isTailwindcssV4: true,
882
- tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
883
- });
884
- finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
885
- return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
886
- }
887
- try {
888
- finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: options.cssPreflight !== false });
889
- } catch {}
890
- const shouldRemoveExistingPreflight = options.cssPreflight === false && options.preserveExistingPreflight === false;
891
- if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
892
- const hasExistingMiniProgramPreflight = options.preserveExistingPreflight !== false && hasMiniProgramPreflightSelector(source);
893
- finalized = finalizeMiniProgramCss(finalized, {
894
- cssPreflight: options.cssPreflight === false && !hasExistingMiniProgramPreflight ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) : void 0,
895
- isTailwindcssV4: true,
896
- tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
897
- });
898
- finalized = ensureWebpackMiniProgramTwContentInit(finalized);
899
- if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
900
- else finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
901
- return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
902
- }
903
- function finalizeWebpackCssAssetOutputSource(source, compilerOptions, isWebGeneratorTarget) {
904
- if (isWebGeneratorTarget) return source;
905
- const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
906
- return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(dedupeCoveredCssRules(dedupeMiniProgramPreflightSelectorRules(source)), styleOptions.cssRemoveHoverPseudoClass));
907
- }
908
- function collectWebpackJsRuntimeCandidatesFromAssets(options) {
909
- if (options.isWebGeneratorTarget) return;
910
- const candidates = /* @__PURE__ */ new Set();
911
- for (const file of options.jsAssets) {
912
- const sourceLike = options.getAssetSource(file);
913
- if (sourceLike === void 0) continue;
914
- const source = stringifyWebpackSourceLike(sourceLike);
915
- for (const candidate of collectStrictEscapedRuntimeCandidates(source, MappingChars2String, options.escapeFragments)) if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
916
- }
917
- return candidates;
918
- }
919
- function collectWebpackJsRuntimeTokenSignature(options) {
920
- if (options.isWebGeneratorTarget) return "";
921
- const tokens = [];
922
- for (const file of options.jsAssets) {
923
- const sourceLike = options.getAssetSource(file);
924
- if (sourceLike === void 0) continue;
925
- tokens.push(...collectRuntimeTokenSignatureParts(stringifyWebpackSourceLike(sourceLike)));
926
- }
927
- return tokens.sort().join("\n");
928
- }
929
- function addRuntimeTransformCandidates(target, candidates) {
930
- if (!candidates?.size) return;
931
- for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate)) target.add(candidate);
932
- }
933
- function createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates) {
934
- if (!isCssSourceTraceEnabled(compilerOptions) || !webpackSourceCandidates) return;
935
- return createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions);
936
- }
937
- function stringifyOptionalWebpackSourceValue(value) {
938
- return typeof value === "string" ? value : value?.toString() ?? "";
918
+ seen.add(css);
919
+ if ((source.processed === true || !css.includes("data:")) && hasAdditionalWebpackAssetUserCssMarkers(css, generatorRawSource)) matchedSources.push({
920
+ css,
921
+ file: source.file,
922
+ processed: source.processed === true
923
+ });
924
+ }
925
+ const currentFile = currentSourceFile ? path.resolve(currentSourceFile) : void 0;
926
+ const parts = matchedSources.sort((a, b) => {
927
+ const aCurrent = currentFile !== void 0 && path.resolve(a.file) === currentFile;
928
+ if (aCurrent !== (currentFile !== void 0 && path.resolve(b.file) === currentFile)) return aCurrent ? -1 : 1;
929
+ return a.file.localeCompare(b.file);
930
+ }).map((source) => source.css);
931
+ return parts.length > 0 ? {
932
+ css: parts.join("\n"),
933
+ processed: matchedSources.every((source) => source.processed)
934
+ } : void 0;
939
935
  }
940
- function stringifyWebpackSourceLike(source) {
941
- if (typeof source === "string") return source;
942
- const value = source.source();
943
- return typeof value === "string" ? value : value.toString();
936
+ function createWebpackGeneratorUserCssSourceAppend(...sources) {
937
+ const parts = sources.filter((source) => source !== void 0 && source.css.trim().length > 0);
938
+ if (parts.length === 0) return;
939
+ let css = "";
940
+ const usedParts = [];
941
+ for (const source of parts) {
942
+ const merged = css.trim().length > 0 ? mergeCoveredCssRuleDeclarations(css, source.css) : void 0;
943
+ if (merged?.changed) css = merged.baseCss;
944
+ const nextCss = css.trim().length > 0 ? filterExistingCssRules(css, merged?.css ?? source.css) : source.css;
945
+ if (!(nextCss.trim().length > 0)) continue;
946
+ css = createCssSourceOrderAppend(css, nextCss);
947
+ usedParts.push(source);
948
+ }
949
+ return {
950
+ css,
951
+ processed: usedParts.every((source) => source.processed)
952
+ };
944
953
  }
945
954
  //#endregion
946
955
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.ts
@@ -1196,89 +1205,395 @@ function createWebpackCssSourceResolvers(options) {
1196
1205
  };
1197
1206
  }
1198
1207
  //#endregion
1199
- //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.ts
1200
- function createChangedByType() {
1201
- return {
1202
- html: /* @__PURE__ */ new Set(),
1203
- js: /* @__PURE__ */ new Set(),
1204
- css: /* @__PURE__ */ new Set(),
1205
- other: /* @__PURE__ */ new Set()
1206
- };
1208
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.ts
1209
+ async function finalizeWebpackProcessAssets(context) {
1210
+ const { activeProcessCacheKeys, activeProcessHashKeys, activeWebpackCssSourceFiles, compilerOptions, cssAssetResources, cssHandlerOptionsCache, cssTaskFactories, cssUserHandlerOptionsCache, debug, entries, groupedEntries, hmrTimingStartedAt, htmlTaskFactories, jsTaskFactories, pruneWebpackCssSources, recordTimingDetail, registeredWebpackCssSourceFiles, taskConcurrency, tasks, timingDetails, watchMode, webpackSourceCandidateScanCache } = context;
1211
+ if (!watchMode) {
1212
+ pushConcurrentTaskFactories(tasks, htmlTaskFactories, taskConcurrency);
1213
+ await Promise.all(tasks);
1214
+ tasks.length = 0;
1215
+ pushConcurrentTaskFactories(tasks, jsTaskFactories, taskConcurrency);
1216
+ await Promise.all(tasks);
1217
+ tasks.length = 0;
1218
+ pushConcurrentTaskFactories(tasks, cssTaskFactories, taskConcurrency);
1219
+ }
1220
+ const taskWaitStartedAt = performance.now();
1221
+ await Promise.all(tasks);
1222
+ recordTimingDetail("tasks.wait", taskWaitStartedAt);
1223
+ const pruneStartedAt = performance.now();
1224
+ compilerOptions.cache.prune?.({
1225
+ cacheKeys: activeProcessCacheKeys,
1226
+ hashKeys: activeProcessHashKeys
1227
+ });
1228
+ const activeCssFiles = new Set(groupedEntries.css.map(([file]) => file));
1229
+ pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
1230
+ if (activeCssFiles.size > 0) pruneWebpackCssSources?.(/* @__PURE__ */ new Set([
1231
+ ...registeredWebpackCssSourceFiles,
1232
+ ...activeWebpackCssSourceFiles,
1233
+ ...[...cssAssetResources.values()].flatMap((resources) => [...resources])
1234
+ ]), { watchMode });
1235
+ recordTimingDetail("cache.prune", pruneStartedAt);
1236
+ debug("end");
1237
+ emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, {
1238
+ ...timingDetails,
1239
+ memoryDebug: resolveWebpackMemoryDebugStats({
1240
+ activeAssetFiles: entries.length,
1241
+ activeCssFiles: activeCssFiles.size,
1242
+ activeProcessCacheKeys,
1243
+ activeProcessHashKeys,
1244
+ cache: compilerOptions.cache,
1245
+ cssHandlerOptionsCache,
1246
+ cssUserHandlerOptionsCache,
1247
+ phase: "processAssets",
1248
+ sourceCandidateScan: webpackSourceCandidateScanCache.getMemoryStats()
1249
+ })
1250
+ });
1251
+ compilerOptions.onEnd();
1207
1252
  }
1208
- function createProcessFiles() {
1209
- return {
1210
- html: /* @__PURE__ */ new Set(),
1211
- js: /* @__PURE__ */ new Set(),
1212
- css: /* @__PURE__ */ new Set()
1253
+ //#endregion
1254
+ //#region src/bundlers/webpack/shared/css-loader-runtime.ts
1255
+ function isWebpackCssLoaderRuntimeSource(source) {
1256
+ return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && source.includes("module.exports = ___CSS_LOADER_EXPORT___");
1257
+ }
1258
+ //#endregion
1259
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.ts
1260
+ async function finalizeWebpackGeneratedCssResult(context) {
1261
+ const { ConcatSource, compilerOptions, cssHandlerOptions, currentRawSource, debug, file, finalizeCssAssetSource, finalizeTracedCss, generated, generatorRawSource, generatorRuntimeSet, isWebGeneratorTarget, runtimeState, shouldPreserveExistingPreflight, sourceCss, sourceCssProcessed, userRawSource } = context;
1262
+ const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
1263
+ css: generated.css,
1264
+ processed: true
1265
+ }, {
1266
+ css: removeWebpackTailwindGeneratedAssetCss(currentRawSource),
1267
+ processed: true
1268
+ })?.css ?? generated.css : generated.css, {
1269
+ cssPreflight: cssHandlerOptions.isMainChunk,
1270
+ generatedCss: true,
1271
+ preserveExistingPreflight: shouldPreserveExistingPreflight
1272
+ }) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
1273
+ const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
1274
+ userRawSource,
1275
+ sourceCss === void 0 ? void 0 : {
1276
+ css: sourceCss,
1277
+ processed: sourceCssProcessed
1278
+ },
1279
+ {
1280
+ css: generatorRawSource,
1281
+ processed: false
1282
+ }
1283
+ ].map((source) => {
1284
+ if (source === void 0) return;
1285
+ return {
1286
+ css: collectWebpackBareSelectorUserCss(source.css),
1287
+ processed: source.processed
1288
+ };
1289
+ }));
1290
+ const handledSourceBareUserCss = sourceBareUserCss === void 0 ? "" : sourceBareUserCss.processed ? sourceBareUserCss.css : (await compilerOptions.styleHandler(sourceBareUserCss.css, cssHandlerOptions)).css;
1291
+ const finalizedSourceBareUserCss = handledSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledSourceBareUserCss, {
1292
+ cssPreflight: false,
1293
+ generatedCss: false
1294
+ });
1295
+ const missingSourceBareUserCss = finalizedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedGeneratedCss, finalizedSourceBareUserCss);
1296
+ const source = new ConcatSource(finalizeTracedCss(missingSourceBareUserCss.trim().length === 0 ? finalizedGeneratedCss : createWebpackGeneratorUserCssSourceAppend({
1297
+ css: finalizedGeneratedCss,
1298
+ processed: true
1299
+ }, {
1300
+ css: missingSourceBareUserCss,
1301
+ processed: true
1302
+ }).css, cssHandlerOptions, { finalized: true }));
1303
+ if (generated) {
1304
+ for (const className of generated.classSet) generatorRuntimeSet.add(className);
1305
+ debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
1306
+ } else debug("css handle: %s", file);
1307
+ return { result: source };
1308
+ }
1309
+ //#endregion
1310
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.ts
1311
+ async function processWebpackGeneratedCssAsset(element, context) {
1312
+ const { ConcatSource, affectedCompilationScopes, assetHashByChunk, compilation, compilationChanges, compilerOptions, configuredCssEntryFiles, configuredMainCssEntryFiles, createRuntimeSetHash, cssSourceTraceSignature, cssSources, cssTaskFactories, debug, enqueueTask, finalizeCssAssetSource, finalizeTracedCss, generatedCssSources, generatorRuntimeSet, getCompilationDependencyRevision, getCssHandlerOptions, getCssUserHandlerOptions, getGeneratorRuntimeSet, hasConfiguredTailwindV4SourceRoots, isSameWebpackSourceScope, isWebGeneratorTarget, rememberProcessCacheKey, resolveWebpackCssSourceFile, runtimeAffectingSourceHash, runtimeState, transformRuntimeSet, updateAssetIfChanged, watchMode, webpackSourceCandidateValueSignature, webpackSourceCandidates } = context;
1313
+ const [file, originalSource] = element;
1314
+ const currentRawSource = originalSource.source().toString();
1315
+ const chunkHash = assetHashByChunk.get(file);
1316
+ const cacheKey = file;
1317
+ const hashKey = `${file}:asset`;
1318
+ rememberProcessCacheKey(cacheKey, hashKey);
1319
+ const cssHandlerOptionsForHash = getCssHandlerOptions(file, currentRawSource);
1320
+ const compilationScope = {
1321
+ id: file,
1322
+ kind: cssHandlerOptionsForHash.isMainChunk ? "global" : "component"
1213
1323
  };
1324
+ const scopeCompilationChanges = affectedCompilationScopes.has(compilationScope.id) ? compilationChanges : void 0;
1325
+ const compilationDependencyRevision = getCompilationDependencyRevision(compilationScope.id);
1326
+ const cssChunkHash = watchMode && cssHandlerOptionsForHash.isMainChunk ? void 0 : chunkHash;
1327
+ const cssSourceHash = (() => {
1328
+ const sourceFile = resolveWebpackCssSourceFile(file, currentRawSource);
1329
+ const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
1330
+ const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
1331
+ if (sourceCss === void 0) return sourceFile === void 0 ? "webpack-css-source:0" : `webpack-css-source:0:${sourceFile}`;
1332
+ return `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}:${generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss)}`;
1333
+ })();
1334
+ const runtimeAwareHash = createRuntimeAwareCssHash(cssChunkHash, compilerOptions.cache.computeHash(currentRawSource), `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}:${cssSourceHash}:compiler-dependencies:${compilationDependencyRevision}`);
1335
+ await enqueueTask(async () => {
1336
+ await processCachedTask({
1337
+ cache: compilerOptions.cache,
1338
+ cacheKey,
1339
+ hashKey,
1340
+ rawSource: currentRawSource,
1341
+ hash: runtimeAwareHash,
1342
+ applyResult(source, { cacheHit }) {
1343
+ updateAssetIfChanged(file, source, {
1344
+ compare: !cacheHit,
1345
+ notifyUpdate: !cacheHit
1346
+ });
1347
+ },
1348
+ onCacheHit() {
1349
+ debug("css cache hit: %s", file);
1350
+ },
1351
+ transform: async () => {
1352
+ await runtimeState.readyPromise;
1353
+ const cssHandlerOptions = getCssHandlerOptions(file, currentRawSource);
1354
+ const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
1355
+ if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
1356
+ const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
1357
+ const sourceCss = sourceFile ? cssSources.get(path.resolve(sourceFile))?.css : void 0;
1358
+ const isConfiguredCssSource = sourceFile !== void 0 && configuredCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
1359
+ const isConfiguredMainCssSource = sourceFile !== void 0 && configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
1360
+ const sourceCssHasTailwindRoot = sourceCss !== void 0 && hasTailwindRootDirectives(sourceCss, { importFallback: true });
1361
+ const shouldPreserveExistingPreflight = cssHandlerOptions.isMainChunk || !isConfiguredMainCssSource && (isConfiguredCssSource || sourceCssHasTailwindRoot);
1362
+ const loaderGeneratedCss = sourceFile ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
1363
+ const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
1364
+ const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await resolveTailwindV4EntriesFromCssCached(sourceCss, path.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
1365
+ if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
1366
+ allowMarkerlessRegistryMatch: configuredCssEntryFiles.length === 1,
1367
+ hasBundlerGeneratedCssMarker: hasBundlerGeneratedCssMarker(currentRawSource),
1368
+ loaderGeneratedClassSet: loaderGeneratedCss.classSet,
1369
+ sourceCandidates: explicitTailwindV4SourceCandidates,
1370
+ shouldRegenerateExplicitTailwindV4CssSource,
1371
+ watchMode
1372
+ })) {
1373
+ for (const className of loaderGeneratedCss.classSet) {
1374
+ generatorRuntimeSet.add(className);
1375
+ transformRuntimeSet.add(className);
1376
+ }
1377
+ for (const dependency of loaderGeneratedCss.dependencies) compilation.fileDependencies?.add?.(dependency);
1378
+ const currentRawSourceWithoutBundlerMarkers = stripBundlerGeneratedCssMarkers(currentRawSource);
1379
+ const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
1380
+ const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
1381
+ const loaderGeneratedCssWithoutMarkers = stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
1382
+ const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : stripBundlerGeneratedCssMarkers(currentAssetUserCss);
1383
+ const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : filterExistingCssRules(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
1384
+ if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk) {
1385
+ debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
1386
+ const userCss = currentAssetMissingUserCss.trim().length === 0 || isCommentOnlyCss(currentAssetMissingUserCss) ? "" : finalizeCssAssetSource(currentAssetMissingUserCss, {
1387
+ cssPreflight: false,
1388
+ generatedCss: false
1389
+ });
1390
+ return { result: new ConcatSource(finalizeTracedCss(userCss, cssHandlerOptions)) };
1391
+ }
1392
+ const mergedLoaderCss = currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
1393
+ css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : filterExistingCssRules(currentAssetUserCss, loaderGeneratedCss.css),
1394
+ processed: true
1395
+ }, currentAssetUserCss === void 0 ? void 0 : {
1396
+ css: currentAssetUserCss,
1397
+ processed: true
1398
+ }).css;
1399
+ const handledLoaderCss = isWebGeneratorTarget ? mergedLoaderCss : (await compilerOptions.styleHandler(mergedLoaderCss, cssHandlerOptions)).css;
1400
+ const finalizedLoaderCss = finalizeCssAssetSource(handledLoaderCss, {
1401
+ cssPreflight: cssHandlerOptions.isMainChunk,
1402
+ generatedCss: true,
1403
+ preserveExistingPreflight: shouldPreserveExistingPreflight
1404
+ });
1405
+ const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
1406
+ css: currentAssetUserCss,
1407
+ processed: true
1408
+ }, sourceCss === void 0 ? void 0 : {
1409
+ css: sourceCss,
1410
+ processed: false
1411
+ }].map((source) => {
1412
+ if (source === void 0) return;
1413
+ return {
1414
+ css: collectWebpackBareSelectorUserCss(source.css),
1415
+ processed: source.processed
1416
+ };
1417
+ }));
1418
+ const handledLoaderSourceBareUserCss = loaderSourceBareUserCss === void 0 ? "" : loaderSourceBareUserCss.processed ? loaderSourceBareUserCss.css : (await compilerOptions.styleHandler(loaderSourceBareUserCss.css, cssHandlerOptions)).css;
1419
+ const finalizedLoaderSourceBareUserCss = handledLoaderSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledLoaderSourceBareUserCss, {
1420
+ cssPreflight: false,
1421
+ generatedCss: false
1422
+ });
1423
+ const missingLoaderSourceBareUserCss = finalizedLoaderSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedLoaderCss, finalizedLoaderSourceBareUserCss);
1424
+ const css = finalizeTracedCss(missingLoaderSourceBareUserCss.trim().length === 0 ? finalizedLoaderCss : createWebpackGeneratorUserCssSourceAppend({
1425
+ css: finalizedLoaderCss,
1426
+ processed: true
1427
+ }, {
1428
+ css: missingLoaderSourceBareUserCss,
1429
+ processed: true
1430
+ }).css, cssHandlerOptions, { finalized: true });
1431
+ debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
1432
+ return { result: new ConcatSource(css) };
1433
+ }
1434
+ const sourceCssProcessed = sourceFile ? cssSources.get(path.resolve(sourceFile))?.processed === true : false;
1435
+ const registeredUserRawSource = createWebpackUserCssSourceAppend([...cssSources.entries()].map(([registeredSourceFile, source]) => ({
1436
+ ...source,
1437
+ file: registeredSourceFile
1438
+ })), generatorRawSource, sourceFile, (registeredSourceFile) => isSameWebpackSourceScope(file, registeredSourceFile, sourceFile));
1439
+ const currentAssetLooksGenerated = hasTailwindGeneratedCss(currentRawSource) || hasTailwindGeneratedCssMarkers(currentRawSource);
1440
+ const currentAssetHasBundlerGeneratedMarker = hasBundlerGeneratedCssMarker(currentRawSource);
1441
+ const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
1442
+ if (sourceFile === void 0 && currentAssetHasBundlerGeneratedMarker && (currentAssetUserCssSource.trim().length === 0 || isCommentOnlyCss(currentAssetUserCssSource))) return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
1443
+ const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
1444
+ const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
1445
+ const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
1446
+ const currentAssetHasUserCss = (sourceCssProcessed || hasExplicitSourceCssForCurrentAsset) && currentAssetLooksGenerated && !shouldPreserveGeneratedWebAssetUserCss ? currentAssetHasAdditionalUserCss : shouldUseWebpackAssetAsGeneratorUserCss(currentAssetUserCssSource, generatorRawSource, { processed: sourceCssProcessed || shouldPreserveGeneratedWebAssetUserCss });
1447
+ const userRawSource = createWebpackGeneratorUserCssSourceAppend(createWebpackCurrentAssetUserRawSource({
1448
+ currentAssetHasUserCss,
1449
+ currentAssetLooksGenerated,
1450
+ currentAssetUserCssSource,
1451
+ shouldAppendCurrentAssetUserCss: shouldAppendCurrentWebpackAssetUserCss({
1452
+ currentAssetHasBundlerGeneratedMarker,
1453
+ currentAssetHasUserCss,
1454
+ currentAssetLooksGenerated,
1455
+ registeredUserRawSource,
1456
+ shouldPreserveGeneratedWebAssetUserCss,
1457
+ sourceCssProcessed
1458
+ }),
1459
+ sourceCssProcessed
1460
+ }), registeredUserRawSource);
1461
+ if (isPureLocalCssImportWrapper(currentRawSource)) return { result: new ConcatSource(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
1462
+ const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
1463
+ const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
1464
+ const currentAssetHasTailwindDirectives = hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || hasTailwindApplyDirective(generatorRawSource);
1465
+ const shouldForceTailwindV4Generation = hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 && sourceFile !== void 0 || currentAssetHasTailwindDirectives || hasExplicitTailwindV4SourceCss);
1466
+ const shouldSkipUnmatchedMainCssGeneration = !isWebGeneratorTarget && cssHandlerOptions.isMainChunk && sourceFile === void 0 && configuredMainCssEntryFiles.length > 0 && !currentAssetHasTailwindDirectives;
1467
+ const shouldSkipPlainNonMainCssGeneration = !cssHandlerOptions.isMainChunk && sourceCss !== void 0 && !hasExplicitSourceCssForCurrentAsset && !hasExplicitTailwindV4SourceCss && !currentAssetHasTailwindDirectives;
1468
+ const shouldMergeFallbackGeneratorRuntime = cssHandlerOptions.isMainChunk || currentAssetHasTailwindDirectives || hasExplicitSourceCssForCurrentAsset;
1469
+ const scopedFallbackGeneratorRuntimeSet = hasExplicitTailwindV4SourceCss || !shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet;
1470
+ const resolvedScopedGeneratorRuntimeSet = await createScopedGeneratorRuntime({
1471
+ cssHandlerOptions,
1472
+ fallbackRuntime: scopedFallbackGeneratorRuntimeSet,
1473
+ getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
1474
+ majorVersion: runtimeState.tailwindRuntime.majorVersion,
1475
+ outputFile: file,
1476
+ rawSource: sourceFile ? cssSources.get(path.resolve(sourceFile))?.css ?? generatorRawSource : generatorRawSource,
1477
+ shouldExcludeSubpackageSourceCandidates: () => false,
1478
+ sourceFile: sourceFile ?? file,
1479
+ scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
1480
+ });
1481
+ const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== scopedFallbackGeneratorRuntimeSet && shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
1482
+ const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
1483
+ const scopedGeneratorCompilerOptions = scopeWebpackGeneratorOptionsToCssSource(compilerOptions, sourceFile, { disableUnmatchedCssEntries: !isWebGeneratorTarget && cssHandlerOptions.isMainChunk });
1484
+ const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
1485
+ ...cssHandlerOptions,
1486
+ sourceOptions: {
1487
+ ...cssHandlerOptions.sourceOptions,
1488
+ cssSources: generatorCssSources
1489
+ }
1490
+ };
1491
+ const generatorOptions = {
1492
+ opts: scopedGeneratorCompilerOptions,
1493
+ runtimeState,
1494
+ runtime: scopedGeneratorRuntimeSet,
1495
+ rawSource: generatorRawSource,
1496
+ forceGenerator: shouldForceTailwindV4Generation,
1497
+ ...hasUsableWebpackGeneratorCssSources(generatorCssSources) ? { cssSources: generatorCssSources } : {},
1498
+ ...userRawSource === void 0 ? {} : { userRawSource: userRawSource.css },
1499
+ ...userRawSource?.processed === true ? { userRawSourceProcessed: true } : {},
1500
+ file,
1501
+ cssHandlerOptions: generatorCssHandlerOptions,
1502
+ cssUserHandlerOptions: getCssUserHandlerOptions(file),
1503
+ compilationChanges: scopeCompilationChanges,
1504
+ frameworkPostcssOwner: compilerOptions,
1505
+ cssStage: "framework-processed",
1506
+ getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
1507
+ sourceCandidates: scopedGeneratorRuntimeSet,
1508
+ restoreLocalCssImports: false,
1509
+ scope: compilationScope,
1510
+ styleHandler: compilerOptions.styleHandler,
1511
+ debug
1512
+ };
1513
+ let generated;
1514
+ if (!shouldSkipUnmatchedMainCssGeneration && !shouldSkipPlainNonMainCssGeneration) try {
1515
+ generated = await generateTailwindV4Css({
1516
+ ...generatorOptions,
1517
+ outputFile: file
1518
+ });
1519
+ } catch (error) {
1520
+ if (!shouldFallbackToWebpackUserCssOnGeneratorError({
1521
+ configuredMainCssEntryFilesLength: configuredMainCssEntryFiles.length,
1522
+ generatorRawSource,
1523
+ hasExplicitTailwindV4SourceCss
1524
+ })) throw error;
1525
+ debug("css generator skipped for plain webpack css asset: %s %O", file, error);
1526
+ generated = void 0;
1527
+ }
1528
+ else debug("css generator skipped for plain webpack css asset: %s", file);
1529
+ for (const dependency of generated?.dependencies ?? []) compilation.fileDependencies?.add?.(dependency);
1530
+ return finalizeWebpackGeneratedCssResult({
1531
+ ConcatSource,
1532
+ compilerOptions,
1533
+ cssHandlerOptions,
1534
+ currentRawSource,
1535
+ debug,
1536
+ file,
1537
+ finalizeCssAssetSource,
1538
+ finalizeTracedCss,
1539
+ generated,
1540
+ generatorRawSource,
1541
+ generatorRuntimeSet,
1542
+ isWebGeneratorTarget,
1543
+ runtimeState,
1544
+ shouldPreserveExistingPreflight,
1545
+ sourceCss,
1546
+ sourceCssProcessed,
1547
+ userRawSource
1548
+ });
1549
+ }
1550
+ });
1551
+ }, cssTaskFactories, "tasks.css");
1214
1552
  }
1215
- function markProcessFile(type, file, processFiles) {
1216
- if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
1553
+ //#endregion
1554
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/asset-emission-plan.ts
1555
+ function applyWebpackAssetEmissionPlan(plan, options) {
1556
+ for (const operation of plan.operations()) {
1557
+ if (operation.kind === "delete") {
1558
+ options.compilation.deleteAsset?.(operation.assetId);
1559
+ continue;
1560
+ }
1561
+ const source = typeof operation.source === "string" ? new options.ConcatSource(operation.source) : operation.source;
1562
+ if (options.writeMode !== "update" && !options.compilation.getAsset(operation.assetId)) {
1563
+ if (options.compilation.emitAsset) {
1564
+ options.compilation.emitAsset(operation.assetId, source);
1565
+ continue;
1566
+ }
1567
+ }
1568
+ options.compilation.updateAsset(operation.assetId, source);
1569
+ }
1217
1570
  }
1218
- function buildWebpackBundleSnapshot(assets, opts, state, compilation) {
1219
- const sourceHashByFile = /* @__PURE__ */ new Map();
1220
- const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
1221
- const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
1222
- const changedByType = createChangedByType();
1223
- const runtimeAffectingChangedByType = createChangedByType();
1224
- const processFiles = createProcessFiles();
1571
+ //#endregion
1572
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.ts
1573
+ function buildWebpackBundleSnapshot(assets, opts, state, compilation, options = {}) {
1225
1574
  const entries = [];
1226
- const firstRun = state.iteration === 0 && state.sourceHashByFile.size === 0;
1227
1575
  for (const [file, asset] of Object.entries(assets)) {
1228
- const type = classifyBundleEntry(file, opts);
1576
+ const type = classifyRuntimeEntry(file, opts);
1229
1577
  if (type !== "html" && type !== "js") continue;
1230
1578
  const source = stringifyWebpackSource(compilation?.getAsset(file)?.source.source() ?? asset.source());
1231
- const hash = opts.cache.computeHash(source);
1232
- sourceHashByFile.set(file, hash);
1233
- const previousHash = state.sourceHashByFile.get(file);
1234
- const changed = previousHash == null || previousHash !== hash;
1235
- const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
1236
- const runtimeAffectingHash = !changed && previousRuntimeAffectingHash != null ? previousRuntimeAffectingHash : (() => {
1237
- const runtimeAffectingSignature = createRuntimeAffectingSourceSignature(source, type);
1238
- runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
1239
- return opts.cache.computeHash(runtimeAffectingSignature);
1240
- })();
1241
- runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
1242
- if (changed) changedByType[type].add(file);
1243
- if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
1244
- if (firstRun) markProcessFile(type, file, processFiles);
1245
- else if (type === "html") processFiles.html.add(file);
1246
- else if (changed) processFiles.js.add(file);
1247
1579
  entries.push({
1248
1580
  file,
1249
- output: {
1250
- fileName: file,
1251
- name: void 0,
1252
- names: [],
1253
- needsCodeReference: false,
1254
- originalFileName: null,
1255
- originalFileNames: [],
1256
- source,
1257
- type: "asset"
1258
- },
1581
+ runtimeCandidate: true,
1259
1582
  source,
1260
1583
  type
1261
1584
  });
1262
1585
  }
1263
- return {
1264
- entries,
1265
- jsEntries: /* @__PURE__ */ new Map(),
1266
- sourceHashByFile,
1267
- runtimeAffectingSignatureByFile,
1268
- runtimeAffectingHashByFile,
1269
- hasOmittedKnownFiles: false,
1270
- changedByType,
1271
- runtimeAffectingChangedByType,
1272
- processFiles,
1273
- linkedImpactsByEntry: /* @__PURE__ */ new Map()
1274
- };
1586
+ const currentFiles = new Set(entries.map((entry) => entry.file));
1587
+ const removedFiles = new Set(options.removedFiles);
1588
+ for (const file of state.sourceHashByFile.keys()) if (!currentFiles.has(file)) removedFiles.add(file);
1589
+ return buildRuntimeCompilationSnapshot(entries, state, {
1590
+ computeHash: (source) => opts.cache.computeHash(source),
1591
+ createRuntimeAffectingSignature: createRuntimeAffectingSourceSignature,
1592
+ removedFiles
1593
+ });
1275
1594
  }
1276
1595
  function releaseWebpackBundleSnapshotSources(snapshot) {
1277
- for (const entry of snapshot.entries) {
1278
- entry.source = "";
1279
- if (entry.output.type === "asset") entry.output.source = "";
1280
- else entry.output.code = "";
1281
- }
1596
+ for (const entry of snapshot.entries) entry.source = "";
1282
1597
  }
1283
1598
  function stringifyWebpackSource(source) {
1284
1599
  if (typeof source === "string") return source;
@@ -1291,8 +1606,14 @@ function createWebpackAssetUpdater(options) {
1291
1606
  return stringifyWebpackSource(asset.source.source());
1292
1607
  };
1293
1608
  const updateAssetIfChanged = (file, source, { compare = true, notifyUpdate = true } = {}) => {
1609
+ const plan = new AssetEmissionPlan();
1610
+ plan.write(file, source);
1294
1611
  if (!compare) {
1295
- options.compilation.updateAsset(file, typeof source === "string" ? new options.ConcatSource(source) : source);
1612
+ applyWebpackAssetEmissionPlan(plan, {
1613
+ compilation: options.compilation,
1614
+ ConcatSource: options.ConcatSource,
1615
+ writeMode: "update"
1616
+ });
1296
1617
  return true;
1297
1618
  }
1298
1619
  const nextSource = typeof source === "string" ? source : stringifyWebpackSource(source.source());
@@ -1301,7 +1622,11 @@ function createWebpackAssetUpdater(options) {
1301
1622
  options.debug("asset unchanged, skip update: %s", file);
1302
1623
  return false;
1303
1624
  }
1304
- options.compilation.updateAsset(file, typeof source === "string" ? new options.ConcatSource(source) : source);
1625
+ applyWebpackAssetEmissionPlan(plan, {
1626
+ compilation: options.compilation,
1627
+ ConcatSource: options.ConcatSource,
1628
+ writeMode: "update"
1629
+ });
1305
1630
  if (notifyUpdate) options.onUpdate(file, previousSource ?? "", nextSource);
1306
1631
  return true;
1307
1632
  };
@@ -1311,6 +1636,114 @@ function createWebpackAssetUpdater(options) {
1311
1636
  };
1312
1637
  }
1313
1638
  //#endregion
1639
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.ts
1640
+ async function enqueueWebpackHtmlAndJsTasks(context) {
1641
+ const { ConcatSource, applyWebpackLinkedJsResults, assetHashByChunk, compilation, compilerOptions, debug, defaultTemplateHandlerOptions, enqueueTask, groupedEntries, isWebGeneratorTarget, jsAssets, moduleGraphOptions, outputDir, rememberProcessCacheKey, rememberTransformedRuntimeCandidates, runtimeState, transformRuntimeSet, updateAssetIfChanged, watchMode } = context;
1642
+ const htmlTaskFactories = [];
1643
+ if (!isWebGeneratorTarget && Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
1644
+ const [file, originalSource] = element;
1645
+ let rawSource;
1646
+ const readRawSource = () => {
1647
+ rawSource ?? (rawSource = originalSource.source().toString());
1648
+ return rawSource;
1649
+ };
1650
+ const cacheKey = file;
1651
+ const hashKey = `${file}:asset`;
1652
+ rememberProcessCacheKey(cacheKey, hashKey);
1653
+ const chunkHash = assetHashByChunk.get(file);
1654
+ await enqueueTask(async () => {
1655
+ await processCachedTask({
1656
+ cache: compilerOptions.cache,
1657
+ cacheKey,
1658
+ hashKey,
1659
+ rawSource: chunkHash === void 0 ? readRawSource() : void 0,
1660
+ hash: chunkHash,
1661
+ applyResult(source, { cacheHit }) {
1662
+ updateAssetIfChanged(file, source, {
1663
+ compare: !cacheHit,
1664
+ notifyUpdate: !cacheHit
1665
+ });
1666
+ },
1667
+ onCacheHit() {
1668
+ debug("html cache hit: %s", file);
1669
+ },
1670
+ transform: async () => {
1671
+ const wxml = await compilerOptions.templateHandler(readRawSource(), defaultTemplateHandlerOptions);
1672
+ const source = new ConcatSource(wxml);
1673
+ debug("html handle: %s", file);
1674
+ return { result: source };
1675
+ }
1676
+ });
1677
+ }, htmlTaskFactories, "tasks.html");
1678
+ }
1679
+ const jsTaskFactories = [];
1680
+ const enqueueJsTask = async (factory) => {
1681
+ await enqueueTask(factory, jsTaskFactories, "tasks.js");
1682
+ };
1683
+ if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
1684
+ const cacheKey = getCacheKey(file);
1685
+ const asset = compilation.getAsset(file);
1686
+ if (!asset) continue;
1687
+ const hashKey = `${file}:asset`;
1688
+ rememberProcessCacheKey(cacheKey, hashKey);
1689
+ const absoluteFile = toAbsoluteOutputPath(file, outputDir);
1690
+ const initialSource = asset.source.source();
1691
+ const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
1692
+ const chunkHash = assetHashByChunk.get(file);
1693
+ const outputModuleGraphOptions = chunkHash === void 0 ? moduleGraphOptions : void 0;
1694
+ await enqueueJsTask(async () => {
1695
+ await processCachedTask({
1696
+ cache: compilerOptions.cache,
1697
+ cacheKey,
1698
+ hashKey,
1699
+ rawSource: chunkHash === void 0 ? initialRawSource : void 0,
1700
+ hash: chunkHash,
1701
+ applyResult(source, { cacheHit }) {
1702
+ if (updateAssetIfChanged(file, source, {
1703
+ compare: !cacheHit,
1704
+ notifyUpdate: !cacheHit
1705
+ })) rememberTransformedRuntimeCandidates(source);
1706
+ },
1707
+ onCacheHit() {
1708
+ debug("js cache hit: %s", file);
1709
+ },
1710
+ transform: async () => {
1711
+ const currentSourceValue = compilation.getAsset(file)?.source.source();
1712
+ const currentSource = stringifyOptionalWebpackSourceValue(currentSourceValue);
1713
+ const handlerOptions = {
1714
+ tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
1715
+ generateMap: false,
1716
+ experimentalJsFastPath: compilerOptions.experimentalJsFastPath ?? (watchMode ? "oxc" : false),
1717
+ filename: absoluteFile,
1718
+ moduleGraph: outputModuleGraphOptions,
1719
+ babelParserOptions: { sourceFilename: absoluteFile }
1720
+ };
1721
+ if (shouldSkipJsTransform(currentSource, {
1722
+ ...handlerOptions,
1723
+ classNameSet: transformRuntimeSet
1724
+ })) return { result: new ConcatSource(currentSource) };
1725
+ const { code, linked } = await compilerOptions.jsHandler(currentSource, transformRuntimeSet, handlerOptions);
1726
+ const source = new ConcatSource(code);
1727
+ debug("js handle: %s", file);
1728
+ applyWebpackLinkedJsResults({
1729
+ ConcatSource,
1730
+ compilation,
1731
+ compilerOptions,
1732
+ debug,
1733
+ jsAssets,
1734
+ linked
1735
+ });
1736
+ return { result: source };
1737
+ }
1738
+ });
1739
+ });
1740
+ }
1741
+ return {
1742
+ htmlTaskFactories,
1743
+ jsTaskFactories
1744
+ };
1745
+ }
1746
+ //#endregion
1314
1747
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.ts
1315
1748
  function createWebpackJsAssetModuleGraph(options) {
1316
1749
  const jsAssets = /* @__PURE__ */ new Map();
@@ -1340,6 +1773,8 @@ function createWebpackJsAssetModuleGraph(options) {
1340
1773
  }
1341
1774
  function applyWebpackLinkedJsResults(options) {
1342
1775
  if (!options.linked) return;
1776
+ const plan = new AssetEmissionPlan();
1777
+ const updates = [];
1343
1778
  for (const [id, { code }] of Object.entries(options.linked)) {
1344
1779
  const assetName = options.jsAssets.get(id);
1345
1780
  if (!assetName) continue;
@@ -1348,13 +1783,163 @@ function applyWebpackLinkedJsResults(options) {
1348
1783
  const previousSource = asset.source.source();
1349
1784
  const previous = previousSource == null ? "" : String(previousSource);
1350
1785
  if (previous === code) continue;
1351
- const source = new options.ConcatSource(code);
1352
- options.compilation.updateAsset(assetName, source);
1786
+ plan.write(assetName, code);
1787
+ updates.push({
1788
+ assetName,
1789
+ code,
1790
+ previous
1791
+ });
1792
+ }
1793
+ if (updates.length === 0) return;
1794
+ applyWebpackAssetEmissionPlan(plan, {
1795
+ compilation: options.compilation,
1796
+ ConcatSource: options.ConcatSource,
1797
+ writeMode: "update"
1798
+ });
1799
+ for (const { assetName, code, previous } of updates) {
1353
1800
  options.compilerOptions.onUpdate(assetName, previous, code);
1354
1801
  options.debug("js linked handle: %s", assetName);
1355
1802
  }
1356
1803
  }
1357
1804
  //#endregion
1805
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.ts
1806
+ async function processWebpackProcessedCssAsset(element, context) {
1807
+ const { ConcatSource, assetHashByChunk, compilerOptions, configuredMainCssEntryFiles, createRuntimeSetHash, cssSourceTraceSignature, cssSources, cssTaskFactories, debug, enqueueTask, finalizeCssAssetSource, finalizeTracedCss, generatedCssSources, getCssHandlerOptions, getGeneratorRuntimeSet, hasConfiguredTailwindV4SourceRoots, isKnownWebpackProcessedCssAsset, isWebGeneratorTarget, isWebpackProcessedCssAsset, processedCssAssetSkipDecisionCache, rememberProcessCacheKey, runtimeAffectingSourceHash, updateAssetIfChanged, watchMode, webpackSourceCandidateSet, webpackSourceCandidateValueSignature, webpackSourceCandidates } = context;
1808
+ const [file, originalSource] = element;
1809
+ let rawSource;
1810
+ const readRawSource = () => {
1811
+ rawSource ?? (rawSource = originalSource.source().toString());
1812
+ return rawSource;
1813
+ };
1814
+ const chunkHash = assetHashByChunk.get(file);
1815
+ const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file, readRawSource());
1816
+ const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
1817
+ const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
1818
+ const processedSourceCss = processedSourceFile ? cssSources.get(path.resolve(processedSourceFile))?.css : void 0;
1819
+ const shouldRegenerateProcessedTailwindV4SourceCss = processedSourceCss !== void 0 && (hasTailwindSourceDirectives(processedSourceCss, { importFallback: true }) || processedSourceCss.includes("@config"));
1820
+ const processedCssAssetKnown = isKnownWebpackProcessedCssAsset?.(file, processedCssAssetMetadata) === true;
1821
+ const processedLoaderGeneratedCss = processedSourceFile ? generatedCssSources.get(path.resolve(processedSourceFile)) : void 0;
1822
+ const processedAssetSourceHash = watchMode && isWebGeneratorTarget && cssHandlerOptionsForProcessedAsset.isMainChunk ? compilerOptions.cache.computeHash(readRawSource()) : chunkHash === void 0 ? processedCssAssetKnown ? "webpack-css-asset:known" : compilerOptions.cache.computeHash(readRawSource()) : "webpack-css-asset:chunk";
1823
+ const processedCssDecisionCacheKey = `${file}:${createRuntimeAwareCssHash(chunkHash, processedAssetSourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`)}`;
1824
+ let currentProcessedRawSource;
1825
+ let hasGeneratedCssMarker = false;
1826
+ let hasTailwindGeneratedAssetCss = false;
1827
+ const readCurrentProcessedRawSource = () => {
1828
+ currentProcessedRawSource ?? (currentProcessedRawSource = readRawSource());
1829
+ return currentProcessedRawSource;
1830
+ };
1831
+ const cachedSkipProcessedCssAsset = processedCssAssetKnown ? processedCssAssetSkipDecisionCache.get(processedCssDecisionCacheKey) : void 0;
1832
+ const shouldRegenerateStaleProcessedWebCssAsset = isWebGeneratorTarget && !processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && webpackSourceCandidateSet !== void 0 && (hasMissingRuntimeCandidates(processedLoaderGeneratedCss?.classSet, webpackSourceCandidateSet) || hasMissingRuntimeCandidates(resolveGeneratedCssRuntimeCandidates(readCurrentProcessedRawSource(), processedLoaderGeneratedCss?.classSet), webpackSourceCandidateSet));
1833
+ if (cachedSkipProcessedCssAsset !== void 0) {
1834
+ hasGeneratedCssMarker = cachedSkipProcessedCssAsset && cssHandlerOptionsForProcessedAsset.isMainChunk;
1835
+ hasTailwindGeneratedAssetCss = hasGeneratedCssMarker;
1836
+ } else {
1837
+ const source = readCurrentProcessedRawSource();
1838
+ hasGeneratedCssMarker = hasBundlerGeneratedCssMarker(source);
1839
+ hasTailwindGeneratedAssetCss = hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source);
1840
+ }
1841
+ const hasProcessedAssetTailwindDirectives = () => {
1842
+ const source = readCurrentProcessedRawSource();
1843
+ return hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
1844
+ };
1845
+ const shouldForceConfiguredMainCssGeneration = cssHandlerOptionsForProcessedAsset.isMainChunk && hasConfiguredTailwindV4SourceRoots() && !hasGeneratedCssMarker && (configuredMainCssEntryFiles.length > 0 || shouldRegenerateProcessedTailwindV4SourceCss || hasProcessedAssetTailwindDirectives());
1846
+ const hasProcessedMainAssetUserCss = cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss) && createWebpackUserCssSourceAppend([...cssSources.entries()].map(([sourceFile, source]) => ({
1847
+ ...source,
1848
+ file: sourceFile
1849
+ })), readCurrentProcessedRawSource()) !== void 0;
1850
+ const hasProcessedLoaderGeneratedUserCss = cachedSkipProcessedCssAsset === void 0 && processedLoaderGeneratedCss !== void 0 && hasAdditionalWebpackAssetUserCssMarkers(processedLoaderGeneratedCss.css, readCurrentProcessedRawSource());
1851
+ const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
1852
+ const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
1853
+ const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && !hasProcessedLoaderGeneratedUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
1854
+ const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
1855
+ if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
1856
+ if (shouldSkipProcessedCssAsset) {
1857
+ const hashKey = `${file}:asset`;
1858
+ const sourceHash = processedAssetSourceHash;
1859
+ rememberProcessCacheKey(file, hashKey);
1860
+ await enqueueTask(async () => {
1861
+ await processCachedTask({
1862
+ cache: compilerOptions.cache,
1863
+ cacheKey: file,
1864
+ hashKey,
1865
+ rawSource: chunkHash === void 0 && !processedCssAssetKnown ? readCurrentProcessedRawSource() : void 0,
1866
+ hash: createRuntimeAwareCssHash(chunkHash, sourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`),
1867
+ applyResult(source, { cacheHit }) {
1868
+ updateAssetIfChanged(file, source, {
1869
+ compare: !cacheHit,
1870
+ notifyUpdate: !cacheHit
1871
+ });
1872
+ },
1873
+ onCacheHit() {
1874
+ debug("css webpack-loader-pipeline cache hit: %s", file);
1875
+ },
1876
+ transform: async () => {
1877
+ const source = readCurrentProcessedRawSource();
1878
+ const missingProcessedLoaderGeneratedCss = isWebGeneratorTarget && processedLoaderGeneratedCss ? filterExistingCssRules(source, stripBundlerGeneratedCssMarkers(processedLoaderGeneratedCss.css)) : "";
1879
+ const sourceWithLoaderGeneratedCss = missingProcessedLoaderGeneratedCss.trim().length === 0 ? source : createWebpackGeneratorUserCssSourceAppend({
1880
+ css: source,
1881
+ processed: true
1882
+ }, {
1883
+ css: missingProcessedLoaderGeneratedCss,
1884
+ processed: true
1885
+ }).css;
1886
+ const processedBareSelectorSourceCss = processedSourceCss ?? (hasTailwindGeneratedAssetCss ? removeWebpackTailwindGeneratedAssetCss(sourceWithLoaderGeneratedCss) : void 0);
1887
+ const handledCss = hasTailwindGeneratedAssetCss && (!hasGeneratedCssMarker || !isWebGeneratorTarget && hasDeferredWebpackGeneratedCss(source, [...generatedCssSources.values()].map((item) => item.classSet))) ? isWebGeneratorTarget ? sourceWithLoaderGeneratedCss : (await compilerOptions.styleHandler(sourceWithLoaderGeneratedCss, cssHandlerOptionsForProcessedAsset)).css : sourceWithLoaderGeneratedCss;
1888
+ const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(handledCss, {
1889
+ cssPreflight: cssHandlerOptionsForProcessedAsset.isMainChunk,
1890
+ generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss
1891
+ }));
1892
+ const processedSourceBareUserCss = isWebGeneratorTarget || processedBareSelectorSourceCss === void 0 ? void 0 : createWebpackGeneratorUserCssSourceAppend({
1893
+ css: collectWebpackBareSelectorUserCss(processedBareSelectorSourceCss),
1894
+ processed: false
1895
+ });
1896
+ const finalizedProcessedSourceBareUserCss = processedSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(processedSourceBareUserCss.css, {
1897
+ cssPreflight: false,
1898
+ generatedCss: false
1899
+ });
1900
+ const missingProcessedSourceBareUserCss = finalizedProcessedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(nextCss, finalizedProcessedSourceBareUserCss);
1901
+ const css = missingProcessedSourceBareUserCss.trim().length === 0 ? nextCss : createWebpackGeneratorUserCssSourceAppend({
1902
+ css: nextCss,
1903
+ processed: true
1904
+ }, {
1905
+ css: missingProcessedSourceBareUserCss,
1906
+ processed: true
1907
+ }).css;
1908
+ debug("css skip webpack-loader-pipeline asset: %s", file);
1909
+ return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset, { finalized: true })) };
1910
+ }
1911
+ });
1912
+ }, cssTaskFactories, "tasks.css");
1913
+ return true;
1914
+ }
1915
+ const currentRawSource = readRawSource();
1916
+ if (isWebpackCssLoaderRuntimeSource(currentRawSource)) {
1917
+ const hashKey = `${file}:asset`;
1918
+ rememberProcessCacheKey(file, hashKey);
1919
+ await enqueueTask(async () => {
1920
+ await processCachedTask({
1921
+ cache: compilerOptions.cache,
1922
+ cacheKey: file,
1923
+ hashKey,
1924
+ rawSource: currentRawSource,
1925
+ hash: createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(currentRawSource), "webpack-css-loader-runtime"),
1926
+ applyResult(source, { cacheHit }) {
1927
+ updateAssetIfChanged(file, source, {
1928
+ compare: !cacheHit,
1929
+ notifyUpdate: !cacheHit
1930
+ });
1931
+ },
1932
+ onCacheHit() {
1933
+ debug("css-loader runtime cache hit: %s", file);
1934
+ },
1935
+ transform: async () => ({ result: new ConcatSource(currentRawSource) })
1936
+ });
1937
+ }, cssTaskFactories, "tasks.css");
1938
+ return true;
1939
+ }
1940
+ return false;
1941
+ }
1942
+ //#endregion
1358
1943
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.ts
1359
1944
  const WEBPACK_SOURCE_CANDIDATE_SCAN_CACHE_MAX = 2;
1360
1945
  function trimScanCache(cache) {
@@ -1532,7 +2117,7 @@ async function refreshWebpackSourceCandidates(options) {
1532
2117
  const root = options.compilerOptions.tailwindcssBasedir ?? process.cwd();
1533
2118
  let sourceScan;
1534
2119
  try {
1535
- sourceScan = await resolveViteSourceScanEntries(options.compilerOptions, options.runtimeState.tailwindRuntime, {
2120
+ sourceScan = await resolveSourceScanEntries(options.compilerOptions, options.runtimeState.tailwindRuntime, {
1536
2121
  root,
1537
2122
  outDir: options.outputDir
1538
2123
  });
@@ -1569,11 +2154,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
1569
2154
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
1570
2155
  const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
1571
2156
  const webpackSourceCandidateScanCache = createWebpackSourceCandidateScanCache();
1572
- const bundleBuildState = createBundleBuildState();
1573
- const bundleRuntimeClassSetManager = runtimeClassSetManager ?? createBundleRuntimeClassSetManager();
2157
+ const bundleBuildState = createRuntimeCompilationBuildState();
2158
+ const bundleRuntimeClassSetManager = runtimeClassSetManager ?? createRuntimeClassSetManager();
1574
2159
  const escapeFragments = createEscapeFragments(MappingChars2String);
1575
2160
  const processedCssAssetSkipDecisionCache = /* @__PURE__ */ new Map();
1576
- let webpackWatchRuntimeScanInitialized = false;
1577
2161
  compiler.hooks.compilation.tap(pluginName, (compilation) => {
1578
2162
  compilation.hooks.processAssets.tapPromise({
1579
2163
  name: pluginName,
@@ -1583,10 +2167,16 @@ function setupWebpackV5ProcessAssetsHook(options) {
1583
2167
  if (entries.length === 0) return;
1584
2168
  const groupedEntries = getGroupedEntries(entries, compilerOptions);
1585
2169
  if (isWebGeneratorTarget && groupedEntries.css.length === 0) return;
2170
+ beginCompilerShadowRun(runtimeState);
1586
2171
  compilerOptions.onStart();
1587
2172
  debug("start");
1588
2173
  await runtimeState.readyPromise;
1589
2174
  const hmrTimingStartedAt = performance.now();
2175
+ const timingDetails = {};
2176
+ const recordTimingDetail = (name, startedAt) => {
2177
+ timingDetails[name] = (timingDetails[name] ?? 0) + Math.max(0, performance.now() - startedAt);
2178
+ };
2179
+ const setupStartedAt = performance.now();
1590
2180
  for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
1591
2181
  const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
1592
2182
  const { updateAssetIfChanged } = createWebpackAssetUpdater({
@@ -1613,6 +2203,9 @@ function setupWebpackV5ProcessAssetsHook(options) {
1613
2203
  cssMatcher: compilerOptions.cssMatcher
1614
2204
  }));
1615
2205
  const watchChangedFiles = new Set([...getWatchChangedFiles?.() ?? []].map((file) => path.resolve(file)));
2206
+ const compilationChanges = createCompilationDependencyChanges(watchChangedFiles);
2207
+ const affectedCompilationScopes = recordCompilationDependencyChanges(runtimeState, compilationChanges);
2208
+ const getCompilationDependencyRevision = (scopeId) => getCompilationScopeDependencyRevision(runtimeState, scopeId);
1616
2209
  const taskConcurrency = watchMode ? resolveTaskConcurrency(1) : void 0;
1617
2210
  const activeProcessCacheKeys = /* @__PURE__ */ new Set();
1618
2211
  const activeProcessHashKeys = /* @__PURE__ */ new Set();
@@ -1643,7 +2236,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
1643
2236
  runtimeState
1644
2237
  });
1645
2238
  const finalizeCssAssetSource = (source, options = {}) => finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options);
1646
- const webpackSourceCandidates = !isWebGeneratorTarget && groupedEntries.css.length > 0 || cssSources.size > 0 || generatedCssSources.size > 0 || isCssSourceTraceEnabled(compilerOptions) ? await refreshWebpackSourceCandidates({
2239
+ const shouldRefreshWebpackSourceCandidates = !isWebGeneratorTarget && groupedEntries.css.length > 0 || cssSources.size > 0 || generatedCssSources.size > 0 || isCssSourceTraceEnabled(compilerOptions);
2240
+ recordTimingDetail("setup", setupStartedAt);
2241
+ const sourceCandidatesStartedAt = performance.now();
2242
+ const webpackSourceCandidates = shouldRefreshWebpackSourceCandidates ? await refreshWebpackSourceCandidates({
1647
2243
  compilerOptions,
1648
2244
  debug,
1649
2245
  outputDir,
@@ -1653,6 +2249,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
1653
2249
  watchMode
1654
2250
  }) : void 0;
1655
2251
  const webpackSourceCandidateValueSignature = webpackSourceCandidates ? createCandidateSignature(webpackSourceCandidates.getSourceCandidatesForEntries(void 0)) : "source-candidates:0";
2252
+ recordTimingDetail("sourceCandidates", sourceCandidatesStartedAt);
1656
2253
  const cssSourceTraceTokenSources = createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates);
1657
2254
  const cssSourceTraceSignature = createCssSourceTraceCacheSignature(cssSourceTraceTokenSources, compilerOptions);
1658
2255
  const annotateCss = (css) => annotateCssSourceTrace(css, {
@@ -1666,6 +2263,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
1666
2263
  isWebGeneratorTarget
1667
2264
  });
1668
2265
  const hasRuntimeTransformAssets = Boolean(!isWebGeneratorTarget && ((groupedEntries.html?.length ?? 0) > 0 || (groupedEntries.js?.length ?? 0) > 0));
2266
+ const runtimeStartedAt = performance.now();
1669
2267
  const forceRuntimeRefresh = getRuntimeRefreshRequirement();
1670
2268
  debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.tailwindRuntime.majorVersion ?? "unknown");
1671
2269
  let runtimeSet;
@@ -1674,8 +2272,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
1674
2272
  else if (watchMode && !forceRuntimeRefresh) {
1675
2273
  const baseRuntimeSet = getRuntimeClassSetSync(runtimeState.tailwindRuntime);
1676
2274
  const snapshot = buildWebpackBundleSnapshot(assets, compilerOptions, bundleBuildState, compilation);
1677
- if (!webpackWatchRuntimeScanInitialized) for (const entry of snapshot.entries) snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
1678
- runtimeAffectingSourceHash = compilerOptions.cache.computeHash([...groupedEntries.html.map(([file, source]) => `${file}:${compilerOptions.cache.computeHash(source.source().toString())}`), ...groupedEntries.js.map(([file, source]) => `${file}:${compilerOptions.cache.computeHash(source.source().toString())}`)].sort().join("\n\n"));
2275
+ if (bundleBuildState.iteration === 0) for (const entry of snapshot.entries) snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
2276
+ runtimeAffectingSourceHash = createRuntimeCompilationAffectingSignature(snapshot, (source) => compilerOptions.cache.computeHash(source));
1679
2277
  try {
1680
2278
  runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
1681
2279
  baseClassSet: baseRuntimeSet,
@@ -1687,12 +2285,11 @@ function setupWebpackV5ProcessAssetsHook(options) {
1687
2285
  runtimeSet = getRuntimeClassSetSync(runtimeState.tailwindRuntime);
1688
2286
  }
1689
2287
  releaseWebpackBundleSnapshotSources(snapshot);
1690
- updateBundleBuildState(bundleBuildState, snapshot, /* @__PURE__ */ new Map(), { incremental: true });
1691
- webpackWatchRuntimeScanInitialized = true;
2288
+ updateRuntimeCompilationBuildState(bundleBuildState, snapshot, /* @__PURE__ */ new Map(), { incremental: true });
1692
2289
  } else {
1693
2290
  if (forceRuntimeRefresh) {
1694
2291
  await bundleRuntimeClassSetManager.reset();
1695
- webpackWatchRuntimeScanInitialized = false;
2292
+ resetRuntimeCompilationBuildState(bundleBuildState);
1696
2293
  }
1697
2294
  runtimeSet = await ensureRuntimeClassSet(runtimeState, {
1698
2295
  forceRefresh: forceRuntimeRefresh,
@@ -1703,6 +2300,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
1703
2300
  }
1704
2301
  await refreshRuntimeMetadata(forceRuntimeRefresh);
1705
2302
  consumeRuntimeRefreshRequirement();
2303
+ recordTimingDetail("runtime", runtimeStartedAt);
1706
2304
  const webpackSourceCandidateSet = webpackSourceCandidates?.getSourceCandidatesForEntries(void 0);
1707
2305
  const generatorRuntimeSet = new Set(runtimeSet);
1708
2306
  addRuntimeTransformCandidates(generatorRuntimeSet, webpackSourceCandidateSet);
@@ -1757,532 +2355,112 @@ function setupWebpackV5ProcessAssetsHook(options) {
1757
2355
  const defaultTemplateHandlerOptions = { runtimeSet: transformRuntimeSet };
1758
2356
  debug("get runtimeSet, class count: %d, transform class count: %d", runtimeSet.size, transformRuntimeSet.size);
1759
2357
  const tasks = [];
1760
- const htmlTaskFactories = [];
1761
2358
  const cssTaskFactories = [];
1762
- const enqueueTask = async (factory, target) => {
2359
+ const enqueueTask = async (factory, target, phase) => {
2360
+ const timedFactory = async () => {
2361
+ const startedAt = performance.now();
2362
+ try {
2363
+ await factory();
2364
+ } finally {
2365
+ recordTimingDetail(phase, startedAt);
2366
+ }
2367
+ };
1763
2368
  if (watchMode) {
1764
- await factory();
2369
+ await timedFactory();
1765
2370
  return;
1766
2371
  }
1767
- target.push(factory);
2372
+ target.push(timedFactory);
1768
2373
  };
1769
- if (!isWebGeneratorTarget && Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
1770
- const [file, originalSource] = element;
1771
- let rawSource;
1772
- const readRawSource = () => {
1773
- rawSource ?? (rawSource = originalSource.source().toString());
1774
- return rawSource;
1775
- };
1776
- const cacheKey = file;
1777
- const hashKey = `${file}:asset`;
1778
- rememberProcessCacheKey(cacheKey, hashKey);
1779
- const chunkHash = assetHashByChunk.get(file);
1780
- await enqueueTask(async () => {
1781
- await processCachedTask({
1782
- cache: compilerOptions.cache,
1783
- cacheKey,
1784
- hashKey,
1785
- rawSource: chunkHash === void 0 ? readRawSource() : void 0,
1786
- hash: chunkHash,
1787
- applyResult(source, { cacheHit }) {
1788
- updateAssetIfChanged(file, source, {
1789
- compare: !cacheHit,
1790
- notifyUpdate: !cacheHit
1791
- });
1792
- },
1793
- onCacheHit() {
1794
- debug("html cache hit: %s", file);
1795
- },
1796
- transform: async () => {
1797
- const wxml = await compilerOptions.templateHandler(readRawSource(), defaultTemplateHandlerOptions);
1798
- const source = new ConcatSource(wxml);
1799
- debug("html handle: %s", file);
1800
- return { result: source };
1801
- }
1802
- });
1803
- }, htmlTaskFactories);
1804
- }
1805
- const jsTaskFactories = [];
1806
- const enqueueJsTask = async (factory) => {
1807
- await enqueueTask(factory, jsTaskFactories);
2374
+ const { htmlTaskFactories, jsTaskFactories } = await enqueueWebpackHtmlAndJsTasks({
2375
+ ConcatSource,
2376
+ applyWebpackLinkedJsResults,
2377
+ assetHashByChunk,
2378
+ compilation,
2379
+ compilerOptions,
2380
+ debug,
2381
+ defaultTemplateHandlerOptions,
2382
+ enqueueTask,
2383
+ groupedEntries,
2384
+ isWebGeneratorTarget,
2385
+ jsAssets,
2386
+ moduleGraphOptions,
2387
+ outputDir,
2388
+ rememberProcessCacheKey,
2389
+ rememberTransformedRuntimeCandidates,
2390
+ runtimeState,
2391
+ transformRuntimeSet,
2392
+ updateAssetIfChanged,
2393
+ watchMode
2394
+ });
2395
+ const cssTaskContext = {
2396
+ ConcatSource,
2397
+ affectedCompilationScopes,
2398
+ assetHashByChunk,
2399
+ compilation,
2400
+ compilationChanges,
2401
+ compilerOptions,
2402
+ configuredCssEntryFiles,
2403
+ configuredMainCssEntryFiles,
2404
+ createRuntimeSetHash,
2405
+ cssSourceTraceSignature,
2406
+ cssSources,
2407
+ cssTaskFactories,
2408
+ debug,
2409
+ enqueueTask,
2410
+ finalizeCssAssetSource,
2411
+ finalizeTracedCss,
2412
+ generatedCssSources,
2413
+ generatorRuntimeSet,
2414
+ getCompilationDependencyRevision,
2415
+ getCssHandlerOptions,
2416
+ getCssUserHandlerOptions,
2417
+ getGeneratorRuntimeSet,
2418
+ hasConfiguredTailwindV4SourceRoots,
2419
+ isKnownWebpackProcessedCssAsset,
2420
+ isSameWebpackSourceScope,
2421
+ isWebGeneratorTarget,
2422
+ isWebpackProcessedCssAsset,
2423
+ processedCssAssetSkipDecisionCache,
2424
+ rememberProcessCacheKey,
2425
+ resolveWebpackCssSourceFile,
2426
+ runtimeAffectingSourceHash,
2427
+ runtimeState,
2428
+ transformRuntimeSet,
2429
+ updateAssetIfChanged,
2430
+ watchMode,
2431
+ webpackSourceCandidateSet,
2432
+ webpackSourceCandidateValueSignature,
2433
+ webpackSourceCandidates
1808
2434
  };
1809
- if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
1810
- const cacheKey = getCacheKey(file);
1811
- const asset = compilation.getAsset(file);
1812
- if (!asset) continue;
1813
- const hashKey = `${file}:asset`;
1814
- rememberProcessCacheKey(cacheKey, hashKey);
1815
- const absoluteFile = toAbsoluteOutputPath(file, outputDir);
1816
- const initialSource = asset.source.source();
1817
- const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
1818
- const chunkHash = assetHashByChunk.get(file);
1819
- await enqueueJsTask(async () => {
1820
- await processCachedTask({
1821
- cache: compilerOptions.cache,
1822
- cacheKey,
1823
- hashKey,
1824
- rawSource: chunkHash === void 0 ? initialRawSource : void 0,
1825
- hash: chunkHash,
1826
- applyResult(source, { cacheHit }) {
1827
- if (updateAssetIfChanged(file, source, {
1828
- compare: !cacheHit,
1829
- notifyUpdate: !cacheHit
1830
- })) rememberTransformedRuntimeCandidates(source);
1831
- },
1832
- onCacheHit() {
1833
- debug("js cache hit: %s", file);
1834
- },
1835
- transform: async () => {
1836
- const currentSourceValue = compilation.getAsset(file)?.source.source();
1837
- const currentSource = stringifyOptionalWebpackSourceValue(currentSourceValue);
1838
- const handlerOptions = {
1839
- tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
1840
- generateMap: false,
1841
- filename: absoluteFile,
1842
- moduleGraph: moduleGraphOptions,
1843
- babelParserOptions: { sourceFilename: absoluteFile }
1844
- };
1845
- if (shouldSkipJsTransform(currentSource, {
1846
- ...handlerOptions,
1847
- classNameSet: transformRuntimeSet
1848
- })) return { result: new ConcatSource(currentSource) };
1849
- const { code, linked } = await compilerOptions.jsHandler(currentSource, transformRuntimeSet, handlerOptions);
1850
- const source = new ConcatSource(code);
1851
- debug("js handle: %s", file);
1852
- applyWebpackLinkedJsResults({
1853
- ConcatSource,
1854
- compilation,
1855
- compilerOptions,
1856
- debug,
1857
- jsAssets,
1858
- linked
1859
- });
1860
- return { result: source };
1861
- }
1862
- });
1863
- });
1864
- }
1865
2435
  for (const element of groupedEntries.css) {
1866
- const [file, originalSource] = element;
1867
- let rawSource;
1868
- const readRawSource = () => {
1869
- rawSource ?? (rawSource = originalSource.source().toString());
1870
- return rawSource;
1871
- };
1872
- const chunkHash = assetHashByChunk.get(file);
1873
- const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file, readRawSource());
1874
- const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
1875
- const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
1876
- const processedSourceCss = processedSourceFile ? cssSources.get(path.resolve(processedSourceFile))?.css : void 0;
1877
- const shouldRegenerateProcessedTailwindV4SourceCss = processedSourceCss !== void 0 && (hasTailwindSourceDirectives(processedSourceCss, { importFallback: true }) || processedSourceCss.includes("@config"));
1878
- const processedCssAssetKnown = isKnownWebpackProcessedCssAsset?.(file, processedCssAssetMetadata) === true;
1879
- const processedLoaderGeneratedCss = processedSourceFile ? generatedCssSources.get(path.resolve(processedSourceFile)) : void 0;
1880
- const processedAssetSourceHash = watchMode && isWebGeneratorTarget && cssHandlerOptionsForProcessedAsset.isMainChunk ? compilerOptions.cache.computeHash(readRawSource()) : chunkHash === void 0 ? processedCssAssetKnown ? "webpack-css-asset:known" : compilerOptions.cache.computeHash(readRawSource()) : "webpack-css-asset:chunk";
1881
- const processedCssDecisionCacheKey = `${file}:${createRuntimeAwareCssHash(chunkHash, processedAssetSourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`)}`;
1882
- let currentProcessedRawSource;
1883
- let hasGeneratedCssMarker = false;
1884
- let hasTailwindGeneratedAssetCss = false;
1885
- const readCurrentProcessedRawSource = () => {
1886
- currentProcessedRawSource ?? (currentProcessedRawSource = readRawSource());
1887
- return currentProcessedRawSource;
1888
- };
1889
- const cachedSkipProcessedCssAsset = processedCssAssetKnown ? processedCssAssetSkipDecisionCache.get(processedCssDecisionCacheKey) : void 0;
1890
- const shouldRegenerateStaleProcessedWebCssAsset = isWebGeneratorTarget && !processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && webpackSourceCandidateSet !== void 0 && (hasMissingRuntimeCandidates(processedLoaderGeneratedCss?.classSet, webpackSourceCandidateSet) || hasMissingRuntimeCandidates(resolveGeneratedCssRuntimeCandidates(readCurrentProcessedRawSource(), processedLoaderGeneratedCss?.classSet), webpackSourceCandidateSet));
1891
- if (cachedSkipProcessedCssAsset !== void 0) {
1892
- hasGeneratedCssMarker = cachedSkipProcessedCssAsset && cssHandlerOptionsForProcessedAsset.isMainChunk;
1893
- hasTailwindGeneratedAssetCss = hasGeneratedCssMarker;
1894
- } else {
1895
- const source = readCurrentProcessedRawSource();
1896
- hasGeneratedCssMarker = hasBundlerGeneratedCssMarker(source);
1897
- hasTailwindGeneratedAssetCss = hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source);
1898
- }
1899
- const hasProcessedAssetTailwindDirectives = () => {
1900
- const source = readCurrentProcessedRawSource();
1901
- return hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
1902
- };
1903
- const shouldForceConfiguredMainCssGeneration = cssHandlerOptionsForProcessedAsset.isMainChunk && hasConfiguredTailwindV4SourceRoots() && !hasGeneratedCssMarker && (configuredMainCssEntryFiles.length > 0 || shouldRegenerateProcessedTailwindV4SourceCss || hasProcessedAssetTailwindDirectives());
1904
- const hasProcessedMainAssetUserCss = cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss) && createWebpackUserCssSourceAppend([...cssSources.entries()].map(([sourceFile, source]) => ({
1905
- ...source,
1906
- file: sourceFile
1907
- })), readCurrentProcessedRawSource()) !== void 0;
1908
- const hasProcessedLoaderGeneratedUserCss = cachedSkipProcessedCssAsset === void 0 && processedLoaderGeneratedCss !== void 0 && hasAdditionalWebpackAssetUserCssMarkers(processedLoaderGeneratedCss.css, readCurrentProcessedRawSource());
1909
- const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
1910
- const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
1911
- const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && !hasProcessedLoaderGeneratedUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
1912
- const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
1913
- if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
1914
- if (shouldSkipProcessedCssAsset) {
1915
- const hashKey = `${file}:asset`;
1916
- const sourceHash = processedAssetSourceHash;
1917
- rememberProcessCacheKey(file, hashKey);
1918
- await enqueueTask(async () => {
1919
- await processCachedTask({
1920
- cache: compilerOptions.cache,
1921
- cacheKey: file,
1922
- hashKey,
1923
- rawSource: chunkHash === void 0 && !processedCssAssetKnown ? readCurrentProcessedRawSource() : void 0,
1924
- hash: createRuntimeAwareCssHash(chunkHash, sourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`),
1925
- applyResult(source, { cacheHit }) {
1926
- updateAssetIfChanged(file, source, {
1927
- compare: !cacheHit,
1928
- notifyUpdate: !cacheHit
1929
- });
1930
- },
1931
- onCacheHit() {
1932
- debug("css webpack-loader-pipeline cache hit: %s", file);
1933
- },
1934
- transform: async () => {
1935
- const source = readCurrentProcessedRawSource();
1936
- const missingProcessedLoaderGeneratedCss = isWebGeneratorTarget && processedLoaderGeneratedCss ? filterExistingCssRules(source, stripBundlerGeneratedCssMarkers(processedLoaderGeneratedCss.css)) : "";
1937
- const sourceWithLoaderGeneratedCss = missingProcessedLoaderGeneratedCss.trim().length === 0 ? source : createWebpackGeneratorUserCssSourceAppend({
1938
- css: source,
1939
- processed: true
1940
- }, {
1941
- css: missingProcessedLoaderGeneratedCss,
1942
- processed: true
1943
- }).css;
1944
- const processedBareSelectorSourceCss = processedSourceCss ?? (hasTailwindGeneratedAssetCss ? removeWebpackTailwindGeneratedAssetCss(sourceWithLoaderGeneratedCss) : void 0);
1945
- const handledCss = hasTailwindGeneratedAssetCss && (!hasGeneratedCssMarker || !isWebGeneratorTarget && hasDeferredWebpackGeneratedCss(source, [...generatedCssSources.values()].map((item) => item.classSet))) ? isWebGeneratorTarget ? sourceWithLoaderGeneratedCss : (await compilerOptions.styleHandler(sourceWithLoaderGeneratedCss, cssHandlerOptionsForProcessedAsset)).css : sourceWithLoaderGeneratedCss;
1946
- const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(handledCss, {
1947
- cssPreflight: cssHandlerOptionsForProcessedAsset.isMainChunk,
1948
- generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss
1949
- }));
1950
- const processedSourceBareUserCss = isWebGeneratorTarget || processedBareSelectorSourceCss === void 0 ? void 0 : createWebpackGeneratorUserCssSourceAppend({
1951
- css: collectWebpackBareSelectorUserCss(processedBareSelectorSourceCss),
1952
- processed: false
1953
- });
1954
- const finalizedProcessedSourceBareUserCss = processedSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(processedSourceBareUserCss.css, {
1955
- cssPreflight: false,
1956
- generatedCss: false
1957
- });
1958
- const missingProcessedSourceBareUserCss = finalizedProcessedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(nextCss, finalizedProcessedSourceBareUserCss);
1959
- const css = missingProcessedSourceBareUserCss.trim().length === 0 ? nextCss : createWebpackGeneratorUserCssSourceAppend({
1960
- css: nextCss,
1961
- processed: true
1962
- }, {
1963
- css: missingProcessedSourceBareUserCss,
1964
- processed: true
1965
- }).css;
1966
- debug("css skip webpack-loader-pipeline asset: %s", file);
1967
- return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset, { finalized: true })) };
1968
- }
1969
- });
1970
- }, cssTaskFactories);
1971
- continue;
1972
- }
1973
- const currentRawSource = readRawSource();
1974
- if (isWebpackCssLoaderRuntimeSource(currentRawSource)) {
1975
- const hashKey = `${file}:asset`;
1976
- rememberProcessCacheKey(file, hashKey);
1977
- await enqueueTask(async () => {
1978
- await processCachedTask({
1979
- cache: compilerOptions.cache,
1980
- cacheKey: file,
1981
- hashKey,
1982
- rawSource: currentRawSource,
1983
- hash: createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(currentRawSource), "webpack-css-loader-runtime"),
1984
- applyResult(source, { cacheHit }) {
1985
- updateAssetIfChanged(file, source, {
1986
- compare: !cacheHit,
1987
- notifyUpdate: !cacheHit
1988
- });
1989
- },
1990
- onCacheHit() {
1991
- debug("css-loader runtime cache hit: %s", file);
1992
- },
1993
- transform: async () => ({ result: new ConcatSource(currentRawSource) })
1994
- });
1995
- }, cssTaskFactories);
1996
- continue;
1997
- }
1998
- const cacheKey = file;
1999
- const hashKey = `${file}:asset`;
2000
- rememberProcessCacheKey(cacheKey, hashKey);
2001
- const cssHandlerOptionsForHash = getCssHandlerOptions(file, currentRawSource);
2002
- const cssChunkHash = watchMode && cssHandlerOptionsForHash.isMainChunk ? void 0 : chunkHash;
2003
- const cssSourceHash = (() => {
2004
- const sourceFile = resolveWebpackCssSourceFile(file, currentRawSource);
2005
- const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
2006
- const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
2007
- if (sourceCss === void 0) return sourceFile === void 0 ? "webpack-css-source:0" : `webpack-css-source:0:${sourceFile}`;
2008
- return `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}:${generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss)}`;
2009
- })();
2010
- const runtimeAwareHash = createRuntimeAwareCssHash(cssChunkHash, compilerOptions.cache.computeHash(currentRawSource), `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}:${cssSourceHash}`);
2011
- await enqueueTask(async () => {
2012
- await processCachedTask({
2013
- cache: compilerOptions.cache,
2014
- cacheKey,
2015
- hashKey,
2016
- rawSource: currentRawSource,
2017
- hash: runtimeAwareHash,
2018
- applyResult(source, { cacheHit }) {
2019
- updateAssetIfChanged(file, source, {
2020
- compare: !cacheHit,
2021
- notifyUpdate: !cacheHit
2022
- });
2023
- },
2024
- onCacheHit() {
2025
- debug("css cache hit: %s", file);
2026
- },
2027
- transform: async () => {
2028
- await runtimeState.readyPromise;
2029
- const cssHandlerOptions = getCssHandlerOptions(file, currentRawSource);
2030
- const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
2031
- if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
2032
- const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
2033
- const sourceCss = sourceFile ? cssSources.get(path.resolve(sourceFile))?.css : void 0;
2034
- const isConfiguredCssSource = sourceFile !== void 0 && configuredCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
2035
- const isConfiguredMainCssSource = sourceFile !== void 0 && configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
2036
- const sourceCssHasTailwindRoot = sourceCss !== void 0 && hasTailwindRootDirectives(sourceCss, { importFallback: true });
2037
- const shouldPreserveExistingPreflight = cssHandlerOptions.isMainChunk || !isConfiguredMainCssSource && (isConfiguredCssSource || sourceCssHasTailwindRoot);
2038
- const loaderGeneratedCss = sourceFile ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
2039
- const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
2040
- const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await resolveTailwindV4EntriesFromCssCached(sourceCss, path.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
2041
- if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
2042
- allowMarkerlessRegistryMatch: configuredCssEntryFiles.length === 1,
2043
- hasBundlerGeneratedCssMarker: hasBundlerGeneratedCssMarker(currentRawSource),
2044
- loaderGeneratedClassSet: loaderGeneratedCss.classSet,
2045
- sourceCandidates: explicitTailwindV4SourceCandidates,
2046
- shouldRegenerateExplicitTailwindV4CssSource,
2047
- watchMode
2048
- })) {
2049
- for (const className of loaderGeneratedCss.classSet) {
2050
- generatorRuntimeSet.add(className);
2051
- transformRuntimeSet.add(className);
2052
- }
2053
- for (const dependency of loaderGeneratedCss.dependencies) compilation.fileDependencies?.add?.(dependency);
2054
- const currentRawSourceWithoutBundlerMarkers = stripBundlerGeneratedCssMarkers(currentRawSource);
2055
- const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
2056
- const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
2057
- const loaderGeneratedCssWithoutMarkers = stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
2058
- const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : stripBundlerGeneratedCssMarkers(currentAssetUserCss);
2059
- const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : filterExistingCssRules(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
2060
- if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk) {
2061
- debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
2062
- const userCss = currentAssetMissingUserCss.trim().length === 0 || isCommentOnlyCss(currentAssetMissingUserCss) ? "" : finalizeCssAssetSource(currentAssetMissingUserCss, {
2063
- cssPreflight: false,
2064
- generatedCss: false
2065
- });
2066
- return { result: new ConcatSource(finalizeTracedCss(userCss, cssHandlerOptions)) };
2067
- }
2068
- const mergedLoaderCss = currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
2069
- css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : filterExistingCssRules(currentAssetUserCss, loaderGeneratedCss.css),
2070
- processed: true
2071
- }, currentAssetUserCss === void 0 ? void 0 : {
2072
- css: currentAssetUserCss,
2073
- processed: true
2074
- }).css;
2075
- const handledLoaderCss = isWebGeneratorTarget ? mergedLoaderCss : (await compilerOptions.styleHandler(mergedLoaderCss, cssHandlerOptions)).css;
2076
- const finalizedLoaderCss = finalizeCssAssetSource(handledLoaderCss, {
2077
- cssPreflight: cssHandlerOptions.isMainChunk,
2078
- generatedCss: true,
2079
- preserveExistingPreflight: shouldPreserveExistingPreflight
2080
- });
2081
- const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
2082
- css: currentAssetUserCss,
2083
- processed: true
2084
- }, sourceCss === void 0 ? void 0 : {
2085
- css: sourceCss,
2086
- processed: false
2087
- }].map((source) => {
2088
- if (source === void 0) return;
2089
- return {
2090
- css: collectWebpackBareSelectorUserCss(source.css),
2091
- processed: source.processed
2092
- };
2093
- }));
2094
- const handledLoaderSourceBareUserCss = loaderSourceBareUserCss === void 0 ? "" : loaderSourceBareUserCss.processed ? loaderSourceBareUserCss.css : (await compilerOptions.styleHandler(loaderSourceBareUserCss.css, cssHandlerOptions)).css;
2095
- const finalizedLoaderSourceBareUserCss = handledLoaderSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledLoaderSourceBareUserCss, {
2096
- cssPreflight: false,
2097
- generatedCss: false
2098
- });
2099
- const missingLoaderSourceBareUserCss = finalizedLoaderSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedLoaderCss, finalizedLoaderSourceBareUserCss);
2100
- const css = finalizeTracedCss(missingLoaderSourceBareUserCss.trim().length === 0 ? finalizedLoaderCss : createWebpackGeneratorUserCssSourceAppend({
2101
- css: finalizedLoaderCss,
2102
- processed: true
2103
- }, {
2104
- css: missingLoaderSourceBareUserCss,
2105
- processed: true
2106
- }).css, cssHandlerOptions, { finalized: true });
2107
- debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
2108
- return { result: new ConcatSource(css) };
2109
- }
2110
- const sourceCssProcessed = sourceFile ? cssSources.get(path.resolve(sourceFile))?.processed === true : false;
2111
- const registeredUserRawSource = createWebpackUserCssSourceAppend([...cssSources.entries()].map(([registeredSourceFile, source]) => ({
2112
- ...source,
2113
- file: registeredSourceFile
2114
- })), generatorRawSource, sourceFile, (registeredSourceFile) => isSameWebpackSourceScope(file, registeredSourceFile, sourceFile));
2115
- const currentAssetLooksGenerated = hasTailwindGeneratedCss(currentRawSource) || hasTailwindGeneratedCssMarkers(currentRawSource);
2116
- const currentAssetHasBundlerGeneratedMarker = hasBundlerGeneratedCssMarker(currentRawSource);
2117
- const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
2118
- if (sourceFile === void 0 && currentAssetHasBundlerGeneratedMarker && (currentAssetUserCssSource.trim().length === 0 || isCommentOnlyCss(currentAssetUserCssSource))) return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
2119
- const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
2120
- const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
2121
- const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
2122
- const currentAssetHasUserCss = (sourceCssProcessed || hasExplicitSourceCssForCurrentAsset) && currentAssetLooksGenerated && !shouldPreserveGeneratedWebAssetUserCss ? currentAssetHasAdditionalUserCss : shouldUseWebpackAssetAsGeneratorUserCss(currentAssetUserCssSource, generatorRawSource, { processed: sourceCssProcessed || shouldPreserveGeneratedWebAssetUserCss });
2123
- const userRawSource = createWebpackGeneratorUserCssSourceAppend(createWebpackCurrentAssetUserRawSource({
2124
- currentAssetHasUserCss,
2125
- currentAssetLooksGenerated,
2126
- currentAssetUserCssSource,
2127
- shouldAppendCurrentAssetUserCss: shouldAppendCurrentWebpackAssetUserCss({
2128
- currentAssetHasBundlerGeneratedMarker,
2129
- currentAssetHasUserCss,
2130
- currentAssetLooksGenerated,
2131
- registeredUserRawSource,
2132
- shouldPreserveGeneratedWebAssetUserCss,
2133
- sourceCssProcessed
2134
- }),
2135
- sourceCssProcessed
2136
- }), registeredUserRawSource);
2137
- if (isPureLocalCssImportWrapper(currentRawSource)) return { result: new ConcatSource(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
2138
- const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
2139
- const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
2140
- const currentAssetHasTailwindDirectives = hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || hasTailwindApplyDirective(generatorRawSource);
2141
- const shouldForceTailwindV4Generation = hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 && sourceFile !== void 0 || currentAssetHasTailwindDirectives || hasExplicitTailwindV4SourceCss);
2142
- const shouldSkipUnmatchedMainCssGeneration = !isWebGeneratorTarget && cssHandlerOptions.isMainChunk && sourceFile === void 0 && configuredMainCssEntryFiles.length > 0 && !currentAssetHasTailwindDirectives;
2143
- const shouldSkipPlainNonMainCssGeneration = !cssHandlerOptions.isMainChunk && sourceCss !== void 0 && !hasExplicitSourceCssForCurrentAsset && !hasExplicitTailwindV4SourceCss && !currentAssetHasTailwindDirectives;
2144
- const shouldMergeFallbackGeneratorRuntime = cssHandlerOptions.isMainChunk || currentAssetHasTailwindDirectives || hasExplicitSourceCssForCurrentAsset;
2145
- const scopedFallbackGeneratorRuntimeSet = hasExplicitTailwindV4SourceCss || !shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet;
2146
- const resolvedScopedGeneratorRuntimeSet = await createScopedGeneratorRuntime({
2147
- cssHandlerOptions,
2148
- fallbackRuntime: scopedFallbackGeneratorRuntimeSet,
2149
- getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
2150
- majorVersion: runtimeState.tailwindRuntime.majorVersion,
2151
- outputFile: file,
2152
- rawSource: sourceFile ? cssSources.get(path.resolve(sourceFile))?.css ?? generatorRawSource : generatorRawSource,
2153
- shouldExcludeSubpackageSourceCandidates: () => false,
2154
- sourceFile: sourceFile ?? file,
2155
- scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
2156
- });
2157
- const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== scopedFallbackGeneratorRuntimeSet && shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
2158
- const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
2159
- const scopedGeneratorCompilerOptions = scopeWebpackGeneratorOptionsToCssSource(compilerOptions, sourceFile, { disableUnmatchedCssEntries: !isWebGeneratorTarget && cssHandlerOptions.isMainChunk });
2160
- const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
2161
- ...cssHandlerOptions,
2162
- sourceOptions: {
2163
- ...cssHandlerOptions.sourceOptions,
2164
- cssSources: generatorCssSources
2165
- }
2166
- };
2167
- const generatorOptions = {
2168
- opts: scopedGeneratorCompilerOptions,
2169
- runtimeState,
2170
- runtime: scopedGeneratorRuntimeSet,
2171
- rawSource: generatorRawSource,
2172
- forceGenerator: shouldForceTailwindV4Generation,
2173
- ...hasUsableWebpackGeneratorCssSources(generatorCssSources) ? { cssSources: generatorCssSources } : {},
2174
- ...userRawSource === void 0 ? {} : { userRawSource: userRawSource.css },
2175
- ...userRawSource?.processed === true ? { userRawSourceProcessed: true } : {},
2176
- file,
2177
- cssHandlerOptions: generatorCssHandlerOptions,
2178
- cssUserHandlerOptions: getCssUserHandlerOptions(file),
2179
- getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
2180
- sourceCandidates: scopedGeneratorRuntimeSet,
2181
- restoreLocalCssImports: false,
2182
- styleHandler: compilerOptions.styleHandler,
2183
- debug
2184
- };
2185
- let generated;
2186
- if (!shouldSkipUnmatchedMainCssGeneration && !shouldSkipPlainNonMainCssGeneration) try {
2187
- generated = await generateTailwindV4Css({
2188
- ...generatorOptions,
2189
- outputFile: file
2190
- });
2191
- } catch (error) {
2192
- if (!shouldFallbackToWebpackUserCssOnGeneratorError({
2193
- configuredMainCssEntryFilesLength: configuredMainCssEntryFiles.length,
2194
- generatorRawSource,
2195
- hasExplicitTailwindV4SourceCss
2196
- })) throw error;
2197
- debug("css generator skipped for plain webpack css asset: %s %O", file, error);
2198
- generated = void 0;
2199
- }
2200
- else debug("css generator skipped for plain webpack css asset: %s", file);
2201
- const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
2202
- css: generated.css,
2203
- processed: true
2204
- }, {
2205
- css: removeWebpackTailwindGeneratedAssetCss(currentRawSource),
2206
- processed: true
2207
- })?.css ?? generated.css : generated.css, {
2208
- cssPreflight: cssHandlerOptions.isMainChunk,
2209
- generatedCss: true,
2210
- preserveExistingPreflight: shouldPreserveExistingPreflight
2211
- }) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
2212
- const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
2213
- userRawSource,
2214
- sourceCss === void 0 ? void 0 : {
2215
- css: sourceCss,
2216
- processed: sourceCssProcessed
2217
- },
2218
- {
2219
- css: generatorRawSource,
2220
- processed: false
2221
- }
2222
- ].map((source) => {
2223
- if (source === void 0) return;
2224
- return {
2225
- css: collectWebpackBareSelectorUserCss(source.css),
2226
- processed: source.processed
2227
- };
2228
- }));
2229
- const handledSourceBareUserCss = sourceBareUserCss === void 0 ? "" : sourceBareUserCss.processed ? sourceBareUserCss.css : (await compilerOptions.styleHandler(sourceBareUserCss.css, cssHandlerOptions)).css;
2230
- const finalizedSourceBareUserCss = handledSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledSourceBareUserCss, {
2231
- cssPreflight: false,
2232
- generatedCss: false
2233
- });
2234
- const missingSourceBareUserCss = finalizedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedGeneratedCss, finalizedSourceBareUserCss);
2235
- const css = finalizeTracedCss(missingSourceBareUserCss.trim().length === 0 ? finalizedGeneratedCss : createWebpackGeneratorUserCssSourceAppend({
2236
- css: finalizedGeneratedCss,
2237
- processed: true
2238
- }, {
2239
- css: missingSourceBareUserCss,
2240
- processed: true
2241
- }).css, cssHandlerOptions, { finalized: true });
2242
- const source = new ConcatSource(css);
2243
- if (generated) {
2244
- for (const className of generated.classSet) generatorRuntimeSet.add(className);
2245
- debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
2246
- } else debug("css handle: %s", file);
2247
- return { result: source };
2248
- }
2249
- });
2250
- }, cssTaskFactories);
2251
- }
2252
- if (!watchMode) {
2253
- pushConcurrentTaskFactories(tasks, htmlTaskFactories, taskConcurrency);
2254
- await Promise.all(tasks);
2255
- tasks.length = 0;
2256
- pushConcurrentTaskFactories(tasks, jsTaskFactories, taskConcurrency);
2257
- await Promise.all(tasks);
2258
- tasks.length = 0;
2259
- pushConcurrentTaskFactories(tasks, cssTaskFactories, taskConcurrency);
2436
+ if (await processWebpackProcessedCssAsset(element, cssTaskContext)) continue;
2437
+ await processWebpackGeneratedCssAsset(element, cssTaskContext);
2260
2438
  }
2261
- await Promise.all(tasks);
2262
- compilerOptions.cache.prune?.({
2263
- cacheKeys: activeProcessCacheKeys,
2264
- hashKeys: activeProcessHashKeys
2265
- });
2266
- const activeCssFiles = new Set(groupedEntries.css.map(([file]) => file));
2267
- pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
2268
- if (activeCssFiles.size > 0) pruneWebpackCssSources?.(/* @__PURE__ */ new Set([
2269
- ...registeredWebpackCssSourceFiles,
2270
- ...activeWebpackCssSourceFiles,
2271
- ...[...cssAssetResources.values()].flatMap((resources) => [...resources])
2272
- ]), { watchMode });
2273
- debug("end");
2274
- emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, { memoryDebug: resolveWebpackMemoryDebugStats({
2275
- activeAssetFiles: entries.length,
2276
- activeCssFiles: activeCssFiles.size,
2439
+ await finalizeWebpackProcessAssets({
2277
2440
  activeProcessCacheKeys,
2278
2441
  activeProcessHashKeys,
2279
- cache: compilerOptions.cache,
2442
+ activeWebpackCssSourceFiles,
2443
+ compilerOptions,
2444
+ cssAssetResources,
2280
2445
  cssHandlerOptionsCache,
2446
+ cssTaskFactories,
2281
2447
  cssUserHandlerOptionsCache,
2282
- phase: "processAssets",
2283
- sourceCandidateScan: webpackSourceCandidateScanCache.getMemoryStats()
2284
- }) });
2285
- compilerOptions.onEnd();
2448
+ debug,
2449
+ entries,
2450
+ groupedEntries,
2451
+ hmrTimingStartedAt,
2452
+ htmlTaskFactories,
2453
+ jsTaskFactories,
2454
+ pruneWebpackCssSources,
2455
+ recordTimingDetail,
2456
+ registeredWebpackCssSourceFiles,
2457
+ taskConcurrency,
2458
+ tasks,
2459
+ timingDetails,
2460
+ watchMode,
2461
+ webpackSourceCandidateScanCache
2462
+ });
2463
+ finalizeCompilerShadowRun(runtimeState);
2286
2464
  });
2287
2465
  if (!isWebGeneratorTarget) compilation.hooks.processAssets.tapPromise({
2288
2466
  name: `${pluginName}:finalize-css-assets`,
@@ -2303,11 +2481,106 @@ function setupWebpackV5ProcessAssetsHook(options) {
2303
2481
  });
2304
2482
  }
2305
2483
  //#endregion
2306
- //#region ../../node_modules/.pnpm/tsdown@0.22.4_oxc-resolver@11.20.0_tsx@4.23.0_typescript@6.0.3_unrun@0.2.37_synckit@0.1_ef728048c31c93ef751206e871d1f97d/node_modules/tsdown/esm-shims.js
2484
+ //#region ../../node_modules/.pnpm/tsdown@0.22.12_@volar+typescript@2.4.28_oxc-resolver@11.20.0_tsx@4.23.1_typescript@6.0._aa54d75c0ba96fdb34ddc2494c359153/node_modules/tsdown/esm-shims.js
2307
2485
  const getFilename = () => fileURLToPath(import.meta.url);
2308
2486
  const getDirname = () => path.dirname(getFilename());
2309
2487
  const __dirname = /* @__PURE__ */ getDirname();
2310
2488
  //#endregion
2489
+ //#region src/shared/mpx-plugin-owner.ts
2490
+ const localRequire = createRequire(import.meta.url);
2491
+ const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
2492
+ const MPX_WEBPACK_PLUGIN_LIB_RE = /^(.*[\\/]@mpxjs[\\/]webpack-plugin)[\\/]lib[\\/]/;
2493
+ const MPX_RECORD_RESOURCE_MAP_DEPENDENCY_RE = /@mpxjs[\\/]webpack-plugin[\\/]lib[\\/]dependencies[\\/]RecordResourceMapDependency(?:\.js)?$/;
2494
+ const compilationOwnerDirs = /* @__PURE__ */ new WeakMap();
2495
+ function findMpxWebpackPluginDir(value) {
2496
+ if (typeof value === "string") return value.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1];
2497
+ if (Array.isArray(value)) {
2498
+ for (const item of value) {
2499
+ const result = findMpxWebpackPluginDir(item);
2500
+ if (result) return result;
2501
+ }
2502
+ return;
2503
+ }
2504
+ if (value && typeof value === "object") for (const key of [
2505
+ "loader",
2506
+ "use",
2507
+ "rules",
2508
+ "oneOf"
2509
+ ]) {
2510
+ const result = findMpxWebpackPluginDir(value[key]);
2511
+ if (result) return result;
2512
+ }
2513
+ }
2514
+ function resolveContextPluginDir(context) {
2515
+ if (typeof context !== "string" || context.length === 0) return;
2516
+ try {
2517
+ const projectRequire = createRequire(path.join(context, "package.json"));
2518
+ return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
2519
+ } catch {
2520
+ return;
2521
+ }
2522
+ }
2523
+ function resolveCompilationPluginDir(compilation, candidates) {
2524
+ const getTemplate = compilation?.dependencyTemplates?.get;
2525
+ if (typeof getTemplate !== "function") return;
2526
+ if (compilation && typeof compilation === "object") {
2527
+ const cached = compilationOwnerDirs.get(compilation);
2528
+ if (cached) return cached;
2529
+ }
2530
+ const rememberOwner = (pluginDir) => {
2531
+ if (pluginDir && compilation && typeof compilation === "object") compilationOwnerDirs.set(compilation, pluginDir);
2532
+ return pluginDir;
2533
+ };
2534
+ for (const [file, module] of Object.entries(localRequire.cache)) {
2535
+ if (!MPX_RECORD_RESOURCE_MAP_DEPENDENCY_RE.test(file)) continue;
2536
+ if (getTemplate.call(compilation.dependencyTemplates, module?.exports)) return rememberOwner(file.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1]);
2537
+ }
2538
+ for (const pluginDir of candidates) try {
2539
+ const dependency = createRequire(path.join(pluginDir, "package.json"))(path.join(pluginDir, "lib/dependencies/RecordResourceMapDependency"));
2540
+ if (getTemplate.call(compilation.dependencyTemplates, dependency)) return rememberOwner(pluginDir);
2541
+ } catch {}
2542
+ }
2543
+ function collectMpxWebpackPluginDirs(owner, fallback) {
2544
+ const activeLoaderPluginDir = findMpxWebpackPluginDir([owner?._module?.loaders, owner?.loaders]);
2545
+ const contextPluginDirs = [
2546
+ owner?.rootContext,
2547
+ owner?.context,
2548
+ owner?.options?.context,
2549
+ process.cwd()
2550
+ ].map(resolveContextPluginDir).filter((item) => Boolean(item));
2551
+ const configuredRulePluginDir = findMpxWebpackPluginDir(owner?.options?.module?.rules);
2552
+ const cachedPluginDirs = Object.keys(localRequire.cache).map((file) => file.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1] ?? (MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file) ? path.dirname(file) : void 0)).filter((item) => Boolean(item));
2553
+ const localPluginDir = (() => {
2554
+ try {
2555
+ return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
2556
+ } catch {
2557
+ return;
2558
+ }
2559
+ })();
2560
+ return {
2561
+ activeLoaderPluginDir,
2562
+ candidates: new Set([
2563
+ activeLoaderPluginDir,
2564
+ ...contextPluginDirs,
2565
+ configuredRulePluginDir,
2566
+ fallback,
2567
+ ...cachedPluginDirs,
2568
+ localPluginDir
2569
+ ].filter((item) => Boolean(item))),
2570
+ configuredRulePluginDir,
2571
+ contextPluginDirs,
2572
+ cachedPluginDirs,
2573
+ localPluginDir
2574
+ };
2575
+ }
2576
+ function resolveMpxWebpackPluginCompilationOwnerDir(owner, compilation, fallback) {
2577
+ return resolveCompilationPluginDir(compilation, collectMpxWebpackPluginDirs(owner, fallback).candidates);
2578
+ }
2579
+ function resolveMpxWebpackPluginDir(owner, fallback, compilation = owner?._compilation ?? owner?.compilation) {
2580
+ const { activeLoaderPluginDir, candidates, configuredRulePluginDir, contextPluginDirs, cachedPluginDirs, localPluginDir } = collectMpxWebpackPluginDirs(owner, fallback);
2581
+ return resolveCompilationPluginDir(compilation, candidates) ?? activeLoaderPluginDir ?? contextPluginDirs[0] ?? configuredRulePluginDir ?? fallback ?? cachedPluginDirs[0] ?? localPluginDir;
2582
+ }
2583
+ //#endregion
2311
2584
  //#region src/shared/tailwindcss-css-redirect.ts
2312
2585
  const moduleWithMutableResolve = Module;
2313
2586
  const patched = /* @__PURE__ */ new WeakSet();
@@ -2326,33 +2599,8 @@ function installTailwindcssCssRedirect(pkgDir) {
2326
2599
  }
2327
2600
  //#endregion
2328
2601
  //#region src/shared/mpx.ts
2329
- const localRequire = createRequire(import.meta.url);
2330
2602
  const MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
2331
- const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
2332
- const MPX_WEBPACK_PLUGIN_LIB_RE = /^(.*[\\/]@mpxjs[\\/]webpack-plugin)[\\/]lib[\\/]/;
2333
- const MPX_WEBPACK_PLUGIN_REQUEST_RE = /@mpxjs\/webpack-plugin\/([^!?]+)/g;
2334
- function findMpxWebpackPluginDirFromRules(rules) {
2335
- const visit = (value) => {
2336
- if (typeof value === "string") return value.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1];
2337
- if (Array.isArray(value)) {
2338
- for (const item of value) {
2339
- const result = visit(item);
2340
- if (result) return result;
2341
- }
2342
- return;
2343
- }
2344
- if (value && typeof value === "object") for (const key of [
2345
- "loader",
2346
- "use",
2347
- "rules",
2348
- "oneOf"
2349
- ]) {
2350
- const result = visit(value[key]);
2351
- if (result) return result;
2352
- }
2353
- };
2354
- return visit(rules);
2355
- }
2603
+ const MPX_WEBPACK_PLUGIN_REQUEST_PATH_RE = /(?:^|[\\/])@mpxjs[\\/]webpack-plugin(?:[\\/](.+))?$/;
2356
2604
  function isMpxStyleResourceQuery(query) {
2357
2605
  if (typeof query !== "string") return false;
2358
2606
  return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
@@ -2360,34 +2608,16 @@ function isMpxStyleResourceQuery(query) {
2360
2608
  function getTailwindcssCssEntry(pkgDir) {
2361
2609
  return path.join(pkgDir, "index.css");
2362
2610
  }
2363
- function resolveMpxWebpackPluginDir(compiler) {
2364
- const rulePluginDir = findMpxWebpackPluginDirFromRules([
2365
- compiler?._module?.loaders,
2366
- compiler?.loaders,
2367
- compiler?.options?.module?.rules
2368
- ]);
2369
- if (rulePluginDir) return rulePluginDir;
2370
- const candidates = [
2371
- compiler?.context,
2372
- compiler?.options?.context,
2373
- process.cwd()
2374
- ].filter((item) => typeof item === "string" && item.length > 0);
2375
- for (const candidate of candidates) try {
2376
- const projectRequire = createRequire(path.join(candidate, "package.json"));
2377
- return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
2378
- } catch {}
2379
- const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
2380
- if (cachedPackageJson) return path.dirname(cachedPackageJson);
2381
- try {
2382
- return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
2383
- } catch {
2384
- return;
2385
- }
2386
- }
2387
2611
  function rewriteMpxWebpackPluginRequests(request, mpxWebpackPluginDir, pathImpl = path) {
2388
- return request.replace(MPX_WEBPACK_PLUGIN_REQUEST_RE, (_full, subpath) => {
2389
- return pathImpl.join(mpxWebpackPluginDir, ...subpath.split("/"));
2390
- });
2612
+ return request.split("!").map((segment) => {
2613
+ const queryIndex = segment.indexOf("?");
2614
+ const requestPath = queryIndex === -1 ? segment : segment.slice(0, queryIndex);
2615
+ const query = queryIndex === -1 ? "" : segment.slice(queryIndex);
2616
+ const match = requestPath.match(MPX_WEBPACK_PLUGIN_REQUEST_PATH_RE);
2617
+ if (!match) return segment;
2618
+ const subpath = match[1];
2619
+ return `${subpath ? pathImpl.join(mpxWebpackPluginDir, ...subpath.split(/[\\/]/)) : mpxWebpackPluginDir}${query}`;
2620
+ }).join("!");
2391
2621
  }
2392
2622
  function patchMpxWebpackPluginRequests(compiler, mpxWebpackPluginDir) {
2393
2623
  if (!mpxWebpackPluginDir || !compiler) return false;
@@ -2395,26 +2625,37 @@ function patchMpxWebpackPluginRequests(compiler, mpxWebpackPluginDir) {
2395
2625
  const patchedCompilers = /* @__PURE__ */ new WeakSet();
2396
2626
  const patchedLoaderResolvers = /* @__PURE__ */ new WeakSet();
2397
2627
  const patchedResolverFactories = /* @__PURE__ */ new WeakSet();
2628
+ let activePluginDir = mpxWebpackPluginDir;
2629
+ const getActivePluginDir = () => activePluginDir;
2398
2630
  const install = (targetCompiler) => {
2399
2631
  if (!targetCompiler || typeof targetCompiler !== "object" || patchedCompilers.has(targetCompiler)) return;
2400
2632
  patchedCompilers.add(targetCompiler);
2401
- ensureResolveLoaderAlias(targetCompiler, mpxWebpackPluginDir);
2633
+ ensureResolveLoaderAlias(targetCompiler, activePluginDir);
2402
2634
  const resolverFactory = targetCompiler.resolverFactory;
2403
2635
  if (resolverFactory && typeof resolverFactory === "object" && !patchedResolverFactories.has(resolverFactory)) {
2404
2636
  patchedResolverFactories.add(resolverFactory);
2405
- installMpxResolveLoaderAlias(targetCompiler, mpxWebpackPluginDir);
2637
+ installMpxResolveLoaderAlias(targetCompiler, getActivePluginDir);
2406
2638
  }
2407
2639
  targetCompiler.hooks?.normalModuleFactory?.tap?.(pluginName, (normalModuleFactory) => {
2408
2640
  const loaderResolver = normalModuleFactory.getResolver?.("loader");
2409
2641
  if (loaderResolver && typeof loaderResolver === "object" && !patchedLoaderResolvers.has(loaderResolver)) {
2410
2642
  patchedLoaderResolvers.add(loaderResolver);
2411
- patchMpxLoaderResolver(loaderResolver, mpxWebpackPluginDir);
2643
+ patchMpxLoaderResolver(loaderResolver, getActivePluginDir);
2412
2644
  }
2413
2645
  normalModuleFactory.hooks.beforeResolve.tap(pluginName, (resolveData) => {
2414
- if (typeof resolveData?.request === "string") resolveData.request = rewriteMpxWebpackPluginRequests(resolveData.request, mpxWebpackPluginDir);
2646
+ const pluginDir = getActivePluginDir();
2647
+ if (pluginDir && typeof resolveData?.request === "string") resolveData.request = rewriteMpxWebpackPluginRequests(resolveData.request, pluginDir);
2415
2648
  });
2416
2649
  });
2417
2650
  targetCompiler.hooks?.compilation?.tap?.(pluginName, (compilation) => {
2651
+ const compilationPluginDir = resolveMpxWebpackPluginCompilationOwnerDir(targetCompiler, compilation, activePluginDir);
2652
+ if (compilationPluginDir) {
2653
+ activePluginDir = compilationPluginDir;
2654
+ patchMpxWebpackPluginNormalizeLib(targetCompiler, compilationPluginDir);
2655
+ ensureResolveLoaderAlias(targetCompiler, compilationPluginDir);
2656
+ const alias = targetCompiler.options?.resolve?.alias;
2657
+ if (alias) addMpxWebpackPluginAlias(alias, compilationPluginDir);
2658
+ }
2418
2659
  compilation.hooks?.childCompiler?.tap?.(pluginName, (childCompiler) => {
2419
2660
  install(childCompiler);
2420
2661
  });
@@ -2434,20 +2675,33 @@ function addMpxWebpackPluginAlias(alias, pkgDir) {
2434
2675
  const recordLoader = path.join(pkgDir, "lib/record-loader");
2435
2676
  const styleCompiler = path.join(pkgDir, "lib/style-compiler/index");
2436
2677
  const stripConditionalLoader = path.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
2437
- if (Array.isArray(alias)) alias.push({
2438
- name: "@mpxjs/webpack-plugin/lib/record-loader",
2439
- alias: recordLoader
2440
- }, {
2441
- name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
2442
- alias: styleCompiler
2443
- }, {
2444
- name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
2445
- alias: stripConditionalLoader
2446
- }, {
2447
- name: /^@mpxjs\/webpack-plugin\//,
2448
- alias: pkgDir
2449
- });
2450
- else {
2678
+ if (Array.isArray(alias)) {
2679
+ const entries = [
2680
+ {
2681
+ name: "@mpxjs/webpack-plugin/lib/record-loader",
2682
+ alias: recordLoader
2683
+ },
2684
+ {
2685
+ name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
2686
+ alias: styleCompiler
2687
+ },
2688
+ {
2689
+ name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
2690
+ alias: stripConditionalLoader
2691
+ },
2692
+ {
2693
+ name: /^@mpxjs\/webpack-plugin\//,
2694
+ alias: pkgDir
2695
+ }
2696
+ ];
2697
+ const managedNames = new Set(entries.filter((entry) => typeof entry.name === "string").map((entry) => entry.name));
2698
+ const managedPatterns = new Set(entries.filter((entry) => entry.name instanceof RegExp).map((entry) => `${entry.name.source}/${entry.name.flags}`));
2699
+ for (let index = alias.length - 1; index >= 0; index--) {
2700
+ const name = alias[index]?.name;
2701
+ if (managedNames.has(name) || name instanceof RegExp && managedPatterns.has(`${name.source}/${name.flags}`)) alias.splice(index, 1);
2702
+ }
2703
+ alias.unshift(...entries);
2704
+ } else {
2451
2705
  alias["@mpxjs/webpack-plugin"] = pkgDir;
2452
2706
  alias["@mpxjs/webpack-plugin$"] = pkgDir;
2453
2707
  alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
@@ -2461,13 +2715,15 @@ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
2461
2715
  compiler.options.resolveLoader.alias = alias;
2462
2716
  addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
2463
2717
  }
2464
- function installMpxResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
2718
+ function installMpxResolveLoaderAlias(compiler, getMpxWebpackPluginDir) {
2465
2719
  const resolveOptionsHook = compiler?.resolverFactory?.hooks?.resolveOptions?.for?.("loader");
2466
2720
  if (!resolveOptionsHook?.tap) return;
2467
2721
  resolveOptionsHook.tap({
2468
2722
  name: "weapp-tailwindcss-mpx-loader-resolve",
2469
2723
  stage: 100
2470
2724
  }, (resolveOptions) => {
2725
+ const mpxWebpackPluginDir = getMpxWebpackPluginDir();
2726
+ if (!mpxWebpackPluginDir) return resolveOptions;
2471
2727
  const alias = Array.isArray(resolveOptions.alias) ? [...resolveOptions.alias] : { ...resolveOptions.alias };
2472
2728
  addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
2473
2729
  return {
@@ -2476,13 +2732,14 @@ function installMpxResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
2476
2732
  };
2477
2733
  });
2478
2734
  }
2479
- function patchMpxLoaderResolver(resolver, mpxWebpackPluginDir) {
2735
+ function patchMpxLoaderResolver(resolver, getMpxWebpackPluginDir) {
2480
2736
  const originalResolve = resolver?.resolve;
2481
2737
  if (typeof originalResolve !== "function" || originalResolve.__weappTwPatched) return;
2482
2738
  const wrappedResolve = function(...args) {
2483
2739
  const requestIndex = typeof args[0] === "string" ? 1 : 2;
2484
2740
  const request = args[requestIndex];
2485
- if (typeof request === "string" && isMpxWebpackPluginRequest(request)) args[requestIndex] = resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir);
2741
+ const mpxWebpackPluginDir = getMpxWebpackPluginDir();
2742
+ if (mpxWebpackPluginDir && typeof request === "string" && isMpxWebpackPluginRequest(request)) args[requestIndex] = resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir);
2486
2743
  return originalResolve.apply(this, args);
2487
2744
  };
2488
2745
  wrappedResolve.__weappTwPatched = true;
@@ -2532,12 +2789,13 @@ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
2532
2789
  function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
2533
2790
  if (!enabled) return;
2534
2791
  const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
2535
- const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
2792
+ const getMpxWebpackPluginDir = () => resolveMpxWebpackPluginDir(loaderContext);
2536
2793
  const originalResolve = loaderContext.resolve;
2537
2794
  if (typeof originalResolve === "function" && !originalResolve.__weappTwPatched) {
2538
2795
  const wrappedResolve = function(context, request, callback) {
2539
2796
  if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
2540
2797
  if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
2798
+ const mpxWebpackPluginDir = getMpxWebpackPluginDir();
2541
2799
  if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
2542
2800
  return originalResolve.call(this, context, request, callback);
2543
2801
  };
@@ -2545,9 +2803,10 @@ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
2545
2803
  loaderContext.resolve = wrappedResolve;
2546
2804
  }
2547
2805
  const originalImportModule = loaderContext.importModule;
2548
- if (mpxWebpackPluginDir && typeof originalImportModule === "function" && !originalImportModule.__weappTwPatched) {
2806
+ if (typeof originalImportModule === "function" && !originalImportModule.__weappTwPatched) {
2549
2807
  const wrappedImportModule = function(request, ...args) {
2550
- const resolvedRequest = typeof request === "string" ? rewriteMpxWebpackPluginRequests(request, mpxWebpackPluginDir) : request;
2808
+ const mpxWebpackPluginDir = getMpxWebpackPluginDir();
2809
+ const resolvedRequest = mpxWebpackPluginDir && typeof request === "string" ? rewriteMpxWebpackPluginRequests(request, mpxWebpackPluginDir) : request;
2551
2810
  return originalImportModule.call(this, resolvedRequest, ...args);
2552
2811
  };
2553
2812
  wrappedImportModule.__weappTwPatched = true;
@@ -2619,7 +2878,7 @@ function createDefaultLoaderAnchorFinders() {
2619
2878
  //#endregion
2620
2879
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
2621
2880
  function setupWebpackV5Loaders(options) {
2622
- const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, loaderAnchorFinders = createDefaultLoaderAnchorFinders(), mpxCssImportRewrite = false, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
2881
+ const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, updateWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, loaderAnchorFinders = createDefaultLoaderAnchorFinders(), mpxCssImportRewrite = false, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
2623
2882
  const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(compilerOptions.generator, {
2624
2883
  appType: compilerOptions.appType,
2625
2884
  platform: compilerOptions.cssOptions?.platform ?? compilerOptions.platform,
@@ -2635,12 +2894,12 @@ function setupWebpackV5Loaders(options) {
2635
2894
  uniAppX: compilerOptions.uniAppX
2636
2895
  });
2637
2896
  if (shouldRewriteCssImports && mpxCssImportRewrite) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
2638
- const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
2897
+ const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.cjs");
2639
2898
  const shouldInjectRuntimeClassSetLoader = !generatorBranch.isWeb;
2640
2899
  const shouldInjectCssGenerationLoader = generatorOptions.enabled && runtimeState.tailwindRuntime.majorVersion === 4 && (generatorTarget === "web" || generatorTarget === "weapp");
2641
2900
  const shouldInjectCssImportRewriteLoader = shouldRewriteCssImports || shouldInjectCssGenerationLoader;
2642
- const runtimeCssGenerationLoader = shouldInjectCssGenerationLoader ? path.resolve(__dirname, "./weapp-tw-css-generation-loader.js") : void 0;
2643
- const runtimeCssImportRewriteLoader = shouldInjectCssImportRewriteLoader ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
2901
+ const runtimeCssGenerationLoader = shouldInjectCssGenerationLoader ? path.resolve(__dirname, "./weapp-tw-css-generation-loader.cjs") : void 0;
2902
+ const runtimeCssImportRewriteLoader = shouldInjectCssImportRewriteLoader ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.cjs") : void 0;
2644
2903
  const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
2645
2904
  const runtimeCssGenerationLoaderExists = runtimeCssGenerationLoader ? fs.existsSync(runtimeCssGenerationLoader) : false;
2646
2905
  const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
@@ -2659,12 +2918,14 @@ function setupWebpackV5Loaders(options) {
2659
2918
  classSet: {
2660
2919
  getClassSet: getClassSetInLoader,
2661
2920
  getWatchDependencies: getRuntimeWatchDependencies,
2662
- ...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile }
2921
+ ...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile },
2922
+ ...updateWebpackGeneratedCss === void 0 ? {} : { updateGeneratedCss: updateWebpackGeneratedCss }
2663
2923
  },
2664
2924
  ...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
2665
2925
  });
2666
2926
  const cleanupWebpackLoaderRuntime = () => {
2667
2927
  deleteWebpackLoaderRuntime(runtimeRegistryKey);
2928
+ disposeCompilerOwner(runtimeState);
2668
2929
  };
2669
2930
  compiler.hooks.watchClose?.tap?.(pluginName, cleanupWebpackLoaderRuntime);
2670
2931
  compiler.hooks.shutdown?.tap?.(pluginName, cleanupWebpackLoaderRuntime);
@@ -2711,6 +2972,10 @@ function setupWebpackV5Loaders(options) {
2711
2972
  let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
2712
2973
  const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
2713
2974
  const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
2975
+ if (isCssModule) {
2976
+ const frameworkPostcssOptions = collectFrameworkPostcssOptionsFromLoaderEntries(loaderEntries, _loaderContext);
2977
+ if (frameworkPostcssOptions) captureResolvedFrameworkPostcssOptions(compilerOptions, frameworkPostcssOptions);
2978
+ }
2714
2979
  if (isCssModule && typeof module.resource === "string") markWebpackCssSourceModule?.(module.resource);
2715
2980
  if (process.env["WEAPP_TW_LOADER_DEBUG"] && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
2716
2981
  rewriteAnchorIdx,
@@ -2758,7 +3023,7 @@ function setupWebpackV5Loaders(options) {
2758
3023
  });
2759
3024
  }
2760
3025
  //#endregion
2761
- //#region src/bundlers/webpack/shared/create-framework-plugin.ts
3026
+ //#region src/bundlers/webpack/shared/create-framework-plugin/watch-output.ts
2762
3027
  const debug = createDebug();
2763
3028
  const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
2764
3029
  const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
@@ -2824,6 +3089,8 @@ function setupWebpackWatchOutputIgnore(compiler) {
2824
3089
  }
2825
3090
  });
2826
3091
  }
3092
+ //#endregion
3093
+ //#region src/bundlers/webpack/shared/create-framework-plugin/plugin.ts
2827
3094
  function isInternalUserDefinedOptions(options) {
2828
3095
  return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
2829
3096
  }
@@ -2969,6 +3236,15 @@ var WebpackFrameworkPlugin = class {
2969
3236
  });
2970
3237
  currentWebpackCssSourceFiles.add(file);
2971
3238
  };
3239
+ const updateWebpackGeneratedCss = (source) => {
3240
+ const file = path.resolve(source.file);
3241
+ const previous = webpackGeneratedCssSources.get(file);
3242
+ if (!previous) return;
3243
+ webpackGeneratedCssSources.set(file, {
3244
+ ...previous,
3245
+ css: source.css
3246
+ });
3247
+ };
2972
3248
  const pruneWebpackCssSources = (activeSourceFiles, _options = {}) => {
2973
3249
  const tailwindOptions = resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
2974
3250
  const configuredSourceFiles = /* @__PURE__ */ new Set();
@@ -3046,6 +3322,7 @@ var WebpackFrameworkPlugin = class {
3046
3322
  markWebpackCssSourceModule,
3047
3323
  registerWebpackCssSourceFile,
3048
3324
  registerWebpackGeneratedCss,
3325
+ updateWebpackGeneratedCss,
3049
3326
  getRuntimeWatchDependencies() {
3050
3327
  return {
3051
3328
  files: runtimeWatchDependencyFiles,