weapp-tailwindcss 4.10.3 → 4.11.0-alpha.0
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-3XVUGMTY.mjs → chunk-2LH6PZH3.mjs} +8 -4
- package/dist/{chunk-3WUHHFLF.mjs → chunk-35EI5JMK.mjs} +4 -2
- package/dist/{chunk-WF636Q5E.js → chunk-7XQXBJL6.js} +10 -9
- package/dist/{chunk-5U24PLVV.js → chunk-ACTJYB33.js} +4 -2
- package/dist/{chunk-UYTCZXNE.mjs → chunk-CLNUBO3Q.mjs} +6 -5
- package/dist/{chunk-TNYEOBAC.mjs → chunk-DOH7FULQ.mjs} +1 -1
- package/dist/{chunk-LICQ6EGN.mjs → chunk-EOK3NZVC.mjs} +2 -2
- package/dist/{chunk-YJSFFRNZ.js → chunk-FKUPQQYX.js} +349 -230
- package/dist/{chunk-E7775SFS.mjs → chunk-FMWKBZWX.mjs} +839 -331
- package/dist/{chunk-L7OBNTRI.js → chunk-FV4ZRTAK.js} +57 -17
- package/dist/{chunk-6Z4GEN2Y.js → chunk-G3G437UE.js} +2 -2
- package/dist/{chunk-DEIJXHGJ.js → chunk-I4EOMKX2.js} +903 -395
- package/dist/{chunk-RM3SY4S4.mjs → chunk-OIDFSOER.mjs} +52 -12
- package/dist/{chunk-YUTKX7JZ.js → chunk-OV7FX6XR.js} +1 -1
- package/dist/{chunk-SR4GC2F4.js → chunk-OYSABARD.js} +8 -4
- package/dist/{chunk-GCRL3ZYP.js → chunk-PXZUQ7RR.js} +5 -5
- package/dist/{chunk-PALDKVKG.mjs → chunk-QX2A7SBB.mjs} +326 -207
- package/dist/{chunk-RYC23C3K.js → chunk-RXNSOSCT.js} +13 -9
- package/dist/{chunk-WXT2GI5R.mjs → chunk-W3JO6LBC.mjs} +30 -16
- package/dist/{chunk-W2N6G2QQ.js → chunk-WGFNCK5B.js} +60 -46
- package/dist/{chunk-QOTLDKI4.mjs → chunk-XGUD52TA.mjs} +9 -5
- package/dist/cli.js +45 -42
- package/dist/cli.mjs +9 -6
- package/dist/core.d.mts +4 -3
- package/dist/core.d.ts +4 -3
- package/dist/core.js +124 -30
- package/dist/core.mjs +119 -25
- package/dist/css-macro/postcss.js +6 -5
- package/dist/css-macro/postcss.mjs +4 -3
- package/dist/css-macro.js +5 -5
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/escape.js +2 -1
- package/dist/escape.mjs +2 -1
- package/dist/gulp.d.mts +1 -1
- package/dist/gulp.d.ts +1 -1
- package/dist/gulp.js +8 -7
- package/dist/gulp.mjs +8 -7
- package/dist/index.js +11 -11
- 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 +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +9 -8
- package/dist/vite.mjs +8 -7
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +10 -9
- package/dist/webpack.mjs +8 -7
- package/dist/webpack4.d.mts +1 -1
- package/dist/webpack4.d.ts +1 -1
- package/dist/webpack4.js +64 -49
- package/dist/webpack4.mjs +33 -18
- package/package.json +6 -6
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkG3G437UEjs = require('./chunk-G3G437UE.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkPXZUQ7RRjs = require('./chunk-PXZUQ7RR.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -24,7 +24,9 @@ var _chunkGCRL3ZYPjs = require('./chunk-GCRL3ZYP.js');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var _chunkI4EOMKX2js = require('./chunk-I4EOMKX2.js');
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
@@ -38,12 +40,12 @@ var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _
|
|
|
38
40
|
var _compilerdom = require('@vue/compiler-dom');
|
|
39
41
|
var _compilersfc = require('@vue/compiler-sfc');
|
|
40
42
|
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
41
|
-
function
|
|
43
|
+
function traverse2(node, visitor) {
|
|
42
44
|
visitor(node);
|
|
43
45
|
if (Array.isArray(node.children)) {
|
|
44
46
|
for (const child of node.children) {
|
|
45
47
|
if (child && typeof child === "object" && "type" in child) {
|
|
46
|
-
|
|
48
|
+
traverse2(child, visitor);
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -55,7 +57,7 @@ function updateStaticAttribute(ms, prop) {
|
|
|
55
57
|
const start = prop.value.loc.start.offset + 1;
|
|
56
58
|
const end = prop.value.loc.end.offset - 1;
|
|
57
59
|
if (start < end) {
|
|
58
|
-
ms.update(start, end,
|
|
60
|
+
ms.update(start, end, _chunkI4EOMKX2js.replaceWxml.call(void 0, prop.value.content));
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
@@ -67,7 +69,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
|
67
69
|
if (start >= end) {
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
|
-
const generated =
|
|
72
|
+
const generated = _chunkI4EOMKX2js.generateCode.call(void 0, prop.exp.content, {
|
|
71
73
|
jsHandler,
|
|
72
74
|
runtimeSet,
|
|
73
75
|
wrapExpression: true
|
|
@@ -91,17 +93,18 @@ var defaultCreateJsHandlerOptions = {
|
|
|
91
93
|
]
|
|
92
94
|
}
|
|
93
95
|
};
|
|
96
|
+
var UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
94
97
|
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
95
|
-
if (
|
|
98
|
+
if (!UVUE_NVUE_RE.test(id)) {
|
|
96
99
|
return;
|
|
97
100
|
}
|
|
98
101
|
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
99
|
-
const matchCustomAttribute =
|
|
102
|
+
const matchCustomAttribute = _chunkI4EOMKX2js.createAttributeMatcher.call(void 0, customAttributesEntities);
|
|
100
103
|
const ms = new (0, _magicstring2.default)(code);
|
|
101
104
|
const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
|
|
102
105
|
if (errors.length === 0) {
|
|
103
106
|
if (_optionalChain([descriptor, 'access', _4 => _4.template, 'optionalAccess', _5 => _5.ast])) {
|
|
104
|
-
|
|
107
|
+
traverse2(descriptor.template.ast, (node) => {
|
|
105
108
|
if (node.type !== _compilerdom.NodeTypes.ELEMENT) {
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
@@ -223,16 +226,20 @@ async function formatPostcssSourceMap(rawMap, file) {
|
|
|
223
226
|
|
|
224
227
|
// src/uni-app-x/vite.ts
|
|
225
228
|
var preprocessorLangs = /* @__PURE__ */ new Set(["scss", "sass", "less", "styl", "stylus"]);
|
|
229
|
+
var INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
230
|
+
var PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
231
|
+
var UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
232
|
+
var UVUE_NVUE_RE2 = /\.(?:uvue|nvue)$/;
|
|
226
233
|
function isPreprocessorRequest(id, lang) {
|
|
227
234
|
const normalizedLang = _optionalChain([lang, 'optionalAccess', _8 => _8.toLowerCase, 'call', _9 => _9()]);
|
|
228
235
|
if (normalizedLang && preprocessorLangs.has(normalizedLang)) {
|
|
229
236
|
return true;
|
|
230
237
|
}
|
|
231
|
-
const inlineLangMatch = id.match(
|
|
238
|
+
const inlineLangMatch = id.match(INLINE_LANG_RE);
|
|
232
239
|
if (inlineLangMatch && preprocessorLangs.has(inlineLangMatch[1].toLowerCase())) {
|
|
233
240
|
return true;
|
|
234
241
|
}
|
|
235
|
-
return
|
|
242
|
+
return PREPROCESSOR_EXT_RE.test(id);
|
|
236
243
|
}
|
|
237
244
|
function createUniAppXPlugins(options) {
|
|
238
245
|
const {
|
|
@@ -248,24 +255,31 @@ function createUniAppXPlugins(options) {
|
|
|
248
255
|
getResolvedConfig
|
|
249
256
|
} = options;
|
|
250
257
|
const isIosPlatform = _nullishCoalesce(providedIosPlatform, () => ( _chunkDYLQ6UOIjs.resolveUniUtsPlatform.call(void 0, ).isAppIos));
|
|
258
|
+
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
251
259
|
async function transformStyle(code, id, query) {
|
|
252
260
|
const parsed = _nullishCoalesce(query, () => ( parseVueRequest(id).query));
|
|
253
261
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
|
|
263
|
+
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
264
|
+
if (!styleHandlerOptions) {
|
|
265
|
+
styleHandlerOptions = {
|
|
266
|
+
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
267
|
+
postcssOptions: {
|
|
268
|
+
options: {
|
|
269
|
+
from: id,
|
|
270
|
+
map: {
|
|
271
|
+
inline: false,
|
|
272
|
+
annotation: false,
|
|
273
|
+
// PostCSS 可能返回虚拟文件,因此需要启用这一项以获取源内容
|
|
274
|
+
sourcesContent: true
|
|
275
|
+
// 若上游预处理器已经生成 source map,sources 中可能出现重复条目
|
|
276
|
+
}
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
|
-
}
|
|
268
|
-
|
|
279
|
+
};
|
|
280
|
+
cssHandlerOptionsCache.set(cacheKey, styleHandlerOptions);
|
|
281
|
+
}
|
|
282
|
+
const postcssResult = await styleHandler(code, styleHandlerOptions);
|
|
269
283
|
const rawPostcssMap = postcssResult.map.toJSON();
|
|
270
284
|
const postcssMap = await formatPostcssSourceMap(
|
|
271
285
|
rawPostcssMap,
|
|
@@ -305,7 +319,7 @@ function createUniAppXPlugins(options) {
|
|
|
305
319
|
await ensureRuntimeClassSet(true);
|
|
306
320
|
},
|
|
307
321
|
async transform(code, id) {
|
|
308
|
-
if (
|
|
322
|
+
if (!UVUE_NVUE_QUERY_RE.test(id)) {
|
|
309
323
|
return;
|
|
310
324
|
}
|
|
311
325
|
const resolvedConfig = getResolvedConfig();
|
|
@@ -328,7 +342,7 @@ function createUniAppXPlugins(options) {
|
|
|
328
342
|
if (_optionalChain([resolvedConfig, 'optionalAccess', _17 => _17.command]) !== "serve") {
|
|
329
343
|
return;
|
|
330
344
|
}
|
|
331
|
-
if (
|
|
345
|
+
if (!UVUE_NVUE_RE2.test(ctx.file)) {
|
|
332
346
|
return;
|
|
333
347
|
}
|
|
334
348
|
await ensureRuntimeClassSet(true);
|
|
@@ -338,7 +352,7 @@ function createUniAppXPlugins(options) {
|
|
|
338
352
|
if (_optionalChain([resolvedConfig, 'optionalAccess', _18 => _18.command]) !== "build" || !_optionalChain([resolvedConfig, 'access', _19 => _19.build, 'optionalAccess', _20 => _20.watch])) {
|
|
339
353
|
return;
|
|
340
354
|
}
|
|
341
|
-
if (
|
|
355
|
+
if (!UVUE_NVUE_QUERY_RE.test(id)) {
|
|
342
356
|
return;
|
|
343
357
|
}
|
|
344
358
|
await ensureRuntimeClassSet(true);
|
|
@@ -361,7 +375,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
361
375
|
runtimeSet,
|
|
362
376
|
applyLinkedResults: applyLinkedResults2
|
|
363
377
|
} = options;
|
|
364
|
-
const absoluteFile =
|
|
378
|
+
const absoluteFile = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, file, outDir);
|
|
365
379
|
const rawSource = originalSource.source.toString();
|
|
366
380
|
const rawHashSource = options.hashSalt ? `${rawSource}
|
|
367
381
|
/*${options.hashSalt}*/` : rawSource;
|
|
@@ -433,7 +447,7 @@ function isJavaScriptEntry(entry) {
|
|
|
433
447
|
function createBundleModuleGraphOptions(outputDir, entries) {
|
|
434
448
|
return {
|
|
435
449
|
resolve(specifier, importer) {
|
|
436
|
-
return
|
|
450
|
+
return _chunkG3G437UEjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
|
|
437
451
|
},
|
|
438
452
|
load(id) {
|
|
439
453
|
const entry = entries.get(id);
|
|
@@ -470,56 +484,116 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
|
|
|
470
484
|
}
|
|
471
485
|
}
|
|
472
486
|
|
|
473
|
-
// src/bundlers/vite/
|
|
474
|
-
var
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
487
|
+
// src/bundlers/vite/runtime-affecting-signature.ts
|
|
488
|
+
var _htmlparser2 = require('htmlparser2');
|
|
489
|
+
function createHtmlRuntimeAffectingSignature(source) {
|
|
490
|
+
try {
|
|
491
|
+
const parts = [];
|
|
492
|
+
const parser = new (0, _htmlparser2.Parser)(
|
|
493
|
+
{
|
|
494
|
+
onattribute(name, value) {
|
|
495
|
+
parts.push(`a:${name}=${value}`);
|
|
496
|
+
},
|
|
497
|
+
oncomment(data) {
|
|
498
|
+
parts.push(`c:${data}`);
|
|
499
|
+
},
|
|
500
|
+
ontext(data) {
|
|
501
|
+
const value = data.trim();
|
|
502
|
+
if (value.length > 0) {
|
|
503
|
+
parts.push(`t:${value}`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
xmlMode: true
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
parser.write(source);
|
|
512
|
+
parser.end();
|
|
513
|
+
return parts.join("\n");
|
|
514
|
+
} catch (e) {
|
|
515
|
+
return source;
|
|
482
516
|
}
|
|
483
|
-
|
|
484
|
-
|
|
517
|
+
}
|
|
518
|
+
function createJsRuntimeAffectingSignature(source) {
|
|
519
|
+
try {
|
|
520
|
+
const ast = _chunkI4EOMKX2js.babelParse.call(void 0, source, {
|
|
521
|
+
cache: true,
|
|
522
|
+
cacheKey: "vite-runtime-affecting:unambiguous",
|
|
523
|
+
plugins: ["jsx", "typescript"],
|
|
524
|
+
sourceType: "unambiguous"
|
|
525
|
+
});
|
|
526
|
+
const parts = [];
|
|
527
|
+
_chunkI4EOMKX2js.traverse.call(void 0, ast, {
|
|
528
|
+
noScope: true,
|
|
529
|
+
StringLiteral(path4) {
|
|
530
|
+
parts.push(`s:${path4.node.value}`);
|
|
531
|
+
},
|
|
532
|
+
TemplateElement(path4) {
|
|
533
|
+
parts.push(`t:${path4.node.value.raw}`);
|
|
534
|
+
},
|
|
535
|
+
JSXText(path4) {
|
|
536
|
+
const value = path4.node.value.trim();
|
|
537
|
+
if (value.length > 0) {
|
|
538
|
+
parts.push(`x:${value}`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
const comments = ast.comments;
|
|
543
|
+
if (Array.isArray(comments)) {
|
|
544
|
+
for (const comment of comments) {
|
|
545
|
+
if (typeof _optionalChain([comment, 'optionalAccess', _22 => _22.value]) === "string" && comment.value.length > 0) {
|
|
546
|
+
parts.push(`c:${comment.value}`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return parts.join("\n");
|
|
551
|
+
} catch (e2) {
|
|
552
|
+
return source;
|
|
485
553
|
}
|
|
486
|
-
|
|
487
|
-
|
|
554
|
+
}
|
|
555
|
+
function createRuntimeAffectingSourceSignature(source, type) {
|
|
556
|
+
if (type === "html") {
|
|
557
|
+
return createHtmlRuntimeAffectingSignature(source);
|
|
488
558
|
}
|
|
489
|
-
if (
|
|
490
|
-
return
|
|
559
|
+
if (type === "js") {
|
|
560
|
+
return createJsRuntimeAffectingSignature(source);
|
|
491
561
|
}
|
|
492
|
-
return
|
|
562
|
+
return source;
|
|
493
563
|
}
|
|
494
564
|
|
|
495
|
-
// src/bundlers/vite/
|
|
496
|
-
function
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
return `${sorted.slice(0, limit).join(",")},...(+${sorted.length - limit})`;
|
|
565
|
+
// src/bundlers/vite/bundle-state.ts
|
|
566
|
+
function createBundleBuildState() {
|
|
567
|
+
return {
|
|
568
|
+
iteration: 0,
|
|
569
|
+
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
570
|
+
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
571
|
+
linkedByEntry: /* @__PURE__ */ new Map(),
|
|
572
|
+
dependentsByLinkedFile: /* @__PURE__ */ new Map()
|
|
573
|
+
};
|
|
505
574
|
}
|
|
506
|
-
function
|
|
575
|
+
function createChangedByType() {
|
|
507
576
|
return {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
577
|
+
html: /* @__PURE__ */ new Set(),
|
|
578
|
+
js: /* @__PURE__ */ new Set(),
|
|
579
|
+
css: /* @__PURE__ */ new Set(),
|
|
580
|
+
other: /* @__PURE__ */ new Set()
|
|
512
581
|
};
|
|
513
582
|
}
|
|
514
|
-
function
|
|
583
|
+
function createProcessFiles() {
|
|
515
584
|
return {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
css: createEmptyMetric()
|
|
585
|
+
html: /* @__PURE__ */ new Set(),
|
|
586
|
+
js: /* @__PURE__ */ new Set(),
|
|
587
|
+
css: /* @__PURE__ */ new Set()
|
|
520
588
|
};
|
|
521
589
|
}
|
|
522
|
-
function
|
|
590
|
+
function readEntrySource(output) {
|
|
591
|
+
if (output.type === "chunk") {
|
|
592
|
+
return output.code;
|
|
593
|
+
}
|
|
594
|
+
return output.source.toString();
|
|
595
|
+
}
|
|
596
|
+
function classifyBundleEntry(file, opts) {
|
|
523
597
|
if (opts.cssMatcher(file)) {
|
|
524
598
|
return "css";
|
|
525
599
|
}
|
|
@@ -531,84 +605,69 @@ function classifyEntry(file, opts) {
|
|
|
531
605
|
}
|
|
532
606
|
return "other";
|
|
533
607
|
}
|
|
534
|
-
function
|
|
535
|
-
|
|
536
|
-
|
|
608
|
+
function collectJsEntries(fileName, output, outDir, store) {
|
|
609
|
+
const entry = { fileName, output };
|
|
610
|
+
if (!isJavaScriptEntry(entry)) {
|
|
611
|
+
return;
|
|
537
612
|
}
|
|
538
|
-
|
|
613
|
+
const absolute = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, fileName, outDir);
|
|
614
|
+
store.set(absolute, entry);
|
|
539
615
|
}
|
|
540
|
-
function
|
|
541
|
-
|
|
616
|
+
function markProcessFile(type, file, processFiles) {
|
|
617
|
+
if (type === "html" || type === "js" || type === "css") {
|
|
618
|
+
processFiles[type].add(file);
|
|
619
|
+
}
|
|
542
620
|
}
|
|
543
|
-
function
|
|
544
|
-
const
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
621
|
+
function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
|
|
622
|
+
const sourceHashByFile = /* @__PURE__ */ new Map();
|
|
623
|
+
const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
|
|
624
|
+
const changedByType = createChangedByType();
|
|
625
|
+
const runtimeAffectingChangedByType = createChangedByType();
|
|
626
|
+
const processFiles = createProcessFiles();
|
|
627
|
+
const linkedImpactsByEntry = /* @__PURE__ */ new Map();
|
|
628
|
+
const jsEntries = /* @__PURE__ */ new Map();
|
|
629
|
+
const entries = [];
|
|
630
|
+
const firstRun = state.linkedByEntry.size === 0;
|
|
631
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
632
|
+
const type = classifyBundleEntry(file, opts);
|
|
553
633
|
const source = readEntrySource(output);
|
|
554
634
|
const hash = opts.cache.computeHash(source);
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
635
|
+
sourceHashByFile.set(file, hash);
|
|
636
|
+
const runtimeAffectingSignature = createRuntimeAffectingSourceSignature(source, type);
|
|
637
|
+
const runtimeAffectingHash = opts.cache.computeHash(runtimeAffectingSignature);
|
|
638
|
+
runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
639
|
+
const previousHash = state.sourceHashByFile.get(file);
|
|
640
|
+
const changed = previousHash == null || previousHash !== hash;
|
|
641
|
+
if (changed) {
|
|
558
642
|
changedByType[type].add(file);
|
|
559
643
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function buildProcessSets(entries, opts, changedByType, previousLinkedByEntry, forceAll = false) {
|
|
567
|
-
const processFiles = {
|
|
568
|
-
html: /* @__PURE__ */ new Set(),
|
|
569
|
-
js: /* @__PURE__ */ new Set(),
|
|
570
|
-
css: /* @__PURE__ */ new Set()
|
|
571
|
-
};
|
|
572
|
-
const linkedImpactsByEntry = /* @__PURE__ */ new Map();
|
|
573
|
-
if (forceAll) {
|
|
574
|
-
for (const [file] of entries) {
|
|
575
|
-
const type = classifyEntry(file, opts);
|
|
576
|
-
if (type === "html" || type === "js" || type === "css") {
|
|
577
|
-
processFiles[type].add(file);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
return {
|
|
581
|
-
files: processFiles,
|
|
582
|
-
linkedImpactsByEntry
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
const firstRun = previousLinkedByEntry.size === 0;
|
|
586
|
-
if (firstRun) {
|
|
587
|
-
for (const [file] of entries) {
|
|
588
|
-
const type = classifyEntry(file, opts);
|
|
589
|
-
if (type === "html" || type === "js" || type === "css") {
|
|
590
|
-
processFiles[type].add(file);
|
|
591
|
-
}
|
|
644
|
+
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
645
|
+
const runtimeAffectingChanged = previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash;
|
|
646
|
+
if (runtimeAffectingChanged) {
|
|
647
|
+
runtimeAffectingChangedByType[type].add(file);
|
|
592
648
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
for (const [file] of entries) {
|
|
599
|
-
if (classifyEntry(file, opts) === "html") {
|
|
649
|
+
if (forceAll || firstRun) {
|
|
650
|
+
markProcessFile(type, file, processFiles);
|
|
651
|
+
} else if (type === "html") {
|
|
600
652
|
processFiles.html.add(file);
|
|
653
|
+
} else if (changed && (type === "js" || type === "css")) {
|
|
654
|
+
processFiles[type].add(file);
|
|
601
655
|
}
|
|
656
|
+
collectJsEntries(file, output, outDir, jsEntries);
|
|
657
|
+
entries.push({
|
|
658
|
+
file,
|
|
659
|
+
output,
|
|
660
|
+
source,
|
|
661
|
+
type
|
|
662
|
+
});
|
|
602
663
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
for (const [entryFile, linkedFiles] of previousLinkedByEntry.entries()) {
|
|
611
|
-
if (linkedFiles.has(changedFile)) {
|
|
664
|
+
if (!forceAll && !firstRun) {
|
|
665
|
+
for (const changedFile of changedByType.js) {
|
|
666
|
+
const dependents = state.dependentsByLinkedFile.get(changedFile);
|
|
667
|
+
if (!dependents) {
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
for (const entryFile of dependents) {
|
|
612
671
|
processFiles.js.add(entryFile);
|
|
613
672
|
let impacts = linkedImpactsByEntry.get(entryFile);
|
|
614
673
|
if (!impacts) {
|
|
@@ -620,10 +679,87 @@ function buildProcessSets(entries, opts, changedByType, previousLinkedByEntry, f
|
|
|
620
679
|
}
|
|
621
680
|
}
|
|
622
681
|
return {
|
|
623
|
-
|
|
682
|
+
entries,
|
|
683
|
+
jsEntries,
|
|
684
|
+
sourceHashByFile,
|
|
685
|
+
runtimeAffectingHashByFile,
|
|
686
|
+
changedByType,
|
|
687
|
+
runtimeAffectingChangedByType,
|
|
688
|
+
processFiles,
|
|
624
689
|
linkedImpactsByEntry
|
|
625
690
|
};
|
|
626
691
|
}
|
|
692
|
+
function invertLinkedByEntry(linkedByEntry) {
|
|
693
|
+
const dependentsByLinkedFile = /* @__PURE__ */ new Map();
|
|
694
|
+
for (const [entryFile, linkedFiles] of linkedByEntry.entries()) {
|
|
695
|
+
for (const linkedFile of linkedFiles) {
|
|
696
|
+
let dependents = dependentsByLinkedFile.get(linkedFile);
|
|
697
|
+
if (!dependents) {
|
|
698
|
+
dependents = /* @__PURE__ */ new Set();
|
|
699
|
+
dependentsByLinkedFile.set(linkedFile, dependents);
|
|
700
|
+
}
|
|
701
|
+
dependents.add(entryFile);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return dependentsByLinkedFile;
|
|
705
|
+
}
|
|
706
|
+
function updateBundleBuildState(state, snapshot, linkedByEntry) {
|
|
707
|
+
state.iteration += 1;
|
|
708
|
+
state.sourceHashByFile = snapshot.sourceHashByFile;
|
|
709
|
+
state.runtimeAffectingHashByFile = snapshot.runtimeAffectingHashByFile;
|
|
710
|
+
state.linkedByEntry = linkedByEntry;
|
|
711
|
+
state.dependentsByLinkedFile = invertLinkedByEntry(linkedByEntry);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/bundlers/vite/js-precheck.ts
|
|
715
|
+
var FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
|
|
716
|
+
var DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
|
|
717
|
+
function shouldSkipViteJsTransform(rawSource, options) {
|
|
718
|
+
if (!rawSource) {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
if (_optionalChain([options, 'optionalAccess', _23 => _23.alwaysEscape])) {
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
if (_optionalChain([options, 'optionalAccess', _24 => _24.moduleSpecifierReplacements]) && Object.keys(options.moduleSpecifierReplacements).length > 0) {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
if (_optionalChain([options, 'optionalAccess', _25 => _25.wrapExpression])) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
if (DEPENDENCY_HINT_RE.test(rawSource)) {
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// src/bundlers/vite/generate-bundle.ts
|
|
737
|
+
function formatDebugFileList(files, limit = 8) {
|
|
738
|
+
if (files.size === 0) {
|
|
739
|
+
return "-";
|
|
740
|
+
}
|
|
741
|
+
const sorted = [...files].sort();
|
|
742
|
+
if (sorted.length <= limit) {
|
|
743
|
+
return sorted.join(",");
|
|
744
|
+
}
|
|
745
|
+
return `${sorted.slice(0, limit).join(",")},...(+${sorted.length - limit})`;
|
|
746
|
+
}
|
|
747
|
+
function createEmptyMetric() {
|
|
748
|
+
return {
|
|
749
|
+
total: 0,
|
|
750
|
+
transformed: 0,
|
|
751
|
+
cacheHits: 0,
|
|
752
|
+
elapsed: 0
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function createEmptyMetrics() {
|
|
756
|
+
return {
|
|
757
|
+
runtimeSet: 0,
|
|
758
|
+
html: createEmptyMetric(),
|
|
759
|
+
js: createEmptyMetric(),
|
|
760
|
+
css: createEmptyMetric()
|
|
761
|
+
};
|
|
762
|
+
}
|
|
627
763
|
function measureElapsed(start) {
|
|
628
764
|
return performance.now() - start;
|
|
629
765
|
}
|
|
@@ -678,17 +814,8 @@ function hasRuntimeAffectingSourceChanges(changedByType) {
|
|
|
678
814
|
return changedByType.html.size > 0 || changedByType.js.size > 0;
|
|
679
815
|
}
|
|
680
816
|
function createGenerateBundleHook(context) {
|
|
681
|
-
const state =
|
|
682
|
-
|
|
683
|
-
previousSourceHashByFile: /* @__PURE__ */ new Map(),
|
|
684
|
-
previousLinkedByEntry: /* @__PURE__ */ new Map(),
|
|
685
|
-
changedByType: {
|
|
686
|
-
html: /* @__PURE__ */ new Set(),
|
|
687
|
-
js: /* @__PURE__ */ new Set(),
|
|
688
|
-
css: /* @__PURE__ */ new Set(),
|
|
689
|
-
other: /* @__PURE__ */ new Set()
|
|
690
|
-
}
|
|
691
|
-
};
|
|
817
|
+
const state = createBundleBuildState();
|
|
818
|
+
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
692
819
|
return async function generateBundle(_opt, bundle) {
|
|
693
820
|
const {
|
|
694
821
|
opts,
|
|
@@ -709,6 +836,26 @@ function createGenerateBundleHook(context) {
|
|
|
709
836
|
jsHandler,
|
|
710
837
|
uniAppX
|
|
711
838
|
} = opts;
|
|
839
|
+
const getCssHandlerOptions = (file) => {
|
|
840
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
841
|
+
const isMainChunk = mainCssChunkMatcher(file, appType);
|
|
842
|
+
const cacheKey = `${_nullishCoalesce(majorVersion, () => ( "unknown"))}:${isMainChunk ? "1" : "0"}:${file}`;
|
|
843
|
+
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
844
|
+
if (cached) {
|
|
845
|
+
return cached;
|
|
846
|
+
}
|
|
847
|
+
const created = {
|
|
848
|
+
isMainChunk,
|
|
849
|
+
postcssOptions: {
|
|
850
|
+
options: {
|
|
851
|
+
from: file
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
majorVersion
|
|
855
|
+
};
|
|
856
|
+
cssHandlerOptionsCache.set(cacheKey, created);
|
|
857
|
+
return created;
|
|
858
|
+
};
|
|
712
859
|
await runtimeState.patchPromise;
|
|
713
860
|
debug2("start");
|
|
714
861
|
onStart();
|
|
@@ -717,23 +864,24 @@ function createGenerateBundleHook(context) {
|
|
|
717
864
|
const disableDirtyOptimization = _process2.default.env.WEAPP_TW_VITE_DISABLE_DIRTY === "1";
|
|
718
865
|
const disableJsPrecheck = _process2.default.env.WEAPP_TW_VITE_DISABLE_JS_PRECHECK === "1";
|
|
719
866
|
const debugCssDiff = _process2.default.env.WEAPP_TW_VITE_DEBUG_CSS_DIFF === "1";
|
|
720
|
-
const
|
|
721
|
-
const
|
|
722
|
-
const
|
|
867
|
+
const resolvedConfig = getResolvedConfig();
|
|
868
|
+
const rootDir = _optionalChain([resolvedConfig, 'optionalAccess', _26 => _26.root]) ? _path2.default.resolve(resolvedConfig.root) : _process2.default.cwd();
|
|
869
|
+
const outDir = _optionalChain([resolvedConfig, 'optionalAccess', _27 => _27.build, 'optionalAccess', _28 => _28.outDir]) ? _path2.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
870
|
+
const snapshot = buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization);
|
|
871
|
+
const forceRuntimeRefreshBySource = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
723
872
|
const forceRuntimeRefresh = forceRuntimeRefreshByEnv || forceRuntimeRefreshBySource;
|
|
724
|
-
const
|
|
725
|
-
const processFiles = processSets.files;
|
|
873
|
+
const processFiles = snapshot.processFiles;
|
|
726
874
|
debug2(
|
|
727
875
|
"dirty iteration=%d html=%d[%s] js=%d[%s] css=%d[%s] other=%d[%s]",
|
|
728
876
|
state.iteration + 1,
|
|
729
|
-
|
|
730
|
-
formatDebugFileList(
|
|
731
|
-
|
|
732
|
-
formatDebugFileList(
|
|
733
|
-
|
|
734
|
-
formatDebugFileList(
|
|
735
|
-
|
|
736
|
-
formatDebugFileList(
|
|
877
|
+
snapshot.changedByType.html.size,
|
|
878
|
+
formatDebugFileList(snapshot.changedByType.html),
|
|
879
|
+
snapshot.changedByType.js.size,
|
|
880
|
+
formatDebugFileList(snapshot.changedByType.js),
|
|
881
|
+
snapshot.changedByType.css.size,
|
|
882
|
+
formatDebugFileList(snapshot.changedByType.css),
|
|
883
|
+
snapshot.changedByType.other.size,
|
|
884
|
+
formatDebugFileList(snapshot.changedByType.other)
|
|
737
885
|
);
|
|
738
886
|
debug2(
|
|
739
887
|
"process iteration=%d html=%d[%s] js=%d[%s] css=%d[%s]",
|
|
@@ -745,30 +893,23 @@ function createGenerateBundleHook(context) {
|
|
|
745
893
|
processFiles.css.size,
|
|
746
894
|
formatDebugFileList(processFiles.css)
|
|
747
895
|
);
|
|
748
|
-
const
|
|
749
|
-
const rootDir = _optionalChain([resolvedConfig, 'optionalAccess', _25 => _25.root]) ? _path2.default.resolve(resolvedConfig.root) : _process2.default.cwd();
|
|
750
|
-
const outDir = _optionalChain([resolvedConfig, 'optionalAccess', _26 => _26.build, 'optionalAccess', _27 => _27.outDir]) ? _path2.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
751
|
-
const jsEntries = /* @__PURE__ */ new Map();
|
|
752
|
-
for (const [fileName, output] of entries) {
|
|
753
|
-
const entry = { fileName, output };
|
|
754
|
-
if (isJavaScriptEntry(entry)) {
|
|
755
|
-
const absolute = toJsAbsoluteFilename(fileName, outDir);
|
|
756
|
-
jsEntries.set(absolute, entry);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
896
|
+
const jsEntries = snapshot.jsEntries;
|
|
759
897
|
const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
|
|
760
898
|
const runtimeStart = performance.now();
|
|
761
899
|
const runtime = await ensureRuntimeClassSet(forceRuntimeRefresh);
|
|
900
|
+
const defaultTemplateHandlerOptions = {
|
|
901
|
+
runtimeSet: runtime
|
|
902
|
+
};
|
|
762
903
|
metrics.runtimeSet = measureElapsed(runtimeStart);
|
|
763
904
|
if (forceRuntimeRefreshBySource) {
|
|
764
905
|
debug2(
|
|
765
906
|
"runtimeSet forced refresh due to source changes: html=%d js=%d",
|
|
766
|
-
|
|
767
|
-
|
|
907
|
+
snapshot.runtimeAffectingChangedByType.html.size,
|
|
908
|
+
snapshot.runtimeAffectingChangedByType.js.size
|
|
768
909
|
);
|
|
769
910
|
}
|
|
770
911
|
debug2("get runtimeSet, class count: %d", runtime.size);
|
|
771
|
-
const runtimeSignature = _nullishCoalesce(
|
|
912
|
+
const runtimeSignature = _nullishCoalesce(_chunkI4EOMKX2js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher), () => ( "runtime:missing"));
|
|
772
913
|
const handleLinkedUpdate = (fileName, previous, next) => {
|
|
773
914
|
onUpdate(fileName, previous, next);
|
|
774
915
|
debug2("js linked handle: %s", fileName);
|
|
@@ -792,21 +933,21 @@ function createGenerateBundleHook(context) {
|
|
|
792
933
|
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
793
934
|
moduleGraph: moduleGraphOptions,
|
|
794
935
|
babelParserOptions: {
|
|
795
|
-
..._nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
936
|
+
..._nullishCoalesce(_optionalChain([extra, 'optionalAccess', _29 => _29.babelParserOptions]), () => ( {})),
|
|
796
937
|
sourceFilename: absoluteFilename
|
|
797
938
|
}
|
|
798
939
|
});
|
|
799
940
|
const linkedByEntry = /* @__PURE__ */ new Map();
|
|
800
941
|
const tasks = [];
|
|
801
942
|
const jsTaskFactories = [];
|
|
802
|
-
for (const
|
|
803
|
-
const type =
|
|
943
|
+
for (const entry of snapshot.entries) {
|
|
944
|
+
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
804
945
|
if (type === "html" && originalSource.type === "asset") {
|
|
805
946
|
metrics.html.total++;
|
|
806
947
|
if (!processFiles.html.has(file)) {
|
|
807
948
|
continue;
|
|
808
949
|
}
|
|
809
|
-
const rawSource =
|
|
950
|
+
const rawSource = originalEntrySource;
|
|
810
951
|
tasks.push(
|
|
811
952
|
_chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
812
953
|
cache,
|
|
@@ -822,9 +963,7 @@ function createGenerateBundleHook(context) {
|
|
|
822
963
|
},
|
|
823
964
|
async transform() {
|
|
824
965
|
const start = performance.now();
|
|
825
|
-
const transformed = await templateHandler(rawSource,
|
|
826
|
-
runtimeSet: runtime
|
|
827
|
-
});
|
|
966
|
+
const transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
828
967
|
metrics.html.elapsed += measureElapsed(start);
|
|
829
968
|
metrics.html.transformed++;
|
|
830
969
|
onUpdate(file, rawSource, transformed);
|
|
@@ -839,7 +978,7 @@ function createGenerateBundleHook(context) {
|
|
|
839
978
|
}
|
|
840
979
|
if (type === "css" && originalSource.type === "asset") {
|
|
841
980
|
metrics.css.total++;
|
|
842
|
-
const rawSource =
|
|
981
|
+
const rawSource = originalEntrySource;
|
|
843
982
|
tasks.push(
|
|
844
983
|
_chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
845
984
|
cache,
|
|
@@ -856,15 +995,7 @@ function createGenerateBundleHook(context) {
|
|
|
856
995
|
async transform() {
|
|
857
996
|
const start = performance.now();
|
|
858
997
|
await runtimeState.patchPromise;
|
|
859
|
-
const { css } = await styleHandler(rawSource,
|
|
860
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType),
|
|
861
|
-
postcssOptions: {
|
|
862
|
-
options: {
|
|
863
|
-
from: file
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
majorVersion: runtimeState.twPatcher.majorVersion
|
|
867
|
-
});
|
|
998
|
+
const { css } = await styleHandler(rawSource, getCssHandlerOptions(file));
|
|
868
999
|
if (debugCssDiff) {
|
|
869
1000
|
debug2("css diff %s: %s", file, summarizeStringDiff(rawSource, css));
|
|
870
1001
|
}
|
|
@@ -889,15 +1020,15 @@ function createGenerateBundleHook(context) {
|
|
|
889
1020
|
debug2("js skip transform (clean), replay cache: %s", file);
|
|
890
1021
|
}
|
|
891
1022
|
if (originalSource.type === "chunk") {
|
|
892
|
-
const absoluteFile =
|
|
893
|
-
const initialRawSource =
|
|
1023
|
+
const absoluteFile = _path2.default.resolve(outDir, file);
|
|
1024
|
+
const initialRawSource = originalEntrySource;
|
|
894
1025
|
const linkedSet = /* @__PURE__ */ new Set();
|
|
895
1026
|
linkedByEntry.set(file, linkedSet);
|
|
896
1027
|
jsTaskFactories.push(async () => {
|
|
897
1028
|
const linkedImpactSignature = createLinkedImpactSignature(
|
|
898
1029
|
file,
|
|
899
|
-
|
|
900
|
-
|
|
1030
|
+
snapshot.linkedImpactsByEntry,
|
|
1031
|
+
snapshot.sourceHashByFile
|
|
901
1032
|
);
|
|
902
1033
|
const hashSalt = createJsHashSalt(runtimeSignature, linkedImpactSignature);
|
|
903
1034
|
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
@@ -973,8 +1104,8 @@ function createGenerateBundleHook(context) {
|
|
|
973
1104
|
runtimeSignature,
|
|
974
1105
|
createLinkedImpactSignature(
|
|
975
1106
|
file,
|
|
976
|
-
|
|
977
|
-
|
|
1107
|
+
snapshot.linkedImpactsByEntry,
|
|
1108
|
+
snapshot.sourceHashByFile
|
|
978
1109
|
)
|
|
979
1110
|
),
|
|
980
1111
|
createHandlerOptions,
|
|
@@ -995,8 +1126,8 @@ function createGenerateBundleHook(context) {
|
|
|
995
1126
|
metrics.js.transformed++;
|
|
996
1127
|
return;
|
|
997
1128
|
}
|
|
998
|
-
const currentSource =
|
|
999
|
-
const absoluteFile =
|
|
1129
|
+
const currentSource = originalEntrySource;
|
|
1130
|
+
const absoluteFile = _path2.default.resolve(outDir, file);
|
|
1000
1131
|
const precheckOptions = createHandlerOptions(absoluteFile, {
|
|
1001
1132
|
uniAppX: _nullishCoalesce(uniAppX, () => ( true)),
|
|
1002
1133
|
babelParserOptions: {
|
|
@@ -1015,25 +1146,12 @@ function createGenerateBundleHook(context) {
|
|
|
1015
1146
|
});
|
|
1016
1147
|
}
|
|
1017
1148
|
}
|
|
1018
|
-
|
|
1149
|
+
_chunkG3G437UEjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
1019
1150
|
await Promise.all(tasks);
|
|
1020
1151
|
for (const apply of pendingLinkedUpdates) {
|
|
1021
1152
|
apply();
|
|
1022
1153
|
}
|
|
1023
|
-
state
|
|
1024
|
-
state.previousSourceHashByFile = dirtyEntries.sourceHashByFile;
|
|
1025
|
-
state.changedByType = dirtyEntries.changedByType;
|
|
1026
|
-
const nextLinkedByEntry = new Map(state.previousLinkedByEntry);
|
|
1027
|
-
for (const [entryFile, linkedFiles] of linkedByEntry.entries()) {
|
|
1028
|
-
nextLinkedByEntry.set(entryFile, linkedFiles);
|
|
1029
|
-
}
|
|
1030
|
-
for (const entryFile of [...nextLinkedByEntry.keys()]) {
|
|
1031
|
-
const exists = entries.some(([fileName]) => fileName === entryFile);
|
|
1032
|
-
if (!exists) {
|
|
1033
|
-
nextLinkedByEntry.delete(entryFile);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
state.previousLinkedByEntry = nextLinkedByEntry;
|
|
1154
|
+
updateBundleBuildState(state, snapshot, linkedByEntry);
|
|
1037
1155
|
debug2(
|
|
1038
1156
|
"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)",
|
|
1039
1157
|
state.iteration,
|
|
@@ -1080,12 +1198,12 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1080
1198
|
const { appType, weappTailwindcssDirPosix: weappTailwindcssDirPosix2 } = options;
|
|
1081
1199
|
return [
|
|
1082
1200
|
{
|
|
1083
|
-
name: `${
|
|
1201
|
+
name: `${_chunkI4EOMKX2js.vitePluginName}:rewrite-css-imports`,
|
|
1084
1202
|
enforce: "pre",
|
|
1085
1203
|
resolveId: {
|
|
1086
1204
|
order: "pre",
|
|
1087
1205
|
handler(id, importer) {
|
|
1088
|
-
const replacement =
|
|
1206
|
+
const replacement = _chunkG3G437UEjs.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix2, {
|
|
1089
1207
|
join: joinPosixPath,
|
|
1090
1208
|
appType
|
|
1091
1209
|
});
|
|
@@ -1104,7 +1222,7 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1104
1222
|
if (!isCSSRequest(id)) {
|
|
1105
1223
|
return null;
|
|
1106
1224
|
}
|
|
1107
|
-
const rewritten =
|
|
1225
|
+
const rewritten = _chunkG3G437UEjs.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix2, {
|
|
1108
1226
|
join: joinPosixPath,
|
|
1109
1227
|
appType
|
|
1110
1228
|
});
|
|
@@ -1122,13 +1240,13 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
1122
1240
|
}
|
|
1123
1241
|
|
|
1124
1242
|
// src/bundlers/vite/index.ts
|
|
1125
|
-
var debug =
|
|
1126
|
-
var weappTailwindcssPackageDir =
|
|
1243
|
+
var debug = _chunkI4EOMKX2js.createDebug.call(void 0, );
|
|
1244
|
+
var weappTailwindcssPackageDir = _chunkG3G437UEjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
1127
1245
|
var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
1128
1246
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
1129
|
-
const rewriteCssImportsSpecified = Object.
|
|
1247
|
+
const rewriteCssImportsSpecified = Object.hasOwn(options, "rewriteCssImports");
|
|
1130
1248
|
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
1131
|
-
const opts =
|
|
1249
|
+
const opts = _chunkI4EOMKX2js.getCompilerContext.call(void 0, options);
|
|
1132
1250
|
const {
|
|
1133
1251
|
disabled,
|
|
1134
1252
|
customAttributes,
|
|
@@ -1142,7 +1260,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1142
1260
|
uniAppX,
|
|
1143
1261
|
disabledDefaultTemplateHandler
|
|
1144
1262
|
} = opts;
|
|
1145
|
-
const disabledOptions =
|
|
1263
|
+
const disabledOptions = _chunkG3G437UEjs.resolveDisabledOptions.call(void 0, disabled);
|
|
1146
1264
|
const tailwindcssMajorVersion = _nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0));
|
|
1147
1265
|
const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
|
|
1148
1266
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
@@ -1153,8 +1271,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1153
1271
|
if (disabledOptions.plugin) {
|
|
1154
1272
|
return rewritePlugins.length ? rewritePlugins : void 0;
|
|
1155
1273
|
}
|
|
1156
|
-
const customAttributesEntities =
|
|
1157
|
-
const patchRecorderState =
|
|
1274
|
+
const customAttributesEntities = _chunkI4EOMKX2js.toCustomAttributesEntities.call(void 0, customAttributes);
|
|
1275
|
+
const patchRecorderState = _chunkPXZUQ7RRjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
1158
1276
|
source: "runtime",
|
|
1159
1277
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
1160
1278
|
});
|
|
@@ -1170,8 +1288,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1170
1288
|
let runtimeRefreshSignature;
|
|
1171
1289
|
let runtimeRefreshOptionsKey;
|
|
1172
1290
|
function resolveRuntimeRefreshOptions() {
|
|
1173
|
-
const configPath = _optionalChain([runtimeState, 'access',
|
|
1174
|
-
const signature =
|
|
1291
|
+
const configPath = _optionalChain([runtimeState, 'access', _30 => _30.twPatcher, 'access', _31 => _31.options, 'optionalAccess', _32 => _32.tailwind, 'optionalAccess', _33 => _33.config]);
|
|
1292
|
+
const signature = _chunkI4EOMKX2js.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
|
|
1175
1293
|
const optionsKey = JSON.stringify({
|
|
1176
1294
|
appType,
|
|
1177
1295
|
uniAppX: Boolean(uniAppX),
|
|
@@ -1192,7 +1310,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1192
1310
|
async function refreshRuntimeState(force) {
|
|
1193
1311
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
1194
1312
|
const shouldRefresh = force || invalidation.changed;
|
|
1195
|
-
const refreshed = await
|
|
1313
|
+
const refreshed = await _chunkI4EOMKX2js.refreshTailwindRuntimeState.call(void 0, runtimeState, {
|
|
1196
1314
|
force: shouldRefresh,
|
|
1197
1315
|
clearCache: force || invalidation.changed
|
|
1198
1316
|
});
|
|
@@ -1213,7 +1331,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1213
1331
|
}
|
|
1214
1332
|
if (forceRuntimeRefresh || !runtimeSetPromise) {
|
|
1215
1333
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
1216
|
-
const task2 =
|
|
1334
|
+
const task2 = _chunkI4EOMKX2js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
|
|
1217
1335
|
force: forceRuntimeRefresh || invalidation.changed,
|
|
1218
1336
|
skipRefresh: forceRuntimeRefresh,
|
|
1219
1337
|
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
@@ -1249,7 +1367,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1249
1367
|
const plugins = [
|
|
1250
1368
|
...rewritePlugins,
|
|
1251
1369
|
{
|
|
1252
|
-
name: `${
|
|
1370
|
+
name: `${_chunkI4EOMKX2js.vitePluginName}:post`,
|
|
1253
1371
|
enforce: "post",
|
|
1254
1372
|
async configResolved(config) {
|
|
1255
1373
|
resolvedConfig = config;
|
|
@@ -1261,12 +1379,13 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
1261
1379
|
await refreshRuntimeState(true);
|
|
1262
1380
|
}
|
|
1263
1381
|
if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
|
|
1264
|
-
const
|
|
1382
|
+
const postcssPlugins = config.css.postcss.plugins;
|
|
1383
|
+
const idx = postcssPlugins.findIndex((x) => (
|
|
1265
1384
|
// @ts-ignore
|
|
1266
1385
|
x.postcssPlugin === "postcss-html-transform"
|
|
1267
1386
|
));
|
|
1268
1387
|
if (idx > -1) {
|
|
1269
|
-
|
|
1388
|
+
postcssPlugins.splice(idx, 1, _htmltransform2.default.call(void 0, ));
|
|
1270
1389
|
debug("remove postcss-html-transform plugin from vite config");
|
|
1271
1390
|
}
|
|
1272
1391
|
}
|