weapp-tailwindcss 4.8.7 → 4.8.9

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 (60) hide show
  1. package/dist/{chunk-JYHBNTYH.mjs → chunk-3BMQ6ZWL.mjs} +2 -2
  2. package/dist/{chunk-ZB6MFKXJ.mjs → chunk-3IP5JCFZ.mjs} +1 -1
  3. package/dist/{chunk-ZSTF2AEN.js → chunk-3URI7W6X.js} +11 -1
  4. package/dist/chunk-4KBHUV2C.js +136 -0
  5. package/dist/{chunk-KRRIFURM.mjs → chunk-5ROWVF7O.mjs} +191 -127
  6. package/dist/{chunk-MIC6E7DV.mjs → chunk-6OE4Q2BC.mjs} +100 -29
  7. package/dist/{chunk-5F64FE7K.js → chunk-6UW6DOPI.js} +5 -5
  8. package/dist/chunk-AGWNHP3C.mjs +136 -0
  9. package/dist/chunk-BYXBJQAS.js +1 -0
  10. package/dist/{chunk-BMUQ4OAB.mjs → chunk-FYYIFZ36.mjs} +13 -107
  11. package/dist/{chunk-YQQ3HDQD.mjs → chunk-H6YMPVI6.mjs} +2 -2
  12. package/dist/{chunk-JW7P34IH.mjs → chunk-HXYNNE6Q.mjs} +178 -59
  13. package/dist/{chunk-3XGTIDA6.mjs → chunk-IXK4ZWFR.mjs} +337 -169
  14. package/dist/{chunk-322IEI2K.js → chunk-J25ZFRYM.js} +172 -53
  15. package/dist/{chunk-GORSBZA2.js → chunk-M4NERJO7.js} +1 -1
  16. package/dist/{chunk-VONLQCG7.js → chunk-PBUQRF6F.js} +211 -147
  17. package/dist/{chunk-DKPIYG24.mjs → chunk-QF65JGNW.mjs} +11 -1
  18. package/dist/{chunk-ESYZLHZI.js → chunk-S2YGU6BU.js} +354 -186
  19. package/dist/{chunk-U4WEDSBF.js → chunk-XQKBWIFI.js} +7 -7
  20. package/dist/{chunk-WUJAJ42W.js → chunk-Z366CKKB.js} +118 -47
  21. package/dist/{chunk-7BASRP3P.js → chunk-ZTGB2D5W.js} +24 -118
  22. package/dist/cli.js +39 -32
  23. package/dist/cli.mjs +12 -5
  24. package/dist/core.js +11 -11
  25. package/dist/core.mjs +5 -5
  26. package/dist/css-macro/postcss.js +1 -1
  27. package/dist/css-macro/postcss.mjs +1 -1
  28. package/dist/css-macro.js +1 -1
  29. package/dist/css-macro.mjs +1 -1
  30. package/dist/defaults.js +3 -3
  31. package/dist/defaults.mjs +2 -2
  32. package/dist/gulp.js +7 -7
  33. package/dist/gulp.mjs +6 -6
  34. package/dist/index.js +11 -11
  35. package/dist/index.mjs +10 -10
  36. package/dist/postcss-html-transform.js +1 -1
  37. package/dist/postcss-html-transform.mjs +1 -1
  38. package/dist/presets.js +4 -4
  39. package/dist/presets.mjs +2 -2
  40. package/dist/reset.js +1 -1
  41. package/dist/reset.mjs +1 -1
  42. package/dist/types.d.mts +7 -0
  43. package/dist/types.d.ts +7 -0
  44. package/dist/types.js +1 -1
  45. package/dist/types.mjs +1 -1
  46. package/dist/vite.js +8 -8
  47. package/dist/vite.mjs +7 -7
  48. package/dist/{weapp-tw-runtime-loader.js → weapp-tw-css-import-rewrite-loader.js} +49 -18
  49. package/dist/weapp-tw-runtime-classset-loader.js +23 -0
  50. package/dist/webpack.d.mts +0 -1
  51. package/dist/webpack.d.ts +0 -1
  52. package/dist/webpack.js +9 -9
  53. package/dist/webpack.mjs +8 -8
  54. package/dist/webpack4.d.mts +0 -1
  55. package/dist/webpack4.d.ts +0 -1
  56. package/dist/webpack4.js +123 -48
  57. package/dist/webpack4.mjs +105 -30
  58. package/package.json +4 -4
  59. package/dist/chunk-PFUB74BL.mjs +0 -61
  60. package/dist/chunk-WYXD5IW7.js +0 -61
@@ -3,13 +3,13 @@
3
3
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
4
4
 
5
5
 
6
- var _chunk5F64FE7Kjs = require('./chunk-5F64FE7K.js');
6
+ var _chunk6UW6DOPIjs = require('./chunk-6UW6DOPI.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunk7BASRP3Pjs = require('./chunk-7BASRP3P.js');
12
+ var _chunkZTGB2D5Wjs = require('./chunk-ZTGB2D5W.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 = _chunk7BASRP3Pjs.createDebug.call(void 0, );
20
+ var debug = _chunkZTGB2D5Wjs.createDebug.call(void 0, );
21
21
  var Transform = _stream2.default.Transform;
22
22
  function createPlugins(options = {}) {
23
- const opts = _chunk7BASRP3Pjs.getCompilerContext.call(void 0, options);
23
+ const opts = _chunkZTGB2D5Wjs.getCompilerContext.call(void 0, options);
24
24
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
25
- const patchRecorderState = _chunk5F64FE7Kjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
25
+ const patchRecorderState = _chunk6UW6DOPIjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
26
26
  source: "runtime",
27
27
  cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
28
28
  });
@@ -36,7 +36,7 @@ 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 _chunk7BASRP3Pjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
39
+ await _chunkZTGB2D5Wjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
40
40
  }
41
41
  async function refreshRuntimeSet(force = false) {
42
42
  await refreshRuntimeState(force);
@@ -44,7 +44,7 @@ function createPlugins(options = {}) {
44
44
  if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
45
45
  return runtimeSet;
46
46
  }
47
- runtimeSet = await _chunk7BASRP3Pjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
47
+ runtimeSet = await _chunkZTGB2D5Wjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
48
48
  runtimeSetInitialized = true;
49
49
  return runtimeSet;
50
50
  }
@@ -1,26 +1,34 @@
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 _chunkWYXD5IW7js = require('./chunk-WYXD5IW7.js');
5
4
 
6
5
 
7
6
 
7
+ var _chunk4KBHUV2Cjs = require('./chunk-4KBHUV2C.js');
8
8
 
9
9
 
10
- var _chunk322IEI2Kjs = require('./chunk-322IEI2K.js');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ var _chunkJ25ZFRYMjs = require('./chunk-J25ZFRYM.js');
11
19
 
12
20
 
13
21
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
14
22
 
15
23
 
16
- var _chunk5F64FE7Kjs = require('./chunk-5F64FE7K.js');
24
+ var _chunk6UW6DOPIjs = require('./chunk-6UW6DOPI.js');
17
25
 
18
26
 
19
27
 
20
28
 
21
29
 
22
30
 
23
- var _chunk7BASRP3Pjs = require('./chunk-7BASRP3P.js');
31
+ var _chunkZTGB2D5Wjs = require('./chunk-ZTGB2D5W.js');
24
32
 
25
33
 
26
34
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -29,15 +37,15 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
29
37
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
30
38
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
31
39
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
32
- var debug = _chunk7BASRP3Pjs.createDebug.call(void 0, );
33
- var weappTailwindcssPackageDir = _chunk322IEI2Kjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
40
+ var debug = _chunkZTGB2D5Wjs.createDebug.call(void 0, );
41
+ var weappTailwindcssPackageDir = _chunkJ25ZFRYMjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
34
42
  var UnifiedWebpackPluginV5 = class {
35
43
  constructor(options = {}) {
36
- this.options = _chunk7BASRP3Pjs.getCompilerContext.call(void 0, options);
37
- this.userSpecifiedRewriteCssImports = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
44
+ this.options = _chunkZTGB2D5Wjs.getCompilerContext.call(void 0, options);
38
45
  this.appType = this.options.appType;
39
46
  }
40
47
  apply(compiler) {
48
+ compiler.options = compiler.options || {};
41
49
  const {
42
50
  mainCssChunkMatcher,
43
51
  disabled,
@@ -49,6 +57,7 @@ var UnifiedWebpackPluginV5 = class {
49
57
  templateHandler,
50
58
  jsHandler,
51
59
  runtimeLoaderPath,
60
+ runtimeCssImportRewriteLoaderPath,
52
61
  cache,
53
62
  twPatcher: initialTwPatcher,
54
63
  refreshTailwindcssPatcher
@@ -56,14 +65,18 @@ var UnifiedWebpackPluginV5 = class {
56
65
  if (disabled) {
57
66
  return;
58
67
  }
59
- const shouldRewriteCssImports = this.options.rewriteCssImports !== false && (this.userSpecifiedRewriteCssImports || (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4);
68
+ const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
69
+ const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false;
70
+ const isMpxApp = _chunkJ25ZFRYMjs.isMpx.call(void 0, this.appType);
60
71
  if (shouldRewriteCssImports) {
61
- _chunkWYXD5IW7js.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
72
+ _chunk4KBHUV2Cjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
62
73
  pkgDir: weappTailwindcssPackageDir,
63
- enabled: true
74
+ enabled: true,
75
+ appType: this.appType
64
76
  });
77
+ _chunkJ25ZFRYMjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
65
78
  }
66
- const patchRecorderState = _chunk5F64FE7Kjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
79
+ const patchRecorderState = _chunk6UW6DOPIjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
67
80
  source: "runtime",
68
81
  cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
69
82
  });
@@ -74,52 +87,110 @@ var UnifiedWebpackPluginV5 = class {
74
87
  onPatchCompleted: patchRecorderState.onPatchCompleted
75
88
  };
76
89
  const refreshRuntimeState = async (force) => {
77
- await _chunk7BASRP3Pjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
90
+ await _chunkZTGB2D5Wjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
78
91
  };
79
92
  const { Compilation, sources, NormalModule } = compiler.webpack;
80
93
  const { ConcatSource } = sources;
81
94
  async function getClassSetInLoader() {
82
95
  await refreshRuntimeState(true);
83
96
  await runtimeState.patchPromise;
84
- await _chunk7BASRP3Pjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
97
+ await _chunkZTGB2D5Wjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
85
98
  }
86
- onLoad();
87
- const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
88
- const isExisted = _fs2.default.existsSync(loader);
99
+ const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
100
+ const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
101
+ const runtimeClassSetLoaderExists = _fs2.default.existsSync(runtimeClassSetLoader);
102
+ const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? _fs2.default.existsSync(runtimeCssImportRewriteLoader) : false;
89
103
  const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
90
- pkgDir: weappTailwindcssPackageDir
104
+ pkgDir: weappTailwindcssPackageDir,
105
+ appType: this.appType
91
106
  } : void 0;
92
- const runtimeLoaderOptions = {
93
- getClassSet: getClassSetInLoader,
94
- rewriteCssImports: runtimeLoaderRewriteOptions
107
+ const classSetLoaderOptions = {
108
+ getClassSet: getClassSetInLoader
95
109
  };
96
- const createRuntimeLoaderEntry = () => ({
97
- loader,
98
- options: runtimeLoaderOptions,
110
+ const { findRewriteAnchor, findClassSetAnchor } = _chunk4KBHUV2Cjs.createLoaderAnchorFinders.call(void 0, this.appType);
111
+ const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
112
+ rewriteCssImports: runtimeLoaderRewriteOptions
113
+ } : void 0;
114
+ onLoad();
115
+ if (shouldRewriteCssImports && isMpxApp) {
116
+ _chunkJ25ZFRYMjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
117
+ }
118
+ if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
119
+ _chunkJ25ZFRYMjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
120
+ }
121
+ const createRuntimeClassSetLoaderEntry = () => ({
122
+ loader: runtimeClassSetLoader,
123
+ options: classSetLoaderOptions,
99
124
  ident: null,
100
125
  type: null
101
126
  });
102
- compiler.hooks.compilation.tap(_chunk7BASRP3Pjs.pluginName, (compilation) => {
103
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunk7BASRP3Pjs.pluginName, (_loaderContext, module) => {
104
- if (!isExisted) {
127
+ const createCssImportRewriteLoaderEntry = () => {
128
+ if (!runtimeCssImportRewriteLoader) {
129
+ return null;
130
+ }
131
+ return {
132
+ loader: runtimeCssImportRewriteLoader,
133
+ options: cssImportRewriteLoaderOptions,
134
+ ident: null,
135
+ type: null
136
+ };
137
+ };
138
+ compiler.hooks.compilation.tap(_chunkZTGB2D5Wjs.pluginName, (compilation) => {
139
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkZTGB2D5Wjs.pluginName, (_loaderContext, module) => {
140
+ const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
141
+ if (!hasRuntimeLoader) {
105
142
  return;
106
143
  }
144
+ _chunkJ25ZFRYMjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
107
145
  const loaderEntries = module.loaders || [];
108
- const idx = loaderEntries.findIndex((entry) => {
109
- if (!_optionalChain([entry, 'optionalAccess', _ => _.loader])) {
110
- return false;
111
- }
112
- return entry.loader.includes("postcss-loader");
113
- });
114
- if (idx === -1) {
146
+ let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
147
+ const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
148
+ const isCssModule = _chunk4KBHUV2Cjs.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
149
+ if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
150
+ debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
151
+ }
152
+ if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) {
153
+ debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
154
+ } else if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) {
155
+ debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
156
+ }
157
+ if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) {
115
158
  return;
116
159
  }
117
- const runtimeLoaderEntry = createRuntimeLoaderEntry();
118
- loaderEntries.splice(idx + 1, 0, runtimeLoaderEntry);
160
+ const anchorlessInsert = (entry, position) => {
161
+ if (position === "after") {
162
+ loaderEntries.push(entry);
163
+ } else {
164
+ loaderEntries.unshift(entry);
165
+ }
166
+ };
167
+ if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader) {
168
+ const existingIndex = loaderEntries.findIndex((entry) => _optionalChain([entry, 'access', _ => _.loader, 'optionalAccess', _2 => _2.includes, 'optionalCall', _3 => _3(runtimeCssImportRewriteLoader)]));
169
+ const rewriteLoaderEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
170
+ if (rewriteLoaderEntry) {
171
+ const anchorIndex = findRewriteAnchor(loaderEntries);
172
+ if (anchorIndex === -1) {
173
+ anchorlessInsert(rewriteLoaderEntry, "after");
174
+ } else {
175
+ loaderEntries.splice(anchorIndex + 1, 0, rewriteLoaderEntry);
176
+ }
177
+ rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
178
+ }
179
+ }
180
+ if (runtimeClassSetLoaderExists && !_chunk4KBHUV2Cjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
181
+ const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
182
+ const anchorIndex = findClassSetAnchor(loaderEntries);
183
+ if (anchorIndex === -1) {
184
+ anchorlessInsert(classSetLoaderEntry, "before");
185
+ } else {
186
+ const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
187
+ loaderEntries.splice(insertIndex, 0, classSetLoaderEntry);
188
+ }
189
+ }
119
190
  });
120
191
  compilation.hooks.processAssets.tapPromise(
121
192
  {
122
- name: _chunk7BASRP3Pjs.pluginName,
193
+ name: _chunkZTGB2D5Wjs.pluginName,
123
194
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
124
195
  },
125
196
  async (assets) => {
@@ -132,18 +203,18 @@ var UnifiedWebpackPluginV5 = class {
132
203
  }
133
204
  }
134
205
  const entries = Object.entries(assets);
135
- const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _2 => _2.compiler, 'optionalAccess', _3 => _3.outputPath]), () => ( compiler.outputPath));
136
- const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _4 => _4.outputOptions, 'optionalAccess', _5 => _5.path]), () => ( _process2.default.cwd()));
206
+ const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _4 => _4.compiler, 'optionalAccess', _5 => _5.outputPath]), () => ( compiler.outputPath));
207
+ const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _6 => _6.outputOptions, 'optionalAccess', _7 => _7.path]), () => ( _process2.default.cwd()));
137
208
  const jsAssets = /* @__PURE__ */ new Map();
138
209
  for (const [file] of entries) {
139
210
  if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
140
- const absolute = _chunk322IEI2Kjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
211
+ const absolute = _chunkJ25ZFRYMjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
141
212
  jsAssets.set(absolute, file);
142
213
  }
143
214
  }
144
215
  const moduleGraphOptions = {
145
216
  resolve(specifier, importer) {
146
- return _chunk322IEI2Kjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
217
+ return _chunkJ25ZFRYMjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
147
218
  },
148
219
  load: (id) => {
149
220
  const assetName = jsAssets.get(id);
@@ -188,7 +259,7 @@ var UnifiedWebpackPluginV5 = class {
188
259
  const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
189
260
  await refreshRuntimeState(true);
190
261
  await runtimeState.patchPromise;
191
- const runtimeSet = await _chunk7BASRP3Pjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
262
+ const runtimeSet = await _chunkZTGB2D5Wjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
192
263
  debug("get runtimeSet, class count: %d", runtimeSet.size);
193
264
  const tasks = [];
194
265
  if (Array.isArray(groupedEntries.html)) {
@@ -225,12 +296,12 @@ var UnifiedWebpackPluginV5 = class {
225
296
  const jsTaskFactories = [];
226
297
  if (Array.isArray(groupedEntries.js)) {
227
298
  for (const [file] of groupedEntries.js) {
228
- const cacheKey = _chunkWYXD5IW7js.getCacheKey.call(void 0, file);
299
+ const cacheKey = _chunk4KBHUV2Cjs.getCacheKey.call(void 0, file);
229
300
  const asset = compilation.getAsset(file);
230
301
  if (!asset) {
231
302
  continue;
232
303
  }
233
- const absoluteFile = _chunk322IEI2Kjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
304
+ const absoluteFile = _chunkJ25ZFRYMjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
234
305
  const initialSource = asset.source.source();
235
306
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
236
307
  jsTaskFactories.push(async () => {
@@ -246,8 +317,8 @@ var UnifiedWebpackPluginV5 = class {
246
317
  },
247
318
  transform: async () => {
248
319
  const currentAsset = compilation.getAsset(file);
249
- const currentSourceValue = _optionalChain([currentAsset, 'optionalAccess', _6 => _6.source, 'access', _7 => _7.source, 'call', _8 => _8()]);
250
- const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : _nullishCoalesce(_optionalChain([currentSourceValue, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]), () => ( ""));
320
+ const currentSourceValue = _optionalChain([currentAsset, 'optionalAccess', _8 => _8.source, 'access', _9 => _9.source, 'call', _10 => _10()]);
321
+ const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : _nullishCoalesce(_optionalChain([currentSourceValue, 'optionalAccess', _11 => _11.toString, 'call', _12 => _12()]), () => ( ""));
251
322
  const { code, linked } = await jsHandler(currentSource, runtimeSet, {
252
323
  filename: absoluteFile,
253
324
  moduleGraph: moduleGraphOptions,
@@ -305,7 +376,7 @@ var UnifiedWebpackPluginV5 = class {
305
376
  );
306
377
  }
307
378
  }
308
- _chunk322IEI2Kjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
379
+ _chunkJ25ZFRYMjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
309
380
  await Promise.all(tasks);
310
381
  debug("end");
311
382
  onEnd();
@@ -1,10 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkESYZLHZIjs = require('./chunk-ESYZLHZI.js');
5
4
 
6
5
 
7
- var _chunkZSTF2AENjs = require('./chunk-ZSTF2AEN.js');
6
+ var _chunkS2YGU6BUjs = require('./chunk-S2YGU6BU.js');
7
+
8
+
9
+ var _chunk3URI7W6Xjs = require('./chunk-3URI7W6X.js');
8
10
 
9
11
 
10
12
 
@@ -25,7 +27,7 @@ function createDebug(prefix) {
25
27
 
26
28
  // src/tailwindcss/runtime.ts
27
29
  var debug = createDebug("[tailwindcss:runtime] ");
28
- var refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
30
+ var refreshTailwindcssPatcherSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
29
31
  var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
30
32
  function getCacheEntry(twPatcher) {
31
33
  let entry = runtimeClassSetCache.get(twPatcher);
@@ -104,7 +106,11 @@ function tryGetRuntimeClassSetSync(twPatcher) {
104
106
  return void 0;
105
107
  }
106
108
  try {
107
- return twPatcher.getClassSetSync();
109
+ const set = twPatcher.getClassSetSync();
110
+ if (set && set.size === 0) {
111
+ return void 0;
112
+ }
113
+ return set;
108
114
  } catch (error) {
109
115
  if (twPatcher.majorVersion === 4) {
110
116
  debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
@@ -181,7 +187,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
181
187
  // package.json
182
188
  var package_default = {
183
189
  name: "weapp-tailwindcss",
184
- version: "4.8.7",
190
+ version: "4.8.9",
185
191
  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!",
186
192
  author: "ice breaker <1324318532@qq.com>",
187
193
  license: "MIT",
@@ -434,7 +440,7 @@ function formatRelativeToBase(targetPath, baseDir) {
434
440
  }
435
441
  function resolveRecordLocation(baseDir) {
436
442
  const normalizedBase = _path2.default.normalize(baseDir);
437
- const packageRoot = _nullishCoalesce(_chunkESYZLHZIjs.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
443
+ const packageRoot = _nullishCoalesce(_chunkS2YGU6BUjs.findNearestPackageRoot.call(void 0, normalizedBase), () => ( normalizedBase));
438
444
  const packageJsonPath = _path2.default.join(packageRoot, "package.json");
439
445
  const hasPackageJson = _fs.existsSync.call(void 0, packageJsonPath);
440
446
  const recordKeySource = hasPackageJson ? packageJsonPath : normalizedBase;
@@ -2721,121 +2727,24 @@ function applyLoggerLevel(logLevel) {
2721
2727
  }
2722
2728
 
2723
2729
  // src/context/index.ts
2724
- var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
2725
- function includesToken(list, token) {
2726
- return list.some((candidate) => {
2727
- if (typeof token === "string") {
2728
- if (typeof candidate === "string") {
2729
- return candidate === token;
2730
- }
2731
- candidate.lastIndex = 0;
2732
- return candidate.test(token);
2733
- }
2734
- if (typeof candidate === "string") {
2735
- token.lastIndex = 0;
2736
- return token.test(candidate);
2737
- }
2738
- return candidate.source === token.source && candidate.flags === token.flags;
2739
- });
2740
- }
2741
- function ensureDefaultsIncluded(value) {
2742
- if (value === true) {
2743
- return {
2744
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
2745
- };
2746
- }
2747
- if (Array.isArray(value)) {
2748
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
2749
- return value;
2750
- }
2751
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
2752
- return missing.length > 0 ? [...value, ...missing] : value;
2753
- }
2754
- if (value && typeof value === "object") {
2755
- const include = value.includeCustomProperties;
2756
- if (!Array.isArray(include)) {
2757
- return {
2758
- ...value,
2759
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
2760
- };
2761
- }
2762
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
2763
- return value;
2764
- }
2765
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
2766
- return missing.length > 0 ? {
2767
- ...value,
2768
- includeCustomProperties: [...include, ...missing]
2769
- } : value;
2770
- }
2771
- return value;
2772
- }
2773
- function normalizeCssEntriesConfig(entries) {
2774
- if (!entries) {
2775
- return void 0;
2776
- }
2777
- if (typeof entries === "string") {
2778
- const trimmed = entries.trim();
2779
- return trimmed ? [trimmed] : void 0;
2780
- }
2781
- if (!Array.isArray(entries)) {
2782
- return void 0;
2783
- }
2784
- const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
2785
- return normalized.length > 0 ? normalized : void 0;
2786
- }
2787
- function hasConfiguredCssEntries(ctx) {
2788
- if (normalizeCssEntriesConfig(ctx.cssEntries)) {
2789
- return true;
2790
- }
2791
- if (normalizeCssEntriesConfig(_optionalChain([ctx, 'access', _86 => _86.tailwindcss, 'optionalAccess', _87 => _87.v4, 'optionalAccess', _88 => _88.cssEntries]))) {
2792
- return true;
2793
- }
2794
- const patcherOptions = ctx.tailwindcssPatcherOptions;
2795
- if (patcherOptions) {
2796
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _89 => _89.tailwind, 'optionalAccess', _90 => _90.v4, 'optionalAccess', _91 => _91.cssEntries]))) {
2797
- return true;
2798
- }
2799
- if (normalizeCssEntriesConfig(_optionalChain([patcherOptions, 'access', _92 => _92.patch, 'optionalAccess', _93 => _93.tailwindcss, 'optionalAccess', _94 => _94.v4, 'optionalAccess', _95 => _95.cssEntries]))) {
2800
- return true;
2801
- }
2802
- }
2803
- return false;
2804
- }
2805
- var hasWarnedMissingCssEntries = false;
2806
- function warnMissingCssEntries(ctx, patcher) {
2807
- if (hasWarnedMissingCssEntries) {
2808
- return;
2809
- }
2810
- if (_optionalChain([patcher, 'optionalAccess', _96 => _96.majorVersion]) !== 4) {
2811
- return;
2812
- }
2813
- if (hasConfiguredCssEntries(ctx)) {
2814
- return;
2815
- }
2816
- hasWarnedMissingCssEntries = true;
2817
- _logger.logger.warn(
2818
- '[tailwindcss@4] \u672A\u68C0\u6D4B\u5230 cssEntries \u914D\u7F6E\u3002\u8BF7\u4F20\u5165\u5305\u542B tailwindcss \u5F15\u7528\u7684 CSS \u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 cssEntries: ["/absolute/path/to/src/app.css"]\uFF0C\u5426\u5219 tailwindcss \u751F\u6210\u7684\u7C7B\u540D\u4E0D\u4F1A\u53C2\u4E0E\u8F6C\u8BD1\u3002'
2819
- );
2820
- }
2821
2730
  async function clearTailwindcssPatcherCache(patcher, options) {
2822
2731
  if (!patcher) {
2823
2732
  return;
2824
2733
  }
2825
- const cacheOptions = _optionalChain([patcher, 'access', _97 => _97.options, 'optionalAccess', _98 => _98.cache]);
2734
+ const cacheOptions = _optionalChain([patcher, 'access', _86 => _86.options, 'optionalAccess', _87 => _87.cache]);
2826
2735
  if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) {
2827
2736
  return;
2828
2737
  }
2829
2738
  const cachePaths = /* @__PURE__ */ new Map();
2830
2739
  const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
2831
- if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _99 => _99.path])) {
2740
+ if (_optionalChain([normalizedCacheOptions, 'optionalAccess', _88 => _88.path])) {
2832
2741
  cachePaths.set(normalizedCacheOptions.path, false);
2833
2742
  }
2834
- const privateCachePath = _optionalChain([patcher, 'optionalAccess', _100 => _100.cacheStore, 'optionalAccess', _101 => _101.options, 'optionalAccess', _102 => _102.path]);
2743
+ const privateCachePath = _optionalChain([patcher, 'optionalAccess', _89 => _89.cacheStore, 'optionalAccess', _90 => _90.options, 'optionalAccess', _91 => _91.path]);
2835
2744
  if (privateCachePath) {
2836
2745
  cachePaths.set(privateCachePath, false);
2837
2746
  }
2838
- if (_optionalChain([options, 'optionalAccess', _103 => _103.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _104 => _104.dir])) {
2747
+ if (_optionalChain([options, 'optionalAccess', _92 => _92.removeDirectory]) && _optionalChain([normalizedCacheOptions, 'optionalAccess', _93 => _93.dir])) {
2839
2748
  cachePaths.set(normalizedCacheOptions.dir, true);
2840
2749
  }
2841
2750
  if (!cachePaths.size) {
@@ -2846,7 +2755,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2846
2755
  await _promises.rm.call(void 0, cachePath, { force: true, recursive });
2847
2756
  } catch (error) {
2848
2757
  const err = error;
2849
- if (_optionalChain([err, 'optionalAccess', _105 => _105.code]) === "ENOENT") {
2758
+ if (_optionalChain([err, 'optionalAccess', _94 => _94.code]) === "ENOENT") {
2850
2759
  continue;
2851
2760
  }
2852
2761
  _logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
@@ -2856,23 +2765,20 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2856
2765
  function createInternalCompilerContext(opts) {
2857
2766
  const ctx = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
2858
2767
  opts,
2859
- _chunkZSTF2AENjs.getDefaultOptions.call(void 0, ),
2768
+ _chunk3URI7W6Xjs.getDefaultOptions.call(void 0, ),
2860
2769
  {}
2861
2770
  );
2862
2771
  ctx.escapeMap = ctx.customReplaceDictionary;
2863
2772
  applyLoggerLevel(ctx.logLevel);
2864
- const twPatcher = _chunkESYZLHZIjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2773
+ const twPatcher = _chunkS2YGU6BUjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2865
2774
  logTailwindcssTarget("runtime", twPatcher, ctx.tailwindcssBasedir);
2866
- if (_optionalChain([twPatcher, 'access', _106 => _106.packageInfo, 'optionalAccess', _107 => _107.version])) {
2775
+ if (_optionalChain([twPatcher, 'access', _95 => _95.packageInfo, 'optionalAccess', _96 => _96.version])) {
2867
2776
  _logger.logger.success(`\u5F53\u524D\u4F7F\u7528 ${_logger.pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${_logger.pc.underline(_logger.pc.bold(_logger.pc.green(twPatcher.packageInfo.version)))}`);
2868
2777
  } else {
2869
2778
  _logger.logger.warn(`${_logger.pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
2870
2779
  }
2871
- warnMissingCssEntries(ctx, twPatcher);
2872
- let cssCalcOptions = _nullishCoalesce(ctx.cssCalc, () => ( twPatcher.majorVersion === 4));
2873
- if (twPatcher.majorVersion === 4 && cssCalcOptions) {
2874
- cssCalcOptions = ensureDefaultsIncluded(cssCalcOptions);
2875
- }
2780
+ _chunkS2YGU6BUjs.warnMissingCssEntries.call(void 0, ctx, twPatcher);
2781
+ const cssCalcOptions = _chunkS2YGU6BUjs.applyV4CssCalcDefaults.call(void 0, ctx.cssCalc, twPatcher);
2876
2782
  ctx.cssCalc = cssCalcOptions;
2877
2783
  const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
2878
2784
  const { styleHandler, jsHandler: jsHandler2, templateHandler } = createHandlersFromContext(
@@ -2887,11 +2793,11 @@ function createInternalCompilerContext(opts) {
2887
2793
  ctx.twPatcher = twPatcher;
2888
2794
  const refreshTailwindcssPatcher = async (options) => {
2889
2795
  const previousPatcher = ctx.twPatcher;
2890
- if (_optionalChain([options, 'optionalAccess', _108 => _108.clearCache]) !== false) {
2796
+ if (_optionalChain([options, 'optionalAccess', _97 => _97.clearCache]) !== false) {
2891
2797
  await clearTailwindcssPatcherCache(previousPatcher);
2892
2798
  }
2893
2799
  invalidateRuntimeClassSet(previousPatcher);
2894
- const nextPatcher = _chunkESYZLHZIjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2800
+ const nextPatcher = _chunkS2YGU6BUjs.createTailwindcssPatcherFromContext.call(void 0, ctx);
2895
2801
  Object.assign(previousPatcher, nextPatcher);
2896
2802
  ctx.twPatcher = previousPatcher;
2897
2803
  return previousPatcher;