weapp-tailwindcss 4.12.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 (308) hide show
  1. package/dist/babel/index.d.ts +3 -0
  2. package/dist/bundlers/gulp/index.d.ts +7 -0
  3. package/dist/bundlers/shared/cache.d.ts +16 -0
  4. package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
  5. package/dist/bundlers/shared/css-imports.d.ts +8 -0
  6. package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
  7. package/dist/bundlers/shared/generator-css.d.ts +41 -0
  8. package/dist/bundlers/shared/module-graph.d.ts +5 -0
  9. package/dist/bundlers/shared/run-tasks.d.ts +2 -0
  10. package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
  11. package/dist/bundlers/vite/bundle-state.d.ts +43 -0
  12. package/dist/bundlers/vite/css-finalizer.d.ts +19 -0
  13. package/dist/bundlers/vite/generate-bundle.d.ts +20 -0
  14. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
  15. package/dist/bundlers/vite/index.d.ts +3 -0
  16. package/dist/bundlers/vite/js-precheck.d.ts +1 -0
  17. package/dist/bundlers/vite/query.d.ts +15 -0
  18. package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
  19. package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
  20. package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
  21. package/dist/bundlers/vite/utils.d.ts +9 -0
  22. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
  26. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
  27. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
  28. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
  29. package/dist/bundlers/webpack/index.d.ts +1 -0
  30. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
  31. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
  32. package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
  33. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
  34. package/dist/cache/index.d.ts +38 -0
  35. package/dist/cache/md5.d.ts +1 -0
  36. package/dist/chunk-8l464Juk.js +28 -0
  37. package/dist/cli/config.d.ts +5 -0
  38. package/dist/cli/context.d.ts +16 -0
  39. package/dist/cli/doctor/constants.d.ts +7 -0
  40. package/dist/cli/doctor/types.d.ts +31 -0
  41. package/dist/cli/doctor.d.ts +4 -0
  42. package/dist/cli/helpers/options/format.d.ts +2 -0
  43. package/dist/cli/helpers/options/parse.d.ts +3 -0
  44. package/dist/cli/helpers/options/resolve.d.ts +1 -0
  45. package/dist/cli/helpers/options.d.ts +3 -0
  46. package/dist/cli/helpers/patch-cwd.d.ts +1 -0
  47. package/dist/cli/helpers.d.ts +5 -0
  48. package/dist/cli/mount-options/patch-status.d.ts +2 -0
  49. package/dist/cli/mount-options.d.ts +2 -0
  50. package/dist/cli/patch-options.d.ts +6 -0
  51. package/dist/cli/tokens.d.ts +4 -0
  52. package/dist/cli/types.d.ts +17 -0
  53. package/dist/cli/vscode-entry.d.ts +14 -0
  54. package/dist/cli/workspace/package-dirs.d.ts +3 -0
  55. package/dist/cli/workspace/patch-package.d.ts +3 -0
  56. package/dist/cli/workspace/patch-utils.d.ts +3 -0
  57. package/dist/cli/workspace/types.d.ts +11 -0
  58. package/dist/cli/workspace/workspace-globs.d.ts +2 -0
  59. package/dist/cli/workspace/workspace-io.d.ts +1 -0
  60. package/dist/cli/workspace/workspace-lock.d.ts +1 -0
  61. package/dist/cli/workspace.d.ts +2 -0
  62. package/dist/cli.d.ts +1 -2
  63. package/dist/cli.js +2425 -3524
  64. package/dist/cli.mjs +2402 -3505
  65. package/dist/constants-B-_T5UnW.mjs +44 -0
  66. package/dist/constants-p1dyh1x1.js +73 -0
  67. package/dist/constants.d.ts +13 -0
  68. package/dist/context/compiler-context-cache.d.ts +3 -0
  69. package/dist/context/custom-attributes.d.ts +2 -0
  70. package/dist/context/handlers.d.ts +6 -0
  71. package/dist/context/index.d.ts +7 -0
  72. package/dist/context/logger.d.ts +4 -0
  73. package/dist/context/tailwindcss/basedir.d.ts +1 -0
  74. package/dist/context/tailwindcss/rax.d.ts +2 -0
  75. package/dist/context/tailwindcss.d.ts +4 -0
  76. package/dist/context/workspace.d.ts +3 -0
  77. package/dist/core.d.ts +5 -21
  78. package/dist/core.js +138 -180
  79. package/dist/core.mjs +135 -180
  80. package/dist/css-imports-BbrbluP9.js +177 -0
  81. package/dist/css-imports-CSdPq_Sc.mjs +128 -0
  82. package/dist/css-macro/constants.d.ts +14 -0
  83. package/dist/css-macro/index.d.ts +15 -0
  84. package/dist/css-macro/postcss.d.ts +3 -7
  85. package/dist/css-macro/postcss.js +44 -58
  86. package/dist/css-macro/postcss.mjs +44 -56
  87. package/dist/css-macro.d.ts +1 -20
  88. package/dist/css-macro.js +37 -50
  89. package/dist/css-macro.mjs +33 -47
  90. package/dist/debug/index.d.ts +5 -0
  91. package/dist/defaults.d.ts +2 -11
  92. package/dist/defaults.js +132 -8
  93. package/dist/defaults.mjs +128 -7
  94. package/dist/escape.js +31 -54
  95. package/dist/escape.mjs +18 -25
  96. package/dist/experimental/index.d.ts +2 -0
  97. package/dist/experimental/oxc/ast-utils.d.ts +30 -0
  98. package/dist/experimental/oxc/index.d.ts +2 -0
  99. package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
  100. package/dist/experimental/shared/cache.d.ts +3 -0
  101. package/dist/experimental/shared/transform.d.ts +3 -0
  102. package/dist/experimental/shared.d.ts +8 -0
  103. package/dist/experimental/swc/ast-utils.d.ts +30 -0
  104. package/dist/experimental/swc/index.d.ts +2 -0
  105. package/dist/experimental/swc/module-specifiers.d.ts +2 -0
  106. package/dist/generator/index.d.ts +11 -0
  107. package/dist/generator/options.d.ts +15 -0
  108. package/dist/generator/types.d.ts +19 -0
  109. package/dist/generator-CZ-JXw6T.js +492 -0
  110. package/dist/generator-Dwxgra97.mjs +399 -0
  111. package/dist/generator-css-CnYjiMrD.js +1084 -0
  112. package/dist/generator-css-DhPFjSzK.mjs +1057 -0
  113. package/dist/generator.d.ts +1 -0
  114. package/dist/generator.js +19 -0
  115. package/dist/generator.mjs +2 -0
  116. package/dist/gulp.d.ts +4 -24
  117. package/dist/gulp.js +271 -13
  118. package/dist/gulp.mjs +263 -13
  119. package/dist/index.d.ts +8 -15
  120. package/dist/index.js +12 -24
  121. package/dist/index.mjs +6 -24
  122. package/dist/js/JsTokenUpdater.d.ts +14 -0
  123. package/dist/js/ModuleGraph.d.ts +18 -0
  124. package/dist/js/NodePathWalker.d.ts +33 -0
  125. package/dist/js/babel/parse.d.ts +9 -0
  126. package/dist/js/babel/process.d.ts +4 -0
  127. package/dist/js/babel.d.ts +13 -0
  128. package/dist/js/class-context.d.ts +3 -0
  129. package/dist/js/evalTransforms.d.ts +7 -0
  130. package/dist/js/handlers.d.ts +5 -0
  131. package/dist/js/index.d.ts +4 -0
  132. package/dist/js/module-graph/ignored-exports.d.ts +18 -0
  133. package/dist/js/module-graph/types.d.ts +17 -0
  134. package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
  135. package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
  136. package/dist/js/precheck.d.ts +2 -0
  137. package/dist/js/sourceAnalysis.d.ts +17 -0
  138. package/dist/js/syntax.d.ts +10 -0
  139. package/dist/js/taggedTemplateIgnore.d.ts +13 -0
  140. package/dist/js/types.d.ts +11 -0
  141. package/dist/lightningcss/index.d.ts +8 -0
  142. package/dist/lightningcss/style-handler/options.d.ts +3 -0
  143. package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
  144. package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
  145. package/dist/lightningcss/style-handler.d.ts +17 -0
  146. package/dist/loader-anchors-DvwgIYdA.mjs +205 -0
  147. package/dist/loader-anchors-cprm4Klq.js +273 -0
  148. package/dist/logger/index.d.ts +2 -0
  149. package/dist/logger-BZ45DZJT.js +1003 -0
  150. package/dist/logger-BoVx1Dbt.mjs +935 -0
  151. package/dist/patcher-options-6gJN2EXy.js +115 -0
  152. package/dist/patcher-options-DQfR5xxT.mjs +92 -0
  153. package/dist/postcss-html-transform.d.ts +3 -3
  154. package/dist/postcss-html-transform.js +7 -10
  155. package/dist/postcss-html-transform.mjs +3 -6
  156. package/dist/postcss.d.ts +15 -0
  157. package/dist/postcss.js +278 -0
  158. package/dist/postcss.mjs +268 -0
  159. package/dist/presets/hbuilderx.d.ts +4 -0
  160. package/dist/presets/index.d.ts +3 -0
  161. package/dist/presets/shared.d.ts +10 -0
  162. package/dist/presets/taro.d.ts +4 -0
  163. package/dist/presets/uni-app-x.d.ts +16 -0
  164. package/dist/presets/uni-app.d.ts +4 -0
  165. package/dist/presets.d.ts +1 -76
  166. package/dist/presets.js +115 -163
  167. package/dist/presets.mjs +107 -163
  168. package/dist/recorder-B_XyZ576.mjs +2763 -0
  169. package/dist/recorder-rn_2v_nd.js +2878 -0
  170. package/dist/reset/index.d.ts +2 -0
  171. package/dist/reset.d.ts +1 -4
  172. package/dist/reset.js +19 -8
  173. package/dist/reset.mjs +2 -8
  174. package/dist/shared/classname-transform.d.ts +14 -0
  175. package/dist/shared/mpx.d.ts +7 -0
  176. package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
  177. package/dist/tailwindcss/index.d.ts +11 -0
  178. package/dist/tailwindcss/miniprogram.d.ts +1 -0
  179. package/dist/tailwindcss/patcher-options.d.ts +56 -0
  180. package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
  181. package/dist/tailwindcss/patcher.d.ts +13 -0
  182. package/dist/tailwindcss/recorder.d.ts +13 -0
  183. package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
  184. package/dist/tailwindcss/runtime/cache.d.ts +11 -0
  185. package/dist/tailwindcss/runtime-logs.d.ts +3 -0
  186. package/dist/tailwindcss/runtime.d.ts +29 -0
  187. package/dist/tailwindcss/targets/paths.d.ts +13 -0
  188. package/dist/tailwindcss/targets/record-io.d.ts +5 -0
  189. package/dist/tailwindcss/targets/recorder.d.ts +3 -0
  190. package/dist/tailwindcss/targets/types.d.ts +35 -0
  191. package/dist/tailwindcss/targets.d.ts +6 -0
  192. package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
  193. package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
  194. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
  195. package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
  196. package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
  197. package/dist/tailwindcss/v4/config.d.ts +5 -0
  198. package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
  199. package/dist/tailwindcss/v4/index.d.ts +2 -0
  200. package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
  201. package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
  202. package/dist/tailwindcss/v4/patcher.d.ts +14 -0
  203. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
  204. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
  205. package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
  206. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +4 -0
  207. package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
  208. package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
  209. package/dist/typedoc.export.d.ts +5 -0
  210. package/dist/types/base.d.ts +1 -0
  211. package/dist/types/disabled-options.d.ts +4 -0
  212. package/dist/types/index.d.ts +104 -0
  213. package/dist/types/shared.d.ts +7 -0
  214. package/dist/types/user-defined-options/general.d.ts +31 -0
  215. package/dist/types/user-defined-options/important.d.ts +37 -0
  216. package/dist/types/user-defined-options/index.d.ts +11 -0
  217. package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
  218. package/dist/types/user-defined-options/matcher.d.ts +9 -0
  219. package/dist/types.d.ts +1 -150
  220. package/dist/types.js +0 -1
  221. package/dist/types.mjs +1 -1
  222. package/dist/uni-app-x/component-local-style.d.ts +19 -0
  223. package/dist/uni-app-x/index.d.ts +2 -0
  224. package/dist/uni-app-x/options.d.ts +12 -0
  225. package/dist/uni-app-x/style-isolation.d.ts +2 -0
  226. package/dist/uni-app-x/transform.d.ts +9 -0
  227. package/dist/uni-app-x/vite.d.ts +36 -0
  228. package/dist/utils/decode.d.ts +2 -0
  229. package/dist/utils/disabled.d.ts +6 -0
  230. package/dist/utils/hbuilderx.d.ts +5 -0
  231. package/dist/utils/index.d.ts +7 -0
  232. package/dist/utils/nameMatcher.d.ts +4 -0
  233. package/dist/utils/resolve-package.d.ts +1 -0
  234. package/dist/utils/uni-platform.d.ts +11 -0
  235. package/dist/utils-7DUGTFED.mjs +48 -0
  236. package/dist/utils-DmC9_In3.js +61 -0
  237. package/dist/vite-BHpAqldo.js +1952 -0
  238. package/dist/vite-C8JlHiyR.mjs +1940 -0
  239. package/dist/vite.d.ts +4 -17
  240. package/dist/vite.js +5 -14
  241. package/dist/vite.mjs +2 -14
  242. package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
  243. package/dist/weapp-tw-runtime-classset-loader.js +31 -50
  244. package/dist/webpack-CABjKGGQ.mjs +441 -0
  245. package/dist/webpack-DNIJ0ysE.js +456 -0
  246. package/dist/webpack.d.ts +4 -25
  247. package/dist/webpack.js +6 -17
  248. package/dist/webpack.mjs +2 -17
  249. package/dist/webpack4.d.ts +4 -26
  250. package/dist/webpack4.js +375 -481
  251. package/dist/webpack4.mjs +366 -482
  252. package/dist/wxml/Tokenizer.d.ts +15 -0
  253. package/dist/wxml/custom-attributes.d.ts +4 -0
  254. package/dist/wxml/index.d.ts +2 -0
  255. package/dist/wxml/shared.d.ts +2 -0
  256. package/dist/wxml/tokenizer/types.d.ts +18 -0
  257. package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
  258. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
  259. package/dist/wxml/utils/codegen.d.ts +2 -0
  260. package/dist/wxml/utils/custom-template.d.ts +3 -0
  261. package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
  262. package/dist/wxml/utils/fragment-updater.d.ts +4 -0
  263. package/dist/wxml/utils/template-fragments.d.ts +3 -0
  264. package/dist/wxml/utils.d.ts +8 -0
  265. package/dist/wxml/whitespace.d.ts +2 -0
  266. package/generator-placeholder.css +1 -0
  267. package/package.json +19 -5
  268. package/dist/chunk-24AGZQVR.js +0 -183
  269. package/dist/chunk-3VQKDHGP.mjs +0 -179
  270. package/dist/chunk-4AFQP74Z.js +0 -24
  271. package/dist/chunk-57SOQCAU.mjs +0 -582
  272. package/dist/chunk-5ZYHNDEK.mjs +0 -2439
  273. package/dist/chunk-76S2EME4.mjs +0 -34
  274. package/dist/chunk-A5PB4KZT.js +0 -138
  275. package/dist/chunk-DUHYLR2R.js +0 -276
  276. package/dist/chunk-DYLQ6UOI.js +0 -71
  277. package/dist/chunk-E7I5TW5K.js +0 -52
  278. package/dist/chunk-FS2NOOEB.js +0 -292
  279. package/dist/chunk-HVNGIKLS.js +0 -3930
  280. package/dist/chunk-JZQBZHN5.js +0 -579
  281. package/dist/chunk-KGTVD4EP.mjs +0 -3930
  282. package/dist/chunk-NNOQDMUP.mjs +0 -10
  283. package/dist/chunk-OF6MFURR.js +0 -34
  284. package/dist/chunk-OFB2KBRP.js +0 -2442
  285. package/dist/chunk-OOHJLO5M.mjs +0 -71
  286. package/dist/chunk-PCDYXXSK.mjs +0 -1515
  287. package/dist/chunk-RKISS72P.js +0 -7
  288. package/dist/chunk-RRQZL7FQ.mjs +0 -292
  289. package/dist/chunk-XAKAD2CR.mjs +0 -138
  290. package/dist/chunk-XZP3MREK.mjs +0 -276
  291. package/dist/chunk-ZAA5ZG3D.js +0 -1518
  292. package/dist/chunk-ZCH4YINE.mjs +0 -52
  293. package/dist/cli.d.mts +0 -2
  294. package/dist/core.d.mts +0 -26
  295. package/dist/css-macro/postcss.d.mts +0 -7
  296. package/dist/css-macro.d.mts +0 -18
  297. package/dist/defaults.d.mts +0 -11
  298. package/dist/gulp.d.mts +0 -24
  299. package/dist/index-BXrmQelt.d.mts +0 -672
  300. package/dist/index-BXrmQelt.d.ts +0 -672
  301. package/dist/index.d.mts +0 -15
  302. package/dist/postcss-html-transform.d.mts +0 -2
  303. package/dist/presets.d.mts +0 -76
  304. package/dist/reset.d.mts +0 -1
  305. package/dist/types.d.mts +0 -150
  306. package/dist/vite.d.mts +0 -17
  307. package/dist/webpack.d.mts +0 -25
  308. package/dist/webpack4.d.mts +0 -26
@@ -1,7 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.12.2__@swc+core@1.15.33_@swc+_bcceec21436c72f72b5a2f34a0f75238/node_modules/tsup/assets/cjs_shims.js
2
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
3
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
4
-
5
-
6
-
7
- exports.importMetaUrl = importMetaUrl;
@@ -1,292 +0,0 @@
1
- import {
2
- resolveTailwindcssImport
3
- } from "./chunk-3VQKDHGP.mjs";
4
- import {
5
- pluginName
6
- } from "./chunk-KGTVD4EP.mjs";
7
-
8
- // src/shared/mpx.ts
9
- import path2 from "path";
10
-
11
- // src/shared/tailwindcss-css-redirect.ts
12
- import Module from "module";
13
- import path from "path";
14
- var moduleWithMutableResolve = Module;
15
- var patched = /* @__PURE__ */ new WeakSet();
16
- function installTailwindcssCssRedirect(pkgDir) {
17
- const target = path.join(pkgDir, "index.css");
18
- const original = moduleWithMutableResolve._resolveFilename;
19
- if (patched.has(original)) {
20
- return;
21
- }
22
- const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
23
- const resolveTailwindcssCss = (request, parent, isMain, options) => {
24
- if (replacements.has(request)) {
25
- return target;
26
- }
27
- if (request.startsWith("tailwindcss/")) {
28
- return path.join(pkgDir, request.slice("tailwindcss/".length));
29
- }
30
- return original(request, parent, isMain, options);
31
- };
32
- moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
33
- patched.add(moduleWithMutableResolve._resolveFilename);
34
- }
35
-
36
- // src/shared/mpx.ts
37
- var MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
38
- function isMpxStyleResourceQuery(query) {
39
- if (typeof query !== "string") {
40
- return false;
41
- }
42
- return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
43
- }
44
- function isMpx(appType) {
45
- return appType === "mpx";
46
- }
47
- function getTailwindcssCssEntry(pkgDir) {
48
- return path2.join(pkgDir, "index.css");
49
- }
50
- function ensureMpxTailwindcssAliases(compiler, pkgDir) {
51
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
52
- compiler.options = compiler.options || {};
53
- compiler.options.resolve = compiler.options.resolve || {};
54
- const alias = compiler.options.resolve.alias ?? {};
55
- if (Array.isArray(alias)) {
56
- alias.push(
57
- { name: "tailwindcss", alias: tailwindcssCssEntry },
58
- { name: "tailwindcss$", alias: tailwindcssCssEntry }
59
- );
60
- } else {
61
- compiler.options.resolve.alias = alias;
62
- alias.tailwindcss = tailwindcssCssEntry;
63
- alias.tailwindcss$ = tailwindcssCssEntry;
64
- }
65
- return tailwindcssCssEntry;
66
- }
67
- function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
68
- if (!enabled || typeof loaderContext.resolve !== "function") {
69
- return;
70
- }
71
- const originalResolve = loaderContext.resolve;
72
- if (originalResolve.__weappTwPatched) {
73
- return;
74
- }
75
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
76
- const wrappedResolve = function(context, request, callback) {
77
- if (request === "tailwindcss" || request === "tailwindcss$") {
78
- return callback(null, tailwindcssCssEntry);
79
- }
80
- if (request?.startsWith("tailwindcss/")) {
81
- return callback(null, path2.join(pkgDir, request.slice("tailwindcss/".length)));
82
- }
83
- return originalResolve.call(this, context, request, callback);
84
- };
85
- wrappedResolve.__weappTwPatched = true;
86
- loaderContext.resolve = wrappedResolve;
87
- }
88
- function setupMpxTailwindcssRedirect(pkgDir, enabled) {
89
- if (enabled) {
90
- installTailwindcssCssRedirect(pkgDir);
91
- }
92
- }
93
- var CSS_EXT_RE = /\.css$/i;
94
- function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
95
- var _a;
96
- if (!loader) {
97
- return;
98
- }
99
- const moduleOptions = (_a = compiler.options).module ?? (_a.module = { rules: [] });
100
- moduleOptions.rules = moduleOptions.rules || [];
101
- const createRule = (match) => ({
102
- ...match,
103
- enforce: "pre",
104
- use: [
105
- {
106
- loader,
107
- options: loaderOptions
108
- }
109
- ]
110
- });
111
- moduleOptions.rules.unshift(
112
- createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }),
113
- createRule({
114
- test: CSS_EXT_RE,
115
- resourceQuery: (query) => !isMpxStyleResourceQuery(query)
116
- })
117
- );
118
- }
119
-
120
- // src/bundlers/webpack/shared/css-imports.ts
121
- var CSS_EXT_RE2 = /\.(?:css|scss|sass|less|styl|pcss)$/i;
122
- function stripResourceQuery(file) {
123
- let idx = file.indexOf("?");
124
- if (idx === -1) {
125
- idx = file.indexOf("&");
126
- }
127
- return idx === -1 ? file : file.slice(0, idx);
128
- }
129
- function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
130
- if (!data) {
131
- return;
132
- }
133
- const request = data.request;
134
- if (!request) {
135
- return;
136
- }
137
- if (request !== "tailwindcss" && request !== "tailwindcss$" && !request.startsWith("tailwindcss/")) {
138
- return;
139
- }
140
- const issuer = data.contextInfo?.issuer;
141
- if (!issuer) {
142
- return;
143
- }
144
- const normalizedIssuer = stripResourceQuery(issuer);
145
- if (!CSS_EXT_RE2.test(normalizedIssuer)) {
146
- return;
147
- }
148
- const resolved = resolveTailwindcssImport(request, pkgDir, { appType });
149
- if (!resolved) {
150
- return;
151
- }
152
- data.request = resolved;
153
- }
154
- function applyTailwindcssCssImportRewrite(compiler, options) {
155
- if (!options.enabled) {
156
- return;
157
- }
158
- compiler.hooks.normalModuleFactory.tap(pluginName, (factory) => {
159
- factory.hooks.beforeResolve.tap(pluginName, (data) => {
160
- rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
161
- });
162
- });
163
- }
164
-
165
- // src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
166
- var MPX_STYLE_RESOURCE_QUERY_RE2 = /(?:\?|&)type=styles\b/;
167
- function getCacheKey(filename) {
168
- return filename;
169
- }
170
- function stripResourceQuery2(resource) {
171
- if (typeof resource !== "string") {
172
- return resource;
173
- }
174
- const queryIndex = resource.indexOf("?");
175
- if (queryIndex !== -1) {
176
- return resource.slice(0, queryIndex);
177
- }
178
- const hashIndex = resource.indexOf("#");
179
- if (hashIndex !== -1) {
180
- return resource.slice(0, hashIndex);
181
- }
182
- return resource;
183
- }
184
- function isCssLikeModuleResource(resource, cssMatcher, appType) {
185
- if (typeof resource !== "string") {
186
- return false;
187
- }
188
- const normalizedResource = stripResourceQuery2(resource);
189
- if (normalizedResource && cssMatcher(normalizedResource)) {
190
- return true;
191
- }
192
- if (appType === "mpx") {
193
- return MPX_STYLE_RESOURCE_QUERY_RE2.test(resource);
194
- }
195
- return false;
196
- }
197
- function hasLoaderEntry(entries, target) {
198
- if (!target) {
199
- return false;
200
- }
201
- return entries.some((entry) => entry.loader?.includes?.(target));
202
- }
203
- function toChunkFiles(files) {
204
- if (!files) {
205
- return [];
206
- }
207
- if (Array.isArray(files)) {
208
- return files;
209
- }
210
- return [...files];
211
- }
212
- function createAssetHashByChunkMap(chunks) {
213
- const partsByFile = /* @__PURE__ */ new Map();
214
- for (const chunk of chunks) {
215
- const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
216
- if (!hash) {
217
- continue;
218
- }
219
- const chunkId = String(chunk.id ?? chunk.name ?? "");
220
- for (const file of toChunkFiles(chunk.files)) {
221
- if (!file) {
222
- continue;
223
- }
224
- let parts = partsByFile.get(file);
225
- if (!parts) {
226
- parts = [];
227
- partsByFile.set(file, parts);
228
- }
229
- parts.push(`${chunkId}:${hash}`);
230
- }
231
- }
232
- const hashByFile = /* @__PURE__ */ new Map();
233
- for (const [file, parts] of partsByFile.entries()) {
234
- hashByFile.set(file, parts.sort().join("|"));
235
- }
236
- return hashByFile;
237
- }
238
- function hasWatchChanges(compiler) {
239
- return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
240
- }
241
-
242
- // src/bundlers/webpack/shared/loader-anchors.ts
243
- var MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
244
- var MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
245
- var MPX_REWRITE_PRECEDENCE_LOADERS = [
246
- MPX_STYLE_COMPILER_LOADER,
247
- MPX_STRIP_CONDITIONAL_LOADER
248
- ];
249
- function createFinder(targets) {
250
- return (entries) => entries.findIndex(
251
- (entry) => targets.some((target) => entry?.loader?.includes?.(target))
252
- );
253
- }
254
- function createPrioritizedFinder(targets) {
255
- return (entries) => {
256
- for (const target of targets) {
257
- const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
258
- if (idx !== -1) {
259
- return idx;
260
- }
261
- }
262
- return -1;
263
- };
264
- }
265
- function createLoaderAnchorFinders(appType) {
266
- if (isMpx(appType)) {
267
- return {
268
- findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
269
- findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
270
- };
271
- }
272
- const fallbackFinder = createFinder(["postcss-loader"]);
273
- return {
274
- findRewriteAnchor: fallbackFinder,
275
- findClassSetAnchor: fallbackFinder
276
- };
277
- }
278
-
279
- export {
280
- isMpx,
281
- ensureMpxTailwindcssAliases,
282
- patchMpxLoaderResolve,
283
- setupMpxTailwindcssRedirect,
284
- injectMpxCssRewritePreRules,
285
- applyTailwindcssCssImportRewrite,
286
- getCacheKey,
287
- isCssLikeModuleResource,
288
- hasLoaderEntry,
289
- createAssetHashByChunkMap,
290
- hasWatchChanges,
291
- createLoaderAnchorFinders
292
- };
@@ -1,138 +0,0 @@
1
- import {
2
- noop
3
- } from "./chunk-OOHJLO5M.mjs";
4
-
5
- // src/defaults.ts
6
- import { isAllowedClassName, MappingChars2String } from "@weapp-core/escape";
7
- var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
8
- var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
9
- var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
10
- var BACKSLASH_RE = /\\/g;
11
- function normalizePath(p) {
12
- return p.replace(BACKSLASH_RE, "/");
13
- }
14
- var MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
15
- var KBONE_MAIN_CSS_RE = /^(?:common\/)?miniprogram-app/;
16
- var IMPLICIT_MAIN_CSS_RE = /^(?:app|common\/main|bundle)(?:\.|\/|$)/;
17
- var MAIN_CSS_CHUNK_MATCHERS = {
18
- "uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
19
- "uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
20
- "uni-app-x": (file) => file.startsWith("app") || file.startsWith("common/main"),
21
- "mpx": (file) => {
22
- const normalized = normalizePath(file);
23
- if (normalized.startsWith("app")) {
24
- return true;
25
- }
26
- return MPX_STYLES_DIR_PATTERN.test(normalized);
27
- },
28
- "taro": (file) => file.startsWith("app"),
29
- "remax": (file) => file.startsWith("app"),
30
- "rax": (file) => file.startsWith("bundle"),
31
- "native": (file) => file.startsWith("app"),
32
- "weapp-vite": (file) => file.startsWith("app"),
33
- "kbone": (file) => KBONE_MAIN_CSS_RE.test(file)
34
- };
35
- var alwaysFalse = () => false;
36
- function createMainCssChunkMatcher() {
37
- return (file, appType) => {
38
- if (!appType) {
39
- const normalized = normalizePath(file);
40
- return IMPLICIT_MAIN_CSS_RE.test(normalized) || MPX_STYLES_DIR_PATTERN.test(normalized) || KBONE_MAIN_CSS_RE.test(normalized);
41
- }
42
- const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
43
- return matcher ? matcher(file) : true;
44
- };
45
- }
46
- function getDefaultOptions() {
47
- return {
48
- /**
49
- * wxss 微信小程序
50
- * acss 支付宝小程序
51
- * jxss 京东小程序
52
- * ttss 头条小程序
53
- * qss QQ小程序
54
- * css 最正常的样式文件
55
- * tyss 涂鸦小程序
56
- */
57
- cssMatcher: (file) => CSS_FILE_PATTERN.test(file),
58
- /**
59
- * wxml 微信小程序
60
- * axml 支付宝小程序
61
- * jxml 京东小程序
62
- * ksml 快手小程序
63
- * ttml 头条小程序
64
- * qml QQ小程序
65
- * tyml 涂鸦小程序
66
- * xhsml 小红书小程序
67
- * swan 百度小程序
68
- */
69
- htmlMatcher: (file) => HTML_FILE_PATTERN.test(file),
70
- jsMatcher: (file) => {
71
- if (file.includes("node_modules")) {
72
- return false;
73
- }
74
- return JS_FILE_PATTERN.test(file);
75
- },
76
- mainCssChunkMatcher: createMainCssChunkMatcher(),
77
- wxsMatcher: alwaysFalse,
78
- // 参考:https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
79
- cssPreflight: {
80
- "box-sizing": "border-box",
81
- "border-width": "0",
82
- "border-style": "solid",
83
- "border-color": "currentColor"
84
- },
85
- disabled: false,
86
- onLoad: noop,
87
- onStart: noop,
88
- onEnd: noop,
89
- onUpdate: noop,
90
- customAttributes: {},
91
- customReplaceDictionary: MappingChars2String,
92
- appType: void 0,
93
- arbitraryValues: {
94
- allowDoubleQuotes: false
95
- },
96
- cssChildCombinatorReplaceValue: ["view", "text"],
97
- inlineWxs: false,
98
- injectAdditionalCssVarScope: false,
99
- rewriteCssImports: true,
100
- jsPreserveClass: (keyword) => {
101
- if (keyword === "*") {
102
- return true;
103
- }
104
- return false;
105
- },
106
- staleClassNameFallback: void 0,
107
- disabledDefaultTemplateHandler: false,
108
- cssSelectorReplacement: {
109
- root: ["page", ".tw-root", "wx-root-portal-content"],
110
- universal: ["view", "text"]
111
- },
112
- babelParserOptions: {
113
- sourceType: "unambiguous",
114
- cache: true,
115
- // 预计算好的 cacheKey,避免重复对选项进行 JSON.stringify
116
- cacheKey: "st:unambiguous"
117
- },
118
- postcssOptions: {},
119
- // 开发版本微信小程序工具和小米13手机上 @property 是有效果的
120
- // 支付宝小程序会直接挂掉
121
- // https://developer.mozilla.org/en-US/docs/Web/CSS/@property
122
- cssRemoveProperty: true,
123
- cssRemoveHoverPseudoClass: true,
124
- ignoreCallExpressionIdentifiers: [],
125
- ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"],
126
- replaceRuntimePackages: false,
127
- tailwindcssPatcherOptions: {
128
- filter(className) {
129
- return !isAllowedClassName(className);
130
- }
131
- },
132
- logLevel: "info"
133
- };
134
- }
135
-
136
- export {
137
- getDefaultOptions
138
- };
@@ -1,276 +0,0 @@
1
- import {
2
- processCachedTask
3
- } from "./chunk-76S2EME4.mjs";
4
- import {
5
- createDebug,
6
- ensureRuntimeClassSet,
7
- getCompilerContext,
8
- refreshTailwindRuntimeState,
9
- setupPatchRecorder,
10
- shouldSkipJsTransform
11
- } from "./chunk-KGTVD4EP.mjs";
12
-
13
- // src/bundlers/gulp/index.ts
14
- import { Buffer } from "buffer";
15
- import fs from "fs";
16
- import path from "path";
17
- import process from "process";
18
- import stream from "stream";
19
- var debug = createDebug();
20
- var Transform = stream.Transform;
21
- function createPlugins(options = {}) {
22
- const opts = getCompilerContext(options);
23
- const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
24
- const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
25
- source: "runtime",
26
- cwd: opts.tailwindcssBasedir ?? process.cwd()
27
- });
28
- let runtimeSet = /* @__PURE__ */ new Set();
29
- const runtimeState = {
30
- twPatcher: initialTwPatcher,
31
- patchPromise: patchRecorderState.patchPromise,
32
- refreshTailwindcssPatcher,
33
- onPatchCompleted: patchRecorderState.onPatchCompleted
34
- };
35
- const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
36
- let cachedDefaultTemplateHandlerOptions;
37
- let cachedDefaultTemplateRuntimeSet;
38
- let cachedDefaultModuleGraphOptions;
39
- const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
40
- let runtimeSetInitialized = false;
41
- async function refreshRuntimeState(force) {
42
- await refreshTailwindRuntimeState(runtimeState, force);
43
- }
44
- async function refreshRuntimeSet(force = false) {
45
- if (!force && runtimeSetInitialized) {
46
- return runtimeSet;
47
- }
48
- runtimeSet = await ensureRuntimeClassSet(runtimeState, {
49
- forceRefresh: force,
50
- forceCollect: force,
51
- clearCache: force,
52
- allowEmpty: false
53
- });
54
- runtimeSetInitialized = true;
55
- return runtimeSet;
56
- }
57
- function resolveWithExtensions(base) {
58
- for (const ext of MODULE_EXTENSIONS) {
59
- const candidate = `${base}${ext}`;
60
- try {
61
- if (fs.statSync(candidate).isFile()) {
62
- return candidate;
63
- }
64
- } catch {
65
- continue;
66
- }
67
- }
68
- return void 0;
69
- }
70
- function resolveLocalModuleCandidate(base) {
71
- try {
72
- const stat = fs.statSync(base);
73
- if (stat.isFile()) {
74
- return base;
75
- }
76
- if (stat.isDirectory()) {
77
- const resolvedIndex = resolveWithExtensions(path.join(base, "index"));
78
- if (resolvedIndex) {
79
- return resolvedIndex;
80
- }
81
- }
82
- } catch {
83
- }
84
- if (!path.extname(base)) {
85
- return resolveWithExtensions(base);
86
- }
87
- return void 0;
88
- }
89
- function createModuleGraphOptionsFor() {
90
- return {
91
- resolve(specifier, importer) {
92
- if (!specifier) {
93
- return void 0;
94
- }
95
- if (!specifier.startsWith(".") && !path.isAbsolute(specifier)) {
96
- return void 0;
97
- }
98
- const normalized = path.resolve(path.dirname(importer), specifier);
99
- return resolveLocalModuleCandidate(normalized);
100
- },
101
- load(id) {
102
- try {
103
- return fs.readFileSync(id, "utf8");
104
- } catch {
105
- return void 0;
106
- }
107
- },
108
- filter(id) {
109
- const relative = path.relative(process.cwd(), id);
110
- return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
111
- }
112
- };
113
- }
114
- function resolveModuleGraphOptions(moduleGraph) {
115
- if (moduleGraph) {
116
- return moduleGraph;
117
- }
118
- if (!cachedDefaultModuleGraphOptions) {
119
- cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
120
- }
121
- return cachedDefaultModuleGraphOptions;
122
- }
123
- function createVinylTransform(handler) {
124
- return new Transform({
125
- objectMode: true,
126
- async transform(file, _encoding, callback) {
127
- try {
128
- await handler(file);
129
- callback(null, file);
130
- } catch (error) {
131
- callback(error, file);
132
- }
133
- }
134
- });
135
- }
136
- function resolveWxssHandlerOptions(options2) {
137
- const majorVersion = runtimeState.twPatcher.majorVersion ?? "unknown";
138
- if (!options2 || Object.keys(options2).length === 0) {
139
- let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
140
- if (!cached) {
141
- cached = {
142
- isMainChunk: true,
143
- majorVersion: runtimeState.twPatcher.majorVersion
144
- };
145
- defaultStyleHandlerOptionsCache.set(majorVersion, cached);
146
- }
147
- return cached;
148
- }
149
- return {
150
- isMainChunk: true,
151
- majorVersion: runtimeState.twPatcher.majorVersion,
152
- ...options2
153
- };
154
- }
155
- function resolveWxmlHandlerOptions(options2) {
156
- if (!options2 || Object.keys(options2).length === 0) {
157
- if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
158
- cachedDefaultTemplateRuntimeSet = runtimeSet;
159
- cachedDefaultTemplateHandlerOptions = {
160
- runtimeSet
161
- };
162
- }
163
- return cachedDefaultTemplateHandlerOptions;
164
- }
165
- return {
166
- runtimeSet,
167
- ...options2
168
- };
169
- }
170
- const transformWxss = (options2 = {}) => createVinylTransform(async (file) => {
171
- if (!file.contents) {
172
- return;
173
- }
174
- await refreshRuntimeState(true);
175
- await runtimeState.patchPromise;
176
- const rawSource = file.contents.toString();
177
- await processCachedTask({
178
- cache,
179
- cacheKey: file.path,
180
- rawSource,
181
- applyResult(source) {
182
- file.contents = Buffer.from(source);
183
- },
184
- onCacheHit() {
185
- debug("css cache hit: %s", file.path);
186
- },
187
- async transform() {
188
- await runtimeState.patchPromise;
189
- const { css } = await styleHandler(rawSource, resolveWxssHandlerOptions(options2));
190
- debug("css handle: %s", file.path);
191
- return {
192
- result: css
193
- };
194
- }
195
- });
196
- });
197
- const transformJs = (options2 = {}) => createVinylTransform(async (file) => {
198
- if (!file.contents) {
199
- return;
200
- }
201
- await refreshRuntimeSet(false);
202
- await runtimeState.patchPromise;
203
- const filename = path.resolve(file.path);
204
- const moduleGraph = resolveModuleGraphOptions(options2.moduleGraph);
205
- const handlerOptions = {
206
- ...options2,
207
- filename,
208
- moduleGraph,
209
- tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
210
- babelParserOptions: {
211
- ...options2?.babelParserOptions ?? {},
212
- sourceFilename: filename
213
- }
214
- };
215
- const rawSource = file.contents.toString();
216
- await processCachedTask({
217
- cache,
218
- cacheKey: file.path,
219
- rawSource,
220
- applyResult(source) {
221
- file.contents = Buffer.from(source);
222
- },
223
- onCacheHit() {
224
- debug("js cache hit: %s", file.path);
225
- },
226
- async transform() {
227
- await runtimeState.patchPromise;
228
- const currentSource = file.contents?.toString() ?? rawSource;
229
- if (shouldSkipJsTransform(currentSource, handlerOptions)) {
230
- return { result: currentSource };
231
- }
232
- const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
233
- debug("js handle: %s", file.path);
234
- return {
235
- result: code
236
- };
237
- }
238
- });
239
- });
240
- const transformWxml = (options2 = {}) => createVinylTransform(async (file) => {
241
- if (!file.contents) {
242
- return;
243
- }
244
- await refreshRuntimeSet(false);
245
- await runtimeState.patchPromise;
246
- const rawSource = file.contents.toString();
247
- await processCachedTask({
248
- cache,
249
- cacheKey: file.path,
250
- rawSource,
251
- applyResult(source) {
252
- file.contents = Buffer.from(source);
253
- },
254
- onCacheHit() {
255
- debug("html cache hit: %s", file.path);
256
- },
257
- async transform() {
258
- await runtimeState.patchPromise;
259
- const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options2));
260
- debug("html handle: %s", file.path);
261
- return {
262
- result: code
263
- };
264
- }
265
- });
266
- });
267
- return {
268
- transformWxss,
269
- transformWxml,
270
- transformJs
271
- };
272
- }
273
-
274
- export {
275
- createPlugins
276
- };