weapp-tailwindcss 4.8.8 → 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 (33) hide show
  1. package/dist/{chunk-M5UEOYBI.mjs → chunk-3BMQ6ZWL.mjs} +2 -2
  2. package/dist/{chunk-2E724WCE.js → chunk-4KBHUV2C.js} +6 -8
  3. package/dist/{chunk-IH3HQU7U.mjs → chunk-5ROWVF7O.mjs} +3 -3
  4. package/dist/{chunk-UTCO4JMJ.mjs → chunk-6OE4Q2BC.mjs} +9 -11
  5. package/dist/{chunk-L5ER4544.js → chunk-6UW6DOPI.js} +5 -5
  6. package/dist/{chunk-PVJDRL3I.mjs → chunk-AGWNHP3C.mjs} +3 -5
  7. package/dist/{chunk-RUXC4E2M.mjs → chunk-FYYIFZ36.mjs} +8 -4
  8. package/dist/{chunk-FB3ASCHC.mjs → chunk-H6YMPVI6.mjs} +2 -2
  9. package/dist/{chunk-RYGPCUUT.mjs → chunk-HXYNNE6Q.mjs} +118 -6
  10. package/dist/{chunk-6TO3GT5S.mjs → chunk-IXK4ZWFR.mjs} +47 -165
  11. package/dist/{chunk-XHR5K5ZT.js → chunk-J25ZFRYM.js} +120 -7
  12. package/dist/{chunk-WF4UE272.js → chunk-PBUQRF6F.js} +22 -22
  13. package/dist/{chunk-P3AQCOOM.js → chunk-S2YGU6BU.js} +28 -146
  14. package/dist/{chunk-Y5XG47XY.js → chunk-XQKBWIFI.js} +7 -7
  15. package/dist/{chunk-E7PFK6BW.js → chunk-Z366CKKB.js} +29 -31
  16. package/dist/{chunk-2KZ4VTIA.js → chunk-ZTGB2D5W.js} +13 -9
  17. package/dist/cli.js +28 -28
  18. package/dist/cli.mjs +2 -2
  19. package/dist/core.js +9 -9
  20. package/dist/core.mjs +3 -3
  21. package/dist/gulp.js +5 -5
  22. package/dist/gulp.mjs +4 -4
  23. package/dist/index.js +9 -9
  24. package/dist/index.mjs +8 -8
  25. package/dist/presets.js +3 -3
  26. package/dist/presets.mjs +1 -1
  27. package/dist/vite.js +6 -6
  28. package/dist/vite.mjs +5 -5
  29. package/dist/webpack.js +7 -7
  30. package/dist/webpack.mjs +6 -6
  31. package/dist/webpack4.js +31 -32
  32. package/dist/webpack4.mjs +10 -11
  33. package/package.json +5 -5
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createPatchTargetRecorder,
3
3
  createTailwindPatchPromise
4
- } from "./chunk-RUXC4E2M.mjs";
4
+ } from "./chunk-FYYIFZ36.mjs";
5
5
  import {
6
6
  logger
7
- } from "./chunk-6TO3GT5S.mjs";
7
+ } from "./chunk-IXK4ZWFR.mjs";
8
8
 
9
9
  // src/tailwindcss/recorder.ts
10
10
  function setupPatchRecorder(patcher, baseDir, options) {
@@ -1,12 +1,10 @@
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
- var _chunkXHR5K5ZTjs = require('./chunk-XHR5K5ZT.js');
4
3
 
4
+ var _chunkJ25ZFRYMjs = require('./chunk-J25ZFRYM.js');
5
5
 
6
- var _chunk2KZ4VTIAjs = require('./chunk-2KZ4VTIA.js');
7
6
 
8
-
9
- var _chunkP3AQCOOMjs = require('./chunk-P3AQCOOM.js');
7
+ var _chunkZTGB2D5Wjs = require('./chunk-ZTGB2D5W.js');
10
8
 
11
9
  // src/bundlers/webpack/shared/css-imports.ts
12
10
  var CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
@@ -36,7 +34,7 @@ function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
36
34
  if (!CSS_EXT_RE.test(normalizedIssuer)) {
37
35
  return;
38
36
  }
39
- const resolved = _chunkXHR5K5ZTjs.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
37
+ const resolved = _chunkJ25ZFRYMjs.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
40
38
  if (!resolved) {
41
39
  return;
42
40
  }
@@ -46,8 +44,8 @@ function applyTailwindcssCssImportRewrite(compiler, options) {
46
44
  if (!options.enabled) {
47
45
  return;
48
46
  }
49
- compiler.hooks.normalModuleFactory.tap(_chunk2KZ4VTIAjs.pluginName, (factory) => {
50
- factory.hooks.beforeResolve.tap(_chunk2KZ4VTIAjs.pluginName, (data) => {
47
+ compiler.hooks.normalModuleFactory.tap(_chunkZTGB2D5Wjs.pluginName, (factory) => {
48
+ factory.hooks.beforeResolve.tap(_chunkZTGB2D5Wjs.pluginName, (data) => {
51
49
  rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
52
50
  });
53
51
  });
@@ -77,7 +75,7 @@ function createPrioritizedFinder(targets) {
77
75
  };
78
76
  }
79
77
  function createLoaderAnchorFinders(appType) {
80
- if (_chunkP3AQCOOMjs.isMpx.call(void 0, appType)) {
78
+ if (_chunkJ25ZFRYMjs.isMpx.call(void 0, appType)) {
81
79
  return {
82
80
  findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
83
81
  findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
@@ -5,13 +5,13 @@ import {
5
5
  resolveTailwindcssImport,
6
6
  rewriteTailwindcssImportsInCode,
7
7
  toAbsoluteOutputPath
8
- } from "./chunk-RYGPCUUT.mjs";
8
+ } from "./chunk-HXYNNE6Q.mjs";
9
9
  import {
10
10
  processCachedTask
11
11
  } from "./chunk-RRHPTTCP.mjs";
12
12
  import {
13
13
  setupPatchRecorder
14
- } from "./chunk-M5UEOYBI.mjs";
14
+ } from "./chunk-3BMQ6ZWL.mjs";
15
15
  import {
16
16
  collectRuntimeClassSet,
17
17
  createAttributeMatcher,
@@ -22,7 +22,7 @@ import {
22
22
  replaceWxml,
23
23
  toCustomAttributesEntities,
24
24
  vitePluginName
25
- } from "./chunk-RUXC4E2M.mjs";
25
+ } from "./chunk-FYYIFZ36.mjs";
26
26
  import {
27
27
  getGroupedEntries
28
28
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -4,33 +4,31 @@ import {
4
4
  getCacheKey,
5
5
  hasLoaderEntry,
6
6
  isCssLikeModuleResource
7
- } from "./chunk-PVJDRL3I.mjs";
7
+ } from "./chunk-AGWNHP3C.mjs";
8
8
  import {
9
+ ensureMpxTailwindcssAliases,
10
+ injectMpxCssRewritePreRules,
11
+ isMpx,
12
+ patchMpxLoaderResolve,
9
13
  pushConcurrentTaskFactories,
10
14
  resolveOutputSpecifier,
11
15
  resolvePackageDir,
16
+ setupMpxTailwindcssRedirect,
12
17
  toAbsoluteOutputPath
13
- } from "./chunk-RYGPCUUT.mjs";
18
+ } from "./chunk-HXYNNE6Q.mjs";
14
19
  import {
15
20
  processCachedTask
16
21
  } from "./chunk-RRHPTTCP.mjs";
17
22
  import {
18
23
  setupPatchRecorder
19
- } from "./chunk-M5UEOYBI.mjs";
24
+ } from "./chunk-3BMQ6ZWL.mjs";
20
25
  import {
21
26
  collectRuntimeClassSet,
22
27
  createDebug,
23
28
  getCompilerContext,
24
29
  pluginName,
25
30
  refreshTailwindRuntimeState
26
- } from "./chunk-RUXC4E2M.mjs";
27
- import {
28
- ensureMpxTailwindcssAliases,
29
- injectMpxCssRewritePreRules,
30
- isMpx,
31
- patchMpxLoaderResolve,
32
- setupMpxTailwindcssRedirect
33
- } from "./chunk-6TO3GT5S.mjs";
31
+ } from "./chunk-FYYIFZ36.mjs";
34
32
  import {
35
33
  getGroupedEntries
36
34
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -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 _chunk2KZ4VTIAjs = require('./chunk-2KZ4VTIA.js');
4
+ var _chunkZTGB2D5Wjs = require('./chunk-ZTGB2D5W.js');
5
5
 
6
6
 
7
- var _chunkP3AQCOOMjs = require('./chunk-P3AQCOOM.js');
7
+ var _chunkS2YGU6BUjs = require('./chunk-S2YGU6BU.js');
8
8
 
9
9
  // src/tailwindcss/recorder.ts
10
10
  function setupPatchRecorder(patcher, baseDir, options) {
11
- const recorder = _chunk2KZ4VTIAjs.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
11
+ const recorder = _chunkZTGB2D5Wjs.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
- _chunkP3AQCOOMjs.logger.info("%s%s", prefix, recorder.message);
14
+ _chunkS2YGU6BUjs.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 ? _chunk2KZ4VTIAjs.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
19
+ const patchPromise = patcher ? _chunkZTGB2D5Wjs.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
20
20
  return {
21
21
  recorder,
22
22
  patchPromise,
@@ -1,12 +1,10 @@
1
1
  import {
2
+ isMpx,
2
3
  resolveTailwindcssImport
3
- } from "./chunk-RYGPCUUT.mjs";
4
+ } from "./chunk-HXYNNE6Q.mjs";
4
5
  import {
5
6
  pluginName
6
- } from "./chunk-RUXC4E2M.mjs";
7
- import {
8
- isMpx
9
- } from "./chunk-6TO3GT5S.mjs";
7
+ } from "./chunk-FYYIFZ36.mjs";
10
8
 
11
9
  // src/bundlers/webpack/shared/css-imports.ts
12
10
  var CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
@@ -3,7 +3,7 @@ import {
3
3
  createTailwindcssPatcherFromContext,
4
4
  findNearestPackageRoot,
5
5
  warnMissingCssEntries
6
- } from "./chunk-6TO3GT5S.mjs";
6
+ } from "./chunk-IXK4ZWFR.mjs";
7
7
  import {
8
8
  getDefaultOptions
9
9
  } from "./chunk-QF65JGNW.mjs";
@@ -27,7 +27,7 @@ function createDebug(prefix) {
27
27
 
28
28
  // src/tailwindcss/runtime.ts
29
29
  var debug = createDebug("[tailwindcss:runtime] ");
30
- var refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
30
+ var refreshTailwindcssPatcherSymbol = /* @__PURE__ */ Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
31
31
  var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
32
32
  function getCacheEntry(twPatcher) {
33
33
  let entry = runtimeClassSetCache.get(twPatcher);
@@ -106,7 +106,11 @@ function tryGetRuntimeClassSetSync(twPatcher) {
106
106
  return void 0;
107
107
  }
108
108
  try {
109
- return twPatcher.getClassSetSync();
109
+ const set = twPatcher.getClassSetSync();
110
+ if (set && set.size === 0) {
111
+ return void 0;
112
+ }
113
+ return set;
110
114
  } catch (error) {
111
115
  if (twPatcher.majorVersion === 4) {
112
116
  debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
@@ -183,7 +187,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
183
187
  // package.json
184
188
  var package_default = {
185
189
  name: "weapp-tailwindcss",
186
- version: "4.8.8",
190
+ version: "4.8.9",
187
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!",
188
192
  author: "ice breaker <1324318532@qq.com>",
189
193
  license: "MIT",
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-RRHPTTCP.mjs";
4
4
  import {
5
5
  setupPatchRecorder
6
- } from "./chunk-M5UEOYBI.mjs";
6
+ } from "./chunk-3BMQ6ZWL.mjs";
7
7
  import {
8
8
  collectRuntimeClassSet,
9
9
  createDebug,
10
10
  getCompilerContext,
11
11
  refreshTailwindRuntimeState
12
- } from "./chunk-RUXC4E2M.mjs";
12
+ } from "./chunk-FYYIFZ36.mjs";
13
13
 
14
14
  // src/bundlers/gulp/index.ts
15
15
  import { Buffer } from "buffer";
@@ -1,7 +1,3 @@
1
- import {
2
- isMpx
3
- } from "./chunk-6TO3GT5S.mjs";
4
-
5
1
  // src/bundlers/shared/module-graph.ts
6
2
  import path from "path";
7
3
  var QUERY_HASH_RE = /[?#].*$/u;
@@ -66,8 +62,119 @@ function resolvePackageDir(name) {
66
62
  return path2.dirname(pkgPath);
67
63
  }
68
64
 
69
- // src/bundlers/shared/css-imports.ts
65
+ // src/shared/mpx.ts
66
+ import path4 from "path";
67
+
68
+ // src/shared/tailwindcss-css-redirect.ts
69
+ import Module from "module";
70
70
  import path3 from "path";
71
+ var moduleWithMutableResolve = Module;
72
+ var patched = /* @__PURE__ */ new WeakSet();
73
+ function installTailwindcssCssRedirect(pkgDir) {
74
+ const target = path3.join(pkgDir, "index.css");
75
+ const original = moduleWithMutableResolve._resolveFilename;
76
+ if (patched.has(original)) {
77
+ return;
78
+ }
79
+ const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
80
+ const resolveTailwindcssCss = (request, parent, isMain, options) => {
81
+ if (replacements.has(request)) {
82
+ return target;
83
+ }
84
+ if (request.startsWith("tailwindcss/")) {
85
+ return path3.join(pkgDir, request.slice("tailwindcss/".length));
86
+ }
87
+ return original(request, parent, isMain, options);
88
+ };
89
+ moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
90
+ patched.add(moduleWithMutableResolve._resolveFilename);
91
+ }
92
+
93
+ // src/shared/mpx.ts
94
+ var MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
95
+ function isMpxStyleResourceQuery(query) {
96
+ if (typeof query !== "string") {
97
+ return false;
98
+ }
99
+ return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
100
+ }
101
+ function isMpx(appType) {
102
+ return appType === "mpx";
103
+ }
104
+ function getTailwindcssCssEntry(pkgDir) {
105
+ return path4.join(pkgDir, "index.css");
106
+ }
107
+ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
108
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
109
+ compiler.options = compiler.options || {};
110
+ compiler.options.resolve = compiler.options.resolve || {};
111
+ const alias = compiler.options.resolve.alias ?? {};
112
+ if (Array.isArray(alias)) {
113
+ alias.push(
114
+ { name: "tailwindcss", alias: tailwindcssCssEntry },
115
+ { name: "tailwindcss$", alias: tailwindcssCssEntry }
116
+ );
117
+ } else {
118
+ compiler.options.resolve.alias = alias;
119
+ alias.tailwindcss = tailwindcssCssEntry;
120
+ alias.tailwindcss$ = tailwindcssCssEntry;
121
+ }
122
+ return tailwindcssCssEntry;
123
+ }
124
+ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
125
+ if (!enabled || typeof loaderContext.resolve !== "function") {
126
+ return;
127
+ }
128
+ const originalResolve = loaderContext.resolve;
129
+ if (originalResolve.__weappTwPatched) {
130
+ return;
131
+ }
132
+ const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
133
+ const wrappedResolve = function(context, request, callback) {
134
+ if (request === "tailwindcss" || request === "tailwindcss$") {
135
+ return callback(null, tailwindcssCssEntry);
136
+ }
137
+ if (request?.startsWith("tailwindcss/")) {
138
+ return callback(null, path4.join(pkgDir, request.slice("tailwindcss/".length)));
139
+ }
140
+ return originalResolve.call(this, context, request, callback);
141
+ };
142
+ wrappedResolve.__weappTwPatched = true;
143
+ loaderContext.resolve = wrappedResolve;
144
+ }
145
+ function setupMpxTailwindcssRedirect(pkgDir, enabled) {
146
+ if (enabled) {
147
+ installTailwindcssCssRedirect(pkgDir);
148
+ }
149
+ }
150
+ function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
151
+ var _a;
152
+ if (!loader) {
153
+ return;
154
+ }
155
+ const moduleOptions = (_a = compiler.options).module ?? (_a.module = { rules: [] });
156
+ moduleOptions.rules = moduleOptions.rules || [];
157
+ const createRule = (match) => ({
158
+ ...match,
159
+ enforce: "pre",
160
+ use: [
161
+ {
162
+ loader,
163
+ options: loaderOptions
164
+ }
165
+ ]
166
+ });
167
+ moduleOptions.rules.unshift(
168
+ createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }),
169
+ createRule({
170
+ test: /\.css$/i,
171
+ resourceQuery: (query) => !isMpxStyleResourceQuery(query)
172
+ })
173
+ );
174
+ }
175
+
176
+ // src/bundlers/shared/css-imports.ts
177
+ import path5 from "path";
71
178
  var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
72
179
  var tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
73
180
  function normalizeTailwindcssSpecifier(specifier) {
@@ -90,7 +197,7 @@ function resolveTailwindcssImport(specifier, pkgDir, options) {
90
197
  if (isMpx(options?.appType) && normalized === "tailwindcss") {
91
198
  return "weapp-tailwindcss/index.css";
92
199
  }
93
- const join = options?.join ?? path3.join;
200
+ const join = options?.join ?? path5.join;
94
201
  const subpath = getTailwindcssSubpath(normalized);
95
202
  return join(pkgDir, subpath);
96
203
  }
@@ -154,6 +261,11 @@ export {
154
261
  toAbsoluteOutputPath,
155
262
  resolveOutputSpecifier,
156
263
  resolvePackageDir,
264
+ isMpx,
265
+ ensureMpxTailwindcssAliases,
266
+ patchMpxLoaderResolve,
267
+ setupMpxTailwindcssRedirect,
268
+ injectMpxCssRewritePreRules,
157
269
  resolveTailwindcssImport,
158
270
  rewriteTailwindcssImportsInCode,
159
271
  pushConcurrentTaskFactories