weapp-tailwindcss 5.0.0-next.7 → 5.0.0-next.8

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 (48) hide show
  1. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
  2. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  3. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
  4. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  5. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -0
  6. package/dist/{cache-DPN5yKSX.js → cache-BVAiJV3J.js} +5 -0
  7. package/dist/{cache-nq0_XJoS.mjs → cache-CHs4DXui.mjs} +5 -0
  8. package/dist/core.js +1 -1
  9. package/dist/core.mjs +1 -1
  10. package/dist/css-macro.js +1 -1
  11. package/dist/css-macro.mjs +1 -1
  12. package/dist/defaults.js +1 -1
  13. package/dist/defaults.mjs +1 -1
  14. package/dist/{generator-TOp4uz7c.js → generator-DKkhJbOg.js} +3 -2
  15. package/dist/{generator-CzfdCZyd.mjs → generator-UBmfduYg.mjs} +3 -2
  16. package/dist/{generator-css-B938WI9a.mjs → generator-css-BIapP56i.mjs} +184 -146
  17. package/dist/{generator-css-Dnpl-IY2.js → generator-css-Mksw8PgB.js} +189 -145
  18. package/dist/generator.js +1 -1
  19. package/dist/generator.mjs +1 -1
  20. package/dist/gulp.js +20 -5
  21. package/dist/gulp.mjs +20 -5
  22. package/dist/index.js +4 -4
  23. package/dist/index.mjs +4 -4
  24. package/dist/{postcss-WsXlC7A-.js → postcss-QIXwT40c.js} +2 -2
  25. package/dist/{postcss-BtAP6sQO.mjs → postcss-w48mGIhe.mjs} +2 -2
  26. package/dist/postcss.js +1 -1
  27. package/dist/postcss.mjs +1 -1
  28. package/dist/{precheck-Dka94ArV.js → precheck-B32p-gLI.js} +5 -5
  29. package/dist/{precheck-DlrmwCc-.mjs → precheck-B4RH6ZNN.mjs} +5 -5
  30. package/dist/presets.js +3 -3
  31. package/dist/presets.mjs +3 -3
  32. package/dist/{runtime-patch-pGdCqAEu.mjs → runtime-patch-CwN5ya72.mjs} +1 -1
  33. package/dist/{runtime-patch-qwuisukL.js → runtime-patch-D6mBo_KB.js} +1 -1
  34. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  35. package/dist/{tailwindcss-T1U5T-iF.js → tailwindcss-Bu-RWIHx.js} +68 -3
  36. package/dist/{tailwindcss-BIJ185GB.mjs → tailwindcss-C5IgPlQ0.mjs} +57 -4
  37. package/dist/{vite-BXChkciE.mjs → vite-BwgRVgxH.mjs} +56 -25
  38. package/dist/{vite-D0CoRblu.js → vite-DyZuiyap.js} +56 -25
  39. package/dist/vite.js +1 -1
  40. package/dist/vite.mjs +1 -1
  41. package/dist/weapp-tw-css-import-rewrite-loader.js +10 -1
  42. package/dist/{webpack-D-sUCY0u.js → webpack-CNV2dx3Q.js} +46 -10
  43. package/dist/{webpack-BNdGm9KL.mjs → webpack-CT6EEENx.mjs} +46 -10
  44. package/dist/webpack.js +1 -1
  45. package/dist/webpack.mjs +1 -1
  46. package/package.json +4 -4
  47. /package/dist/{utils-VZvGusYs.js → utils-BiShvil9.js} +0 -0
  48. /package/dist/{utils-BJjKRQgf.mjs → utils-Btw1iOVV.mjs} +0 -0
@@ -1,8 +1,9 @@
1
- import { c as resolveTailwindcssOptions, n as getRuntimeClassSetSignature } from "./cache-nq0_XJoS.mjs";
2
- import { n as createDebug } from "./runtime-patch-pGdCqAEu.mjs";
3
- import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform } from "./precheck-DlrmwCc-.mjs";
4
- import { r as getGroupedEntries } from "./utils-BJjKRQgf.mjs";
5
- import { a as processCachedTask, t as generateCssByGenerator } from "./generator-css-B938WI9a.mjs";
1
+ import { c as resolveTailwindcssOptions, n as getRuntimeClassSetSignature } from "./cache-CHs4DXui.mjs";
2
+ import { n as createDebug } from "./runtime-patch-CwN5ya72.mjs";
3
+ import { r as processCachedTask, t as generateCssByGenerator } from "./generator-css-BIapP56i.mjs";
4
+ import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform, v as refreshTailwindRuntimeState } from "./precheck-B4RH6ZNN.mjs";
5
+ import { r as getGroupedEntries } from "./utils-Btw1iOVV.mjs";
6
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-C5IgPlQ0.mjs";
6
7
  import { a as resolveOutputSpecifier, n as resolvePackageDir, o as toAbsoluteOutputPath, r as resolvePluginDisabledState, t as pushConcurrentTaskFactories } from "./run-tasks-DdNi-hkk.mjs";
7
8
  import Module, { createRequire } from "node:module";
8
9
  import path from "node:path";
@@ -27,7 +28,7 @@ function installTailwindcssCssRedirect(pkgDir) {
27
28
  }
28
29
  //#endregion
29
30
  //#region src/shared/mpx.ts
30
- const require = createRequire(import.meta.url);
31
+ const localRequire = createRequire(import.meta.url);
31
32
  const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
32
33
  function isMpxStyleResourceQuery(query) {
33
34
  if (typeof query !== "string") return false;
@@ -39,6 +40,18 @@ function isMpx(appType) {
39
40
  function getTailwindcssCssEntry(pkgDir) {
40
41
  return path.join(pkgDir, "index.css");
41
42
  }
43
+ function resolveMpxWebpackPluginDir(compiler) {
44
+ const candidates = [
45
+ compiler?.context,
46
+ compiler?.options?.context,
47
+ process.cwd()
48
+ ].filter((item) => typeof item === "string" && item.length > 0);
49
+ for (const candidate of candidates) try {
50
+ const projectRequire = createRequire(path.join(candidate, "package.json"));
51
+ return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
52
+ } catch {}
53
+ return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
54
+ }
42
55
  function isMpxWebpackPluginRequest(request) {
43
56
  return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
44
57
  }
@@ -60,9 +73,9 @@ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
60
73
  }
61
74
  function ensureMpxTailwindcssAliases(compiler, pkgDir) {
62
75
  const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
63
- const mpxWebpackPluginDir = path.dirname(require.resolve("@mpxjs/webpack-plugin/package.json"));
64
76
  compiler.options = compiler.options || {};
65
77
  compiler.options.resolve = compiler.options.resolve || {};
78
+ const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
66
79
  ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
67
80
  const alias = compiler.options.resolve.alias ?? {};
68
81
  compiler.options.resolve.alias = alias;
@@ -425,7 +438,7 @@ function createLoaderAnchorFinders(appType) {
425
438
  //#endregion
426
439
  //#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
427
440
  function setupWebpackV5Loaders(options) {
428
- const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
441
+ const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
429
442
  const isMpxApp = isMpx(appType);
430
443
  if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
431
444
  const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
@@ -434,7 +447,8 @@ function setupWebpackV5Loaders(options) {
434
447
  const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
435
448
  const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
436
449
  pkgDir: weappTailwindcssPackageDir,
437
- appType
450
+ appType,
451
+ registerCssSource: registerAutoCssSource
438
452
  } : void 0;
439
453
  const classSetLoaderOptions = {
440
454
  getClassSet: getClassSetInLoader,
@@ -519,7 +533,12 @@ var UnifiedWebpackPluginV5 = class {
519
533
  constructor(options = {}) {
520
534
  _defineProperty(this, "options", void 0);
521
535
  _defineProperty(this, "appType", void 0);
522
- this.options = getCompilerContext(options);
536
+ _defineProperty(this, "hasInitialTailwindCssRoots", void 0);
537
+ this.hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots(options);
538
+ this.options = getCompilerContext({
539
+ ...options,
540
+ __internalDeferMissingCssEntriesWarning: true
541
+ });
523
542
  this.appType = this.options.appType;
524
543
  }
525
544
  apply(compiler) {
@@ -547,6 +566,10 @@ var UnifiedWebpackPluginV5 = class {
547
566
  const tailwindOptions = resolveTailwindcssOptions(runtimeState.twPatcher.options);
548
567
  if (tailwindOptions?.config) runtimeWatchDependencyFiles.add(tailwindOptions.config);
549
568
  for (const entry of tailwindOptions?.v4?.cssEntries ?? []) runtimeWatchDependencyFiles.add(entry);
569
+ for (const source of tailwindOptions?.v4?.cssSources ?? []) {
570
+ if (source.file) runtimeWatchDependencyFiles.add(source.file);
571
+ for (const dependency of source.dependencies ?? []) runtimeWatchDependencyFiles.add(dependency);
572
+ }
550
573
  for (const source of tailwindOptions?.v4?.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
551
574
  if (typeof runtimeState.twPatcher.collectContentTokens !== "function") return;
552
575
  try {
@@ -570,6 +593,18 @@ var UnifiedWebpackPluginV5 = class {
570
593
  runtimeMetadataPrepared = false;
571
594
  syncRuntimeRefreshRequirement();
572
595
  };
596
+ const registerAutoCssSource = async (source) => {
597
+ if (this.hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !source.file) return;
598
+ if (!upsertTailwindV4CssSource(this.options, source)) return;
599
+ runtimeSetPrepared = false;
600
+ runtimeMetadataPrepared = false;
601
+ runtimeRefreshRequiredForCompilation = true;
602
+ await refreshTailwindRuntimeState(runtimeState, {
603
+ force: true,
604
+ clearCache: true
605
+ });
606
+ debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
607
+ };
573
608
  compiler.hooks.invalid?.tap?.(pluginName, () => {
574
609
  runtimeRefreshRequiredForCompilation = true;
575
610
  });
@@ -600,6 +635,7 @@ var UnifiedWebpackPluginV5 = class {
600
635
  weappTailwindcssPackageDir,
601
636
  shouldRewriteCssImports,
602
637
  runtimeLoaderPath,
638
+ registerAutoCssSource,
603
639
  getClassSetInLoader,
604
640
  getRuntimeWatchDependencies() {
605
641
  return {
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_webpack = require("./webpack-D-sUCY0u.js");
2
+ const require_webpack = require("./webpack-CNV2dx3Q.js");
3
3
  exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
4
4
  exports.WeappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
5
5
  exports.weappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
package/dist/webpack.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-BNdGm9KL.mjs";
1
+ import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-CT6EEENx.mjs";
2
2
  export { UnifiedWebpackPluginV5, UnifiedWebpackPluginV5 as WeappTailwindcss, UnifiedWebpackPluginV5 as weappTailwindcss, weappTailwindcssPackageDir };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weapp-tailwindcss",
3
- "version": "5.0.0-next.7",
3
+ "version": "5.0.0-next.8",
4
4
  "description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -186,13 +186,13 @@
186
186
  "magic-string": "0.30.21",
187
187
  "postcss-load-config": "^6.0.1",
188
188
  "semver": "~7.8.0",
189
- "tailwindcss-patch": "9.3.2",
189
+ "tailwindcss-patch": "9.3.3",
190
190
  "yaml": "^2.9.0",
191
- "@weapp-tailwindcss/postcss": "2.2.1-next.0",
192
191
  "@weapp-tailwindcss/logger": "1.1.0",
192
+ "@weapp-tailwindcss/postcss": "2.2.1-next.1",
193
193
  "@weapp-tailwindcss/reset": "0.1.1-next.0",
194
194
  "@weapp-tailwindcss/shared": "1.1.3",
195
- "tailwindcss-config": "1.1.6-next.0"
195
+ "tailwindcss-config": "1.1.6-next.1"
196
196
  },
197
197
  "scripts": {
198
198
  "dev": "tsdown --watch --sourcemap",
File without changes
File without changes