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
|
@@ -4,31 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkXX7SUSE7js = require('./chunk-XX7SUSE7.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
12
|
+
var _chunkDGL3SP2Hjs = require('./chunk-DGL3SP2H.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
var _chunkORSWL3MIjs = require('./chunk-ORSWL3MI.js');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
var
|
|
25
|
+
var _chunkI7VIMPUBjs = require('./chunk-I7VIMPUB.js');
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.js');
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -37,11 +38,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
37
38
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
38
39
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
39
40
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
40
|
-
var debug =
|
|
41
|
-
var weappTailwindcssPackageDir =
|
|
41
|
+
var debug = _chunk7UBHTADVjs.createDebug.call(void 0, );
|
|
42
|
+
var weappTailwindcssPackageDir = _chunkORSWL3MIjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
42
43
|
var UnifiedWebpackPluginV5 = class {
|
|
43
44
|
constructor(options = {}) {
|
|
44
|
-
this.options =
|
|
45
|
+
this.options = _chunk7UBHTADVjs.getCompilerContext.call(void 0, options);
|
|
45
46
|
this.appType = this.options.appType;
|
|
46
47
|
}
|
|
47
48
|
apply(compiler) {
|
|
@@ -62,21 +63,22 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
62
63
|
twPatcher: initialTwPatcher,
|
|
63
64
|
refreshTailwindcssPatcher
|
|
64
65
|
} = this.options;
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
66
|
+
const disabledOptions = _chunkORSWL3MIjs.resolveDisabledOptions.call(void 0, disabled);
|
|
68
67
|
const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
|
|
69
|
-
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false;
|
|
70
|
-
const isMpxApp =
|
|
68
|
+
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
69
|
+
const isMpxApp = _chunkDGL3SP2Hjs.isMpx.call(void 0, this.appType);
|
|
71
70
|
if (shouldRewriteCssImports) {
|
|
72
|
-
|
|
71
|
+
_chunkDGL3SP2Hjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
|
|
73
72
|
pkgDir: weappTailwindcssPackageDir,
|
|
74
73
|
enabled: true,
|
|
75
74
|
appType: this.appType
|
|
76
75
|
});
|
|
77
|
-
|
|
76
|
+
_chunkDGL3SP2Hjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
|
|
77
|
+
}
|
|
78
|
+
if (disabledOptions.plugin) {
|
|
79
|
+
return;
|
|
78
80
|
}
|
|
79
|
-
const patchRecorderState =
|
|
81
|
+
const patchRecorderState = _chunkI7VIMPUBjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
80
82
|
source: "runtime",
|
|
81
83
|
cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
82
84
|
});
|
|
@@ -87,14 +89,14 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
87
89
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
88
90
|
};
|
|
89
91
|
const refreshRuntimeState = async (force) => {
|
|
90
|
-
await
|
|
92
|
+
await _chunk7UBHTADVjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
91
93
|
};
|
|
92
94
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
93
95
|
const { ConcatSource } = sources;
|
|
94
96
|
async function getClassSetInLoader() {
|
|
95
97
|
await refreshRuntimeState(true);
|
|
96
98
|
await runtimeState.patchPromise;
|
|
97
|
-
await
|
|
99
|
+
await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
98
100
|
}
|
|
99
101
|
const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
|
|
100
102
|
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
|
|
@@ -107,16 +109,16 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
107
109
|
const classSetLoaderOptions = {
|
|
108
110
|
getClassSet: getClassSetInLoader
|
|
109
111
|
};
|
|
110
|
-
const { findRewriteAnchor, findClassSetAnchor } =
|
|
112
|
+
const { findRewriteAnchor, findClassSetAnchor } = _chunkDGL3SP2Hjs.createLoaderAnchorFinders.call(void 0, this.appType);
|
|
111
113
|
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
112
114
|
rewriteCssImports: runtimeLoaderRewriteOptions
|
|
113
115
|
} : void 0;
|
|
114
116
|
onLoad();
|
|
115
117
|
if (shouldRewriteCssImports && isMpxApp) {
|
|
116
|
-
|
|
118
|
+
_chunkDGL3SP2Hjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
|
|
117
119
|
}
|
|
118
120
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
|
|
119
|
-
|
|
121
|
+
_chunkDGL3SP2Hjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
120
122
|
}
|
|
121
123
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
122
124
|
loader: runtimeClassSetLoader,
|
|
@@ -135,17 +137,17 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
135
137
|
type: null
|
|
136
138
|
};
|
|
137
139
|
};
|
|
138
|
-
compiler.hooks.compilation.tap(
|
|
139
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
140
|
+
compiler.hooks.compilation.tap(_chunk7UBHTADVjs.pluginName, (compilation) => {
|
|
141
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunk7UBHTADVjs.pluginName, (_loaderContext, module) => {
|
|
140
142
|
const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
|
|
141
143
|
if (!hasRuntimeLoader) {
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
_chunkDGL3SP2Hjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
|
|
145
147
|
const loaderEntries = module.loaders || [];
|
|
146
148
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
147
149
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
148
|
-
const isCssModule =
|
|
150
|
+
const isCssModule = _chunkDGL3SP2Hjs.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
|
|
149
151
|
if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
|
|
150
152
|
debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
|
|
151
153
|
}
|
|
@@ -177,7 +179,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
177
179
|
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
|
-
if (runtimeClassSetLoaderExists && !
|
|
182
|
+
if (runtimeClassSetLoaderExists && !_chunkDGL3SP2Hjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
|
|
181
183
|
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
182
184
|
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
183
185
|
if (anchorIndex === -1) {
|
|
@@ -190,7 +192,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
190
192
|
});
|
|
191
193
|
compilation.hooks.processAssets.tapPromise(
|
|
192
194
|
{
|
|
193
|
-
name:
|
|
195
|
+
name: _chunk7UBHTADVjs.pluginName,
|
|
194
196
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
195
197
|
},
|
|
196
198
|
async (assets) => {
|
|
@@ -208,13 +210,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
208
210
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
209
211
|
for (const [file] of entries) {
|
|
210
212
|
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
211
|
-
const absolute =
|
|
213
|
+
const absolute = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
212
214
|
jsAssets.set(absolute, file);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
const moduleGraphOptions = {
|
|
216
218
|
resolve(specifier, importer) {
|
|
217
|
-
return
|
|
219
|
+
return _chunkORSWL3MIjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
218
220
|
},
|
|
219
221
|
load: (id) => {
|
|
220
222
|
const assetName = jsAssets.get(id);
|
|
@@ -259,7 +261,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
259
261
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
260
262
|
await refreshRuntimeState(true);
|
|
261
263
|
await runtimeState.patchPromise;
|
|
262
|
-
const runtimeSet = await
|
|
264
|
+
const runtimeSet = await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
263
265
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
264
266
|
const tasks = [];
|
|
265
267
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -296,12 +298,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
296
298
|
const jsTaskFactories = [];
|
|
297
299
|
if (Array.isArray(groupedEntries.js)) {
|
|
298
300
|
for (const [file] of groupedEntries.js) {
|
|
299
|
-
const cacheKey =
|
|
301
|
+
const cacheKey = _chunkDGL3SP2Hjs.getCacheKey.call(void 0, file);
|
|
300
302
|
const asset = compilation.getAsset(file);
|
|
301
303
|
if (!asset) {
|
|
302
304
|
continue;
|
|
303
305
|
}
|
|
304
|
-
const absoluteFile =
|
|
306
|
+
const absoluteFile = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
305
307
|
const initialSource = asset.source.source();
|
|
306
308
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
307
309
|
jsTaskFactories.push(async () => {
|
|
@@ -376,7 +378,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
376
378
|
);
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
|
-
|
|
381
|
+
_chunkORSWL3MIjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
380
382
|
await Promise.all(tasks);
|
|
381
383
|
debug("end");
|
|
382
384
|
onEnd();
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveTailwindcssImport
|
|
3
|
+
} from "./chunk-3SKEY32E.mjs";
|
|
4
|
+
import {
|
|
5
|
+
pluginName
|
|
6
|
+
} from "./chunk-QYYQDG6A.mjs";
|
|
7
|
+
|
|
8
|
+
// src/shared/mpx.ts
|
|
9
|
+
import path2 from "path";
|
|
10
|
+
|
|
11
|
+
// src/shared/tailwindcss-css-redirect.ts
|
|
12
|
+
import Module from "module";
|
|
13
|
+
import path from "path";
|
|
14
|
+
var moduleWithMutableResolve = Module;
|
|
15
|
+
var patched = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
function installTailwindcssCssRedirect(pkgDir) {
|
|
17
|
+
const target = path.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 path.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.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 = 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 (request?.startsWith("tailwindcss/")) {
|
|
81
|
+
return callback(null, path2.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 = (_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 = data.contextInfo?.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 = resolveTailwindcssImport(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(pluginName, (factory) => {
|
|
158
|
+
factory.hooks.beforeResolve.tap(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) => entry?.loader?.includes?.(target))
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
function createPrioritizedFinder(targets) {
|
|
177
|
+
return (entries) => {
|
|
178
|
+
for (const target of targets) {
|
|
179
|
+
const idx = entries.findIndex((entry) => entry?.loader?.includes?.(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) => entry.loader?.includes?.(target));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
isMpx,
|
|
242
|
+
ensureMpxTailwindcssAliases,
|
|
243
|
+
patchMpxLoaderResolve,
|
|
244
|
+
setupMpxTailwindcssRedirect,
|
|
245
|
+
injectMpxCssRewritePreRules,
|
|
246
|
+
applyTailwindcssCssImportRewrite,
|
|
247
|
+
createLoaderAnchorFinders,
|
|
248
|
+
getCacheKey,
|
|
249
|
+
isCssLikeModuleResource,
|
|
250
|
+
hasLoaderEntry
|
|
251
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -334,9 +334,9 @@ async function patchWorkspace(options) {
|
|
|
334
334
|
try {
|
|
335
335
|
const patcher = createWorkspacePatcher(dir);
|
|
336
336
|
if (options.clearCache) {
|
|
337
|
-
await
|
|
337
|
+
await _chunk7UBHTADVjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
|
|
338
338
|
}
|
|
339
|
-
const recorder =
|
|
339
|
+
const recorder = _chunk7UBHTADVjs.createPatchTargetRecorder.call(void 0, dir, patcher, {
|
|
340
340
|
source: "cli",
|
|
341
341
|
cwd: dir,
|
|
342
342
|
recordTarget: options.recordTarget !== false,
|
|
@@ -345,7 +345,7 @@ async function patchWorkspace(options) {
|
|
|
345
345
|
if (_optionalChain([recorder, 'optionalAccess', _13 => _13.message])) {
|
|
346
346
|
_chunkJ4MI4EJOjs.logger.info("[workspace] %s %s", displayName, recorder.message);
|
|
347
347
|
}
|
|
348
|
-
|
|
348
|
+
_chunk7UBHTADVjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir);
|
|
349
349
|
await patcher.patch();
|
|
350
350
|
if (_optionalChain([recorder, 'optionalAccess', _14 => _14.onPatched])) {
|
|
351
351
|
await recorder.onPatched();
|
|
@@ -500,9 +500,9 @@ var mountOptions = {
|
|
|
500
500
|
}
|
|
501
501
|
const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx);
|
|
502
502
|
if (shouldClearCache) {
|
|
503
|
-
await
|
|
503
|
+
await _chunk7UBHTADVjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true });
|
|
504
504
|
}
|
|
505
|
-
const recorder =
|
|
505
|
+
const recorder = _chunk7UBHTADVjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, {
|
|
506
506
|
source: "cli",
|
|
507
507
|
cwd: ctx.cwd,
|
|
508
508
|
recordTarget: shouldRecordTarget,
|
|
@@ -511,7 +511,7 @@ var mountOptions = {
|
|
|
511
511
|
if (_optionalChain([recorder, 'optionalAccess', _18 => _18.message])) {
|
|
512
512
|
_chunkJ4MI4EJOjs.logger.info(recorder.message);
|
|
513
513
|
}
|
|
514
|
-
|
|
514
|
+
_chunk7UBHTADVjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd);
|
|
515
515
|
await patcher.patch();
|
|
516
516
|
if (_optionalChain([recorder, 'optionalAccess', _19 => _19.onPatched])) {
|
|
517
517
|
const recordPath = await recorder.onPatched();
|
|
@@ -659,9 +659,9 @@ async function generateVscodeIntellisenseEntry(options) {
|
|
|
659
659
|
|
|
660
660
|
// src/cli.ts
|
|
661
661
|
_process2.default.title = "node (weapp-tailwindcss)";
|
|
662
|
-
if (_semver2.default.lt(_process2.default.versions.node,
|
|
662
|
+
if (_semver2.default.lt(_process2.default.versions.node, _chunk7UBHTADVjs.WEAPP_TW_REQUIRED_NODE_VERSION)) {
|
|
663
663
|
_chunkJ4MI4EJOjs.logger.warn(
|
|
664
|
-
`You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${
|
|
664
|
+
`You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunk7UBHTADVjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`
|
|
665
665
|
);
|
|
666
666
|
}
|
|
667
667
|
var cli = _tailwindcsspatch.createTailwindcssPatchCli.call(void 0, {
|
package/dist/cli.mjs
CHANGED
package/dist/core.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
var
|
|
3
|
+
var _chunkI7VIMPUBjs = require('./chunk-I7VIMPUB.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk7UBHTADVjs = require('./chunk-7UBHTADV.js');
|
|
9
9
|
require('./chunk-J4MI4EJO.js');
|
|
10
10
|
require('./chunk-3URI7W6X.js');
|
|
11
11
|
require('./chunk-UW3WHSZ5.js');
|
|
@@ -15,9 +15,9 @@ require('./chunk-MB4BR57E.js');
|
|
|
15
15
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
16
16
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
17
17
|
function createContext(options = {}) {
|
|
18
|
-
const opts =
|
|
18
|
+
const opts = _chunk7UBHTADVjs.getCompilerContext.call(void 0, options);
|
|
19
19
|
const { templateHandler, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
20
|
-
const patchRecorderState =
|
|
20
|
+
const patchRecorderState = _chunkI7VIMPUBjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
21
21
|
source: "runtime",
|
|
22
22
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
23
23
|
});
|
|
@@ -29,7 +29,7 @@ function createContext(options = {}) {
|
|
|
29
29
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
30
30
|
};
|
|
31
31
|
async function refreshRuntimeState(force) {
|
|
32
|
-
await
|
|
32
|
+
await _chunk7UBHTADVjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
33
33
|
}
|
|
34
34
|
async function transformWxss(rawCss, options2) {
|
|
35
35
|
await runtimeState.patchPromise;
|
|
@@ -38,7 +38,7 @@ function createContext(options = {}) {
|
|
|
38
38
|
}));
|
|
39
39
|
await refreshRuntimeState(true);
|
|
40
40
|
await runtimeState.patchPromise;
|
|
41
|
-
runtimeSet = await
|
|
41
|
+
runtimeSet = await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
async function transformJs(rawJs, options2 = {}) {
|
|
@@ -48,7 +48,7 @@ function createContext(options = {}) {
|
|
|
48
48
|
} else {
|
|
49
49
|
await refreshRuntimeState(true);
|
|
50
50
|
await runtimeState.patchPromise;
|
|
51
|
-
runtimeSet = await
|
|
51
|
+
runtimeSet = await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
52
52
|
}
|
|
53
53
|
return await jsHandler(rawJs, runtimeSet, options2);
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ function createContext(options = {}) {
|
|
|
57
57
|
if (!_optionalChain([options2, 'optionalAccess', _2 => _2.runtimeSet]) && runtimeSet.size === 0) {
|
|
58
58
|
await refreshRuntimeState(true);
|
|
59
59
|
await runtimeState.patchPromise;
|
|
60
|
-
runtimeSet = await
|
|
60
|
+
runtimeSet = await _chunk7UBHTADVjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
61
61
|
}
|
|
62
62
|
return templateHandler(rawWxml, _shared.defuOverrideArray.call(void 0, options2, {
|
|
63
63
|
runtimeSet
|
package/dist/core.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setupPatchRecorder
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FQX7YIN5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
collectRuntimeClassSet,
|
|
6
6
|
getCompilerContext,
|
|
7
7
|
refreshTailwindRuntimeState
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QYYQDG6A.mjs";
|
|
9
9
|
import "./chunk-3VIPMWAG.mjs";
|
|
10
10
|
import "./chunk-QF65JGNW.mjs";
|
|
11
11
|
import "./chunk-ZNKIYZRQ.mjs";
|
package/dist/gulp.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkH4BVDT5Qjs = require('./chunk-H4BVDT5Q.js');
|
|
4
4
|
require('./chunk-LTJQUORK.js');
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-I7VIMPUB.js');
|
|
6
|
+
require('./chunk-7UBHTADV.js');
|
|
7
7
|
require('./chunk-J4MI4EJO.js');
|
|
8
8
|
require('./chunk-3URI7W6X.js');
|
|
9
9
|
require('./chunk-UW3WHSZ5.js');
|
|
10
10
|
require('./chunk-MB4BR57E.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
exports.createPlugins =
|
|
13
|
+
exports.createPlugins = _chunkH4BVDT5Qjs.createPlugins;
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugins
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4ZJEFTPC.mjs";
|
|
4
4
|
import "./chunk-RRHPTTCP.mjs";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-FQX7YIN5.mjs";
|
|
6
|
+
import "./chunk-QYYQDG6A.mjs";
|
|
7
7
|
import "./chunk-3VIPMWAG.mjs";
|
|
8
8
|
import "./chunk-QF65JGNW.mjs";
|
|
9
9
|
import "./chunk-ZNKIYZRQ.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createPlugins } from './gulp.mjs';
|
|
2
|
-
export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, JsModuleGraphOptions, LinkedJsModuleResult, RefreshTailwindcssPatcherOptions, TailwindcssPatcherLike, UserDefinedOptions } from './types.mjs';
|
|
2
|
+
export { AppType, CreateJsHandlerOptions, DisabledOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, JsModuleGraphOptions, LinkedJsModuleResult, RefreshTailwindcssPatcherOptions, TailwindcssPatcherLike, UserDefinedOptions } from './types.mjs';
|
|
3
3
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
4
4
|
export { UnifiedWebpackPluginV5, weappTailwindcssPackageDir } from './webpack.mjs';
|
|
5
5
|
export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createPlugins } from './gulp.js';
|
|
2
|
-
export { AppType, CreateJsHandlerOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, JsModuleGraphOptions, LinkedJsModuleResult, RefreshTailwindcssPatcherOptions, TailwindcssPatcherLike, UserDefinedOptions } from './types.js';
|
|
2
|
+
export { AppType, CreateJsHandlerOptions, DisabledOptions, IArbitraryValues, IBaseWebpackPlugin, ICommonReplaceOptions, ICustomAttributes, ICustomAttributesEntities, IJsHandlerOptions, ITemplateHandlerOptions, InternalPatchResult, InternalPostcssOptions, InternalUserDefinedOptions, ItemOrItemArray, JsHandler, JsHandlerResult, JsModuleGraphOptions, LinkedJsModuleResult, RefreshTailwindcssPatcherOptions, TailwindcssPatcherLike, UserDefinedOptions } from './types.js';
|
|
3
3
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.js';
|
|
4
4
|
export { UnifiedWebpackPluginV5, weappTailwindcssPackageDir } from './webpack.js';
|
|
5
5
|
export { CssPreflightOptions, IStyleHandlerOptions } from '@weapp-tailwindcss/postcss';
|