weapp-tailwindcss 5.0.0-next.32 → 5.0.0-next.35

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 (45) hide show
  1. package/dist/{bundle-state-C4ib5xPG.js → bundle-state-8w8DM8Lw.js} +1 -1
  2. package/dist/{bundle-state-BIsgsoNW.mjs → bundle-state-Bsr05EFW.mjs} +1 -1
  3. package/dist/bundlers/shared/cache.d.ts +3 -1
  4. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
  5. package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
  6. package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
  7. package/dist/cli.js +9 -10
  8. package/dist/cli.mjs +10 -11
  9. package/dist/core.js +1 -1
  10. package/dist/core.mjs +1 -1
  11. package/dist/{generator-BEXaaUzP.js → generator-BtpQoQEH.js} +1 -1
  12. package/dist/{generator-CpsHA4Wd.mjs → generator-CmLpVJgw.mjs} +1 -1
  13. package/dist/generator.js +2 -2
  14. package/dist/generator.mjs +2 -2
  15. package/dist/gulp.js +5 -5
  16. package/dist/gulp.mjs +5 -5
  17. package/dist/{incremental-runtime-class-set-D2fsgk5t.mjs → incremental-runtime-class-set-W61zZU00.mjs} +72 -10
  18. package/dist/{incremental-runtime-class-set-CLP1Qv8F.js → incremental-runtime-class-set-vqTU-eph.js} +77 -9
  19. package/dist/index.js +4 -4
  20. package/dist/index.mjs +4 -4
  21. package/dist/js/replacement-cache.d.ts +5 -0
  22. package/dist/{postcss-BvkdIZr8.mjs → postcss-DGprmeke.mjs} +2 -2
  23. package/dist/{postcss-DN7IQzYb.js → postcss-DSvNrY0J.js} +2 -2
  24. package/dist/postcss.js +1 -1
  25. package/dist/postcss.mjs +1 -1
  26. package/dist/{precheck-CQeqnfo5.js → precheck-Bp-V1T_Q.js} +12 -12
  27. package/dist/{precheck-nITnYBDn.mjs → precheck-nPDKYr8V.mjs} +13 -13
  28. package/dist/presets.js +2 -2
  29. package/dist/presets.mjs +2 -2
  30. package/dist/{source-candidates-7Q-kTOSb.js → source-candidates-BjB4wSga.js} +1 -1
  31. package/dist/{source-candidates-_x8bq0Mz.mjs → source-candidates-l12JBkKU.mjs} +1 -1
  32. package/dist/{tailwindcss-udhXxMX9.mjs → tailwindcss-D6zEhnyE.mjs} +1 -1
  33. package/dist/{tailwindcss-Cl7hUlYV.js → tailwindcss-bNXguXhC.js} +1 -1
  34. package/dist/{v3-engine-C_KeUQG3.mjs → v3-engine-BYcGCWUY.mjs} +33 -0
  35. package/dist/{v3-engine-DwY4Fixu.js → v3-engine-KDOfD-6F.js} +33 -0
  36. package/dist/{vite-BAHjBu8j.mjs → vite-C8SUICPv.mjs} +103 -42
  37. package/dist/{vite-CYkkJZ3Q.js → vite-CMzi0wR2.js} +103 -42
  38. package/dist/vite.js +1 -1
  39. package/dist/vite.mjs +1 -1
  40. package/dist/weapp-tw-css-import-rewrite-loader.js +33 -1
  41. package/dist/{webpack-CPwDaKy3.js → webpack-2v1sQKyZ.js} +65 -29
  42. package/dist/{webpack-xxmiRxcy.mjs → webpack-pdpdIv_X.mjs} +65 -29
  43. package/dist/webpack.js +1 -1
  44. package/dist/webpack.mjs +1 -1
  45. package/package.json +6 -6
@@ -1,10 +1,10 @@
1
- import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-nITnYBDn.mjs";
2
- import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-C_KeUQG3.mjs";
3
- import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CpsHA4Wd.mjs";
4
- import { i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-D2fsgk5t.mjs";
1
+ import { b as ensureRuntimeClassSet, d as _defineProperty, f as init_defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./precheck-nPDKYr8V.mjs";
2
+ import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-BYcGCWUY.mjs";
3
+ import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CmLpVJgw.mjs";
4
+ import { d as removeTailwindSourceDirectives, i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-W61zZU00.mjs";
5
5
  import { r as getGroupedEntries } from "./utils-DsaS975I.mjs";
6
- import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-udhXxMX9.mjs";
7
- import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-BIsgsoNW.mjs";
6
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-D6zEhnyE.mjs";
7
+ import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-Bsr05EFW.mjs";
8
8
  import Module, { createRequire } from "node:module";
9
9
  import fs from "node:fs";
10
10
  import process from "node:process";
@@ -264,6 +264,10 @@ function createWebpackSnapshotAssets(assets) {
264
264
  }];
265
265
  }));
266
266
  }
267
+ function stringifyWebpackSource(source) {
268
+ if (typeof source === "string") return source;
269
+ return source?.toString() ?? "";
270
+ }
267
271
  function setupWebpackV5ProcessAssetsHook(options) {
268
272
  const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
269
273
  const { Compilation, sources } = compiler.webpack;
@@ -285,6 +289,22 @@ function setupWebpackV5ProcessAssetsHook(options) {
285
289
  const hmrTimingStartedAt = performance.now();
286
290
  for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
287
291
  const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
292
+ const getCurrentAssetSource = (file) => {
293
+ const asset = compilation.getAsset(file);
294
+ if (!asset) return;
295
+ return stringifyWebpackSource(asset.source.source());
296
+ };
297
+ const updateAssetIfChanged = (file, source, { notifyUpdate = true } = {}) => {
298
+ const nextSource = stringifyWebpackSource(source.source());
299
+ const previousSource = getCurrentAssetSource(file);
300
+ if (previousSource === nextSource) {
301
+ debug("asset unchanged, skip update: %s", file);
302
+ return false;
303
+ }
304
+ compilation.updateAsset(file, source);
305
+ if (notifyUpdate) compilerOptions.onUpdate(file, previousSource ?? "", nextSource);
306
+ return true;
307
+ };
288
308
  const entries = Object.entries(assets);
289
309
  const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
290
310
  const outputDir = compilerOutputPath ? path.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? process.cwd();
@@ -317,12 +337,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
317
337
  const asset = compilation.getAsset(assetName);
318
338
  if (!asset) continue;
319
339
  const previousSource = asset.source.source();
320
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
321
- if (previous === code) continue;
322
- const source = new ConcatSource(code);
323
- compilation.updateAsset(assetName, source);
324
- compilerOptions.onUpdate(assetName, previous, code);
325
- debug("js linked handle: %s", assetName);
340
+ if ((typeof previousSource === "string" ? previousSource : previousSource.toString()) === code) continue;
341
+ if (updateAssetIfChanged(assetName, new ConcatSource(code))) debug("js linked handle: %s", assetName);
326
342
  }
327
343
  };
328
344
  const groupedEntries = getGroupedEntries(entries, compilerOptions);
@@ -351,6 +367,9 @@ function setupWebpackV5ProcessAssetsHook(options) {
351
367
  cssUserHandlerOptionsCache.set(cacheKey, created);
352
368
  return created;
353
369
  };
370
+ const finalizeCssAssetSource = (source) => {
371
+ return removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
372
+ };
354
373
  const forceRuntimeRefresh = getRuntimeRefreshRequirement();
355
374
  debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
356
375
  let runtimeSet;
@@ -403,16 +422,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
403
422
  hashKey: `${file}:asset`,
404
423
  rawSource,
405
424
  hash: chunkHash,
406
- applyResult(source) {
407
- compilation.updateAsset(file, source);
425
+ applyResult(source, { cacheHit }) {
426
+ updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
408
427
  },
409
428
  onCacheHit() {
410
429
  debug("html cache hit: %s", file);
411
430
  },
412
431
  transform: async () => {
413
- const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
414
- const source = new ConcatSource(wxml);
415
- compilerOptions.onUpdate(file, rawSource, wxml);
432
+ const source = new ConcatSource(await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions));
416
433
  debug("html handle: %s", file);
417
434
  return { result: source };
418
435
  }
@@ -434,8 +451,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
434
451
  hashKey: `${file}:asset`,
435
452
  rawSource: initialRawSource,
436
453
  hash: chunkHash,
437
- applyResult(source) {
438
- compilation.updateAsset(file, source);
454
+ applyResult(source, { cacheHit }) {
455
+ updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
439
456
  },
440
457
  onCacheHit() {
441
458
  debug("js cache hit: %s", file);
@@ -455,7 +472,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
455
472
  })) return { result: new ConcatSource(currentSource) };
456
473
  const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
457
474
  const source = new ConcatSource(code);
458
- compilerOptions.onUpdate(file, currentSource, code);
459
475
  debug("js handle: %s", file);
460
476
  applyLinkedResults(linked);
461
477
  return { result: source };
@@ -467,21 +483,20 @@ function setupWebpackV5ProcessAssetsHook(options) {
467
483
  const [file, originalSource] = element;
468
484
  const rawSource = originalSource.source().toString();
469
485
  if (isWebpackProcessedCssAsset?.(file, rawSource)) {
470
- const nextCss = stripBundlerGeneratedCssMarkers(rawSource);
486
+ const nextCss = finalizeCssAssetSource(rawSource);
471
487
  tasks.push(processCachedTask({
472
488
  cache: compilerOptions.cache,
473
489
  cacheKey: file,
474
490
  hashKey: `${file}:asset`,
475
491
  rawSource,
476
492
  hash: createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash),
477
- applyResult(source) {
478
- compilation.updateAsset(file, source);
493
+ applyResult(source, { cacheHit }) {
494
+ updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
479
495
  },
480
496
  onCacheHit() {
481
497
  debug("css webpack-loader-pipeline cache hit: %s", file);
482
498
  },
483
499
  transform: async () => {
484
- compilerOptions.onUpdate(file, rawSource, nextCss);
485
500
  debug("css skip webpack-loader-pipeline asset: %s", file);
486
501
  return { result: new ConcatSource(nextCss) };
487
502
  }
@@ -496,8 +511,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
496
511
  hashKey: `${file}:asset`,
497
512
  rawSource,
498
513
  hash: runtimeAwareHash,
499
- applyResult(source) {
500
- compilation.updateAsset(file, source);
514
+ applyResult(source, { cacheHit }) {
515
+ updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
501
516
  },
502
517
  onCacheHit() {
503
518
  debug("css cache hit: %s", file);
@@ -516,9 +531,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
516
531
  styleHandler: compilerOptions.styleHandler,
517
532
  debug
518
533
  });
519
- const css = generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css;
520
- const source = new ConcatSource(css);
521
- compilerOptions.onUpdate(file, rawSource, css);
534
+ const source = new ConcatSource(finalizeCssAssetSource(generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css));
522
535
  if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
523
536
  else debug("css handle: %s", file);
524
537
  return { result: source };
@@ -670,6 +683,28 @@ function setupWebpackV5Loaders(options) {
670
683
  init_defineProperty();
671
684
  const debug = createDebug();
672
685
  const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
686
+ function normalizeIgnoredList(ignored) {
687
+ if (Array.isArray(ignored)) return ignored;
688
+ return ignored == null ? [] : [ignored];
689
+ }
690
+ function appendIgnoredPath(ignored, ignoredPath) {
691
+ const ignoredList = normalizeIgnoredList(ignored);
692
+ if (ignoredList.some((item) => typeof item === "string" && path.resolve(item) === ignoredPath)) return ignored;
693
+ return [...ignoredList, ignoredPath];
694
+ }
695
+ function setupWebpackWatchOutputIgnore(compiler) {
696
+ const originalWatch = compiler.watch?.bind(compiler);
697
+ if (typeof originalWatch !== "function") return;
698
+ compiler.watch = ((watchOptions, handler) => {
699
+ const outputPath = compiler.outputPath || compiler.options?.output?.path;
700
+ const outputDir = outputPath ? path.resolve(outputPath) : void 0;
701
+ if (!outputDir) return originalWatch(watchOptions, handler);
702
+ return originalWatch({
703
+ ...watchOptions,
704
+ ignored: appendIgnoredPath(watchOptions.ignored, outputDir)
705
+ }, handler);
706
+ });
707
+ }
673
708
  /**
674
709
  * @name WeappTailwindcss
675
710
  * @description webpack5 核心转义插件
@@ -697,6 +732,7 @@ var WeappTailwindcss = class {
697
732
  const isMpxApp = isMpx(this.appType);
698
733
  if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
699
734
  if (disabledOptions.plugin) return;
735
+ setupWebpackWatchOutputIgnore(compiler);
700
736
  const runtimeState = {
701
737
  twPatcher: initialTwPatcher,
702
738
  readyPromise: createTailwindRuntimeReadyPromise(initialTwPatcher),
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_webpack = require("./webpack-CPwDaKy3.js");
2
+ const require_webpack = require("./webpack-2v1sQKyZ.js");
3
3
  exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
4
4
  exports.weappTailwindcss = require_webpack.WeappTailwindcss;
5
5
  exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
package/dist/webpack.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-xxmiRxcy.mjs";
1
+ import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-pdpdIv_X.mjs";
2
2
  export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "5.0.0-next.32",
3
+ "version": "5.0.0-next.35",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -182,13 +182,13 @@
182
182
  "micromatch": "^4.0.8",
183
183
  "postcss-load-config": "^6.0.1",
184
184
  "semver": "~7.8.1",
185
- "tailwindcss-patch": "9.3.7",
185
+ "tailwindcss-patch": "9.4.1",
186
186
  "yaml": "^2.9.0",
187
187
  "@weapp-tailwindcss/logger": "2.0.0-next.0",
188
- "@weapp-tailwindcss/reset": "0.1.1-next.1",
189
- "@weapp-tailwindcss/postcss": "3.0.0-next.8",
190
- "tailwindcss-config": "2.0.0-next.2",
191
- "@weapp-tailwindcss/shared": "2.0.0-next.0"
188
+ "@weapp-tailwindcss/shared": "2.0.0-next.1",
189
+ "tailwindcss-config": "2.0.0-next.3",
190
+ "@weapp-tailwindcss/postcss": "3.0.0-next.9",
191
+ "@weapp-tailwindcss/reset": "0.1.1-next.1"
192
192
  },
193
193
  "devDependencies": {
194
194
  "@vue/compiler-dom": "^3.5.35",