weapp-tailwindcss 4.8.3 → 4.8.5-alpha.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/dist/{chunk-7KTLLGAG.mjs → chunk-3XGTIDA6.mjs} +72 -49
  2. package/dist/{chunk-26ZRX6OH.js → chunk-5KVCFUCR.js} +27 -20
  3. package/dist/{chunk-QGH4JZRW.mjs → chunk-67CD2S5L.mjs} +0 -8
  4. package/dist/{chunk-H34KPZQW.js → chunk-AB45L5FP.js} +2 -2
  5. package/dist/{chunk-E3GZQTOH.mjs → chunk-E4WMGIBB.mjs} +13 -6
  6. package/dist/{chunk-KSHK56CW.mjs → chunk-EQP3XJUM.mjs} +1 -1
  7. package/dist/chunk-GBKTM7HE.mjs +29 -0
  8. package/dist/{chunk-NLLCK6RM.mjs → chunk-NE4IF47K.mjs} +11 -4
  9. package/dist/{chunk-UUVGNRUM.mjs → chunk-NMUFIIAM.mjs} +36 -23
  10. package/dist/{chunk-N2ZUYGKA.js → chunk-OQGFV6TW.js} +14 -7
  11. package/dist/{chunk-UCA2DMVN.js → chunk-OR5KGJ46.js} +5 -5
  12. package/dist/{chunk-W5Z3I3S2.js → chunk-QZ5JL3U3.js} +52 -39
  13. package/dist/chunk-R6ERGDBQ.js +29 -0
  14. package/dist/{chunk-2ZEOKKVA.js → chunk-RJRLVYVJ.js} +77 -54
  15. package/dist/{chunk-WTOLVORM.mjs → chunk-T25LQFYZ.mjs} +389 -52
  16. package/dist/chunk-UTZLVU3M.js +7 -0
  17. package/dist/{chunk-PLV4QGF4.js → chunk-YKMZHWQ4.js} +427 -90
  18. package/dist/cli.js +270 -311
  19. package/dist/cli.mjs +273 -313
  20. package/dist/core.js +19 -11
  21. package/dist/core.mjs +14 -6
  22. package/dist/css-macro/postcss.js +1 -1
  23. package/dist/css-macro/postcss.mjs +1 -1
  24. package/dist/css-macro.js +1 -1
  25. package/dist/css-macro.mjs +1 -1
  26. package/dist/defaults.js +1 -1
  27. package/dist/defaults.mjs +1 -1
  28. package/dist/gulp.js +6 -5
  29. package/dist/gulp.mjs +5 -4
  30. package/dist/index.js +10 -9
  31. package/dist/index.mjs +8 -7
  32. package/dist/postcss-html-transform.js +1 -1
  33. package/dist/postcss-html-transform.mjs +1 -1
  34. package/dist/presets.js +4 -6
  35. package/dist/presets.mjs +3 -5
  36. package/dist/reset.d.mts +30 -0
  37. package/dist/reset.d.ts +32 -0
  38. package/dist/reset.js +161 -0
  39. package/dist/reset.mjs +161 -0
  40. package/dist/types.js +1 -1
  41. package/dist/types.mjs +1 -1
  42. package/dist/vite.js +7 -6
  43. package/dist/vite.mjs +5 -4
  44. package/dist/webpack.js +8 -7
  45. package/dist/webpack.mjs +6 -5
  46. package/dist/webpack4.js +29 -22
  47. package/dist/webpack4.mjs +14 -7
  48. package/package.json +12 -5
  49. package/dist/chunk-OXASK55Q.js +0 -6
  50. package/dist/chunk-PMF2CCKK.mjs +0 -6
  51. package/dist/chunk-UJIUFWXE.js +0 -15
@@ -3,7 +3,6 @@ import {
3
3
  } from "./chunk-ZNKIYZRQ.mjs";
4
4
 
5
5
  // src/context/tailwindcss.ts
6
- import { existsSync as existsSync3 } from "fs";
7
6
  import { createRequire as createRequire2 } from "module";
8
7
  import path3 from "path";
9
8
  import process2 from "process";
@@ -41,6 +40,23 @@ function findWorkspaceRoot(startDir) {
41
40
  current = parent;
42
41
  }
43
42
  }
43
+ function findNearestPackageRoot(startDir) {
44
+ if (!startDir) {
45
+ return void 0;
46
+ }
47
+ let current = path.resolve(startDir);
48
+ while (true) {
49
+ const pkgPath = path.join(current, "package.json");
50
+ if (existsSync(pkgPath)) {
51
+ return current;
52
+ }
53
+ const parent = path.dirname(current);
54
+ if (parent === current) {
55
+ return void 0;
56
+ }
57
+ current = parent;
58
+ }
59
+ }
44
60
  function findWorkspacePackageDir(rootDir, packageName) {
45
61
  const visited = /* @__PURE__ */ new Set();
46
62
  const queue = [path.resolve(rootDir)];
@@ -167,23 +183,6 @@ function createFallbackTailwindcssPatcher() {
167
183
  };
168
184
  }
169
185
  var hasLoggedMissingTailwind = false;
170
- function findNearestPackageRoot(startDir) {
171
- if (!startDir) {
172
- return void 0;
173
- }
174
- let current = path2.resolve(startDir);
175
- while (true) {
176
- const pkgPath = path2.join(current, "package.json");
177
- if (existsSync2(pkgPath)) {
178
- return current;
179
- }
180
- const parent = path2.dirname(current);
181
- if (parent === current) {
182
- return void 0;
183
- }
184
- current = parent;
185
- }
186
- }
187
186
  function appendNodeModules(paths, dir) {
188
187
  if (!dir) {
189
188
  return;
@@ -446,6 +445,11 @@ function createTailwindcssPatcher(options) {
446
445
  }
447
446
  }
448
447
 
448
+ // src/tailwindcss/index.ts
449
+ function getTailwindcssPackageInfo(options) {
450
+ return getPackageInfoSync("tailwindcss", options);
451
+ }
452
+
449
453
  // src/context/tailwindcss.ts
450
454
  var ENV_BASEDIR_KEYS = [
451
455
  "WEAPP_TAILWINDCSS_BASEDIR",
@@ -536,7 +540,9 @@ function resolveTailwindcssBasedir(basedir, fallback) {
536
540
  const packageEnvBasedir = pickPackageEnvBasedir();
537
541
  const shouldDetectCaller = !envBasedir || envBasedirIsGeneric;
538
542
  const callerBasedir = shouldDetectCaller ? detectCallerBasedir() : void 0;
539
- const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? process2.cwd();
543
+ const cwd = process2.cwd();
544
+ const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
545
+ const resolveRelative = (value) => path3.isAbsolute(value) ? path3.normalize(value) : path3.normalize(path3.resolve(anchor, value));
540
546
  if (process2.env.WEAPP_TW_DEBUG_STACK === "1") {
541
547
  logger2.debug("resolveTailwindcssBasedir anchor %O", {
542
548
  basedir,
@@ -547,22 +553,18 @@ function resolveTailwindcssBasedir(basedir, fallback) {
547
553
  fallback,
548
554
  callerBasedir,
549
555
  npm_package_json: process2.env.npm_package_json,
550
- cwd: process2.cwd(),
556
+ cwd,
551
557
  anchor
552
558
  });
553
559
  }
554
560
  if (basedir && basedir.trim().length > 0) {
555
- if (path3.isAbsolute(basedir)) {
556
- return path3.normalize(basedir);
557
- }
558
- return path3.resolve(anchor, basedir);
561
+ return resolveRelative(basedir);
559
562
  }
560
563
  if (envBasedir && !envBasedirIsGeneric) {
561
564
  return path3.normalize(envBasedir);
562
565
  }
563
566
  if (fallback && fallback.trim().length > 0) {
564
- const resolvedFallback = path3.isAbsolute(fallback) ? fallback : path3.resolve(anchor, fallback);
565
- return path3.normalize(resolvedFallback);
567
+ return resolveRelative(fallback);
566
568
  }
567
569
  if (packageEnvBasedir) {
568
570
  return path3.normalize(packageEnvBasedir);
@@ -599,24 +601,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
599
601
  if (envBasedir) {
600
602
  return path3.normalize(envBasedir);
601
603
  }
602
- return path3.normalize(process2.cwd());
603
- }
604
- function findNearestPackageRootFromDir(startDir) {
605
- if (!startDir) {
606
- return void 0;
607
- }
608
- let current = path3.resolve(startDir);
609
- while (true) {
610
- const pkgPath = path3.join(current, "package.json");
611
- if (existsSync3(pkgPath)) {
612
- return current;
613
- }
614
- const parent = path3.dirname(current);
615
- if (parent === current) {
616
- return void 0;
617
- }
618
- current = parent;
619
- }
604
+ return path3.normalize(cwd);
620
605
  }
621
606
  function guessBasedirFromEntries(entries) {
622
607
  if (!entries) {
@@ -631,7 +616,7 @@ function guessBasedirFromEntries(entries) {
631
616
  continue;
632
617
  }
633
618
  const entryDir = path3.dirname(trimmed);
634
- const resolved = findNearestPackageRootFromDir(entryDir) ?? entryDir;
619
+ const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
635
620
  if (resolved) {
636
621
  return resolved;
637
622
  }
@@ -656,10 +641,37 @@ function normalizeCssEntries(entries, anchor) {
656
641
  }
657
642
  return normalized.size > 0 ? [...normalized] : void 0;
658
643
  }
659
- function groupCssEntriesByBase(entries) {
644
+ function isSubPath(parent, child) {
645
+ if (!parent || !child) {
646
+ return false;
647
+ }
648
+ const relative = path3.relative(parent, child);
649
+ return relative === "" || !relative.startsWith("..") && !path3.isAbsolute(relative);
650
+ }
651
+ function resolveCssEntryBase(entryDir, options) {
652
+ const normalizedDir = path3.normalize(entryDir);
653
+ const { preferredBaseDir, workspaceRoot } = options;
654
+ if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) {
655
+ return preferredBaseDir;
656
+ }
657
+ if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) {
658
+ return workspaceRoot;
659
+ }
660
+ const packageRoot = findNearestPackageRoot(normalizedDir);
661
+ if (packageRoot) {
662
+ return path3.normalize(packageRoot);
663
+ }
664
+ return normalizedDir;
665
+ }
666
+ function groupCssEntriesByBase(entries, options = {}) {
667
+ const normalizedOptions = {
668
+ preferredBaseDir: options.preferredBaseDir ? path3.normalize(options.preferredBaseDir) : void 0,
669
+ workspaceRoot: options.workspaceRoot ? path3.normalize(options.workspaceRoot) : void 0
670
+ };
660
671
  const groups = /* @__PURE__ */ new Map();
661
672
  for (const entry of entries) {
662
- const baseDir = path3.normalize(path3.dirname(entry));
673
+ const entryDir = path3.dirname(entry);
674
+ const baseDir = resolveCssEntryBase(entryDir, normalizedOptions);
663
675
  const bucket = groups.get(baseDir);
664
676
  if (bucket) {
665
677
  bucket.push(entry);
@@ -889,7 +901,11 @@ function createTailwindcssPatcherFromContext(ctx) {
889
901
  supportCustomLengthUnitsPatch,
890
902
  appType
891
903
  };
892
- const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries) : void 0;
904
+ const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
905
+ const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
906
+ preferredBaseDir: resolvedTailwindcssBasedir,
907
+ workspaceRoot
908
+ }) : void 0;
893
909
  const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
894
910
  if (multiPatcher) {
895
911
  return multiPatcher;
@@ -909,7 +925,14 @@ function createTailwindcssPatcherFromContext(ctx) {
909
925
  );
910
926
  }
911
927
 
928
+ // src/logger/index.ts
929
+ import { logger as logger3 } from "@weapp-tailwindcss/logger";
930
+
912
931
  export {
932
+ findWorkspaceRoot,
933
+ findNearestPackageRoot,
934
+ getTailwindcssPackageInfo,
913
935
  resolveTailwindcssBasedir,
914
- createTailwindcssPatcherFromContext
936
+ createTailwindcssPatcherFromContext,
937
+ logger3 as logger
915
938
  };
@@ -1,24 +1,26 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkUCA2DMVNjs = require('./chunk-UCA2DMVN.js');
4
+ var _chunkOR5KGJ46js = require('./chunk-OR5KGJ46.js');
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkH34KPZQWjs = require('./chunk-H34KPZQW.js');
10
+ var _chunkAB45L5FPjs = require('./chunk-AB45L5FP.js');
11
11
 
12
12
 
13
13
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
14
14
 
15
15
 
16
+ var _chunkR6ERGDBQjs = require('./chunk-R6ERGDBQ.js');
16
17
 
17
18
 
18
19
 
19
20
 
20
21
 
21
- var _chunkPLV4QGF4js = require('./chunk-PLV4QGF4.js');
22
+
23
+ var _chunkYKMZHWQ4js = require('./chunk-YKMZHWQ4.js');
22
24
 
23
25
 
24
26
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -27,11 +29,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
27
29
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
28
30
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
29
31
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
30
- var debug = _chunkPLV4QGF4js.createDebug.call(void 0, );
31
- var weappTailwindcssPackageDir = _chunkH34KPZQWjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
32
+ var debug = _chunkYKMZHWQ4js.createDebug.call(void 0, );
33
+ var weappTailwindcssPackageDir = _chunkAB45L5FPjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
32
34
  var UnifiedWebpackPluginV5 = class {
33
35
  constructor(options = {}) {
34
- this.options = _chunkPLV4QGF4js.getCompilerContext.call(void 0, options);
36
+ this.options = _chunkYKMZHWQ4js.getCompilerContext.call(void 0, options);
35
37
  this.userSpecifiedRewriteCssImports = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
36
38
  this.appType = this.options.appType;
37
39
  }
@@ -56,25 +58,30 @@ var UnifiedWebpackPluginV5 = class {
56
58
  }
57
59
  const shouldRewriteCssImports = this.options.rewriteCssImports !== false && (this.userSpecifiedRewriteCssImports || (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4);
58
60
  if (shouldRewriteCssImports) {
59
- _chunkUCA2DMVNjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
61
+ _chunkOR5KGJ46js.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
60
62
  pkgDir: weappTailwindcssPackageDir,
61
63
  enabled: true
62
64
  });
63
65
  }
66
+ const patchRecorderState = _chunkR6ERGDBQjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
67
+ source: "runtime",
68
+ cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
69
+ });
64
70
  const runtimeState = {
65
71
  twPatcher: initialTwPatcher,
66
- patchPromise: _chunkPLV4QGF4js.createTailwindPatchPromise.call(void 0, initialTwPatcher),
67
- refreshTailwindcssPatcher
72
+ patchPromise: patchRecorderState.patchPromise,
73
+ refreshTailwindcssPatcher,
74
+ onPatchCompleted: patchRecorderState.onPatchCompleted
68
75
  };
69
76
  const refreshRuntimeState = async (force) => {
70
- await _chunkPLV4QGF4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
77
+ await _chunkYKMZHWQ4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
71
78
  };
72
79
  const { Compilation, sources, NormalModule } = compiler.webpack;
73
80
  const { ConcatSource } = sources;
74
81
  async function getClassSetInLoader() {
75
82
  await refreshRuntimeState(true);
76
83
  await runtimeState.patchPromise;
77
- await _chunkPLV4QGF4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
84
+ await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
78
85
  }
79
86
  onLoad();
80
87
  const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
@@ -92,8 +99,8 @@ var UnifiedWebpackPluginV5 = class {
92
99
  ident: null,
93
100
  type: null
94
101
  });
95
- compiler.hooks.compilation.tap(_chunkPLV4QGF4js.pluginName, (compilation) => {
96
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkPLV4QGF4js.pluginName, (_loaderContext, module) => {
102
+ compiler.hooks.compilation.tap(_chunkYKMZHWQ4js.pluginName, (compilation) => {
103
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkYKMZHWQ4js.pluginName, (_loaderContext, module) => {
97
104
  if (isExisted) {
98
105
  const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
99
106
  const runtimeLoaderEntry = createRuntimeLoaderEntry();
@@ -106,7 +113,7 @@ var UnifiedWebpackPluginV5 = class {
106
113
  });
107
114
  compilation.hooks.processAssets.tapPromise(
108
115
  {
109
- name: _chunkPLV4QGF4js.pluginName,
116
+ name: _chunkYKMZHWQ4js.pluginName,
110
117
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
111
118
  },
112
119
  async (assets) => {
@@ -124,13 +131,13 @@ var UnifiedWebpackPluginV5 = class {
124
131
  const jsAssets = /* @__PURE__ */ new Map();
125
132
  for (const [file] of entries) {
126
133
  if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
127
- const absolute = _chunkH34KPZQWjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
134
+ const absolute = _chunkAB45L5FPjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
128
135
  jsAssets.set(absolute, file);
129
136
  }
130
137
  }
131
138
  const moduleGraphOptions = {
132
139
  resolve(specifier, importer) {
133
- return _chunkH34KPZQWjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
140
+ return _chunkAB45L5FPjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
134
141
  },
135
142
  load: (id) => {
136
143
  const assetName = jsAssets.get(id);
@@ -175,7 +182,7 @@ var UnifiedWebpackPluginV5 = class {
175
182
  const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
176
183
  await refreshRuntimeState(true);
177
184
  await runtimeState.patchPromise;
178
- const runtimeSet = await _chunkPLV4QGF4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
185
+ const runtimeSet = await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
179
186
  debug("get runtimeSet, class count: %d", runtimeSet.size);
180
187
  const tasks = [];
181
188
  if (Array.isArray(groupedEntries.html)) {
@@ -212,12 +219,12 @@ var UnifiedWebpackPluginV5 = class {
212
219
  const jsTaskFactories = [];
213
220
  if (Array.isArray(groupedEntries.js)) {
214
221
  for (const [file] of groupedEntries.js) {
215
- const cacheKey = _chunkUCA2DMVNjs.getCacheKey.call(void 0, file);
222
+ const cacheKey = _chunkOR5KGJ46js.getCacheKey.call(void 0, file);
216
223
  const asset = compilation.getAsset(file);
217
224
  if (!asset) {
218
225
  continue;
219
226
  }
220
- const absoluteFile = _chunkH34KPZQWjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
227
+ const absoluteFile = _chunkAB45L5FPjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
221
228
  const initialSource = asset.source.source();
222
229
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
223
230
  jsTaskFactories.push(async () => {
@@ -292,7 +299,7 @@ var UnifiedWebpackPluginV5 = class {
292
299
  );
293
300
  }
294
301
  }
295
- _chunkH34KPZQWjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
302
+ _chunkAB45L5FPjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
296
303
  await Promise.all(tasks);
297
304
  debug("end");
298
305
  onEnd();
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.53.1_@types+node@24.10.1__@swc+core@1.15.3_@swc+h_5a981c295142658a01fde01f36b7c0a8/node_modules/tsup/assets/esm_shims.js
9
2
  import path from "path";
10
3
  import { fileURLToPath } from "url";
@@ -13,6 +6,5 @@ var getDirname = () => path.dirname(getFilename());
13
6
  var __dirname = /* @__PURE__ */ getDirname();
14
7
 
15
8
  export {
16
- __require,
17
9
  __dirname
18
10
  };
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkUJIUFWXEjs = require('./chunk-UJIUFWXE.js');
3
+ var _chunkUTZLVU3Mjs = require('./chunk-UTZLVU3M.js');
4
4
 
5
5
  // src/utils/resolve-package.ts
6
6
  var _module = require('module');
7
7
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
- var require2 = _module.createRequire.call(void 0, _chunkUJIUFWXEjs.importMetaUrl);
8
+ var require2 = _module.createRequire.call(void 0, _chunkUTZLVU3Mjs.importMetaUrl);
9
9
  function resolvePackageDir(name) {
10
10
  const pkgPath = require2.resolve(`${name}/package.json`);
11
11
  return _path2.default.dirname(pkgPath);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  applyTailwindcssCssImportRewrite,
3
3
  getCacheKey
4
- } from "./chunk-KSHK56CW.mjs";
4
+ } from "./chunk-EQP3XJUM.mjs";
5
5
  import {
6
6
  pushConcurrentTaskFactories,
7
7
  resolveOutputSpecifier,
@@ -11,20 +11,22 @@ import {
11
11
  import {
12
12
  processCachedTask
13
13
  } from "./chunk-RRHPTTCP.mjs";
14
+ import {
15
+ setupPatchRecorder
16
+ } from "./chunk-GBKTM7HE.mjs";
14
17
  import {
15
18
  collectRuntimeClassSet,
16
19
  createDebug,
17
- createTailwindPatchPromise,
18
20
  getCompilerContext,
19
21
  pluginName,
20
22
  refreshTailwindRuntimeState
21
- } from "./chunk-WTOLVORM.mjs";
23
+ } from "./chunk-T25LQFYZ.mjs";
22
24
  import {
23
25
  getGroupedEntries
24
26
  } from "./chunk-ZNKIYZRQ.mjs";
25
27
  import {
26
28
  __dirname
27
- } from "./chunk-QGH4JZRW.mjs";
29
+ } from "./chunk-67CD2S5L.mjs";
28
30
 
29
31
  // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
30
32
  import fs from "fs";
@@ -64,10 +66,15 @@ var UnifiedWebpackPluginV5 = class {
64
66
  enabled: true
65
67
  });
66
68
  }
69
+ const patchRecorderState = setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
70
+ source: "runtime",
71
+ cwd: this.options.tailwindcssBasedir ?? process.cwd()
72
+ });
67
73
  const runtimeState = {
68
74
  twPatcher: initialTwPatcher,
69
- patchPromise: createTailwindPatchPromise(initialTwPatcher),
70
- refreshTailwindcssPatcher
75
+ patchPromise: patchRecorderState.patchPromise,
76
+ refreshTailwindcssPatcher,
77
+ onPatchCompleted: patchRecorderState.onPatchCompleted
71
78
  };
72
79
  const refreshRuntimeState = async (force) => {
73
80
  await refreshTailwindRuntimeState(runtimeState, force);
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-JW7P34IH.mjs";
4
4
  import {
5
5
  pluginName
6
- } from "./chunk-WTOLVORM.mjs";
6
+ } from "./chunk-T25LQFYZ.mjs";
7
7
 
8
8
  // src/bundlers/webpack/shared/css-imports.ts
9
9
  var CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
@@ -0,0 +1,29 @@
1
+ import {
2
+ createPatchTargetRecorder,
3
+ createTailwindPatchPromise
4
+ } from "./chunk-T25LQFYZ.mjs";
5
+ import {
6
+ logger
7
+ } from "./chunk-3XGTIDA6.mjs";
8
+
9
+ // src/tailwindcss/recorder.ts
10
+ function setupPatchRecorder(patcher, baseDir, options) {
11
+ const recorder = createPatchTargetRecorder(baseDir, patcher, options);
12
+ if (recorder?.message && options?.logMessage !== false) {
13
+ const prefix = options?.messagePrefix ? `${options.messagePrefix} ` : "";
14
+ logger.info("%s%s", prefix, recorder.message);
15
+ }
16
+ const onPatchCompleted = recorder?.onPatched ? async () => {
17
+ await recorder.onPatched();
18
+ } : void 0;
19
+ const patchPromise = patcher ? createTailwindPatchPromise(patcher, onPatchCompleted) : Promise.resolve();
20
+ return {
21
+ recorder,
22
+ patchPromise,
23
+ onPatchCompleted
24
+ };
25
+ }
26
+
27
+ export {
28
+ setupPatchRecorder
29
+ };
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  processCachedTask
3
3
  } from "./chunk-RRHPTTCP.mjs";
4
+ import {
5
+ setupPatchRecorder
6
+ } from "./chunk-GBKTM7HE.mjs";
4
7
  import {
5
8
  collectRuntimeClassSet,
6
9
  createDebug,
7
- createTailwindPatchPromise,
8
10
  getCompilerContext,
9
11
  refreshTailwindRuntimeState
10
- } from "./chunk-WTOLVORM.mjs";
12
+ } from "./chunk-T25LQFYZ.mjs";
11
13
 
12
14
  // src/bundlers/gulp/index.ts
13
15
  import { Buffer } from "buffer";
@@ -20,11 +22,16 @@ var Transform = stream.Transform;
20
22
  function createPlugins(options = {}) {
21
23
  const opts = getCompilerContext(options);
22
24
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
25
+ const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
26
+ source: "runtime",
27
+ cwd: opts.tailwindcssBasedir ?? process.cwd()
28
+ });
23
29
  let runtimeSet = /* @__PURE__ */ new Set();
24
30
  const runtimeState = {
25
31
  twPatcher: initialTwPatcher,
26
- patchPromise: createTailwindPatchPromise(initialTwPatcher),
27
- refreshTailwindcssPatcher
32
+ patchPromise: patchRecorderState.patchPromise,
33
+ refreshTailwindcssPatcher,
34
+ onPatchCompleted: patchRecorderState.onPatchCompleted
28
35
  };
29
36
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
30
37
  let runtimeSetInitialized = false;
@@ -9,18 +9,20 @@ import {
9
9
  import {
10
10
  processCachedTask
11
11
  } from "./chunk-RRHPTTCP.mjs";
12
+ import {
13
+ setupPatchRecorder
14
+ } from "./chunk-GBKTM7HE.mjs";
12
15
  import {
13
16
  collectRuntimeClassSet,
14
17
  createAttributeMatcher,
15
18
  createDebug,
16
- createTailwindPatchPromise,
17
19
  generateCode,
18
20
  getCompilerContext,
19
21
  refreshTailwindRuntimeState,
20
22
  replaceWxml,
21
23
  toCustomAttributesEntities,
22
24
  vitePluginName
23
- } from "./chunk-WTOLVORM.mjs";
25
+ } from "./chunk-T25LQFYZ.mjs";
24
26
  import {
25
27
  getGroupedEntries
26
28
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -322,10 +324,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
322
324
  return;
323
325
  }
324
326
  const customAttributesEntities = toCustomAttributesEntities(customAttributes);
327
+ const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
328
+ source: "runtime",
329
+ cwd: opts.tailwindcssBasedir ?? process2.cwd()
330
+ });
325
331
  const runtimeState = {
326
332
  twPatcher: initialTwPatcher,
327
- patchPromise: createTailwindPatchPromise(initialTwPatcher),
328
- refreshTailwindcssPatcher
333
+ patchPromise: patchRecorderState.patchPromise,
334
+ refreshTailwindcssPatcher,
335
+ onPatchCompleted: patchRecorderState.onPatchCompleted
329
336
  };
330
337
  let runtimeSet;
331
338
  let runtimeSetPromise;
@@ -366,28 +373,34 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
366
373
  {
367
374
  name: `${vitePluginName}:rewrite-css-imports`,
368
375
  enforce: "pre",
369
- resolveId(id, importer) {
370
- const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, { join: joinPosixPath });
371
- if (!replacement) {
372
- return null;
373
- }
374
- if (importer && !isCssLikeImporter(importer)) {
375
- return null;
376
+ resolveId: {
377
+ order: "pre",
378
+ handler(id, importer) {
379
+ const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, { join: joinPosixPath });
380
+ if (!replacement) {
381
+ return null;
382
+ }
383
+ if (importer && !isCssLikeImporter(importer)) {
384
+ return null;
385
+ }
386
+ return replacement;
376
387
  }
377
- return replacement;
378
388
  },
379
- transform(code, id) {
380
- if (!isCSSRequest(id)) {
381
- return null;
382
- }
383
- const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, { join: joinPosixPath });
384
- if (!rewritten) {
385
- return null;
389
+ transform: {
390
+ order: "pre",
391
+ handler(code, id) {
392
+ if (!isCSSRequest(id)) {
393
+ return null;
394
+ }
395
+ const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, { join: joinPosixPath });
396
+ if (!rewritten) {
397
+ return null;
398
+ }
399
+ return {
400
+ code: rewritten,
401
+ map: null
402
+ };
386
403
  }
387
- return {
388
- code: rewritten,
389
- map: null
390
- };
391
404
  }
392
405
  }
393
406
  ];
@@ -3,11 +3,13 @@
3
3
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
4
4
 
5
5
 
6
+ var _chunkR6ERGDBQjs = require('./chunk-R6ERGDBQ.js');
6
7
 
7
8
 
8
9
 
9
10
 
10
- var _chunkPLV4QGF4js = require('./chunk-PLV4QGF4.js');
11
+
12
+ var _chunkYKMZHWQ4js = require('./chunk-YKMZHWQ4.js');
11
13
 
12
14
  // src/bundlers/gulp/index.ts
13
15
  var _buffer = require('buffer');
@@ -15,21 +17,26 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
15
17
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
16
18
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
17
19
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
18
- var debug = _chunkPLV4QGF4js.createDebug.call(void 0, );
20
+ var debug = _chunkYKMZHWQ4js.createDebug.call(void 0, );
19
21
  var Transform = _stream2.default.Transform;
20
22
  function createPlugins(options = {}) {
21
- const opts = _chunkPLV4QGF4js.getCompilerContext.call(void 0, options);
23
+ const opts = _chunkYKMZHWQ4js.getCompilerContext.call(void 0, options);
22
24
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
25
+ const patchRecorderState = _chunkR6ERGDBQjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
26
+ source: "runtime",
27
+ cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
28
+ });
23
29
  let runtimeSet = /* @__PURE__ */ new Set();
24
30
  const runtimeState = {
25
31
  twPatcher: initialTwPatcher,
26
- patchPromise: _chunkPLV4QGF4js.createTailwindPatchPromise.call(void 0, initialTwPatcher),
27
- refreshTailwindcssPatcher
32
+ patchPromise: patchRecorderState.patchPromise,
33
+ refreshTailwindcssPatcher,
34
+ onPatchCompleted: patchRecorderState.onPatchCompleted
28
35
  };
29
36
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
30
37
  let runtimeSetInitialized = false;
31
38
  async function refreshRuntimeState(force) {
32
- await _chunkPLV4QGF4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
39
+ await _chunkYKMZHWQ4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
33
40
  }
34
41
  async function refreshRuntimeSet(force = false) {
35
42
  await refreshRuntimeState(force);
@@ -37,7 +44,7 @@ function createPlugins(options = {}) {
37
44
  if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
38
45
  return runtimeSet;
39
46
  }
40
- runtimeSet = await _chunkPLV4QGF4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
47
+ runtimeSet = await _chunkYKMZHWQ4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
41
48
  runtimeSetInitialized = true;
42
49
  return runtimeSet;
43
50
  }