weapp-tailwindcss 4.10.1 → 4.10.3

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 (65) hide show
  1. package/dist/{chunk-IIDSY4XZ.js → chunk-6Z4GEN2Y.js} +2 -2
  2. package/dist/{chunk-7K3R5LV6.js → chunk-DEIJXHGJ.js} +252 -70
  3. package/dist/{chunk-RXM5ERRJ.mjs → chunk-E7775SFS.mjs} +212 -30
  4. package/dist/{chunk-RB7YN5XZ.js → chunk-GCRL3ZYP.js} +5 -5
  5. package/dist/{chunk-W3EZEDKD.js → chunk-L7OBNTRI.js} +8 -7
  6. package/dist/{chunk-4QCL7FBX.mjs → chunk-LICQ6EGN.mjs} +1 -1
  7. package/dist/{chunk-ESIT2XWD.mjs → chunk-PALDKVKG.mjs} +58 -5
  8. package/dist/{chunk-7ZI6WVIU.mjs → chunk-RM3SY4S4.mjs} +3 -2
  9. package/dist/{chunk-5APD2MNV.js → chunk-RYC23C3K.js} +4 -4
  10. package/dist/{chunk-HT76VHOV.mjs → chunk-TNYEOBAC.mjs} +1 -1
  11. package/dist/{chunk-GKT5AE7D.mjs → chunk-UYTCZXNE.mjs} +1 -1
  12. package/dist/{chunk-K7CTHHN2.js → chunk-W2N6G2QQ.js} +35 -34
  13. package/dist/{chunk-P65O2L27.js → chunk-WF636Q5E.js} +5 -5
  14. package/dist/{chunk-3BKE5AJQ.mjs → chunk-WXT2GI5R.mjs} +5 -4
  15. package/dist/{chunk-EE4DYM4E.js → chunk-YJSFFRNZ.js} +81 -28
  16. package/dist/{chunk-DBAAU4LK.js → chunk-YUTKX7JZ.js} +1 -1
  17. package/dist/cli.js +39 -39
  18. package/dist/cli.mjs +2 -2
  19. package/dist/core.d.mts +1 -1
  20. package/dist/core.d.ts +1 -1
  21. package/dist/core.js +24 -11
  22. package/dist/core.mjs +18 -5
  23. package/dist/css-macro/postcss.js +1 -1
  24. package/dist/css-macro/postcss.mjs +1 -1
  25. package/dist/css-macro.js +1 -1
  26. package/dist/css-macro.mjs +1 -1
  27. package/dist/defaults.d.mts +1 -1
  28. package/dist/defaults.d.ts +1 -1
  29. package/dist/defaults.js +1 -1
  30. package/dist/defaults.mjs +1 -1
  31. package/dist/gulp.d.mts +1 -1
  32. package/dist/gulp.d.ts +1 -1
  33. package/dist/gulp.js +6 -6
  34. package/dist/gulp.mjs +4 -4
  35. package/dist/{index-BESv5MWf.d.ts → index-t_VBjwYm.d.mts} +11 -0
  36. package/dist/{index-BESv5MWf.d.mts → index-t_VBjwYm.d.ts} +11 -0
  37. package/dist/index.d.mts +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +10 -10
  40. package/dist/index.mjs +7 -7
  41. package/dist/postcss-html-transform.js +1 -1
  42. package/dist/postcss-html-transform.mjs +1 -1
  43. package/dist/presets.d.mts +1 -1
  44. package/dist/presets.d.ts +1 -1
  45. package/dist/presets.js +5 -5
  46. package/dist/presets.mjs +1 -1
  47. package/dist/reset.js +1 -1
  48. package/dist/reset.mjs +1 -1
  49. package/dist/types.d.mts +14 -2
  50. package/dist/types.d.ts +14 -2
  51. package/dist/types.js +1 -1
  52. package/dist/types.mjs +1 -1
  53. package/dist/vite.d.mts +1 -1
  54. package/dist/vite.d.ts +1 -1
  55. package/dist/vite.js +7 -7
  56. package/dist/vite.mjs +4 -4
  57. package/dist/webpack.d.mts +1 -1
  58. package/dist/webpack.d.ts +1 -1
  59. package/dist/webpack.js +8 -8
  60. package/dist/webpack.mjs +5 -5
  61. package/dist/webpack4.d.mts +1 -1
  62. package/dist/webpack4.d.ts +1 -1
  63. package/dist/webpack4.js +36 -35
  64. package/dist/webpack4.mjs +5 -4
  65. package/package.json +5 -5
@@ -16,10 +16,10 @@ import {
16
16
  import _createDebug from "debug";
17
17
  var _debug = _createDebug("weapp-tw");
18
18
  function createDebug(prefix) {
19
- function debug2(formatter, ...args) {
19
+ function debug3(formatter, ...args) {
20
20
  return _debug((prefix ?? "") + formatter, ...args);
21
21
  }
22
- return debug2;
22
+ return debug3;
23
23
  }
24
24
 
25
25
  // src/tailwindcss/runtime/cache.ts
@@ -285,7 +285,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
285
285
  // package.json
286
286
  var package_default = {
287
287
  name: "weapp-tailwindcss",
288
- version: "4.10.1",
288
+ version: "4.10.3",
289
289
  description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
290
290
  author: "ice breaker <1324318532@qq.com>",
291
291
  license: "MIT",
@@ -480,7 +480,7 @@ var package_default = {
480
480
  "@babel/parser": "~7.29.0",
481
481
  "@babel/traverse": "~7.29.0",
482
482
  "@babel/types": "~7.29.0",
483
- "@tailwindcss-mangle/config": "^6.1.1",
483
+ "@tailwindcss-mangle/config": "^6.1.3",
484
484
  "@vue/compiler-dom": "catalog:vue3",
485
485
  "@vue/compiler-sfc": "catalog:vue3",
486
486
  "@weapp-core/escape": "~7.0.0",
@@ -1189,22 +1189,80 @@ import { jsStringEscape } from "@ast-core/escape";
1189
1189
  import { escapeStringRegexp as escapeStringRegexp2 } from "@weapp-core/regex";
1190
1190
  import { splitCode } from "@weapp-tailwindcss/shared/extractors";
1191
1191
 
1192
+ // src/wxml/shared.ts
1193
+ import { escape, MappingChars2String } from "@weapp-core/escape";
1194
+ function replaceWxml(original, options = {
1195
+ keepEOL: false,
1196
+ escapeMap: MappingChars2String
1197
+ }) {
1198
+ const { keepEOL, escapeMap, ignoreHead } = options;
1199
+ let res = original;
1200
+ if (!keepEOL) {
1201
+ res = res.replaceAll(/[\n\r]+/g, "");
1202
+ }
1203
+ res = escape(res, {
1204
+ map: escapeMap,
1205
+ ignoreHead
1206
+ });
1207
+ return res;
1208
+ }
1209
+
1192
1210
  // src/shared/classname-transform.ts
1193
- function shouldTransformClassNameCandidate(candidate, {
1211
+ function isArbitraryValueCandidate(candidate) {
1212
+ const normalized = candidate.trim();
1213
+ if (!normalized.includes("[") || !normalized.includes("]")) {
1214
+ return false;
1215
+ }
1216
+ if (/^(?:https?:)?\/\//.test(normalized)) {
1217
+ return false;
1218
+ }
1219
+ return true;
1220
+ }
1221
+ function shouldEnableArbitraryValueFallback({
1222
+ classNameSet,
1223
+ jsArbitraryValueFallback,
1224
+ tailwindcssMajorVersion
1225
+ }) {
1226
+ if (jsArbitraryValueFallback === true) {
1227
+ return true;
1228
+ }
1229
+ if (jsArbitraryValueFallback === false) {
1230
+ return false;
1231
+ }
1232
+ return tailwindcssMajorVersion === 4 && (!classNameSet || classNameSet.size === 0);
1233
+ }
1234
+ function resolveClassNameTransformDecision(candidate, {
1194
1235
  alwaysEscape,
1195
1236
  classNameSet,
1196
- jsPreserveClass
1237
+ escapeMap,
1238
+ jsArbitraryValueFallback,
1239
+ jsPreserveClass,
1240
+ tailwindcssMajorVersion,
1241
+ classContext
1197
1242
  }) {
1198
1243
  if (alwaysEscape) {
1199
- return true;
1244
+ return "direct";
1200
1245
  }
1201
1246
  if (jsPreserveClass?.(candidate)) {
1202
- return false;
1247
+ return "skip";
1203
1248
  }
1204
- if (!classNameSet || classNameSet.size === 0) {
1205
- return false;
1249
+ if (classNameSet?.has(candidate)) {
1250
+ return "direct";
1251
+ }
1252
+ if (classNameSet && classNameSet.size > 0) {
1253
+ const escapedCandidate = replaceWxml(candidate, { escapeMap });
1254
+ if (escapedCandidate !== candidate && classNameSet.has(escapedCandidate)) {
1255
+ return "escaped";
1256
+ }
1257
+ }
1258
+ if (classContext && isArbitraryValueCandidate(candidate) && shouldEnableArbitraryValueFallback({
1259
+ classNameSet,
1260
+ jsArbitraryValueFallback,
1261
+ tailwindcssMajorVersion
1262
+ })) {
1263
+ return "fallback";
1206
1264
  }
1207
- return classNameSet.has(candidate);
1265
+ return "skip";
1208
1266
  }
1209
1267
 
1210
1268
  // src/utils/decode.ts
@@ -1230,25 +1288,105 @@ function decodeUnicode2(input) {
1230
1288
  }
1231
1289
  }
1232
1290
 
1233
- // src/wxml/shared.ts
1234
- import { escape, MappingChars2String } from "@weapp-core/escape";
1235
- function replaceWxml(original, options = {
1236
- keepEOL: false,
1237
- escapeMap: MappingChars2String
1238
- }) {
1239
- const { keepEOL, escapeMap, ignoreHead } = options;
1240
- let res = original;
1241
- if (!keepEOL) {
1242
- res = res.replaceAll(/[\n\r]+/g, "");
1291
+ // src/js/class-context.ts
1292
+ var CLASS_LIKE_KEYWORDS = /* @__PURE__ */ new Set([
1293
+ "class",
1294
+ "classname",
1295
+ "hoverclass",
1296
+ "virtualhostclass",
1297
+ "rootclass"
1298
+ ]);
1299
+ var CLASS_HELPER_IDENTIFIERS = /* @__PURE__ */ new Set([
1300
+ "cn",
1301
+ "clsx",
1302
+ "classnames",
1303
+ "twmerge",
1304
+ "cva",
1305
+ "tv",
1306
+ "cx",
1307
+ "r"
1308
+ ]);
1309
+ function normalizeKeyword(name) {
1310
+ return name.replace(/[-_:]/g, "").toLowerCase();
1311
+ }
1312
+ function readObjectKeyName(path5) {
1313
+ if (path5.isIdentifier()) {
1314
+ return path5.node.name;
1243
1315
  }
1244
- res = escape(res, {
1245
- map: escapeMap,
1246
- ignoreHead
1247
- });
1248
- return res;
1316
+ if (path5.isStringLiteral()) {
1317
+ return path5.node.value;
1318
+ }
1319
+ if (path5.isTemplateLiteral() && path5.node.expressions.length === 0) {
1320
+ return path5.node.quasis[0]?.value.cooked ?? path5.node.quasis[0]?.value.raw;
1321
+ }
1322
+ return void 0;
1323
+ }
1324
+ function isClassLikeObjectProperty(path5, valuePath) {
1325
+ if (!path5.isObjectProperty()) {
1326
+ return false;
1327
+ }
1328
+ if (path5.get("value") !== valuePath) {
1329
+ return false;
1330
+ }
1331
+ const keyName = readObjectKeyName(path5.get("key"));
1332
+ if (!keyName) {
1333
+ return false;
1334
+ }
1335
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(keyName));
1336
+ }
1337
+ function isClassLikeJsxAttribute(path5) {
1338
+ if (!path5.isJSXAttribute()) {
1339
+ return false;
1340
+ }
1341
+ const namePath = path5.get("name");
1342
+ if (!namePath.isJSXIdentifier()) {
1343
+ return false;
1344
+ }
1345
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(namePath.node.name));
1346
+ }
1347
+ function isClassLikeCallExpression(path5, valuePath) {
1348
+ if (!path5.isCallExpression()) {
1349
+ return false;
1350
+ }
1351
+ const args = path5.get("arguments");
1352
+ if (!args.includes(valuePath)) {
1353
+ return false;
1354
+ }
1355
+ const calleePath = path5.get("callee");
1356
+ if (calleePath.isIdentifier()) {
1357
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(calleePath.node.name));
1358
+ }
1359
+ if (calleePath.isMemberExpression()) {
1360
+ const propertyPath = calleePath.get("property");
1361
+ if (propertyPath.isIdentifier()) {
1362
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(propertyPath.node.name));
1363
+ }
1364
+ if (propertyPath.isStringLiteral()) {
1365
+ return CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(propertyPath.node.value));
1366
+ }
1367
+ }
1368
+ return false;
1369
+ }
1370
+ function isClassContextLiteralPath(path5) {
1371
+ let current = path5;
1372
+ while (current.parentPath) {
1373
+ const parent = current.parentPath;
1374
+ if (isClassLikeObjectProperty(parent, current)) {
1375
+ return true;
1376
+ }
1377
+ if (isClassLikeJsxAttribute(parent)) {
1378
+ return true;
1379
+ }
1380
+ if (isClassLikeCallExpression(parent, current)) {
1381
+ return true;
1382
+ }
1383
+ current = parent;
1384
+ }
1385
+ return false;
1249
1386
  }
1250
1387
 
1251
1388
  // src/js/handlers.ts
1389
+ var debug2 = createDebug("[js:handlers] ");
1252
1390
  var patternCache = /* @__PURE__ */ new Map();
1253
1391
  var replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
1254
1392
  var defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1313,7 +1451,9 @@ function replaceHandleValue(path5, options) {
1313
1451
  needEscaped = false
1314
1452
  } = options;
1315
1453
  const { classNameSet, alwaysEscape } = options;
1316
- if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
1454
+ const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
1455
+ const classContext = options.wrapExpression || isClassContextLiteralPath(path5);
1456
+ if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) {
1317
1457
  return void 0;
1318
1458
  }
1319
1459
  const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path5, options);
@@ -1326,10 +1466,32 @@ function replaceHandleValue(path5, options) {
1326
1466
  }
1327
1467
  let transformed = literal;
1328
1468
  let mutated = false;
1469
+ let matchedCandidateCount = 0;
1470
+ let escapedDecisionCount = 0;
1471
+ let fallbackDecisionCount = 0;
1472
+ const escapedSamples = [];
1473
+ const skippedSamples = [];
1329
1474
  for (const candidate of candidates) {
1330
- if (!shouldTransformClassNameCandidate(candidate, options)) {
1475
+ const decision = resolveClassNameTransformDecision(candidate, {
1476
+ ...options,
1477
+ classContext
1478
+ });
1479
+ if (decision === "skip") {
1480
+ if (skippedSamples.length < 6) {
1481
+ skippedSamples.push(candidate);
1482
+ }
1331
1483
  continue;
1332
1484
  }
1485
+ matchedCandidateCount += 1;
1486
+ if (decision === "escaped") {
1487
+ escapedDecisionCount += 1;
1488
+ if (escapedSamples.length < 6) {
1489
+ escapedSamples.push(candidate);
1490
+ }
1491
+ }
1492
+ if (decision === "fallback") {
1493
+ fallbackDecisionCount += 1;
1494
+ }
1333
1495
  if (!transformed.includes(candidate)) {
1334
1496
  continue;
1335
1497
  }
@@ -1345,6 +1507,18 @@ function replaceHandleValue(path5, options) {
1345
1507
  if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
1346
1508
  return void 0;
1347
1509
  }
1510
+ debug2(
1511
+ "runtimeSet size=%d fallbackTriggered=%s candidates=%d matched=%d escapedHits=%d skipped=%d file=%s escapedSamples=%s skippedSamples=%s",
1512
+ classNameSet?.size ?? 0,
1513
+ fallbackDecisionCount > 0,
1514
+ candidates.length,
1515
+ matchedCandidateCount,
1516
+ escapedDecisionCount,
1517
+ skippedSamples.length,
1518
+ options.filename ?? "unknown",
1519
+ escapedSamples.join(",") || "-",
1520
+ skippedSamples.join(",") || "-"
1521
+ );
1348
1522
  const start = node.start + offset;
1349
1523
  const end = node.end - offset;
1350
1524
  if (start >= end || transformed === original) {
@@ -2394,6 +2568,8 @@ function createJsHandler(options) {
2394
2568
  arbitraryValues,
2395
2569
  escapeMap,
2396
2570
  staleClassNameFallback,
2571
+ jsArbitraryValueFallback,
2572
+ tailwindcssMajorVersion,
2397
2573
  jsPreserveClass,
2398
2574
  generateMap,
2399
2575
  needEscaped,
@@ -2416,6 +2592,8 @@ function createJsHandler(options) {
2416
2592
  classNameSet,
2417
2593
  escapeMap,
2418
2594
  staleClassNameFallback,
2595
+ jsArbitraryValueFallback,
2596
+ tailwindcssMajorVersion,
2419
2597
  arbitraryValues,
2420
2598
  jsPreserveClass,
2421
2599
  generateMap,
@@ -2879,7 +3057,7 @@ function resolveRuntimePackageReplacements(option) {
2879
3057
  }
2880
3058
  return Object.keys(normalized).length > 0 ? normalized : void 0;
2881
3059
  }
2882
- function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
3060
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
2883
3061
  const {
2884
3062
  cssPreflight,
2885
3063
  cssPreflightRange,
@@ -2898,6 +3076,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2898
3076
  arbitraryValues,
2899
3077
  jsPreserveClass,
2900
3078
  staleClassNameFallback,
3079
+ jsArbitraryValueFallback,
2901
3080
  babelParserOptions,
2902
3081
  ignoreCallExpressionIdentifiers,
2903
3082
  ignoreTaggedTemplateExpressionIdentifiers,
@@ -2928,6 +3107,8 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
2928
3107
  arbitraryValues,
2929
3108
  jsPreserveClass,
2930
3109
  staleClassNameFallback,
3110
+ jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
3111
+ tailwindcssMajorVersion,
2931
3112
  generateMap: true,
2932
3113
  babelParserOptions,
2933
3114
  ignoreCallExpressionIdentifiers,
@@ -3029,7 +3210,8 @@ function createInternalCompilerContext(opts) {
3029
3210
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
3030
3211
  ctx,
3031
3212
  customAttributesEntities,
3032
- cssCalcOptions
3213
+ cssCalcOptions,
3214
+ twPatcher.majorVersion
3033
3215
  );
3034
3216
  ctx.styleHandler = styleHandler;
3035
3217
  ctx.jsHandler = jsHandler2;
@@ -1,22 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunk7K3R5LV6js = require('./chunk-7K3R5LV6.js');
4
+ var _chunkDEIJXHGJjs = require('./chunk-DEIJXHGJ.js');
5
5
 
6
6
 
7
- var _chunk5APD2MNVjs = require('./chunk-5APD2MNV.js');
7
+ var _chunkRYC23C3Kjs = require('./chunk-RYC23C3K.js');
8
8
 
9
9
  // src/tailwindcss/recorder.ts
10
10
  function setupPatchRecorder(patcher, baseDir, options) {
11
- const recorder = _chunk7K3R5LV6js.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
11
+ const recorder = _chunkDEIJXHGJjs.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
12
12
  if (_optionalChain([recorder, 'optionalAccess', _ => _.message]) && _optionalChain([options, 'optionalAccess', _2 => _2.logMessage]) !== false) {
13
13
  const prefix = _optionalChain([options, 'optionalAccess', _3 => _3.messagePrefix]) ? `${options.messagePrefix} ` : "";
14
- _chunk5APD2MNVjs.logger.info("%s%s", prefix, recorder.message);
14
+ _chunkRYC23C3Kjs.logger.info("%s%s", prefix, recorder.message);
15
15
  }
16
16
  const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _4 => _4.onPatched]) ? async () => {
17
17
  await recorder.onPatched();
18
18
  } : void 0;
19
- const patchPromise = patcher ? _chunk7K3R5LV6js.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
19
+ const patchPromise = patcher ? _chunkDEIJXHGJjs.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
20
20
  return {
21
21
  recorder,
22
22
  patchPromise,
@@ -3,13 +3,13 @@
3
3
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
4
4
 
5
5
 
6
- var _chunkRB7YN5XZjs = require('./chunk-RB7YN5XZ.js');
6
+ var _chunkGCRL3ZYPjs = require('./chunk-GCRL3ZYP.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunk7K3R5LV6js = require('./chunk-7K3R5LV6.js');
12
+ var _chunkDEIJXHGJjs = require('./chunk-DEIJXHGJ.js');
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  var _buffer = require('buffer');
@@ -17,12 +17,12 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
17
17
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
18
18
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
19
19
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
20
- var debug = _chunk7K3R5LV6js.createDebug.call(void 0, );
20
+ var debug = _chunkDEIJXHGJjs.createDebug.call(void 0, );
21
21
  var Transform = _stream2.default.Transform;
22
22
  function createPlugins(options = {}) {
23
- const opts = _chunk7K3R5LV6js.getCompilerContext.call(void 0, options);
23
+ const opts = _chunkDEIJXHGJjs.getCompilerContext.call(void 0, options);
24
24
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
25
- const patchRecorderState = _chunkRB7YN5XZjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
25
+ const patchRecorderState = _chunkGCRL3ZYPjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
26
26
  source: "runtime",
27
27
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
28
28
  });
@@ -36,13 +36,13 @@ function createPlugins(options = {}) {
36
36
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
37
37
  let runtimeSetInitialized = false;
38
38
  async function refreshRuntimeState(force) {
39
- await _chunk7K3R5LV6js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
39
+ await _chunkDEIJXHGJjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
40
40
  }
41
41
  async function refreshRuntimeSet(force = false) {
42
42
  if (!force && runtimeSetInitialized) {
43
43
  return runtimeSet;
44
44
  }
45
- runtimeSet = await _chunk7K3R5LV6js.ensureRuntimeClassSet.call(void 0, runtimeState, {
45
+ runtimeSet = await _chunkDEIJXHGJjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
46
46
  forceRefresh: force,
47
47
  forceCollect: force,
48
48
  clearCache: force,
@@ -164,6 +164,7 @@ function createPlugins(options = {}) {
164
164
  ...options2,
165
165
  filename,
166
166
  moduleGraph,
167
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
167
168
  babelParserOptions: {
168
169
  ..._nullishCoalesce(_optionalChain([options2, 'optionalAccess', _ => _.babelParserOptions]), () => ( {})),
169
170
  sourceFilename: filename
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createPatchTargetRecorder,
3
3
  createTailwindPatchPromise
4
- } from "./chunk-RXM5ERRJ.mjs";
4
+ } from "./chunk-E7775SFS.mjs";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-QOTLDKI4.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-RRHPTTCP.mjs";
13
13
  import {
14
14
  setupPatchRecorder
15
- } from "./chunk-4QCL7FBX.mjs";
15
+ } from "./chunk-LICQ6EGN.mjs";
16
16
  import {
17
17
  collectRuntimeClassSet,
18
18
  createAttributeMatcher,
@@ -24,12 +24,13 @@ import {
24
24
  replaceWxml,
25
25
  toCustomAttributesEntities,
26
26
  vitePluginName
27
- } from "./chunk-RXM5ERRJ.mjs";
27
+ } from "./chunk-E7775SFS.mjs";
28
28
  import {
29
29
  resolveUniUtsPlatform
30
30
  } from "./chunk-OOHJLO5M.mjs";
31
31
 
32
32
  // src/bundlers/vite/index.ts
33
+ import path3 from "path";
33
34
  import process3 from "process";
34
35
  import postcssHtmlTransform from "@weapp-tailwindcss/postcss/html-transform";
35
36
 
@@ -492,6 +493,16 @@ function shouldSkipViteJsTransform(rawSource, options) {
492
493
  }
493
494
 
494
495
  // src/bundlers/vite/generate-bundle.ts
496
+ function formatDebugFileList(files, limit = 8) {
497
+ if (files.size === 0) {
498
+ return "-";
499
+ }
500
+ const sorted = [...files].sort();
501
+ if (sorted.length <= limit) {
502
+ return sorted.join(",");
503
+ }
504
+ return `${sorted.slice(0, limit).join(",")},...(+${sorted.length - limit})`;
505
+ }
495
506
  function createEmptyMetric() {
496
507
  return {
497
508
  total: 0,
@@ -712,6 +723,28 @@ function createGenerateBundleHook(context) {
712
723
  const forceRuntimeRefresh = forceRuntimeRefreshByEnv || forceRuntimeRefreshBySource;
713
724
  const processSets = buildProcessSets(entries, opts, dirtyEntries.changedByType, state.previousLinkedByEntry, disableDirtyOptimization);
714
725
  const processFiles = processSets.files;
726
+ debug2(
727
+ "dirty iteration=%d html=%d[%s] js=%d[%s] css=%d[%s] other=%d[%s]",
728
+ state.iteration + 1,
729
+ dirtyEntries.changedByType.html.size,
730
+ formatDebugFileList(dirtyEntries.changedByType.html),
731
+ dirtyEntries.changedByType.js.size,
732
+ formatDebugFileList(dirtyEntries.changedByType.js),
733
+ dirtyEntries.changedByType.css.size,
734
+ formatDebugFileList(dirtyEntries.changedByType.css),
735
+ dirtyEntries.changedByType.other.size,
736
+ formatDebugFileList(dirtyEntries.changedByType.other)
737
+ );
738
+ debug2(
739
+ "process iteration=%d html=%d[%s] js=%d[%s] css=%d[%s]",
740
+ state.iteration + 1,
741
+ processFiles.html.size,
742
+ formatDebugFileList(processFiles.html),
743
+ processFiles.js.size,
744
+ formatDebugFileList(processFiles.js),
745
+ processFiles.css.size,
746
+ formatDebugFileList(processFiles.css)
747
+ );
715
748
  const resolvedConfig = getResolvedConfig();
716
749
  const rootDir = resolvedConfig?.root ? path2.resolve(resolvedConfig.root) : process2.cwd();
717
750
  const outDir = resolvedConfig?.build?.outDir ? path2.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
@@ -756,6 +789,7 @@ function createGenerateBundleHook(context) {
756
789
  const createHandlerOptions = (absoluteFilename, extra) => ({
757
790
  ...extra,
758
791
  filename: absoluteFilename,
792
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
759
793
  moduleGraph: moduleGraphOptions,
760
794
  babelParserOptions: {
761
795
  ...extra?.babelParserOptions ?? {},
@@ -850,8 +884,9 @@ function createGenerateBundleHook(context) {
850
884
  continue;
851
885
  }
852
886
  metrics.js.total++;
853
- if (!processFiles.js.has(file)) {
854
- continue;
887
+ const shouldTransformJs = processFiles.js.has(file);
888
+ if (!shouldTransformJs) {
889
+ debug2("js skip transform (clean), replay cache: %s", file);
855
890
  }
856
891
  if (originalSource.type === "chunk") {
857
892
  const absoluteFile = toJsAbsoluteFilename(file, outDir);
@@ -881,6 +916,9 @@ function createGenerateBundleHook(context) {
881
916
  async transform() {
882
917
  const start = performance.now();
883
918
  const rawSource = originalSource.code;
919
+ if (!shouldTransformJs) {
920
+ debug2("js cache replay miss, fallback transform: %s", file);
921
+ }
884
922
  const handlerOptions = createHandlerOptions(absoluteFile);
885
923
  if (!disableJsPrecheck && shouldSkipViteJsTransform(rawSource, handlerOptions)) {
886
924
  metrics.js.elapsed += measureElapsed(start);
@@ -950,6 +988,13 @@ function createGenerateBundleHook(context) {
950
988
  );
951
989
  jsTaskFactories.push(async () => {
952
990
  const start = performance.now();
991
+ if (!shouldTransformJs) {
992
+ debug2("js skip transform (clean, uni-app-x), replay cache: %s", file);
993
+ await factory();
994
+ metrics.js.elapsed += measureElapsed(start);
995
+ metrics.js.transformed++;
996
+ return;
997
+ }
953
998
  const currentSource = originalSource.source.toString();
954
999
  const absoluteFile = toJsAbsoluteFilename(file, outDir);
955
1000
  const precheckOptions = createHandlerOptions(absoluteFile, {
@@ -1082,6 +1127,7 @@ var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
1082
1127
  var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
1083
1128
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1084
1129
  const rewriteCssImportsSpecified = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
1130
+ const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
1085
1131
  const opts = getCompilerContext(options);
1086
1132
  const {
1087
1133
  disabled,
@@ -1205,8 +1251,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
1205
1251
  {
1206
1252
  name: `${vitePluginName}:post`,
1207
1253
  enforce: "post",
1208
- configResolved(config) {
1254
+ async configResolved(config) {
1209
1255
  resolvedConfig = config;
1256
+ const resolvedRoot = config.root ? path3.resolve(config.root) : void 0;
1257
+ if (!hasExplicitTailwindcssBasedir && resolvedRoot && opts.tailwindcssBasedir !== resolvedRoot) {
1258
+ const previousBasedir = opts.tailwindcssBasedir;
1259
+ opts.tailwindcssBasedir = resolvedRoot;
1260
+ debug("align tailwindcss basedir with vite root: %s -> %s", previousBasedir ?? "undefined", resolvedRoot);
1261
+ await refreshRuntimeState(true);
1262
+ }
1210
1263
  if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
1211
1264
  const idx = config.css.postcss.plugins.findIndex((x) => (
1212
1265
  // @ts-ignore
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-RRHPTTCP.mjs";
4
4
  import {
5
5
  setupPatchRecorder
6
- } from "./chunk-4QCL7FBX.mjs";
6
+ } from "./chunk-LICQ6EGN.mjs";
7
7
  import {
8
8
  createDebug,
9
9
  ensureRuntimeClassSet,
10
10
  getCompilerContext,
11
11
  refreshTailwindRuntimeState
12
- } from "./chunk-RXM5ERRJ.mjs";
12
+ } from "./chunk-E7775SFS.mjs";
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  import { Buffer } from "buffer";
@@ -164,6 +164,7 @@ function createPlugins(options = {}) {
164
164
  ...options2,
165
165
  filename,
166
166
  moduleGraph,
167
+ tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
167
168
  babelParserOptions: {
168
169
  ...options2?.babelParserOptions ?? {},
169
170
  sourceFilename: filename
@@ -3,7 +3,7 @@
3
3
  var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
4
4
 
5
5
 
6
- var _chunkDBAAU4LKjs = require('./chunk-DBAAU4LK.js');
6
+ var _chunkYUTKX7JZjs = require('./chunk-YUTKX7JZ.js');
7
7
 
8
8
  // src/logger/index.ts
9
9
  var _logger = require('@weapp-tailwindcss/logger');
@@ -399,7 +399,7 @@ function resolveModuleFromPaths(specifier, paths) {
399
399
  return void 0;
400
400
  }
401
401
  try {
402
- const req = _module.createRequire.call(void 0, _chunkDBAAU4LKjs.importMetaUrl);
402
+ const req = _module.createRequire.call(void 0, _chunkYUTKX7JZjs.importMetaUrl);
403
403
  return req.resolve(specifier, { paths });
404
404
  } catch (e3) {
405
405
  return void 0;
@@ -454,11 +454,11 @@ function createDefaultResolvePaths(basedir) {
454
454
  const cwd = _process2.default.cwd();
455
455
  appendNodeModules(paths, cwd);
456
456
  try {
457
- const modulePath = _url.fileURLToPath.call(void 0, _chunkDBAAU4LKjs.importMetaUrl);
457
+ const modulePath = _url.fileURLToPath.call(void 0, _chunkYUTKX7JZjs.importMetaUrl);
458
458
  const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
459
459
  paths.add(candidate);
460
460
  } catch (e4) {
461
- paths.add(_chunkDBAAU4LKjs.importMetaUrl);
461
+ paths.add(_chunkYUTKX7JZjs.importMetaUrl);
462
462
  }
463
463
  if (paths.size === 0) {
464
464
  fallbackCandidates = fallbackCandidates.filter(Boolean);
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.10.13__@swc+core@1.15.11_@swc_f8079344adc4b1859e6989f440e01c9c/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.10.13__@swc+core@1.15.13_@swc_3c7849ff4c0b6c5a62dfcd4f04ae2c69/node_modules/tsup/assets/esm_shims.js
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-F2CKKG6Q.mjs";
4
4
  import {
5
5
  pluginName
6
- } from "./chunk-RXM5ERRJ.mjs";
6
+ } from "./chunk-E7775SFS.mjs";
7
7
 
8
8
  // src/shared/mpx.ts
9
9
  import path2 from "path";