weapp-tailwindcss 4.7.1 → 4.7.3
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-XLUAMJS6.js → chunk-2AAEKHNR.js} +49 -43
- package/dist/{chunk-W4YVU4OO.mjs → chunk-3ARXMTWC.mjs} +10 -1
- package/dist/chunk-667CYXAH.mjs +133 -0
- package/dist/chunk-BUMQQPAO.js +133 -0
- package/dist/{chunk-C7SH2SQK.mjs → chunk-CIBW3DQO.mjs} +43 -37
- package/dist/{chunk-Z6YNBYLM.mjs → chunk-DXFNC4BP.mjs} +278 -109
- package/dist/{chunk-KCL4CARB.js → chunk-JTGVWJ3Z.js} +281 -112
- package/dist/{chunk-NRG7N2Q7.mjs → chunk-KZJLIZIK.mjs} +0 -1
- package/dist/{chunk-34T2BFTJ.mjs → chunk-KZUIVLPP.mjs} +42 -1
- package/dist/{chunk-4NJFDWBZ.js → chunk-L2CHPESJ.js} +94 -78
- package/dist/{chunk-FUMBS2BS.mjs → chunk-O3TOCTXE.mjs} +85 -69
- package/dist/chunk-R7GWRQDJ.js +15 -0
- package/dist/chunk-SCOGAO45.mjs +18 -0
- package/dist/{chunk-KF7YCOEP.js → chunk-SIZNRUIV.js} +14 -5
- package/dist/{chunk-KMGWHIDU.js → chunk-UAU6XVAY.js} +7 -6
- package/dist/{chunk-WVKK6TBL.js → chunk-W7BVY5S5.js} +42 -1
- package/dist/{chunk-LZ6L3UQO.js → chunk-WXBFAARR.js} +0 -1
- package/dist/{chunk-F6IW6L27.mjs → chunk-XFYWHJEU.mjs} +6 -5
- package/dist/cli.js +384 -16
- package/dist/cli.mjs +384 -17
- package/dist/core.js +11 -10
- package/dist/core.mjs +11 -10
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/escape.js +1 -1
- package/dist/escape.mjs +1 -1
- package/dist/gulp.js +7 -7
- package/dist/gulp.mjs +6 -6
- package/dist/index.js +10 -10
- package/dist/index.mjs +9 -9
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +2 -2
- package/dist/types.d.mts +8 -21
- package/dist/types.d.ts +8 -21
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +8 -8
- package/dist/vite.mjs +7 -7
- package/dist/webpack.js +8 -8
- package/dist/webpack.mjs +7 -7
- package/dist/webpack4.js +52 -46
- package/dist/webpack4.mjs +45 -39
- package/package.json +5 -3
- package/dist/chunk-4EUTRMUC.mjs +0 -10
- package/dist/chunk-FB5P4TRH.js +0 -70
- package/dist/chunk-QXSBMK2W.js +0 -7
- package/dist/chunk-YPBRGP6K.mjs +0 -70
|
@@ -4,18 +4,20 @@ var _chunk6GP37C26js = require('./chunk-6GP37C26.js');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkW7BVY5S5js = require('./chunk-W7BVY5S5.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
var _chunkBUMQQPAOjs = require('./chunk-BUMQQPAO.js');
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _chunkJTGVWJ3Zjs = require('./chunk-JTGVWJ3Z.js');
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -24,10 +26,10 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
24
26
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
25
27
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
26
28
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
27
|
-
var debug =
|
|
29
|
+
var debug = _chunkBUMQQPAOjs.createDebug.call(void 0, );
|
|
28
30
|
var UnifiedWebpackPluginV5 = class {
|
|
29
31
|
constructor(options = {}) {
|
|
30
|
-
this.options =
|
|
32
|
+
this.options = _chunkJTGVWJ3Zjs.getCompilerContext.call(void 0, options);
|
|
31
33
|
this.appType = this.options.appType;
|
|
32
34
|
}
|
|
33
35
|
apply(compiler) {
|
|
@@ -48,12 +50,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
48
50
|
if (disabled) {
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
const patchPromise =
|
|
53
|
+
const patchPromise = _chunkBUMQQPAOjs.createTailwindPatchPromise.call(void 0, twPatcher);
|
|
52
54
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
53
55
|
const { ConcatSource } = sources;
|
|
54
56
|
async function getClassSetInLoader() {
|
|
55
57
|
await patchPromise;
|
|
56
|
-
await
|
|
58
|
+
await _chunkBUMQQPAOjs.collectRuntimeClassSet.call(void 0, twPatcher, { force: true });
|
|
57
59
|
}
|
|
58
60
|
onLoad();
|
|
59
61
|
const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
|
|
@@ -66,8 +68,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
66
68
|
ident: null,
|
|
67
69
|
type: null
|
|
68
70
|
};
|
|
69
|
-
compiler.hooks.compilation.tap(
|
|
70
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
71
|
+
compiler.hooks.compilation.tap(_chunkJTGVWJ3Zjs.pluginName, (compilation) => {
|
|
72
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkJTGVWJ3Zjs.pluginName, (_loaderContext, module) => {
|
|
71
73
|
if (isExisted) {
|
|
72
74
|
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
73
75
|
if (idx > -1) {
|
|
@@ -77,7 +79,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
77
79
|
});
|
|
78
80
|
compilation.hooks.processAssets.tapPromise(
|
|
79
81
|
{
|
|
80
|
-
name:
|
|
82
|
+
name: _chunkJTGVWJ3Zjs.pluginName,
|
|
81
83
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
82
84
|
},
|
|
83
85
|
async (assets) => {
|
|
@@ -95,13 +97,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
95
97
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
96
98
|
for (const [file] of entries) {
|
|
97
99
|
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
98
|
-
const absolute =
|
|
100
|
+
const absolute = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
99
101
|
jsAssets.set(absolute, file);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
const moduleGraphOptions = {
|
|
103
105
|
resolve(specifier, importer) {
|
|
104
|
-
return
|
|
106
|
+
return _chunkW7BVY5S5js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
105
107
|
},
|
|
106
108
|
load: (id) => {
|
|
107
109
|
const assetName = jsAssets.get(id);
|
|
@@ -144,7 +146,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
144
146
|
}
|
|
145
147
|
};
|
|
146
148
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
147
|
-
const runtimeSet = await
|
|
149
|
+
const runtimeSet = await _chunkBUMQQPAOjs.collectRuntimeClassSet.call(void 0, twPatcher, { force: true });
|
|
148
150
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
149
151
|
const tasks = [];
|
|
150
152
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -178,6 +180,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
178
180
|
);
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
const jsTaskFactories = [];
|
|
181
184
|
if (Array.isArray(groupedEntries.js)) {
|
|
182
185
|
for (const [file] of groupedEntries.js) {
|
|
183
186
|
const cacheKey = _chunk6GP37C26js.getCacheKey.call(void 0, file);
|
|
@@ -185,38 +188,40 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
185
188
|
if (!asset) {
|
|
186
189
|
continue;
|
|
187
190
|
}
|
|
188
|
-
const absoluteFile =
|
|
191
|
+
const absoluteFile = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
189
192
|
const initialSource = asset.source.source();
|
|
190
193
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
194
|
+
jsTaskFactories.push(async () => {
|
|
195
|
+
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
196
|
+
cache,
|
|
197
|
+
cacheKey,
|
|
198
|
+
rawSource: initialRawSource,
|
|
199
|
+
applyResult(source) {
|
|
200
|
+
compilation.updateAsset(file, source);
|
|
201
|
+
},
|
|
202
|
+
onCacheHit() {
|
|
203
|
+
debug("js cache hit: %s", file);
|
|
204
|
+
},
|
|
205
|
+
transform: async () => {
|
|
206
|
+
const currentAsset = compilation.getAsset(file);
|
|
207
|
+
const currentSourceValue = _optionalChain([currentAsset, 'optionalAccess', _5 => _5.source, 'access', _6 => _6.source, 'call', _7 => _7()]);
|
|
208
|
+
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : _nullishCoalesce(_optionalChain([currentSourceValue, 'optionalAccess', _8 => _8.toString, 'call', _9 => _9()]), () => ( ""));
|
|
209
|
+
const { code, linked } = await jsHandler(currentSource, runtimeSet, {
|
|
210
|
+
filename: absoluteFile,
|
|
211
|
+
moduleGraph: moduleGraphOptions,
|
|
212
|
+
babelParserOptions: {
|
|
213
|
+
sourceFilename: absoluteFile
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
const source = new ConcatSource(code);
|
|
217
|
+
onUpdate(file, currentSource, code);
|
|
218
|
+
debug("js handle: %s", file);
|
|
219
|
+
applyLinkedResults(linked);
|
|
220
|
+
return {
|
|
221
|
+
result: source
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
});
|
|
220
225
|
});
|
|
221
226
|
}
|
|
222
227
|
}
|
|
@@ -258,6 +263,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
258
263
|
);
|
|
259
264
|
}
|
|
260
265
|
}
|
|
266
|
+
_chunkW7BVY5S5js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
261
267
|
await Promise.all(tasks);
|
|
262
268
|
debug("end");
|
|
263
269
|
onEnd();
|
|
@@ -384,6 +384,12 @@ var ENV_BASEDIR_KEYS = [
|
|
|
384
384
|
"PWD"
|
|
385
385
|
];
|
|
386
386
|
var GENERIC_ENV_BASEDIR_KEYS = /* @__PURE__ */ new Set(["INIT_CWD", "PWD"]);
|
|
387
|
+
function isLegacyTailwindcssPatcherOptions(options) {
|
|
388
|
+
return typeof options === "object" && options !== null && "patch" in options;
|
|
389
|
+
}
|
|
390
|
+
function isModernTailwindcssPatchOptions(options) {
|
|
391
|
+
return typeof options === "object" && options !== null && !("patch" in options);
|
|
392
|
+
}
|
|
387
393
|
function pickEnvBasedir() {
|
|
388
394
|
for (const key of ENV_BASEDIR_KEYS) {
|
|
389
395
|
const value = process2.env[key];
|
|
@@ -542,7 +548,7 @@ function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries)
|
|
|
542
548
|
if (!options) {
|
|
543
549
|
return options;
|
|
544
550
|
}
|
|
545
|
-
if (
|
|
551
|
+
if (isLegacyTailwindcssPatcherOptions(options)) {
|
|
546
552
|
const patchOptions = options.patch;
|
|
547
553
|
if (!patchOptions) {
|
|
548
554
|
return options;
|
|
@@ -567,6 +573,9 @@ function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries)
|
|
|
567
573
|
patch: nextPatch
|
|
568
574
|
};
|
|
569
575
|
}
|
|
576
|
+
if (!isModernTailwindcssPatchOptions(options)) {
|
|
577
|
+
return options;
|
|
578
|
+
}
|
|
570
579
|
if (!options.tailwind) {
|
|
571
580
|
return options;
|
|
572
581
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// src/tailwindcss/runtime.ts
|
|
2
|
+
import { statSync } from "fs";
|
|
3
|
+
|
|
4
|
+
// src/debug/index.ts
|
|
5
|
+
import _createDebug from "debug";
|
|
6
|
+
var _debug = _createDebug("weapp-tw");
|
|
7
|
+
function createDebug(prefix) {
|
|
8
|
+
function debug2(formatter, ...args) {
|
|
9
|
+
return _debug((prefix ?? "") + formatter, ...args);
|
|
10
|
+
}
|
|
11
|
+
return debug2;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/tailwindcss/runtime.ts
|
|
15
|
+
var debug = createDebug("[tailwindcss:runtime] ");
|
|
16
|
+
var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
function getCacheEntry(twPatcher) {
|
|
18
|
+
let entry = runtimeClassSetCache.get(twPatcher);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
entry = {};
|
|
21
|
+
runtimeClassSetCache.set(twPatcher, entry);
|
|
22
|
+
}
|
|
23
|
+
return entry;
|
|
24
|
+
}
|
|
25
|
+
function getTailwindConfigSignature(twPatcher) {
|
|
26
|
+
const configPath = twPatcher.options?.tailwind?.config;
|
|
27
|
+
if (typeof configPath !== "string" || configPath.length === 0) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const stats = statSync(configPath);
|
|
32
|
+
return `${configPath}:${stats.size}:${stats.mtimeMs}`;
|
|
33
|
+
} catch {
|
|
34
|
+
return `${configPath}:missing`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function invalidateRuntimeClassSet(twPatcher) {
|
|
38
|
+
if (!twPatcher) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
runtimeClassSetCache.delete(twPatcher);
|
|
42
|
+
}
|
|
43
|
+
function createTailwindPatchPromise(twPatcher) {
|
|
44
|
+
return Promise.resolve(twPatcher.patch()).then((result) => {
|
|
45
|
+
invalidateRuntimeClassSet(twPatcher);
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function shouldPreferSync(majorVersion) {
|
|
50
|
+
if (majorVersion == null) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (majorVersion === 3) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (majorVersion === 4) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function tryGetRuntimeClassSetSync(twPatcher) {
|
|
62
|
+
if (typeof twPatcher.getClassSetSync !== "function") {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
if (!shouldPreferSync(twPatcher.majorVersion)) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return twPatcher.getClassSetSync();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (twPatcher.majorVersion === 4) {
|
|
72
|
+
debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
|
|
73
|
+
} else {
|
|
74
|
+
debug("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
|
|
75
|
+
}
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
80
|
+
const entry = getCacheEntry(twPatcher);
|
|
81
|
+
const signature = getTailwindConfigSignature(twPatcher);
|
|
82
|
+
if (!options.force) {
|
|
83
|
+
if (entry.value && entry.signature === signature) {
|
|
84
|
+
return entry.value;
|
|
85
|
+
}
|
|
86
|
+
if (entry.promise) {
|
|
87
|
+
return entry.promise;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
entry.value = void 0;
|
|
91
|
+
}
|
|
92
|
+
const task = (async () => {
|
|
93
|
+
const syncSet = tryGetRuntimeClassSetSync(twPatcher);
|
|
94
|
+
if (syncSet) {
|
|
95
|
+
return syncSet;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const result = await twPatcher.extract({ write: false });
|
|
99
|
+
if (result?.classSet) {
|
|
100
|
+
return result.classSet;
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
debug("extract() failed, fallback to getClassSet(): %O", error);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const fallbackSet = await Promise.resolve(twPatcher.getClassSet());
|
|
107
|
+
if (fallbackSet) {
|
|
108
|
+
return fallbackSet;
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
debug("getClassSet() failed, returning empty set: %O", error);
|
|
112
|
+
}
|
|
113
|
+
return /* @__PURE__ */ new Set();
|
|
114
|
+
})();
|
|
115
|
+
entry.promise = task;
|
|
116
|
+
entry.signature = signature;
|
|
117
|
+
try {
|
|
118
|
+
const resolved = await task;
|
|
119
|
+
entry.value = resolved;
|
|
120
|
+
entry.promise = void 0;
|
|
121
|
+
entry.signature = signature;
|
|
122
|
+
return resolved;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
entry.promise = void 0;
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
createDebug,
|
|
131
|
+
createTailwindPatchPromise,
|
|
132
|
+
collectRuntimeClassSet
|
|
133
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
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; }// src/tailwindcss/runtime.ts
|
|
2
|
+
var _fs = require('fs');
|
|
3
|
+
|
|
4
|
+
// src/debug/index.ts
|
|
5
|
+
var _debug2 = require('debug'); var _debug3 = _interopRequireDefault(_debug2);
|
|
6
|
+
var _debug = _debug3.default.call(void 0, "weapp-tw");
|
|
7
|
+
function createDebug(prefix) {
|
|
8
|
+
function debug2(formatter, ...args) {
|
|
9
|
+
return _debug((_nullishCoalesce(prefix, () => ( ""))) + formatter, ...args);
|
|
10
|
+
}
|
|
11
|
+
return debug2;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/tailwindcss/runtime.ts
|
|
15
|
+
var debug = createDebug("[tailwindcss:runtime] ");
|
|
16
|
+
var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
function getCacheEntry(twPatcher) {
|
|
18
|
+
let entry = runtimeClassSetCache.get(twPatcher);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
entry = {};
|
|
21
|
+
runtimeClassSetCache.set(twPatcher, entry);
|
|
22
|
+
}
|
|
23
|
+
return entry;
|
|
24
|
+
}
|
|
25
|
+
function getTailwindConfigSignature(twPatcher) {
|
|
26
|
+
const configPath = _optionalChain([twPatcher, 'access', _ => _.options, 'optionalAccess', _2 => _2.tailwind, 'optionalAccess', _3 => _3.config]);
|
|
27
|
+
if (typeof configPath !== "string" || configPath.length === 0) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const stats = _fs.statSync.call(void 0, configPath);
|
|
32
|
+
return `${configPath}:${stats.size}:${stats.mtimeMs}`;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return `${configPath}:missing`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function invalidateRuntimeClassSet(twPatcher) {
|
|
38
|
+
if (!twPatcher) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
runtimeClassSetCache.delete(twPatcher);
|
|
42
|
+
}
|
|
43
|
+
function createTailwindPatchPromise(twPatcher) {
|
|
44
|
+
return Promise.resolve(twPatcher.patch()).then((result) => {
|
|
45
|
+
invalidateRuntimeClassSet(twPatcher);
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function shouldPreferSync(majorVersion) {
|
|
50
|
+
if (majorVersion == null) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (majorVersion === 3) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (majorVersion === 4) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function tryGetRuntimeClassSetSync(twPatcher) {
|
|
62
|
+
if (typeof twPatcher.getClassSetSync !== "function") {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
if (!shouldPreferSync(twPatcher.majorVersion)) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return twPatcher.getClassSetSync();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (twPatcher.majorVersion === 4) {
|
|
72
|
+
debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
|
|
73
|
+
} else {
|
|
74
|
+
debug("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
|
|
75
|
+
}
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
80
|
+
const entry = getCacheEntry(twPatcher);
|
|
81
|
+
const signature = getTailwindConfigSignature(twPatcher);
|
|
82
|
+
if (!options.force) {
|
|
83
|
+
if (entry.value && entry.signature === signature) {
|
|
84
|
+
return entry.value;
|
|
85
|
+
}
|
|
86
|
+
if (entry.promise) {
|
|
87
|
+
return entry.promise;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
entry.value = void 0;
|
|
91
|
+
}
|
|
92
|
+
const task = (async () => {
|
|
93
|
+
const syncSet = tryGetRuntimeClassSetSync(twPatcher);
|
|
94
|
+
if (syncSet) {
|
|
95
|
+
return syncSet;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const result = await twPatcher.extract({ write: false });
|
|
99
|
+
if (_optionalChain([result, 'optionalAccess', _4 => _4.classSet])) {
|
|
100
|
+
return result.classSet;
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
debug("extract() failed, fallback to getClassSet(): %O", error);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const fallbackSet = await Promise.resolve(twPatcher.getClassSet());
|
|
107
|
+
if (fallbackSet) {
|
|
108
|
+
return fallbackSet;
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
debug("getClassSet() failed, returning empty set: %O", error);
|
|
112
|
+
}
|
|
113
|
+
return /* @__PURE__ */ new Set();
|
|
114
|
+
})();
|
|
115
|
+
entry.promise = task;
|
|
116
|
+
entry.signature = signature;
|
|
117
|
+
try {
|
|
118
|
+
const resolved = await task;
|
|
119
|
+
entry.value = resolved;
|
|
120
|
+
entry.promise = void 0;
|
|
121
|
+
entry.signature = signature;
|
|
122
|
+
return resolved;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
entry.promise = void 0;
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
exports.createDebug = createDebug; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.collectRuntimeClassSet = collectRuntimeClassSet;
|
|
@@ -2,26 +2,28 @@ import {
|
|
|
2
2
|
getCacheKey
|
|
3
3
|
} from "./chunk-2F7HOQQY.mjs";
|
|
4
4
|
import {
|
|
5
|
+
pushConcurrentTaskFactories,
|
|
5
6
|
resolveOutputSpecifier,
|
|
6
7
|
toAbsoluteOutputPath
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KZUIVLPP.mjs";
|
|
8
9
|
import {
|
|
9
10
|
processCachedTask
|
|
10
11
|
} from "./chunk-RRHPTTCP.mjs";
|
|
11
12
|
import {
|
|
12
13
|
collectRuntimeClassSet,
|
|
13
|
-
createDebug
|
|
14
|
-
|
|
14
|
+
createDebug,
|
|
15
|
+
createTailwindPatchPromise
|
|
16
|
+
} from "./chunk-667CYXAH.mjs";
|
|
15
17
|
import {
|
|
16
18
|
getCompilerContext,
|
|
17
19
|
pluginName
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DXFNC4BP.mjs";
|
|
19
21
|
import {
|
|
20
22
|
getGroupedEntries
|
|
21
23
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
22
24
|
import {
|
|
23
25
|
__dirname
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SCOGAO45.mjs";
|
|
25
27
|
|
|
26
28
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
27
29
|
import fs from "fs";
|
|
@@ -51,12 +53,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
51
53
|
if (disabled) {
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
|
-
const patchPromise =
|
|
56
|
+
const patchPromise = createTailwindPatchPromise(twPatcher);
|
|
55
57
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
56
58
|
const { ConcatSource } = sources;
|
|
57
59
|
async function getClassSetInLoader() {
|
|
58
60
|
await patchPromise;
|
|
59
|
-
await collectRuntimeClassSet(twPatcher);
|
|
61
|
+
await collectRuntimeClassSet(twPatcher, { force: true });
|
|
60
62
|
}
|
|
61
63
|
onLoad();
|
|
62
64
|
const loader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
|
|
@@ -147,7 +149,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
147
149
|
}
|
|
148
150
|
};
|
|
149
151
|
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
150
|
-
const runtimeSet = await collectRuntimeClassSet(twPatcher);
|
|
152
|
+
const runtimeSet = await collectRuntimeClassSet(twPatcher, { force: true });
|
|
151
153
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
152
154
|
const tasks = [];
|
|
153
155
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -181,6 +183,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
181
183
|
);
|
|
182
184
|
}
|
|
183
185
|
}
|
|
186
|
+
const jsTaskFactories = [];
|
|
184
187
|
if (Array.isArray(groupedEntries.js)) {
|
|
185
188
|
for (const [file] of groupedEntries.js) {
|
|
186
189
|
const cacheKey = getCacheKey(file);
|
|
@@ -191,35 +194,37 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
191
194
|
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
192
195
|
const initialSource = asset.source.source();
|
|
193
196
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
197
|
+
jsTaskFactories.push(async () => {
|
|
198
|
+
await processCachedTask({
|
|
199
|
+
cache,
|
|
200
|
+
cacheKey,
|
|
201
|
+
rawSource: initialRawSource,
|
|
202
|
+
applyResult(source) {
|
|
203
|
+
compilation.updateAsset(file, source);
|
|
204
|
+
},
|
|
205
|
+
onCacheHit() {
|
|
206
|
+
debug("js cache hit: %s", file);
|
|
207
|
+
},
|
|
208
|
+
transform: async () => {
|
|
209
|
+
const currentAsset = compilation.getAsset(file);
|
|
210
|
+
const currentSourceValue = currentAsset?.source.source();
|
|
211
|
+
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
|
|
212
|
+
const { code, linked } = await jsHandler(currentSource, runtimeSet, {
|
|
213
|
+
filename: absoluteFile,
|
|
214
|
+
moduleGraph: moduleGraphOptions,
|
|
215
|
+
babelParserOptions: {
|
|
216
|
+
sourceFilename: absoluteFile
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
const source = new ConcatSource(code);
|
|
220
|
+
onUpdate(file, currentSource, code);
|
|
221
|
+
debug("js handle: %s", file);
|
|
222
|
+
applyLinkedResults(linked);
|
|
223
|
+
return {
|
|
224
|
+
result: source
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
});
|
|
223
228
|
});
|
|
224
229
|
}
|
|
225
230
|
}
|
|
@@ -261,6 +266,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
261
266
|
);
|
|
262
267
|
}
|
|
263
268
|
}
|
|
269
|
+
pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
264
270
|
await Promise.all(tasks);
|
|
265
271
|
debug("end");
|
|
266
272
|
onEnd();
|