weapp-tailwindcss 4.8.13 → 4.8.15
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.
- package/dist/{chunk-HXYNNE6Q.mjs → chunk-3SKEY32E.mjs} +18 -119
- package/dist/{chunk-JSV4IYLL.mjs → chunk-4ZJEFTPC.mjs} +2 -2
- package/dist/{chunk-CSDB62E5.mjs → chunk-7LRI7LJO.mjs} +14 -12
- package/dist/{chunk-BLTNVVBH.js → chunk-7UBHTADV.js} +1 -1
- package/dist/chunk-DGL3SP2H.js +251 -0
- package/dist/{chunk-7MREZHFO.mjs → chunk-FQX7YIN5.mjs} +1 -1
- package/dist/{chunk-G4UFQ3CK.js → chunk-H4BVDT5Q.js} +7 -7
- package/dist/{chunk-3S6VRBOM.js → chunk-I7VIMPUB.js} +3 -3
- package/dist/{chunk-4E2U7YIQ.mjs → chunk-K3XO75VC.mjs} +68 -48
- package/dist/{chunk-Z6E242OH.js → chunk-ORSWL3MI.js} +18 -119
- package/dist/{chunk-U6O2TOS7.js → chunk-PIVX3SXU.js} +84 -64
- package/dist/{chunk-WHELJMZL.mjs → chunk-QYYQDG6A.mjs} +1 -1
- package/dist/{chunk-B7643BFR.js → chunk-W3CX5DGR.js} +34 -32
- package/dist/chunk-XRYCPSQC.mjs +251 -0
- package/dist/cli.js +9 -9
- package/dist/cli.mjs +1 -1
- package/dist/core.js +8 -8
- package/dist/core.mjs +2 -2
- package/dist/gulp.js +4 -4
- package/dist/gulp.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/types.d.mts +24 -2
- package/dist/types.d.ts +24 -2
- package/dist/vite.js +5 -5
- package/dist/vite.mjs +4 -4
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -18
- package/dist/weapp-tw-runtime-classset-loader.js +1 -3
- package/dist/webpack.js +6 -6
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.js +35 -33
- package/dist/webpack4.mjs +14 -12
- package/package.json +3 -3
- package/dist/chunk-BYXBJQAS.js +0 -1
- package/dist/chunk-OPA2EYQV.mjs +0 -136
- package/dist/chunk-XX7SUSE7.js +0 -136
|
@@ -53,6 +53,20 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
|
53
53
|
return matchWithExtensions(candidate, hasOutput);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// src/utils/disabled.ts
|
|
57
|
+
function resolveDisabledOptions(disabled) {
|
|
58
|
+
if (disabled === true) {
|
|
59
|
+
return { plugin: true, rewriteCssImports: false };
|
|
60
|
+
}
|
|
61
|
+
if (disabled === false || disabled == null) {
|
|
62
|
+
return { plugin: false, rewriteCssImports: false };
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
plugin: disabled.plugin ?? false,
|
|
66
|
+
rewriteCssImports: disabled.rewriteCssImports ?? false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
// src/utils/resolve-package.ts
|
|
57
71
|
import { createRequire } from "module";
|
|
58
72
|
import path2 from "path";
|
|
@@ -62,119 +76,8 @@ function resolvePackageDir(name) {
|
|
|
62
76
|
return path2.dirname(pkgPath);
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
// src/shared/mpx.ts
|
|
66
|
-
import path4 from "path";
|
|
67
|
-
|
|
68
|
-
// src/shared/tailwindcss-css-redirect.ts
|
|
69
|
-
import Module from "module";
|
|
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
79
|
// src/bundlers/shared/css-imports.ts
|
|
177
|
-
import
|
|
80
|
+
import path3 from "path";
|
|
178
81
|
var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
179
82
|
var tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
180
83
|
function normalizeTailwindcssSpecifier(specifier) {
|
|
@@ -194,10 +97,10 @@ function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
|
194
97
|
if (!tailwindcssImportRE.test(normalized)) {
|
|
195
98
|
return null;
|
|
196
99
|
}
|
|
197
|
-
if (
|
|
100
|
+
if (normalized === "tailwindcss") {
|
|
198
101
|
return "weapp-tailwindcss/index.css";
|
|
199
102
|
}
|
|
200
|
-
const join = options?.join ??
|
|
103
|
+
const join = options?.join ?? path3.join;
|
|
201
104
|
const subpath = getTailwindcssSubpath(normalized);
|
|
202
105
|
return join(pkgDir, subpath);
|
|
203
106
|
}
|
|
@@ -260,12 +163,8 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
|
260
163
|
export {
|
|
261
164
|
toAbsoluteOutputPath,
|
|
262
165
|
resolveOutputSpecifier,
|
|
166
|
+
resolveDisabledOptions,
|
|
263
167
|
resolvePackageDir,
|
|
264
|
-
isMpx,
|
|
265
|
-
ensureMpxTailwindcssAliases,
|
|
266
|
-
patchMpxLoaderResolve,
|
|
267
|
-
setupMpxTailwindcssRedirect,
|
|
268
|
-
injectMpxCssRewritePreRules,
|
|
269
168
|
resolveTailwindcssImport,
|
|
270
169
|
rewriteTailwindcssImportsInCode,
|
|
271
170
|
pushConcurrentTaskFactories
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-RRHPTTCP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
setupPatchRecorder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FQX7YIN5.mjs";
|
|
7
7
|
import {
|
|
8
8
|
collectRuntimeClassSet,
|
|
9
9
|
createDebug,
|
|
10
10
|
getCompilerContext,
|
|
11
11
|
refreshTailwindRuntimeState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QYYQDG6A.mjs";
|
|
13
13
|
|
|
14
14
|
// src/bundlers/gulp/index.ts
|
|
15
15
|
import { Buffer } from "buffer";
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyTailwindcssCssImportRewrite,
|
|
3
3
|
createLoaderAnchorFinders,
|
|
4
|
+
ensureMpxTailwindcssAliases,
|
|
4
5
|
getCacheKey,
|
|
5
6
|
hasLoaderEntry,
|
|
6
|
-
isCssLikeModuleResource
|
|
7
|
-
} from "./chunk-OPA2EYQV.mjs";
|
|
8
|
-
import {
|
|
9
|
-
ensureMpxTailwindcssAliases,
|
|
10
7
|
injectMpxCssRewritePreRules,
|
|
8
|
+
isCssLikeModuleResource,
|
|
11
9
|
isMpx,
|
|
12
10
|
patchMpxLoaderResolve,
|
|
11
|
+
setupMpxTailwindcssRedirect
|
|
12
|
+
} from "./chunk-XRYCPSQC.mjs";
|
|
13
|
+
import {
|
|
13
14
|
pushConcurrentTaskFactories,
|
|
15
|
+
resolveDisabledOptions,
|
|
14
16
|
resolveOutputSpecifier,
|
|
15
17
|
resolvePackageDir,
|
|
16
|
-
setupMpxTailwindcssRedirect,
|
|
17
18
|
toAbsoluteOutputPath
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-3SKEY32E.mjs";
|
|
19
20
|
import {
|
|
20
21
|
processCachedTask
|
|
21
22
|
} from "./chunk-RRHPTTCP.mjs";
|
|
22
23
|
import {
|
|
23
24
|
setupPatchRecorder
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FQX7YIN5.mjs";
|
|
25
26
|
import {
|
|
26
27
|
collectRuntimeClassSet,
|
|
27
28
|
createDebug,
|
|
28
29
|
getCompilerContext,
|
|
29
30
|
pluginName,
|
|
30
31
|
refreshTailwindRuntimeState
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-QYYQDG6A.mjs";
|
|
32
33
|
import {
|
|
33
34
|
getGroupedEntries
|
|
34
35
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
@@ -65,11 +66,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
65
66
|
twPatcher: initialTwPatcher,
|
|
66
67
|
refreshTailwindcssPatcher
|
|
67
68
|
} = this.options;
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
69
|
+
const disabledOptions = resolveDisabledOptions(disabled);
|
|
71
70
|
const isTailwindcssV4 = (initialTwPatcher.majorVersion ?? 0) >= 4;
|
|
72
|
-
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false;
|
|
71
|
+
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
73
72
|
const isMpxApp = isMpx(this.appType);
|
|
74
73
|
if (shouldRewriteCssImports) {
|
|
75
74
|
applyTailwindcssCssImportRewrite(compiler, {
|
|
@@ -79,6 +78,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
79
78
|
});
|
|
80
79
|
setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
81
80
|
}
|
|
81
|
+
if (disabledOptions.plugin) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
82
84
|
const patchRecorderState = setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
83
85
|
source: "runtime",
|
|
84
86
|
cwd: this.options.tailwindcssBasedir ?? process.cwd()
|
|
@@ -187,7 +187,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
187
187
|
// package.json
|
|
188
188
|
var package_default = {
|
|
189
189
|
name: "weapp-tailwindcss",
|
|
190
|
-
version: "4.8.
|
|
190
|
+
version: "4.8.15",
|
|
191
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!",
|
|
192
192
|
author: "ice breaker <1324318532@qq.com>",
|
|
193
193
|
license: "MIT",
|
|
@@ -0,0 +1,251 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunkORSWL3MIjs = require('./chunk-ORSWL3MI.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.js');
|
|
7
|
+
|
|
8
|
+
// src/shared/mpx.ts
|
|
9
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
10
|
+
|
|
11
|
+
// src/shared/tailwindcss-css-redirect.ts
|
|
12
|
+
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
13
|
+
|
|
14
|
+
var moduleWithMutableResolve = _module2.default;
|
|
15
|
+
var patched = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
function installTailwindcssCssRedirect(pkgDir) {
|
|
17
|
+
const target = _path2.default.join(pkgDir, "index.css");
|
|
18
|
+
const original = moduleWithMutableResolve._resolveFilename;
|
|
19
|
+
if (patched.has(original)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
|
|
23
|
+
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
24
|
+
if (replacements.has(request)) {
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
if (request.startsWith("tailwindcss/")) {
|
|
28
|
+
return _path2.default.join(pkgDir, request.slice("tailwindcss/".length));
|
|
29
|
+
}
|
|
30
|
+
return original(request, parent, isMain, options);
|
|
31
|
+
};
|
|
32
|
+
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
33
|
+
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/shared/mpx.ts
|
|
37
|
+
var MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
|
|
38
|
+
function isMpxStyleResourceQuery(query) {
|
|
39
|
+
if (typeof query !== "string") {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
|
|
43
|
+
}
|
|
44
|
+
function isMpx(appType) {
|
|
45
|
+
return appType === "mpx";
|
|
46
|
+
}
|
|
47
|
+
function getTailwindcssCssEntry(pkgDir) {
|
|
48
|
+
return _path2.default.join(pkgDir, "index.css");
|
|
49
|
+
}
|
|
50
|
+
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
51
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
52
|
+
compiler.options = compiler.options || {};
|
|
53
|
+
compiler.options.resolve = compiler.options.resolve || {};
|
|
54
|
+
const alias = _nullishCoalesce(compiler.options.resolve.alias, () => ( {}));
|
|
55
|
+
if (Array.isArray(alias)) {
|
|
56
|
+
alias.push(
|
|
57
|
+
{ name: "tailwindcss", alias: tailwindcssCssEntry },
|
|
58
|
+
{ name: "tailwindcss$", alias: tailwindcssCssEntry }
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
compiler.options.resolve.alias = alias;
|
|
62
|
+
alias.tailwindcss = tailwindcssCssEntry;
|
|
63
|
+
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
64
|
+
}
|
|
65
|
+
return tailwindcssCssEntry;
|
|
66
|
+
}
|
|
67
|
+
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
68
|
+
if (!enabled || typeof loaderContext.resolve !== "function") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const originalResolve = loaderContext.resolve;
|
|
72
|
+
if (originalResolve.__weappTwPatched) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
76
|
+
const wrappedResolve = function(context, request, callback) {
|
|
77
|
+
if (request === "tailwindcss" || request === "tailwindcss$") {
|
|
78
|
+
return callback(null, tailwindcssCssEntry);
|
|
79
|
+
}
|
|
80
|
+
if (_optionalChain([request, 'optionalAccess', _ => _.startsWith, 'call', _2 => _2("tailwindcss/")])) {
|
|
81
|
+
return callback(null, _path2.default.join(pkgDir, request.slice("tailwindcss/".length)));
|
|
82
|
+
}
|
|
83
|
+
return originalResolve.call(this, context, request, callback);
|
|
84
|
+
};
|
|
85
|
+
wrappedResolve.__weappTwPatched = true;
|
|
86
|
+
loaderContext.resolve = wrappedResolve;
|
|
87
|
+
}
|
|
88
|
+
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
89
|
+
if (enabled) {
|
|
90
|
+
installTailwindcssCssRedirect(pkgDir);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
94
|
+
var _a;
|
|
95
|
+
if (!loader) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const moduleOptions = _nullishCoalesce((_a = compiler.options).module, () => ( (_a.module = { rules: [] })));
|
|
99
|
+
moduleOptions.rules = moduleOptions.rules || [];
|
|
100
|
+
const createRule = (match) => ({
|
|
101
|
+
...match,
|
|
102
|
+
enforce: "pre",
|
|
103
|
+
use: [
|
|
104
|
+
{
|
|
105
|
+
loader,
|
|
106
|
+
options: loaderOptions
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
moduleOptions.rules.unshift(
|
|
111
|
+
createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }),
|
|
112
|
+
createRule({
|
|
113
|
+
test: /\.css$/i,
|
|
114
|
+
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/bundlers/webpack/shared/css-imports.ts
|
|
120
|
+
var CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
|
|
121
|
+
function stripResourceQuery(file) {
|
|
122
|
+
let idx = file.indexOf("?");
|
|
123
|
+
if (idx === -1) {
|
|
124
|
+
idx = file.indexOf("&");
|
|
125
|
+
}
|
|
126
|
+
return idx === -1 ? file : file.slice(0, idx);
|
|
127
|
+
}
|
|
128
|
+
function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
|
|
129
|
+
if (!data) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const request = data.request;
|
|
133
|
+
if (!request) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (request !== "tailwindcss" && request !== "tailwindcss$" && !request.startsWith("tailwindcss/")) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const issuer = _optionalChain([data, 'access', _3 => _3.contextInfo, 'optionalAccess', _4 => _4.issuer]);
|
|
140
|
+
if (!issuer) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const normalizedIssuer = stripResourceQuery(issuer);
|
|
144
|
+
if (!CSS_EXT_RE.test(normalizedIssuer)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const resolved = _chunkORSWL3MIjs.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
|
|
148
|
+
if (!resolved) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
data.request = resolved;
|
|
152
|
+
}
|
|
153
|
+
function applyTailwindcssCssImportRewrite(compiler, options) {
|
|
154
|
+
if (!options.enabled) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
compiler.hooks.normalModuleFactory.tap(_chunk7UBHTADVjs.pluginName, (factory) => {
|
|
158
|
+
factory.hooks.beforeResolve.tap(_chunk7UBHTADVjs.pluginName, (data) => {
|
|
159
|
+
rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/bundlers/webpack/shared/loader-anchors.ts
|
|
165
|
+
var MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
166
|
+
var MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
167
|
+
var MPX_REWRITE_PRECEDENCE_LOADERS = [
|
|
168
|
+
MPX_STYLE_COMPILER_LOADER,
|
|
169
|
+
MPX_STRIP_CONDITIONAL_LOADER
|
|
170
|
+
];
|
|
171
|
+
function createFinder(targets) {
|
|
172
|
+
return (entries) => entries.findIndex(
|
|
173
|
+
(entry) => targets.some((target) => _optionalChain([entry, 'optionalAccess', _5 => _5.loader, 'optionalAccess', _6 => _6.includes, 'optionalCall', _7 => _7(target)]))
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function createPrioritizedFinder(targets) {
|
|
177
|
+
return (entries) => {
|
|
178
|
+
for (const target of targets) {
|
|
179
|
+
const idx = entries.findIndex((entry) => _optionalChain([entry, 'optionalAccess', _8 => _8.loader, 'optionalAccess', _9 => _9.includes, 'optionalCall', _10 => _10(target)]));
|
|
180
|
+
if (idx !== -1) {
|
|
181
|
+
return idx;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return -1;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function createLoaderAnchorFinders(appType) {
|
|
188
|
+
if (isMpx(appType)) {
|
|
189
|
+
return {
|
|
190
|
+
findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
|
|
191
|
+
findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const fallbackFinder = createFinder(["postcss-loader"]);
|
|
195
|
+
return {
|
|
196
|
+
findRewriteAnchor: fallbackFinder,
|
|
197
|
+
findClassSetAnchor: fallbackFinder
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
|
|
202
|
+
var MPX_STYLE_RESOURCE_QUERY_RE2 = /(?:\?|&)type=styles\b/;
|
|
203
|
+
function getCacheKey(filename) {
|
|
204
|
+
return filename;
|
|
205
|
+
}
|
|
206
|
+
function stripResourceQuery2(resource) {
|
|
207
|
+
if (typeof resource !== "string") {
|
|
208
|
+
return resource;
|
|
209
|
+
}
|
|
210
|
+
const queryIndex = resource.indexOf("?");
|
|
211
|
+
if (queryIndex !== -1) {
|
|
212
|
+
return resource.slice(0, queryIndex);
|
|
213
|
+
}
|
|
214
|
+
const hashIndex = resource.indexOf("#");
|
|
215
|
+
if (hashIndex !== -1) {
|
|
216
|
+
return resource.slice(0, hashIndex);
|
|
217
|
+
}
|
|
218
|
+
return resource;
|
|
219
|
+
}
|
|
220
|
+
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
221
|
+
if (typeof resource !== "string") {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const normalizedResource = stripResourceQuery2(resource);
|
|
225
|
+
if (normalizedResource && cssMatcher(normalizedResource)) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
if (appType === "mpx") {
|
|
229
|
+
return MPX_STYLE_RESOURCE_QUERY_RE2.test(resource);
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
function hasLoaderEntry(entries, target) {
|
|
234
|
+
if (!target) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
return entries.some((entry) => _optionalChain([entry, 'access', _11 => _11.loader, 'optionalAccess', _12 => _12.includes, 'optionalCall', _13 => _13(target)]));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
exports.isMpx = isMpx; exports.ensureMpxTailwindcssAliases = ensureMpxTailwindcssAliases; exports.patchMpxLoaderResolve = patchMpxLoaderResolve; exports.setupMpxTailwindcssRedirect = setupMpxTailwindcssRedirect; exports.injectMpxCssRewritePreRules = injectMpxCssRewritePreRules; exports.applyTailwindcssCssImportRewrite = applyTailwindcssCssImportRewrite; exports.createLoaderAnchorFinders = createLoaderAnchorFinders; exports.getCacheKey = getCacheKey; exports.isCssLikeModuleResource = isCssLikeModuleResource; exports.hasLoaderEntry = hasLoaderEntry;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkI7VIMPUBjs = require('./chunk-I7VIMPUB.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.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 =
|
|
20
|
+
var debug = _chunk7UBHTADVjs.createDebug.call(void 0, );
|
|
21
21
|
var Transform = _stream2.default.Transform;
|
|
22
22
|
function createPlugins(options = {}) {
|
|
23
|
-
const opts =
|
|
23
|
+
const opts = _chunk7UBHTADVjs.getCompilerContext.call(void 0, options);
|
|
24
24
|
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
25
|
-
const patchRecorderState =
|
|
25
|
+
const patchRecorderState = _chunkI7VIMPUBjs.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
|
|
39
|
+
await _chunk7UBHTADVjs.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
|
|
47
|
+
runtimeSet = await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
|
|
48
48
|
runtimeSetInitialized = true;
|
|
49
49
|
return runtimeSet;
|
|
50
50
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
|
4
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkJ4MI4EJOjs = require('./chunk-J4MI4EJO.js');
|
|
8
8
|
|
|
9
9
|
// src/tailwindcss/recorder.ts
|
|
10
10
|
function setupPatchRecorder(patcher, baseDir, options) {
|
|
11
|
-
const recorder =
|
|
11
|
+
const recorder = _chunk7UBHTADVjs.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
14
|
_chunkJ4MI4EJOjs.logger.info("%s%s", prefix, recorder.message);
|
|
@@ -16,7 +16,7 @@ function setupPatchRecorder(patcher, baseDir, options) {
|
|
|
16
16
|
const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _4 => _4.onPatched]) ? async () => {
|
|
17
17
|
await recorder.onPatched();
|
|
18
18
|
} : void 0;
|
|
19
|
-
const patchPromise = patcher ?
|
|
19
|
+
const patchPromise = patcher ? _chunk7UBHTADVjs.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
|
|
20
20
|
return {
|
|
21
21
|
recorder,
|
|
22
22
|
patchPromise,
|