weapp-tailwindcss 4.12.0-next.0 → 5.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/bin/weapp-tailwindcss.js +21 -1
  2. package/dist/babel/index.d.ts +3 -0
  3. package/dist/bundlers/gulp/index.d.ts +7 -0
  4. package/dist/bundlers/shared/cache.d.ts +16 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
  6. package/dist/bundlers/shared/css-imports.d.ts +8 -0
  7. package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
  8. package/dist/bundlers/shared/generator-css.d.ts +41 -0
  9. package/dist/bundlers/shared/module-graph.d.ts +5 -0
  10. package/dist/bundlers/shared/run-tasks.d.ts +2 -0
  11. package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
  12. package/dist/bundlers/vite/bundle-state.d.ts +43 -0
  13. package/dist/bundlers/vite/css-finalizer.d.ts +19 -0
  14. package/dist/bundlers/vite/generate-bundle.d.ts +20 -0
  15. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
  16. package/dist/bundlers/vite/index.d.ts +3 -0
  17. package/dist/bundlers/vite/js-precheck.d.ts +1 -0
  18. package/dist/bundlers/vite/query.d.ts +15 -0
  19. package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
  20. package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
  21. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
  22. package/dist/bundlers/vite/utils.d.ts +9 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
  26. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
  27. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
  28. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
  29. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
  30. package/dist/bundlers/webpack/index.d.ts +1 -0
  31. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
  32. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
  33. package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
  34. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
  35. package/dist/cache/index.d.ts +38 -0
  36. package/dist/cache/md5.d.ts +1 -0
  37. package/dist/chunk-8l464Juk.js +28 -0
  38. package/dist/cli/config.d.ts +5 -0
  39. package/dist/cli/context.d.ts +16 -0
  40. package/dist/cli/doctor/constants.d.ts +7 -0
  41. package/dist/cli/doctor/types.d.ts +31 -0
  42. package/dist/cli/doctor.d.ts +4 -0
  43. package/dist/cli/helpers/options/format.d.ts +2 -0
  44. package/dist/cli/helpers/options/parse.d.ts +3 -0
  45. package/dist/cli/helpers/options/resolve.d.ts +1 -0
  46. package/dist/cli/helpers/options.d.ts +3 -0
  47. package/dist/cli/helpers/patch-cwd.d.ts +1 -0
  48. package/dist/cli/helpers.d.ts +5 -0
  49. package/dist/cli/mount-options/patch-status.d.ts +2 -0
  50. package/dist/cli/mount-options.d.ts +2 -0
  51. package/dist/cli/patch-options.d.ts +6 -0
  52. package/dist/cli/tokens.d.ts +4 -0
  53. package/dist/cli/types.d.ts +17 -0
  54. package/dist/cli/vscode-entry.d.ts +14 -0
  55. package/dist/cli/workspace/package-dirs.d.ts +3 -0
  56. package/dist/cli/workspace/patch-package.d.ts +3 -0
  57. package/dist/cli/workspace/patch-utils.d.ts +3 -0
  58. package/dist/cli/workspace/types.d.ts +11 -0
  59. package/dist/cli/workspace/workspace-globs.d.ts +2 -0
  60. package/dist/cli/workspace/workspace-io.d.ts +1 -0
  61. package/dist/cli/workspace/workspace-lock.d.ts +1 -0
  62. package/dist/cli/workspace.d.ts +2 -0
  63. package/dist/cli.d.ts +1 -2
  64. package/dist/cli.js +2517 -1544
  65. package/dist/cli.mjs +2493 -1524
  66. package/dist/constants-B-_T5UnW.mjs +44 -0
  67. package/dist/constants-p1dyh1x1.js +73 -0
  68. package/dist/constants.d.ts +13 -0
  69. package/dist/context/compiler-context-cache.d.ts +3 -0
  70. package/dist/context/custom-attributes.d.ts +2 -0
  71. package/dist/context/handlers.d.ts +6 -0
  72. package/dist/context/index.d.ts +7 -0
  73. package/dist/context/logger.d.ts +4 -0
  74. package/dist/context/tailwindcss/basedir.d.ts +1 -0
  75. package/dist/context/tailwindcss/rax.d.ts +2 -0
  76. package/dist/context/tailwindcss.d.ts +4 -0
  77. package/dist/context/workspace.d.ts +3 -0
  78. package/dist/core.d.ts +5 -21
  79. package/dist/core.js +138 -180
  80. package/dist/core.mjs +135 -180
  81. package/dist/css-imports-BbrbluP9.js +177 -0
  82. package/dist/css-imports-CSdPq_Sc.mjs +128 -0
  83. package/dist/css-macro/constants.d.ts +14 -0
  84. package/dist/css-macro/index.d.ts +15 -0
  85. package/dist/css-macro/postcss.d.ts +3 -7
  86. package/dist/css-macro/postcss.js +44 -58
  87. package/dist/css-macro/postcss.mjs +44 -56
  88. package/dist/css-macro.d.ts +1 -20
  89. package/dist/css-macro.js +37 -50
  90. package/dist/css-macro.mjs +33 -47
  91. package/dist/debug/index.d.ts +5 -0
  92. package/dist/defaults.d.ts +2 -11
  93. package/dist/defaults.js +132 -8
  94. package/dist/defaults.mjs +128 -7
  95. package/dist/escape.js +31 -54
  96. package/dist/escape.mjs +18 -25
  97. package/dist/experimental/index.d.ts +2 -0
  98. package/dist/experimental/oxc/ast-utils.d.ts +30 -0
  99. package/dist/experimental/oxc/index.d.ts +2 -0
  100. package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
  101. package/dist/experimental/shared/cache.d.ts +3 -0
  102. package/dist/experimental/shared/transform.d.ts +3 -0
  103. package/dist/experimental/shared.d.ts +8 -0
  104. package/dist/experimental/swc/ast-utils.d.ts +30 -0
  105. package/dist/experimental/swc/index.d.ts +2 -0
  106. package/dist/experimental/swc/module-specifiers.d.ts +2 -0
  107. package/dist/generator/index.d.ts +11 -0
  108. package/dist/generator/options.d.ts +15 -0
  109. package/dist/generator/types.d.ts +19 -0
  110. package/dist/generator-CZ-JXw6T.js +492 -0
  111. package/dist/generator-Dwxgra97.mjs +399 -0
  112. package/dist/generator-css-CnYjiMrD.js +1084 -0
  113. package/dist/generator-css-DhPFjSzK.mjs +1057 -0
  114. package/dist/generator.d.ts +1 -0
  115. package/dist/generator.js +19 -0
  116. package/dist/generator.mjs +2 -0
  117. package/dist/gulp.d.ts +4 -24
  118. package/dist/gulp.js +271 -13
  119. package/dist/gulp.mjs +263 -13
  120. package/dist/index.d.ts +8 -15
  121. package/dist/index.js +12 -24
  122. package/dist/index.mjs +6 -24
  123. package/dist/js/JsTokenUpdater.d.ts +14 -0
  124. package/dist/js/ModuleGraph.d.ts +18 -0
  125. package/dist/js/NodePathWalker.d.ts +33 -0
  126. package/dist/js/babel/parse.d.ts +9 -0
  127. package/dist/js/babel/process.d.ts +4 -0
  128. package/dist/js/babel.d.ts +13 -0
  129. package/dist/js/class-context.d.ts +3 -0
  130. package/dist/js/evalTransforms.d.ts +7 -0
  131. package/dist/js/handlers.d.ts +5 -0
  132. package/dist/js/index.d.ts +4 -0
  133. package/dist/js/module-graph/ignored-exports.d.ts +18 -0
  134. package/dist/js/module-graph/types.d.ts +17 -0
  135. package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
  136. package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
  137. package/dist/js/precheck.d.ts +2 -0
  138. package/dist/js/sourceAnalysis.d.ts +17 -0
  139. package/dist/js/syntax.d.ts +10 -0
  140. package/dist/js/taggedTemplateIgnore.d.ts +13 -0
  141. package/dist/js/types.d.ts +11 -0
  142. package/dist/lightningcss/index.d.ts +8 -0
  143. package/dist/lightningcss/style-handler/options.d.ts +3 -0
  144. package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
  145. package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
  146. package/dist/lightningcss/style-handler.d.ts +17 -0
  147. package/dist/loader-anchors-DvwgIYdA.mjs +205 -0
  148. package/dist/loader-anchors-cprm4Klq.js +273 -0
  149. package/dist/logger/index.d.ts +2 -0
  150. package/dist/logger-BZ45DZJT.js +1003 -0
  151. package/dist/logger-BoVx1Dbt.mjs +935 -0
  152. package/dist/patcher-options-6gJN2EXy.js +115 -0
  153. package/dist/patcher-options-DQfR5xxT.mjs +92 -0
  154. package/dist/postcss-html-transform.d.ts +3 -3
  155. package/dist/postcss-html-transform.js +7 -10
  156. package/dist/postcss-html-transform.mjs +3 -6
  157. package/dist/postcss.d.ts +15 -0
  158. package/dist/postcss.js +278 -0
  159. package/dist/postcss.mjs +268 -0
  160. package/dist/presets/hbuilderx.d.ts +4 -0
  161. package/dist/presets/index.d.ts +3 -0
  162. package/dist/presets/shared.d.ts +10 -0
  163. package/dist/presets/taro.d.ts +4 -0
  164. package/dist/presets/uni-app-x.d.ts +16 -0
  165. package/dist/presets/uni-app.d.ts +4 -0
  166. package/dist/presets.d.ts +1 -76
  167. package/dist/presets.js +115 -163
  168. package/dist/presets.mjs +107 -163
  169. package/dist/recorder-B_XyZ576.mjs +2763 -0
  170. package/dist/recorder-rn_2v_nd.js +2878 -0
  171. package/dist/reset/index.d.ts +2 -0
  172. package/dist/reset.d.ts +1 -4
  173. package/dist/reset.js +19 -8
  174. package/dist/reset.mjs +2 -8
  175. package/dist/shared/classname-transform.d.ts +14 -0
  176. package/dist/shared/mpx.d.ts +7 -0
  177. package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
  178. package/dist/tailwindcss/index.d.ts +11 -0
  179. package/dist/tailwindcss/miniprogram.d.ts +1 -0
  180. package/dist/tailwindcss/patcher-options.d.ts +56 -0
  181. package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
  182. package/dist/tailwindcss/patcher.d.ts +13 -0
  183. package/dist/tailwindcss/recorder.d.ts +13 -0
  184. package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
  185. package/dist/tailwindcss/runtime/cache.d.ts +11 -0
  186. package/dist/tailwindcss/runtime-logs.d.ts +3 -0
  187. package/dist/tailwindcss/runtime.d.ts +29 -0
  188. package/dist/tailwindcss/targets/paths.d.ts +13 -0
  189. package/dist/tailwindcss/targets/record-io.d.ts +5 -0
  190. package/dist/tailwindcss/targets/recorder.d.ts +3 -0
  191. package/dist/tailwindcss/targets/types.d.ts +35 -0
  192. package/dist/tailwindcss/targets.d.ts +6 -0
  193. package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
  194. package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
  195. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
  196. package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
  197. package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
  198. package/dist/tailwindcss/v4/config.d.ts +5 -0
  199. package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
  200. package/dist/tailwindcss/v4/index.d.ts +2 -0
  201. package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
  202. package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
  203. package/dist/tailwindcss/v4/patcher.d.ts +14 -0
  204. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
  205. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
  206. package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
  207. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +4 -0
  208. package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
  209. package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
  210. package/dist/typedoc.export.d.ts +5 -0
  211. package/dist/types/base.d.ts +1 -0
  212. package/dist/types/disabled-options.d.ts +4 -0
  213. package/dist/types/index.d.ts +104 -0
  214. package/dist/types/shared.d.ts +7 -0
  215. package/dist/types/user-defined-options/general.d.ts +31 -0
  216. package/dist/types/user-defined-options/important.d.ts +37 -0
  217. package/dist/types/user-defined-options/index.d.ts +11 -0
  218. package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
  219. package/dist/types/user-defined-options/matcher.d.ts +9 -0
  220. package/dist/types.d.ts +1 -150
  221. package/dist/types.js +0 -1
  222. package/dist/types.mjs +1 -1
  223. package/dist/uni-app-x/component-local-style.d.ts +19 -0
  224. package/dist/uni-app-x/index.d.ts +2 -0
  225. package/dist/uni-app-x/options.d.ts +12 -0
  226. package/dist/uni-app-x/style-isolation.d.ts +2 -0
  227. package/dist/uni-app-x/transform.d.ts +9 -0
  228. package/dist/uni-app-x/vite.d.ts +36 -0
  229. package/dist/utils/decode.d.ts +2 -0
  230. package/dist/utils/disabled.d.ts +6 -0
  231. package/dist/utils/hbuilderx.d.ts +5 -0
  232. package/dist/utils/index.d.ts +7 -0
  233. package/dist/utils/nameMatcher.d.ts +4 -0
  234. package/dist/utils/resolve-package.d.ts +1 -0
  235. package/dist/utils/uni-platform.d.ts +11 -0
  236. package/dist/utils-7DUGTFED.mjs +48 -0
  237. package/dist/utils-DmC9_In3.js +61 -0
  238. package/dist/vite-BHpAqldo.js +1952 -0
  239. package/dist/vite-C8JlHiyR.mjs +1940 -0
  240. package/dist/vite.d.ts +4 -17
  241. package/dist/vite.js +5 -14
  242. package/dist/vite.mjs +2 -14
  243. package/dist/weapp-tw-css-import-rewrite-loader.js +59 -87
  244. package/dist/weapp-tw-runtime-classset-loader.js +33 -47
  245. package/dist/webpack-CABjKGGQ.mjs +441 -0
  246. package/dist/webpack-DNIJ0ysE.js +456 -0
  247. package/dist/webpack.d.ts +4 -25
  248. package/dist/webpack.js +6 -17
  249. package/dist/webpack.mjs +2 -17
  250. package/dist/webpack4.d.ts +4 -26
  251. package/dist/webpack4.js +379 -481
  252. package/dist/webpack4.mjs +370 -482
  253. package/dist/wxml/Tokenizer.d.ts +15 -0
  254. package/dist/wxml/custom-attributes.d.ts +4 -0
  255. package/dist/wxml/index.d.ts +2 -0
  256. package/dist/wxml/shared.d.ts +2 -0
  257. package/dist/wxml/tokenizer/types.d.ts +18 -0
  258. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
  259. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
  260. package/dist/wxml/utils/codegen.d.ts +2 -0
  261. package/dist/wxml/utils/custom-template.d.ts +3 -0
  262. package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
  263. package/dist/wxml/utils/fragment-updater.d.ts +4 -0
  264. package/dist/wxml/utils/template-fragments.d.ts +3 -0
  265. package/dist/wxml/utils.d.ts +8 -0
  266. package/dist/wxml/whitespace.d.ts +2 -0
  267. package/generator-placeholder.css +1 -0
  268. package/package.json +28 -13
  269. package/scripts/postinstall.mjs +59 -0
  270. package/dist/chunk-2LH6PZH3.mjs +0 -51
  271. package/dist/chunk-4AFQP74Z.js +0 -24
  272. package/dist/chunk-5ONE75V7.js +0 -2381
  273. package/dist/chunk-76S2EME4.mjs +0 -34
  274. package/dist/chunk-A5PB4KZT.js +0 -138
  275. package/dist/chunk-AYJ4HLWZ.mjs +0 -1508
  276. package/dist/chunk-DYLQ6UOI.js +0 -71
  277. package/dist/chunk-F2CKKG6Q.mjs +0 -171
  278. package/dist/chunk-F5XJWJYO.mjs +0 -582
  279. package/dist/chunk-FMK6SFQQ.js +0 -276
  280. package/dist/chunk-GC7WXUOW.js +0 -3906
  281. package/dist/chunk-GD4SQMVF.mjs +0 -2378
  282. package/dist/chunk-GMKSBLNY.js +0 -175
  283. package/dist/chunk-HL3US2OT.mjs +0 -10
  284. package/dist/chunk-LVSUBDJC.js +0 -579
  285. package/dist/chunk-NIS74SI6.js +0 -1511
  286. package/dist/chunk-OF6MFURR.js +0 -34
  287. package/dist/chunk-ONLKZIRQ.js +0 -7
  288. package/dist/chunk-OOHJLO5M.mjs +0 -71
  289. package/dist/chunk-OYSABARD.js +0 -51
  290. package/dist/chunk-QNRJCEZN.mjs +0 -3906
  291. package/dist/chunk-UUJWDME4.mjs +0 -276
  292. package/dist/chunk-WSS26HZS.js +0 -292
  293. package/dist/chunk-XAKAD2CR.mjs +0 -138
  294. package/dist/chunk-ZR3KN3FG.mjs +0 -292
  295. package/dist/cli.d.mts +0 -2
  296. package/dist/core.d.mts +0 -26
  297. package/dist/css-macro/postcss.d.mts +0 -7
  298. package/dist/css-macro.d.mts +0 -18
  299. package/dist/defaults.d.mts +0 -11
  300. package/dist/gulp.d.mts +0 -24
  301. package/dist/index-BXrmQelt.d.mts +0 -672
  302. package/dist/index-BXrmQelt.d.ts +0 -672
  303. package/dist/index.d.mts +0 -15
  304. package/dist/postcss-html-transform.d.mts +0 -2
  305. package/dist/presets.d.mts +0 -76
  306. package/dist/reset.d.mts +0 -1
  307. package/dist/types.d.mts +0 -150
  308. package/dist/vite.d.mts +0 -17
  309. package/dist/webpack.d.mts +0 -25
  310. package/dist/webpack4.d.mts +0 -26
package/dist/webpack4.js CHANGED
@@ -1,489 +1,387 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
- var _chunkWSS26HZSjs = require('./chunk-WSS26HZS.js');
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunkGMKSBLNYjs = require('./chunk-GMKSBLNY.js');
21
-
22
-
23
- var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
- var _chunkGC7WXUOWjs = require('./chunk-GC7WXUOW.js');
32
-
33
-
34
- var _chunkNIS74SI6js = require('./chunk-NIS74SI6.js');
35
- require('./chunk-A5PB4KZT.js');
36
-
37
-
38
- var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
39
- require('./chunk-ONLKZIRQ.js');
40
-
41
- // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
42
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
43
-
44
- // src/bundlers/webpack/BaseUnifiedPlugin/v4-assets.ts
45
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
46
-
47
- var _webpacksources = require('webpack-sources');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-8l464Juk.js");
3
+ const require_recorder = require("./recorder-rn_2v_nd.js");
4
+ const require_utils = require("./utils-DmC9_In3.js");
5
+ const require_logger = require("./logger-BZ45DZJT.js");
6
+ const require_generator_css = require("./generator-css-CnYjiMrD.js");
7
+ const require_css_imports = require("./css-imports-BbrbluP9.js");
8
+ const require_loader_anchors = require("./loader-anchors-cprm4Klq.js");
9
+ let node_path = require("node:path");
10
+ node_path = require_chunk.__toESM(node_path);
11
+ let node_process = require("node:process");
12
+ node_process = require_chunk.__toESM(node_process);
13
+ let node_fs = require("node:fs");
14
+ node_fs = require_chunk.__toESM(node_fs);
15
+ let webpack_sources = require("webpack-sources");
16
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v4-assets.ts
48
17
  function resolveWebpackStaleClassNameFallback(option, _compiler) {
49
- if (typeof option === "boolean") {
50
- return option;
51
- }
52
- return false;
18
+ if (typeof option === "boolean") return option;
19
+ return false;
20
+ }
21
+ function toWebpackV4AssetCompilation(compilation) {
22
+ return compilation;
23
+ }
24
+ function readWebpackV4AssetSource(asset) {
25
+ const source = asset.source();
26
+ return typeof source === "string" ? source : source.toString();
53
27
  }
54
28
  function setupWebpackV4EmitHook(options) {
55
- const {
56
- compiler,
57
- options: compilerOptions,
58
- appType,
59
- runtimeState,
60
- debug: debug2
61
- } = options;
62
- const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
63
- compiler.hooks.emit.tapPromise(_chunkGC7WXUOWjs.pluginName, async (compilation) => {
64
- await runtimeState.patchPromise;
65
- compilerOptions.onStart();
66
- debug2("start");
67
- for (const chunk of compilation.chunks) {
68
- if (chunk.id && chunk.hash) {
69
- compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
70
- }
71
- }
72
- const assetHashByChunk = _chunkWSS26HZSjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
73
- const assets = compilation.assets;
74
- const entries = Object.entries(assets);
75
- const outputDir = _optionalChain([compiler, 'access', _ => _.options, 'optionalAccess', _2 => _2.output, 'optionalAccess', _3 => _3.path]) ? _path2.default.resolve(compiler.options.output.path) : _process2.default.cwd();
76
- const jsAssets = /* @__PURE__ */ new Map();
77
- for (const [file] of entries) {
78
- if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
79
- const absolute = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
80
- jsAssets.set(absolute, file);
81
- }
82
- }
83
- const moduleGraphOptions = {
84
- resolve(specifier, importer) {
85
- return _chunkGMKSBLNYjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
86
- },
87
- load: (id) => {
88
- const assetName = jsAssets.get(id);
89
- if (!assetName) {
90
- return void 0;
91
- }
92
- const assetSource = compilation.assets[assetName];
93
- if (!assetSource) {
94
- return void 0;
95
- }
96
- const source = assetSource.source();
97
- return typeof source === "string" ? source : source.toString();
98
- },
99
- filter(id) {
100
- return jsAssets.has(id);
101
- }
102
- };
103
- const applyLinkedResults = (linked) => {
104
- if (!linked) {
105
- return;
106
- }
107
- for (const [id, { code }] of Object.entries(linked)) {
108
- const assetName = jsAssets.get(id);
109
- if (!assetName) {
110
- continue;
111
- }
112
- const assetSource = compilation.assets[assetName];
113
- if (!assetSource) {
114
- continue;
115
- }
116
- const previousSource = assetSource.source();
117
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
118
- if (previous === code) {
119
- continue;
120
- }
121
- const source = new (0, _webpacksources.ConcatSource)(code);
122
- compilation.updateAsset(assetName, source);
123
- compilerOptions.onUpdate(assetName, previous, code);
124
- debug2("js linked handle: %s", assetName);
125
- }
126
- };
127
- const groupedEntries = _chunkDYLQ6UOIjs.getGroupedEntries.call(void 0, entries, compilerOptions);
128
- const getCssHandlerOptions = (file) => {
129
- const majorVersion = runtimeState.twPatcher.majorVersion;
130
- const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
131
- const cacheKey = `${_nullishCoalesce(majorVersion, () => ( "unknown"))}:${isMainChunk ? "1" : "0"}:${file}`;
132
- const cached = cssHandlerOptionsCache.get(cacheKey);
133
- if (cached) {
134
- return cached;
135
- }
136
- const created = {
137
- isMainChunk,
138
- postcssOptions: {
139
- options: {
140
- from: file
141
- }
142
- },
143
- majorVersion
144
- };
145
- cssHandlerOptionsCache.set(cacheKey, created);
146
- return created;
147
- };
148
- const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
149
- const runtimeSet = await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
150
- // webpack 的 script-only 热更新可能不会触发 runtime classset loader,
151
- // 这里强制收集可避免沿用上轮 class set,保证 JS 仅按最新集合精确命中。
152
- forceCollect: true,
153
- allowEmpty: false
154
- });
155
- const defaultTemplateHandlerOptions = {
156
- runtimeSet
157
- };
158
- debug2("get runtimeSet, class count: %d", runtimeSet.size);
159
- const tasks = [];
160
- if (Array.isArray(groupedEntries.html)) {
161
- for (const element of groupedEntries.html) {
162
- const [file, originalSource] = element;
163
- const rawSource = originalSource.source().toString();
164
- const cacheKey = file;
165
- const chunkHash = assetHashByChunk.get(file);
166
- tasks.push(
167
- _chunkOF6MFURRjs.processCachedTask.call(void 0, {
168
- cache: compilerOptions.cache,
169
- cacheKey,
170
- hashKey: `${file}:asset`,
171
- rawSource,
172
- hash: chunkHash,
173
- applyResult(source) {
174
- compilation.updateAsset(file, source);
175
- },
176
- onCacheHit() {
177
- debug2("html cache hit: %s", file);
178
- },
179
- transform: async () => {
180
- const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
181
- const source = new (0, _webpacksources.ConcatSource)(wxml);
182
- compilerOptions.onUpdate(file, rawSource, wxml);
183
- debug2("html handle: %s", file);
184
- return {
185
- result: source
186
- };
187
- }
188
- })
189
- );
190
- }
191
- }
192
- const jsTaskFactories = [];
193
- if (Array.isArray(groupedEntries.js)) {
194
- for (const [file] of groupedEntries.js) {
195
- const cacheKey = _chunkWSS26HZSjs.getCacheKey.call(void 0, file);
196
- const assetSource = compilation.assets[file];
197
- if (!assetSource) {
198
- continue;
199
- }
200
- const initialValue = assetSource.source();
201
- const initialRawSource = typeof initialValue === "string" ? initialValue : initialValue.toString();
202
- const absoluteFile = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
203
- const chunkHash = assetHashByChunk.get(file);
204
- const sourceAwareHash = chunkHash ? `${chunkHash}:${compilerOptions.cache.computeHash(initialRawSource)}` : void 0;
205
- jsTaskFactories.push(async () => {
206
- await _chunkOF6MFURRjs.processCachedTask.call(void 0, {
207
- cache: compilerOptions.cache,
208
- cacheKey,
209
- hashKey: `${file}:asset`,
210
- rawSource: initialRawSource,
211
- hash: sourceAwareHash,
212
- applyResult(source) {
213
- compilation.updateAsset(file, source);
214
- },
215
- onCacheHit() {
216
- debug2("js cache hit: %s", file);
217
- },
218
- transform: async () => {
219
- const currentAsset = compilation.assets[file];
220
- const currentValue = _optionalChain([currentAsset, 'optionalAccess', _4 => _4.source, 'call', _5 => _5()]);
221
- const currentSource = typeof currentValue === "string" ? currentValue : _nullishCoalesce(_optionalChain([currentValue, 'optionalAccess', _6 => _6.toString, 'call', _7 => _7()]), () => ( ""));
222
- const handlerOptions = {
223
- staleClassNameFallback,
224
- tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
225
- filename: absoluteFile,
226
- moduleGraph: moduleGraphOptions,
227
- babelParserOptions: {
228
- sourceFilename: absoluteFile
229
- }
230
- };
231
- if (_chunkGC7WXUOWjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
232
- return { result: new (0, _webpacksources.ConcatSource)(currentSource) };
233
- }
234
- const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
235
- const source = new (0, _webpacksources.ConcatSource)(code);
236
- compilerOptions.onUpdate(file, currentSource, code);
237
- debug2("js handle: %s", file);
238
- applyLinkedResults(linked);
239
- return {
240
- result: source
241
- };
242
- }
243
- });
244
- });
245
- }
246
- }
247
- if (Array.isArray(groupedEntries.css)) {
248
- for (const element of groupedEntries.css) {
249
- const [file, originalSource] = element;
250
- const rawSource = originalSource.source().toString();
251
- const cacheKey = file;
252
- const chunkHash = assetHashByChunk.get(file);
253
- tasks.push(
254
- _chunkOF6MFURRjs.processCachedTask.call(void 0, {
255
- cache: compilerOptions.cache,
256
- cacheKey,
257
- hashKey: `${file}:asset`,
258
- rawSource,
259
- hash: chunkHash,
260
- applyResult(source) {
261
- compilation.updateAsset(file, source);
262
- },
263
- onCacheHit() {
264
- debug2("css cache hit: %s", file);
265
- },
266
- transform: async () => {
267
- await runtimeState.patchPromise;
268
- const { css } = await compilerOptions.styleHandler(rawSource, getCssHandlerOptions(file));
269
- const source = new (0, _webpacksources.ConcatSource)(css);
270
- compilerOptions.onUpdate(file, rawSource, css);
271
- debug2("css handle: %s", file);
272
- return {
273
- result: source
274
- };
275
- }
276
- })
277
- );
278
- }
279
- }
280
- _chunkGMKSBLNYjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
281
- await Promise.all(tasks);
282
- debug2("end");
283
- compilerOptions.onEnd();
284
- });
29
+ const { compiler, options: compilerOptions, appType, runtimeState, debug } = options;
30
+ const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
31
+ const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
32
+ compiler.hooks.emit.tapPromise(require_recorder.pluginName, async (compilation) => {
33
+ await runtimeState.patchPromise;
34
+ compilerOptions.onStart();
35
+ debug("start");
36
+ for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
37
+ const assetCompilation = toWebpackV4AssetCompilation(compilation);
38
+ const assetHashByChunk = require_loader_anchors.createAssetHashByChunkMap(compilation.chunks);
39
+ const assets = assetCompilation.assets;
40
+ const entries = Object.entries(assets);
41
+ const outputDir = compiler.options?.output?.path ? node_path.default.resolve(compiler.options.output.path) : node_process.default.cwd();
42
+ const jsAssets = /* @__PURE__ */ new Map();
43
+ for (const [file] of entries) if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
44
+ const absolute = require_css_imports.toAbsoluteOutputPath(file, outputDir);
45
+ jsAssets.set(absolute, file);
46
+ }
47
+ const moduleGraphOptions = {
48
+ resolve(specifier, importer) {
49
+ return require_css_imports.resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
50
+ },
51
+ load: (id) => {
52
+ const assetName = jsAssets.get(id);
53
+ if (!assetName) return;
54
+ const assetSource = assetCompilation.assets[assetName];
55
+ if (!assetSource) return;
56
+ return readWebpackV4AssetSource(assetSource);
57
+ },
58
+ filter(id) {
59
+ return jsAssets.has(id);
60
+ }
61
+ };
62
+ const applyLinkedResults = (linked) => {
63
+ if (!linked) return;
64
+ for (const [id, { code }] of Object.entries(linked)) {
65
+ const assetName = jsAssets.get(id);
66
+ if (!assetName) continue;
67
+ const assetSource = assetCompilation.assets[assetName];
68
+ if (!assetSource) continue;
69
+ const previous = readWebpackV4AssetSource(assetSource);
70
+ if (previous === code) continue;
71
+ const source = new webpack_sources.ConcatSource(code);
72
+ assetCompilation.updateAsset(assetName, source);
73
+ compilerOptions.onUpdate(assetName, previous, code);
74
+ debug("js linked handle: %s", assetName);
75
+ }
76
+ };
77
+ const groupedEntries = require_utils.getGroupedEntries(entries, compilerOptions);
78
+ const getCssHandlerOptions = (file) => {
79
+ const majorVersion = runtimeState.twPatcher.majorVersion;
80
+ const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
81
+ const cacheKey = `${majorVersion ?? "unknown"}:${isMainChunk ? "1" : "0"}:${file}`;
82
+ const cached = cssHandlerOptionsCache.get(cacheKey);
83
+ if (cached) return cached;
84
+ const created = {
85
+ isMainChunk,
86
+ postcssOptions: { options: { from: file } },
87
+ majorVersion
88
+ };
89
+ cssHandlerOptionsCache.set(cacheKey, created);
90
+ return created;
91
+ };
92
+ const getCssUserHandlerOptions = (file) => {
93
+ const cacheKey = `${runtimeState.twPatcher.majorVersion ?? "unknown"}:${file}`;
94
+ const cached = cssUserHandlerOptionsCache.get(cacheKey);
95
+ if (cached) return cached;
96
+ const created = {
97
+ ...getCssHandlerOptions(file),
98
+ isMainChunk: false
99
+ };
100
+ cssUserHandlerOptionsCache.set(cacheKey, created);
101
+ return created;
102
+ };
103
+ const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
104
+ const runtimeSet = await require_recorder.ensureRuntimeClassSet(runtimeState, {
105
+ forceCollect: true,
106
+ allowEmpty: false
107
+ });
108
+ const defaultTemplateHandlerOptions = { runtimeSet };
109
+ debug("get runtimeSet, class count: %d", runtimeSet.size);
110
+ const tasks = [];
111
+ if (Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
112
+ const [file, originalSource] = element;
113
+ const rawSource = readWebpackV4AssetSource(originalSource);
114
+ const cacheKey = file;
115
+ const chunkHash = assetHashByChunk.get(file);
116
+ tasks.push(require_generator_css.processCachedTask({
117
+ cache: compilerOptions.cache,
118
+ cacheKey,
119
+ hashKey: `${file}:asset`,
120
+ rawSource,
121
+ hash: chunkHash,
122
+ applyResult(source) {
123
+ assetCompilation.updateAsset(file, source);
124
+ },
125
+ onCacheHit() {
126
+ debug("html cache hit: %s", file);
127
+ },
128
+ transform: async () => {
129
+ const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
130
+ const source = new webpack_sources.ConcatSource(wxml);
131
+ compilerOptions.onUpdate(file, rawSource, wxml);
132
+ debug("html handle: %s", file);
133
+ return { result: source };
134
+ }
135
+ }));
136
+ }
137
+ const jsTaskFactories = [];
138
+ if (Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
139
+ const cacheKey = require_loader_anchors.getCacheKey(file);
140
+ const assetSource = assetCompilation.assets[file];
141
+ if (!assetSource) continue;
142
+ const initialRawSource = readWebpackV4AssetSource(assetSource);
143
+ const absoluteFile = require_css_imports.toAbsoluteOutputPath(file, outputDir);
144
+ const chunkHash = assetHashByChunk.get(file);
145
+ const sourceAwareHash = chunkHash ? `${chunkHash}:${compilerOptions.cache.computeHash(initialRawSource)}` : void 0;
146
+ jsTaskFactories.push(async () => {
147
+ await require_generator_css.processCachedTask({
148
+ cache: compilerOptions.cache,
149
+ cacheKey,
150
+ hashKey: `${file}:asset`,
151
+ rawSource: initialRawSource,
152
+ hash: sourceAwareHash,
153
+ applyResult(source) {
154
+ assetCompilation.updateAsset(file, source);
155
+ },
156
+ onCacheHit() {
157
+ debug("js cache hit: %s", file);
158
+ },
159
+ transform: async () => {
160
+ const currentAsset = assetCompilation.assets[file];
161
+ const currentSource = currentAsset ? readWebpackV4AssetSource(currentAsset) : "";
162
+ const handlerOptions = {
163
+ staleClassNameFallback,
164
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
165
+ filename: absoluteFile,
166
+ moduleGraph: moduleGraphOptions,
167
+ babelParserOptions: { sourceFilename: absoluteFile }
168
+ };
169
+ if (require_recorder.shouldSkipJsTransform(currentSource, handlerOptions)) return { result: new webpack_sources.ConcatSource(currentSource) };
170
+ const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
171
+ const source = new webpack_sources.ConcatSource(code);
172
+ compilerOptions.onUpdate(file, currentSource, code);
173
+ debug("js handle: %s", file);
174
+ applyLinkedResults(linked);
175
+ return { result: source };
176
+ }
177
+ });
178
+ });
179
+ }
180
+ if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
181
+ const [file, originalSource] = element;
182
+ const rawSource = readWebpackV4AssetSource(originalSource);
183
+ const cacheKey = file;
184
+ const chunkHash = assetHashByChunk.get(file);
185
+ tasks.push(require_generator_css.processCachedTask({
186
+ cache: compilerOptions.cache,
187
+ cacheKey,
188
+ hashKey: `${file}:asset`,
189
+ rawSource,
190
+ hash: chunkHash,
191
+ applyResult(source) {
192
+ assetCompilation.updateAsset(file, source);
193
+ },
194
+ onCacheHit() {
195
+ debug("css cache hit: %s", file);
196
+ },
197
+ transform: async () => {
198
+ await runtimeState.patchPromise;
199
+ const cssHandlerOptions = getCssHandlerOptions(file);
200
+ const generated = await require_generator_css.generateCssByGenerator({
201
+ opts: compilerOptions,
202
+ runtimeState,
203
+ runtime: runtimeSet,
204
+ rawSource,
205
+ file,
206
+ cssHandlerOptions,
207
+ cssUserHandlerOptions: getCssUserHandlerOptions(file),
208
+ styleHandler: compilerOptions.styleHandler,
209
+ debug
210
+ });
211
+ const css = generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css;
212
+ const source = new webpack_sources.ConcatSource(css);
213
+ compilerOptions.onUpdate(file, rawSource, css);
214
+ if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
215
+ else debug("css handle: %s", file);
216
+ return { result: source };
217
+ }
218
+ }));
219
+ }
220
+ require_css_imports.pushConcurrentTaskFactories(tasks, jsTaskFactories);
221
+ await Promise.all(tasks);
222
+ debug("end");
223
+ compilerOptions.onEnd();
224
+ });
285
225
  }
286
-
287
- // src/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.ts
288
- var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
289
-
290
-
226
+ //#endregion
227
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.ts
291
228
  function setupWebpackV4Loaders(options) {
292
- const {
293
- compiler,
294
- options: compilerOptions,
295
- appType,
296
- weappTailwindcssPackageDir: weappTailwindcssPackageDir2,
297
- shouldRewriteCssImports,
298
- runtimeLoaderPath,
299
- runtimeCssImportRewriteLoaderPath,
300
- getClassSetInLoader,
301
- debug: debug2
302
- } = options;
303
- const isMpxApp = _chunkWSS26HZSjs.isMpx.call(void 0, appType);
304
- if (shouldRewriteCssImports && isMpxApp) {
305
- _chunkWSS26HZSjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
306
- }
307
- const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
308
- const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
309
- const runtimeClassSetLoaderExists = _fs2.default.existsSync(runtimeClassSetLoader);
310
- const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? _fs2.default.existsSync(runtimeCssImportRewriteLoader) : false;
311
- const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
312
- pkgDir: weappTailwindcssPackageDir2,
313
- appType
314
- } : void 0;
315
- const classSetLoaderOptions = {
316
- getClassSet: getClassSetInLoader
317
- };
318
- const { findRewriteAnchor, findClassSetAnchor } = _chunkWSS26HZSjs.createLoaderAnchorFinders.call(void 0, appType);
319
- const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
320
- rewriteCssImports: runtimeLoaderRewriteOptions
321
- } : void 0;
322
- if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
323
- _chunkWSS26HZSjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
324
- }
325
- const createRuntimeClassSetLoaderEntry = () => ({
326
- loader: runtimeClassSetLoader,
327
- options: classSetLoaderOptions,
328
- ident: null,
329
- type: null
330
- });
331
- const createCssImportRewriteLoaderEntry = () => {
332
- if (!runtimeCssImportRewriteLoader) {
333
- return null;
334
- }
335
- return {
336
- loader: runtimeCssImportRewriteLoader,
337
- options: cssImportRewriteLoaderOptions,
338
- ident: null,
339
- type: null
340
- };
341
- };
342
- compiler.hooks.compilation.tap(_chunkGC7WXUOWjs.pluginName, (compilation) => {
343
- compilation.hooks.normalModuleLoader.tap(_chunkGC7WXUOWjs.pluginName, (_loaderContext, module) => {
344
- const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
345
- if (!hasRuntimeLoader) {
346
- return;
347
- }
348
- if (shouldRewriteCssImports && _chunkWSS26HZSjs.isMpx.call(void 0, appType) && typeof _loaderContext.resolve === "function") {
349
- _chunkWSS26HZSjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, true);
350
- }
351
- const loaderEntries = module.loaders || [];
352
- let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
353
- const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
354
- const isCssModule = _chunkWSS26HZSjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
355
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
356
- debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
357
- }
358
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) {
359
- debug2("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
360
- } else if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) {
361
- debug2("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
362
- }
363
- if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) {
364
- return;
365
- }
366
- const anchorlessInsert = (entry, position) => {
367
- if (position === "after") {
368
- loaderEntries.push(entry);
369
- } else {
370
- loaderEntries.unshift(entry);
371
- }
372
- };
373
- if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
374
- const existingIndex = loaderEntries.findIndex(
375
- (entry) => _optionalChain([entry, 'access', _8 => _8.loader, 'optionalAccess', _9 => _9.includes, 'optionalCall', _10 => _10(runtimeCssImportRewriteLoader)])
376
- );
377
- const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
378
- if (rewriteEntry) {
379
- const anchorIndex = findRewriteAnchor(loaderEntries);
380
- if (anchorIndex === -1) {
381
- anchorlessInsert(rewriteEntry, "after");
382
- } else {
383
- loaderEntries.splice(anchorIndex + 1, 0, rewriteEntry);
384
- }
385
- rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
386
- }
387
- }
388
- if (runtimeClassSetLoaderExists && !_chunkWSS26HZSjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
389
- const anchorIndex = findClassSetAnchor(loaderEntries);
390
- if (anchorIndex === -1) {
391
- anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
392
- } else {
393
- const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
394
- loaderEntries.splice(insertIndex, 0, createRuntimeClassSetLoaderEntry());
395
- }
396
- }
397
- });
398
- });
229
+ const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, getClassSetInLoader, debug } = options;
230
+ const isMpxApp = require_loader_anchors.isMpx(appType);
231
+ if (shouldRewriteCssImports && isMpxApp) require_loader_anchors.ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
232
+ const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
233
+ const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? runtimeCssImportRewriteLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
234
+ const runtimeClassSetLoaderExists = node_fs.default.existsSync(runtimeClassSetLoader);
235
+ const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
236
+ const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
237
+ pkgDir: weappTailwindcssPackageDir,
238
+ appType
239
+ } : void 0;
240
+ const classSetLoaderOptions = { getClassSet: getClassSetInLoader };
241
+ const { findRewriteAnchor, findClassSetAnchor } = require_loader_anchors.createLoaderAnchorFinders(appType);
242
+ const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { rewriteCssImports: runtimeLoaderRewriteOptions } : void 0;
243
+ if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) require_loader_anchors.injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
244
+ const createRuntimeClassSetLoaderEntry = () => ({
245
+ loader: runtimeClassSetLoader,
246
+ options: classSetLoaderOptions,
247
+ ident: null,
248
+ type: null
249
+ });
250
+ const createCssImportRewriteLoaderEntry = () => {
251
+ if (!runtimeCssImportRewriteLoader) return null;
252
+ return {
253
+ loader: runtimeCssImportRewriteLoader,
254
+ options: cssImportRewriteLoaderOptions,
255
+ ident: null,
256
+ type: null
257
+ };
258
+ };
259
+ compiler.hooks.compilation.tap(require_recorder.pluginName, (compilation) => {
260
+ compilation.hooks.normalModuleLoader.tap(require_recorder.pluginName, (_loaderContext, module) => {
261
+ if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
262
+ if (shouldRewriteCssImports && require_loader_anchors.isMpx(appType) && typeof _loaderContext.resolve === "function") require_loader_anchors.patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, true);
263
+ const loaderEntries = module.loaders || [];
264
+ let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
265
+ const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
266
+ const isCssModule = require_loader_anchors.isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
267
+ if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
268
+ rewriteAnchorIdx,
269
+ classSetAnchorIdx
270
+ });
271
+ if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), {
272
+ rewriteAnchorIdx,
273
+ classSetAnchorIdx
274
+ });
275
+ else if (node_process.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
276
+ rewriteAnchorIdx,
277
+ classSetAnchorIdx
278
+ });
279
+ if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) return;
280
+ const anchorlessInsert = (entry, position) => {
281
+ if (position === "after") loaderEntries.push(entry);
282
+ else loaderEntries.unshift(entry);
283
+ };
284
+ if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
285
+ const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
286
+ const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
287
+ if (rewriteEntry) {
288
+ const anchorIndex = findRewriteAnchor(loaderEntries);
289
+ if (anchorIndex === -1) anchorlessInsert(rewriteEntry, "after");
290
+ else loaderEntries.splice(anchorIndex + 1, 0, rewriteEntry);
291
+ rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
292
+ }
293
+ }
294
+ if (runtimeClassSetLoaderExists && !require_loader_anchors.hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
295
+ const anchorIndex = findClassSetAnchor(loaderEntries);
296
+ if (anchorIndex === -1) anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
297
+ else {
298
+ const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
299
+ loaderEntries.splice(insertIndex, 0, createRuntimeClassSetLoaderEntry());
300
+ }
301
+ }
302
+ });
303
+ });
399
304
  }
400
-
401
- // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
402
- var debug = _chunkGC7WXUOWjs.createDebug.call(void 0, );
403
- var weappTailwindcssPackageDir = _chunkGMKSBLNYjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
305
+ //#endregion
306
+ //#region src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
307
+ const debug = require_recorder.createDebug();
308
+ const weappTailwindcssPackageDir = require_css_imports.resolvePackageDir("weapp-tailwindcss");
309
+ /**
310
+ * @name UnifiedWebpackPluginV4
311
+ * @description webpack4 核心转义插件
312
+ * @link https://tw.icebreaker.top/docs/intro
313
+ */
404
314
  var UnifiedWebpackPluginV4 = class {
405
- constructor(options = {}) {
406
- this.options = _chunkGC7WXUOWjs.getCompilerContext.call(void 0, options);
407
- this.appType = this.options.appType;
408
- }
409
- apply(compiler) {
410
- compiler.options = compiler.options || {};
411
- const {
412
- disabled,
413
- onLoad,
414
- runtimeLoaderPath,
415
- runtimeCssImportRewriteLoaderPath,
416
- twPatcher: initialTwPatcher,
417
- refreshTailwindcssPatcher
418
- } = this.options;
419
- const disabledOptions = _chunkGMKSBLNYjs.resolveDisabledOptions.call(void 0, disabled);
420
- const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
421
- const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
422
- const isMpxApp = _chunkWSS26HZSjs.isMpx.call(void 0, this.appType);
423
- if (shouldRewriteCssImports) {
424
- _chunkWSS26HZSjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
425
- pkgDir: weappTailwindcssPackageDir,
426
- enabled: true,
427
- appType: this.appType
428
- });
429
- _chunkWSS26HZSjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
430
- }
431
- if (disabledOptions.plugin) {
432
- return;
433
- }
434
- const patchRecorderState = _chunkGC7WXUOWjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
435
- source: "runtime",
436
- cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
437
- });
438
- const runtimeState = {
439
- twPatcher: initialTwPatcher,
440
- patchPromise: patchRecorderState.patchPromise,
441
- refreshTailwindcssPatcher,
442
- onPatchCompleted: patchRecorderState.onPatchCompleted
443
- };
444
- let runtimeSetPrepared = false;
445
- let runtimeSetSignature;
446
- compiler.hooks.compilation.tap(_chunkGC7WXUOWjs.pluginName, () => {
447
- runtimeSetPrepared = false;
448
- });
449
- async function getClassSetInLoader() {
450
- if (runtimeSetPrepared) {
451
- return;
452
- }
453
- const signature = _chunkNIS74SI6js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
454
- const forceRefresh = signature !== runtimeSetSignature;
455
- runtimeSetPrepared = true;
456
- await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
457
- forceRefresh,
458
- forceCollect: true,
459
- clearCache: forceRefresh,
460
- allowEmpty: true
461
- });
462
- runtimeSetSignature = signature;
463
- }
464
- onLoad();
465
- setupWebpackV4Loaders({
466
- compiler,
467
- options: this.options,
468
- appType: this.appType,
469
- weappTailwindcssPackageDir,
470
- shouldRewriteCssImports,
471
- runtimeLoaderPath,
472
- runtimeCssImportRewriteLoaderPath,
473
- getClassSetInLoader,
474
- debug
475
- });
476
- setupWebpackV4EmitHook({
477
- compiler,
478
- options: this.options,
479
- appType: this.appType,
480
- runtimeState,
481
- debug
482
- });
483
- }
315
+ constructor(options = {}) {
316
+ this.options = require_recorder.getCompilerContext(options);
317
+ this.appType = this.options.appType;
318
+ }
319
+ apply(compiler) {
320
+ compiler.options = compiler.options || {};
321
+ const { disabled, onLoad, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
322
+ const disabledOptions = require_css_imports.resolveDisabledOptions(disabled);
323
+ const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
324
+ const isMpxApp = require_loader_anchors.isMpx(this.appType);
325
+ if (shouldRewriteCssImports) {
326
+ require_loader_anchors.applyTailwindcssCssImportRewrite(compiler, {
327
+ pkgDir: weappTailwindcssPackageDir,
328
+ enabled: true,
329
+ appType: this.appType
330
+ });
331
+ require_loader_anchors.setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
332
+ }
333
+ if (disabledOptions.plugin) return;
334
+ const patchRecorderState = require_recorder.setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
335
+ source: "runtime",
336
+ cwd: this.options.tailwindcssBasedir ?? node_process.default.cwd()
337
+ });
338
+ const runtimeState = {
339
+ twPatcher: initialTwPatcher,
340
+ patchPromise: patchRecorderState.patchPromise,
341
+ refreshTailwindcssPatcher,
342
+ onPatchCompleted: patchRecorderState.onPatchCompleted
343
+ };
344
+ let runtimeSetPrepared = false;
345
+ let runtimeSetSignature;
346
+ compiler.hooks.compilation.tap(require_recorder.pluginName, () => {
347
+ runtimeSetPrepared = false;
348
+ });
349
+ async function getClassSetInLoader() {
350
+ if (runtimeSetPrepared) return;
351
+ const signature = require_logger.getRuntimeClassSetSignature(runtimeState.twPatcher);
352
+ const forceRefresh = signature !== runtimeSetSignature;
353
+ runtimeSetPrepared = true;
354
+ await require_recorder.ensureRuntimeClassSet(runtimeState, {
355
+ forceRefresh,
356
+ forceCollect: true,
357
+ clearCache: forceRefresh,
358
+ allowEmpty: true
359
+ });
360
+ runtimeSetSignature = signature;
361
+ }
362
+ onLoad();
363
+ setupWebpackV4Loaders({
364
+ compiler,
365
+ options: this.options,
366
+ appType: this.appType,
367
+ weappTailwindcssPackageDir,
368
+ shouldRewriteCssImports,
369
+ runtimeLoaderPath,
370
+ runtimeCssImportRewriteLoaderPath,
371
+ getClassSetInLoader,
372
+ debug
373
+ });
374
+ setupWebpackV4EmitHook({
375
+ compiler,
376
+ options: this.options,
377
+ appType: this.appType,
378
+ runtimeState,
379
+ debug
380
+ });
381
+ }
484
382
  };
485
-
486
-
487
-
488
-
489
- exports.UnifiedWebpackPluginV4 = UnifiedWebpackPluginV4; exports.weappTailwindcss = UnifiedWebpackPluginV4; exports.weappTailwindcssPackageDir = weappTailwindcssPackageDir;
383
+ //#endregion
384
+ exports.UnifiedWebpackPluginV4 = UnifiedWebpackPluginV4;
385
+ exports.WeappTailwindcss = UnifiedWebpackPluginV4;
386
+ exports.weappTailwindcss = UnifiedWebpackPluginV4;
387
+ exports.weappTailwindcssPackageDir = weappTailwindcssPackageDir;