weapp-tailwindcss 4.12.0-alpha.2 → 4.12.0-alpha.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.
@@ -11,14 +11,14 @@
11
11
 
12
12
 
13
13
 
14
- var _chunk2A4NRLSYjs = require('./chunk-2A4NRLSY.js');
14
+ var _chunkUVMAPQU7js = require('./chunk-UVMAPQU7.js');
15
15
 
16
16
 
17
17
 
18
18
 
19
19
 
20
20
 
21
- var _chunkGMKSBLNYjs = require('./chunk-GMKSBLNY.js');
21
+ var _chunkL3O54VR6js = require('./chunk-L3O54VR6.js');
22
22
 
23
23
 
24
24
  var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
@@ -29,7 +29,7 @@ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
29
29
 
30
30
 
31
31
 
32
- var _chunkYVRX3F6Sjs = require('./chunk-YVRX3F6S.js');
32
+ var _chunkOSWTWMAKjs = require('./chunk-OSWTWMAK.js');
33
33
 
34
34
 
35
35
 
@@ -64,10 +64,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
64
64
  const { Compilation, sources } = compiler.webpack;
65
65
  const { ConcatSource } = sources;
66
66
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
67
- compiler.hooks.compilation.tap(_chunkYVRX3F6Sjs.pluginName, (compilation) => {
67
+ compiler.hooks.compilation.tap(_chunkOSWTWMAKjs.pluginName, (compilation) => {
68
68
  compilation.hooks.processAssets.tapPromise(
69
69
  {
70
- name: _chunkYVRX3F6Sjs.pluginName,
70
+ name: _chunkOSWTWMAKjs.pluginName,
71
71
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
72
72
  },
73
73
  async (assets) => {
@@ -79,20 +79,20 @@ function setupWebpackV5ProcessAssetsHook(options) {
79
79
  compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
80
80
  }
81
81
  }
82
- const assetHashByChunk = _chunk2A4NRLSYjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
82
+ const assetHashByChunk = _chunkUVMAPQU7js.createAssetHashByChunkMap.call(void 0, compilation.chunks);
83
83
  const entries = Object.entries(assets);
84
84
  const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _ => _.compiler, 'optionalAccess', _2 => _2.outputPath]), () => ( compiler.outputPath));
85
85
  const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _3 => _3.outputOptions, 'optionalAccess', _4 => _4.path]), () => ( _process2.default.cwd()));
86
86
  const jsAssets = /* @__PURE__ */ new Map();
87
87
  for (const [file] of entries) {
88
88
  if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
89
- const absolute = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
89
+ const absolute = _chunkL3O54VR6js.toAbsoluteOutputPath.call(void 0, file, outputDir);
90
90
  jsAssets.set(absolute, file);
91
91
  }
92
92
  }
93
93
  const moduleGraphOptions = {
94
94
  resolve(specifier, importer) {
95
- return _chunkGMKSBLNYjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
95
+ return _chunkL3O54VR6js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
96
96
  },
97
97
  load: (id) => {
98
98
  const assetName = jsAssets.get(id);
@@ -158,7 +158,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
158
158
  const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
159
159
  const forceRuntimeRefresh = getRuntimeRefreshRequirement();
160
160
  debug2("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, _nullishCoalesce(runtimeState.twPatcher.majorVersion, () => ( "unknown")));
161
- const runtimeSet = await _chunkYVRX3F6Sjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
161
+ const runtimeSet = await _chunkOSWTWMAKjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
162
162
  forceRefresh: forceRuntimeRefresh,
163
163
  // webpack 的 script-only 热更新可能不会触发 runtime classset loader,
164
164
  // 这里强制收集可避免沿用上轮 class set,保证 JS 仅按最新集合精确命中。
@@ -208,12 +208,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
208
208
  const jsTaskFactories = [];
209
209
  if (Array.isArray(groupedEntries.js)) {
210
210
  for (const [file] of groupedEntries.js) {
211
- const cacheKey = _chunk2A4NRLSYjs.getCacheKey.call(void 0, file);
211
+ const cacheKey = _chunkUVMAPQU7js.getCacheKey.call(void 0, file);
212
212
  const asset = compilation.getAsset(file);
213
213
  if (!asset) {
214
214
  continue;
215
215
  }
216
- const absoluteFile = _chunkGMKSBLNYjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
216
+ const absoluteFile = _chunkL3O54VR6js.toAbsoluteOutputPath.call(void 0, file, outputDir);
217
217
  const initialSource = asset.source.source();
218
218
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
219
219
  const chunkHash = assetHashByChunk.get(file);
@@ -243,7 +243,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
243
243
  sourceFilename: absoluteFile
244
244
  }
245
245
  };
246
- if (_chunkYVRX3F6Sjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
246
+ if (_chunkOSWTWMAKjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
247
247
  return { result: new ConcatSource(currentSource) };
248
248
  }
249
249
  const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
@@ -292,7 +292,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
292
292
  );
293
293
  }
294
294
  }
295
- _chunkGMKSBLNYjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
295
+ _chunkL3O54VR6js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
296
296
  await Promise.all(tasks);
297
297
  debug2("end");
298
298
  compilerOptions.onEnd();
@@ -318,9 +318,9 @@ function setupWebpackV5Loaders(options) {
318
318
  getRuntimeWatchDependencies,
319
319
  debug: debug2
320
320
  } = options;
321
- const isMpxApp = _chunk2A4NRLSYjs.isMpx.call(void 0, appType);
321
+ const isMpxApp = _chunkUVMAPQU7js.isMpx.call(void 0, appType);
322
322
  if (shouldRewriteCssImports && isMpxApp) {
323
- _chunk2A4NRLSYjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
323
+ _chunkUVMAPQU7js.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
324
324
  }
325
325
  const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
326
326
  const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
@@ -334,12 +334,12 @@ function setupWebpackV5Loaders(options) {
334
334
  getClassSet: getClassSetInLoader,
335
335
  getWatchDependencies: getRuntimeWatchDependencies
336
336
  };
337
- const { findRewriteAnchor, findClassSetAnchor } = _chunk2A4NRLSYjs.createLoaderAnchorFinders.call(void 0, appType);
337
+ const { findRewriteAnchor, findClassSetAnchor } = _chunkUVMAPQU7js.createLoaderAnchorFinders.call(void 0, appType);
338
338
  const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
339
339
  rewriteCssImports: runtimeLoaderRewriteOptions
340
340
  } : void 0;
341
341
  if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
342
- _chunk2A4NRLSYjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
342
+ _chunkUVMAPQU7js.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
343
343
  }
344
344
  const createRuntimeClassSetLoaderEntry = () => ({
345
345
  loader: runtimeClassSetLoader,
@@ -359,17 +359,17 @@ function setupWebpackV5Loaders(options) {
359
359
  };
360
360
  };
361
361
  const { NormalModule } = compiler.webpack;
362
- compiler.hooks.compilation.tap(_chunkYVRX3F6Sjs.pluginName, (compilation) => {
363
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkYVRX3F6Sjs.pluginName, (_loaderContext, module) => {
362
+ compiler.hooks.compilation.tap(_chunkOSWTWMAKjs.pluginName, (compilation) => {
363
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkOSWTWMAKjs.pluginName, (_loaderContext, module) => {
364
364
  const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
365
365
  if (!hasRuntimeLoader) {
366
366
  return;
367
367
  }
368
- _chunk2A4NRLSYjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, shouldRewriteCssImports && isMpxApp);
368
+ _chunkUVMAPQU7js.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, shouldRewriteCssImports && isMpxApp);
369
369
  const loaderEntries = module.loaders || [];
370
370
  let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
371
371
  const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
372
- const isCssModule = _chunk2A4NRLSYjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
372
+ const isCssModule = _chunkUVMAPQU7js.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
373
373
  if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
374
374
  debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
375
375
  }
@@ -401,7 +401,7 @@ function setupWebpackV5Loaders(options) {
401
401
  rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
402
402
  }
403
403
  }
404
- if (runtimeClassSetLoaderExists && !_chunk2A4NRLSYjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
404
+ if (runtimeClassSetLoaderExists && !_chunkUVMAPQU7js.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
405
405
  const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
406
406
  const anchorIndex = findClassSetAnchor(loaderEntries);
407
407
  if (anchorIndex === -1) {
@@ -416,11 +416,11 @@ function setupWebpackV5Loaders(options) {
416
416
  }
417
417
 
418
418
  // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
419
- var debug = _chunkYVRX3F6Sjs.createDebug.call(void 0, );
420
- var weappTailwindcssPackageDir = _chunkGMKSBLNYjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
419
+ var debug = _chunkOSWTWMAKjs.createDebug.call(void 0, );
420
+ var weappTailwindcssPackageDir = _chunkL3O54VR6js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
421
421
  var UnifiedWebpackPluginV5 = class {
422
422
  constructor(options = {}) {
423
- this.options = _chunkYVRX3F6Sjs.getCompilerContext.call(void 0, options);
423
+ this.options = _chunkOSWTWMAKjs.getCompilerContext.call(void 0, options);
424
424
  this.appType = this.options.appType;
425
425
  }
426
426
  apply(compiler) {
@@ -433,22 +433,22 @@ var UnifiedWebpackPluginV5 = class {
433
433
  twPatcher: initialTwPatcher,
434
434
  refreshTailwindcssPatcher
435
435
  } = this.options;
436
- const disabledOptions = _chunkGMKSBLNYjs.resolveDisabledOptions.call(void 0, disabled);
436
+ const disabledOptions = _chunkL3O54VR6js.resolveDisabledOptions.call(void 0, disabled);
437
437
  const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
438
438
  const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
439
- const isMpxApp = _chunk2A4NRLSYjs.isMpx.call(void 0, this.appType);
439
+ const isMpxApp = _chunkUVMAPQU7js.isMpx.call(void 0, this.appType);
440
440
  if (shouldRewriteCssImports) {
441
- _chunk2A4NRLSYjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
441
+ _chunkUVMAPQU7js.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
442
442
  pkgDir: weappTailwindcssPackageDir,
443
443
  enabled: true,
444
444
  appType: this.appType
445
445
  });
446
- _chunk2A4NRLSYjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
446
+ _chunkUVMAPQU7js.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
447
447
  }
448
448
  if (disabledOptions.plugin) {
449
449
  return;
450
450
  }
451
- const patchRecorderState = _chunkYVRX3F6Sjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
451
+ const patchRecorderState = _chunkOSWTWMAKjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
452
452
  source: "runtime",
453
453
  cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
454
454
  });
@@ -506,21 +506,21 @@ var UnifiedWebpackPluginV5 = class {
506
506
  runtimeMetadataPrepared = true;
507
507
  };
508
508
  const syncRuntimeRefreshRequirement = () => {
509
- runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || _chunk2A4NRLSYjs.hasWatchChanges.call(void 0, compiler);
509
+ runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || _chunkUVMAPQU7js.hasWatchChanges.call(void 0, compiler);
510
510
  };
511
511
  const resetRuntimePreparation = () => {
512
512
  runtimeSetPrepared = false;
513
513
  runtimeMetadataPrepared = false;
514
514
  syncRuntimeRefreshRequirement();
515
515
  };
516
- _optionalChain([compiler, 'access', _20 => _20.hooks, 'access', _21 => _21.invalid, 'optionalAccess', _22 => _22.tap, 'optionalCall', _23 => _23(_chunkYVRX3F6Sjs.pluginName, () => {
516
+ _optionalChain([compiler, 'access', _20 => _20.hooks, 'access', _21 => _21.invalid, 'optionalAccess', _22 => _22.tap, 'optionalCall', _23 => _23(_chunkOSWTWMAKjs.pluginName, () => {
517
517
  runtimeRefreshRequiredForCompilation = true;
518
518
  })]);
519
- _optionalChain([compiler, 'access', _24 => _24.hooks, 'access', _25 => _25.watchRun, 'optionalAccess', _26 => _26.tap, 'optionalCall', _27 => _27(_chunkYVRX3F6Sjs.pluginName, syncRuntimeRefreshRequirement)]);
519
+ _optionalChain([compiler, 'access', _24 => _24.hooks, 'access', _25 => _25.watchRun, 'optionalAccess', _26 => _26.tap, 'optionalCall', _27 => _27(_chunkOSWTWMAKjs.pluginName, syncRuntimeRefreshRequirement)]);
520
520
  if (_optionalChain([compiler, 'access', _28 => _28.hooks, 'access', _29 => _29.thisCompilation, 'optionalAccess', _30 => _30.tap])) {
521
- compiler.hooks.thisCompilation.tap(_chunkYVRX3F6Sjs.pluginName, resetRuntimePreparation);
521
+ compiler.hooks.thisCompilation.tap(_chunkOSWTWMAKjs.pluginName, resetRuntimePreparation);
522
522
  } else if (_optionalChain([compiler, 'access', _31 => _31.hooks, 'access', _32 => _32.compilation, 'optionalAccess', _33 => _33.tap])) {
523
- compiler.hooks.compilation.tap(_chunkYVRX3F6Sjs.pluginName, resetRuntimePreparation);
523
+ compiler.hooks.compilation.tap(_chunkOSWTWMAKjs.pluginName, resetRuntimePreparation);
524
524
  }
525
525
  async function getClassSetInLoader() {
526
526
  if (runtimeSetPrepared) {
@@ -530,7 +530,7 @@ var UnifiedWebpackPluginV5 = class {
530
530
  const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
531
531
  debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
532
532
  runtimeSetPrepared = true;
533
- await _chunkYVRX3F6Sjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
533
+ await _chunkOSWTWMAKjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
534
534
  forceRefresh,
535
535
  forceCollect: true,
536
536
  clearCache: forceRefresh,
@@ -25,8 +25,12 @@ function resolvePackageDir(name) {
25
25
  import path2 from "path";
26
26
  var QUERY_HASH_RE = /[?#].*$/u;
27
27
  var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
28
+ var WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
28
29
  var VIRTUAL_PREFIX = "\0";
29
30
  var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
31
+ function normalizeOutputPathKey(value) {
32
+ return path2.normalize(value).replace(/\\/g, "/");
33
+ }
30
34
  function stripQueryAndHash(specifier) {
31
35
  return specifier.replace(QUERY_HASH_RE, "");
32
36
  }
@@ -38,11 +42,14 @@ function isResolvableSpecifier(specifier) {
38
42
  if (normalized.startsWith(VIRTUAL_PREFIX)) {
39
43
  return false;
40
44
  }
45
+ if (path2.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
46
+ return true;
47
+ }
41
48
  return !PROTOCOL_RE.test(normalized);
42
49
  }
43
50
  function toAbsoluteOutputPath(fileName, outDir) {
44
- if (path2.isAbsolute(fileName)) {
45
- return fileName;
51
+ if (path2.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) {
52
+ return path2.normalize(fileName);
46
53
  }
47
54
  return path2.resolve(outDir, fileName);
48
55
  }
@@ -66,8 +73,8 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
66
73
  }
67
74
  const normalized = stripQueryAndHash(specifier);
68
75
  let candidate;
69
- if (path2.isAbsolute(normalized)) {
70
- candidate = normalized;
76
+ if (path2.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
77
+ candidate = path2.normalize(normalized);
71
78
  } else if (normalized.startsWith("/")) {
72
79
  candidate = path2.resolve(outDir, normalized.slice(1));
73
80
  } else {
@@ -161,6 +168,7 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
161
168
  }
162
169
 
163
170
  export {
171
+ normalizeOutputPathKey,
164
172
  toAbsoluteOutputPath,
165
173
  resolveOutputSpecifier,
166
174
  resolveDisabledOptions,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  resolveTailwindcssImport
3
- } from "./chunk-F2CKKG6Q.mjs";
3
+ } from "./chunk-3VQKDHGP.mjs";
4
4
  import {
5
5
  pluginName
6
- } from "./chunk-LWEVOVRD.mjs";
6
+ } from "./chunk-J6FIO3RO.mjs";
7
7
 
8
8
  // src/shared/mpx.ts
9
9
  import path2 from "path";
@@ -11,14 +11,14 @@ import {
11
11
  isMpx,
12
12
  patchMpxLoaderResolve,
13
13
  setupMpxTailwindcssRedirect
14
- } from "./chunk-SHDJA4GG.mjs";
14
+ } from "./chunk-6MIA3KYY.mjs";
15
15
  import {
16
16
  pushConcurrentTaskFactories,
17
17
  resolveDisabledOptions,
18
18
  resolveOutputSpecifier,
19
19
  resolvePackageDir,
20
20
  toAbsoluteOutputPath
21
- } from "./chunk-F2CKKG6Q.mjs";
21
+ } from "./chunk-3VQKDHGP.mjs";
22
22
  import {
23
23
  processCachedTask
24
24
  } from "./chunk-76S2EME4.mjs";
@@ -29,7 +29,7 @@ import {
29
29
  pluginName,
30
30
  setupPatchRecorder,
31
31
  shouldSkipJsTransform
32
- } from "./chunk-LWEVOVRD.mjs";
32
+ } from "./chunk-J6FIO3RO.mjs";
33
33
  import {
34
34
  getRuntimeClassSetSignature,
35
35
  resolveTailwindcssOptions
@@ -1,4 +1,5 @@
1
1
  import {
2
+ normalizeOutputPathKey,
2
3
  pushConcurrentTaskFactories,
3
4
  resolveDisabledOptions,
4
5
  resolveOutputSpecifier,
@@ -6,7 +7,7 @@ import {
6
7
  resolveTailwindcssImport,
7
8
  rewriteTailwindcssImportsInCode,
8
9
  toAbsoluteOutputPath
9
- } from "./chunk-F2CKKG6Q.mjs";
10
+ } from "./chunk-3VQKDHGP.mjs";
10
11
  import {
11
12
  processCachedTask
12
13
  } from "./chunk-76S2EME4.mjs";
@@ -27,7 +28,7 @@ import {
27
28
  toCustomAttributesEntities,
28
29
  traverse,
29
30
  vitePluginName
30
- } from "./chunk-LWEVOVRD.mjs";
31
+ } from "./chunk-J6FIO3RO.mjs";
31
32
  import {
32
33
  findNearestPackageRoot,
33
34
  findTailwindConfig,
@@ -761,19 +762,24 @@ function isJavaScriptEntry(entry) {
761
762
  return entry.fileName.endsWith(".js");
762
763
  }
763
764
  function createBundleModuleGraphOptions(outputDir, entries) {
765
+ const normalizedEntries = /* @__PURE__ */ new Map();
766
+ for (const [id, entry] of entries) {
767
+ normalizedEntries.set(normalizeOutputPathKey(id), entry);
768
+ }
769
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
764
770
  return {
765
771
  resolve(specifier, importer) {
766
- return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => entries.has(candidate));
772
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
767
773
  },
768
774
  load(id) {
769
- const entry = entries.get(id);
775
+ const entry = getEntry(id);
770
776
  if (!entry) {
771
777
  return void 0;
772
778
  }
773
779
  return readOutputEntry(entry);
774
780
  },
775
781
  filter(id) {
776
- return entries.has(id);
782
+ return Boolean(getEntry(id));
777
783
  }
778
784
  };
779
785
  }
@@ -781,8 +787,12 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
781
787
  if (!linked) {
782
788
  return;
783
789
  }
790
+ const normalizedEntries = /* @__PURE__ */ new Map();
791
+ for (const [entryId, entry] of entries) {
792
+ normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
793
+ }
784
794
  for (const [id, { code }] of Object.entries(linked)) {
785
- const entry = entries.get(id);
795
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
786
796
  if (!entry) {
787
797
  continue;
788
798
  }
@@ -1262,6 +1272,11 @@ function createGenerateBundleHook(context) {
1262
1272
  );
1263
1273
  }
1264
1274
  const jsEntries = snapshot.jsEntries;
1275
+ const normalizedJsEntries = /* @__PURE__ */ new Map();
1276
+ for (const [id, entry] of jsEntries) {
1277
+ normalizedJsEntries.set(normalizeOutputPathKey(id), entry);
1278
+ }
1279
+ const getJsEntry = (id) => jsEntries.get(id) ?? normalizedJsEntries.get(normalizeOutputPathKey(id));
1265
1280
  const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
1266
1281
  const runtimeStart = performance.now();
1267
1282
  const runtime = useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv) : await context.ensureRuntimeClassSet(forceRuntimeRefreshByEnv);
@@ -1479,7 +1494,7 @@ function createGenerateBundleHook(context) {
1479
1494
  debug3("js handle: %s", file);
1480
1495
  if (linked) {
1481
1496
  for (const id of Object.keys(linked)) {
1482
- const linkedEntry = jsEntries.get(id);
1497
+ const linkedEntry = getJsEntry(id);
1483
1498
  if (linkedEntry && linkedSet) {
1484
1499
  linkedSet.add(linkedEntry.fileName);
1485
1500
  }
@@ -1501,7 +1516,7 @@ function createGenerateBundleHook(context) {
1501
1516
  const wrappedApplyLinkedUpdates = (linked) => {
1502
1517
  if (linked) {
1503
1518
  for (const id of Object.keys(linked)) {
1504
- const linkedEntry = jsEntries.get(id);
1519
+ const linkedEntry = getJsEntry(id);
1505
1520
  if (linkedEntry && linkedSet) {
1506
1521
  linkedSet.add(linkedEntry.fileName);
1507
1522
  }
@@ -363,14 +363,14 @@ function initializeCache(cacheConfig) {
363
363
  }
364
364
 
365
365
  // src/tailwindcss/runtime-logs.ts
366
- import process2 from "process";
366
+ import process from "process";
367
367
  import { logger as logger2, pc } from "@weapp-tailwindcss/logger";
368
368
  var runtimeLogDedupeHolder = globalThis;
369
369
  var runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
370
370
  function createRuntimeLogKey(category, baseDir, rootPath, version) {
371
371
  return JSON.stringify([
372
372
  category,
373
- baseDir ?? process2.cwd(),
373
+ baseDir ?? process.cwd(),
374
374
  rootPath ?? "",
375
375
  version ?? ""
376
376
  ]);
@@ -405,7 +405,7 @@ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
405
405
  }
406
406
 
407
407
  // src/tailwindcss/targets.ts
408
- import process5 from "process";
408
+ import process4 from "process";
409
409
  import { logger as logger4 } from "@weapp-tailwindcss/logger";
410
410
 
411
411
  // src/tailwindcss/targets/paths.ts
@@ -414,18 +414,21 @@ import path from "path";
414
414
  var PATCH_INFO_FILENAME = "tailwindcss-target.json";
415
415
  var PATCH_INFO_CACHE_RELATIVE_PATH = path.join("node_modules", ".cache", "weapp-tailwindcss", PATCH_INFO_FILENAME);
416
416
  var PATCH_INFO_LEGACY_RELATIVE_PATH = path.join(".tw-patch", PATCH_INFO_FILENAME);
417
+ function toDisplayPath(value) {
418
+ return path.normalize(value).replace(/\\/g, "/");
419
+ }
417
420
  function formatRelativeToBase(targetPath, baseDir) {
418
421
  if (!baseDir) {
419
- return path.normalize(targetPath);
422
+ return toDisplayPath(targetPath);
420
423
  }
421
424
  const relative = path.relative(baseDir, targetPath);
422
425
  if (!relative || relative === ".") {
423
426
  return ".";
424
427
  }
425
428
  if (relative.startsWith("..")) {
426
- return path.normalize(targetPath);
429
+ return toDisplayPath(targetPath);
427
430
  }
428
- return path.join(".", relative);
431
+ return toDisplayPath(path.join(".", relative));
429
432
  }
430
433
  function resolveRecordLocation(baseDir) {
431
434
  const normalizedBase = path.normalize(baseDir);
@@ -460,13 +463,13 @@ function getRecordFileCandidates(baseDir) {
460
463
  import { existsSync as existsSync2, readFileSync } from "fs";
461
464
  import { mkdir, writeFile } from "fs/promises";
462
465
  import path2 from "path";
463
- import process3 from "process";
466
+ import process2 from "process";
464
467
  import { logger as logger3 } from "@weapp-tailwindcss/logger";
465
468
 
466
469
  // package.json
467
470
  var package_default = {
468
471
  name: "weapp-tailwindcss",
469
- version: "4.12.0-alpha.2",
472
+ version: "4.12.0-alpha.3",
470
473
  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!",
471
474
  author: "ice breaker <1324318532@qq.com>",
472
475
  license: "MIT",
@@ -709,7 +712,7 @@ function warnInvalidPatchTargetRecord(baseDir, recordPath, reason) {
709
712
  }
710
713
  loggedInvalidPatchRecords.add(normalizedPath);
711
714
  const fileDisplay = formatRelativeToBase(normalizedPath, baseDir);
712
- const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process3.cwd());
715
+ const baseDisplay = formatRelativeToBase(path2.normalize(baseDir), process2.cwd());
713
716
  const reasonMessage = reason ? `\uFF1A${reason}` : "";
714
717
  logger3.warn(
715
718
  `\u68C0\u6D4B\u5230\u635F\u574F\u7684 Tailwind CSS \u76EE\u6807\u8BB0\u5F55 ${fileDisplay}${reasonMessage}\u3002\u8BF7\u5728 ${baseDisplay} \u91CD\u65B0\u6267\u884C "weapp-tw patch --record-target" \u6216\u5220\u9664\u8BE5\u6587\u4EF6\u540E\u518D\u8FD0\u884C\u3002`
@@ -768,7 +771,7 @@ async function saveCliPatchTargetRecord(baseDir, patcher, options) {
768
771
  `, "utf8");
769
772
  return recordPath;
770
773
  } catch (error) {
771
- const baseDisplay = formatRelativeToBase(normalizedBase, process3.cwd());
774
+ const baseDisplay = formatRelativeToBase(normalizedBase, process2.cwd());
772
775
  logger3.warn(
773
776
  '\u81EA\u52A8\u66F4\u65B0 Tailwind CSS \u8865\u4E01\u8BB0\u5F55\u5931\u8D25\uFF0C\u8BF7\u5728 %s \u8FD0\u884C "weapp-tw patch --cwd %s"\u3002',
774
777
  baseDisplay,
@@ -781,10 +784,10 @@ async function saveCliPatchTargetRecord(baseDir, patcher, options) {
781
784
 
782
785
  // src/tailwindcss/targets/recorder.ts
783
786
  import path3 from "path";
784
- import process4 from "process";
787
+ import process3 from "process";
785
788
  function findPatchTargetRecord(baseDir) {
786
789
  const visited = /* @__PURE__ */ new Set();
787
- const fallback = baseDir ?? process4.cwd();
790
+ const fallback = baseDir ?? process3.cwd();
788
791
  let current = path3.resolve(fallback);
789
792
  while (!visited.has(current)) {
790
793
  const record = readPatchTargetRecord(current);
@@ -867,7 +870,7 @@ function logTailwindcssTarget(kind, patcher, baseDir) {
867
870
  logger4.warn(
868
871
  "%s \u672A\u627E\u5230 Tailwind CSS \u4F9D\u8D56\uFF0C\u8BF7\u68C0\u67E5\u5728 %s \u662F\u5426\u5DF2\u5B89\u88C5 tailwindcss",
869
872
  label,
870
- baseDir ?? process5.cwd()
873
+ baseDir ?? process4.cwd()
871
874
  );
872
875
  return;
873
876
  }
@@ -883,7 +886,7 @@ function logTailwindcssTarget(kind, patcher, baseDir) {
883
886
  // src/context/compiler-context-cache.ts
884
887
  import { Buffer } from "buffer";
885
888
  import path4 from "path";
886
- import process6 from "process";
889
+ import process5 from "process";
887
890
  import { logger as logger5 } from "@weapp-tailwindcss/logger";
888
891
  var PAREN_CONTENT_RE = /\(([^)]+)\)/u;
889
892
  var AT_LOCATION_RE = /at\s+(\S.*)$/u;
@@ -917,7 +920,7 @@ function shouldProbeCallerLocation(opts) {
917
920
  if (hasExplicitOptionBasedir(opts)) {
918
921
  return false;
919
922
  }
920
- return !(process6.env.WEAPP_TAILWINDCSS_BASEDIR || process6.env.WEAPP_TAILWINDCSS_BASE_DIR || process6.env.TAILWINDCSS_BASEDIR || process6.env.TAILWINDCSS_BASE_DIR);
923
+ return !(process5.env.WEAPP_TAILWINDCSS_BASEDIR || process5.env.WEAPP_TAILWINDCSS_BASE_DIR || process5.env.TAILWINDCSS_BASEDIR || process5.env.TAILWINDCSS_BASE_DIR);
921
924
  }
922
925
  function detectCallerLocation() {
923
926
  const stack = new Error("compiler-context-cache stack probe").stack;
@@ -950,20 +953,20 @@ function getRuntimeCacheScope(opts) {
950
953
  }
951
954
  const runtimeScope = {
952
955
  caller: void 0,
953
- cwd: process6.cwd(),
954
- init_cwd: process6.env.INIT_CWD,
955
- npm_config_local_prefix: process6.env.npm_config_local_prefix,
956
- npm_package_json: process6.env.npm_package_json,
957
- pnpm_package_name: process6.env.PNPM_PACKAGE_NAME,
958
- pwd: process6.env.PWD,
959
- tailwindcss_base_dir: process6.env.TAILWINDCSS_BASE_DIR,
960
- tailwindcss_basedir: process6.env.TAILWINDCSS_BASEDIR,
961
- uni_app_input_dir: process6.env.UNI_APP_INPUT_DIR,
962
- uni_cli_root: process6.env.UNI_CLI_ROOT,
963
- uni_input_dir: process6.env.UNI_INPUT_DIR,
964
- uni_input_root: process6.env.UNI_INPUT_ROOT,
965
- weapp_tailwindcss_base_dir: process6.env.WEAPP_TAILWINDCSS_BASE_DIR,
966
- weapp_tailwindcss_basedir: process6.env.WEAPP_TAILWINDCSS_BASEDIR
956
+ cwd: process5.cwd(),
957
+ init_cwd: process5.env.INIT_CWD,
958
+ npm_config_local_prefix: process5.env.npm_config_local_prefix,
959
+ npm_package_json: process5.env.npm_package_json,
960
+ pnpm_package_name: process5.env.PNPM_PACKAGE_NAME,
961
+ pwd: process5.env.PWD,
962
+ tailwindcss_base_dir: process5.env.TAILWINDCSS_BASE_DIR,
963
+ tailwindcss_basedir: process5.env.TAILWINDCSS_BASEDIR,
964
+ uni_app_input_dir: process5.env.UNI_APP_INPUT_DIR,
965
+ uni_cli_root: process5.env.UNI_CLI_ROOT,
966
+ uni_input_dir: process5.env.UNI_INPUT_DIR,
967
+ uni_input_root: process5.env.UNI_INPUT_ROOT,
968
+ weapp_tailwindcss_base_dir: process5.env.WEAPP_TAILWINDCSS_BASE_DIR,
969
+ weapp_tailwindcss_basedir: process5.env.WEAPP_TAILWINDCSS_BASEDIR
967
970
  };
968
971
  if (shouldProbeCallerLocation(opts)) {
969
972
  runtimeScope.caller = detectCallerLocation();
@@ -2067,6 +2070,7 @@ function walkEvalExpression(path5, options, updater, handler) {
2067
2070
  for (const q of n.quasis) {
2068
2071
  const stub = {
2069
2072
  node: q,
2073
+ isStringLiteral: () => false,
2070
2074
  isTemplateElement: () => true
2071
2075
  };
2072
2076
  handleEvalTemplateElement(stub, templateHandlerOptions, updater, handler);
@@ -3851,10 +3855,11 @@ function getCompilerContext(opts) {
3851
3855
  }
3852
3856
 
3853
3857
  // src/js/precheck.ts
3858
+ import process6 from "process";
3854
3859
  var FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
3855
3860
  var DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
3856
3861
  function shouldSkipJsTransform(rawSource, options) {
3857
- if (process.env.WEAPP_TW_DISABLE_JS_PRECHECK === "1") {
3862
+ if (process6.env.WEAPP_TW_DISABLE_JS_PRECHECK === "1") {
3858
3863
  return false;
3859
3864
  }
3860
3865
  if (!rawSource) {
@@ -29,8 +29,12 @@ function resolvePackageDir(name) {
29
29
 
30
30
  var QUERY_HASH_RE = /[?#].*$/u;
31
31
  var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
32
+ var WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
32
33
  var VIRTUAL_PREFIX = "\0";
33
34
  var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
35
+ function normalizeOutputPathKey(value) {
36
+ return _path2.default.normalize(value).replace(/\\/g, "/");
37
+ }
34
38
  function stripQueryAndHash(specifier) {
35
39
  return specifier.replace(QUERY_HASH_RE, "");
36
40
  }
@@ -42,11 +46,14 @@ function isResolvableSpecifier(specifier) {
42
46
  if (normalized.startsWith(VIRTUAL_PREFIX)) {
43
47
  return false;
44
48
  }
49
+ if (_path2.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
50
+ return true;
51
+ }
45
52
  return !PROTOCOL_RE.test(normalized);
46
53
  }
47
54
  function toAbsoluteOutputPath(fileName, outDir) {
48
- if (_path2.default.isAbsolute(fileName)) {
49
- return fileName;
55
+ if (_path2.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) {
56
+ return _path2.default.normalize(fileName);
50
57
  }
51
58
  return _path2.default.resolve(outDir, fileName);
52
59
  }
@@ -70,8 +77,8 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
70
77
  }
71
78
  const normalized = stripQueryAndHash(specifier);
72
79
  let candidate;
73
- if (_path2.default.isAbsolute(normalized)) {
74
- candidate = normalized;
80
+ if (_path2.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
81
+ candidate = _path2.default.normalize(normalized);
75
82
  } else if (normalized.startsWith("/")) {
76
83
  candidate = _path2.default.resolve(outDir, normalized.slice(1));
77
84
  } else {
@@ -172,4 +179,5 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
172
179
 
173
180
 
174
181
 
175
- exports.toAbsoluteOutputPath = toAbsoluteOutputPath; exports.resolveOutputSpecifier = resolveOutputSpecifier; exports.resolveDisabledOptions = resolveDisabledOptions; exports.resolvePackageDir = resolvePackageDir; exports.pushConcurrentTaskFactories = pushConcurrentTaskFactories; exports.resolveTailwindcssImport = resolveTailwindcssImport; exports.rewriteTailwindcssImportsInCode = rewriteTailwindcssImportsInCode;
182
+
183
+ exports.normalizeOutputPathKey = normalizeOutputPathKey; exports.toAbsoluteOutputPath = toAbsoluteOutputPath; exports.resolveOutputSpecifier = resolveOutputSpecifier; exports.resolveDisabledOptions = resolveDisabledOptions; exports.resolvePackageDir = resolvePackageDir; exports.pushConcurrentTaskFactories = pushConcurrentTaskFactories; exports.resolveTailwindcssImport = resolveTailwindcssImport; exports.rewriteTailwindcssImportsInCode = rewriteTailwindcssImportsInCode;