weapp-tailwindcss 4.12.0-next.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/bin/weapp-tailwindcss.js +21 -1
  2. package/dist/{chunk-GMKSBLNY.js → chunk-24AGZQVR.js} +15 -7
  3. package/dist/{chunk-F2CKKG6Q.mjs → chunk-3VQKDHGP.mjs} +12 -4
  4. package/dist/{chunk-F5XJWJYO.mjs → chunk-57SOQCAU.mjs} +5 -5
  5. package/dist/{chunk-GD4SQMVF.mjs → chunk-5ZYHNDEK.mjs} +98 -37
  6. package/dist/{chunk-FMK6SFQQ.js → chunk-DUHYLR2R.js} +7 -7
  7. package/dist/{chunk-OYSABARD.js → chunk-E7I5TW5K.js} +3 -2
  8. package/dist/{chunk-WSS26HZS.js → chunk-FS2NOOEB.js} +5 -5
  9. package/dist/{chunk-GC7WXUOW.js → chunk-HVNGIKLS.js} +55 -31
  10. package/dist/{chunk-LVSUBDJC.js → chunk-JZQBZHN5.js} +39 -39
  11. package/dist/{chunk-QNRJCEZN.mjs → chunk-KGTVD4EP.mjs} +66 -42
  12. package/dist/{chunk-HL3US2OT.mjs → chunk-NNOQDMUP.mjs} +1 -1
  13. package/dist/{chunk-5ONE75V7.js → chunk-OFB2KBRP.js} +175 -114
  14. package/dist/{chunk-AYJ4HLWZ.mjs → chunk-PCDYXXSK.mjs} +11 -4
  15. package/dist/{chunk-ONLKZIRQ.js → chunk-RKISS72P.js} +1 -1
  16. package/dist/{chunk-ZR3KN3FG.mjs → chunk-RRQZL7FQ.mjs} +2 -2
  17. package/dist/{chunk-UUJWDME4.mjs → chunk-XZP3MREK.mjs} +1 -1
  18. package/dist/{chunk-NIS74SI6.js → chunk-ZAA5ZG3D.js} +60 -53
  19. package/dist/{chunk-2LH6PZH3.mjs → chunk-ZCH4YINE.mjs} +3 -2
  20. package/dist/cli.js +2241 -169
  21. package/dist/cli.mjs +2246 -174
  22. package/dist/core.js +9 -9
  23. package/dist/core.mjs +3 -3
  24. package/dist/css-macro/postcss.js +4 -4
  25. package/dist/css-macro/postcss.mjs +2 -2
  26. package/dist/css-macro.js +5 -5
  27. package/dist/css-macro.mjs +2 -2
  28. package/dist/defaults.js +1 -1
  29. package/dist/defaults.mjs +1 -1
  30. package/dist/gulp.js +5 -5
  31. package/dist/gulp.mjs +4 -4
  32. package/dist/index.js +9 -9
  33. package/dist/index.mjs +8 -8
  34. package/dist/postcss-html-transform.js +1 -1
  35. package/dist/postcss-html-transform.mjs +1 -1
  36. package/dist/presets.js +6 -6
  37. package/dist/presets.mjs +2 -2
  38. package/dist/reset.js +1 -1
  39. package/dist/reset.mjs +1 -1
  40. package/dist/types.js +1 -1
  41. package/dist/types.mjs +1 -1
  42. package/dist/vite.js +6 -6
  43. package/dist/vite.mjs +5 -5
  44. package/dist/weapp-tw-css-import-rewrite-loader.js +10 -5
  45. package/dist/weapp-tw-runtime-classset-loader.js +9 -4
  46. package/dist/webpack.js +7 -7
  47. package/dist/webpack.mjs +6 -6
  48. package/dist/webpack4.js +59 -55
  49. package/dist/webpack4.mjs +28 -24
  50. package/package.json +11 -10
  51. package/scripts/postinstall.mjs +59 -0
package/dist/webpack4.js CHANGED
@@ -10,14 +10,14 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkWSS26HZSjs = require('./chunk-WSS26HZS.js');
13
+ var _chunkFS2NOOEBjs = require('./chunk-FS2NOOEB.js');
14
14
 
15
15
 
16
16
 
17
17
 
18
18
 
19
19
 
20
- var _chunkGMKSBLNYjs = require('./chunk-GMKSBLNY.js');
20
+ var _chunk24AGZQVRjs = require('./chunk-24AGZQVR.js');
21
21
 
22
22
 
23
23
  var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
@@ -28,15 +28,15 @@ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
28
28
 
29
29
 
30
30
 
31
- var _chunkGC7WXUOWjs = require('./chunk-GC7WXUOW.js');
31
+ var _chunkHVNGIKLSjs = require('./chunk-HVNGIKLS.js');
32
32
 
33
33
 
34
- var _chunkNIS74SI6js = require('./chunk-NIS74SI6.js');
34
+ var _chunkZAA5ZG3Djs = require('./chunk-ZAA5ZG3D.js');
35
35
  require('./chunk-A5PB4KZT.js');
36
36
 
37
37
 
38
38
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
39
- require('./chunk-ONLKZIRQ.js');
39
+ require('./chunk-RKISS72P.js');
40
40
 
41
41
  // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
42
42
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
@@ -51,6 +51,13 @@ function resolveWebpackStaleClassNameFallback(option, _compiler) {
51
51
  }
52
52
  return false;
53
53
  }
54
+ function toWebpackV4AssetCompilation(compilation) {
55
+ return compilation;
56
+ }
57
+ function readWebpackV4AssetSource(asset) {
58
+ const source = asset.source();
59
+ return typeof source === "string" ? source : source.toString();
60
+ }
54
61
  function setupWebpackV4EmitHook(options) {
55
62
  const {
56
63
  compiler,
@@ -60,7 +67,7 @@ function setupWebpackV4EmitHook(options) {
60
67
  debug: debug2
61
68
  } = options;
62
69
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
63
- compiler.hooks.emit.tapPromise(_chunkGC7WXUOWjs.pluginName, async (compilation) => {
70
+ compiler.hooks.emit.tapPromise(_chunkHVNGIKLSjs.pluginName, async (compilation) => {
64
71
  await runtimeState.patchPromise;
65
72
  compilerOptions.onStart();
66
73
  debug2("start");
@@ -69,32 +76,32 @@ function setupWebpackV4EmitHook(options) {
69
76
  compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
70
77
  }
71
78
  }
72
- const assetHashByChunk = _chunkWSS26HZSjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
73
- const assets = compilation.assets;
79
+ const assetCompilation = toWebpackV4AssetCompilation(compilation);
80
+ const assetHashByChunk = _chunkFS2NOOEBjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
81
+ const assets = assetCompilation.assets;
74
82
  const entries = Object.entries(assets);
75
83
  const outputDir = _optionalChain([compiler, 'access', _ => _.options, 'optionalAccess', _2 => _2.output, 'optionalAccess', _3 => _3.path]) ? _path2.default.resolve(compiler.options.output.path) : _process2.default.cwd();
76
84
  const jsAssets = /* @__PURE__ */ new Map();
77
85
  for (const [file] of entries) {
78
86
  if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
79
- const absolute = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
87
+ const absolute = _chunk24AGZQVRjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
80
88
  jsAssets.set(absolute, file);
81
89
  }
82
90
  }
83
91
  const moduleGraphOptions = {
84
92
  resolve(specifier, importer) {
85
- return _chunkGMKSBLNYjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
93
+ return _chunk24AGZQVRjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
86
94
  },
87
95
  load: (id) => {
88
96
  const assetName = jsAssets.get(id);
89
97
  if (!assetName) {
90
98
  return void 0;
91
99
  }
92
- const assetSource = compilation.assets[assetName];
100
+ const assetSource = assetCompilation.assets[assetName];
93
101
  if (!assetSource) {
94
102
  return void 0;
95
103
  }
96
- const source = assetSource.source();
97
- return typeof source === "string" ? source : source.toString();
104
+ return readWebpackV4AssetSource(assetSource);
98
105
  },
99
106
  filter(id) {
100
107
  return jsAssets.has(id);
@@ -109,17 +116,16 @@ function setupWebpackV4EmitHook(options) {
109
116
  if (!assetName) {
110
117
  continue;
111
118
  }
112
- const assetSource = compilation.assets[assetName];
119
+ const assetSource = assetCompilation.assets[assetName];
113
120
  if (!assetSource) {
114
121
  continue;
115
122
  }
116
- const previousSource = assetSource.source();
117
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
123
+ const previous = readWebpackV4AssetSource(assetSource);
118
124
  if (previous === code) {
119
125
  continue;
120
126
  }
121
127
  const source = new (0, _webpacksources.ConcatSource)(code);
122
- compilation.updateAsset(assetName, source);
128
+ assetCompilation.updateAsset(assetName, source);
123
129
  compilerOptions.onUpdate(assetName, previous, code);
124
130
  debug2("js linked handle: %s", assetName);
125
131
  }
@@ -146,7 +152,7 @@ function setupWebpackV4EmitHook(options) {
146
152
  return created;
147
153
  };
148
154
  const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
149
- const runtimeSet = await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
155
+ const runtimeSet = await _chunkHVNGIKLSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
150
156
  // webpack 的 script-only 热更新可能不会触发 runtime classset loader,
151
157
  // 这里强制收集可避免沿用上轮 class set,保证 JS 仅按最新集合精确命中。
152
158
  forceCollect: true,
@@ -160,7 +166,7 @@ function setupWebpackV4EmitHook(options) {
160
166
  if (Array.isArray(groupedEntries.html)) {
161
167
  for (const element of groupedEntries.html) {
162
168
  const [file, originalSource] = element;
163
- const rawSource = originalSource.source().toString();
169
+ const rawSource = readWebpackV4AssetSource(originalSource);
164
170
  const cacheKey = file;
165
171
  const chunkHash = assetHashByChunk.get(file);
166
172
  tasks.push(
@@ -171,7 +177,7 @@ function setupWebpackV4EmitHook(options) {
171
177
  rawSource,
172
178
  hash: chunkHash,
173
179
  applyResult(source) {
174
- compilation.updateAsset(file, source);
180
+ assetCompilation.updateAsset(file, source);
175
181
  },
176
182
  onCacheHit() {
177
183
  debug2("html cache hit: %s", file);
@@ -192,14 +198,13 @@ function setupWebpackV4EmitHook(options) {
192
198
  const jsTaskFactories = [];
193
199
  if (Array.isArray(groupedEntries.js)) {
194
200
  for (const [file] of groupedEntries.js) {
195
- const cacheKey = _chunkWSS26HZSjs.getCacheKey.call(void 0, file);
196
- const assetSource = compilation.assets[file];
201
+ const cacheKey = _chunkFS2NOOEBjs.getCacheKey.call(void 0, file);
202
+ const assetSource = assetCompilation.assets[file];
197
203
  if (!assetSource) {
198
204
  continue;
199
205
  }
200
- const initialValue = assetSource.source();
201
- const initialRawSource = typeof initialValue === "string" ? initialValue : initialValue.toString();
202
- const absoluteFile = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
206
+ const initialRawSource = readWebpackV4AssetSource(assetSource);
207
+ const absoluteFile = _chunk24AGZQVRjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
203
208
  const chunkHash = assetHashByChunk.get(file);
204
209
  const sourceAwareHash = chunkHash ? `${chunkHash}:${compilerOptions.cache.computeHash(initialRawSource)}` : void 0;
205
210
  jsTaskFactories.push(async () => {
@@ -210,15 +215,14 @@ function setupWebpackV4EmitHook(options) {
210
215
  rawSource: initialRawSource,
211
216
  hash: sourceAwareHash,
212
217
  applyResult(source) {
213
- compilation.updateAsset(file, source);
218
+ assetCompilation.updateAsset(file, source);
214
219
  },
215
220
  onCacheHit() {
216
221
  debug2("js cache hit: %s", file);
217
222
  },
218
223
  transform: async () => {
219
- const currentAsset = compilation.assets[file];
220
- const currentValue = _optionalChain([currentAsset, 'optionalAccess', _4 => _4.source, 'call', _5 => _5()]);
221
- const currentSource = typeof currentValue === "string" ? currentValue : _nullishCoalesce(_optionalChain([currentValue, 'optionalAccess', _6 => _6.toString, 'call', _7 => _7()]), () => ( ""));
224
+ const currentAsset = assetCompilation.assets[file];
225
+ const currentSource = currentAsset ? readWebpackV4AssetSource(currentAsset) : "";
222
226
  const handlerOptions = {
223
227
  staleClassNameFallback,
224
228
  tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
@@ -228,7 +232,7 @@ function setupWebpackV4EmitHook(options) {
228
232
  sourceFilename: absoluteFile
229
233
  }
230
234
  };
231
- if (_chunkGC7WXUOWjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
235
+ if (_chunkHVNGIKLSjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
232
236
  return { result: new (0, _webpacksources.ConcatSource)(currentSource) };
233
237
  }
234
238
  const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
@@ -247,7 +251,7 @@ function setupWebpackV4EmitHook(options) {
247
251
  if (Array.isArray(groupedEntries.css)) {
248
252
  for (const element of groupedEntries.css) {
249
253
  const [file, originalSource] = element;
250
- const rawSource = originalSource.source().toString();
254
+ const rawSource = readWebpackV4AssetSource(originalSource);
251
255
  const cacheKey = file;
252
256
  const chunkHash = assetHashByChunk.get(file);
253
257
  tasks.push(
@@ -258,7 +262,7 @@ function setupWebpackV4EmitHook(options) {
258
262
  rawSource,
259
263
  hash: chunkHash,
260
264
  applyResult(source) {
261
- compilation.updateAsset(file, source);
265
+ assetCompilation.updateAsset(file, source);
262
266
  },
263
267
  onCacheHit() {
264
268
  debug2("css cache hit: %s", file);
@@ -277,7 +281,7 @@ function setupWebpackV4EmitHook(options) {
277
281
  );
278
282
  }
279
283
  }
280
- _chunkGMKSBLNYjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
284
+ _chunk24AGZQVRjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
281
285
  await Promise.all(tasks);
282
286
  debug2("end");
283
287
  compilerOptions.onEnd();
@@ -300,9 +304,9 @@ function setupWebpackV4Loaders(options) {
300
304
  getClassSetInLoader,
301
305
  debug: debug2
302
306
  } = options;
303
- const isMpxApp = _chunkWSS26HZSjs.isMpx.call(void 0, appType);
307
+ const isMpxApp = _chunkFS2NOOEBjs.isMpx.call(void 0, appType);
304
308
  if (shouldRewriteCssImports && isMpxApp) {
305
- _chunkWSS26HZSjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
309
+ _chunkFS2NOOEBjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
306
310
  }
307
311
  const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
308
312
  const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
@@ -315,12 +319,12 @@ function setupWebpackV4Loaders(options) {
315
319
  const classSetLoaderOptions = {
316
320
  getClassSet: getClassSetInLoader
317
321
  };
318
- const { findRewriteAnchor, findClassSetAnchor } = _chunkWSS26HZSjs.createLoaderAnchorFinders.call(void 0, appType);
322
+ const { findRewriteAnchor, findClassSetAnchor } = _chunkFS2NOOEBjs.createLoaderAnchorFinders.call(void 0, appType);
319
323
  const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
320
324
  rewriteCssImports: runtimeLoaderRewriteOptions
321
325
  } : void 0;
322
326
  if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
323
- _chunkWSS26HZSjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
327
+ _chunkFS2NOOEBjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
324
328
  }
325
329
  const createRuntimeClassSetLoaderEntry = () => ({
326
330
  loader: runtimeClassSetLoader,
@@ -339,19 +343,19 @@ function setupWebpackV4Loaders(options) {
339
343
  type: null
340
344
  };
341
345
  };
342
- compiler.hooks.compilation.tap(_chunkGC7WXUOWjs.pluginName, (compilation) => {
343
- compilation.hooks.normalModuleLoader.tap(_chunkGC7WXUOWjs.pluginName, (_loaderContext, module) => {
346
+ compiler.hooks.compilation.tap(_chunkHVNGIKLSjs.pluginName, (compilation) => {
347
+ compilation.hooks.normalModuleLoader.tap(_chunkHVNGIKLSjs.pluginName, (_loaderContext, module) => {
344
348
  const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
345
349
  if (!hasRuntimeLoader) {
346
350
  return;
347
351
  }
348
- if (shouldRewriteCssImports && _chunkWSS26HZSjs.isMpx.call(void 0, appType) && typeof _loaderContext.resolve === "function") {
349
- _chunkWSS26HZSjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, true);
352
+ if (shouldRewriteCssImports && _chunkFS2NOOEBjs.isMpx.call(void 0, appType) && typeof _loaderContext.resolve === "function") {
353
+ _chunkFS2NOOEBjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, true);
350
354
  }
351
355
  const loaderEntries = module.loaders || [];
352
356
  let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
353
357
  const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
354
- const isCssModule = _chunkWSS26HZSjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
358
+ const isCssModule = _chunkFS2NOOEBjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
355
359
  if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
356
360
  debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
357
361
  }
@@ -372,7 +376,7 @@ function setupWebpackV4Loaders(options) {
372
376
  };
373
377
  if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
374
378
  const existingIndex = loaderEntries.findIndex(
375
- (entry) => _optionalChain([entry, 'access', _8 => _8.loader, 'optionalAccess', _9 => _9.includes, 'optionalCall', _10 => _10(runtimeCssImportRewriteLoader)])
379
+ (entry) => _optionalChain([entry, 'access', _4 => _4.loader, 'optionalAccess', _5 => _5.includes, 'optionalCall', _6 => _6(runtimeCssImportRewriteLoader)])
376
380
  );
377
381
  const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
378
382
  if (rewriteEntry) {
@@ -385,7 +389,7 @@ function setupWebpackV4Loaders(options) {
385
389
  rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
386
390
  }
387
391
  }
388
- if (runtimeClassSetLoaderExists && !_chunkWSS26HZSjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
392
+ if (runtimeClassSetLoaderExists && !_chunkFS2NOOEBjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
389
393
  const anchorIndex = findClassSetAnchor(loaderEntries);
390
394
  if (anchorIndex === -1) {
391
395
  anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
@@ -399,11 +403,11 @@ function setupWebpackV4Loaders(options) {
399
403
  }
400
404
 
401
405
  // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
402
- var debug = _chunkGC7WXUOWjs.createDebug.call(void 0, );
403
- var weappTailwindcssPackageDir = _chunkGMKSBLNYjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
406
+ var debug = _chunkHVNGIKLSjs.createDebug.call(void 0, );
407
+ var weappTailwindcssPackageDir = _chunk24AGZQVRjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
404
408
  var UnifiedWebpackPluginV4 = class {
405
409
  constructor(options = {}) {
406
- this.options = _chunkGC7WXUOWjs.getCompilerContext.call(void 0, options);
410
+ this.options = _chunkHVNGIKLSjs.getCompilerContext.call(void 0, options);
407
411
  this.appType = this.options.appType;
408
412
  }
409
413
  apply(compiler) {
@@ -416,22 +420,22 @@ var UnifiedWebpackPluginV4 = class {
416
420
  twPatcher: initialTwPatcher,
417
421
  refreshTailwindcssPatcher
418
422
  } = this.options;
419
- const disabledOptions = _chunkGMKSBLNYjs.resolveDisabledOptions.call(void 0, disabled);
423
+ const disabledOptions = _chunk24AGZQVRjs.resolveDisabledOptions.call(void 0, disabled);
420
424
  const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
421
425
  const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
422
- const isMpxApp = _chunkWSS26HZSjs.isMpx.call(void 0, this.appType);
426
+ const isMpxApp = _chunkFS2NOOEBjs.isMpx.call(void 0, this.appType);
423
427
  if (shouldRewriteCssImports) {
424
- _chunkWSS26HZSjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
428
+ _chunkFS2NOOEBjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
425
429
  pkgDir: weappTailwindcssPackageDir,
426
430
  enabled: true,
427
431
  appType: this.appType
428
432
  });
429
- _chunkWSS26HZSjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
433
+ _chunkFS2NOOEBjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
430
434
  }
431
435
  if (disabledOptions.plugin) {
432
436
  return;
433
437
  }
434
- const patchRecorderState = _chunkGC7WXUOWjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
438
+ const patchRecorderState = _chunkHVNGIKLSjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
435
439
  source: "runtime",
436
440
  cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
437
441
  });
@@ -443,17 +447,17 @@ var UnifiedWebpackPluginV4 = class {
443
447
  };
444
448
  let runtimeSetPrepared = false;
445
449
  let runtimeSetSignature;
446
- compiler.hooks.compilation.tap(_chunkGC7WXUOWjs.pluginName, () => {
450
+ compiler.hooks.compilation.tap(_chunkHVNGIKLSjs.pluginName, () => {
447
451
  runtimeSetPrepared = false;
448
452
  });
449
453
  async function getClassSetInLoader() {
450
454
  if (runtimeSetPrepared) {
451
455
  return;
452
456
  }
453
- const signature = _chunkNIS74SI6js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
457
+ const signature = _chunkZAA5ZG3Djs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
454
458
  const forceRefresh = signature !== runtimeSetSignature;
455
459
  runtimeSetPrepared = true;
456
- await _chunkGC7WXUOWjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
460
+ await _chunkHVNGIKLSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
457
461
  forceRefresh,
458
462
  forceCollect: true,
459
463
  clearCache: forceRefresh,
package/dist/webpack4.mjs CHANGED
@@ -10,14 +10,14 @@ import {
10
10
  isMpx,
11
11
  patchMpxLoaderResolve,
12
12
  setupMpxTailwindcssRedirect
13
- } from "./chunk-ZR3KN3FG.mjs";
13
+ } from "./chunk-RRQZL7FQ.mjs";
14
14
  import {
15
15
  pushConcurrentTaskFactories,
16
16
  resolveDisabledOptions,
17
17
  resolveOutputSpecifier,
18
18
  resolvePackageDir,
19
19
  toAbsoluteOutputPath
20
- } from "./chunk-F2CKKG6Q.mjs";
20
+ } from "./chunk-3VQKDHGP.mjs";
21
21
  import {
22
22
  processCachedTask
23
23
  } from "./chunk-76S2EME4.mjs";
@@ -28,17 +28,17 @@ import {
28
28
  pluginName,
29
29
  setupPatchRecorder,
30
30
  shouldSkipJsTransform
31
- } from "./chunk-QNRJCEZN.mjs";
31
+ } from "./chunk-KGTVD4EP.mjs";
32
32
  import {
33
33
  getRuntimeClassSetSignature
34
- } from "./chunk-AYJ4HLWZ.mjs";
34
+ } from "./chunk-PCDYXXSK.mjs";
35
35
  import "./chunk-XAKAD2CR.mjs";
36
36
  import {
37
37
  getGroupedEntries
38
38
  } from "./chunk-OOHJLO5M.mjs";
39
39
  import {
40
40
  __dirname
41
- } from "./chunk-HL3US2OT.mjs";
41
+ } from "./chunk-NNOQDMUP.mjs";
42
42
 
43
43
  // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
44
44
  import process3 from "process";
@@ -53,6 +53,13 @@ function resolveWebpackStaleClassNameFallback(option, _compiler) {
53
53
  }
54
54
  return false;
55
55
  }
56
+ function toWebpackV4AssetCompilation(compilation) {
57
+ return compilation;
58
+ }
59
+ function readWebpackV4AssetSource(asset) {
60
+ const source = asset.source();
61
+ return typeof source === "string" ? source : source.toString();
62
+ }
56
63
  function setupWebpackV4EmitHook(options) {
57
64
  const {
58
65
  compiler,
@@ -71,8 +78,9 @@ function setupWebpackV4EmitHook(options) {
71
78
  compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
72
79
  }
73
80
  }
81
+ const assetCompilation = toWebpackV4AssetCompilation(compilation);
74
82
  const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
75
- const assets = compilation.assets;
83
+ const assets = assetCompilation.assets;
76
84
  const entries = Object.entries(assets);
77
85
  const outputDir = compiler.options?.output?.path ? path.resolve(compiler.options.output.path) : process.cwd();
78
86
  const jsAssets = /* @__PURE__ */ new Map();
@@ -91,12 +99,11 @@ function setupWebpackV4EmitHook(options) {
91
99
  if (!assetName) {
92
100
  return void 0;
93
101
  }
94
- const assetSource = compilation.assets[assetName];
102
+ const assetSource = assetCompilation.assets[assetName];
95
103
  if (!assetSource) {
96
104
  return void 0;
97
105
  }
98
- const source = assetSource.source();
99
- return typeof source === "string" ? source : source.toString();
106
+ return readWebpackV4AssetSource(assetSource);
100
107
  },
101
108
  filter(id) {
102
109
  return jsAssets.has(id);
@@ -111,17 +118,16 @@ function setupWebpackV4EmitHook(options) {
111
118
  if (!assetName) {
112
119
  continue;
113
120
  }
114
- const assetSource = compilation.assets[assetName];
121
+ const assetSource = assetCompilation.assets[assetName];
115
122
  if (!assetSource) {
116
123
  continue;
117
124
  }
118
- const previousSource = assetSource.source();
119
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
125
+ const previous = readWebpackV4AssetSource(assetSource);
120
126
  if (previous === code) {
121
127
  continue;
122
128
  }
123
129
  const source = new ConcatSource(code);
124
- compilation.updateAsset(assetName, source);
130
+ assetCompilation.updateAsset(assetName, source);
125
131
  compilerOptions.onUpdate(assetName, previous, code);
126
132
  debug2("js linked handle: %s", assetName);
127
133
  }
@@ -162,7 +168,7 @@ function setupWebpackV4EmitHook(options) {
162
168
  if (Array.isArray(groupedEntries.html)) {
163
169
  for (const element of groupedEntries.html) {
164
170
  const [file, originalSource] = element;
165
- const rawSource = originalSource.source().toString();
171
+ const rawSource = readWebpackV4AssetSource(originalSource);
166
172
  const cacheKey = file;
167
173
  const chunkHash = assetHashByChunk.get(file);
168
174
  tasks.push(
@@ -173,7 +179,7 @@ function setupWebpackV4EmitHook(options) {
173
179
  rawSource,
174
180
  hash: chunkHash,
175
181
  applyResult(source) {
176
- compilation.updateAsset(file, source);
182
+ assetCompilation.updateAsset(file, source);
177
183
  },
178
184
  onCacheHit() {
179
185
  debug2("html cache hit: %s", file);
@@ -195,12 +201,11 @@ function setupWebpackV4EmitHook(options) {
195
201
  if (Array.isArray(groupedEntries.js)) {
196
202
  for (const [file] of groupedEntries.js) {
197
203
  const cacheKey = getCacheKey(file);
198
- const assetSource = compilation.assets[file];
204
+ const assetSource = assetCompilation.assets[file];
199
205
  if (!assetSource) {
200
206
  continue;
201
207
  }
202
- const initialValue = assetSource.source();
203
- const initialRawSource = typeof initialValue === "string" ? initialValue : initialValue.toString();
208
+ const initialRawSource = readWebpackV4AssetSource(assetSource);
204
209
  const absoluteFile = toAbsoluteOutputPath(file, outputDir);
205
210
  const chunkHash = assetHashByChunk.get(file);
206
211
  const sourceAwareHash = chunkHash ? `${chunkHash}:${compilerOptions.cache.computeHash(initialRawSource)}` : void 0;
@@ -212,15 +217,14 @@ function setupWebpackV4EmitHook(options) {
212
217
  rawSource: initialRawSource,
213
218
  hash: sourceAwareHash,
214
219
  applyResult(source) {
215
- compilation.updateAsset(file, source);
220
+ assetCompilation.updateAsset(file, source);
216
221
  },
217
222
  onCacheHit() {
218
223
  debug2("js cache hit: %s", file);
219
224
  },
220
225
  transform: async () => {
221
- const currentAsset = compilation.assets[file];
222
- const currentValue = currentAsset?.source();
223
- const currentSource = typeof currentValue === "string" ? currentValue : currentValue?.toString() ?? "";
226
+ const currentAsset = assetCompilation.assets[file];
227
+ const currentSource = currentAsset ? readWebpackV4AssetSource(currentAsset) : "";
224
228
  const handlerOptions = {
225
229
  staleClassNameFallback,
226
230
  tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
@@ -249,7 +253,7 @@ function setupWebpackV4EmitHook(options) {
249
253
  if (Array.isArray(groupedEntries.css)) {
250
254
  for (const element of groupedEntries.css) {
251
255
  const [file, originalSource] = element;
252
- const rawSource = originalSource.source().toString();
256
+ const rawSource = readWebpackV4AssetSource(originalSource);
253
257
  const cacheKey = file;
254
258
  const chunkHash = assetHashByChunk.get(file);
255
259
  tasks.push(
@@ -260,7 +264,7 @@ function setupWebpackV4EmitHook(options) {
260
264
  rawSource,
261
265
  hash: chunkHash,
262
266
  applyResult(source) {
263
- compilation.updateAsset(file, source);
267
+ assetCompilation.updateAsset(file, source);
264
268
  },
265
269
  onCacheHit() {
266
270
  debug2("css cache hit: %s", file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "4.12.0-next.0",
3
+ "version": "4.12.0",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -150,13 +150,14 @@
150
150
  "dist",
151
151
  "index.css",
152
152
  "preflight.css",
153
+ "scripts/postinstall.mjs",
153
154
  "theme.css",
154
155
  "uni-app-x.css",
155
156
  "utilities.css",
156
157
  "with-layer.css"
157
158
  ],
158
159
  "engines": {
159
- "node": "^18.17.0 || >=20.5.0"
160
+ "node": "^20.19.0 || >=22.12.0"
160
161
  },
161
162
  "publishConfig": {
162
163
  "access": "public",
@@ -164,10 +165,10 @@
164
165
  },
165
166
  "dependencies": {
166
167
  "@ast-core/escape": "~1.0.1",
167
- "@babel/parser": "~7.29.2",
168
+ "@babel/parser": "~7.29.3",
168
169
  "@babel/traverse": "~7.29.0",
169
170
  "@babel/types": "~7.29.0",
170
- "@tailwindcss-mangle/config": "^7.0.0",
171
+ "@tailwindcss-mangle/config": "^7.0.1",
171
172
  "@vue/compiler-dom": "^3.5.33",
172
173
  "@vue/compiler-sfc": "^3.5.33",
173
174
  "@weapp-core/escape": "~7.0.0",
@@ -182,12 +183,12 @@
182
183
  "lru-cache": "10.4.3",
183
184
  "magic-string": "0.30.21",
184
185
  "semver": "~7.7.4",
185
- "tailwindcss-patch": "9.0.0",
186
+ "tailwindcss-patch": "9.0.1",
186
187
  "webpack-sources": "3.3.4",
187
- "yaml": "^2.8.3",
188
+ "yaml": "^2.8.4",
188
189
  "@weapp-tailwindcss/logger": "1.1.0",
189
- "@weapp-tailwindcss/postcss": "2.2.0-next.0",
190
- "@weapp-tailwindcss/reset": "0.1.0-next.0",
190
+ "@weapp-tailwindcss/postcss": "2.2.0",
191
+ "@weapp-tailwindcss/reset": "0.1.0",
191
192
  "@weapp-tailwindcss/shared": "1.1.3"
192
193
  },
193
194
  "devDependencies": {
@@ -200,7 +201,7 @@
200
201
  "build:cli": "cd plugins/cli && pnpm run build",
201
202
  "build:css": "tsx scripts/build-css.ts",
202
203
  "build:weapp-theme": "tsx scripts/build-weapp-theme.ts",
203
- "test": "npm run postinstall && vitest run",
204
+ "test": "pnpm run cli:patch && vitest run",
204
205
  "test:dev": "vitest",
205
206
  "test:ui": "vitest --ui",
206
207
  "bench": "vitest bench --config ./vitest.config.ts",
@@ -217,7 +218,7 @@
217
218
  "release": "tsx scripts/release.ts",
218
219
  "lint": "eslint .",
219
220
  "lint:fix": "eslint ./src --fix",
220
- "postinstall": "node bin/weapp-tailwindcss.js patch",
221
+ "postinstall": "node scripts/postinstall.mjs",
221
222
  "bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
222
223
  "test:watch-hmr": "node --import tsx scripts/watch-hmr-regression/index.ts"
223
224
  }
@@ -0,0 +1,59 @@
1
+ import { spawnSync } from 'node:child_process'
2
+ import process from 'node:process'
3
+ import { fileURLToPath, pathToFileURL } from 'node:url'
4
+
5
+ const cliPath = fileURLToPath(new URL('../bin/weapp-tailwindcss.js', import.meta.url))
6
+ const missingRuntimeModuleMessage = `${[
7
+ '[weapp-tailwindcss] postinstall patch skipped because a runtime module is missing.',
8
+ 'Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.',
9
+ ].join(' ')}\n`
10
+
11
+ export function isMissingRuntimeModuleOutput(output) {
12
+ return /MODULE_NOT_FOUND|Cannot find module/.test(output)
13
+ }
14
+
15
+ export function resolvePostinstallPatchExitCode(result) {
16
+ if (result.error) {
17
+ return {
18
+ code: 0,
19
+ message: `[weapp-tailwindcss] postinstall patch skipped: ${result.error.message}\n`,
20
+ }
21
+ }
22
+
23
+ if (result.status && isMissingRuntimeModuleOutput(`${result.stderr ?? ''}\n${result.stdout ?? ''}`)) {
24
+ return {
25
+ code: 0,
26
+ message: missingRuntimeModuleMessage,
27
+ }
28
+ }
29
+
30
+ return {
31
+ code: result.status ?? 0,
32
+ }
33
+ }
34
+
35
+ export function runPostinstallPatch() {
36
+ const result = spawnSync(process.execPath, [cliPath, 'patch'], {
37
+ encoding: 'utf8',
38
+ })
39
+
40
+ if (result.stdout) {
41
+ process.stdout.write(result.stdout)
42
+ }
43
+
44
+ if (result.stderr) {
45
+ process.stderr.write(result.stderr)
46
+ }
47
+
48
+ const resolved = resolvePostinstallPatchExitCode(result)
49
+ if (resolved.message) {
50
+ process.stderr.write(resolved.message)
51
+ }
52
+
53
+ process.exitCode = resolved.code
54
+ }
55
+
56
+ const entryPoint = process.argv[1] ? pathToFileURL(process.argv[1]).href : undefined
57
+ if (import.meta.url === entryPoint) {
58
+ runPostinstallPatch()
59
+ }