weapp-tailwindcss 4.9.9-beta.0 → 4.10.0-beta.2
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-FT3YGOHE.mjs → chunk-2KAM7AAG.mjs} +35 -7
- package/dist/{chunk-PO3CCFU7.js → chunk-3RGU475C.js} +4 -4
- package/dist/{chunk-YPIQUBC4.mjs → chunk-7ATL22KK.mjs} +44 -17
- package/dist/{chunk-NBS6RMNM.mjs → chunk-AGF55OIE.mjs} +1 -1
- package/dist/{chunk-YYE3U4L3.mjs → chunk-D3I6GQUV.mjs} +134 -20
- package/dist/{chunk-HAM3JEU2.js → chunk-DBAAU4LK.js} +1 -1
- package/dist/{chunk-U4T2HGRZ.js → chunk-F7FBGRWS.js} +16 -13
- package/dist/{chunk-YVYWSXU7.mjs → chunk-FIJF6OL7.mjs} +13 -10
- package/dist/{chunk-A2ST4H4Y.js → chunk-FLJBD5TW.js} +5 -5
- package/dist/{chunk-CAFL5XBF.js → chunk-GFJYJ6WV.js} +65 -38
- package/dist/{chunk-47TVJCQM.mjs → chunk-HT76VHOV.mjs} +1 -1
- package/dist/{chunk-DOX3RXJ2.js → chunk-IIDSY4XZ.js} +2 -2
- package/dist/{chunk-IY5ZVBL2.mjs → chunk-Q7TIBSU2.mjs} +37 -1
- package/dist/{chunk-42HSNAKM.js → chunk-QOWSZHYT.js} +42 -6
- package/dist/{chunk-YY55J7K3.js → chunk-UCDOKKRH.js} +141 -27
- package/dist/{chunk-HQ2G6NBK.js → chunk-YS2V3XY2.js} +57 -29
- package/dist/cli.js +39 -39
- package/dist/cli.mjs +2 -2
- package/dist/core.js +29 -22
- package/dist/core.mjs +28 -21
- 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 +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -6
- package/dist/gulp.mjs +4 -4
- package/dist/index.js +10 -10
- package/dist/index.mjs +7 -7
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +5 -5
- package/dist/presets.mjs +1 -1
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.d.mts +5 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -7
- package/dist/vite.mjs +4 -4
- package/dist/webpack.js +8 -8
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.js +63 -41
- package/dist/webpack4.mjs +40 -18
- package/package.json +7 -6
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-RRHPTTCP.mjs";
|
|
13
13
|
import {
|
|
14
14
|
setupPatchRecorder
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AGF55OIE.mjs";
|
|
16
16
|
import {
|
|
17
17
|
collectRuntimeClassSet,
|
|
18
18
|
createAttributeMatcher,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
replaceWxml,
|
|
25
25
|
toCustomAttributesEntities,
|
|
26
26
|
vitePluginName
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-D3I6GQUV.mjs";
|
|
28
28
|
import {
|
|
29
29
|
resolveUniUtsPlatform
|
|
30
30
|
} from "./chunk-OOHJLO5M.mjs";
|
|
@@ -620,6 +620,30 @@ function formatCacheHitRate(metric) {
|
|
|
620
620
|
}
|
|
621
621
|
return `${(metric.cacheHits / metric.total * 100).toFixed(2)}%`;
|
|
622
622
|
}
|
|
623
|
+
function formatMs(value) {
|
|
624
|
+
return value.toFixed(2);
|
|
625
|
+
}
|
|
626
|
+
function summarizeStringDiff(previous, next) {
|
|
627
|
+
if (previous === next) {
|
|
628
|
+
return "same";
|
|
629
|
+
}
|
|
630
|
+
const previousLength = previous.length;
|
|
631
|
+
const nextLength = next.length;
|
|
632
|
+
const minLength = Math.min(previousLength, nextLength);
|
|
633
|
+
let prefixLength = 0;
|
|
634
|
+
while (prefixLength < minLength && previous.charCodeAt(prefixLength) === next.charCodeAt(prefixLength)) {
|
|
635
|
+
prefixLength += 1;
|
|
636
|
+
}
|
|
637
|
+
let previousSuffixCursor = previousLength - 1;
|
|
638
|
+
let nextSuffixCursor = nextLength - 1;
|
|
639
|
+
while (previousSuffixCursor >= prefixLength && nextSuffixCursor >= prefixLength && previous.charCodeAt(previousSuffixCursor) === next.charCodeAt(nextSuffixCursor)) {
|
|
640
|
+
previousSuffixCursor -= 1;
|
|
641
|
+
nextSuffixCursor -= 1;
|
|
642
|
+
}
|
|
643
|
+
const previousChangedLength = previousSuffixCursor >= prefixLength ? previousSuffixCursor - prefixLength + 1 : 0;
|
|
644
|
+
const nextChangedLength = nextSuffixCursor >= prefixLength ? nextSuffixCursor - prefixLength + 1 : 0;
|
|
645
|
+
return `changed@${prefixLength} old=${previousChangedLength} new=${nextChangedLength} len=${previousLength}->${nextLength}`;
|
|
646
|
+
}
|
|
623
647
|
function createLinkedImpactSignature(entry, linkedImpactsByEntry, sourceHashByFile) {
|
|
624
648
|
const changedLinkedFiles = linkedImpactsByEntry.get(entry);
|
|
625
649
|
if (!changedLinkedFiles || changedLinkedFiles.size === 0) {
|
|
@@ -676,6 +700,7 @@ function createGenerateBundleHook(context) {
|
|
|
676
700
|
const forceRuntimeRefresh = process2.env.WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH === "1";
|
|
677
701
|
const disableDirtyOptimization = process2.env.WEAPP_TW_VITE_DISABLE_DIRTY === "1";
|
|
678
702
|
const disableJsPrecheck = process2.env.WEAPP_TW_VITE_DISABLE_JS_PRECHECK === "1";
|
|
703
|
+
const debugCssDiff = process2.env.WEAPP_TW_VITE_DEBUG_CSS_DIFF === "1";
|
|
679
704
|
const entries = Object.entries(bundle);
|
|
680
705
|
const dirtyEntries = computeDirtyEntries(entries, opts, state);
|
|
681
706
|
const processSets = buildProcessSets(entries, opts, dirtyEntries.changedByType, state.previousLinkedByEntry, disableDirtyOptimization);
|
|
@@ -795,6 +820,9 @@ function createGenerateBundleHook(context) {
|
|
|
795
820
|
},
|
|
796
821
|
majorVersion: runtimeState.twPatcher.majorVersion
|
|
797
822
|
});
|
|
823
|
+
if (debugCssDiff) {
|
|
824
|
+
debug2("css diff %s: %s", file, summarizeStringDiff(rawSource, css));
|
|
825
|
+
}
|
|
798
826
|
metrics.css.elapsed += measureElapsed(start);
|
|
799
827
|
metrics.css.transformed++;
|
|
800
828
|
onUpdate(file, rawSource, css);
|
|
@@ -955,24 +983,24 @@ function createGenerateBundleHook(context) {
|
|
|
955
983
|
}
|
|
956
984
|
state.previousLinkedByEntry = nextLinkedByEntry;
|
|
957
985
|
debug2(
|
|
958
|
-
"metrics iteration=%d runtime
|
|
986
|
+
"metrics iteration=%d runtime=%sms html(total=%d transform=%d hit=%d rate=%s elapsed=%sms) js(total=%d transform=%d hit=%d rate=%s elapsed=%sms) css(total=%d transform=%d hit=%d rate=%s elapsed=%sms)",
|
|
959
987
|
state.iteration,
|
|
960
|
-
metrics.runtimeSet,
|
|
988
|
+
formatMs(metrics.runtimeSet),
|
|
961
989
|
metrics.html.total,
|
|
962
990
|
metrics.html.transformed,
|
|
963
991
|
metrics.html.cacheHits,
|
|
964
992
|
formatCacheHitRate(metrics.html),
|
|
965
|
-
metrics.html.elapsed,
|
|
993
|
+
formatMs(metrics.html.elapsed),
|
|
966
994
|
metrics.js.total,
|
|
967
995
|
metrics.js.transformed,
|
|
968
996
|
metrics.js.cacheHits,
|
|
969
997
|
formatCacheHitRate(metrics.js),
|
|
970
|
-
metrics.js.elapsed,
|
|
998
|
+
formatMs(metrics.js.elapsed),
|
|
971
999
|
metrics.css.total,
|
|
972
1000
|
metrics.css.transformed,
|
|
973
1001
|
metrics.css.cacheHits,
|
|
974
1002
|
formatCacheHitRate(metrics.css),
|
|
975
|
-
metrics.css.elapsed
|
|
1003
|
+
formatMs(metrics.css.elapsed)
|
|
976
1004
|
);
|
|
977
1005
|
onEnd();
|
|
978
1006
|
debug2("end");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkDBAAU4LKjs = require('./chunk-DBAAU4LK.js');
|
|
7
7
|
|
|
8
8
|
// src/logger/index.ts
|
|
9
9
|
var _logger = require('@weapp-tailwindcss/logger');
|
|
@@ -318,7 +318,7 @@ function resolveModuleFromPaths(specifier, paths) {
|
|
|
318
318
|
return void 0;
|
|
319
319
|
}
|
|
320
320
|
try {
|
|
321
|
-
const req = _module.createRequire.call(void 0,
|
|
321
|
+
const req = _module.createRequire.call(void 0, _chunkDBAAU4LKjs.importMetaUrl);
|
|
322
322
|
return req.resolve(specifier, { paths });
|
|
323
323
|
} catch (e3) {
|
|
324
324
|
return void 0;
|
|
@@ -373,11 +373,11 @@ function createDefaultResolvePaths(basedir) {
|
|
|
373
373
|
const cwd = _process2.default.cwd();
|
|
374
374
|
appendNodeModules(paths, cwd);
|
|
375
375
|
try {
|
|
376
|
-
const modulePath = _url.fileURLToPath.call(void 0,
|
|
376
|
+
const modulePath = _url.fileURLToPath.call(void 0, _chunkDBAAU4LKjs.importMetaUrl);
|
|
377
377
|
const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
|
|
378
378
|
paths.add(candidate);
|
|
379
379
|
} catch (e4) {
|
|
380
|
-
paths.add(
|
|
380
|
+
paths.add(_chunkDBAAU4LKjs.importMetaUrl);
|
|
381
381
|
}
|
|
382
382
|
if (paths.size === 0) {
|
|
383
383
|
fallbackCandidates = fallbackCandidates.filter(Boolean);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyTailwindcssCssImportRewrite,
|
|
3
|
+
createAssetHashByChunkMap,
|
|
3
4
|
createLoaderAnchorFinders,
|
|
4
5
|
ensureMpxTailwindcssAliases,
|
|
5
6
|
getCacheKey,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
isMpx,
|
|
10
11
|
patchMpxLoaderResolve,
|
|
11
12
|
setupMpxTailwindcssRedirect
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-Q7TIBSU2.mjs";
|
|
13
14
|
import {
|
|
14
15
|
pushConcurrentTaskFactories,
|
|
15
16
|
resolveDisabledOptions,
|
|
@@ -22,20 +23,20 @@ import {
|
|
|
22
23
|
} from "./chunk-RRHPTTCP.mjs";
|
|
23
24
|
import {
|
|
24
25
|
setupPatchRecorder
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AGF55OIE.mjs";
|
|
26
27
|
import {
|
|
27
|
-
collectRuntimeClassSet,
|
|
28
28
|
createDebug,
|
|
29
|
+
ensureRuntimeClassSet,
|
|
29
30
|
getCompilerContext,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
31
|
+
getRuntimeClassSetSignature,
|
|
32
|
+
pluginName
|
|
33
|
+
} from "./chunk-D3I6GQUV.mjs";
|
|
33
34
|
import {
|
|
34
35
|
getGroupedEntries
|
|
35
36
|
} from "./chunk-OOHJLO5M.mjs";
|
|
36
37
|
import {
|
|
37
38
|
__dirname
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-HT76VHOV.mjs";
|
|
39
40
|
|
|
40
41
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
41
42
|
import process3 from "process";
|
|
@@ -49,7 +50,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
49
50
|
options: compilerOptions,
|
|
50
51
|
appType,
|
|
51
52
|
runtimeState,
|
|
52
|
-
refreshRuntimeState,
|
|
53
53
|
debug: debug2
|
|
54
54
|
} = options;
|
|
55
55
|
const { Compilation, sources } = compiler.webpack;
|
|
@@ -69,6 +69,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
69
69
|
compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
72
73
|
const entries = Object.entries(assets);
|
|
73
74
|
const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
|
|
74
75
|
const outputDir = compilerOutputPath ? path.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? process.cwd();
|
|
@@ -124,9 +125,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
127
|
const groupedEntries = getGroupedEntries(entries, compilerOptions);
|
|
127
|
-
await
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
const runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
129
|
+
forceCollect: false,
|
|
130
|
+
allowEmpty: false
|
|
131
|
+
});
|
|
130
132
|
debug2("get runtimeSet, class count: %d", runtimeSet.size);
|
|
131
133
|
const tasks = [];
|
|
132
134
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -134,11 +136,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
134
136
|
const [file, originalSource] = element;
|
|
135
137
|
const rawSource = originalSource.source().toString();
|
|
136
138
|
const cacheKey = file;
|
|
139
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
137
140
|
tasks.push(
|
|
138
141
|
processCachedTask({
|
|
139
142
|
cache: compilerOptions.cache,
|
|
140
143
|
cacheKey,
|
|
144
|
+
hashKey: `${file}:asset`,
|
|
141
145
|
rawSource,
|
|
146
|
+
hash: chunkHash,
|
|
142
147
|
applyResult(source) {
|
|
143
148
|
compilation.updateAsset(file, source);
|
|
144
149
|
},
|
|
@@ -171,11 +176,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
171
176
|
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
172
177
|
const initialSource = asset.source.source();
|
|
173
178
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
179
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
174
180
|
jsTaskFactories.push(async () => {
|
|
175
181
|
await processCachedTask({
|
|
176
182
|
cache: compilerOptions.cache,
|
|
177
183
|
cacheKey,
|
|
184
|
+
hashKey: `${file}:asset`,
|
|
178
185
|
rawSource: initialRawSource,
|
|
186
|
+
hash: chunkHash,
|
|
179
187
|
applyResult(source) {
|
|
180
188
|
compilation.updateAsset(file, source);
|
|
181
189
|
},
|
|
@@ -210,11 +218,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
210
218
|
const [file, originalSource] = element;
|
|
211
219
|
const rawSource = originalSource.source().toString();
|
|
212
220
|
const cacheKey = file;
|
|
221
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
213
222
|
tasks.push(
|
|
214
223
|
processCachedTask({
|
|
215
224
|
cache: compilerOptions.cache,
|
|
216
225
|
cacheKey,
|
|
226
|
+
hashKey: `${file}:asset`,
|
|
217
227
|
rawSource,
|
|
228
|
+
hash: chunkHash,
|
|
218
229
|
applyResult(source) {
|
|
219
230
|
compilation.updateAsset(file, source);
|
|
220
231
|
},
|
|
@@ -407,13 +418,30 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
407
418
|
refreshTailwindcssPatcher,
|
|
408
419
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
409
420
|
};
|
|
410
|
-
|
|
411
|
-
|
|
421
|
+
let runtimeSetPrepared = false;
|
|
422
|
+
let runtimeSetSignature;
|
|
423
|
+
const resetRuntimePreparation = () => {
|
|
424
|
+
runtimeSetPrepared = false;
|
|
412
425
|
};
|
|
426
|
+
if (compiler.hooks.thisCompilation?.tap) {
|
|
427
|
+
compiler.hooks.thisCompilation.tap(pluginName, resetRuntimePreparation);
|
|
428
|
+
} else if (compiler.hooks.compilation?.tap) {
|
|
429
|
+
compiler.hooks.compilation.tap(pluginName, resetRuntimePreparation);
|
|
430
|
+
}
|
|
413
431
|
async function getClassSetInLoader() {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
432
|
+
if (runtimeSetPrepared) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const signature = getRuntimeClassSetSignature(runtimeState.twPatcher);
|
|
436
|
+
const forceRefresh = signature !== runtimeSetSignature;
|
|
437
|
+
runtimeSetPrepared = true;
|
|
438
|
+
await ensureRuntimeClassSet(runtimeState, {
|
|
439
|
+
forceRefresh,
|
|
440
|
+
forceCollect: true,
|
|
441
|
+
clearCache: forceRefresh,
|
|
442
|
+
allowEmpty: true
|
|
443
|
+
});
|
|
444
|
+
runtimeSetSignature = signature;
|
|
417
445
|
}
|
|
418
446
|
onLoad();
|
|
419
447
|
setupWebpackV5Loaders({
|
|
@@ -432,7 +460,6 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
432
460
|
options: this.options,
|
|
433
461
|
appType: this.appType,
|
|
434
462
|
runtimeState,
|
|
435
|
-
refreshRuntimeState,
|
|
436
463
|
debug
|
|
437
464
|
});
|
|
438
465
|
}
|
|
@@ -79,6 +79,15 @@ function createTailwindPatchPromise(twPatcher, onPatched) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
+
var runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
|
|
83
|
+
function getRuntimeClassSetStateEntry(state) {
|
|
84
|
+
let entry = runtimeClassSetStateCache.get(state);
|
|
85
|
+
if (!entry) {
|
|
86
|
+
entry = {};
|
|
87
|
+
runtimeClassSetStateCache.set(state, entry);
|
|
88
|
+
}
|
|
89
|
+
return entry;
|
|
90
|
+
}
|
|
82
91
|
async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
83
92
|
const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
|
|
84
93
|
const force = normalizedOptions.force;
|
|
@@ -100,6 +109,62 @@ async function refreshTailwindRuntimeState(state, forceOrOptions) {
|
|
|
100
109
|
}
|
|
101
110
|
return refreshed;
|
|
102
111
|
}
|
|
112
|
+
async function ensureRuntimeClassSet(state, options = {}) {
|
|
113
|
+
const forceRefresh = options.forceRefresh === true;
|
|
114
|
+
const forceCollect = options.forceCollect === true;
|
|
115
|
+
const clearCache = options.clearCache === true;
|
|
116
|
+
const allowEmpty = options.allowEmpty === true;
|
|
117
|
+
if (forceRefresh) {
|
|
118
|
+
await refreshTailwindRuntimeState(state, {
|
|
119
|
+
force: true,
|
|
120
|
+
clearCache
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
await state.patchPromise;
|
|
124
|
+
const entry = getRuntimeClassSetStateEntry(state);
|
|
125
|
+
const signature = getRuntimeClassSetSignature(state.twPatcher);
|
|
126
|
+
const signatureChanged = entry.signature !== signature;
|
|
127
|
+
const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
|
|
128
|
+
if (!shouldForceCollect) {
|
|
129
|
+
if (entry.value && (allowEmpty || entry.value.size > 0)) {
|
|
130
|
+
return entry.value;
|
|
131
|
+
}
|
|
132
|
+
if (entry.promise) {
|
|
133
|
+
return entry.promise;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const task = (async () => {
|
|
137
|
+
const collected = await collectRuntimeClassSet(state.twPatcher, {
|
|
138
|
+
force: shouldForceCollect,
|
|
139
|
+
skipRefresh: true,
|
|
140
|
+
clearCache
|
|
141
|
+
});
|
|
142
|
+
if (allowEmpty || collected.size > 0) {
|
|
143
|
+
return collected;
|
|
144
|
+
}
|
|
145
|
+
await refreshTailwindRuntimeState(state, {
|
|
146
|
+
force: true,
|
|
147
|
+
clearCache: true
|
|
148
|
+
});
|
|
149
|
+
await state.patchPromise;
|
|
150
|
+
return collectRuntimeClassSet(state.twPatcher, {
|
|
151
|
+
force: true,
|
|
152
|
+
skipRefresh: true,
|
|
153
|
+
clearCache: true
|
|
154
|
+
});
|
|
155
|
+
})();
|
|
156
|
+
entry.promise = task;
|
|
157
|
+
try {
|
|
158
|
+
const runtimeSet = await task;
|
|
159
|
+
entry.value = runtimeSet;
|
|
160
|
+
entry.signature = getRuntimeClassSetSignature(state.twPatcher);
|
|
161
|
+
return runtimeSet;
|
|
162
|
+
} finally {
|
|
163
|
+
if (entry.promise === task) {
|
|
164
|
+
entry.promise = void 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
103
168
|
function shouldPreferSync(majorVersion) {
|
|
104
169
|
if (majorVersion == null) {
|
|
105
170
|
return true;
|
|
@@ -201,7 +266,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
201
266
|
// package.json
|
|
202
267
|
var package_default = {
|
|
203
268
|
name: "weapp-tailwindcss",
|
|
204
|
-
version: "4.
|
|
269
|
+
version: "4.10.0-beta.2",
|
|
205
270
|
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!",
|
|
206
271
|
author: "ice breaker <1324318532@qq.com>",
|
|
207
272
|
license: "MIT",
|
|
@@ -384,7 +449,8 @@ var package_default = {
|
|
|
384
449
|
lint: "eslint .",
|
|
385
450
|
"lint:fix": "eslint ./src --fix",
|
|
386
451
|
postinstall: "node bin/weapp-tailwindcss.js patch",
|
|
387
|
-
"bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts"
|
|
452
|
+
"bench:vite-dev-hmr": "tsx scripts/vite-dev-hmr-bench.ts",
|
|
453
|
+
"test:watch-hmr": "tsx scripts/watch-hmr-regression.ts"
|
|
388
454
|
},
|
|
389
455
|
publishConfig: {
|
|
390
456
|
access: "public",
|
|
@@ -411,7 +477,7 @@ var package_default = {
|
|
|
411
477
|
"local-pkg": "^1.1.2",
|
|
412
478
|
"lru-cache": "10.4.3",
|
|
413
479
|
"magic-string": "0.30.21",
|
|
414
|
-
semver: "~7.7.
|
|
480
|
+
semver: "~7.7.4",
|
|
415
481
|
"tailwindcss-patch": "catalog:tailwindcssPatch",
|
|
416
482
|
"webpack-sources": "3.3.3",
|
|
417
483
|
yaml: "^2.8.2"
|
|
@@ -1057,6 +1123,67 @@ import { jsStringEscape } from "@ast-core/escape";
|
|
|
1057
1123
|
import { escapeStringRegexp as escapeStringRegexp2 } from "@weapp-core/regex";
|
|
1058
1124
|
import { splitCode } from "@weapp-tailwindcss/shared/extractors";
|
|
1059
1125
|
|
|
1126
|
+
// src/shared/classname-transform.ts
|
|
1127
|
+
var arbitraryClassTokenRE = /\[[^\]\r\n]+\]/;
|
|
1128
|
+
var utilityLikeClassRE = /^-?[@\w][\w:/.[\]()%#!,-]*$/;
|
|
1129
|
+
var escapableTokenRE = /[.[\]/:]/;
|
|
1130
|
+
function isArbitraryValueClassName(candidate) {
|
|
1131
|
+
if (!arbitraryClassTokenRE.test(candidate)) {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
return candidate.startsWith("[") || candidate.includes("-[") || candidate.includes(":[");
|
|
1135
|
+
}
|
|
1136
|
+
function shouldFallbackEscapeClassName(candidate) {
|
|
1137
|
+
if (!candidate) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
if (candidate.startsWith("@")) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
if (candidate.includes("://")) {
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
if (candidate.includes("/")) {
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
if (!utilityLikeClassRE.test(candidate)) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
if (isArbitraryValueClassName(candidate)) {
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
if (!escapableTokenRE.test(candidate)) {
|
|
1156
|
+
return false;
|
|
1157
|
+
}
|
|
1158
|
+
if (!candidate.includes(".")) {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
return candidate.includes("-") || candidate.includes(":");
|
|
1162
|
+
}
|
|
1163
|
+
function shouldTransformClassNameCandidate(candidate, {
|
|
1164
|
+
alwaysEscape,
|
|
1165
|
+
classNameSet,
|
|
1166
|
+
staleClassNameFallback,
|
|
1167
|
+
jsPreserveClass
|
|
1168
|
+
}) {
|
|
1169
|
+
if (alwaysEscape) {
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
if (jsPreserveClass?.(candidate)) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
if (!classNameSet || classNameSet.size === 0) {
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
if (classNameSet.has(candidate)) {
|
|
1179
|
+
return true;
|
|
1180
|
+
}
|
|
1181
|
+
if (!staleClassNameFallback) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
return shouldFallbackEscapeClassName(candidate);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1060
1187
|
// src/utils/decode.ts
|
|
1061
1188
|
var unicodeEscapeRE = /\\u([\dA-Fa-f]{4})/g;
|
|
1062
1189
|
var unicodeEscapeTestRE = /\\u[\dA-Fa-f]{4}/;
|
|
@@ -1134,22 +1261,6 @@ function getReplacement(candidate, escapeMap) {
|
|
|
1134
1261
|
function hasIgnoreComment(node) {
|
|
1135
1262
|
return Array.isArray(node.leadingComments) && node.leadingComments.some((comment) => comment.value.includes("weapp-tw") && comment.value.includes("ignore"));
|
|
1136
1263
|
}
|
|
1137
|
-
function shouldTransformClassName(candidate, {
|
|
1138
|
-
alwaysEscape,
|
|
1139
|
-
classNameSet,
|
|
1140
|
-
jsPreserveClass
|
|
1141
|
-
}) {
|
|
1142
|
-
if (alwaysEscape) {
|
|
1143
|
-
return true;
|
|
1144
|
-
}
|
|
1145
|
-
if (!classNameSet) {
|
|
1146
|
-
return false;
|
|
1147
|
-
}
|
|
1148
|
-
if (!classNameSet.has(candidate)) {
|
|
1149
|
-
return false;
|
|
1150
|
-
}
|
|
1151
|
-
return !jsPreserveClass?.(candidate);
|
|
1152
|
-
}
|
|
1153
1264
|
function extractLiteralValue(path4, { unescapeUnicode, arbitraryValues }) {
|
|
1154
1265
|
const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
|
|
1155
1266
|
let offset = 0;
|
|
@@ -1193,7 +1304,7 @@ function replaceHandleValue(path4, options) {
|
|
|
1193
1304
|
let transformed = literal;
|
|
1194
1305
|
let mutated = false;
|
|
1195
1306
|
for (const candidate of candidates) {
|
|
1196
|
-
if (!
|
|
1307
|
+
if (!shouldTransformClassNameCandidate(candidate, options)) {
|
|
1197
1308
|
continue;
|
|
1198
1309
|
}
|
|
1199
1310
|
if (!transformed.includes(candidate)) {
|
|
@@ -2259,6 +2370,7 @@ function createJsHandler(options) {
|
|
|
2259
2370
|
const {
|
|
2260
2371
|
arbitraryValues,
|
|
2261
2372
|
escapeMap,
|
|
2373
|
+
staleClassNameFallback,
|
|
2262
2374
|
jsPreserveClass,
|
|
2263
2375
|
generateMap,
|
|
2264
2376
|
needEscaped,
|
|
@@ -2280,6 +2392,7 @@ function createJsHandler(options) {
|
|
|
2280
2392
|
{
|
|
2281
2393
|
classNameSet,
|
|
2282
2394
|
escapeMap,
|
|
2395
|
+
staleClassNameFallback,
|
|
2283
2396
|
arbitraryValues,
|
|
2284
2397
|
jsPreserveClass,
|
|
2285
2398
|
generateMap,
|
|
@@ -2915,6 +3028,7 @@ export {
|
|
|
2915
3028
|
getRuntimeClassSetSignature,
|
|
2916
3029
|
createTailwindPatchPromise,
|
|
2917
3030
|
refreshTailwindRuntimeState,
|
|
3031
|
+
ensureRuntimeClassSet,
|
|
2918
3032
|
collectRuntimeClassSet,
|
|
2919
3033
|
pluginName,
|
|
2920
3034
|
vitePluginName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.10.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@24.10.13__@swc+core@1.15.11_@swc_f8079344adc4b1859e6989f440e01c9c/node_modules/tsup/assets/cjs_shims.js
|
|
2
2
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
3
3
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
4
4
|
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkFLJBD5TWjs = require('./chunk-FLJBD5TW.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkUCDOKKRHjs = require('./chunk-UCDOKKRH.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 = _chunkUCDOKKRHjs.createDebug.call(void 0, );
|
|
21
21
|
var Transform = _stream2.default.Transform;
|
|
22
22
|
function createPlugins(options = {}) {
|
|
23
|
-
const opts =
|
|
23
|
+
const opts = _chunkUCDOKKRHjs.getCompilerContext.call(void 0, options);
|
|
24
24
|
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
25
|
-
const patchRecorderState =
|
|
25
|
+
const patchRecorderState = _chunkFLJBD5TWjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
26
26
|
source: "runtime",
|
|
27
27
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
28
28
|
});
|
|
@@ -36,15 +36,18 @@ 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 _chunkUCDOKKRHjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
40
40
|
}
|
|
41
41
|
async function refreshRuntimeSet(force = false) {
|
|
42
|
-
|
|
43
|
-
await runtimeState.patchPromise;
|
|
44
|
-
if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
|
|
42
|
+
if (!force && runtimeSetInitialized) {
|
|
45
43
|
return runtimeSet;
|
|
46
44
|
}
|
|
47
|
-
runtimeSet = await
|
|
45
|
+
runtimeSet = await _chunkUCDOKKRHjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
46
|
+
forceRefresh: force,
|
|
47
|
+
forceCollect: force,
|
|
48
|
+
clearCache: force,
|
|
49
|
+
allowEmpty: false
|
|
50
|
+
});
|
|
48
51
|
runtimeSetInitialized = true;
|
|
49
52
|
return runtimeSet;
|
|
50
53
|
}
|
|
@@ -122,7 +125,7 @@ function createPlugins(options = {}) {
|
|
|
122
125
|
if (!file.contents) {
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
|
-
await
|
|
128
|
+
await refreshRuntimeState(true);
|
|
126
129
|
await runtimeState.patchPromise;
|
|
127
130
|
const rawSource = file.contents.toString();
|
|
128
131
|
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
@@ -153,7 +156,7 @@ function createPlugins(options = {}) {
|
|
|
153
156
|
if (!file.contents) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
|
-
await refreshRuntimeSet(
|
|
159
|
+
await refreshRuntimeSet(false);
|
|
157
160
|
await runtimeState.patchPromise;
|
|
158
161
|
const filename = _path2.default.resolve(file.path);
|
|
159
162
|
const moduleGraph = _nullishCoalesce(options2.moduleGraph, () => ( createModuleGraphOptionsFor()));
|
|
@@ -192,7 +195,7 @@ function createPlugins(options = {}) {
|
|
|
192
195
|
if (!file.contents) {
|
|
193
196
|
return;
|
|
194
197
|
}
|
|
195
|
-
await refreshRuntimeSet(
|
|
198
|
+
await refreshRuntimeSet(false);
|
|
196
199
|
await runtimeState.patchPromise;
|
|
197
200
|
const rawSource = file.contents.toString();
|
|
198
201
|
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-RRHPTTCP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
setupPatchRecorder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AGF55OIE.mjs";
|
|
7
7
|
import {
|
|
8
|
-
collectRuntimeClassSet,
|
|
9
8
|
createDebug,
|
|
9
|
+
ensureRuntimeClassSet,
|
|
10
10
|
getCompilerContext,
|
|
11
11
|
refreshTailwindRuntimeState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-D3I6GQUV.mjs";
|
|
13
13
|
|
|
14
14
|
// src/bundlers/gulp/index.ts
|
|
15
15
|
import { Buffer } from "buffer";
|
|
@@ -39,12 +39,15 @@ function createPlugins(options = {}) {
|
|
|
39
39
|
await refreshTailwindRuntimeState(runtimeState, force);
|
|
40
40
|
}
|
|
41
41
|
async function refreshRuntimeSet(force = false) {
|
|
42
|
-
|
|
43
|
-
await runtimeState.patchPromise;
|
|
44
|
-
if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
|
|
42
|
+
if (!force && runtimeSetInitialized) {
|
|
45
43
|
return runtimeSet;
|
|
46
44
|
}
|
|
47
|
-
runtimeSet = await
|
|
45
|
+
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
46
|
+
forceRefresh: force,
|
|
47
|
+
forceCollect: force,
|
|
48
|
+
clearCache: force,
|
|
49
|
+
allowEmpty: false
|
|
50
|
+
});
|
|
48
51
|
runtimeSetInitialized = true;
|
|
49
52
|
return runtimeSet;
|
|
50
53
|
}
|
|
@@ -122,7 +125,7 @@ function createPlugins(options = {}) {
|
|
|
122
125
|
if (!file.contents) {
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
|
-
await
|
|
128
|
+
await refreshRuntimeState(true);
|
|
126
129
|
await runtimeState.patchPromise;
|
|
127
130
|
const rawSource = file.contents.toString();
|
|
128
131
|
await processCachedTask({
|
|
@@ -153,7 +156,7 @@ function createPlugins(options = {}) {
|
|
|
153
156
|
if (!file.contents) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
|
-
await refreshRuntimeSet(
|
|
159
|
+
await refreshRuntimeSet(false);
|
|
157
160
|
await runtimeState.patchPromise;
|
|
158
161
|
const filename = path.resolve(file.path);
|
|
159
162
|
const moduleGraph = options2.moduleGraph ?? createModuleGraphOptionsFor();
|
|
@@ -192,7 +195,7 @@ function createPlugins(options = {}) {
|
|
|
192
195
|
if (!file.contents) {
|
|
193
196
|
return;
|
|
194
197
|
}
|
|
195
|
-
await refreshRuntimeSet(
|
|
198
|
+
await refreshRuntimeSet(false);
|
|
196
199
|
await runtimeState.patchPromise;
|
|
197
200
|
const rawSource = file.contents.toString();
|
|
198
201
|
await processCachedTask({
|