weapp-tailwindcss 5.1.6 → 5.1.7
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/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +10 -0
- package/dist/{context-3GGqW9vw.mjs → context-BqeDu1Ha.mjs} +5 -4
- package/dist/{context-BCSk_YnL.js → context-C7KTDlrG.js} +5 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CoT5vu9w.mjs → generator-BOt2Tvx3.mjs} +1 -1
- package/dist/{generator-CqWzj2Z1.js → generator-DASZwC6t.js} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-hXE1U4Cu.js → gulp-D6hsaTLM.js} +4 -4
- package/dist/{gulp-Bss4wJ8t.mjs → gulp-alDZryyB.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-Df4203aI.js → hmr-timing-BIr_CiPW.js} +12 -6
- package/dist/{hmr-timing-Cfu-4Bnf.mjs → hmr-timing-CYwVMRol.mjs} +12 -6
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-BbCmW975.mjs → source-candidate-scan-signature-D97ZEXcj.mjs} +3 -3
- package/dist/{source-candidate-scan-signature-5Uk6U72B.js → source-candidate-scan-signature-Djr2Hw8y.js} +3 -3
- package/dist/{tailwindcss-Bjr3aphG.mjs → tailwindcss-DDGD90w7.mjs} +1 -1
- package/dist/{tailwindcss-DYJ3HZD2.js → tailwindcss-DPxJpRVP.js} +1 -1
- package/dist/{transform-B6_y_yCB.js → transform-CvqqZBuq.js} +1 -1
- package/dist/{transform--155BmeJ.mjs → transform-DPPr79r2.mjs} +1 -1
- package/dist/uni-app-x/web-preflight-reset.d.ts +3 -0
- package/dist/{v4-engine-C9cmNlP8.js → v4-engine-3UmJkAY7.js} +32 -1
- package/dist/{v4-engine-DRQaCFMm.mjs → v4-engine-CYSrDVNp.mjs} +33 -2
- package/dist/{vite-Baw9qNrc.js → vite-BJRlG835.js} +91 -17
- package/dist/{vite-PdxjaqhO.mjs → vite-XxJh7Xtu.mjs} +91 -17
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +141 -6
- package/dist/{webpack-C9u7mfGE.js → webpack-BxBOMUtY.js} +274 -34
- package/dist/{webpack-BffTDmod.mjs → webpack-eN8WzIT-.mjs} +274 -34
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
-
const require_v4_engine = require("./v4-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-3UmJkAY7.js");
|
|
3
|
+
const require_generator = require("./generator-DASZwC6t.js");
|
|
4
4
|
const require_utils = require("./utils-D3h8j7Mk.js");
|
|
5
|
-
const require_context = require("./context-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
5
|
+
const require_context = require("./context-C7KTDlrG.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-DPxJpRVP.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-BIr_CiPW.js");
|
|
8
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-Djr2Hw8y.js");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
10
10
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
11
11
|
let node_path = require("node:path");
|
|
@@ -396,6 +396,11 @@ function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
|
396
396
|
if (sourceCss && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss) || require_v4_engine.hasTailwindGeneratedCss(sourceCss) || require_v4_engine.hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
|
|
397
397
|
return rawSource;
|
|
398
398
|
}
|
|
399
|
+
function shouldConsumeWebpackLoaderGeneratedCss(options) {
|
|
400
|
+
if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
|
|
401
|
+
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
402
|
+
return options.hasBundlerGeneratedCssMarker;
|
|
403
|
+
}
|
|
399
404
|
function hasUsableWebpackGeneratorCssSources(cssSources) {
|
|
400
405
|
return Array.isArray(cssSources) && cssSources.some((source) => typeof source?.css === "string" && source.css.length > 0);
|
|
401
406
|
}
|
|
@@ -447,7 +452,8 @@ function hasProcessedCssAssetUrl(css) {
|
|
|
447
452
|
return /url\(\s*["']?data:/i.test(css);
|
|
448
453
|
}
|
|
449
454
|
function shouldUseWebpackAssetAsGeneratorUserCss(rawSource, generatorRawSource, options = {}) {
|
|
450
|
-
|
|
455
|
+
const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
|
|
456
|
+
return rawSource !== generatorRawSource && (options.processed === true || !rawSource.includes("data:")) && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) && !require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) && !require_v4_engine.hasTailwindApplyDirective(rawSource) && rawMarkers.size > 0 && !isOnlyWebpackTailwindGeneratedPreflightCss(rawSource) && (!require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) || hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource));
|
|
451
457
|
}
|
|
452
458
|
function collectWebpackAssetUserCssMarkers(source) {
|
|
453
459
|
const markers = /* @__PURE__ */ new Set();
|
|
@@ -469,6 +475,44 @@ function collectWebpackAssetUserCssMarkers(source) {
|
|
|
469
475
|
} catch {}
|
|
470
476
|
return markers;
|
|
471
477
|
}
|
|
478
|
+
function hasWebpackClassSelector(selector) {
|
|
479
|
+
return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
|
|
480
|
+
}
|
|
481
|
+
function isWebpackKeyframesRule(rule) {
|
|
482
|
+
let parent = rule.parent;
|
|
483
|
+
while (parent) {
|
|
484
|
+
if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
|
|
485
|
+
parent = parent.parent;
|
|
486
|
+
}
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
function collectWebpackBareSelectorUserCss(source) {
|
|
490
|
+
try {
|
|
491
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(require_v4_engine.removeTailwindSourceDirectives(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.removeTailwindV4GeneratorAtRules(source)), { importFallback: true }));
|
|
492
|
+
let changed = false;
|
|
493
|
+
root.walkAtRules((rule) => {
|
|
494
|
+
if (rule.name === "import" || rule.name === "font-face" || rule.name.endsWith("keyframes")) {
|
|
495
|
+
rule.remove();
|
|
496
|
+
changed = true;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
root.walkRules((rule) => {
|
|
500
|
+
if (isWebpackKeyframesRule(rule) || rule.selectors.some((selector) => hasWebpackClassSelector(selector))) {
|
|
501
|
+
rule.remove();
|
|
502
|
+
changed = true;
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
root.walkAtRules((rule) => {
|
|
506
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
507
|
+
rule.remove();
|
|
508
|
+
changed = true;
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
return changed ? root.toString() : source;
|
|
512
|
+
} catch {
|
|
513
|
+
return "";
|
|
514
|
+
}
|
|
515
|
+
}
|
|
472
516
|
const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
|
|
473
517
|
"theme",
|
|
474
518
|
"base",
|
|
@@ -477,6 +521,26 @@ const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
|
|
|
477
521
|
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
478
522
|
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
479
523
|
const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
|
|
524
|
+
const WEBPACK_TAILWIND_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
525
|
+
"*",
|
|
526
|
+
":after",
|
|
527
|
+
":before",
|
|
528
|
+
"::after",
|
|
529
|
+
"::before",
|
|
530
|
+
"::backdrop",
|
|
531
|
+
"view",
|
|
532
|
+
"text"
|
|
533
|
+
]);
|
|
534
|
+
const WEBPACK_TAILWIND_PREFLIGHT_PROPS = /* @__PURE__ */ new Set([
|
|
535
|
+
"box-sizing",
|
|
536
|
+
"border",
|
|
537
|
+
"border-width",
|
|
538
|
+
"border-style",
|
|
539
|
+
"border-color",
|
|
540
|
+
"margin",
|
|
541
|
+
"padding"
|
|
542
|
+
]);
|
|
543
|
+
const WEBPACK_TAILWIND_THEME_TOKEN_RE = /^--(?:tw-|color-|spacing|breakpoint-|container-|text-|font-|tracking-|leading-|radius-|shadow-|inset-shadow-|drop-shadow-|ease-|animate-|blur-|perspective-|aspect-|default-)/;
|
|
480
544
|
function parseWebpackCssLayerNames(params) {
|
|
481
545
|
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
482
546
|
}
|
|
@@ -512,18 +576,21 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
512
576
|
return;
|
|
513
577
|
}
|
|
514
578
|
if (shouldRemoveLayer && !names.includes("utilities")) {
|
|
515
|
-
rule.
|
|
516
|
-
|
|
579
|
+
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
580
|
+
child.remove();
|
|
581
|
+
changed = true;
|
|
582
|
+
}
|
|
583
|
+
if (rule.nodes?.length === 0) {
|
|
584
|
+
rule.remove();
|
|
585
|
+
changed = true;
|
|
586
|
+
}
|
|
517
587
|
return;
|
|
518
588
|
}
|
|
519
589
|
if (shouldRemoveLayer) {
|
|
520
|
-
rule.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
changed = true;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
590
|
+
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
591
|
+
child.remove();
|
|
592
|
+
changed = true;
|
|
593
|
+
}
|
|
527
594
|
if (rule.nodes?.length === 0) {
|
|
528
595
|
rule.remove();
|
|
529
596
|
changed = true;
|
|
@@ -533,7 +600,7 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
533
600
|
root.walkRules((rule) => {
|
|
534
601
|
if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
|
|
535
602
|
const selector = rule.selector.trim();
|
|
536
|
-
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector)) {
|
|
603
|
+
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || isWebpackTailwindGeneratedPreflightRule(rule)) {
|
|
537
604
|
rule.remove();
|
|
538
605
|
changed = true;
|
|
539
606
|
}
|
|
@@ -556,14 +623,59 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
556
623
|
}
|
|
557
624
|
}
|
|
558
625
|
function isWebpackTailwindGeneratedPrefixNode(node) {
|
|
559
|
-
if (node.type === "rule") return node
|
|
626
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, [
|
|
627
|
+
"theme",
|
|
628
|
+
"base",
|
|
629
|
+
"utilities"
|
|
630
|
+
], true);
|
|
560
631
|
if (node.type !== "atrule") return false;
|
|
561
632
|
const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
|
|
562
633
|
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
563
|
-
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name)))
|
|
634
|
+
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) {
|
|
635
|
+
if (node.nodes === void 0) return true;
|
|
636
|
+
return node.nodes.length > 0 && node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, names));
|
|
637
|
+
}
|
|
564
638
|
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
565
639
|
return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
|
|
566
640
|
}
|
|
641
|
+
function isWebpackTailwindGeneratedLayerNode(node, layerNames) {
|
|
642
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, layerNames, false);
|
|
643
|
+
if (node.type !== "atrule") return false;
|
|
644
|
+
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
645
|
+
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
646
|
+
return node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, layerNames));
|
|
647
|
+
}
|
|
648
|
+
function isWebpackTailwindGeneratedRule(rule, layerNames, includePrefix) {
|
|
649
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
650
|
+
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), includePrefix))) return true;
|
|
651
|
+
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true))) return true;
|
|
652
|
+
if (layerNames.includes("theme") && isWebpackTailwindGeneratedThemeRule(rule)) return true;
|
|
653
|
+
if (layerNames.includes("base") && isWebpackTailwindGeneratedPreflightRule(rule)) return true;
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
function isWebpackTailwindGeneratedThemeRule(rule) {
|
|
657
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
658
|
+
return declarations.length > 0 && declarations.every((decl) => WEBPACK_TAILWIND_THEME_TOKEN_RE.test(decl.prop) || decl.value.includes("--theme("));
|
|
659
|
+
}
|
|
660
|
+
function isWebpackTailwindGeneratedPreflightRule(rule) {
|
|
661
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
662
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
663
|
+
return selectors.length > 0 && declarations.length > 0 && selectors.every((selector) => {
|
|
664
|
+
const normalized = selector.trim().replace(/\s+/g, " ");
|
|
665
|
+
return WEBPACK_TAILWIND_PREFLIGHT_SELECTORS.has(normalized);
|
|
666
|
+
}) && declarations.every((decl) => WEBPACK_TAILWIND_PREFLIGHT_PROPS.has(decl.prop));
|
|
667
|
+
}
|
|
668
|
+
function isOnlyWebpackTailwindGeneratedPreflightCss(source) {
|
|
669
|
+
try {
|
|
670
|
+
const nodes = _weapp_tailwindcss_postcss.postcss.parse(source).nodes ?? [];
|
|
671
|
+
return nodes.length > 0 && nodes.every((node) => {
|
|
672
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedPreflightRule(node);
|
|
673
|
+
return node.type === "atrule" && (node.nodes === void 0 || node.nodes.length === 0);
|
|
674
|
+
});
|
|
675
|
+
} catch {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
567
679
|
function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
|
|
568
680
|
return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
|
|
569
681
|
}
|
|
@@ -875,6 +987,26 @@ function stringifyWebpackSourceLike(source) {
|
|
|
875
987
|
}
|
|
876
988
|
//#endregion
|
|
877
989
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.ts
|
|
990
|
+
function normalizeWebpackCssSourceRef(file) {
|
|
991
|
+
return file.replaceAll("\\", "/");
|
|
992
|
+
}
|
|
993
|
+
function collectWebpackCssTokenSourceRefs(source) {
|
|
994
|
+
const refs = /* @__PURE__ */ new Set();
|
|
995
|
+
for (const line of source.split("\n")) {
|
|
996
|
+
if (!line.includes("/* tokens:") || !line.includes("<=")) continue;
|
|
997
|
+
const traceStart = line.indexOf("<=");
|
|
998
|
+
const traceEnd = line.indexOf("*/", traceStart);
|
|
999
|
+
const trace = line.slice(traceStart + 2, traceEnd >= 0 ? traceEnd : void 0);
|
|
1000
|
+
for (const segment of trace.split("|")) {
|
|
1001
|
+
const sourceList = segment.replace(/^[^<]*<=\s*/, "").split(",");
|
|
1002
|
+
for (const ref of sourceList) {
|
|
1003
|
+
const normalizedRef = ref.trim();
|
|
1004
|
+
if (normalizedRef) refs.add(normalizeWebpackCssSourceRef(normalizedRef));
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return refs;
|
|
1009
|
+
}
|
|
878
1010
|
function createWebpackCssSourceResolvers(options) {
|
|
879
1011
|
const { activeWebpackAssetResourceFiles, appType, compilerOptions, compilation, cssAssetResources, cssHandlerOptionsCache, cssSources, cssUserHandlerOptionsCache, groupedCssEntriesLength, singleCssAssetFile, isWebGeneratorTarget, outputDir, runtimeState } = options;
|
|
880
1012
|
const hasConfiguredTailwindV4SourceRoots = () => {
|
|
@@ -942,6 +1074,19 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
942
1074
|
return activeAssetResource;
|
|
943
1075
|
}
|
|
944
1076
|
if (rawSource) {
|
|
1077
|
+
const tokenSourceRefs = collectWebpackCssTokenSourceRefs(rawSource);
|
|
1078
|
+
if (tokenSourceRefs.size > 0) {
|
|
1079
|
+
const tokenSourceMatches = [...cssSources.keys()].filter((sourceFile) => {
|
|
1080
|
+
const relativeSourceFile = normalizeWebpackCssSourceRef(node_path.default.relative(compilerOptions.tailwindcssBasedir, sourceFile));
|
|
1081
|
+
const absoluteSourceFile = normalizeWebpackCssSourceRef(node_path.default.resolve(sourceFile));
|
|
1082
|
+
return tokenSourceRefs.has(relativeSourceFile) || tokenSourceRefs.has(absoluteSourceFile);
|
|
1083
|
+
}).sort();
|
|
1084
|
+
if (tokenSourceMatches.length === 1) {
|
|
1085
|
+
const sourceFile = tokenSourceMatches[0];
|
|
1086
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
1087
|
+
return sourceFile;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
945
1090
|
const representedTailwindSourceMatches = [...cssSources.entries()].filter(([, source]) => isWebpackCssSourceRepresentedInAsset(rawSource, source.css)).map(([sourceFile]) => ({
|
|
946
1091
|
sourceFile,
|
|
947
1092
|
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(file, sourceFile, {
|
|
@@ -1702,7 +1847,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1702
1847
|
return rawSource;
|
|
1703
1848
|
};
|
|
1704
1849
|
const chunkHash = assetHashByChunk.get(file);
|
|
1705
|
-
const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file);
|
|
1850
|
+
const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file, readRawSource());
|
|
1706
1851
|
const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
|
|
1707
1852
|
const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
|
|
1708
1853
|
const processedSourceCss = processedSourceFile ? cssSources.get(node_path.default.resolve(processedSourceFile))?.css : void 0;
|
|
@@ -1737,9 +1882,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1737
1882
|
...source,
|
|
1738
1883
|
file: sourceFile
|
|
1739
1884
|
})), readCurrentProcessedRawSource()) !== void 0;
|
|
1885
|
+
const hasProcessedLoaderGeneratedUserCss = cachedSkipProcessedCssAsset === void 0 && processedLoaderGeneratedCss !== void 0 && hasAdditionalWebpackAssetUserCssMarkers(processedLoaderGeneratedCss.css, readCurrentProcessedRawSource());
|
|
1740
1886
|
const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && require_v4_engine.hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
|
|
1741
1887
|
const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1742
|
-
const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1888
|
+
const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && !hasProcessedLoaderGeneratedUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1743
1889
|
const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
|
|
1744
1890
|
if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
|
|
1745
1891
|
if (shouldSkipProcessedCssAsset) {
|
|
@@ -1764,12 +1910,29 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1764
1910
|
},
|
|
1765
1911
|
transform: async () => {
|
|
1766
1912
|
const source = readCurrentProcessedRawSource();
|
|
1913
|
+
const processedBareSelectorSourceCss = processedSourceCss ?? (hasTailwindGeneratedAssetCss ? removeWebpackTailwindGeneratedAssetCss(source) : void 0);
|
|
1767
1914
|
const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(hasTailwindGeneratedAssetCss && !hasGeneratedCssMarker ? isWebGeneratorTarget ? source : (await compilerOptions.styleHandler(source, cssHandlerOptionsForProcessedAsset)).css : source, {
|
|
1768
1915
|
cssPreflight: cssHandlerOptionsForProcessedAsset.isMainChunk,
|
|
1769
1916
|
generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss
|
|
1770
1917
|
}));
|
|
1918
|
+
const processedSourceBareUserCss = isWebGeneratorTarget || processedBareSelectorSourceCss === void 0 ? void 0 : createWebpackGeneratorUserCssSourceAppend({
|
|
1919
|
+
css: collectWebpackBareSelectorUserCss(processedBareSelectorSourceCss),
|
|
1920
|
+
processed: false
|
|
1921
|
+
});
|
|
1922
|
+
const finalizedProcessedSourceBareUserCss = processedSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(processedSourceBareUserCss.css, {
|
|
1923
|
+
cssPreflight: false,
|
|
1924
|
+
generatedCss: false
|
|
1925
|
+
});
|
|
1926
|
+
const missingProcessedSourceBareUserCss = finalizedProcessedSourceBareUserCss.trim().length === 0 ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, finalizedProcessedSourceBareUserCss);
|
|
1927
|
+
const css = missingProcessedSourceBareUserCss.trim().length === 0 ? nextCss : createWebpackGeneratorUserCssSourceAppend({
|
|
1928
|
+
css: nextCss,
|
|
1929
|
+
processed: true
|
|
1930
|
+
}, {
|
|
1931
|
+
css: missingProcessedSourceBareUserCss,
|
|
1932
|
+
processed: true
|
|
1933
|
+
}).css;
|
|
1771
1934
|
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
1772
|
-
return { result: new ConcatSource(finalizeTracedCss(
|
|
1935
|
+
return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset)) };
|
|
1773
1936
|
}
|
|
1774
1937
|
});
|
|
1775
1938
|
}, cssTaskFactories);
|
|
@@ -1838,7 +2001,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1838
2001
|
const loaderGeneratedCss = sourceFile && !isWebGeneratorTarget ? generatedCssSources.get(node_path.default.resolve(sourceFile)) : void 0;
|
|
1839
2002
|
const sourceCss = sourceFile ? cssSources.get(node_path.default.resolve(sourceFile))?.css : void 0;
|
|
1840
2003
|
const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1841
|
-
|
|
2004
|
+
const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await require_tailwindcss.resolveTailwindV4EntriesFromCssCached(sourceCss, node_path.default.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
|
|
2005
|
+
if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
|
|
2006
|
+
hasBundlerGeneratedCssMarker: require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(currentRawSource),
|
|
2007
|
+
loaderGeneratedClassSet: loaderGeneratedCss.classSet,
|
|
2008
|
+
sourceCandidates: explicitTailwindV4SourceCandidates,
|
|
2009
|
+
shouldRegenerateExplicitTailwindV4CssSource,
|
|
2010
|
+
watchMode
|
|
2011
|
+
})) {
|
|
1842
2012
|
for (const className of loaderGeneratedCss.classSet) {
|
|
1843
2013
|
generatorRuntimeSet.add(className);
|
|
1844
2014
|
transformRuntimeSet.add(className);
|
|
@@ -1847,16 +2017,49 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1847
2017
|
const currentRawSourceWithoutBundlerMarkers = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(currentRawSource);
|
|
1848
2018
|
const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
|
|
1849
2019
|
const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? require_hmr_timing.removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
|
|
1850
|
-
const
|
|
1851
|
-
|
|
2020
|
+
const isConfiguredMainCssSource = configuredMainCssEntryFiles.some((entry) => node_path.default.resolve(entry) === node_path.default.resolve(sourceFile));
|
|
2021
|
+
const loaderGeneratedCssWithoutMarkers = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
|
|
2022
|
+
const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(currentAssetUserCss);
|
|
2023
|
+
const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !require_v4_engine.isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
|
|
2024
|
+
if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk && (currentAssetMissingUserCss.trim().length === 0 || require_v4_engine.isCommentOnlyCss(currentAssetMissingUserCss))) {
|
|
2025
|
+
debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
|
|
2026
|
+
return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
|
|
2027
|
+
}
|
|
2028
|
+
const finalizedLoaderCss = finalizeCssAssetSource(currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
|
|
2029
|
+
css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? require_hmr_timing.removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(currentAssetUserCss, loaderGeneratedCss.css),
|
|
1852
2030
|
processed: true
|
|
1853
|
-
}, {
|
|
2031
|
+
}, currentAssetUserCss === void 0 ? void 0 : {
|
|
1854
2032
|
css: currentAssetUserCss,
|
|
1855
2033
|
processed: true
|
|
1856
2034
|
}).css, {
|
|
1857
2035
|
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1858
2036
|
generatedCss: true
|
|
1859
|
-
})
|
|
2037
|
+
});
|
|
2038
|
+
const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
|
|
2039
|
+
css: currentAssetUserCss,
|
|
2040
|
+
processed: true
|
|
2041
|
+
}, sourceCss === void 0 ? void 0 : {
|
|
2042
|
+
css: sourceCss,
|
|
2043
|
+
processed: false
|
|
2044
|
+
}].map((source) => {
|
|
2045
|
+
if (source === void 0) return;
|
|
2046
|
+
return {
|
|
2047
|
+
css: collectWebpackBareSelectorUserCss(source.css),
|
|
2048
|
+
processed: source.processed
|
|
2049
|
+
};
|
|
2050
|
+
}));
|
|
2051
|
+
const finalizedLoaderSourceBareUserCss = loaderSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(loaderSourceBareUserCss.css, {
|
|
2052
|
+
cssPreflight: false,
|
|
2053
|
+
generatedCss: false
|
|
2054
|
+
});
|
|
2055
|
+
const missingLoaderSourceBareUserCss = finalizedLoaderSourceBareUserCss.trim().length === 0 ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(finalizedLoaderCss, finalizedLoaderSourceBareUserCss);
|
|
2056
|
+
const css = finalizeTracedCss(missingLoaderSourceBareUserCss.trim().length === 0 ? finalizedLoaderCss : createWebpackGeneratorUserCssSourceAppend({
|
|
2057
|
+
css: finalizedLoaderCss,
|
|
2058
|
+
processed: true
|
|
2059
|
+
}, {
|
|
2060
|
+
css: missingLoaderSourceBareUserCss,
|
|
2061
|
+
processed: true
|
|
2062
|
+
}).css, cssHandlerOptions);
|
|
1860
2063
|
debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
|
|
1861
2064
|
return { result: new ConcatSource(css) };
|
|
1862
2065
|
}
|
|
@@ -1947,7 +2150,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1947
2150
|
generated = void 0;
|
|
1948
2151
|
}
|
|
1949
2152
|
else debug("css generator skipped for unmatched webpack main css asset: %s", file);
|
|
1950
|
-
const
|
|
2153
|
+
const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
|
|
1951
2154
|
css: generated.css,
|
|
1952
2155
|
processed: true
|
|
1953
2156
|
}, {
|
|
@@ -1956,7 +2159,36 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1956
2159
|
})?.css ?? generated.css : generated.css, {
|
|
1957
2160
|
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1958
2161
|
generatedCss: true
|
|
1959
|
-
}) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false })
|
|
2162
|
+
}) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
|
|
2163
|
+
const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
|
|
2164
|
+
userRawSource,
|
|
2165
|
+
sourceCss === void 0 ? void 0 : {
|
|
2166
|
+
css: sourceCss,
|
|
2167
|
+
processed: sourceCssProcessed
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
css: generatorRawSource,
|
|
2171
|
+
processed: false
|
|
2172
|
+
}
|
|
2173
|
+
].map((source) => {
|
|
2174
|
+
if (source === void 0) return;
|
|
2175
|
+
return {
|
|
2176
|
+
css: collectWebpackBareSelectorUserCss(source.css),
|
|
2177
|
+
processed: source.processed
|
|
2178
|
+
};
|
|
2179
|
+
}));
|
|
2180
|
+
const finalizedSourceBareUserCss = sourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(sourceBareUserCss.css, {
|
|
2181
|
+
cssPreflight: false,
|
|
2182
|
+
generatedCss: false
|
|
2183
|
+
});
|
|
2184
|
+
const missingSourceBareUserCss = finalizedSourceBareUserCss.trim().length === 0 ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(finalizedGeneratedCss, finalizedSourceBareUserCss);
|
|
2185
|
+
const source = new ConcatSource(finalizeTracedCss(missingSourceBareUserCss.trim().length === 0 ? finalizedGeneratedCss : createWebpackGeneratorUserCssSourceAppend({
|
|
2186
|
+
css: finalizedGeneratedCss,
|
|
2187
|
+
processed: true
|
|
2188
|
+
}, {
|
|
2189
|
+
css: missingSourceBareUserCss,
|
|
2190
|
+
processed: true
|
|
2191
|
+
}).css, cssHandlerOptions));
|
|
1960
2192
|
if (generated) {
|
|
1961
2193
|
for (const className of generated.classSet) generatorRuntimeSet.add(className);
|
|
1962
2194
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
|
|
@@ -2157,6 +2389,13 @@ function setupWebpackV5Loaders(options) {
|
|
|
2157
2389
|
const debug = require_context.createDebug();
|
|
2158
2390
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
2159
2391
|
const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
|
|
2392
|
+
function shouldKeepPreviousWebpackCssSource(previous, next) {
|
|
2393
|
+
if (next.processed === true && previous.processed === false) return true;
|
|
2394
|
+
if (previous.processed === true || next.processed === true || !previous.css || !next.css || previous.css === next.css) return false;
|
|
2395
|
+
const previousMarkers = collectWebpackAssetUserCssMarkers(previous.css);
|
|
2396
|
+
const nextMarkers = collectWebpackAssetUserCssMarkers(next.css);
|
|
2397
|
+
return previousMarkers.size > nextMarkers.size && [...nextMarkers].every((marker) => previousMarkers.has(marker));
|
|
2398
|
+
}
|
|
2160
2399
|
function normalizeIgnoredList(ignored) {
|
|
2161
2400
|
return (Array.isArray(ignored) ? [...ignored] : [ignored]).filter((item) => typeof item === "string" || item instanceof RegExp || typeof item === "function");
|
|
2162
2401
|
}
|
|
@@ -2334,14 +2573,15 @@ var WeappTailwindcss = class {
|
|
|
2334
2573
|
const registerWebpackCssSourceFile = (source) => {
|
|
2335
2574
|
const file = node_path.default.resolve(source.file);
|
|
2336
2575
|
const previous = webpackCssSources.get(file);
|
|
2337
|
-
|
|
2576
|
+
const next = {
|
|
2577
|
+
css: typeof source.css === "string" ? require_v4_engine.normalizeTailwindConfigDirectives(source.css, node_path.default.dirname(file)) : source.css,
|
|
2578
|
+
processed: source.processed
|
|
2579
|
+
};
|
|
2580
|
+
if (previous && shouldKeepPreviousWebpackCssSource(previous, next)) {
|
|
2338
2581
|
currentWebpackCssSourceFiles.add(file);
|
|
2339
2582
|
return;
|
|
2340
2583
|
}
|
|
2341
|
-
webpackCssSources.set(file,
|
|
2342
|
-
css: typeof source.css === "string" ? require_v4_engine.normalizeTailwindConfigDirectives(source.css, node_path.default.dirname(file)) : source.css,
|
|
2343
|
-
processed: source.processed
|
|
2344
|
-
});
|
|
2584
|
+
webpackCssSources.set(file, next);
|
|
2345
2585
|
currentWebpackCssSourceFiles.add(file);
|
|
2346
2586
|
};
|
|
2347
2587
|
const registerWebpackGeneratedCss = (source) => {
|