weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.5

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 (95) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundlers/shared/generator-css.d.ts +5 -2
  4. package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
  5. package/dist/bundlers/vite/index.d.ts +1 -1
  6. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  7. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
  8. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
  9. package/dist/cli/context.d.ts +0 -3
  10. package/dist/cli/mount-options.d.ts +2 -0
  11. package/dist/cli.js +8 -2
  12. package/dist/cli.mjs +8 -2
  13. package/dist/constants.d.ts +1 -1
  14. package/dist/core.js +1 -1
  15. package/dist/core.mjs +1 -1
  16. package/dist/css-macro.d.ts +1 -0
  17. package/dist/defaults.js +5 -7
  18. package/dist/defaults.mjs +5 -7
  19. package/dist/generator/index.d.ts +1 -1
  20. package/dist/generator/options.d.ts +3 -4
  21. package/dist/{generator-mmhXzZnv.js → generator-9UEp8OoQ.js} +259 -21
  22. package/dist/{generator-Y-Ikv4Fu.mjs → generator-Dpp-5s8z.mjs} +260 -22
  23. package/dist/{generator-css-D3OdPRiS.js → generator-css-CGueCYbX.js} +182 -42
  24. package/dist/{generator-css-B5ejWUMv.mjs → generator-css-MyjZhF0z.mjs} +182 -42
  25. package/dist/generator.js +1 -1
  26. package/dist/generator.mjs +1 -1
  27. package/dist/gulp.js +17 -14
  28. package/dist/gulp.mjs +17 -14
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +4 -4
  31. package/dist/index.mjs +4 -4
  32. package/dist/js/index.d.ts +1 -0
  33. package/dist/js/literal-transform.d.ts +2 -0
  34. package/dist/{logger-BoVx1Dbt.mjs → logger-1gx9UllH.mjs} +21 -51
  35. package/dist/{logger-BZ45DZJT.js → logger-D9clu_3f.js} +21 -51
  36. package/dist/patcher-options-DnqazL9E.js +34 -0
  37. package/dist/patcher-options-GuOwX0-k.mjs +17 -0
  38. package/dist/postcss.d.ts +2 -2
  39. package/dist/postcss.js +37 -28
  40. package/dist/postcss.mjs +37 -28
  41. package/dist/presets.js +1 -1
  42. package/dist/presets.mjs +1 -1
  43. package/dist/{recorder-zsgatmkB.mjs → recorder-BIW3Kuke.mjs} +5 -12
  44. package/dist/{recorder-gYSNLfOP.js → recorder-D4BKt75Q.js} +5 -12
  45. package/dist/reset.d.ts +1 -0
  46. package/dist/{css-imports-BbrbluP9.js → run-tasks-Cq5A5nVD.js} +6 -55
  47. package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DUVrDJGl.mjs} +5 -42
  48. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  49. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  50. package/dist/tailwindcss/patcher.d.ts +1 -2
  51. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  52. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  53. package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
  54. package/dist/tailwindcss/version.d.ts +4 -0
  55. package/dist/typedoc.export.d.ts +0 -2
  56. package/dist/types/index.d.ts +1 -3
  57. package/dist/types/shared.d.ts +3 -0
  58. package/dist/types/user-defined-options/general.d.ts +0 -2
  59. package/dist/types/user-defined-options/important.d.ts +3 -3
  60. package/dist/utils/disabled.d.ts +2 -3
  61. package/dist/version-CWBxRFPB.js +56 -0
  62. package/dist/version-WNz3MwRv.mjs +49 -0
  63. package/dist/{vite-BC9U7ahn.js → vite-BkMGwDeH.js} +106 -39
  64. package/dist/{vite-CrlzCNqz.mjs → vite-fDM-UQpR.mjs} +89 -22
  65. package/dist/vite.d.ts +1 -2
  66. package/dist/vite.js +3 -4
  67. package/dist/vite.mjs +2 -2
  68. package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
  69. package/dist/{webpack-DD7A6V0u.js → webpack-CICGEKT9.js} +225 -43
  70. package/dist/{webpack-Bu6M-Hbw.mjs → webpack-D2Wdk28V.mjs} +214 -27
  71. package/dist/webpack.js +1 -1
  72. package/dist/webpack.mjs +1 -1
  73. package/package.json +21 -30
  74. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  75. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  76. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  77. package/dist/experimental/index.d.ts +0 -2
  78. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  79. package/dist/experimental/oxc/index.d.ts +0 -2
  80. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  81. package/dist/experimental/shared/cache.d.ts +0 -3
  82. package/dist/experimental/shared/transform.d.ts +0 -3
  83. package/dist/experimental/shared.d.ts +0 -8
  84. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  85. package/dist/experimental/swc/index.d.ts +0 -2
  86. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  87. package/dist/loader-anchors-CNkWT8hx.js +0 -273
  88. package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
  89. package/dist/patcher-options-6gJN2EXy.js +0 -115
  90. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  91. package/dist/types/disabled-options.d.ts +0 -4
  92. package/dist/webpack4.d.ts +0 -4
  93. package/dist/webpack4.js +0 -387
  94. package/dist/webpack4.mjs +0 -379
  95. package/scripts/postinstall.mjs +0 -59
@@ -1,273 +0,0 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_recorder = require("./recorder-gYSNLfOP.js");
3
- const require_css_imports = require("./css-imports-BbrbluP9.js");
4
- let node_module = require("node:module");
5
- node_module = require_chunk.__toESM(node_module);
6
- let node_path = require("node:path");
7
- node_path = require_chunk.__toESM(node_path);
8
- //#region src/shared/tailwindcss-css-redirect.ts
9
- const moduleWithMutableResolve = node_module.default;
10
- const patched = /* @__PURE__ */ new WeakSet();
11
- function installTailwindcssCssRedirect(pkgDir) {
12
- const target = node_path.default.join(pkgDir, "index.css");
13
- const original = moduleWithMutableResolve._resolveFilename;
14
- if (patched.has(original)) return;
15
- const replacements = new Set(["tailwindcss", "tailwindcss$"]);
16
- const resolveTailwindcssCss = (request, parent, isMain, options) => {
17
- if (replacements.has(request)) return target;
18
- if (request.startsWith("tailwindcss/")) return node_path.default.join(pkgDir, request.slice(12));
19
- return original(request, parent, isMain, options);
20
- };
21
- moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
22
- patched.add(moduleWithMutableResolve._resolveFilename);
23
- }
24
- //#endregion
25
- //#region src/shared/mpx.ts
26
- const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
27
- function isMpxStyleResourceQuery(query) {
28
- if (typeof query !== "string") return false;
29
- return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
30
- }
31
- function isMpx(appType) {
32
- return appType === "mpx";
33
- }
34
- function getTailwindcssCssEntry(pkgDir) {
35
- return node_path.default.join(pkgDir, "index.css");
36
- }
37
- function ensureMpxTailwindcssAliases(compiler, pkgDir) {
38
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
39
- compiler.options = compiler.options || {};
40
- compiler.options.resolve = compiler.options.resolve || {};
41
- const alias = compiler.options.resolve.alias ?? {};
42
- if (Array.isArray(alias)) alias.push({
43
- name: "tailwindcss",
44
- alias: tailwindcssCssEntry
45
- }, {
46
- name: "tailwindcss$",
47
- alias: tailwindcssCssEntry
48
- });
49
- else {
50
- compiler.options.resolve.alias = alias;
51
- alias.tailwindcss = tailwindcssCssEntry;
52
- alias.tailwindcss$ = tailwindcssCssEntry;
53
- }
54
- return tailwindcssCssEntry;
55
- }
56
- function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
57
- if (!enabled || typeof loaderContext.resolve !== "function") return;
58
- const originalResolve = loaderContext.resolve;
59
- if (originalResolve.__weappTwPatched) return;
60
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
61
- const wrappedResolve = function(context, request, callback) {
62
- if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
63
- if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
64
- return originalResolve.call(this, context, request, callback);
65
- };
66
- wrappedResolve.__weappTwPatched = true;
67
- loaderContext.resolve = wrappedResolve;
68
- }
69
- function setupMpxTailwindcssRedirect(pkgDir, enabled) {
70
- if (enabled) installTailwindcssCssRedirect(pkgDir);
71
- }
72
- const CSS_EXT_RE$1 = /\.css$/i;
73
- function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
74
- var _compiler$options;
75
- if (!loader) return;
76
- const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
77
- moduleOptions.rules = moduleOptions.rules || [];
78
- const createRule = (match) => ({
79
- ...match,
80
- enforce: "pre",
81
- use: [{
82
- loader,
83
- options: loaderOptions
84
- }]
85
- });
86
- moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
87
- test: CSS_EXT_RE$1,
88
- resourceQuery: (query) => !isMpxStyleResourceQuery(query)
89
- }));
90
- }
91
- //#endregion
92
- //#region src/bundlers/webpack/shared/css-imports.ts
93
- const CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
94
- function stripResourceQuery$1(file) {
95
- let idx = file.indexOf("?");
96
- if (idx === -1) idx = file.indexOf("&");
97
- return idx === -1 ? file : file.slice(0, idx);
98
- }
99
- function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
100
- if (!data) return;
101
- const request = data.request;
102
- if (!request) return;
103
- if (request !== "tailwindcss" && request !== "tailwindcss$" && !request.startsWith("tailwindcss/")) return;
104
- const issuer = data.contextInfo?.issuer;
105
- if (!issuer) return;
106
- const normalizedIssuer = stripResourceQuery$1(issuer);
107
- if (!CSS_EXT_RE.test(normalizedIssuer)) return;
108
- const resolved = require_css_imports.resolveTailwindcssImport(request, pkgDir, { appType });
109
- if (!resolved) return;
110
- data.request = resolved;
111
- }
112
- function applyTailwindcssCssImportRewrite(compiler, options) {
113
- if (!options.enabled) return;
114
- compiler.hooks.normalModuleFactory.tap(require_recorder.pluginName, (factory) => {
115
- factory.hooks.beforeResolve.tap(require_recorder.pluginName, (data) => {
116
- rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
117
- });
118
- });
119
- }
120
- //#endregion
121
- //#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
122
- const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
123
- function getCacheKey(filename) {
124
- return filename;
125
- }
126
- function stripResourceQuery(resource) {
127
- if (typeof resource !== "string") return resource;
128
- const queryIndex = resource.indexOf("?");
129
- if (queryIndex !== -1) return resource.slice(0, queryIndex);
130
- const hashIndex = resource.indexOf("#");
131
- if (hashIndex !== -1) return resource.slice(0, hashIndex);
132
- return resource;
133
- }
134
- function isCssLikeModuleResource(resource, cssMatcher, appType) {
135
- if (typeof resource !== "string") return false;
136
- const normalizedResource = stripResourceQuery(resource);
137
- if (normalizedResource && cssMatcher(normalizedResource)) return true;
138
- if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
139
- return false;
140
- }
141
- function hasLoaderEntry(entries, target) {
142
- if (!target) return false;
143
- return entries.some((entry) => entry.loader?.includes?.(target));
144
- }
145
- function toChunkFiles(files) {
146
- if (!files) return [];
147
- if (Array.isArray(files)) return files;
148
- return [...files];
149
- }
150
- function createAssetHashByChunkMap(chunks) {
151
- const partsByFile = /* @__PURE__ */ new Map();
152
- for (const chunk of chunks) {
153
- const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
154
- if (!hash) continue;
155
- const chunkId = String(chunk.id ?? chunk.name ?? "");
156
- for (const file of toChunkFiles(chunk.files)) {
157
- if (!file) continue;
158
- let parts = partsByFile.get(file);
159
- if (!parts) {
160
- parts = [];
161
- partsByFile.set(file, parts);
162
- }
163
- parts.push(`${chunkId}:${hash}`);
164
- }
165
- }
166
- const hashByFile = /* @__PURE__ */ new Map();
167
- for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
168
- return hashByFile;
169
- }
170
- function hasWatchChanges(compiler) {
171
- return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
172
- }
173
- //#endregion
174
- //#region src/bundlers/webpack/shared/loader-anchors.ts
175
- const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
176
- const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
177
- const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
178
- function createFinder(targets) {
179
- return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
180
- }
181
- function createPrioritizedFinder(targets) {
182
- return (entries) => {
183
- for (const target of targets) {
184
- const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
185
- if (idx !== -1) return idx;
186
- }
187
- return -1;
188
- };
189
- }
190
- function createLoaderAnchorFinders(appType) {
191
- if (isMpx(appType)) return {
192
- findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
193
- findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
194
- };
195
- const fallbackFinder = createFinder(["postcss-loader"]);
196
- return {
197
- findRewriteAnchor: fallbackFinder,
198
- findClassSetAnchor: fallbackFinder
199
- };
200
- }
201
- //#endregion
202
- Object.defineProperty(exports, "applyTailwindcssCssImportRewrite", {
203
- enumerable: true,
204
- get: function() {
205
- return applyTailwindcssCssImportRewrite;
206
- }
207
- });
208
- Object.defineProperty(exports, "createAssetHashByChunkMap", {
209
- enumerable: true,
210
- get: function() {
211
- return createAssetHashByChunkMap;
212
- }
213
- });
214
- Object.defineProperty(exports, "createLoaderAnchorFinders", {
215
- enumerable: true,
216
- get: function() {
217
- return createLoaderAnchorFinders;
218
- }
219
- });
220
- Object.defineProperty(exports, "ensureMpxTailwindcssAliases", {
221
- enumerable: true,
222
- get: function() {
223
- return ensureMpxTailwindcssAliases;
224
- }
225
- });
226
- Object.defineProperty(exports, "getCacheKey", {
227
- enumerable: true,
228
- get: function() {
229
- return getCacheKey;
230
- }
231
- });
232
- Object.defineProperty(exports, "hasLoaderEntry", {
233
- enumerable: true,
234
- get: function() {
235
- return hasLoaderEntry;
236
- }
237
- });
238
- Object.defineProperty(exports, "hasWatchChanges", {
239
- enumerable: true,
240
- get: function() {
241
- return hasWatchChanges;
242
- }
243
- });
244
- Object.defineProperty(exports, "injectMpxCssRewritePreRules", {
245
- enumerable: true,
246
- get: function() {
247
- return injectMpxCssRewritePreRules;
248
- }
249
- });
250
- Object.defineProperty(exports, "isCssLikeModuleResource", {
251
- enumerable: true,
252
- get: function() {
253
- return isCssLikeModuleResource;
254
- }
255
- });
256
- Object.defineProperty(exports, "isMpx", {
257
- enumerable: true,
258
- get: function() {
259
- return isMpx;
260
- }
261
- });
262
- Object.defineProperty(exports, "patchMpxLoaderResolve", {
263
- enumerable: true,
264
- get: function() {
265
- return patchMpxLoaderResolve;
266
- }
267
- });
268
- Object.defineProperty(exports, "setupMpxTailwindcssRedirect", {
269
- enumerable: true,
270
- get: function() {
271
- return setupMpxTailwindcssRedirect;
272
- }
273
- });
@@ -1,205 +0,0 @@
1
- import { p as pluginName } from "./recorder-zsgatmkB.mjs";
2
- import { t as resolveTailwindcssImport } from "./css-imports-CSdPq_Sc.mjs";
3
- import Module from "node:module";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- //#region src/shared/tailwindcss-css-redirect.ts
7
- const moduleWithMutableResolve = Module;
8
- const patched = /* @__PURE__ */ new WeakSet();
9
- function installTailwindcssCssRedirect(pkgDir) {
10
- const target = path.join(pkgDir, "index.css");
11
- const original = moduleWithMutableResolve._resolveFilename;
12
- if (patched.has(original)) return;
13
- const replacements = new Set(["tailwindcss", "tailwindcss$"]);
14
- const resolveTailwindcssCss = (request, parent, isMain, options) => {
15
- if (replacements.has(request)) return target;
16
- if (request.startsWith("tailwindcss/")) return path.join(pkgDir, request.slice(12));
17
- return original(request, parent, isMain, options);
18
- };
19
- moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
20
- patched.add(moduleWithMutableResolve._resolveFilename);
21
- }
22
- //#endregion
23
- //#region src/shared/mpx.ts
24
- const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
25
- function isMpxStyleResourceQuery(query) {
26
- if (typeof query !== "string") return false;
27
- return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
28
- }
29
- function isMpx(appType) {
30
- return appType === "mpx";
31
- }
32
- function getTailwindcssCssEntry(pkgDir) {
33
- return path.join(pkgDir, "index.css");
34
- }
35
- function ensureMpxTailwindcssAliases(compiler, pkgDir) {
36
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
37
- compiler.options = compiler.options || {};
38
- compiler.options.resolve = compiler.options.resolve || {};
39
- const alias = compiler.options.resolve.alias ?? {};
40
- if (Array.isArray(alias)) alias.push({
41
- name: "tailwindcss",
42
- alias: tailwindcssCssEntry
43
- }, {
44
- name: "tailwindcss$",
45
- alias: tailwindcssCssEntry
46
- });
47
- else {
48
- compiler.options.resolve.alias = alias;
49
- alias.tailwindcss = tailwindcssCssEntry;
50
- alias.tailwindcss$ = tailwindcssCssEntry;
51
- }
52
- return tailwindcssCssEntry;
53
- }
54
- function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
55
- if (!enabled || typeof loaderContext.resolve !== "function") return;
56
- const originalResolve = loaderContext.resolve;
57
- if (originalResolve.__weappTwPatched) return;
58
- const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
59
- const wrappedResolve = function(context, request, callback) {
60
- if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
61
- if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
62
- return originalResolve.call(this, context, request, callback);
63
- };
64
- wrappedResolve.__weappTwPatched = true;
65
- loaderContext.resolve = wrappedResolve;
66
- }
67
- function setupMpxTailwindcssRedirect(pkgDir, enabled) {
68
- if (enabled) installTailwindcssCssRedirect(pkgDir);
69
- }
70
- const CSS_EXT_RE$1 = /\.css$/i;
71
- function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
72
- var _compiler$options;
73
- if (!loader) return;
74
- const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
75
- moduleOptions.rules = moduleOptions.rules || [];
76
- const createRule = (match) => ({
77
- ...match,
78
- enforce: "pre",
79
- use: [{
80
- loader,
81
- options: loaderOptions
82
- }]
83
- });
84
- moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
85
- test: CSS_EXT_RE$1,
86
- resourceQuery: (query) => !isMpxStyleResourceQuery(query)
87
- }));
88
- }
89
- //#endregion
90
- //#region src/bundlers/webpack/shared/css-imports.ts
91
- const CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
92
- function stripResourceQuery$1(file) {
93
- let idx = file.indexOf("?");
94
- if (idx === -1) idx = file.indexOf("&");
95
- return idx === -1 ? file : file.slice(0, idx);
96
- }
97
- function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
98
- if (!data) return;
99
- const request = data.request;
100
- if (!request) return;
101
- if (request !== "tailwindcss" && request !== "tailwindcss$" && !request.startsWith("tailwindcss/")) return;
102
- const issuer = data.contextInfo?.issuer;
103
- if (!issuer) return;
104
- const normalizedIssuer = stripResourceQuery$1(issuer);
105
- if (!CSS_EXT_RE.test(normalizedIssuer)) return;
106
- const resolved = resolveTailwindcssImport(request, pkgDir, { appType });
107
- if (!resolved) return;
108
- data.request = resolved;
109
- }
110
- function applyTailwindcssCssImportRewrite(compiler, options) {
111
- if (!options.enabled) return;
112
- compiler.hooks.normalModuleFactory.tap(pluginName, (factory) => {
113
- factory.hooks.beforeResolve.tap(pluginName, (data) => {
114
- rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
115
- });
116
- });
117
- }
118
- //#endregion
119
- //#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
120
- const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
121
- function getCacheKey(filename) {
122
- return filename;
123
- }
124
- function stripResourceQuery(resource) {
125
- if (typeof resource !== "string") return resource;
126
- const queryIndex = resource.indexOf("?");
127
- if (queryIndex !== -1) return resource.slice(0, queryIndex);
128
- const hashIndex = resource.indexOf("#");
129
- if (hashIndex !== -1) return resource.slice(0, hashIndex);
130
- return resource;
131
- }
132
- function isCssLikeModuleResource(resource, cssMatcher, appType) {
133
- if (typeof resource !== "string") return false;
134
- const normalizedResource = stripResourceQuery(resource);
135
- if (normalizedResource && cssMatcher(normalizedResource)) return true;
136
- if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
137
- return false;
138
- }
139
- function hasLoaderEntry(entries, target) {
140
- if (!target) return false;
141
- return entries.some((entry) => entry.loader?.includes?.(target));
142
- }
143
- function toChunkFiles(files) {
144
- if (!files) return [];
145
- if (Array.isArray(files)) return files;
146
- return [...files];
147
- }
148
- function createAssetHashByChunkMap(chunks) {
149
- const partsByFile = /* @__PURE__ */ new Map();
150
- for (const chunk of chunks) {
151
- const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
152
- if (!hash) continue;
153
- const chunkId = String(chunk.id ?? chunk.name ?? "");
154
- for (const file of toChunkFiles(chunk.files)) {
155
- if (!file) continue;
156
- let parts = partsByFile.get(file);
157
- if (!parts) {
158
- parts = [];
159
- partsByFile.set(file, parts);
160
- }
161
- parts.push(`${chunkId}:${hash}`);
162
- }
163
- }
164
- const hashByFile = /* @__PURE__ */ new Map();
165
- for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
166
- return hashByFile;
167
- }
168
- function hasWatchChanges(compiler) {
169
- return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
170
- }
171
- //#endregion
172
- //#region ../../node_modules/.pnpm/tsdown@0.21.10_oxc-resolver@11.16.0_@emnapi+core@1.10.0_@emnapi+runtime@1.10.0__synckit_2e62271a4111dd71b1211b37ea0ad6f5/node_modules/tsdown/esm-shims.js
173
- const getFilename = () => fileURLToPath(import.meta.url);
174
- const getDirname = () => path.dirname(getFilename());
175
- const __dirname = /* @__PURE__ */ getDirname();
176
- //#endregion
177
- //#region src/bundlers/webpack/shared/loader-anchors.ts
178
- const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
179
- const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
180
- const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
181
- function createFinder(targets) {
182
- return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
183
- }
184
- function createPrioritizedFinder(targets) {
185
- return (entries) => {
186
- for (const target of targets) {
187
- const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
188
- if (idx !== -1) return idx;
189
- }
190
- return -1;
191
- };
192
- }
193
- function createLoaderAnchorFinders(appType) {
194
- if (isMpx(appType)) return {
195
- findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
196
- findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
197
- };
198
- const fallbackFinder = createFinder(["postcss-loader"]);
199
- return {
200
- findRewriteAnchor: fallbackFinder,
201
- findClassSetAnchor: fallbackFinder
202
- };
203
- }
204
- //#endregion
205
- export { hasLoaderEntry as a, applyTailwindcssCssImportRewrite as c, isMpx as d, patchMpxLoaderResolve as f, getCacheKey as i, ensureMpxTailwindcssAliases as l, __dirname as n, hasWatchChanges as o, setupMpxTailwindcssRedirect as p, createAssetHashByChunkMap as r, isCssLikeModuleResource as s, createLoaderAnchorFinders as t, injectMpxCssRewritePreRules as u };
@@ -1,115 +0,0 @@
1
- //#region src/tailwindcss/patcher-options.ts
2
- function resolveTailwindcssOptions(options) {
3
- if (!options) return;
4
- const compatOptions = options;
5
- return compatOptions.tailwindcss ?? compatOptions.tailwind;
6
- }
7
- function normalizeExtendLengthUnits(value) {
8
- if (value === false) return false;
9
- if (value === true) return { enabled: true };
10
- if (value && typeof value === "object") return {
11
- enabled: true,
12
- ...value
13
- };
14
- }
15
- function normalizeTailwindcssPatcherOptions(options) {
16
- if (!options) return;
17
- if ("patch" in options) {
18
- const { cache, patch } = options;
19
- const normalized = {};
20
- if (cache !== void 0) normalized.cache = cache;
21
- const apply = {};
22
- const extract = {};
23
- if (patch?.overwrite !== void 0) apply.overwrite = patch.overwrite;
24
- if (patch?.filter) normalized.filter = patch.filter;
25
- const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
26
- const exposeContext = patch?.applyPatches?.exportContext;
27
- if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
28
- apply.exposeContext = exposeContext;
29
- apply.extendLengthUnits = extendLengthUnits;
30
- }
31
- const cwd = patch?.cwd ?? patch?.basedir;
32
- if (cwd) normalized.projectRoot = cwd;
33
- const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
34
- const legacyResolve = patch?.resolve;
35
- let nextTailwindOptions = tailwindOptions;
36
- if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
37
- nextTailwindOptions = {
38
- ...nextTailwindOptions,
39
- packageName: "@tailwindcss/postcss7-compat",
40
- postcssPlugin: nextTailwindOptions.postcssPlugin
41
- };
42
- if (!nextTailwindOptions.postcssPlugin) nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
43
- }
44
- if (nextTailwindOptions || legacyResolve) {
45
- const resolveOptions = nextTailwindOptions?.resolve;
46
- const mergedResolve = legacyResolve || resolveOptions ? {
47
- ...resolveOptions ?? {},
48
- ...legacyResolve ?? {}
49
- } : void 0;
50
- normalized.tailwindcss = {
51
- ...nextTailwindOptions ?? {},
52
- ...mergedResolve ? { resolve: mergedResolve } : {}
53
- };
54
- }
55
- if (patch?.output) {
56
- if (patch.output.filename !== void 0) extract.file = patch.output.filename;
57
- if (patch.output.loose !== void 0) extract.pretty = patch.output.loose ? 2 : false;
58
- if (patch.output.removeUniversalSelector !== void 0) extract.removeUniversalSelector = patch.output.removeUniversalSelector;
59
- }
60
- if (Object.keys(apply).length > 0) normalized.apply = apply;
61
- if (Object.keys(extract).length > 0) normalized.extract = extract;
62
- return toModernTailwindcssPatchOptions(normalized);
63
- }
64
- return toModernTailwindcssPatchOptions(options);
65
- }
66
- function toModernTailwindcssPatchOptions(options) {
67
- if (!options) return;
68
- const normalized = {};
69
- if (options.cache !== void 0) normalized.cache = options.cache;
70
- if (options.filter) normalized.filter = options.filter;
71
- const projectRoot = options.projectRoot ?? options.cwd;
72
- if (projectRoot) normalized.projectRoot = projectRoot;
73
- const tailwindcss = resolveTailwindcssOptions(options);
74
- if (tailwindcss) normalized.tailwindcss = { ...tailwindcss };
75
- const apply = { ...options.apply ?? {} };
76
- if (apply.overwrite === void 0 && options.overwrite !== void 0) apply.overwrite = options.overwrite;
77
- if (apply.exposeContext === void 0 && options.features?.exposeContext !== void 0) apply.exposeContext = options.features.exposeContext;
78
- if (apply.extendLengthUnits === void 0 && options.features?.extendLengthUnits !== void 0) apply.extendLengthUnits = options.features.extendLengthUnits;
79
- if (Object.keys(apply).length > 0) normalized.apply = apply;
80
- const extract = { ...options.extract ?? {} };
81
- if (options.output) {
82
- if (extract.write === void 0 && options.output.enabled !== void 0) extract.write = options.output.enabled;
83
- if (extract.file === void 0 && options.output.file !== void 0) extract.file = options.output.file;
84
- if (extract.format === void 0 && options.output.format !== void 0) extract.format = options.output.format;
85
- if (extract.pretty === void 0 && options.output.pretty !== void 0) extract.pretty = options.output.pretty;
86
- if (extract.removeUniversalSelector === void 0 && options.output.removeUniversalSelector !== void 0) extract.removeUniversalSelector = options.output.removeUniversalSelector;
87
- }
88
- if (Object.keys(extract).length > 0) normalized.extract = extract;
89
- return normalized;
90
- }
91
- //#endregion
92
- Object.defineProperty(exports, "normalizeExtendLengthUnits", {
93
- enumerable: true,
94
- get: function() {
95
- return normalizeExtendLengthUnits;
96
- }
97
- });
98
- Object.defineProperty(exports, "normalizeTailwindcssPatcherOptions", {
99
- enumerable: true,
100
- get: function() {
101
- return normalizeTailwindcssPatcherOptions;
102
- }
103
- });
104
- Object.defineProperty(exports, "resolveTailwindcssOptions", {
105
- enumerable: true,
106
- get: function() {
107
- return resolveTailwindcssOptions;
108
- }
109
- });
110
- Object.defineProperty(exports, "toModernTailwindcssPatchOptions", {
111
- enumerable: true,
112
- get: function() {
113
- return toModernTailwindcssPatchOptions;
114
- }
115
- });
@@ -1,92 +0,0 @@
1
- //#region src/tailwindcss/patcher-options.ts
2
- function resolveTailwindcssOptions(options) {
3
- if (!options) return;
4
- const compatOptions = options;
5
- return compatOptions.tailwindcss ?? compatOptions.tailwind;
6
- }
7
- function normalizeExtendLengthUnits(value) {
8
- if (value === false) return false;
9
- if (value === true) return { enabled: true };
10
- if (value && typeof value === "object") return {
11
- enabled: true,
12
- ...value
13
- };
14
- }
15
- function normalizeTailwindcssPatcherOptions(options) {
16
- if (!options) return;
17
- if ("patch" in options) {
18
- const { cache, patch } = options;
19
- const normalized = {};
20
- if (cache !== void 0) normalized.cache = cache;
21
- const apply = {};
22
- const extract = {};
23
- if (patch?.overwrite !== void 0) apply.overwrite = patch.overwrite;
24
- if (patch?.filter) normalized.filter = patch.filter;
25
- const extendLengthUnits = normalizeExtendLengthUnits(patch?.applyPatches?.extendLengthUnits);
26
- const exposeContext = patch?.applyPatches?.exportContext;
27
- if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
28
- apply.exposeContext = exposeContext;
29
- apply.extendLengthUnits = extendLengthUnits;
30
- }
31
- const cwd = patch?.cwd ?? patch?.basedir;
32
- if (cwd) normalized.projectRoot = cwd;
33
- const tailwindOptions = patch?.tailwindcss ? { ...patch.tailwindcss } : void 0;
34
- const legacyResolve = patch?.resolve;
35
- let nextTailwindOptions = tailwindOptions;
36
- if (nextTailwindOptions?.version === 2 && !nextTailwindOptions.packageName) {
37
- nextTailwindOptions = {
38
- ...nextTailwindOptions,
39
- packageName: "@tailwindcss/postcss7-compat",
40
- postcssPlugin: nextTailwindOptions.postcssPlugin
41
- };
42
- if (!nextTailwindOptions.postcssPlugin) nextTailwindOptions.postcssPlugin = "@tailwindcss/postcss7-compat";
43
- }
44
- if (nextTailwindOptions || legacyResolve) {
45
- const resolveOptions = nextTailwindOptions?.resolve;
46
- const mergedResolve = legacyResolve || resolveOptions ? {
47
- ...resolveOptions ?? {},
48
- ...legacyResolve ?? {}
49
- } : void 0;
50
- normalized.tailwindcss = {
51
- ...nextTailwindOptions ?? {},
52
- ...mergedResolve ? { resolve: mergedResolve } : {}
53
- };
54
- }
55
- if (patch?.output) {
56
- if (patch.output.filename !== void 0) extract.file = patch.output.filename;
57
- if (patch.output.loose !== void 0) extract.pretty = patch.output.loose ? 2 : false;
58
- if (patch.output.removeUniversalSelector !== void 0) extract.removeUniversalSelector = patch.output.removeUniversalSelector;
59
- }
60
- if (Object.keys(apply).length > 0) normalized.apply = apply;
61
- if (Object.keys(extract).length > 0) normalized.extract = extract;
62
- return toModernTailwindcssPatchOptions(normalized);
63
- }
64
- return toModernTailwindcssPatchOptions(options);
65
- }
66
- function toModernTailwindcssPatchOptions(options) {
67
- if (!options) return;
68
- const normalized = {};
69
- if (options.cache !== void 0) normalized.cache = options.cache;
70
- if (options.filter) normalized.filter = options.filter;
71
- const projectRoot = options.projectRoot ?? options.cwd;
72
- if (projectRoot) normalized.projectRoot = projectRoot;
73
- const tailwindcss = resolveTailwindcssOptions(options);
74
- if (tailwindcss) normalized.tailwindcss = { ...tailwindcss };
75
- const apply = { ...options.apply ?? {} };
76
- if (apply.overwrite === void 0 && options.overwrite !== void 0) apply.overwrite = options.overwrite;
77
- if (apply.exposeContext === void 0 && options.features?.exposeContext !== void 0) apply.exposeContext = options.features.exposeContext;
78
- if (apply.extendLengthUnits === void 0 && options.features?.extendLengthUnits !== void 0) apply.extendLengthUnits = options.features.extendLengthUnits;
79
- if (Object.keys(apply).length > 0) normalized.apply = apply;
80
- const extract = { ...options.extract ?? {} };
81
- if (options.output) {
82
- if (extract.write === void 0 && options.output.enabled !== void 0) extract.write = options.output.enabled;
83
- if (extract.file === void 0 && options.output.file !== void 0) extract.file = options.output.file;
84
- if (extract.format === void 0 && options.output.format !== void 0) extract.format = options.output.format;
85
- if (extract.pretty === void 0 && options.output.pretty !== void 0) extract.pretty = options.output.pretty;
86
- if (extract.removeUniversalSelector === void 0 && options.output.removeUniversalSelector !== void 0) extract.removeUniversalSelector = options.output.removeUniversalSelector;
87
- }
88
- if (Object.keys(extract).length > 0) normalized.extract = extract;
89
- return normalized;
90
- }
91
- //#endregion
92
- export { toModernTailwindcssPatchOptions as i, normalizeTailwindcssPatcherOptions as n, resolveTailwindcssOptions as r, normalizeExtendLengthUnits as t };
@@ -1,4 +0,0 @@
1
- export interface DisabledOptions {
2
- plugin?: boolean;
3
- rewriteCssImports?: boolean;
4
- }