weapp-tailwindcss 4.9.2 → 4.9.4

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 (54) hide show
  1. package/dist/{chunk-WGBJY2H3.mjs → chunk-3IXWQT3G.mjs} +646 -565
  2. package/dist/{chunk-5O6237HX.js → chunk-4RUFPPI6.js} +400 -377
  3. package/dist/{chunk-2L6NDZIQ.mjs → chunk-6HOLMRXS.mjs} +2 -2
  4. package/dist/{chunk-ZE7JKKFT.mjs → chunk-7D27E7TU.mjs} +438 -415
  5. package/dist/chunk-AJDZJQNR.mjs +444 -0
  6. package/dist/{chunk-U7BH6QHE.js → chunk-DKX737YI.js} +277 -236
  7. package/dist/{chunk-VU2GIXVH.js → chunk-EZWWOZAH.js} +7 -7
  8. package/dist/{chunk-3SKEY32E.mjs → chunk-F2CKKG6Q.mjs} +67 -67
  9. package/dist/{chunk-DNRNFN4I.js → chunk-KHBSYJ76.js} +44 -44
  10. package/dist/{chunk-XXJNXESJ.js → chunk-MVOIVNKL.js} +635 -554
  11. package/dist/{chunk-G5OV7IOU.mjs → chunk-QAEALIIZ.mjs} +2 -2
  12. package/dist/{chunk-FFGR5V3H.mjs → chunk-SPH6SCTM.mjs} +1 -1
  13. package/dist/{chunk-2WPTDMN3.js → chunk-VPHA77FH.js} +61 -61
  14. package/dist/{chunk-DSD5JRCQ.mjs → chunk-WCM6ODS4.mjs} +265 -224
  15. package/dist/{chunk-CBOVUIXD.mjs → chunk-XI2H73CF.mjs} +41 -41
  16. package/dist/{chunk-UAEME5HT.js → chunk-Y6F6NBA7.js} +1 -1
  17. package/dist/chunk-Z3A2XYUL.js +441 -0
  18. package/dist/{chunk-W3MTTQ5M.js → chunk-ZQ7ET56G.js} +5 -5
  19. package/dist/cli.js +182 -136
  20. package/dist/cli.mjs +194 -148
  21. package/dist/core.js +10 -10
  22. package/dist/core.mjs +4 -4
  23. package/dist/css-macro/postcss.js +1 -1
  24. package/dist/css-macro/postcss.mjs +1 -1
  25. package/dist/css-macro.js +1 -1
  26. package/dist/css-macro.mjs +1 -1
  27. package/dist/defaults.js +1 -1
  28. package/dist/defaults.mjs +1 -1
  29. package/dist/gulp.js +6 -6
  30. package/dist/gulp.mjs +5 -5
  31. package/dist/index.js +10 -10
  32. package/dist/index.mjs +9 -9
  33. package/dist/postcss-html-transform.js +1 -1
  34. package/dist/postcss-html-transform.mjs +1 -1
  35. package/dist/presets.js +5 -5
  36. package/dist/presets.mjs +2 -2
  37. package/dist/reset.d.mts +2 -1
  38. package/dist/reset.d.ts +2 -1
  39. package/dist/reset.js +25 -21
  40. package/dist/reset.mjs +25 -21
  41. package/dist/types.d.mts +503 -474
  42. package/dist/types.d.ts +503 -474
  43. package/dist/types.js +1 -1
  44. package/dist/types.mjs +1 -1
  45. package/dist/vite.js +7 -7
  46. package/dist/vite.mjs +6 -6
  47. package/dist/weapp-tw-css-import-rewrite-loader.js +2 -4
  48. package/dist/webpack.js +8 -8
  49. package/dist/webpack.mjs +7 -7
  50. package/dist/webpack4.js +351 -307
  51. package/dist/webpack4.mjs +341 -297
  52. package/package.json +10 -10
  53. package/dist/chunk-5AKI6FQP.mjs +0 -397
  54. package/dist/chunk-SNEMGP42.js +0 -394
package/dist/webpack4.js CHANGED
@@ -9,80 +9,388 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkDNRNFN4Ijs = require('./chunk-DNRNFN4I.js');
12
+ var _chunkKHBSYJ76js = require('./chunk-KHBSYJ76.js');
13
13
 
14
14
 
15
15
 
16
16
 
17
17
 
18
18
 
19
- var _chunk2WPTDMN3js = require('./chunk-2WPTDMN3.js');
19
+ var _chunkVPHA77FHjs = require('./chunk-VPHA77FH.js');
20
20
 
21
21
 
22
22
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
23
23
 
24
24
 
25
- var _chunkW3MTTQ5Mjs = require('./chunk-W3MTTQ5M.js');
25
+ var _chunkZQ7ET56Gjs = require('./chunk-ZQ7ET56G.js');
26
26
 
27
27
 
28
28
 
29
29
 
30
30
 
31
31
 
32
- var _chunkXXJNXESJjs = require('./chunk-XXJNXESJ.js');
33
- require('./chunk-5O6237HX.js');
32
+ var _chunkMVOIVNKLjs = require('./chunk-MVOIVNKL.js');
33
+ require('./chunk-4RUFPPI6.js');
34
34
  require('./chunk-FYYBY3VK.js');
35
35
 
36
36
 
37
37
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
38
- require('./chunk-UAEME5HT.js');
38
+ require('./chunk-Y6F6NBA7.js');
39
39
 
40
40
  // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
41
- var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
42
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
43
41
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
42
+
43
+ // src/bundlers/webpack/BaseUnifiedPlugin/v4-assets.ts
44
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
45
+
44
46
  var _webpacksources = require('webpack-sources');
45
- var debug = _chunkXXJNXESJjs.createDebug.call(void 0, );
46
- var weappTailwindcssPackageDir = _chunk2WPTDMN3js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
47
+ function setupWebpackV4EmitHook(options) {
48
+ const {
49
+ compiler,
50
+ options: compilerOptions,
51
+ appType,
52
+ runtimeState,
53
+ refreshRuntimeState,
54
+ debug: debug2
55
+ } = options;
56
+ compiler.hooks.emit.tapPromise(_chunkMVOIVNKLjs.pluginName, async (compilation) => {
57
+ await runtimeState.patchPromise;
58
+ compilerOptions.onStart();
59
+ debug2("start");
60
+ for (const chunk of compilation.chunks) {
61
+ if (chunk.id && chunk.hash) {
62
+ compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
63
+ }
64
+ }
65
+ const assets = compilation.assets;
66
+ const entries = Object.entries(assets);
67
+ const outputDir = _optionalChain([compiler, 'access', _ => _.options, 'optionalAccess', _2 => _2.output, 'optionalAccess', _3 => _3.path]) ? _path2.default.resolve(compiler.options.output.path) : _process2.default.cwd();
68
+ const jsAssets = /* @__PURE__ */ new Map();
69
+ for (const [file] of entries) {
70
+ if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
71
+ const absolute = _chunkVPHA77FHjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
72
+ jsAssets.set(absolute, file);
73
+ }
74
+ }
75
+ const moduleGraphOptions = {
76
+ resolve(specifier, importer) {
77
+ return _chunkVPHA77FHjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
78
+ },
79
+ load: (id) => {
80
+ const assetName = jsAssets.get(id);
81
+ if (!assetName) {
82
+ return void 0;
83
+ }
84
+ const assetSource = compilation.assets[assetName];
85
+ if (!assetSource) {
86
+ return void 0;
87
+ }
88
+ const source = assetSource.source();
89
+ return typeof source === "string" ? source : source.toString();
90
+ },
91
+ filter(id) {
92
+ return jsAssets.has(id);
93
+ }
94
+ };
95
+ const applyLinkedResults = (linked) => {
96
+ if (!linked) {
97
+ return;
98
+ }
99
+ for (const [id, { code }] of Object.entries(linked)) {
100
+ const assetName = jsAssets.get(id);
101
+ if (!assetName) {
102
+ continue;
103
+ }
104
+ const assetSource = compilation.assets[assetName];
105
+ if (!assetSource) {
106
+ continue;
107
+ }
108
+ const previousSource = assetSource.source();
109
+ const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
110
+ if (previous === code) {
111
+ continue;
112
+ }
113
+ const source = new (0, _webpacksources.ConcatSource)(code);
114
+ compilation.updateAsset(assetName, source);
115
+ compilerOptions.onUpdate(assetName, previous, code);
116
+ debug2("js linked handle: %s", assetName);
117
+ }
118
+ };
119
+ const groupedEntries = _chunkDYLQ6UOIjs.getGroupedEntries.call(void 0, entries, compilerOptions);
120
+ await refreshRuntimeState(true);
121
+ await runtimeState.patchPromise;
122
+ const runtimeSet = await _chunkMVOIVNKLjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
123
+ debug2("get runtimeSet, class count: %d", runtimeSet.size);
124
+ const tasks = [];
125
+ if (Array.isArray(groupedEntries.html)) {
126
+ for (const element of groupedEntries.html) {
127
+ const [file, originalSource] = element;
128
+ const rawSource = originalSource.source().toString();
129
+ const cacheKey = file;
130
+ tasks.push(
131
+ _chunkLTJQUORKjs.processCachedTask.call(void 0, {
132
+ cache: compilerOptions.cache,
133
+ cacheKey,
134
+ rawSource,
135
+ applyResult(source) {
136
+ compilation.updateAsset(file, source);
137
+ },
138
+ onCacheHit() {
139
+ debug2("html cache hit: %s", file);
140
+ },
141
+ transform: async () => {
142
+ const wxml = await compilerOptions.templateHandler(rawSource, {
143
+ runtimeSet
144
+ });
145
+ const source = new (0, _webpacksources.ConcatSource)(wxml);
146
+ compilerOptions.onUpdate(file, rawSource, wxml);
147
+ debug2("html handle: %s", file);
148
+ return {
149
+ result: source
150
+ };
151
+ }
152
+ })
153
+ );
154
+ }
155
+ }
156
+ const jsTaskFactories = [];
157
+ if (Array.isArray(groupedEntries.js)) {
158
+ for (const [file] of groupedEntries.js) {
159
+ const cacheKey = _chunkKHBSYJ76js.getCacheKey.call(void 0, file);
160
+ const assetSource = compilation.assets[file];
161
+ if (!assetSource) {
162
+ continue;
163
+ }
164
+ const initialValue = assetSource.source();
165
+ const initialRawSource = typeof initialValue === "string" ? initialValue : initialValue.toString();
166
+ const absoluteFile = _chunkVPHA77FHjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
167
+ jsTaskFactories.push(async () => {
168
+ await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
169
+ cache: compilerOptions.cache,
170
+ cacheKey,
171
+ rawSource: initialRawSource,
172
+ applyResult(source) {
173
+ compilation.updateAsset(file, source);
174
+ },
175
+ onCacheHit() {
176
+ debug2("js cache hit: %s", file);
177
+ },
178
+ transform: async () => {
179
+ const currentAsset = compilation.assets[file];
180
+ const currentValue = _optionalChain([currentAsset, 'optionalAccess', _4 => _4.source, 'call', _5 => _5()]);
181
+ const currentSource = typeof currentValue === "string" ? currentValue : _nullishCoalesce(_optionalChain([currentValue, 'optionalAccess', _6 => _6.toString, 'call', _7 => _7()]), () => ( ""));
182
+ const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, {
183
+ filename: absoluteFile,
184
+ moduleGraph: moduleGraphOptions,
185
+ babelParserOptions: {
186
+ sourceFilename: absoluteFile
187
+ }
188
+ });
189
+ const source = new (0, _webpacksources.ConcatSource)(code);
190
+ compilerOptions.onUpdate(file, currentSource, code);
191
+ debug2("js handle: %s", file);
192
+ applyLinkedResults(linked);
193
+ return {
194
+ result: source
195
+ };
196
+ }
197
+ });
198
+ });
199
+ }
200
+ }
201
+ if (Array.isArray(groupedEntries.css)) {
202
+ for (const element of groupedEntries.css) {
203
+ const [file, originalSource] = element;
204
+ const rawSource = originalSource.source().toString();
205
+ const cacheKey = file;
206
+ tasks.push(
207
+ _chunkLTJQUORKjs.processCachedTask.call(void 0, {
208
+ cache: compilerOptions.cache,
209
+ cacheKey,
210
+ rawSource,
211
+ applyResult(source) {
212
+ compilation.updateAsset(file, source);
213
+ },
214
+ onCacheHit() {
215
+ debug2("css cache hit: %s", file);
216
+ },
217
+ transform: async () => {
218
+ await runtimeState.patchPromise;
219
+ const { css } = await compilerOptions.styleHandler(rawSource, {
220
+ isMainChunk: compilerOptions.mainCssChunkMatcher(file, appType),
221
+ postcssOptions: {
222
+ options: {
223
+ from: file
224
+ }
225
+ },
226
+ majorVersion: runtimeState.twPatcher.majorVersion
227
+ });
228
+ const source = new (0, _webpacksources.ConcatSource)(css);
229
+ compilerOptions.onUpdate(file, rawSource, css);
230
+ debug2("css handle: %s", file);
231
+ return {
232
+ result: source
233
+ };
234
+ }
235
+ })
236
+ );
237
+ }
238
+ }
239
+ _chunkVPHA77FHjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
240
+ await Promise.all(tasks);
241
+ debug2("end");
242
+ compilerOptions.onEnd();
243
+ });
244
+ }
245
+
246
+ // src/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.ts
247
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
248
+
249
+
250
+ function setupWebpackV4Loaders(options) {
251
+ const {
252
+ compiler,
253
+ options: compilerOptions,
254
+ appType,
255
+ weappTailwindcssPackageDir: weappTailwindcssPackageDir2,
256
+ shouldRewriteCssImports,
257
+ runtimeLoaderPath,
258
+ runtimeCssImportRewriteLoaderPath,
259
+ getClassSetInLoader,
260
+ debug: debug2
261
+ } = options;
262
+ const isMpxApp = _chunkKHBSYJ76js.isMpx.call(void 0, appType);
263
+ if (shouldRewriteCssImports && isMpxApp) {
264
+ _chunkKHBSYJ76js.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
265
+ }
266
+ const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
267
+ const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
268
+ const runtimeClassSetLoaderExists = _fs2.default.existsSync(runtimeClassSetLoader);
269
+ const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? _fs2.default.existsSync(runtimeCssImportRewriteLoader) : false;
270
+ const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
271
+ pkgDir: weappTailwindcssPackageDir2,
272
+ appType
273
+ } : void 0;
274
+ const classSetLoaderOptions = {
275
+ getClassSet: getClassSetInLoader
276
+ };
277
+ const { findRewriteAnchor, findClassSetAnchor } = _chunkKHBSYJ76js.createLoaderAnchorFinders.call(void 0, appType);
278
+ const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
279
+ rewriteCssImports: runtimeLoaderRewriteOptions
280
+ } : void 0;
281
+ if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
282
+ _chunkKHBSYJ76js.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
283
+ }
284
+ const createRuntimeClassSetLoaderEntry = () => ({
285
+ loader: runtimeClassSetLoader,
286
+ options: classSetLoaderOptions,
287
+ ident: null,
288
+ type: null
289
+ });
290
+ const createCssImportRewriteLoaderEntry = () => {
291
+ if (!runtimeCssImportRewriteLoader) {
292
+ return null;
293
+ }
294
+ return {
295
+ loader: runtimeCssImportRewriteLoader,
296
+ options: cssImportRewriteLoaderOptions,
297
+ ident: null,
298
+ type: null
299
+ };
300
+ };
301
+ compiler.hooks.compilation.tap(_chunkMVOIVNKLjs.pluginName, (compilation) => {
302
+ compilation.hooks.normalModuleLoader.tap(_chunkMVOIVNKLjs.pluginName, (_loaderContext, module) => {
303
+ const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
304
+ if (!hasRuntimeLoader) {
305
+ return;
306
+ }
307
+ if (shouldRewriteCssImports && _chunkKHBSYJ76js.isMpx.call(void 0, appType) && typeof _loaderContext.resolve === "function") {
308
+ _chunkKHBSYJ76js.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, true);
309
+ }
310
+ const loaderEntries = module.loaders || [];
311
+ let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
312
+ const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
313
+ const isCssModule = _chunkKHBSYJ76js.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
314
+ if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
315
+ debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
316
+ }
317
+ if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) {
318
+ debug2("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
319
+ } else if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) {
320
+ debug2("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
321
+ }
322
+ if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) {
323
+ return;
324
+ }
325
+ const anchorlessInsert = (entry, position) => {
326
+ if (position === "after") {
327
+ loaderEntries.push(entry);
328
+ } else {
329
+ loaderEntries.unshift(entry);
330
+ }
331
+ };
332
+ if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
333
+ const existingIndex = loaderEntries.findIndex(
334
+ (entry) => _optionalChain([entry, 'access', _8 => _8.loader, 'optionalAccess', _9 => _9.includes, 'optionalCall', _10 => _10(runtimeCssImportRewriteLoader)])
335
+ );
336
+ const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
337
+ if (rewriteEntry) {
338
+ const anchorIndex = findRewriteAnchor(loaderEntries);
339
+ if (anchorIndex === -1) {
340
+ anchorlessInsert(rewriteEntry, "after");
341
+ } else {
342
+ loaderEntries.splice(anchorIndex + 1, 0, rewriteEntry);
343
+ }
344
+ rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
345
+ }
346
+ }
347
+ if (runtimeClassSetLoaderExists && !_chunkKHBSYJ76js.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
348
+ const anchorIndex = findClassSetAnchor(loaderEntries);
349
+ if (anchorIndex === -1) {
350
+ anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
351
+ } else {
352
+ const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
353
+ loaderEntries.splice(insertIndex, 0, createRuntimeClassSetLoaderEntry());
354
+ }
355
+ }
356
+ });
357
+ });
358
+ }
359
+
360
+ // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
361
+ var debug = _chunkMVOIVNKLjs.createDebug.call(void 0, );
362
+ var weappTailwindcssPackageDir = _chunkVPHA77FHjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
47
363
  var UnifiedWebpackPluginV4 = class {
48
364
  constructor(options = {}) {
49
- this.options = _chunkXXJNXESJjs.getCompilerContext.call(void 0, options);
365
+ this.options = _chunkMVOIVNKLjs.getCompilerContext.call(void 0, options);
50
366
  this.appType = this.options.appType;
51
367
  }
52
368
  apply(compiler) {
53
369
  compiler.options = compiler.options || {};
54
370
  const {
55
- mainCssChunkMatcher,
56
371
  disabled,
57
372
  onLoad,
58
- onUpdate,
59
- onEnd,
60
- onStart,
61
- styleHandler,
62
- templateHandler,
63
- jsHandler,
64
373
  runtimeLoaderPath,
65
374
  runtimeCssImportRewriteLoaderPath,
66
- cache,
67
375
  twPatcher: initialTwPatcher,
68
376
  refreshTailwindcssPatcher
69
377
  } = this.options;
70
- const disabledOptions = _chunk2WPTDMN3js.resolveDisabledOptions.call(void 0, disabled);
378
+ const disabledOptions = _chunkVPHA77FHjs.resolveDisabledOptions.call(void 0, disabled);
71
379
  const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
72
380
  const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
73
- const isMpxApp = _chunkDNRNFN4Ijs.isMpx.call(void 0, this.appType);
381
+ const isMpxApp = _chunkKHBSYJ76js.isMpx.call(void 0, this.appType);
74
382
  if (shouldRewriteCssImports) {
75
- _chunkDNRNFN4Ijs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
383
+ _chunkKHBSYJ76js.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
76
384
  pkgDir: weappTailwindcssPackageDir,
77
385
  enabled: true,
78
386
  appType: this.appType
79
387
  });
80
- _chunkDNRNFN4Ijs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
388
+ _chunkKHBSYJ76js.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
81
389
  }
82
390
  if (disabledOptions.plugin) {
83
391
  return;
84
392
  }
85
- const patchRecorderState = _chunkW3MTTQ5Mjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
393
+ const patchRecorderState = _chunkZQ7ET56Gjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
86
394
  source: "runtime",
87
395
  cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
88
396
  });
@@ -93,296 +401,32 @@ var UnifiedWebpackPluginV4 = class {
93
401
  onPatchCompleted: patchRecorderState.onPatchCompleted
94
402
  };
95
403
  const refreshRuntimeState = async (force) => {
96
- await _chunkXXJNXESJjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
404
+ await _chunkMVOIVNKLjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
97
405
  };
98
406
  async function getClassSetInLoader() {
99
407
  await refreshRuntimeState(true);
100
408
  await runtimeState.patchPromise;
101
- await _chunkXXJNXESJjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
409
+ await _chunkMVOIVNKLjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
102
410
  }
103
- const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
104
- const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
105
- const runtimeClassSetLoaderExists = _fs2.default.existsSync(runtimeClassSetLoader);
106
- const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? _fs2.default.existsSync(runtimeCssImportRewriteLoader) : false;
107
- const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
108
- pkgDir: weappTailwindcssPackageDir,
109
- appType: this.appType
110
- } : void 0;
111
- const classSetLoaderOptions = {
112
- getClassSet: getClassSetInLoader
113
- };
114
- const { findRewriteAnchor, findClassSetAnchor } = _chunkDNRNFN4Ijs.createLoaderAnchorFinders.call(void 0, this.appType);
115
- const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
116
- rewriteCssImports: runtimeLoaderRewriteOptions
117
- } : void 0;
118
411
  onLoad();
119
- if (shouldRewriteCssImports && isMpxApp) {
120
- _chunkDNRNFN4Ijs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
121
- }
122
- if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
123
- _chunkDNRNFN4Ijs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
124
- }
125
- const createRuntimeClassSetLoaderEntry = () => ({
126
- loader: runtimeClassSetLoader,
127
- options: classSetLoaderOptions,
128
- ident: null,
129
- type: null
130
- });
131
- const createCssImportRewriteLoaderEntry = () => {
132
- if (!runtimeCssImportRewriteLoader) {
133
- return null;
134
- }
135
- return {
136
- loader: runtimeCssImportRewriteLoader,
137
- options: cssImportRewriteLoaderOptions,
138
- ident: null,
139
- type: null
140
- };
141
- };
142
- compiler.hooks.compilation.tap(_chunkXXJNXESJjs.pluginName, (compilation) => {
143
- compilation.hooks.normalModuleLoader.tap(_chunkXXJNXESJjs.pluginName, (_loaderContext, module) => {
144
- const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
145
- if (!hasRuntimeLoader) {
146
- return;
147
- }
148
- if (shouldRewriteCssImports && _chunkDNRNFN4Ijs.isMpx.call(void 0, this.appType) && typeof _loaderContext.resolve === "function") {
149
- _chunkDNRNFN4Ijs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, true);
150
- }
151
- const loaderEntries = module.loaders || [];
152
- let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
153
- const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
154
- const isCssModule = _chunkDNRNFN4Ijs.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
155
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
156
- debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
157
- }
158
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) {
159
- debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
160
- } else if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) {
161
- debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
162
- }
163
- if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) {
164
- return;
165
- }
166
- const anchorlessInsert = (entry, position) => {
167
- if (position === "after") {
168
- loaderEntries.push(entry);
169
- } else {
170
- loaderEntries.unshift(entry);
171
- }
172
- };
173
- if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
174
- const existingIndex = loaderEntries.findIndex(
175
- (entry) => _optionalChain([entry, 'access', _ => _.loader, 'optionalAccess', _2 => _2.includes, 'optionalCall', _3 => _3(runtimeCssImportRewriteLoader)])
176
- );
177
- const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
178
- if (rewriteEntry) {
179
- const anchorIndex = findRewriteAnchor(loaderEntries);
180
- if (anchorIndex === -1) {
181
- anchorlessInsert(rewriteEntry, "after");
182
- } else {
183
- loaderEntries.splice(anchorIndex + 1, 0, rewriteEntry);
184
- }
185
- rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
186
- }
187
- }
188
- if (runtimeClassSetLoaderExists && !_chunkDNRNFN4Ijs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
189
- const anchorIndex = findClassSetAnchor(loaderEntries);
190
- if (anchorIndex === -1) {
191
- anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
192
- } else {
193
- const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
194
- loaderEntries.splice(insertIndex, 0, createRuntimeClassSetLoaderEntry());
195
- }
196
- }
197
- });
412
+ setupWebpackV4Loaders({
413
+ compiler,
414
+ options: this.options,
415
+ appType: this.appType,
416
+ weappTailwindcssPackageDir,
417
+ shouldRewriteCssImports,
418
+ runtimeLoaderPath,
419
+ runtimeCssImportRewriteLoaderPath,
420
+ getClassSetInLoader,
421
+ debug
198
422
  });
199
- compiler.hooks.emit.tapPromise(_chunkXXJNXESJjs.pluginName, async (compilation) => {
200
- await runtimeState.patchPromise;
201
- onStart();
202
- debug("start");
203
- for (const chunk of compilation.chunks) {
204
- if (chunk.id && chunk.hash) {
205
- cache.calcHashValueChanged(chunk.id, chunk.hash);
206
- }
207
- }
208
- const assets = compilation.assets;
209
- const entries = Object.entries(assets);
210
- const outputDir = _optionalChain([compiler, 'access', _4 => _4.options, 'optionalAccess', _5 => _5.output, 'optionalAccess', _6 => _6.path]) ? _path2.default.resolve(compiler.options.output.path) : _process2.default.cwd();
211
- const jsAssets = /* @__PURE__ */ new Map();
212
- for (const [file] of entries) {
213
- if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
214
- const absolute = _chunk2WPTDMN3js.toAbsoluteOutputPath.call(void 0, file, outputDir);
215
- jsAssets.set(absolute, file);
216
- }
217
- }
218
- const moduleGraphOptions = {
219
- resolve(specifier, importer) {
220
- return _chunk2WPTDMN3js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
221
- },
222
- load: (id) => {
223
- const assetName = jsAssets.get(id);
224
- if (!assetName) {
225
- return void 0;
226
- }
227
- const assetSource = compilation.assets[assetName];
228
- if (!assetSource) {
229
- return void 0;
230
- }
231
- const source = assetSource.source();
232
- return typeof source === "string" ? source : source.toString();
233
- },
234
- filter(id) {
235
- return jsAssets.has(id);
236
- }
237
- };
238
- const applyLinkedResults = (linked) => {
239
- if (!linked) {
240
- return;
241
- }
242
- for (const [id, { code }] of Object.entries(linked)) {
243
- const assetName = jsAssets.get(id);
244
- if (!assetName) {
245
- continue;
246
- }
247
- const assetSource = compilation.assets[assetName];
248
- if (!assetSource) {
249
- continue;
250
- }
251
- const previousSource = assetSource.source();
252
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
253
- if (previous === code) {
254
- continue;
255
- }
256
- const source = new (0, _webpacksources.ConcatSource)(code);
257
- compilation.updateAsset(assetName, source);
258
- onUpdate(assetName, previous, code);
259
- debug("js linked handle: %s", assetName);
260
- }
261
- };
262
- const groupedEntries = _chunkDYLQ6UOIjs.getGroupedEntries.call(void 0, entries, this.options);
263
- await refreshRuntimeState(true);
264
- await runtimeState.patchPromise;
265
- const runtimeSet = await _chunkXXJNXESJjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
266
- debug("get runtimeSet, class count: %d", runtimeSet.size);
267
- const tasks = [];
268
- if (Array.isArray(groupedEntries.html)) {
269
- for (const element of groupedEntries.html) {
270
- const [file, originalSource] = element;
271
- const rawSource = originalSource.source().toString();
272
- const cacheKey = file;
273
- tasks.push(
274
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
275
- cache,
276
- cacheKey,
277
- rawSource,
278
- applyResult(source) {
279
- compilation.updateAsset(file, source);
280
- },
281
- onCacheHit() {
282
- debug("html cache hit: %s", file);
283
- },
284
- transform: async () => {
285
- const wxml = await templateHandler(rawSource, {
286
- runtimeSet
287
- });
288
- const source = new (0, _webpacksources.ConcatSource)(wxml);
289
- onUpdate(file, rawSource, wxml);
290
- debug("html handle: %s", file);
291
- return {
292
- result: source
293
- };
294
- }
295
- })
296
- );
297
- }
298
- }
299
- const jsTaskFactories = [];
300
- if (Array.isArray(groupedEntries.js)) {
301
- for (const [file] of groupedEntries.js) {
302
- const cacheKey = _chunkDNRNFN4Ijs.getCacheKey.call(void 0, file);
303
- const assetSource = compilation.assets[file];
304
- if (!assetSource) {
305
- continue;
306
- }
307
- const initialValue = assetSource.source();
308
- const initialRawSource = typeof initialValue === "string" ? initialValue : initialValue.toString();
309
- const absoluteFile = _chunk2WPTDMN3js.toAbsoluteOutputPath.call(void 0, file, outputDir);
310
- jsTaskFactories.push(async () => {
311
- await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
312
- cache,
313
- cacheKey,
314
- rawSource: initialRawSource,
315
- applyResult(source) {
316
- compilation.updateAsset(file, source);
317
- },
318
- onCacheHit() {
319
- debug("js cache hit: %s", file);
320
- },
321
- transform: async () => {
322
- const currentAsset = compilation.assets[file];
323
- const currentValue = _optionalChain([currentAsset, 'optionalAccess', _7 => _7.source, 'call', _8 => _8()]);
324
- const currentSource = typeof currentValue === "string" ? currentValue : _nullishCoalesce(_optionalChain([currentValue, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]), () => ( ""));
325
- const { code, linked } = await jsHandler(currentSource, runtimeSet, {
326
- filename: absoluteFile,
327
- moduleGraph: moduleGraphOptions,
328
- babelParserOptions: {
329
- sourceFilename: absoluteFile
330
- }
331
- });
332
- const source = new (0, _webpacksources.ConcatSource)(code);
333
- onUpdate(file, currentSource, code);
334
- debug("js handle: %s", file);
335
- applyLinkedResults(linked);
336
- return {
337
- result: source
338
- };
339
- }
340
- });
341
- });
342
- }
343
- }
344
- if (Array.isArray(groupedEntries.css)) {
345
- for (const element of groupedEntries.css) {
346
- const [file, originalSource] = element;
347
- const rawSource = originalSource.source().toString();
348
- const cacheKey = file;
349
- tasks.push(
350
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
351
- cache,
352
- cacheKey,
353
- rawSource,
354
- applyResult(source) {
355
- compilation.updateAsset(file, source);
356
- },
357
- onCacheHit() {
358
- debug("css cache hit: %s", file);
359
- },
360
- transform: async () => {
361
- await runtimeState.patchPromise;
362
- const { css } = await styleHandler(rawSource, {
363
- isMainChunk: mainCssChunkMatcher(file, this.appType),
364
- postcssOptions: {
365
- options: {
366
- from: file
367
- }
368
- },
369
- majorVersion: runtimeState.twPatcher.majorVersion
370
- });
371
- const source = new (0, _webpacksources.ConcatSource)(css);
372
- onUpdate(file, rawSource, css);
373
- debug("css handle: %s", file);
374
- return {
375
- result: source
376
- };
377
- }
378
- })
379
- );
380
- }
381
- }
382
- _chunk2WPTDMN3js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
383
- await Promise.all(tasks);
384
- debug("end");
385
- onEnd();
423
+ setupWebpackV4EmitHook({
424
+ compiler,
425
+ options: this.options,
426
+ appType: this.appType,
427
+ runtimeState,
428
+ refreshRuntimeState,
429
+ debug
386
430
  });
387
431
  }
388
432
  };