weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.20

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 (220) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BlXvU4jl.js +530 -0
  4. package/dist/bundle-state-PO6MysTJ.mjs +414 -0
  5. package/dist/bundlers/shared/cache.d.ts +6 -6
  6. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  7. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  8. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +5 -0
  9. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  10. package/dist/bundlers/shared/css-cleanup.d.ts +7 -3
  11. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  12. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  13. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  14. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  15. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  16. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  17. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  18. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  19. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  20. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  21. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  22. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  23. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  24. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  25. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  26. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  27. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  28. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  29. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  30. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  31. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  32. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  33. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  34. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  35. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  36. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  37. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  38. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  39. package/dist/bundlers/vite/index.d.ts +1 -1
  40. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  41. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  42. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  43. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  44. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  45. package/dist/bundlers/vite/source-candidates.d.ts +16 -1
  46. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  47. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  48. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  50. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  51. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  52. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  53. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  54. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  55. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  56. package/dist/cache/index.d.ts +6 -6
  57. package/dist/cli/context.d.ts +1 -14
  58. package/dist/cli/doctor/types.d.ts +11 -11
  59. package/dist/cli/helpers.d.ts +1 -2
  60. package/dist/cli/mount-options.d.ts +2 -0
  61. package/dist/cli/types.d.ts +0 -2
  62. package/dist/cli/vscode-entry.d.ts +3 -3
  63. package/dist/cli.js +605 -611
  64. package/dist/cli.mjs +614 -620
  65. package/dist/constants.d.ts +1 -2
  66. package/dist/core.js +13 -20
  67. package/dist/core.mjs +8 -14
  68. package/dist/css-macro/postcss.js +3 -2
  69. package/dist/css-macro/postcss.mjs +3 -2
  70. package/dist/css-macro.d.ts +1 -0
  71. package/dist/css-macro.js +2 -2
  72. package/dist/css-macro.mjs +2 -2
  73. package/dist/defaults-B1igPF_e.mjs +150 -0
  74. package/dist/defaults-IHhYxNeU.js +193 -0
  75. package/dist/defaults.d.ts +15 -1
  76. package/dist/defaults.js +6 -131
  77. package/dist/defaults.mjs +2 -129
  78. package/dist/escape.js +10 -2
  79. package/dist/escape.mjs +10 -2
  80. package/dist/generator/index.d.ts +1 -1
  81. package/dist/generator/options.d.ts +9 -8
  82. package/dist/generator/types.d.ts +3 -3
  83. package/dist/generator-DIuglJub.mjs +32 -0
  84. package/dist/generator-N4jy1HCk.js +55 -0
  85. package/dist/generator.js +12 -11
  86. package/dist/generator.mjs +2 -1
  87. package/dist/gulp.js +185 -47
  88. package/dist/gulp.mjs +179 -41
  89. package/dist/incremental-runtime-class-set-CJ0Pnsw2.js +2348 -0
  90. package/dist/incremental-runtime-class-set-hF-uiw6W.mjs +2285 -0
  91. package/dist/index.d.ts +1 -1
  92. package/dist/index.js +6 -6
  93. package/dist/index.mjs +5 -5
  94. package/dist/js/babel/cache-options.d.ts +3 -0
  95. package/dist/js/babel/parse.d.ts +7 -4
  96. package/dist/js/index.d.ts +1 -0
  97. package/dist/js/literal-transform.d.ts +2 -0
  98. package/dist/js/precheck.d.ts +2 -2
  99. package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
  100. package/dist/lightningcss/style-handler.d.ts +3 -3
  101. package/dist/logger-CZUxvJJD.mjs +2 -0
  102. package/dist/logger-EVNB9z7i.js +1 -0
  103. package/dist/postcss/config-directive.d.ts +1 -0
  104. package/dist/postcss/context.d.ts +9 -0
  105. package/dist/postcss/source-files.d.ts +8 -0
  106. package/dist/postcss/tailwind-version.d.ts +3 -0
  107. package/dist/postcss-D4UdbBQ6.mjs +228 -0
  108. package/dist/postcss-DlY-YRvA.js +237 -0
  109. package/dist/postcss.d.ts +2 -2
  110. package/dist/postcss.js +3 -276
  111. package/dist/postcss.mjs +1 -269
  112. package/dist/{recorder-gYSNLfOP.js → precheck-BjEbVEpX.js} +218 -314
  113. package/dist/{recorder-zsgatmkB.mjs → precheck-tbk626YL.mjs} +186 -281
  114. package/dist/presets.js +13 -11
  115. package/dist/presets.mjs +11 -9
  116. package/dist/reset.d.ts +1 -0
  117. package/dist/runtime-registry-D5qnaSpo.js +5516 -0
  118. package/dist/shared/mpx.d.ts +1 -0
  119. package/dist/source-candidates-BrvneDDd.mjs +209 -0
  120. package/dist/source-candidates-gxijpPI3.js +222 -0
  121. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  122. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  123. package/dist/tailwindcss/patcher.d.ts +1 -2
  124. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  125. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  126. package/dist/tailwindcss/runtime.d.ts +11 -12
  127. package/dist/tailwindcss/source-scan.d.ts +35 -0
  128. package/dist/tailwindcss/targets.d.ts +1 -5
  129. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  130. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  131. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  132. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  133. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  134. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  135. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  136. package/dist/tailwindcss/version.d.ts +4 -0
  137. package/dist/tailwindcss-BhG7BtB-.js +651 -0
  138. package/dist/tailwindcss-c6ROlNNW.mjs +600 -0
  139. package/dist/typedoc.export.d.ts +0 -2
  140. package/dist/types/index.d.ts +51 -48
  141. package/dist/types/shared.d.ts +3 -0
  142. package/dist/types/user-defined-options/general.d.ts +23 -23
  143. package/dist/types/user-defined-options/important.d.ts +31 -28
  144. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  145. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  146. package/dist/uni-app-x/vite.d.ts +1 -1
  147. package/dist/utils/disabled.d.ts +2 -3
  148. package/dist/utils/object.d.ts +9 -0
  149. package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
  150. package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
  151. package/dist/v3-engine-5LoZUH-4.js +3695 -0
  152. package/dist/v3-engine-DIXDEDmL.mjs +3406 -0
  153. package/dist/{vite-CrlzCNqz.mjs → vite-B5faZcbE.mjs} +1256 -1088
  154. package/dist/vite-MyXBNux0.js +2368 -0
  155. package/dist/vite.d.ts +1 -2
  156. package/dist/vite.js +3 -4
  157. package/dist/vite.mjs +2 -2
  158. package/dist/weapp-tw-css-import-rewrite-loader.js +5157 -16
  159. package/dist/weapp-tw-runtime-classset-loader.js +32 -7
  160. package/dist/webpack-BnVyDmsD.mjs +836 -0
  161. package/dist/webpack-Mz1V0A9p.js +846 -0
  162. package/dist/webpack.js +1 -1
  163. package/dist/webpack.mjs +1 -1
  164. package/package.json +27 -37
  165. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  166. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  167. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  168. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  169. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  170. package/dist/cli/config.d.ts +0 -5
  171. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  172. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  173. package/dist/cli/patch-options.d.ts +0 -6
  174. package/dist/cli/tokens.d.ts +0 -4
  175. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  176. package/dist/cli/workspace/patch-package.d.ts +0 -3
  177. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  178. package/dist/cli/workspace/types.d.ts +0 -11
  179. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  180. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  181. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  182. package/dist/cli/workspace.d.ts +0 -2
  183. package/dist/css-imports-BbrbluP9.js +0 -177
  184. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  185. package/dist/experimental/index.d.ts +0 -2
  186. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  187. package/dist/experimental/oxc/index.d.ts +0 -2
  188. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  189. package/dist/experimental/shared/cache.d.ts +0 -3
  190. package/dist/experimental/shared/transform.d.ts +0 -3
  191. package/dist/experimental/shared.d.ts +0 -8
  192. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  193. package/dist/experimental/swc/index.d.ts +0 -2
  194. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  195. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  196. package/dist/generator-css-B5ejWUMv.mjs +0 -1098
  197. package/dist/generator-css-D3OdPRiS.js +0 -1125
  198. package/dist/generator-mmhXzZnv.js +0 -1276
  199. package/dist/js/syntax.d.ts +0 -10
  200. package/dist/loader-anchors-CNkWT8hx.js +0 -273
  201. package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
  202. package/dist/logger-BZ45DZJT.js +0 -1003
  203. package/dist/logger-BoVx1Dbt.mjs +0 -935
  204. package/dist/patcher-options-6gJN2EXy.js +0 -115
  205. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  206. package/dist/tailwindcss/recorder.d.ts +0 -13
  207. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  208. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  209. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  210. package/dist/tailwindcss/targets/types.d.ts +0 -35
  211. package/dist/types/disabled-options.d.ts +0 -4
  212. package/dist/vite-BC9U7ahn.js +0 -2199
  213. package/dist/webpack-Bu6M-Hbw.mjs +0 -441
  214. package/dist/webpack-DD7A6V0u.js +0 -456
  215. package/dist/webpack4.d.ts +0 -4
  216. package/dist/webpack4.js +0 -387
  217. package/dist/webpack4.mjs +0 -379
  218. package/scripts/postinstall.mjs +0 -59
  219. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  220. /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/dist/webpack4.js DELETED
@@ -1,387 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_chunk = require("./chunk-8l464Juk.js");
3
- const require_recorder = require("./recorder-gYSNLfOP.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-D3OdPRiS.js");
7
- const require_css_imports = require("./css-imports-BbrbluP9.js");
8
- const require_loader_anchors = require("./loader-anchors-CNkWT8hx.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
17
- function resolveWebpackStaleClassNameFallback(option, _compiler) {
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();
27
- }
28
- function setupWebpackV4EmitHook(options) {
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
- });
225
- }
226
- //#endregion
227
- //#region src/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.ts
228
- function setupWebpackV4Loaders(options) {
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
- });
304
- }
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
- */
314
- var UnifiedWebpackPluginV4 = class {
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
- }
382
- };
383
- //#endregion
384
- exports.UnifiedWebpackPluginV4 = UnifiedWebpackPluginV4;
385
- exports.WeappTailwindcss = UnifiedWebpackPluginV4;
386
- exports.weappTailwindcss = UnifiedWebpackPluginV4;
387
- exports.weappTailwindcssPackageDir = weappTailwindcssPackageDir;