weapp-tailwindcss 4.4.0 → 4.5.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-34T2BFTJ.mjs +59 -0
- package/dist/{chunk-D25XJJMP.mjs → chunk-3KKB4FSY.mjs} +341 -10
- package/dist/{chunk-D2AKCBDU.mjs → chunk-6L7B4COX.mjs} +75 -2
- package/dist/{chunk-QXCC745G.js → chunk-AMP5MSHS.js} +99 -28
- package/dist/{chunk-GQAB52GE.js → chunk-BMXULECQ.js} +344 -13
- package/dist/{chunk-FBGUUXQV.mjs → chunk-FWIGQ4RY.mjs} +1 -1
- package/dist/{chunk-NDHL3P32.mjs → chunk-JLKUUNWL.mjs} +156 -55
- package/dist/{chunk-RBRSMHFS.js → chunk-NHB7NFQC.js} +1 -1
- package/dist/{chunk-VN2BU7ON.js → chunk-RELKXSH6.js} +160 -59
- package/dist/{chunk-L3HOZDIV.mjs → chunk-RWW76EBW.mjs} +98 -27
- package/dist/chunk-V4SEPP3F.js +195 -0
- package/dist/chunk-WVKK6TBL.js +59 -0
- package/dist/cli.js +3 -3
- package/dist/cli.mjs +2 -2
- package/dist/core.js +3 -3
- package/dist/core.mjs +2 -2
- 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/escape.js +1 -1
- package/dist/escape.mjs +1 -1
- package/dist/gulp.js +4 -4
- package/dist/gulp.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -6
- package/dist/index.mjs +6 -5
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/types.d.mts +48 -2
- package/dist/types.d.ts +48 -2
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +5 -4
- package/dist/vite.mjs +4 -3
- package/dist/webpack.js +5 -4
- package/dist/webpack.mjs +4 -3
- package/dist/webpack4.js +99 -29
- package/dist/webpack4.mjs +97 -27
- package/package.json +5 -5
- package/dist/chunk-H2Y5VNOJ.js +0 -122
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/bundlers/shared/module-graph.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
var QUERY_HASH_RE = /[?#].*$/u;
|
|
4
|
+
var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
5
|
+
var VIRTUAL_PREFIX = "\0";
|
|
6
|
+
var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
|
|
7
|
+
function stripQueryAndHash(specifier) {
|
|
8
|
+
return specifier.replace(QUERY_HASH_RE, "");
|
|
9
|
+
}
|
|
10
|
+
function isResolvableSpecifier(specifier) {
|
|
11
|
+
if (!specifier) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const normalized = stripQueryAndHash(specifier);
|
|
15
|
+
if (normalized.startsWith(VIRTUAL_PREFIX)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return !PROTOCOL_RE.test(normalized);
|
|
19
|
+
}
|
|
20
|
+
function toAbsoluteOutputPath(fileName, outDir) {
|
|
21
|
+
if (path.isAbsolute(fileName)) {
|
|
22
|
+
return fileName;
|
|
23
|
+
}
|
|
24
|
+
return path.resolve(outDir, fileName);
|
|
25
|
+
}
|
|
26
|
+
function matchWithExtensions(candidate, hasOutput) {
|
|
27
|
+
if (hasOutput(candidate)) {
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
if (!path.extname(candidate)) {
|
|
31
|
+
for (const ext of JS_EXTENSIONS) {
|
|
32
|
+
const extended = `${candidate}${ext}`;
|
|
33
|
+
if (hasOutput(extended)) {
|
|
34
|
+
return extended;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
41
|
+
if (!isResolvableSpecifier(specifier)) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
const normalized = stripQueryAndHash(specifier);
|
|
45
|
+
let candidate;
|
|
46
|
+
if (path.isAbsolute(normalized)) {
|
|
47
|
+
candidate = normalized;
|
|
48
|
+
} else if (normalized.startsWith("/")) {
|
|
49
|
+
candidate = path.resolve(outDir, normalized.slice(1));
|
|
50
|
+
} else {
|
|
51
|
+
candidate = path.resolve(path.dirname(importer), normalized);
|
|
52
|
+
}
|
|
53
|
+
return matchWithExtensions(candidate, hasOutput);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
toAbsoluteOutputPath,
|
|
58
|
+
resolveOutputSpecifier
|
|
59
|
+
};
|
|
@@ -10,17 +10,14 @@ import {
|
|
|
10
10
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
11
11
|
|
|
12
12
|
// src/context/index.ts
|
|
13
|
-
import { logger as
|
|
13
|
+
import { logger as logger3, pc } from "@weapp-tailwindcss/logger";
|
|
14
14
|
import { useMangleStore } from "@weapp-tailwindcss/mangle";
|
|
15
15
|
|
|
16
16
|
// src/cache/index.ts
|
|
17
17
|
import { LRUCache } from "lru-cache";
|
|
18
18
|
|
|
19
19
|
// src/cache/md5.ts
|
|
20
|
-
import
|
|
21
|
-
function md5Hash(data) {
|
|
22
|
-
return crypto.createHash("md5").update(data).digest("hex");
|
|
23
|
-
}
|
|
20
|
+
import { md5 } from "@weapp-tailwindcss/shared/node";
|
|
24
21
|
|
|
25
22
|
// src/cache/index.ts
|
|
26
23
|
function isProcessResult(value) {
|
|
@@ -54,7 +51,7 @@ function createCache(options) {
|
|
|
54
51
|
return instance.set(key, value);
|
|
55
52
|
},
|
|
56
53
|
computeHash(message) {
|
|
57
|
-
return
|
|
54
|
+
return md5(message);
|
|
58
55
|
},
|
|
59
56
|
calcHashValueChanged(key, hash) {
|
|
60
57
|
const hit = hashMap.get(key);
|
|
@@ -395,6 +392,274 @@ var JsTokenUpdater = class {
|
|
|
395
392
|
}
|
|
396
393
|
};
|
|
397
394
|
|
|
395
|
+
// src/js/ModuleGraph.ts
|
|
396
|
+
var JsModuleGraph = class {
|
|
397
|
+
constructor(entry, graphOptions) {
|
|
398
|
+
this.modules = /* @__PURE__ */ new Map();
|
|
399
|
+
this.queue = [];
|
|
400
|
+
this.ignoredExportNames = /* @__PURE__ */ new Map();
|
|
401
|
+
this.resolve = graphOptions.resolve;
|
|
402
|
+
this.load = graphOptions.load;
|
|
403
|
+
this.filter = graphOptions.filter;
|
|
404
|
+
this.maxDepth = graphOptions.maxDepth ?? Number.POSITIVE_INFINITY;
|
|
405
|
+
const { moduleGraph: _moduleGraph, filename: _ignoredFilename, ...rest } = entry.handlerOptions;
|
|
406
|
+
this.baseOptions = {
|
|
407
|
+
...rest,
|
|
408
|
+
filename: entry.filename
|
|
409
|
+
};
|
|
410
|
+
this.parserOptions = entry.handlerOptions.babelParserOptions;
|
|
411
|
+
this.rootFilename = entry.filename;
|
|
412
|
+
this.modules.set(entry.filename, {
|
|
413
|
+
filename: entry.filename,
|
|
414
|
+
source: entry.source,
|
|
415
|
+
analysis: entry.analysis
|
|
416
|
+
});
|
|
417
|
+
this.queue.push({ filename: entry.filename, depth: 0 });
|
|
418
|
+
}
|
|
419
|
+
build() {
|
|
420
|
+
this.collectDependencies();
|
|
421
|
+
const linked = {};
|
|
422
|
+
for (const [filename, state] of this.modules) {
|
|
423
|
+
if (filename === this.rootFilename) {
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const childOptions = {
|
|
427
|
+
...this.baseOptions,
|
|
428
|
+
filename
|
|
429
|
+
};
|
|
430
|
+
const ms = processUpdatedSource(state.source, childOptions, state.analysis);
|
|
431
|
+
const code = ms.toString();
|
|
432
|
+
if (code !== state.source) {
|
|
433
|
+
linked[filename] = { code };
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return linked;
|
|
437
|
+
}
|
|
438
|
+
addIgnoredExport(filename, exportName) {
|
|
439
|
+
if (!exportName) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
let pending = this.ignoredExportNames.get(filename);
|
|
443
|
+
if (!pending) {
|
|
444
|
+
pending = /* @__PURE__ */ new Set();
|
|
445
|
+
this.ignoredExportNames.set(filename, pending);
|
|
446
|
+
}
|
|
447
|
+
if (pending.has(exportName)) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
pending.add(exportName);
|
|
451
|
+
const existing = this.modules.get(filename);
|
|
452
|
+
if (existing) {
|
|
453
|
+
this.applyIgnoredExportsToAnalysis(filename, existing.analysis);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
registerIgnoredExportsFromTokens(resolved, tokens) {
|
|
457
|
+
for (const token of tokens) {
|
|
458
|
+
if (token.type === "ImportSpecifier") {
|
|
459
|
+
this.addIgnoredExport(resolved, token.imported);
|
|
460
|
+
} else if (token.type === "ImportDefaultSpecifier") {
|
|
461
|
+
this.addIgnoredExport(resolved, "default");
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
applyIgnoredExportsToAnalysis(filename, analysis) {
|
|
466
|
+
const pending = this.ignoredExportNames.get(filename);
|
|
467
|
+
if (!pending || pending.size === 0) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const names = new Set(pending);
|
|
471
|
+
pending.clear();
|
|
472
|
+
const propagate = [];
|
|
473
|
+
for (const exportPath of analysis.exportDeclarations) {
|
|
474
|
+
if (names.size === 0) {
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
if (exportPath.isExportDefaultDeclaration()) {
|
|
478
|
+
if (names.has("default")) {
|
|
479
|
+
analysis.walker.walkExportDefaultDeclaration(exportPath);
|
|
480
|
+
names.delete("default");
|
|
481
|
+
}
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if (exportPath.isExportNamedDeclaration()) {
|
|
485
|
+
const source = exportPath.node.source?.value;
|
|
486
|
+
if (typeof source === "string") {
|
|
487
|
+
for (const spec of exportPath.get("specifiers")) {
|
|
488
|
+
if (!spec.isExportSpecifier()) {
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const exported = spec.get("exported");
|
|
492
|
+
let exportedName;
|
|
493
|
+
if (exported.isIdentifier()) {
|
|
494
|
+
exportedName = exported.node.name;
|
|
495
|
+
} else if (exported.isStringLiteral()) {
|
|
496
|
+
exportedName = exported.node.value;
|
|
497
|
+
}
|
|
498
|
+
if (!exportedName || !names.has(exportedName)) {
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
const local = spec.get("local");
|
|
502
|
+
if (local.isIdentifier()) {
|
|
503
|
+
propagate.push({
|
|
504
|
+
specifier: source,
|
|
505
|
+
exportName: local.node.name
|
|
506
|
+
});
|
|
507
|
+
names.delete(exportedName);
|
|
508
|
+
} else if (local.isStringLiteral()) {
|
|
509
|
+
propagate.push({
|
|
510
|
+
specifier: source,
|
|
511
|
+
exportName: local.node.value
|
|
512
|
+
});
|
|
513
|
+
names.delete(exportedName);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
const declaration = exportPath.get("declaration");
|
|
519
|
+
if (declaration.isVariableDeclaration()) {
|
|
520
|
+
for (const decl of declaration.get("declarations")) {
|
|
521
|
+
const id = decl.get("id");
|
|
522
|
+
if (id.isIdentifier()) {
|
|
523
|
+
const exportName = id.node.name;
|
|
524
|
+
if (names.has(exportName)) {
|
|
525
|
+
analysis.walker.walkVariableDeclarator(decl);
|
|
526
|
+
names.delete(exportName);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
for (const spec of exportPath.get("specifiers")) {
|
|
532
|
+
if (!spec.isExportSpecifier()) {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const exported = spec.get("exported");
|
|
536
|
+
let exportedName;
|
|
537
|
+
if (exported.isIdentifier()) {
|
|
538
|
+
exportedName = exported.node.name;
|
|
539
|
+
} else if (exported.isStringLiteral()) {
|
|
540
|
+
exportedName = exported.node.value;
|
|
541
|
+
}
|
|
542
|
+
if (!exportedName || !names.has(exportedName)) {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
const local = spec.get("local");
|
|
546
|
+
analysis.walker.walkNode(local);
|
|
547
|
+
names.delete(exportedName);
|
|
548
|
+
}
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
if (exportPath.isExportAllDeclaration()) {
|
|
552
|
+
const source = exportPath.node.source?.value;
|
|
553
|
+
if (typeof source === "string") {
|
|
554
|
+
for (const exportName of names) {
|
|
555
|
+
propagate.push({
|
|
556
|
+
specifier: source,
|
|
557
|
+
exportName
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
names.clear();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
for (const { specifier, exportName } of propagate) {
|
|
565
|
+
let resolved;
|
|
566
|
+
try {
|
|
567
|
+
resolved = this.resolve(specifier, filename);
|
|
568
|
+
} catch {
|
|
569
|
+
resolved = void 0;
|
|
570
|
+
}
|
|
571
|
+
if (!resolved) {
|
|
572
|
+
pending.add(exportName);
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (this.filter && !this.filter(resolved, specifier, filename)) {
|
|
576
|
+
pending.add(exportName);
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
this.addIgnoredExport(resolved, exportName);
|
|
580
|
+
}
|
|
581
|
+
for (const name of names) {
|
|
582
|
+
pending.add(name);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
collectDependencies() {
|
|
586
|
+
while (this.queue.length > 0) {
|
|
587
|
+
const { filename, depth } = this.queue.shift();
|
|
588
|
+
if (depth >= this.maxDepth) {
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
const state = this.modules.get(filename);
|
|
592
|
+
if (!state) {
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
const dependencySpecifiers = /* @__PURE__ */ new Map();
|
|
596
|
+
for (const token of state.analysis.walker.imports) {
|
|
597
|
+
if (!dependencySpecifiers.has(token.source)) {
|
|
598
|
+
dependencySpecifiers.set(token.source, []);
|
|
599
|
+
}
|
|
600
|
+
dependencySpecifiers.get(token.source).push(token);
|
|
601
|
+
}
|
|
602
|
+
for (const exportPath of state.analysis.exportDeclarations) {
|
|
603
|
+
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
604
|
+
const source = exportPath.node.source?.value;
|
|
605
|
+
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
606
|
+
dependencySpecifiers.set(source, []);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
for (const [specifier, tokens] of dependencySpecifiers) {
|
|
611
|
+
let resolved;
|
|
612
|
+
try {
|
|
613
|
+
resolved = this.resolve(specifier, filename);
|
|
614
|
+
} catch {
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
if (!resolved) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (this.filter && !this.filter(resolved, specifier, filename)) {
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (tokens.length > 0) {
|
|
624
|
+
this.registerIgnoredExportsFromTokens(resolved, tokens);
|
|
625
|
+
}
|
|
626
|
+
if (this.modules.has(resolved)) {
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
let source;
|
|
630
|
+
try {
|
|
631
|
+
source = this.load(resolved);
|
|
632
|
+
} catch {
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (typeof source !== "string") {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
let analysis;
|
|
639
|
+
try {
|
|
640
|
+
const ast = babelParse(source, {
|
|
641
|
+
...this.parserOptions,
|
|
642
|
+
sourceFilename: resolved
|
|
643
|
+
});
|
|
644
|
+
analysis = analyzeSource(ast, {
|
|
645
|
+
...this.baseOptions,
|
|
646
|
+
filename: resolved
|
|
647
|
+
});
|
|
648
|
+
this.applyIgnoredExportsToAnalysis(resolved, analysis);
|
|
649
|
+
} catch {
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
this.modules.set(resolved, {
|
|
653
|
+
filename: resolved,
|
|
654
|
+
source,
|
|
655
|
+
analysis
|
|
656
|
+
});
|
|
657
|
+
this.queue.push({ filename: resolved, depth: depth + 1 });
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
398
663
|
// src/js/NodePathWalker.ts
|
|
399
664
|
var NodePathWalker = class {
|
|
400
665
|
constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
|
|
@@ -494,6 +759,7 @@ var NodePathWalker = class {
|
|
|
494
759
|
declaration: importDeclaration,
|
|
495
760
|
specifier: arg,
|
|
496
761
|
imported: imported.node.name,
|
|
762
|
+
local: arg.node.local.name,
|
|
497
763
|
source: importDeclaration.node.source.value,
|
|
498
764
|
type: "ImportSpecifier"
|
|
499
765
|
}
|
|
@@ -504,6 +770,7 @@ var NodePathWalker = class {
|
|
|
504
770
|
{
|
|
505
771
|
declaration: importDeclaration,
|
|
506
772
|
specifier: arg,
|
|
773
|
+
local: arg.node.local.name,
|
|
507
774
|
source: importDeclaration.node.source.value,
|
|
508
775
|
type: "ImportDefaultSpecifier"
|
|
509
776
|
}
|
|
@@ -555,6 +822,8 @@ var NodePathWalker = class {
|
|
|
555
822
|
const decl = path2.get("declaration");
|
|
556
823
|
if (decl.isIdentifier()) {
|
|
557
824
|
this.walkNode(decl);
|
|
825
|
+
} else {
|
|
826
|
+
this.walkNode(decl);
|
|
558
827
|
}
|
|
559
828
|
}
|
|
560
829
|
walkExportAllDeclaration(path2) {
|
|
@@ -782,12 +1051,28 @@ function jsHandler(rawSource, options) {
|
|
|
782
1051
|
}
|
|
783
1052
|
const analysis = analyzeSource(ast, options);
|
|
784
1053
|
const ms = processUpdatedSource(rawSource, options, analysis);
|
|
785
|
-
|
|
1054
|
+
const result = {
|
|
786
1055
|
code: ms.toString(),
|
|
787
1056
|
get map() {
|
|
788
1057
|
return ms.generateMap();
|
|
789
1058
|
}
|
|
790
1059
|
};
|
|
1060
|
+
if (options.moduleGraph && options.filename) {
|
|
1061
|
+
const graph = new JsModuleGraph(
|
|
1062
|
+
{
|
|
1063
|
+
filename: options.filename,
|
|
1064
|
+
source: rawSource,
|
|
1065
|
+
analysis,
|
|
1066
|
+
handlerOptions: options
|
|
1067
|
+
},
|
|
1068
|
+
options.moduleGraph
|
|
1069
|
+
);
|
|
1070
|
+
const linked = graph.build();
|
|
1071
|
+
if (Object.keys(linked).length > 0) {
|
|
1072
|
+
result.linked = linked;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return result;
|
|
791
1076
|
}
|
|
792
1077
|
|
|
793
1078
|
// src/js/index.ts
|
|
@@ -1325,8 +1610,38 @@ import { getPackageInfoSync } from "local-pkg";
|
|
|
1325
1610
|
// src/tailwindcss/patcher.ts
|
|
1326
1611
|
import path from "path";
|
|
1327
1612
|
import process from "process";
|
|
1613
|
+
import { logger as logger2 } from "@weapp-tailwindcss/logger";
|
|
1328
1614
|
import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
1329
1615
|
import { TailwindcssPatcher } from "tailwindcss-patch";
|
|
1616
|
+
function createFallbackTailwindcssPatcher() {
|
|
1617
|
+
const packageInfo = {
|
|
1618
|
+
name: "tailwindcss",
|
|
1619
|
+
version: void 0,
|
|
1620
|
+
rootPath: "",
|
|
1621
|
+
packageJsonPath: "",
|
|
1622
|
+
packageJson: {}
|
|
1623
|
+
};
|
|
1624
|
+
return {
|
|
1625
|
+
packageInfo,
|
|
1626
|
+
majorVersion: 0,
|
|
1627
|
+
patch() {
|
|
1628
|
+
},
|
|
1629
|
+
async getClassSet() {
|
|
1630
|
+
return /* @__PURE__ */ new Set();
|
|
1631
|
+
},
|
|
1632
|
+
getClassSetV3() {
|
|
1633
|
+
return /* @__PURE__ */ new Set();
|
|
1634
|
+
},
|
|
1635
|
+
async extract(_options) {
|
|
1636
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
1637
|
+
return {
|
|
1638
|
+
classList: [],
|
|
1639
|
+
classSet
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1644
|
+
var hasLoggedMissingTailwind = false;
|
|
1330
1645
|
function createTailwindcssPatcher(options) {
|
|
1331
1646
|
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
1332
1647
|
const cache = {};
|
|
@@ -1339,7 +1654,7 @@ function createTailwindcssPatcher(options) {
|
|
|
1339
1654
|
cache.dir = path.resolve(process.cwd(), cacheDir);
|
|
1340
1655
|
}
|
|
1341
1656
|
}
|
|
1342
|
-
|
|
1657
|
+
const resolvedOptions = defuOverrideArray2(
|
|
1343
1658
|
tailwindcssPatcherOptions,
|
|
1344
1659
|
{
|
|
1345
1660
|
cache,
|
|
@@ -1357,7 +1672,19 @@ function createTailwindcssPatcher(options) {
|
|
|
1357
1672
|
}
|
|
1358
1673
|
}
|
|
1359
1674
|
}
|
|
1360
|
-
)
|
|
1675
|
+
);
|
|
1676
|
+
try {
|
|
1677
|
+
return new TailwindcssPatcher(resolvedOptions);
|
|
1678
|
+
} catch (error) {
|
|
1679
|
+
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
1680
|
+
if (!hasLoggedMissingTailwind) {
|
|
1681
|
+
logger2.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
|
|
1682
|
+
hasLoggedMissingTailwind = true;
|
|
1683
|
+
}
|
|
1684
|
+
return createFallbackTailwindcssPatcher();
|
|
1685
|
+
}
|
|
1686
|
+
throw error;
|
|
1687
|
+
}
|
|
1361
1688
|
}
|
|
1362
1689
|
|
|
1363
1690
|
// src/context/tailwindcss.ts
|
|
@@ -1399,7 +1726,11 @@ function getCompilerContext(opts) {
|
|
|
1399
1726
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
1400
1727
|
applyLoggerLevel(ctx.logLevel);
|
|
1401
1728
|
const twPatcher = createTailwindcssPatcherFromContext(ctx);
|
|
1402
|
-
|
|
1729
|
+
if (twPatcher.packageInfo?.version) {
|
|
1730
|
+
logger3.success(`\u5F53\u524D\u4F7F\u7528 ${pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${pc.underline(pc.bold(pc.green(twPatcher.packageInfo.version)))}`);
|
|
1731
|
+
} else {
|
|
1732
|
+
logger3.warn(`${pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
|
|
1733
|
+
}
|
|
1403
1734
|
const cssCalcOptions = ctx.cssCalc ?? twPatcher.majorVersion === 4;
|
|
1404
1735
|
const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
|
|
1405
1736
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
@@ -4,10 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-H4JTYYOI.mjs";
|
|
5
5
|
import {
|
|
6
6
|
getCompilerContext
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3KKB4FSY.mjs";
|
|
8
8
|
|
|
9
9
|
// src/bundlers/gulp/index.ts
|
|
10
10
|
import { Buffer } from "buffer";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import process from "process";
|
|
11
14
|
import stream from "stream";
|
|
12
15
|
var debug = createDebug();
|
|
13
16
|
var Transform = stream.Transform;
|
|
@@ -16,6 +19,64 @@ function createPlugins(options = {}) {
|
|
|
16
19
|
const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
17
20
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
18
21
|
twPatcher.patch();
|
|
22
|
+
const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
|
|
23
|
+
function resolveWithExtensions(base) {
|
|
24
|
+
for (const ext of MODULE_EXTENSIONS) {
|
|
25
|
+
const candidate = `${base}${ext}`;
|
|
26
|
+
try {
|
|
27
|
+
if (fs.statSync(candidate).isFile()) {
|
|
28
|
+
return candidate;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
function resolveLocalModuleCandidate(base) {
|
|
37
|
+
try {
|
|
38
|
+
const stat = fs.statSync(base);
|
|
39
|
+
if (stat.isFile()) {
|
|
40
|
+
return base;
|
|
41
|
+
}
|
|
42
|
+
if (stat.isDirectory()) {
|
|
43
|
+
const resolvedIndex = resolveWithExtensions(path.join(base, "index"));
|
|
44
|
+
if (resolvedIndex) {
|
|
45
|
+
return resolvedIndex;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
if (!path.extname(base)) {
|
|
51
|
+
return resolveWithExtensions(base);
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
function createModuleGraphOptionsFor() {
|
|
56
|
+
return {
|
|
57
|
+
resolve(specifier, importer) {
|
|
58
|
+
if (!specifier) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
if (!specifier.startsWith(".") && !path.isAbsolute(specifier)) {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
const normalized = path.resolve(path.dirname(importer), specifier);
|
|
65
|
+
return resolveLocalModuleCandidate(normalized);
|
|
66
|
+
},
|
|
67
|
+
load(id) {
|
|
68
|
+
try {
|
|
69
|
+
return fs.readFileSync(id, "utf8");
|
|
70
|
+
} catch {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
filter(id) {
|
|
75
|
+
const relative = path.relative(process.cwd(), id);
|
|
76
|
+
return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
19
80
|
function createVinylTransform(handler) {
|
|
20
81
|
return new Transform({
|
|
21
82
|
objectMode: true,
|
|
@@ -63,6 +124,17 @@ function createPlugins(options = {}) {
|
|
|
63
124
|
if (!file.contents) {
|
|
64
125
|
return;
|
|
65
126
|
}
|
|
127
|
+
const filename = path.resolve(file.path);
|
|
128
|
+
const moduleGraph = options2.moduleGraph ?? createModuleGraphOptionsFor();
|
|
129
|
+
const handlerOptions = {
|
|
130
|
+
...options2,
|
|
131
|
+
filename,
|
|
132
|
+
moduleGraph,
|
|
133
|
+
babelParserOptions: {
|
|
134
|
+
...options2?.babelParserOptions ?? {},
|
|
135
|
+
sourceFilename: filename
|
|
136
|
+
}
|
|
137
|
+
};
|
|
66
138
|
const rawSource = file.contents.toString();
|
|
67
139
|
await processCachedTask({
|
|
68
140
|
cache,
|
|
@@ -75,7 +147,8 @@ function createPlugins(options = {}) {
|
|
|
75
147
|
debug("js cache hit: %s", file.path);
|
|
76
148
|
},
|
|
77
149
|
async transform() {
|
|
78
|
-
const
|
|
150
|
+
const currentSource = file.contents?.toString() ?? rawSource;
|
|
151
|
+
const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
79
152
|
debug("js handle: %s", file.path);
|
|
80
153
|
return {
|
|
81
154
|
result: code
|