weapp-tailwindcss 4.10.3 → 4.11.0-alpha.1

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 (64) hide show
  1. package/dist/{chunk-3XVUGMTY.mjs → chunk-2LH6PZH3.mjs} +8 -4
  2. package/dist/{chunk-3WUHHFLF.mjs → chunk-35EI5JMK.mjs} +4 -2
  3. package/dist/{chunk-RYC23C3K.js → chunk-4LPOQMFS.js} +203 -198
  4. package/dist/{chunk-5U24PLVV.js → chunk-ACTJYB33.js} +4 -2
  5. package/dist/chunk-CZLXTEHN.js +1936 -0
  6. package/dist/{chunk-TNYEOBAC.mjs → chunk-DOH7FULQ.mjs} +1 -1
  7. package/dist/{chunk-E7775SFS.mjs → chunk-FZNYV7VH.mjs} +914 -334
  8. package/dist/{chunk-6Z4GEN2Y.js → chunk-G3G437UE.js} +2 -2
  9. package/dist/{chunk-DEIJXHGJ.js → chunk-G5NLM3AL.js} +978 -398
  10. package/dist/{chunk-W2N6G2QQ.js → chunk-GWDHNCL2.js} +60 -46
  11. package/dist/{chunk-QOTLDKI4.mjs → chunk-IEZ5RBMG.mjs} +197 -192
  12. package/dist/{chunk-RM3SY4S4.mjs → chunk-JBM3HGHP.mjs} +52 -12
  13. package/dist/{chunk-WXT2GI5R.mjs → chunk-KKT2DKMW.mjs} +30 -16
  14. package/dist/chunk-LD7LZ4IK.mjs +1933 -0
  15. package/dist/{chunk-GCRL3ZYP.js → chunk-NOKJXG3W.js} +5 -5
  16. package/dist/{chunk-YUTKX7JZ.js → chunk-OV7FX6XR.js} +1 -1
  17. package/dist/{chunk-SR4GC2F4.js → chunk-OYSABARD.js} +8 -4
  18. package/dist/{chunk-LICQ6EGN.mjs → chunk-QYZCRG7F.mjs} +2 -2
  19. package/dist/{chunk-UYTCZXNE.mjs → chunk-R6KEYO3F.mjs} +6 -5
  20. package/dist/{chunk-WF636Q5E.js → chunk-SQG2MOFQ.js} +10 -9
  21. package/dist/{chunk-L7OBNTRI.js → chunk-W2EMGF7H.js} +57 -17
  22. package/dist/cli.js +45 -42
  23. package/dist/cli.mjs +9 -6
  24. package/dist/core.d.mts +4 -3
  25. package/dist/core.d.ts +4 -3
  26. package/dist/core.js +124 -30
  27. package/dist/core.mjs +119 -25
  28. package/dist/css-macro/postcss.js +6 -5
  29. package/dist/css-macro/postcss.mjs +4 -3
  30. package/dist/css-macro.js +5 -5
  31. package/dist/css-macro.mjs +2 -2
  32. package/dist/defaults.js +3 -3
  33. package/dist/defaults.mjs +2 -2
  34. package/dist/escape.js +2 -1
  35. package/dist/escape.mjs +2 -1
  36. package/dist/gulp.d.mts +1 -1
  37. package/dist/gulp.d.ts +1 -1
  38. package/dist/gulp.js +8 -7
  39. package/dist/gulp.mjs +8 -7
  40. package/dist/index.js +11 -11
  41. package/dist/index.mjs +9 -9
  42. package/dist/postcss-html-transform.js +1 -1
  43. package/dist/postcss-html-transform.mjs +1 -1
  44. package/dist/presets.js +5 -5
  45. package/dist/presets.mjs +2 -2
  46. package/dist/reset.js +1 -1
  47. package/dist/reset.mjs +1 -1
  48. package/dist/types.js +1 -1
  49. package/dist/types.mjs +1 -1
  50. package/dist/vite.d.mts +1 -1
  51. package/dist/vite.d.ts +1 -1
  52. package/dist/vite.js +9 -8
  53. package/dist/vite.mjs +8 -7
  54. package/dist/webpack.d.mts +1 -1
  55. package/dist/webpack.d.ts +1 -1
  56. package/dist/webpack.js +10 -9
  57. package/dist/webpack.mjs +8 -7
  58. package/dist/webpack4.d.mts +1 -1
  59. package/dist/webpack4.d.ts +1 -1
  60. package/dist/webpack4.js +64 -49
  61. package/dist/webpack4.mjs +33 -18
  62. package/package.json +7 -7
  63. package/dist/chunk-PALDKVKG.mjs +0 -1291
  64. package/dist/chunk-YJSFFRNZ.js +0 -1291
@@ -5,6 +5,90 @@ import {
5
5
  // src/logger/index.ts
6
6
  import { logger } from "@weapp-tailwindcss/logger";
7
7
 
8
+ // src/context/workspace.ts
9
+ import { existsSync, readdirSync, readFileSync } from "fs";
10
+ import path from "path";
11
+ var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
12
+ "node_modules",
13
+ ".git",
14
+ ".hg",
15
+ ".svn",
16
+ ".turbo",
17
+ ".output",
18
+ ".next",
19
+ "dist",
20
+ "build"
21
+ ]);
22
+ function findWorkspaceRoot(startDir) {
23
+ if (!startDir) {
24
+ return void 0;
25
+ }
26
+ let current = path.resolve(startDir);
27
+ while (true) {
28
+ const workspaceFile = path.join(current, "pnpm-workspace.yaml");
29
+ if (existsSync(workspaceFile)) {
30
+ return current;
31
+ }
32
+ const parent = path.dirname(current);
33
+ if (parent === current) {
34
+ return void 0;
35
+ }
36
+ current = parent;
37
+ }
38
+ }
39
+ function findNearestPackageRoot(startDir) {
40
+ if (!startDir) {
41
+ return void 0;
42
+ }
43
+ let current = path.resolve(startDir);
44
+ while (true) {
45
+ const pkgPath = path.join(current, "package.json");
46
+ if (existsSync(pkgPath)) {
47
+ return current;
48
+ }
49
+ const parent = path.dirname(current);
50
+ if (parent === current) {
51
+ return void 0;
52
+ }
53
+ current = parent;
54
+ }
55
+ }
56
+ function findWorkspacePackageDir(rootDir, packageName) {
57
+ const visited = /* @__PURE__ */ new Set();
58
+ const queue = [path.resolve(rootDir)];
59
+ while (queue.length > 0) {
60
+ const current = queue.shift();
61
+ const normalized = path.normalize(current);
62
+ if (visited.has(normalized)) {
63
+ continue;
64
+ }
65
+ visited.add(normalized);
66
+ try {
67
+ const pkgPath = path.join(normalized, "package.json");
68
+ if (existsSync(pkgPath)) {
69
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
70
+ if (pkg?.name === packageName) {
71
+ return normalized;
72
+ }
73
+ }
74
+ } catch {
75
+ }
76
+ let entries;
77
+ try {
78
+ entries = readdirSync(normalized, { withFileTypes: true });
79
+ } catch {
80
+ continue;
81
+ }
82
+ for (const entry of entries) {
83
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) {
84
+ continue;
85
+ }
86
+ queue.push(path.join(normalized, entry.name));
87
+ }
88
+ }
89
+ return void 0;
90
+ }
91
+
8
92
  // src/tailwindcss/v4/config.ts
9
93
  import { logger as logger2 } from "@weapp-tailwindcss/logger";
10
94
  var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
@@ -115,100 +199,125 @@ function applyV4CssCalcDefaults(cssCalc, patcher) {
115
199
  return cssCalcOptions;
116
200
  }
117
201
 
118
- // src/tailwindcss/v4/patcher.ts
119
- import { logger as logger4 } from "@weapp-tailwindcss/logger";
120
-
121
- // src/tailwindcss/patcher.ts
122
- import path3 from "path";
123
- import process2 from "process";
124
- import { logger as logger3 } from "@weapp-tailwindcss/logger";
125
- import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
126
- import { TailwindcssPatcher } from "tailwindcss-patch";
127
-
128
- // src/context/workspace.ts
129
- import { existsSync, readdirSync, readFileSync } from "fs";
130
- import path from "path";
131
- var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
132
- "node_modules",
133
- ".git",
134
- ".hg",
135
- ".svn",
136
- ".turbo",
137
- ".output",
138
- ".next",
139
- "dist",
140
- "build"
141
- ]);
142
- function findWorkspaceRoot(startDir) {
143
- if (!startDir) {
202
+ // src/tailwindcss/patcher-resolve.ts
203
+ import { existsSync as existsSync2 } from "fs";
204
+ import { createRequire } from "module";
205
+ import path2 from "path";
206
+ import process from "process";
207
+ import { fileURLToPath } from "url";
208
+ var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
209
+ var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
210
+ "stubs/config.full.js",
211
+ "defaultConfig.js"
212
+ ];
213
+ var TAILWIND_CONFIG_FILES = [
214
+ "tailwind.config.js",
215
+ "tailwind.config.cjs",
216
+ "tailwind.config.mjs",
217
+ "tailwind.config.ts",
218
+ "tailwind.config.cts",
219
+ "tailwind.config.mts"
220
+ ];
221
+ function isPathSpecifier(specifier) {
222
+ if (!specifier) {
223
+ return false;
224
+ }
225
+ if (specifier.startsWith("file://")) {
226
+ return true;
227
+ }
228
+ if (path2.isAbsolute(specifier)) {
229
+ return true;
230
+ }
231
+ return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
232
+ }
233
+ function resolveModuleFromPaths(specifier, paths) {
234
+ if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
144
235
  return void 0;
145
236
  }
146
- let current = path.resolve(startDir);
147
- while (true) {
148
- const workspaceFile = path.join(current, "pnpm-workspace.yaml");
149
- if (existsSync(workspaceFile)) {
150
- return current;
151
- }
152
- const parent = path.dirname(current);
153
- if (parent === current) {
154
- return void 0;
155
- }
156
- current = parent;
237
+ try {
238
+ const req = createRequire(import.meta.url);
239
+ return req.resolve(specifier, { paths });
240
+ } catch {
241
+ return void 0;
157
242
  }
158
243
  }
159
- function findNearestPackageRoot(startDir) {
160
- if (!startDir) {
244
+ function resolveTailwindConfigFallback(packageName, paths) {
245
+ if (!packageName) {
161
246
  return void 0;
162
247
  }
163
- let current = path.resolve(startDir);
164
- while (true) {
165
- const pkgPath = path.join(current, "package.json");
166
- if (existsSync(pkgPath)) {
167
- return current;
168
- }
169
- const parent = path.dirname(current);
170
- if (parent === current) {
171
- return void 0;
248
+ for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
249
+ const candidate = `${packageName}/${suffix}`;
250
+ const resolved = resolveModuleFromPaths(candidate, paths);
251
+ if (resolved) {
252
+ return resolved;
172
253
  }
173
- current = parent;
174
254
  }
255
+ return void 0;
175
256
  }
176
- function findWorkspacePackageDir(rootDir, packageName) {
177
- const visited = /* @__PURE__ */ new Set();
178
- const queue = [path.resolve(rootDir)];
179
- while (queue.length > 0) {
180
- const current = queue.shift();
181
- const normalized = path.normalize(current);
182
- if (visited.has(normalized)) {
183
- continue;
184
- }
185
- visited.add(normalized);
186
- try {
187
- const pkgPath = path.join(normalized, "package.json");
188
- if (existsSync(pkgPath)) {
189
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
190
- if (pkg?.name === packageName) {
191
- return normalized;
192
- }
257
+ function appendNodeModules(paths, dir) {
258
+ if (!dir) {
259
+ return;
260
+ }
261
+ const nodeModulesDir = path2.join(dir, "node_modules");
262
+ if (existsSync2(nodeModulesDir)) {
263
+ paths.add(nodeModulesDir);
264
+ }
265
+ }
266
+ function findTailwindConfig(searchRoots) {
267
+ for (const root of searchRoots) {
268
+ for (const file of TAILWIND_CONFIG_FILES) {
269
+ const candidate = path2.resolve(root, file);
270
+ if (existsSync2(candidate)) {
271
+ return candidate;
193
272
  }
194
- } catch {
195
273
  }
196
- let entries;
197
- try {
198
- entries = readdirSync(normalized, { withFileTypes: true });
199
- } catch {
200
- continue;
274
+ }
275
+ return void 0;
276
+ }
277
+ function createDefaultResolvePaths(basedir) {
278
+ const paths = /* @__PURE__ */ new Set();
279
+ let fallbackCandidates = [];
280
+ if (basedir) {
281
+ const resolvedBase = path2.resolve(basedir);
282
+ appendNodeModules(paths, resolvedBase);
283
+ fallbackCandidates.push(resolvedBase);
284
+ const packageRoot = findNearestPackageRoot(resolvedBase);
285
+ if (packageRoot) {
286
+ appendNodeModules(paths, packageRoot);
287
+ fallbackCandidates.push(packageRoot);
201
288
  }
202
- for (const entry of entries) {
203
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) {
204
- continue;
205
- }
206
- queue.push(path.join(normalized, entry.name));
289
+ }
290
+ const cwd = process.cwd();
291
+ appendNodeModules(paths, cwd);
292
+ try {
293
+ const modulePath = fileURLToPath(import.meta.url);
294
+ const candidate = existsSync2(modulePath) && !path2.extname(modulePath) ? modulePath : path2.dirname(modulePath);
295
+ paths.add(candidate);
296
+ } catch {
297
+ paths.add(import.meta.url);
298
+ }
299
+ if (paths.size === 0) {
300
+ fallbackCandidates = fallbackCandidates.filter(Boolean);
301
+ if (fallbackCandidates.length === 0) {
302
+ fallbackCandidates.push(cwd);
303
+ }
304
+ for (const candidate of fallbackCandidates) {
305
+ paths.add(candidate);
207
306
  }
208
307
  }
209
- return void 0;
308
+ return [...paths];
210
309
  }
211
310
 
311
+ // src/tailwindcss/v4/patcher.ts
312
+ import { logger as logger4 } from "@weapp-tailwindcss/logger";
313
+
314
+ // src/tailwindcss/patcher.ts
315
+ import path3 from "path";
316
+ import process2 from "process";
317
+ import { logger as logger3 } from "@weapp-tailwindcss/logger";
318
+ import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
319
+ import { TailwindcssPatcher } from "tailwindcss-patch";
320
+
212
321
  // src/tailwindcss/patcher-options.ts
213
322
  function normalizeExtendLengthUnits(value) {
214
323
  if (value === false) {
@@ -360,115 +469,6 @@ function toModernTailwindcssPatchOptions(options) {
360
469
  return normalized;
361
470
  }
362
471
 
363
- // src/tailwindcss/patcher-resolve.ts
364
- import { existsSync as existsSync2 } from "fs";
365
- import { createRequire } from "module";
366
- import path2 from "path";
367
- import process from "process";
368
- import { fileURLToPath } from "url";
369
- var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
370
- var DEFAULT_TAILWIND_CONFIG_SPECIFIERS = [
371
- "stubs/config.full.js",
372
- "defaultConfig.js"
373
- ];
374
- var TAILWIND_CONFIG_FILES = [
375
- "tailwind.config.js",
376
- "tailwind.config.cjs",
377
- "tailwind.config.mjs",
378
- "tailwind.config.ts",
379
- "tailwind.config.cts",
380
- "tailwind.config.mts"
381
- ];
382
- function isPathSpecifier(specifier) {
383
- if (!specifier) {
384
- return false;
385
- }
386
- if (specifier.startsWith("file://")) {
387
- return true;
388
- }
389
- if (path2.isAbsolute(specifier)) {
390
- return true;
391
- }
392
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
393
- }
394
- function resolveModuleFromPaths(specifier, paths) {
395
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) {
396
- return void 0;
397
- }
398
- try {
399
- const req = createRequire(import.meta.url);
400
- return req.resolve(specifier, { paths });
401
- } catch {
402
- return void 0;
403
- }
404
- }
405
- function resolveTailwindConfigFallback(packageName, paths) {
406
- if (!packageName) {
407
- return void 0;
408
- }
409
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
410
- const candidate = `${packageName}/${suffix}`;
411
- const resolved = resolveModuleFromPaths(candidate, paths);
412
- if (resolved) {
413
- return resolved;
414
- }
415
- }
416
- return void 0;
417
- }
418
- function appendNodeModules(paths, dir) {
419
- if (!dir) {
420
- return;
421
- }
422
- const nodeModulesDir = path2.join(dir, "node_modules");
423
- if (existsSync2(nodeModulesDir)) {
424
- paths.add(nodeModulesDir);
425
- }
426
- }
427
- function findTailwindConfig(searchRoots) {
428
- for (const root of searchRoots) {
429
- for (const file of TAILWIND_CONFIG_FILES) {
430
- const candidate = path2.resolve(root, file);
431
- if (existsSync2(candidate)) {
432
- return candidate;
433
- }
434
- }
435
- }
436
- return void 0;
437
- }
438
- function createDefaultResolvePaths(basedir) {
439
- const paths = /* @__PURE__ */ new Set();
440
- let fallbackCandidates = [];
441
- if (basedir) {
442
- const resolvedBase = path2.resolve(basedir);
443
- appendNodeModules(paths, resolvedBase);
444
- fallbackCandidates.push(resolvedBase);
445
- const packageRoot = findNearestPackageRoot(resolvedBase);
446
- if (packageRoot) {
447
- appendNodeModules(paths, packageRoot);
448
- fallbackCandidates.push(packageRoot);
449
- }
450
- }
451
- const cwd = process.cwd();
452
- appendNodeModules(paths, cwd);
453
- try {
454
- const modulePath = fileURLToPath(import.meta.url);
455
- const candidate = existsSync2(modulePath) && !path2.extname(modulePath) ? modulePath : path2.dirname(modulePath);
456
- paths.add(candidate);
457
- } catch {
458
- paths.add(import.meta.url);
459
- }
460
- if (paths.size === 0) {
461
- fallbackCandidates = fallbackCandidates.filter(Boolean);
462
- if (fallbackCandidates.length === 0) {
463
- fallbackCandidates.push(cwd);
464
- }
465
- for (const candidate of fallbackCandidates) {
466
- paths.add(candidate);
467
- }
468
- }
469
- return [...paths];
470
- }
471
-
472
472
  // src/tailwindcss/patcher.ts
473
473
  function createFallbackTailwindcssPatcher() {
474
474
  const packageInfo = {
@@ -507,6 +507,8 @@ function createFallbackTailwindcssPatcher() {
507
507
  };
508
508
  }
509
509
  var hasLoggedMissingTailwind = false;
510
+ var TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
511
+ var UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
510
512
  function createTailwindcssPatcher(options) {
511
513
  const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
512
514
  const cache = {
@@ -580,7 +582,7 @@ function createTailwindcssPatcher(options) {
580
582
  const sourcePaths = customPaths ? existingResolve.paths : resolvePaths;
581
583
  resolvedTailwindOptions.resolve = {
582
584
  ...existingResolve,
583
- paths: Array.from(new Set(sourcePaths))
585
+ paths: [...new Set(sourcePaths)]
584
586
  };
585
587
  logger3.debug("Tailwind resolve config %O", {
586
588
  packageName: resolvedTailwindOptions.packageName,
@@ -628,14 +630,14 @@ function createTailwindcssPatcher(options) {
628
630
  return new TailwindcssPatcher(resolvedOptions);
629
631
  } catch (error) {
630
632
  const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
631
- if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
633
+ if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
632
634
  if (!hasLoggedMissingTailwind) {
633
635
  logger3.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
634
636
  hasLoggedMissingTailwind = true;
635
637
  }
636
638
  return createFallbackTailwindcssPatcher();
637
639
  }
638
- if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
640
+ if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) {
639
641
  logger3.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwindcss?.packageName, searchPaths);
640
642
  }
641
643
  throw error;
@@ -944,7 +946,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
944
946
  packageCandidates.add(
945
947
  mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss"
946
948
  );
947
- const patchers = Array.from(packageCandidates).map((packageName) => {
949
+ const patchers = Array.from(packageCandidates, (packageName) => {
948
950
  const tailwindOptionsForPackage = {
949
951
  ...mergedTailwindOptions,
950
952
  packageName
@@ -1012,6 +1014,8 @@ function pickPackageEnvBasedir() {
1012
1014
  }
1013
1015
  return void 0;
1014
1016
  }
1017
+ var STACK_PAREN_RE = /\(([^)]+)\)/u;
1018
+ var STACK_AT_RE = /at\s+(\S.*)$/u;
1015
1019
  function detectCallerBasedir() {
1016
1020
  const stack = new Error("resolveTailwindcssBasedir stack probe").stack;
1017
1021
  if (!stack) {
@@ -1022,7 +1026,7 @@ function detectCallerBasedir() {
1022
1026
  }
1023
1027
  const lines = stack.split("\n");
1024
1028
  for (const line of lines) {
1025
- const match = line.match(/\(([^)]+)\)/u) ?? line.match(/at\s+(\S.*)$/u);
1029
+ const match = line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE);
1026
1030
  const location = match?.[1];
1027
1031
  if (!location) {
1028
1032
  continue;
@@ -1255,6 +1259,7 @@ export {
1255
1259
  findNearestPackageRoot,
1256
1260
  warnMissingCssEntries,
1257
1261
  applyV4CssCalcDefaults,
1262
+ findTailwindConfig,
1258
1263
  resolveTailwindcssBasedir,
1259
1264
  createTailwindcssPatcherFromContext,
1260
1265
  logger
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-RRHPTTCP.mjs";
4
4
  import {
5
5
  setupPatchRecorder
6
- } from "./chunk-LICQ6EGN.mjs";
6
+ } from "./chunk-QYZCRG7F.mjs";
7
7
  import {
8
8
  createDebug,
9
9
  ensureRuntimeClassSet,
10
10
  getCompilerContext,
11
11
  refreshTailwindRuntimeState
12
- } from "./chunk-E7775SFS.mjs";
12
+ } from "./chunk-FZNYV7VH.mjs";
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  import { Buffer } from "buffer";
@@ -33,6 +33,10 @@ function createPlugins(options = {}) {
33
33
  refreshTailwindcssPatcher,
34
34
  onPatchCompleted: patchRecorderState.onPatchCompleted
35
35
  };
36
+ const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
37
+ let cachedDefaultTemplateHandlerOptions;
38
+ let cachedDefaultTemplateRuntimeSet;
39
+ let cachedDefaultModuleGraphOptions;
36
40
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
37
41
  let runtimeSetInitialized = false;
38
42
  async function refreshRuntimeState(force) {
@@ -108,6 +112,15 @@ function createPlugins(options = {}) {
108
112
  }
109
113
  };
110
114
  }
115
+ function resolveModuleGraphOptions(moduleGraph) {
116
+ if (moduleGraph) {
117
+ return moduleGraph;
118
+ }
119
+ if (!cachedDefaultModuleGraphOptions) {
120
+ cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
121
+ }
122
+ return cachedDefaultModuleGraphOptions;
123
+ }
111
124
  function createVinylTransform(handler) {
112
125
  return new Transform({
113
126
  objectMode: true,
@@ -121,6 +134,40 @@ function createPlugins(options = {}) {
121
134
  }
122
135
  });
123
136
  }
137
+ function resolveWxssHandlerOptions(options2) {
138
+ const majorVersion = runtimeState.twPatcher.majorVersion ?? "unknown";
139
+ if (!options2 || Object.keys(options2).length === 0) {
140
+ let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
141
+ if (!cached) {
142
+ cached = {
143
+ isMainChunk: true,
144
+ majorVersion: runtimeState.twPatcher.majorVersion
145
+ };
146
+ defaultStyleHandlerOptionsCache.set(majorVersion, cached);
147
+ }
148
+ return cached;
149
+ }
150
+ return {
151
+ isMainChunk: true,
152
+ majorVersion: runtimeState.twPatcher.majorVersion,
153
+ ...options2
154
+ };
155
+ }
156
+ function resolveWxmlHandlerOptions(options2) {
157
+ if (!options2 || Object.keys(options2).length === 0) {
158
+ if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
159
+ cachedDefaultTemplateRuntimeSet = runtimeSet;
160
+ cachedDefaultTemplateHandlerOptions = {
161
+ runtimeSet
162
+ };
163
+ }
164
+ return cachedDefaultTemplateHandlerOptions;
165
+ }
166
+ return {
167
+ runtimeSet,
168
+ ...options2
169
+ };
170
+ }
124
171
  const transformWxss = (options2 = {}) => createVinylTransform(async (file) => {
125
172
  if (!file.contents) {
126
173
  return;
@@ -140,11 +187,7 @@ function createPlugins(options = {}) {
140
187
  },
141
188
  async transform() {
142
189
  await runtimeState.patchPromise;
143
- const { css } = await styleHandler(rawSource, {
144
- isMainChunk: true,
145
- majorVersion: runtimeState.twPatcher.majorVersion,
146
- ...options2
147
- });
190
+ const { css } = await styleHandler(rawSource, resolveWxssHandlerOptions(options2));
148
191
  debug("css handle: %s", file.path);
149
192
  return {
150
193
  result: css
@@ -159,7 +202,7 @@ function createPlugins(options = {}) {
159
202
  await refreshRuntimeSet(false);
160
203
  await runtimeState.patchPromise;
161
204
  const filename = path.resolve(file.path);
162
- const moduleGraph = options2.moduleGraph ?? createModuleGraphOptionsFor();
205
+ const moduleGraph = resolveModuleGraphOptions(options2.moduleGraph);
163
206
  const handlerOptions = {
164
207
  ...options2,
165
208
  filename,
@@ -211,10 +254,7 @@ function createPlugins(options = {}) {
211
254
  },
212
255
  async transform() {
213
256
  await runtimeState.patchPromise;
214
- const code = await templateHandler(rawSource, {
215
- runtimeSet,
216
- ...options2
217
- });
257
+ const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options2));
218
258
  debug("html handle: %s", file.path);
219
259
  return {
220
260
  result: code