weapp-tailwindcss 5.1.15 → 5.1.16
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/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +43 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +2 -2
- package/dist/bundlers/shared/framework-postcss.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +18 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +33 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +3 -6
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
- package/dist/bundlers/shared/generator-css.d.ts +1 -2
- package/dist/bundlers/shared/v4-generation-core.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
- package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
- package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
- package/dist/bundlers/vite/generate-bundle-runtime.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +12 -0
- package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
- package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +4 -4
- package/dist/bundlers/vite/source-candidates/collector.d.ts +8 -0
- package/dist/bundlers/vite/source-candidates/store.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/types-and-cache.d.ts +69 -0
- package/dist/bundlers/vite/source-candidates.d.ts +4 -68
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -219
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
- package/dist/cli.js +14 -18
- package/dist/cli.mjs +14 -18
- package/dist/{context-VeFq_8vW.js → context-BtLIID4m.js} +3 -3
- package/dist/{context-BgGWVAmN.mjs → context-JzwzSX36.mjs} +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CEnUsjed.js → generator-B91GhUJQ.js} +636 -505
- package/dist/{generator-CEo920So.mjs → generator-Bv7myuhY.mjs} +556 -431
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/{gulp-DP71z1jG.mjs → gulp-CKSklPlH.mjs} +217 -186
- package/dist/{gulp-3m1dAiig.js → gulp-Q1wITegn.js} +217 -186
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-1aS6--U7.mjs → hmr-timing-BXg7nI8N.mjs} +3411 -3276
- package/dist/{hmr-timing-B8p4f0ca.js → hmr-timing-CMPaWn9P.js} +3425 -3278
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/shared/mpx-plugin-owner.d.ts +2 -0
- package/dist/{source-candidate-scan-signature-BAahhiwb.js → source-candidate-scan-signature-BKZZk_e6.js} +144 -4
- package/dist/{source-candidate-scan-signature-Cf7259PR.mjs → source-candidate-scan-signature-CtK-mB_C.mjs} +127 -4
- package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
- package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +52 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
- package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-B4phC0kB.js} +2 -2
- package/dist/{tailwindcss-xs704TRw.mjs → tailwindcss-BTcXX8Ka.mjs} +2 -2
- package/dist/{vite-nXZEiwG0.mjs → vite-BwQWl9ft.mjs} +806 -692
- package/dist/{vite-DUVjMduj.js → vite-DhVnXvAQ.js} +805 -691
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-generation-loader.js +1 -1
- package/dist/{weapp-tw-css-import-rewrite-loader-DNk0IxAt.js → weapp-tw-css-import-rewrite-loader-B0tVkJLH.js} +2410 -2084
- package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
- package/dist/weapp-tw-runtime-classset-loader.js +10 -4
- package/dist/{webpack-C_UUFRgj.mjs → webpack-Bo1QrFPf.mjs} +1387 -1114
- package/dist/{webpack-nppysF4B.js → webpack-kh78iMSS.js} +1386 -1113
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +9 -7
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-B91GhUJQ.js");
|
|
4
4
|
const require_object = require("./object-COs_Mw6p.js");
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-B4phC0kB.js");
|
|
6
6
|
require("./utils-CuKLf1Zv.js");
|
|
7
7
|
const require_wxml = require("./wxml-Ce10eREX.js");
|
|
8
|
-
const require_context = require("./context-
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
8
|
+
const require_context = require("./context-BtLIID4m.js");
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-CMPaWn9P.js");
|
|
10
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BKZZk_e6.js");
|
|
11
11
|
require("./logger-TlKT3xmR.js");
|
|
12
12
|
let node_fs = require("node:fs");
|
|
13
13
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
@@ -21,8 +21,8 @@ let lru_cache = require("lru-cache");
|
|
|
21
21
|
let node_fs_promises = require("node:fs/promises");
|
|
22
22
|
let micromatch = require("micromatch");
|
|
23
23
|
micromatch = require_rolldown_runtime.__toESM(micromatch);
|
|
24
|
-
let node_buffer = require("node:buffer");
|
|
25
24
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
25
|
+
let node_buffer = require("node:buffer");
|
|
26
26
|
let comment_json = require("comment-json");
|
|
27
27
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
28
28
|
//#region src/uni-app-x/style-asset/style-value.ts
|
|
@@ -502,6 +502,17 @@ function createUniAppXBundleAssetSourceGetter(bundle) {
|
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
504
|
//#endregion
|
|
505
|
+
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
506
|
+
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
507
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
508
|
+
if (!output.fileName || output.fileName === file) continue;
|
|
509
|
+
const existing = bundle[output.fileName];
|
|
510
|
+
if (existing != null && existing !== output) continue;
|
|
511
|
+
bundle[output.fileName] = output;
|
|
512
|
+
delete bundle[file];
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
505
516
|
//#region src/bundlers/vite/generate-bundle/transform-filter.ts
|
|
506
517
|
function toArray(value) {
|
|
507
518
|
return Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
@@ -1705,159 +1716,553 @@ const mix = (del = delimiter) => {
|
|
|
1705
1716
|
const posix = /* @__PURE__ */ mix(":");
|
|
1706
1717
|
const win32 = /* @__PURE__ */ mix(";");
|
|
1707
1718
|
//#endregion
|
|
1708
|
-
//#region src/bundlers/vite/
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
".nvue",
|
|
1713
|
-
".svelte",
|
|
1714
|
-
".mpx"
|
|
1715
|
-
];
|
|
1716
|
-
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
1717
|
-
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
1718
|
-
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
1719
|
-
function isSfcStyleSourceFile(file) {
|
|
1720
|
-
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
1721
|
-
return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
|
|
1719
|
+
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
1720
|
+
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1721
|
+
function isCssOutputFile(file) {
|
|
1722
|
+
return CSS_OUTPUT_FILE_RE.test(file);
|
|
1722
1723
|
}
|
|
1723
|
-
function
|
|
1724
|
-
const
|
|
1725
|
-
|
|
1726
|
-
let index = 0;
|
|
1727
|
-
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1728
|
-
while (match !== null) {
|
|
1729
|
-
const attrs = match[1] ?? "";
|
|
1730
|
-
styleSources.push({
|
|
1731
|
-
attrs,
|
|
1732
|
-
index,
|
|
1733
|
-
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
1734
|
-
source: match[2] ?? ""
|
|
1735
|
-
});
|
|
1736
|
-
index += 1;
|
|
1737
|
-
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
1738
|
-
}
|
|
1739
|
-
return styleSources;
|
|
1724
|
+
function isRootStyleOutputFile(file) {
|
|
1725
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1726
|
+
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
1740
1727
|
}
|
|
1741
|
-
function
|
|
1742
|
-
return
|
|
1728
|
+
function isMiniProgramStyleOutputFile(file) {
|
|
1729
|
+
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
1743
1730
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1731
|
+
//#endregion
|
|
1732
|
+
//#region src/bundlers/vite/processed-css-assets/markers-imports.ts
|
|
1733
|
+
function createCssAssetPipelineContext(options, file, bundle) {
|
|
1734
|
+
const context = options.createCssPipelineContext?.(file);
|
|
1735
|
+
return context ? {
|
|
1736
|
+
...context,
|
|
1737
|
+
bundle
|
|
1738
|
+
} : void 0;
|
|
1746
1739
|
}
|
|
1747
|
-
function
|
|
1748
|
-
|
|
1749
|
-
return scopedStyleBlock ? `${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true` : sourceFile;
|
|
1740
|
+
function getAssetFile$1(bundleFile, asset) {
|
|
1741
|
+
return asset.fileName || bundleFile;
|
|
1750
1742
|
}
|
|
1751
|
-
function
|
|
1752
|
-
return source
|
|
1743
|
+
function readAssetSource$2(asset) {
|
|
1744
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
1753
1745
|
}
|
|
1754
|
-
function
|
|
1755
|
-
|
|
1756
|
-
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
1746
|
+
function clearAssetSource(asset) {
|
|
1747
|
+
asset.source = "";
|
|
1757
1748
|
}
|
|
1758
|
-
function
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
params.set("index", String(styleBlock.index));
|
|
1763
|
-
if (styleBlock.scoped) params.set("scoped", "true");
|
|
1764
|
-
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
1765
|
-
if (lang) params.set("lang", lang);
|
|
1766
|
-
return `${sourceFile}?${params.toString()}`;
|
|
1749
|
+
function appendCss$1(baseCss, css) {
|
|
1750
|
+
if (baseCss.length === 0) return css;
|
|
1751
|
+
if (css.length === 0) return baseCss;
|
|
1752
|
+
return `${baseCss}\n${css}`;
|
|
1767
1753
|
}
|
|
1768
|
-
function
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1754
|
+
function normalizeCssRecordIdentity(css) {
|
|
1755
|
+
return css.trim();
|
|
1756
|
+
}
|
|
1757
|
+
function hasNonCommentCss(css) {
|
|
1758
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
1759
|
+
}
|
|
1760
|
+
function dedupeViteCssResults(records) {
|
|
1761
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1762
|
+
return records.filter((record) => {
|
|
1763
|
+
const key = `${require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
1764
|
+
if (seen.has(key)) return false;
|
|
1765
|
+
seen.add(key);
|
|
1766
|
+
return true;
|
|
1776
1767
|
});
|
|
1777
|
-
const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
|
|
1778
|
-
const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
|
|
1779
|
-
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
1780
1768
|
}
|
|
1781
|
-
function
|
|
1782
|
-
|
|
1783
|
-
|
|
1769
|
+
function removeTailwindSourceMediaWrappersRoot(root) {
|
|
1770
|
+
let changed = false;
|
|
1771
|
+
root.walkAtRules("media", (atRule) => {
|
|
1772
|
+
if (!atRule.params.startsWith("source(")) return;
|
|
1773
|
+
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
1774
|
+
else atRule.remove();
|
|
1775
|
+
changed = true;
|
|
1776
|
+
});
|
|
1777
|
+
if (changed) root.walkAtRules((atRule) => {
|
|
1778
|
+
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
1779
|
+
});
|
|
1780
|
+
return changed;
|
|
1784
1781
|
}
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1787
|
-
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
1782
|
+
function removeTailwindSourceMediaWrappersFallback(css) {
|
|
1783
|
+
return css.replace(/@media\s+source\([^)]*\)\s*\{\s*\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/?\s*\}/gi, "").replace(/@media\s+source\([^)]*\)\s*\{\s*\}/gi, "");
|
|
1788
1784
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
return;
|
|
1799
|
-
}
|
|
1800
|
-
const styleBlocks = extractSfcStyleBlocks(source);
|
|
1801
|
-
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
1802
|
-
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
1803
|
-
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
1804
|
-
return;
|
|
1785
|
+
function removeTailwindEntryDirectivesFromCss(css) {
|
|
1786
|
+
try {
|
|
1787
|
+
const source = require_generator.stripGeneratorPlaceholderMarkers(css);
|
|
1788
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1789
|
+
const removedMediaWrappers = removeTailwindSourceMediaWrappersRoot(root);
|
|
1790
|
+
const removedTailwindDirectives = (0, _weapp_tailwindcss_postcss.removeTailwindSourceDirectivesRoot)(root);
|
|
1791
|
+
return removedMediaWrappers || removedTailwindDirectives ? root.toString() : source;
|
|
1792
|
+
} catch {
|
|
1793
|
+
return require_generator.removeTailwindSourceDirectives(removeTailwindSourceMediaWrappersFallback(css));
|
|
1805
1794
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1795
|
+
}
|
|
1796
|
+
function removeUnsupportedMiniProgramCssImportsFallback(css, file) {
|
|
1797
|
+
if (!isMiniProgramStyleOutputFile(file) || !css.includes("@import")) return css;
|
|
1798
|
+
return css.split(/\r?\n/).filter((line) => {
|
|
1799
|
+
const trimmed = line.trim();
|
|
1800
|
+
if (!trimmed.startsWith("@import")) return true;
|
|
1801
|
+
const request = (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
1802
|
+
return request === void 0 || (0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request);
|
|
1803
|
+
}).join("\n");
|
|
1804
|
+
}
|
|
1805
|
+
function normalizeInjectableCssForTarget(css, file) {
|
|
1806
|
+
return normalizeInjectableCssForTargetWithImports(css, file).css;
|
|
1807
|
+
}
|
|
1808
|
+
function normalizeInjectableCssForTargetWithImports(css, file) {
|
|
1809
|
+
if (!css.includes("@import")) return {
|
|
1810
|
+
css,
|
|
1811
|
+
importedStyleFiles: /* @__PURE__ */ new Set()
|
|
1811
1812
|
};
|
|
1813
|
+
try {
|
|
1814
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1815
|
+
const changed = isMiniProgramStyleOutputFile(file) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramCssImportsRoot)(root) : false;
|
|
1816
|
+
const importedStyleFiles = collectImportedStyleFilesRoot(root, file);
|
|
1817
|
+
return {
|
|
1818
|
+
css: changed ? root.toString() : css,
|
|
1819
|
+
importedStyleFiles: importedStyleFiles.size > 0 ? importedStyleFiles : collectImportedStyleFilesFallback(css, file)
|
|
1820
|
+
};
|
|
1821
|
+
} catch {
|
|
1822
|
+
const fallbackCss = removeUnsupportedMiniProgramCssImportsFallback(css, file);
|
|
1823
|
+
return {
|
|
1824
|
+
css: fallbackCss,
|
|
1825
|
+
importedStyleFiles: collectImportedStyleFiles(fallbackCss, file)
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1812
1828
|
}
|
|
1813
|
-
function
|
|
1814
|
-
return
|
|
1829
|
+
function stripStyleExtension(file) {
|
|
1830
|
+
return file.replace(/[?#].*$/, "").replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)$/i, "");
|
|
1815
1831
|
}
|
|
1816
|
-
function
|
|
1817
|
-
|
|
1818
|
-
return [
|
|
1819
|
-
output.facadeModuleId,
|
|
1820
|
-
...moduleIds,
|
|
1821
|
-
...Object.keys(output.modules ?? {})
|
|
1822
|
-
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
1832
|
+
function isStyleImportRequest(request) {
|
|
1833
|
+
return typeof request === "string" && request.length > 0 && !/^(?:https?:)?\/\//i.test(request) && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request);
|
|
1823
1834
|
}
|
|
1824
|
-
function
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (
|
|
1828
|
-
|
|
1835
|
+
function resolveImportedStyleFile(targetFile, request) {
|
|
1836
|
+
if (!isStyleImportRequest(request)) return;
|
|
1837
|
+
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
1838
|
+
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
1839
|
+
const targetDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
1840
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
1829
1841
|
}
|
|
1830
|
-
function
|
|
1831
|
-
const
|
|
1832
|
-
|
|
1833
|
-
const
|
|
1834
|
-
|
|
1842
|
+
function collectImportedStyleFilesFromRequests(requests, targetFile) {
|
|
1843
|
+
const imports = /* @__PURE__ */ new Set();
|
|
1844
|
+
for (const request of requests) {
|
|
1845
|
+
const importedFile = resolveImportedStyleFile(targetFile, request);
|
|
1846
|
+
if (importedFile) imports.add(importedFile);
|
|
1835
1847
|
}
|
|
1836
|
-
|
|
1848
|
+
return imports;
|
|
1837
1849
|
}
|
|
1838
|
-
function
|
|
1839
|
-
|
|
1840
|
-
if (!isSfcStyleSourceFile(file)) return;
|
|
1841
|
-
if (!node_path.default.isAbsolute(file)) return;
|
|
1842
|
-
return node_path.default.resolve(file);
|
|
1850
|
+
function collectImportedStyleFilesRoot(root, targetFile) {
|
|
1851
|
+
return collectImportedStyleFilesFromRequests((0, _weapp_tailwindcss_postcss.collectCssImportRequestsRoot)(root), targetFile);
|
|
1843
1852
|
}
|
|
1844
|
-
function
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1853
|
+
function collectImportedStyleFilesFallback(css, targetFile) {
|
|
1854
|
+
return collectImportedStyleFilesFromRequests([...css.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s;)]+))/g)].map((match) => match[1] ?? match[2] ?? match[3]).filter((request) => typeof request === "string" && request.length > 0), targetFile);
|
|
1855
|
+
}
|
|
1856
|
+
function collectImportedStyleFiles(css, targetFile) {
|
|
1857
|
+
if (!css.includes("@import")) return /* @__PURE__ */ new Set();
|
|
1858
|
+
try {
|
|
1859
|
+
const imports = collectImportedStyleFilesRoot(_weapp_tailwindcss_postcss.postcss.parse(css), targetFile);
|
|
1860
|
+
return imports.size > 0 ? imports : collectImportedStyleFilesFallback(css, targetFile);
|
|
1861
|
+
} catch {}
|
|
1862
|
+
return collectImportedStyleFilesFallback(css, targetFile);
|
|
1863
|
+
}
|
|
1864
|
+
function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
|
|
1865
|
+
return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
|
|
1866
|
+
}
|
|
1867
|
+
function isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
1868
|
+
if (!markerFile) return false;
|
|
1869
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(targetFile)) === require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile)));
|
|
1870
|
+
}
|
|
1871
|
+
function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1872
|
+
const blocks = require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
1873
|
+
if (blocks.length <= 1) return require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1874
|
+
const matchedCss = blocks.filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.css);
|
|
1875
|
+
return matchedCss.length > 0 ? matchedCss.join("\n") : require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
1876
|
+
}
|
|
1877
|
+
function collectMatchingGeneratedCssMarkerFiles(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
1878
|
+
return require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite").filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.file).filter((markerFile) => typeof markerFile === "string" && markerFile.length > 0);
|
|
1879
|
+
}
|
|
1880
|
+
function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
1881
|
+
const sources = [];
|
|
1882
|
+
const excludedFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(excludedFile);
|
|
1883
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1884
|
+
if (output.type !== "asset") continue;
|
|
1885
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
1886
|
+
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
1887
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
1888
|
+
if (source.length > 0) sources.push(source);
|
|
1889
|
+
}
|
|
1890
|
+
return sources;
|
|
1891
|
+
}
|
|
1892
|
+
function isHtmlOutputFile(file) {
|
|
1893
|
+
return /\.html(?:$|[?#])/i.test(file);
|
|
1894
|
+
}
|
|
1895
|
+
function stripQueryAndHash(file) {
|
|
1896
|
+
return file.replace(/[?#].*$/, "");
|
|
1897
|
+
}
|
|
1898
|
+
function resolveHtmlLinkedStyleFile(htmlFile, request) {
|
|
1899
|
+
if (!isStyleImportRequest(request)) return;
|
|
1900
|
+
const cleanRequest = stripQueryAndHash(request);
|
|
1901
|
+
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
1902
|
+
const htmlDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(htmlFile)));
|
|
1903
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(htmlDir === "." ? "" : htmlDir, cleanRequest));
|
|
1904
|
+
}
|
|
1905
|
+
function collectHtmlLinkedStyleFiles(bundle) {
|
|
1906
|
+
const linkedFiles = /* @__PURE__ */ new Set();
|
|
1907
|
+
const linkedBasenames = /* @__PURE__ */ new Set();
|
|
1908
|
+
const linkHrefRE = /<link\s[^>]*href\s*=\s*(["'])([^"']+)\1[^>]*>/gi;
|
|
1909
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1910
|
+
if (output.type !== "asset") continue;
|
|
1911
|
+
const htmlFile = getAssetFile$1(bundleFile, output);
|
|
1912
|
+
if (!isHtmlOutputFile(htmlFile)) continue;
|
|
1913
|
+
const html = readAssetSource$2(output);
|
|
1914
|
+
for (const match of html.matchAll(linkHrefRE)) {
|
|
1915
|
+
const href = match[2];
|
|
1916
|
+
if (!href) continue;
|
|
1917
|
+
const linkedFile = resolveHtmlLinkedStyleFile(htmlFile, href);
|
|
1918
|
+
if (!linkedFile || !isRootStyleOutputFile(linkedFile)) continue;
|
|
1919
|
+
linkedFiles.add(linkedFile);
|
|
1920
|
+
linkedBasenames.add(posix.posix.basename(linkedFile));
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
return {
|
|
1924
|
+
linkedBasenames,
|
|
1925
|
+
linkedFiles
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
function isLinkedStyleFile(file, linked) {
|
|
1929
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(file));
|
|
1930
|
+
return linked.linkedFiles.has(fileKey) || isRootStyleOutputFile(fileKey) && linked.linkedBasenames.has(posix.posix.basename(fileKey));
|
|
1931
|
+
}
|
|
1932
|
+
function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options = {}) {
|
|
1933
|
+
const linked = collectHtmlLinkedStyleFiles(bundle);
|
|
1934
|
+
if (linked.linkedFiles.size === 0 && linked.linkedBasenames.size === 0) return 0;
|
|
1935
|
+
const linkedSources = /* @__PURE__ */ new Set();
|
|
1936
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1937
|
+
if (output.type !== "asset") continue;
|
|
1938
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
1939
|
+
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
1940
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
1941
|
+
if (source.length > 0) linkedSources.add(source);
|
|
1942
|
+
}
|
|
1943
|
+
if (linkedSources.size === 0) return 0;
|
|
1944
|
+
let removed = 0;
|
|
1945
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1946
|
+
if (output.type !== "asset") continue;
|
|
1947
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
1948
|
+
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
1949
|
+
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
1950
|
+
if (!linkedSources.has(source)) continue;
|
|
1951
|
+
delete bundle[bundleFile];
|
|
1952
|
+
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
1953
|
+
removed++;
|
|
1954
|
+
}
|
|
1955
|
+
return removed;
|
|
1956
|
+
}
|
|
1957
|
+
//#endregion
|
|
1958
|
+
//#region src/bundlers/vite/processed-css-assets/cleanup.ts
|
|
1959
|
+
function collectCssImportAtRuleCss(css) {
|
|
1960
|
+
if (!css.includes("@import")) return [];
|
|
1961
|
+
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
1962
|
+
if (fallbackImports.length > 0) return fallbackImports;
|
|
1963
|
+
try {
|
|
1964
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1965
|
+
const imports = [];
|
|
1966
|
+
root.each((node) => {
|
|
1967
|
+
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
1968
|
+
});
|
|
1969
|
+
return imports;
|
|
1970
|
+
} catch {
|
|
1971
|
+
return [];
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
function parseCssImportRequest(importCss) {
|
|
1975
|
+
const trimmed = importCss.trim();
|
|
1976
|
+
if (!trimmed.startsWith("@import")) return;
|
|
1977
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
1978
|
+
}
|
|
1979
|
+
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
1980
|
+
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
1981
|
+
const request = parseCssImportRequest(importCss);
|
|
1982
|
+
if (request === void 0) return false;
|
|
1983
|
+
if ((0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request)) return true;
|
|
1984
|
+
return isStyleImportRequest(request) && !request.includes("/");
|
|
1985
|
+
}
|
|
1986
|
+
function restoreCssImportAtRules(source, filtered, file) {
|
|
1987
|
+
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
1988
|
+
if (imports.length === 0) return filtered;
|
|
1989
|
+
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
1990
|
+
if (missingImports.length === 0) return filtered;
|
|
1991
|
+
return appendCss$1(missingImports.join("\n"), filtered);
|
|
1992
|
+
}
|
|
1993
|
+
function removeCommentOnlyAtRules(css) {
|
|
1994
|
+
if (!css.includes("@")) return css;
|
|
1995
|
+
try {
|
|
1996
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1997
|
+
let changed = false;
|
|
1998
|
+
root.walkAtRules((atRule) => {
|
|
1999
|
+
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2000
|
+
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2001
|
+
atRule.remove();
|
|
2002
|
+
changed = true;
|
|
2003
|
+
});
|
|
2004
|
+
return changed ? root.toString() : css;
|
|
2005
|
+
} catch {
|
|
2006
|
+
return css;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2010
|
+
if (importedStyleFiles.size === 0) return [];
|
|
2011
|
+
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2012
|
+
const importedSources = [];
|
|
2013
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2014
|
+
if (output.type !== "asset") continue;
|
|
2015
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2016
|
+
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2017
|
+
importedSources.push(readAssetSource$2(output));
|
|
2018
|
+
}
|
|
2019
|
+
return importedSources;
|
|
2020
|
+
}
|
|
2021
|
+
function collectBundleAssetFiles(bundle) {
|
|
2022
|
+
const files = /* @__PURE__ */ new Set();
|
|
2023
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2024
|
+
if (output.type !== "asset") continue;
|
|
2025
|
+
files.add(require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2026
|
+
}
|
|
2027
|
+
return files;
|
|
2028
|
+
}
|
|
2029
|
+
function normalizeComparableStyleFile(file) {
|
|
2030
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2031
|
+
}
|
|
2032
|
+
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2033
|
+
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2034
|
+
return [
|
|
2035
|
+
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2036
|
+
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2037
|
+
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2038
|
+
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2039
|
+
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2040
|
+
}
|
|
2041
|
+
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2042
|
+
if (typeof file !== "string" || file.length === 0) return false;
|
|
2043
|
+
const fileKey = normalizeComparableStyleFile(file);
|
|
2044
|
+
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2045
|
+
}
|
|
2046
|
+
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2047
|
+
const opts = options.opts;
|
|
2048
|
+
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2049
|
+
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2050
|
+
if (context === void 0) return;
|
|
2051
|
+
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2052
|
+
...context,
|
|
2053
|
+
bundle,
|
|
2054
|
+
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2055
|
+
isMiniProgramStyleOutputFile,
|
|
2056
|
+
isRootStyleOutputFile,
|
|
2057
|
+
outputFile,
|
|
2058
|
+
sourceFile
|
|
2059
|
+
});
|
|
2060
|
+
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2061
|
+
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2062
|
+
const rootCssFiles = [];
|
|
2063
|
+
const matchedRootCssFiles = [];
|
|
2064
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2065
|
+
if (output.type !== "asset") continue;
|
|
2066
|
+
const file = getAssetFile$1(bundleFile, output);
|
|
2067
|
+
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2068
|
+
rootCssFiles.push(file);
|
|
2069
|
+
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2070
|
+
}
|
|
2071
|
+
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2072
|
+
if (matchedRootCssFiles.length > 1) return;
|
|
2073
|
+
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2074
|
+
}
|
|
2075
|
+
function findBundleAssetByOutputFile(bundle, file) {
|
|
2076
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2077
|
+
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2078
|
+
return output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2079
|
+
})?.[1];
|
|
2080
|
+
}
|
|
2081
|
+
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2082
|
+
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2083
|
+
if (importedStyleFiles.size === 0) return false;
|
|
2084
|
+
let hasNonImportNode = false;
|
|
2085
|
+
try {
|
|
2086
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).each((node) => {
|
|
2087
|
+
if (node.type === "comment") return;
|
|
2088
|
+
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2089
|
+
});
|
|
2090
|
+
} catch {
|
|
2091
|
+
return false;
|
|
2092
|
+
}
|
|
2093
|
+
if (hasNonImportNode) return false;
|
|
2094
|
+
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2095
|
+
}
|
|
2096
|
+
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2097
|
+
const resolvedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2098
|
+
return resolvedOutputFile !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2099
|
+
}
|
|
2100
|
+
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2101
|
+
const resolvedFromFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2102
|
+
if (!markerFile) return resolvedFromFile;
|
|
2103
|
+
const resolvedFromMarker = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2104
|
+
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2105
|
+
return resolvedFromFile;
|
|
2106
|
+
}
|
|
2107
|
+
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2108
|
+
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2109
|
+
const outputFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
2110
|
+
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2111
|
+
}
|
|
2112
|
+
//#endregion
|
|
2113
|
+
//#region src/bundlers/vite/generate-bundle/sfc-style-source.ts
|
|
2114
|
+
const SFC_STYLE_SOURCE_EXTENSIONS = [
|
|
2115
|
+
".vue",
|
|
2116
|
+
".uvue",
|
|
2117
|
+
".nvue",
|
|
2118
|
+
".svelte",
|
|
2119
|
+
".mpx"
|
|
2120
|
+
];
|
|
2121
|
+
const SFC_STYLE_BLOCK_RE$1 = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
2122
|
+
const SFC_SCOPED_STYLE_ATTR_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
2123
|
+
const SFC_LANG_STYLE_ATTR_RE = /(?:^|\s)lang(?:=(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+)))?/i;
|
|
2124
|
+
function isSfcStyleSourceFile(file) {
|
|
2125
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
2126
|
+
return SFC_STYLE_SOURCE_EXTENSIONS.some((extension) => normalizedFile.endsWith(extension));
|
|
2127
|
+
}
|
|
2128
|
+
function extractSfcStyleBlocks(source) {
|
|
2129
|
+
const styleSources = [];
|
|
2130
|
+
SFC_STYLE_BLOCK_RE$1.lastIndex = 0;
|
|
2131
|
+
let index = 0;
|
|
2132
|
+
let match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2133
|
+
while (match !== null) {
|
|
2134
|
+
const attrs = match[1] ?? "";
|
|
2135
|
+
styleSources.push({
|
|
2136
|
+
attrs,
|
|
2137
|
+
index,
|
|
2138
|
+
scoped: SFC_SCOPED_STYLE_ATTR_RE.test(attrs),
|
|
2139
|
+
source: match[2] ?? ""
|
|
2140
|
+
});
|
|
2141
|
+
index += 1;
|
|
2142
|
+
match = SFC_STYLE_BLOCK_RE$1.exec(source);
|
|
2143
|
+
}
|
|
2144
|
+
return styleSources;
|
|
2145
|
+
}
|
|
2146
|
+
function extractSfcStyleSources(source) {
|
|
2147
|
+
return extractSfcStyleBlocks(source).map((style) => style.source);
|
|
2148
|
+
}
|
|
2149
|
+
function hasSfcStyleSources(source) {
|
|
2150
|
+
return extractSfcStyleSources(source).length > 0;
|
|
2151
|
+
}
|
|
2152
|
+
function resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks) {
|
|
2153
|
+
const scopedStyleBlock = styleBlocks.find((style) => style.scoped);
|
|
2154
|
+
return scopedStyleBlock ? `${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true` : sourceFile;
|
|
2155
|
+
}
|
|
2156
|
+
function normalizeSfcStyleSourceForCompare(source) {
|
|
2157
|
+
return source.replace(/\r\n?/g, "\n").trim();
|
|
2158
|
+
}
|
|
2159
|
+
function resolveSfcStyleBlockLang(attrs) {
|
|
2160
|
+
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
2161
|
+
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
2162
|
+
}
|
|
2163
|
+
function createSfcStyleRequest(sourceFile, styleBlock) {
|
|
2164
|
+
const params = new URLSearchParams();
|
|
2165
|
+
params.set("vue", "");
|
|
2166
|
+
params.set("type", "style");
|
|
2167
|
+
params.set("index", String(styleBlock.index));
|
|
2168
|
+
if (styleBlock.scoped) params.set("scoped", "true");
|
|
2169
|
+
const lang = resolveSfcStyleBlockLang(styleBlock.attrs);
|
|
2170
|
+
if (lang) params.set("lang", lang);
|
|
2171
|
+
return `${sourceFile}?${params.toString()}`;
|
|
2172
|
+
}
|
|
2173
|
+
function resolveSfcStyleRequestFromKnownSource(sourceFile, sfcSource, styleSource, currentRequest) {
|
|
2174
|
+
if (!sfcSource) return sourceFile;
|
|
2175
|
+
const styleBlocks = extractSfcStyleBlocks(sfcSource);
|
|
2176
|
+
if (styleBlocks.length === 0) return sourceFile;
|
|
2177
|
+
const normalizedStyleSource = normalizeSfcStyleSourceForCompare(styleSource);
|
|
2178
|
+
const matchedBlocks = styleBlocks.filter((styleBlock) => {
|
|
2179
|
+
const normalizedBlockSource = normalizeSfcStyleSourceForCompare(styleBlock.source);
|
|
2180
|
+
return normalizedBlockSource === normalizedStyleSource || normalizedBlockSource.includes(normalizedStyleSource) || normalizedStyleSource.includes(normalizedBlockSource);
|
|
2181
|
+
});
|
|
2182
|
+
const requestIndex = currentRequest ? Number.parseInt(new URLSearchParams(currentRequest.split("?", 2)[1] ?? "").get("index") ?? "", 10) : NaN;
|
|
2183
|
+
const styleBlock = (Number.isInteger(requestIndex) ? styleBlocks.find((styleBlock) => styleBlock.index === requestIndex) : void 0) ?? (matchedBlocks.length === 1 ? matchedBlocks[0] : styleBlocks.length === 1 ? styleBlocks[0] : void 0);
|
|
2184
|
+
return styleBlock ? createSfcStyleRequest(sourceFile, styleBlock) : sourceFile;
|
|
2185
|
+
}
|
|
2186
|
+
function hasTailwindGenerationSource(source, options = {}) {
|
|
2187
|
+
const allowRootDirectives = options.allowRootDirectives !== false;
|
|
2188
|
+
return require_generator.hasTailwindNonRootGenerationDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindSourceDirectives(source, { importFallback: true }) || allowRootDirectives && require_generator.hasTailwindRootDirectives(source, { importFallback: true }) || require_generator.hasTailwindApplyDirective(source);
|
|
2189
|
+
}
|
|
2190
|
+
function hasTailwindGenerationSourceForFile(file, source) {
|
|
2191
|
+
if (require_generator.isTailwindV4CssEntry(file)) return hasTailwindGenerationSource(source);
|
|
2192
|
+
return hasTailwindGenerationSource(source, { allowRootDirectives: false });
|
|
2193
|
+
}
|
|
2194
|
+
async function resolveSfcStyleSourceFromOutputFile(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, getSfcSource, debug) {
|
|
2195
|
+
const sourceFile = resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug);
|
|
2196
|
+
if (!sourceFile) {
|
|
2197
|
+
debug("sfc style source infer skipped: no source file for %s", outputFile);
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
const source = getSfcSource?.(sourceFile);
|
|
2201
|
+
if (source == null) {
|
|
2202
|
+
debug("sfc style source infer skipped: missing known source for %s -> %s", outputFile, sourceFile);
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
const styleBlocks = extractSfcStyleBlocks(source);
|
|
2206
|
+
const rawSource = styleBlocks.map((style) => style.source).join("\n");
|
|
2207
|
+
if (!rawSource || !hasTailwindGenerationSourceForFile(sourceFile, rawSource)) {
|
|
2208
|
+
debug("sfc style source infer skipped: no tailwind generation source for %s -> %s", outputFile, sourceFile);
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
debug("sfc style source inferred: %s -> %s", outputFile, sourceFile);
|
|
2212
|
+
return {
|
|
2213
|
+
outputFile,
|
|
2214
|
+
rawSource,
|
|
2215
|
+
sourceFile: resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks)
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
function normalizeSfcSourceFileForCompare(file) {
|
|
2219
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2220
|
+
}
|
|
2221
|
+
function collectChunkModuleIds$1(output) {
|
|
2222
|
+
const moduleIds = Array.isArray(output.moduleIds) ? output.moduleIds : [];
|
|
2223
|
+
return [
|
|
2224
|
+
output.facadeModuleId,
|
|
2225
|
+
...moduleIds,
|
|
2226
|
+
...Object.keys(output.modules ?? {})
|
|
2227
|
+
].filter((id, index, ids) => typeof id === "string" && id.length > 0 && ids.indexOf(id) === index);
|
|
2228
|
+
}
|
|
2229
|
+
function normalizeSourceStyleModuleId(id) {
|
|
2230
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2231
|
+
if (!CSS_SOURCE_OUTPUT_EXT_RE.test(file)) return;
|
|
2232
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
2233
|
+
return node_path.default.resolve(file);
|
|
2234
|
+
}
|
|
2235
|
+
function resolveSiblingJsChunkFile(outputFile, cssMatcher) {
|
|
2236
|
+
const normalizedOutputFile = outputFile.replace(/[?#].*$/, "");
|
|
2237
|
+
if (cssMatcher?.(normalizedOutputFile)) {
|
|
2238
|
+
const extension = node_path.default.extname(normalizedOutputFile);
|
|
2239
|
+
return extension ? `${normalizedOutputFile.slice(0, -extension.length)}.js` : void 0;
|
|
2240
|
+
}
|
|
2241
|
+
if (CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedOutputFile)) return normalizedOutputFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".js");
|
|
2242
|
+
}
|
|
2243
|
+
function normalizeSfcModuleId(id) {
|
|
2244
|
+
const file = id.replace(/[?#].*$/, "");
|
|
2245
|
+
if (!isSfcStyleSourceFile(file)) return;
|
|
2246
|
+
if (!node_path.default.isAbsolute(file)) return;
|
|
2247
|
+
return node_path.default.resolve(file);
|
|
2248
|
+
}
|
|
2249
|
+
function resolveSfcStyleFileFromSiblingChunk(outputFile, snapshot, outputRoot, sourceRoot, cssMatcher, debug) {
|
|
2250
|
+
const siblingJsFile = resolveSiblingJsChunkFile(outputFile, cssMatcher);
|
|
2251
|
+
if (!siblingJsFile) {
|
|
2252
|
+
debug("sfc style sibling chunk skipped: no sibling js for %s", outputFile);
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
const normalizedSiblingJsFile = require_source_candidate_scan_signature.normalizeOutputPathKey(siblingJsFile);
|
|
2256
|
+
const siblingChunk = snapshot.entries.find((entry) => entry.type === "js" && entry.output.type === "chunk" && require_source_candidate_scan_signature.normalizeOutputPathKey(entry.file) === normalizedSiblingJsFile);
|
|
2257
|
+
if (!siblingChunk || siblingChunk.output.type !== "chunk") {
|
|
2258
|
+
debug("sfc style sibling chunk skipped: missing chunk for %s -> %s", outputFile, siblingJsFile);
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
const sourceFiles = collectChunkModuleIds$1(siblingChunk.output).map(normalizeSfcModuleId).filter((file, index, files) => Boolean(file) && files.indexOf(file) === index);
|
|
2262
|
+
if (sourceFiles.length === 0) {
|
|
2263
|
+
debug("sfc style sibling chunk skipped: no sfc modules for %s -> %s", outputFile, siblingJsFile);
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
1861
2266
|
const scoredSources = sourceFiles.map((sourceFile) => ({
|
|
1862
2267
|
sourceFile,
|
|
1863
2268
|
score: scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot)
|
|
@@ -2004,254 +2409,26 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
2004
2409
|
const matchedSubpackageRoot = [...subpackageRoots].find((root) => isSubpackageOutputFile(entry.file, /* @__PURE__ */ new Set([root])));
|
|
2005
2410
|
if (!matchedSubpackageRoot) continue;
|
|
2006
2411
|
for (const moduleId of collectChunkModuleIds$1(entry.output)) {
|
|
2007
|
-
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
2008
|
-
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
2009
|
-
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
2013
|
-
base: sourceRoot,
|
|
2014
|
-
negated: false,
|
|
2015
|
-
pattern: "**/*"
|
|
2016
|
-
})));
|
|
2017
|
-
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => node_path.default.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
2018
|
-
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
2019
|
-
base: baseRoot,
|
|
2020
|
-
negated: false,
|
|
2021
|
-
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
2022
|
-
});
|
|
2023
|
-
return sourceEntries;
|
|
2024
|
-
}
|
|
2025
|
-
//#endregion
|
|
2026
|
-
//#region src/bundlers/vite/processed-css-assets.ts
|
|
2027
|
-
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
2028
|
-
function createCssAssetPipelineContext(options, file, bundle) {
|
|
2029
|
-
const context = options.createCssPipelineContext?.(file);
|
|
2030
|
-
return context ? {
|
|
2031
|
-
...context,
|
|
2032
|
-
bundle
|
|
2033
|
-
} : void 0;
|
|
2034
|
-
}
|
|
2035
|
-
function isCssOutputFile(file) {
|
|
2036
|
-
return CSS_OUTPUT_FILE_RE.test(file);
|
|
2037
|
-
}
|
|
2038
|
-
function getAssetFile$1(bundleFile, asset) {
|
|
2039
|
-
return asset.fileName || bundleFile;
|
|
2040
|
-
}
|
|
2041
|
-
function readAssetSource$2(asset) {
|
|
2042
|
-
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
2043
|
-
}
|
|
2044
|
-
function clearAssetSource(asset) {
|
|
2045
|
-
asset.source = "";
|
|
2046
|
-
}
|
|
2047
|
-
function appendCss$1(baseCss, css) {
|
|
2048
|
-
if (baseCss.length === 0) return css;
|
|
2049
|
-
if (css.length === 0) return baseCss;
|
|
2050
|
-
return `${baseCss}\n${css}`;
|
|
2051
|
-
}
|
|
2052
|
-
function normalizeCssRecordIdentity(css) {
|
|
2053
|
-
return css.trim();
|
|
2054
|
-
}
|
|
2055
|
-
function hasNonCommentCss(css) {
|
|
2056
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
|
|
2057
|
-
}
|
|
2058
|
-
function dedupeViteCssResults(records) {
|
|
2059
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2060
|
-
return records.filter((record) => {
|
|
2061
|
-
const key = `${require_source_candidate_scan_signature.normalizeOutputPathKey(record.outputFile ?? "")}\0${normalizeCssRecordIdentity(record.css)}`;
|
|
2062
|
-
if (seen.has(key)) return false;
|
|
2063
|
-
seen.add(key);
|
|
2064
|
-
return true;
|
|
2065
|
-
});
|
|
2066
|
-
}
|
|
2067
|
-
function removeTailwindSourceMediaWrappersRoot(root) {
|
|
2068
|
-
let changed = false;
|
|
2069
|
-
root.walkAtRules("media", (atRule) => {
|
|
2070
|
-
if (!atRule.params.startsWith("source(")) return;
|
|
2071
|
-
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
2072
|
-
else atRule.remove();
|
|
2073
|
-
changed = true;
|
|
2074
|
-
});
|
|
2075
|
-
if (changed) root.walkAtRules((atRule) => {
|
|
2076
|
-
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
2077
|
-
});
|
|
2078
|
-
return changed;
|
|
2079
|
-
}
|
|
2080
|
-
function removeTailwindSourceMediaWrappersFallback(css) {
|
|
2081
|
-
return css.replace(/@media\s+source\([^)]*\)\s*\{\s*\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/?\s*\}/gi, "").replace(/@media\s+source\([^)]*\)\s*\{\s*\}/gi, "");
|
|
2082
|
-
}
|
|
2083
|
-
function removeTailwindEntryDirectivesFromCss(css) {
|
|
2084
|
-
try {
|
|
2085
|
-
const source = require_generator.stripGeneratorPlaceholderMarkers(css);
|
|
2086
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2087
|
-
const removedMediaWrappers = removeTailwindSourceMediaWrappersRoot(root);
|
|
2088
|
-
const removedTailwindDirectives = (0, _weapp_tailwindcss_postcss.removeTailwindSourceDirectivesRoot)(root);
|
|
2089
|
-
return removedMediaWrappers || removedTailwindDirectives ? root.toString() : source;
|
|
2090
|
-
} catch {
|
|
2091
|
-
return require_generator.removeTailwindSourceDirectives(removeTailwindSourceMediaWrappersFallback(css));
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
function removeUnsupportedMiniProgramCssImportsFallback(css, file) {
|
|
2095
|
-
if (!isMiniProgramStyleOutputFile(file) || !css.includes("@import")) return css;
|
|
2096
|
-
return css.split(/\r?\n/).filter((line) => {
|
|
2097
|
-
const trimmed = line.trim();
|
|
2098
|
-
if (!trimmed.startsWith("@import")) return true;
|
|
2099
|
-
const request = (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
2100
|
-
return request === void 0 || (0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request);
|
|
2101
|
-
}).join("\n");
|
|
2102
|
-
}
|
|
2103
|
-
function normalizeInjectableCssForTarget(css, file) {
|
|
2104
|
-
return normalizeInjectableCssForTargetWithImports(css, file).css;
|
|
2105
|
-
}
|
|
2106
|
-
function normalizeInjectableCssForTargetWithImports(css, file) {
|
|
2107
|
-
if (!css.includes("@import")) return {
|
|
2108
|
-
css,
|
|
2109
|
-
importedStyleFiles: /* @__PURE__ */ new Set()
|
|
2110
|
-
};
|
|
2111
|
-
try {
|
|
2112
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2113
|
-
const changed = isMiniProgramStyleOutputFile(file) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramCssImportsRoot)(root) : false;
|
|
2114
|
-
const importedStyleFiles = collectImportedStyleFilesRoot(root, file);
|
|
2115
|
-
return {
|
|
2116
|
-
css: changed ? root.toString() : css,
|
|
2117
|
-
importedStyleFiles: importedStyleFiles.size > 0 ? importedStyleFiles : collectImportedStyleFilesFallback(css, file)
|
|
2118
|
-
};
|
|
2119
|
-
} catch {
|
|
2120
|
-
const fallbackCss = removeUnsupportedMiniProgramCssImportsFallback(css, file);
|
|
2121
|
-
return {
|
|
2122
|
-
css: fallbackCss,
|
|
2123
|
-
importedStyleFiles: collectImportedStyleFiles(fallbackCss, file)
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
function stripStyleExtension(file) {
|
|
2128
|
-
return file.replace(/[?#].*$/, "").replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)$/i, "");
|
|
2129
|
-
}
|
|
2130
|
-
function isStyleImportRequest(request) {
|
|
2131
|
-
return typeof request === "string" && request.length > 0 && !/^(?:https?:)?\/\//i.test(request) && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request);
|
|
2132
|
-
}
|
|
2133
|
-
function resolveImportedStyleFile(targetFile, request) {
|
|
2134
|
-
if (!isStyleImportRequest(request)) return;
|
|
2135
|
-
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
2136
|
-
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
2137
|
-
const targetDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
2138
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
2139
|
-
}
|
|
2140
|
-
function collectImportedStyleFilesFromRequests(requests, targetFile) {
|
|
2141
|
-
const imports = /* @__PURE__ */ new Set();
|
|
2142
|
-
for (const request of requests) {
|
|
2143
|
-
const importedFile = resolveImportedStyleFile(targetFile, request);
|
|
2144
|
-
if (importedFile) imports.add(importedFile);
|
|
2145
|
-
}
|
|
2146
|
-
return imports;
|
|
2147
|
-
}
|
|
2148
|
-
function collectImportedStyleFilesRoot(root, targetFile) {
|
|
2149
|
-
return collectImportedStyleFilesFromRequests((0, _weapp_tailwindcss_postcss.collectCssImportRequestsRoot)(root), targetFile);
|
|
2150
|
-
}
|
|
2151
|
-
function collectImportedStyleFilesFallback(css, targetFile) {
|
|
2152
|
-
return collectImportedStyleFilesFromRequests([...css.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s;)]+))/g)].map((match) => match[1] ?? match[2] ?? match[3]).filter((request) => typeof request === "string" && request.length > 0), targetFile);
|
|
2153
|
-
}
|
|
2154
|
-
function collectImportedStyleFiles(css, targetFile) {
|
|
2155
|
-
if (!css.includes("@import")) return /* @__PURE__ */ new Set();
|
|
2156
|
-
try {
|
|
2157
|
-
const imports = collectImportedStyleFilesRoot(_weapp_tailwindcss_postcss.postcss.parse(css), targetFile);
|
|
2158
|
-
return imports.size > 0 ? imports : collectImportedStyleFilesFallback(css, targetFile);
|
|
2159
|
-
} catch {}
|
|
2160
|
-
return collectImportedStyleFilesFallback(css, targetFile);
|
|
2161
|
-
}
|
|
2162
|
-
function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
|
|
2163
|
-
return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
|
|
2164
|
-
}
|
|
2165
|
-
function isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
2166
|
-
if (!markerFile) return false;
|
|
2167
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(targetFile)) === require_source_candidate_scan_signature.normalizeOutputPathKey(stripStyleExtension(normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile)));
|
|
2168
|
-
}
|
|
2169
|
-
function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
2170
|
-
const blocks = require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
2171
|
-
if (blocks.length <= 1) return require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
2172
|
-
const matchedCss = blocks.filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.css);
|
|
2173
|
-
return matchedCss.length > 0 ? matchedCss.join("\n") : require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
2174
|
-
}
|
|
2175
|
-
function collectMatchingGeneratedCssMarkerFiles(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
2176
|
-
return require_hmr_timing.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite").filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.file).filter((markerFile) => typeof markerFile === "string" && markerFile.length > 0);
|
|
2177
|
-
}
|
|
2178
|
-
function collectRootStyleBundleCssSources(bundle, excludedFile) {
|
|
2179
|
-
const sources = [];
|
|
2180
|
-
const excludedFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(excludedFile);
|
|
2181
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2182
|
-
if (output.type !== "asset") continue;
|
|
2183
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2184
|
-
if (file === excludedFileKey || !isRootStyleOutputFile(file)) continue;
|
|
2185
|
-
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2186
|
-
if (source.length > 0) sources.push(source);
|
|
2187
|
-
}
|
|
2188
|
-
return sources;
|
|
2189
|
-
}
|
|
2190
|
-
function isHtmlOutputFile(file) {
|
|
2191
|
-
return /\.html(?:$|[?#])/i.test(file);
|
|
2192
|
-
}
|
|
2193
|
-
function stripQueryAndHash(file) {
|
|
2194
|
-
return file.replace(/[?#].*$/, "");
|
|
2195
|
-
}
|
|
2196
|
-
function resolveHtmlLinkedStyleFile(htmlFile, request) {
|
|
2197
|
-
if (!isStyleImportRequest(request)) return;
|
|
2198
|
-
const cleanRequest = stripQueryAndHash(request);
|
|
2199
|
-
if (cleanRequest.startsWith("/")) return require_source_candidate_scan_signature.normalizeOutputPathKey(cleanRequest.slice(1));
|
|
2200
|
-
const htmlDir = posix.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(htmlFile)));
|
|
2201
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.posix.join(htmlDir === "." ? "" : htmlDir, cleanRequest));
|
|
2202
|
-
}
|
|
2203
|
-
function collectHtmlLinkedStyleFiles(bundle) {
|
|
2204
|
-
const linkedFiles = /* @__PURE__ */ new Set();
|
|
2205
|
-
const linkedBasenames = /* @__PURE__ */ new Set();
|
|
2206
|
-
const linkHrefRE = /<link\s[^>]*href\s*=\s*(["'])([^"']+)\1[^>]*>/gi;
|
|
2207
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2208
|
-
if (output.type !== "asset") continue;
|
|
2209
|
-
const htmlFile = getAssetFile$1(bundleFile, output);
|
|
2210
|
-
if (!isHtmlOutputFile(htmlFile)) continue;
|
|
2211
|
-
const html = readAssetSource$2(output);
|
|
2212
|
-
for (const match of html.matchAll(linkHrefRE)) {
|
|
2213
|
-
const href = match[2];
|
|
2214
|
-
if (!href) continue;
|
|
2215
|
-
const linkedFile = resolveHtmlLinkedStyleFile(htmlFile, href);
|
|
2216
|
-
if (!linkedFile || !isRootStyleOutputFile(linkedFile)) continue;
|
|
2217
|
-
linkedFiles.add(linkedFile);
|
|
2218
|
-
linkedBasenames.add(posix.posix.basename(linkedFile));
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
return {
|
|
2222
|
-
linkedBasenames,
|
|
2223
|
-
linkedFiles
|
|
2224
|
-
};
|
|
2225
|
-
}
|
|
2226
|
-
function isLinkedStyleFile(file, linked) {
|
|
2227
|
-
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(stripQueryAndHash(file));
|
|
2228
|
-
return linked.linkedFiles.has(fileKey) || isRootStyleOutputFile(fileKey) && linked.linkedBasenames.has(posix.posix.basename(fileKey));
|
|
2229
|
-
}
|
|
2230
|
-
function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, options = {}) {
|
|
2231
|
-
const linked = collectHtmlLinkedStyleFiles(bundle);
|
|
2232
|
-
if (linked.linkedFiles.size === 0 && linked.linkedBasenames.size === 0) return 0;
|
|
2233
|
-
const linkedSources = /* @__PURE__ */ new Set();
|
|
2234
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2235
|
-
if (output.type !== "asset") continue;
|
|
2236
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2237
|
-
if (!isCssOutputFile(file) || isMiniProgramStyleOutputFile(file) || !isLinkedStyleFile(file, linked)) continue;
|
|
2238
|
-
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2239
|
-
if (source.length > 0) linkedSources.add(source);
|
|
2240
|
-
}
|
|
2241
|
-
if (linkedSources.size === 0) return 0;
|
|
2242
|
-
let removed = 0;
|
|
2243
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2244
|
-
if (output.type !== "asset") continue;
|
|
2245
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2246
|
-
if (!isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file) || isLinkedStyleFile(file, linked)) continue;
|
|
2247
|
-
const source = require_hmr_timing.stripBundlerGeneratedCssMarkers(readAssetSource$2(output)).trim();
|
|
2248
|
-
if (!linkedSources.has(source)) continue;
|
|
2249
|
-
delete bundle[bundleFile];
|
|
2250
|
-
options.debug?.("remove duplicate unlinked root css asset referenced by html: %s", file);
|
|
2251
|
-
removed++;
|
|
2412
|
+
if (!node_path.default.isAbsolute(moduleId.replace(/[?#].*$/, ""))) continue;
|
|
2413
|
+
const sourceRoot = resolveSubpackageSourceRootFromModuleId(moduleId, matchedSubpackageRoot);
|
|
2414
|
+
if (sourceRoot) sourceRoots.add(sourceRoot);
|
|
2415
|
+
}
|
|
2252
2416
|
}
|
|
2253
|
-
|
|
2417
|
+
sourceEntries.push(...[...sourceRoots].map((sourceRoot) => ({
|
|
2418
|
+
base: sourceRoot,
|
|
2419
|
+
negated: false,
|
|
2420
|
+
pattern: "**/*"
|
|
2421
|
+
})));
|
|
2422
|
+
const resolvedBaseRoots = sourceBaseRoots.filter((baseRoot) => typeof baseRoot === "string" && baseRoot.length > 0).map((baseRoot) => node_path.default.resolve(baseRoot)).filter((baseRoot, index, roots) => roots.indexOf(baseRoot) === index);
|
|
2423
|
+
for (const baseRoot of resolvedBaseRoots) for (const subpackageRoot of subpackageRoots) sourceEntries.push({
|
|
2424
|
+
base: baseRoot,
|
|
2425
|
+
negated: false,
|
|
2426
|
+
pattern: `**/${normalizePackageRoot(subpackageRoot)}/**`
|
|
2427
|
+
});
|
|
2428
|
+
return sourceEntries;
|
|
2254
2429
|
}
|
|
2430
|
+
//#endregion
|
|
2431
|
+
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2255
2432
|
const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
2256
2433
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2257
2434
|
function hasVueScopedAttr(value) {
|
|
@@ -2333,9 +2510,11 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2333
2510
|
const rules = /* @__PURE__ */ new Set();
|
|
2334
2511
|
const atRules = /* @__PURE__ */ new Set();
|
|
2335
2512
|
const declarationsBySelector = /* @__PURE__ */ new Map();
|
|
2513
|
+
const normalizedRuleCss = /* @__PURE__ */ new Set();
|
|
2336
2514
|
for (const source of cssSources) try {
|
|
2337
2515
|
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2338
2516
|
root.walkRules((rule) => {
|
|
2517
|
+
normalizedRuleCss.add(normalizeCssSignatureValue(rule.toString()));
|
|
2339
2518
|
const declarations = createDeclarationSignature(rule);
|
|
2340
2519
|
if (declarations.length === 0) return;
|
|
2341
2520
|
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
@@ -2353,7 +2532,16 @@ function collectRootScopedComparableCssCoverage(cssSources) {
|
|
|
2353
2532
|
return {
|
|
2354
2533
|
rules,
|
|
2355
2534
|
atRules,
|
|
2356
|
-
declarationsBySelector
|
|
2535
|
+
declarationsBySelector,
|
|
2536
|
+
normalizedRuleCss
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function prepareImportedCssCoverage(importedCssSources) {
|
|
2540
|
+
const sources = importedCssSources.map((source) => require_hmr_timing.stripBundlerGeneratedCssMarkers(source).trim()).filter(Boolean);
|
|
2541
|
+
if (sources.length === 0) return;
|
|
2542
|
+
return {
|
|
2543
|
+
coverage: collectRootScopedComparableCssCoverage(sources),
|
|
2544
|
+
sources
|
|
2357
2545
|
};
|
|
2358
2546
|
}
|
|
2359
2547
|
function isRuleCoveredByRootCss(rule, coverage) {
|
|
@@ -2421,7 +2609,48 @@ function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile
|
|
|
2421
2609
|
}
|
|
2422
2610
|
function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
2423
2611
|
const rootSources = collectRootStyleBundleCssSources(bundle, file);
|
|
2424
|
-
|
|
2612
|
+
if (css.trim().length === 0) return css;
|
|
2613
|
+
const hasScopedCss = hasVueScopedAttr(css);
|
|
2614
|
+
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2615
|
+
const hasUnscopedMiniProgramPreflight = hasScopedCss && hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2616
|
+
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2617
|
+
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2618
|
+
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2619
|
+
let nextCss = css;
|
|
2620
|
+
try {
|
|
2621
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2622
|
+
let changed = false;
|
|
2623
|
+
root.walkRules((rule) => {
|
|
2624
|
+
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule))) {
|
|
2625
|
+
rule.remove();
|
|
2626
|
+
changed = true;
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2630
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || hasScopedTailwindGeneratedCss && isLikelyTailwindPropertyAtRule(atRule)) {
|
|
2631
|
+
atRule.remove();
|
|
2632
|
+
changed = true;
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
2636
|
+
atRule.remove();
|
|
2637
|
+
changed = true;
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2640
|
+
root.walkComments((comment) => {
|
|
2641
|
+
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
2642
|
+
comment.remove();
|
|
2643
|
+
changed = true;
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
2647
|
+
const next = comment.next();
|
|
2648
|
+
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
2649
|
+
comment.remove();
|
|
2650
|
+
changed = true;
|
|
2651
|
+
});
|
|
2652
|
+
if (changed) nextCss = root.toString().trim();
|
|
2653
|
+
} catch {}
|
|
2425
2654
|
return hasNonCommentCss(nextCss) ? nextCss : "";
|
|
2426
2655
|
}
|
|
2427
2656
|
function removeDanglingCssSourceTraceComments(css) {
|
|
@@ -2461,6 +2690,8 @@ function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
|
2461
2690
|
}
|
|
2462
2691
|
return updated;
|
|
2463
2692
|
}
|
|
2693
|
+
//#endregion
|
|
2694
|
+
//#region src/bundlers/vite/processed-css-assets/injection-plan.ts
|
|
2464
2695
|
function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, options) {
|
|
2465
2696
|
if (options.injectIntoMain === true) return isRootStyleOutputFile(targetFile) || typeof options.outputFile === "string" && require_source_candidate_scan_signature.normalizeOutputPathKey(options.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2466
2697
|
if (options.injectIntoMain === false) return false;
|
|
@@ -2476,13 +2707,6 @@ function shouldReplayViteProcessedCssIntoMainCss(opts, file, sourceFile, outputF
|
|
|
2476
2707
|
}
|
|
2477
2708
|
return isRootStyleOutputFile(file) && opts.mainCssChunkMatcher(file, opts.appType) || isSourceRootPrefixedOutputFile(file, outputFile) && isRootStyleOutputFile(outputFile) && opts.mainCssChunkMatcher(outputFile, opts.appType);
|
|
2478
2709
|
}
|
|
2479
|
-
function isRootStyleOutputFile(file) {
|
|
2480
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2481
|
-
return isCssOutputFile(normalized) && !normalized.includes("/");
|
|
2482
|
-
}
|
|
2483
|
-
function isMiniProgramStyleOutputFile(file) {
|
|
2484
|
-
return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
2485
|
-
}
|
|
2486
2710
|
function shouldPreserveMiniProgramImportShell(options, bundle, file, css) {
|
|
2487
2711
|
const context = createCssAssetPipelineContext(options, file, bundle);
|
|
2488
2712
|
return context !== void 0 && shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
@@ -2566,48 +2790,41 @@ function isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedSt
|
|
|
2566
2790
|
return false;
|
|
2567
2791
|
}
|
|
2568
2792
|
function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, records, options) {
|
|
2569
|
-
let removed = 0;
|
|
2570
2793
|
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
2571
2794
|
const targetIsRootWebStyle = isRootStyleOutputFile(targetFileKey) && !isMiniProgramStyleOutputFile(targetFileKey);
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2590
|
-
removed++;
|
|
2591
|
-
}
|
|
2795
|
+
const removableRecords = records.filter((record) => options.shouldRemoveInjectedSourceAsset?.(targetFile, record) === true);
|
|
2796
|
+
if (removableRecords.length === 0) return 0;
|
|
2797
|
+
const recordFileKeys = new Set(removableRecords.map((record) => require_source_candidate_scan_signature.normalizeOutputPathKey(record.file)));
|
|
2798
|
+
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
2799
|
+
let removed = 0;
|
|
2800
|
+
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
2801
|
+
if (candidateOutput.type !== "asset") continue;
|
|
2802
|
+
const candidateKey = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(candidateFile, candidateOutput));
|
|
2803
|
+
if (candidateKey === targetFileKey || !isCssOutputFile(candidateKey)) continue;
|
|
2804
|
+
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
2805
|
+
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
2806
|
+
const candidateSource = readAssetSource$2(candidateOutput).trim();
|
|
2807
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(targetCss, candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !hasNonCommentCss((0, _weapp_tailwindcss_postcss.filterExistingCssRules)(targetCss, candidateSource).trim())))) continue;
|
|
2808
|
+
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
2809
|
+
else clearAssetSource(candidateOutput);
|
|
2810
|
+
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
2811
|
+
removed++;
|
|
2592
2812
|
}
|
|
2593
2813
|
return removed;
|
|
2594
2814
|
}
|
|
2595
|
-
function removeCssCoveredByImportedViteResults(css, importedCssSources) {
|
|
2596
|
-
if (
|
|
2597
|
-
|
|
2598
|
-
if (importedCss.length === 0) return css;
|
|
2599
|
-
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, [importedCss], { exactOnly: true }));
|
|
2815
|
+
function removeCssCoveredByImportedViteResults(css, importedCssSources, prepared = prepareImportedCssCoverage(importedCssSources)) {
|
|
2816
|
+
if (!prepared) return css;
|
|
2817
|
+
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, prepared.sources, { exactOnly: true }, prepared.coverage));
|
|
2600
2818
|
}
|
|
2601
|
-
function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
2819
|
+
function removeCssRulesCoveredBySources(css, sources, options = {}, preparedCoverage) {
|
|
2602
2820
|
if (sources.length === 0 || css.trim().length === 0) return css;
|
|
2603
|
-
const coverage = collectRootScopedComparableCssCoverage(sources);
|
|
2604
|
-
|
|
2605
|
-
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coveredRuleCss.size === 0) return css;
|
|
2821
|
+
const coverage = preparedCoverage ?? collectRootScopedComparableCssCoverage(sources);
|
|
2822
|
+
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coverage.normalizedRuleCss.size === 0) return css;
|
|
2606
2823
|
try {
|
|
2607
2824
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2608
2825
|
let changed = false;
|
|
2609
2826
|
root.walkRules((rule) => {
|
|
2610
|
-
if (!
|
|
2827
|
+
if (!coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
|
|
2611
2828
|
rule.remove();
|
|
2612
2829
|
changed = true;
|
|
2613
2830
|
});
|
|
@@ -2616,168 +2833,8 @@ function removeCssRulesCoveredBySources(css, sources, options = {}) {
|
|
|
2616
2833
|
return css;
|
|
2617
2834
|
}
|
|
2618
2835
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
for (const source of sources) try {
|
|
2622
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
2623
|
-
rules.add(normalizeCssSignatureValue(rule.toString()));
|
|
2624
|
-
});
|
|
2625
|
-
} catch {}
|
|
2626
|
-
return rules;
|
|
2627
|
-
}
|
|
2628
|
-
function collectCssImportAtRuleCss(css) {
|
|
2629
|
-
if (!css.includes("@import")) return [];
|
|
2630
|
-
const fallbackImports = [...css.matchAll(/@import\s[^;]+;?/g)].map((match) => match[0]);
|
|
2631
|
-
if (fallbackImports.length > 0) return fallbackImports;
|
|
2632
|
-
try {
|
|
2633
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2634
|
-
const imports = [];
|
|
2635
|
-
root.each((node) => {
|
|
2636
|
-
if (node.type === "atrule" && node.name === "import") imports.push(node.toString());
|
|
2637
|
-
});
|
|
2638
|
-
return imports;
|
|
2639
|
-
} catch {
|
|
2640
|
-
return [];
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
function parseCssImportRequest(importCss) {
|
|
2644
|
-
const trimmed = importCss.trim();
|
|
2645
|
-
if (!trimmed.startsWith("@import")) return;
|
|
2646
|
-
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(trimmed.slice(7).trim().replace(/;$/, "").trim());
|
|
2647
|
-
}
|
|
2648
|
-
function shouldRestoreCssImportAtRule(importCss, file) {
|
|
2649
|
-
if (file === void 0 || !isMiniProgramStyleOutputFile(file)) return true;
|
|
2650
|
-
const request = parseCssImportRequest(importCss);
|
|
2651
|
-
if (request === void 0) return false;
|
|
2652
|
-
if ((0, _weapp_tailwindcss_postcss.isMiniProgramLocalCssImportRequest)(request)) return true;
|
|
2653
|
-
return isStyleImportRequest(request) && !request.includes("/");
|
|
2654
|
-
}
|
|
2655
|
-
function restoreCssImportAtRules(source, filtered, file) {
|
|
2656
|
-
const imports = collectCssImportAtRuleCss(source).filter((importCss) => shouldRestoreCssImportAtRule(importCss, file));
|
|
2657
|
-
if (imports.length === 0) return filtered;
|
|
2658
|
-
const missingImports = imports.filter((importCss) => !filtered.includes(importCss));
|
|
2659
|
-
if (missingImports.length === 0) return filtered;
|
|
2660
|
-
return appendCss$1(missingImports.join("\n"), filtered);
|
|
2661
|
-
}
|
|
2662
|
-
function removeCommentOnlyAtRules(css) {
|
|
2663
|
-
if (!css.includes("@")) return css;
|
|
2664
|
-
try {
|
|
2665
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2666
|
-
let changed = false;
|
|
2667
|
-
root.walkAtRules((atRule) => {
|
|
2668
|
-
if (!atRule.nodes || atRule.nodes.length === 0) return;
|
|
2669
|
-
if (atRule.nodes.some((node) => node.type !== "comment")) return;
|
|
2670
|
-
atRule.remove();
|
|
2671
|
-
changed = true;
|
|
2672
|
-
});
|
|
2673
|
-
return changed ? root.toString() : css;
|
|
2674
|
-
} catch {
|
|
2675
|
-
return css;
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
2679
|
-
if (importedStyleFiles.size === 0) return [];
|
|
2680
|
-
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
2681
|
-
const importedSources = [];
|
|
2682
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2683
|
-
if (output.type !== "asset") continue;
|
|
2684
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output));
|
|
2685
|
-
if (!(importedStyleFiles.has(file) || !file.includes("/") && importedFileNames.has(posix.posix.basename(file)))) continue;
|
|
2686
|
-
importedSources.push(readAssetSource$2(output));
|
|
2687
|
-
}
|
|
2688
|
-
return importedSources;
|
|
2689
|
-
}
|
|
2690
|
-
function collectBundleAssetFiles(bundle) {
|
|
2691
|
-
const files = /* @__PURE__ */ new Set();
|
|
2692
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2693
|
-
if (output.type !== "asset") continue;
|
|
2694
|
-
files.add(require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)));
|
|
2695
|
-
}
|
|
2696
|
-
return files;
|
|
2697
|
-
}
|
|
2698
|
-
function normalizeComparableStyleFile(file) {
|
|
2699
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(posix.normalize(file.replace(/[?#].*$/, "")));
|
|
2700
|
-
}
|
|
2701
|
-
function collectConfiguredTailwindV4CssEntryFiles(opts) {
|
|
2702
|
-
const runtimeCssEntries = opts.tailwindRuntime?.options?.tailwindcss?.v4?.cssEntries;
|
|
2703
|
-
return [
|
|
2704
|
-
...Array.isArray(opts.cssEntries) ? opts.cssEntries : [],
|
|
2705
|
-
...Array.isArray(opts.tailwindcss?.v4?.cssEntries) ? opts.tailwindcss.v4.cssEntries : [],
|
|
2706
|
-
...Array.isArray(opts.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) ? opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries : [],
|
|
2707
|
-
...Array.isArray(runtimeCssEntries) ? runtimeCssEntries : []
|
|
2708
|
-
].filter((file) => typeof file === "string" && file.length > 0);
|
|
2709
|
-
}
|
|
2710
|
-
function isConfiguredTailwindV4CssEntryFile(opts, file) {
|
|
2711
|
-
if (typeof file !== "string" || file.length === 0) return false;
|
|
2712
|
-
const fileKey = normalizeComparableStyleFile(file);
|
|
2713
|
-
return collectConfiguredTailwindV4CssEntryFiles(opts).some((entry) => normalizeComparableStyleFile(entry) === fileKey);
|
|
2714
|
-
}
|
|
2715
|
-
function resolveConfiguredCssEntryRootInjectionTarget(bundle, options, sourceFile, outputFile) {
|
|
2716
|
-
const opts = options.opts;
|
|
2717
|
-
if (opts === void 0 || isMiniProgramStyleOutputFile(outputFile) || !isConfiguredTailwindV4CssEntryFile(opts, sourceFile)) return;
|
|
2718
|
-
const context = createCssAssetPipelineContext(options, outputFile, bundle);
|
|
2719
|
-
if (context === void 0) return;
|
|
2720
|
-
const resolvedByStrategy = options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget?.({
|
|
2721
|
-
...context,
|
|
2722
|
-
bundle,
|
|
2723
|
-
isConfiguredCssEntryFile: (file) => isConfiguredTailwindV4CssEntryFile(opts, file),
|
|
2724
|
-
isMiniProgramStyleOutputFile,
|
|
2725
|
-
isRootStyleOutputFile,
|
|
2726
|
-
outputFile,
|
|
2727
|
-
sourceFile
|
|
2728
|
-
});
|
|
2729
|
-
if (resolvedByStrategy !== void 0) return resolvedByStrategy;
|
|
2730
|
-
if (options.cssPipelineStrategy?.resolveConfiguredCssEntryRootInjectionTarget == null) return;
|
|
2731
|
-
const rootCssFiles = [];
|
|
2732
|
-
const matchedRootCssFiles = [];
|
|
2733
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
2734
|
-
if (output.type !== "asset") continue;
|
|
2735
|
-
const file = getAssetFile$1(bundleFile, output);
|
|
2736
|
-
if (!opts.cssMatcher(file) || !isRootStyleOutputFile(file) || isMiniProgramStyleOutputFile(file)) continue;
|
|
2737
|
-
rootCssFiles.push(file);
|
|
2738
|
-
if (opts.mainCssChunkMatcher(file, opts.appType)) matchedRootCssFiles.push(file);
|
|
2739
|
-
}
|
|
2740
|
-
if (matchedRootCssFiles.length === 1) return matchedRootCssFiles[0];
|
|
2741
|
-
if (matchedRootCssFiles.length > 1) return;
|
|
2742
|
-
return rootCssFiles.length === 1 ? rootCssFiles[0] : void 0;
|
|
2743
|
-
}
|
|
2744
|
-
function findBundleAssetByOutputFile(bundle, file) {
|
|
2745
|
-
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2746
|
-
return Object.entries(bundle).find(([bundleFile, output]) => {
|
|
2747
|
-
return output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(getAssetFile$1(bundleFile, output)) === fileKey;
|
|
2748
|
-
})?.[1];
|
|
2749
|
-
}
|
|
2750
|
-
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
2751
|
-
const importedStyleFiles = collectImportedStyleFiles(css, file);
|
|
2752
|
-
if (importedStyleFiles.size === 0) return false;
|
|
2753
|
-
let hasNonImportNode = false;
|
|
2754
|
-
try {
|
|
2755
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).each((node) => {
|
|
2756
|
-
if (node.type === "comment") return;
|
|
2757
|
-
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
2758
|
-
});
|
|
2759
|
-
} catch {
|
|
2760
|
-
return false;
|
|
2761
|
-
}
|
|
2762
|
-
if (hasNonImportNode) return false;
|
|
2763
|
-
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
2764
|
-
}
|
|
2765
|
-
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2766
|
-
const resolvedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2767
|
-
return resolvedOutputFile !== require_source_candidate_scan_signature.normalizeOutputPathKey(file) && existingAssetFiles.has(resolvedOutputFile);
|
|
2768
|
-
}
|
|
2769
|
-
function resolveViteGeneratedCssMarkerOutputFile(file, markerFile, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
2770
|
-
const resolvedFromFile = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(file) ?? file);
|
|
2771
|
-
if (!markerFile) return resolvedFromFile;
|
|
2772
|
-
const resolvedFromMarker = require_source_candidate_scan_signature.normalizeOutputPathKey(resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile);
|
|
2773
|
-
if (resolvedFromMarker !== resolvedFromFile && existingAssetFiles.has(resolvedFromMarker)) return resolvedFromMarker;
|
|
2774
|
-
return resolvedFromFile;
|
|
2775
|
-
}
|
|
2776
|
-
function isSourceRootPrefixedOutputFile(file, outputFile) {
|
|
2777
|
-
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2778
|
-
const outputFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
2779
|
-
return fileKey !== outputFileKey && fileKey.endsWith(`/${outputFileKey}`);
|
|
2780
|
-
}
|
|
2836
|
+
//#endregion
|
|
2837
|
+
//#region src/bundlers/vite/processed-css-assets/collector.ts
|
|
2781
2838
|
function collectViteProcessedCssAssetResults(bundle, options) {
|
|
2782
2839
|
let collected = 0;
|
|
2783
2840
|
const existingAssetFiles = collectBundleAssetFiles(bundle);
|
|
@@ -2847,8 +2904,14 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
2847
2904
|
return collected;
|
|
2848
2905
|
}
|
|
2849
2906
|
function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
2907
|
+
const measure = (name, task) => {
|
|
2908
|
+
const startedAt = performance.now();
|
|
2909
|
+
const result = task();
|
|
2910
|
+
options.recordTimingDetail?.(`finalize.processedCss.inject.${name}`, startedAt);
|
|
2911
|
+
return result;
|
|
2912
|
+
};
|
|
2850
2913
|
const transformCss = (css, file) => options.transformCss?.(css, file) ?? css;
|
|
2851
|
-
const viteCssResults = dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2914
|
+
const viteCssResults = measure("prepareResults", () => dedupeViteCssResults([...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
2852
2915
|
return typeof record === "string" ? {
|
|
2853
2916
|
file,
|
|
2854
2917
|
css: record,
|
|
@@ -2862,7 +2925,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2862
2925
|
})).map((record) => ({
|
|
2863
2926
|
...record,
|
|
2864
2927
|
css: transformCss(record.css, record.outputFile ?? record.file)
|
|
2865
|
-
})).filter((record) => record.css.length > 0);
|
|
2928
|
+
})).filter((record) => record.css.length > 0));
|
|
2866
2929
|
let injected = 0;
|
|
2867
2930
|
for (const [bundleFile, bundleOutput] of Object.entries(bundle)) {
|
|
2868
2931
|
let output = bundleOutput;
|
|
@@ -2888,16 +2951,19 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2888
2951
|
}
|
|
2889
2952
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2890
2953
|
const mainFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
2891
|
-
const normalizedOriginalCss = normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file);
|
|
2954
|
+
const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file));
|
|
2892
2955
|
let nextCss = normalizedOriginalCss.css;
|
|
2893
2956
|
const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
|
|
2894
2957
|
const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
|
|
2895
|
-
|
|
2958
|
+
const importedBundleCssCoverage = prepareImportedCssCoverage(importedBundleCssSources);
|
|
2959
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, importedBundleCssSources, importedBundleCssCoverage);
|
|
2896
2960
|
const importedViteCssResults = viteCssResults.filter((record) => isViteProcessedCssResultImported(record, importedStyleFiles));
|
|
2897
2961
|
const bundleAssetFiles = collectBundleAssetFiles(bundle);
|
|
2898
2962
|
const uncoveredImportedViteCssResults = importedViteCssResults.filter((record) => !isViteProcessedCssResultCoveredByImportedBundleAsset(record, importedStyleFiles, bundleAssetFiles));
|
|
2899
2963
|
const importedCssSources = [...importedBundleCssSources, ...uncoveredImportedViteCssResults.map((record) => record.css)];
|
|
2900
|
-
|
|
2964
|
+
const uncoveredImportedCssSources = uncoveredImportedViteCssResults.map((record) => record.css);
|
|
2965
|
+
nextCss = removeCssCoveredByImportedViteResults(nextCss, uncoveredImportedCssSources, prepareImportedCssCoverage(uncoveredImportedCssSources));
|
|
2966
|
+
const importedCssCoverage = prepareImportedCssCoverage(importedCssSources);
|
|
2901
2967
|
const targetViteCssResults = [];
|
|
2902
2968
|
for (const record of viteCssResults) {
|
|
2903
2969
|
if (!isRootStyleOutputFile(file)) {
|
|
@@ -2906,41 +2972,40 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2906
2972
|
if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
|
|
2907
2973
|
if (isViteProcessedCssResultImported(record, importedStyleFiles)) continue;
|
|
2908
2974
|
targetViteCssResults.push(record);
|
|
2909
|
-
let css = normalizeInjectableCssForTarget(require_hmr_timing.stripBundlerGeneratedCssMarkers(record.css).trim(), file).trim();
|
|
2910
|
-
css = removeCssCoveredByImportedViteResults(css, importedCssSources).trim();
|
|
2975
|
+
let css = measure("normalizeRecord", () => normalizeInjectableCssForTarget(require_hmr_timing.stripBundlerGeneratedCssMarkers(record.css).trim(), file).trim());
|
|
2976
|
+
css = measure("importCoverage", () => removeCssCoveredByImportedViteResults(css, importedCssSources, importedCssCoverage).trim());
|
|
2911
2977
|
if (css.length === 0) continue;
|
|
2912
|
-
const mergedLayerCss = require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
2978
|
+
const mergedLayerCss = measure("mergeLayers", () => require_hmr_timing.mergeMarkedUserLayerComponentsCss(nextCss, css));
|
|
2913
2979
|
if (mergedLayerCss.merged) {
|
|
2914
2980
|
nextCss = mergedLayerCss.css;
|
|
2915
2981
|
css = require_hmr_timing.extractMarkedUserLayerComponentsCss(css).rest.trim();
|
|
2916
2982
|
if (css.length === 0) continue;
|
|
2917
2983
|
}
|
|
2918
|
-
|
|
2919
|
-
if ((0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, css)) continue;
|
|
2920
|
-
const mergedPreflightDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css);
|
|
2984
|
+
const mergedPreflightDeclarations = measure("mergePreflight", () => (0, _weapp_tailwindcss_postcss.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css));
|
|
2921
2985
|
if (mergedPreflightDeclarations.changed) {
|
|
2922
2986
|
nextCss = mergedPreflightDeclarations.baseCss;
|
|
2923
2987
|
css = mergedPreflightDeclarations.css.trim();
|
|
2924
2988
|
if (css.length === 0) continue;
|
|
2925
2989
|
}
|
|
2926
|
-
const mergedThemeScopeDeclarations = (0, _weapp_tailwindcss_postcss.mergeMiniProgramThemeScopeRuleDeclarations)(nextCss, css);
|
|
2990
|
+
const mergedThemeScopeDeclarations = measure("mergeTheme", () => (0, _weapp_tailwindcss_postcss.mergeMiniProgramThemeScopeRuleDeclarations)(nextCss, css));
|
|
2927
2991
|
if (mergedThemeScopeDeclarations.changed) {
|
|
2928
2992
|
nextCss = mergedThemeScopeDeclarations.baseCss;
|
|
2929
2993
|
css = mergedThemeScopeDeclarations.css.trim();
|
|
2930
2994
|
if (css.length === 0) continue;
|
|
2931
2995
|
}
|
|
2932
|
-
const mergedRuleDeclarations = (0, _weapp_tailwindcss_postcss.mergeCoveredCssRuleDeclarations)(nextCss, css);
|
|
2996
|
+
const mergedRuleDeclarations = measure("mergeDeclarations", () => (0, _weapp_tailwindcss_postcss.mergeCoveredCssRuleDeclarations)(nextCss, css));
|
|
2933
2997
|
if (mergedRuleDeclarations.changed) {
|
|
2934
2998
|
nextCss = mergedRuleDeclarations.baseCss;
|
|
2935
2999
|
css = mergedRuleDeclarations.css.trim();
|
|
2936
3000
|
if (css.length === 0) continue;
|
|
2937
3001
|
}
|
|
2938
|
-
const missingCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css);
|
|
2939
|
-
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss)) continue;
|
|
3002
|
+
const missingCss = measure("filterRules", () => (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(nextCss, css));
|
|
3003
|
+
if (missingCss.length === 0 || !hasNonCommentCss(missingCss) || measure("containsMissing", () => (0, _weapp_tailwindcss_postcss.containsCssAfterMinify)(nextCss, missingCss))) continue;
|
|
2940
3004
|
nextCss = appendCss$1(nextCss, missingCss);
|
|
2941
3005
|
}
|
|
2942
3006
|
const finalImportedCssSources = collectImportedBundleCssSources(bundle, collectImportedStyleFiles(originalSource, file));
|
|
2943
|
-
|
|
3007
|
+
const finalImportedCssCoverage = prepareImportedCssCoverage(finalImportedCssSources);
|
|
3008
|
+
nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
|
|
2944
3009
|
if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
|
|
2945
3010
|
if (nextCss !== originalSource) {
|
|
2946
3011
|
output.source = nextCss;
|
|
@@ -2949,24 +3014,13 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
2949
3014
|
options.onUpdate?.(file, originalSource, nextCss);
|
|
2950
3015
|
options.debug?.("inject vite-processed css into main css asset: %s bytes=%d", file, nextCss.length);
|
|
2951
3016
|
}
|
|
2952
|
-
const removedSources = removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options);
|
|
3017
|
+
const removedSources = measure("removeSources", () => removeCoveredInjectedSourceAssets(bundle, file, nextCss, targetViteCssResults, options));
|
|
2953
3018
|
if (nextCss === originalSource && removedSources === 0) continue;
|
|
2954
3019
|
injected++;
|
|
2955
3020
|
}
|
|
2956
3021
|
return injected;
|
|
2957
3022
|
}
|
|
2958
3023
|
//#endregion
|
|
2959
|
-
//#region src/bundlers/vite/generate-bundle/bundle-file-names.ts
|
|
2960
|
-
function normalizeBundleFileNameKeysForTest(bundle) {
|
|
2961
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
2962
|
-
if (!output.fileName || output.fileName === file) continue;
|
|
2963
|
-
const existing = bundle[output.fileName];
|
|
2964
|
-
if (existing != null && existing !== output) continue;
|
|
2965
|
-
bundle[output.fileName] = output;
|
|
2966
|
-
delete bundle[file];
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
//#endregion
|
|
2970
3024
|
//#region src/bundlers/vite/generate-bundle/final-css-assets.ts
|
|
2971
3025
|
function readAssetSource$1(output) {
|
|
2972
3026
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
@@ -3149,6 +3203,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
3149
3203
|
...cssHandlerOptions,
|
|
3150
3204
|
isMainChunk: false
|
|
3151
3205
|
},
|
|
3206
|
+
frameworkPostcssStage: "complete",
|
|
3152
3207
|
getSourceCandidatesForEntries,
|
|
3153
3208
|
styleHandler,
|
|
3154
3209
|
debug
|
|
@@ -3218,7 +3273,7 @@ function pruneLastCssResults(resultByFile, sourceHashByFile, activeFiles) {
|
|
|
3218
3273
|
}
|
|
3219
3274
|
}
|
|
3220
3275
|
//#endregion
|
|
3221
|
-
//#region src/bundlers/vite/generate-bundle/finalize.ts
|
|
3276
|
+
//#region src/bundlers/vite/generate-bundle/finalize/root-import-shell.ts
|
|
3222
3277
|
function readAssetSource(asset) {
|
|
3223
3278
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
3224
3279
|
}
|
|
@@ -3307,6 +3362,8 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
3307
3362
|
}
|
|
3308
3363
|
return updated;
|
|
3309
3364
|
}
|
|
3365
|
+
//#endregion
|
|
3366
|
+
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
3310
3367
|
async function finalizeGenerateBundle(options) {
|
|
3311
3368
|
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
3312
3369
|
const tasksStart = performance.now();
|
|
@@ -3319,6 +3376,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3319
3376
|
await Promise.all(tasks);
|
|
3320
3377
|
recordTimingDetail("tasks", tasksStart);
|
|
3321
3378
|
for (const apply of pendingLinkedUpdates) apply();
|
|
3379
|
+
const uniAppXPostCssStartedAt = performance.now();
|
|
3322
3380
|
const applyStyleSources = await handleUniAppXPostCssTasks({
|
|
3323
3381
|
bundle,
|
|
3324
3382
|
debug,
|
|
@@ -3334,7 +3392,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3334
3392
|
runtimeState,
|
|
3335
3393
|
styleHandler
|
|
3336
3394
|
});
|
|
3395
|
+
recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
|
|
3337
3396
|
const syncViteProcessedCssIntoMainCssAssets = () => {
|
|
3397
|
+
const collectStartedAt = performance.now();
|
|
3338
3398
|
collectViteProcessedCssAssetResults(bundle, {
|
|
3339
3399
|
opts,
|
|
3340
3400
|
cssPipelineStrategy,
|
|
@@ -3348,7 +3408,9 @@ async function finalizeGenerateBundle(options) {
|
|
|
3348
3408
|
transformCss: transformWebTargetCss,
|
|
3349
3409
|
debug
|
|
3350
3410
|
});
|
|
3351
|
-
|
|
3411
|
+
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
3412
|
+
const injectStartedAt = performance.now();
|
|
3413
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
3352
3414
|
opts,
|
|
3353
3415
|
cssPipelineStrategy,
|
|
3354
3416
|
createCssPipelineContext,
|
|
@@ -3362,16 +3424,22 @@ async function finalizeGenerateBundle(options) {
|
|
|
3362
3424
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
3363
3425
|
},
|
|
3364
3426
|
debug,
|
|
3365
|
-
onUpdate
|
|
3427
|
+
onUpdate,
|
|
3428
|
+
recordTimingDetail
|
|
3366
3429
|
});
|
|
3430
|
+
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
3431
|
+
return injected;
|
|
3367
3432
|
};
|
|
3433
|
+
const processedCssStartedAt = performance.now();
|
|
3368
3434
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3369
3435
|
if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
|
|
3370
3436
|
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
|
|
3371
3437
|
syncViteProcessedCssIntoMainCssAssets();
|
|
3372
3438
|
}
|
|
3439
|
+
recordTimingDetail("finalize.processedCss", processedCssStartedAt);
|
|
3373
3440
|
const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
|
|
3374
3441
|
const finalizeCssPipelineContext = createFinalizeCssPipelineContext();
|
|
3442
|
+
const rootCssStartedAt = performance.now();
|
|
3375
3443
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
3376
3444
|
cssMatcher: opts.cssMatcher,
|
|
3377
3445
|
debug,
|
|
@@ -3400,6 +3468,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3400
3468
|
isWebGeneratorTarget,
|
|
3401
3469
|
outDir
|
|
3402
3470
|
}) === true) removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle, { debug });
|
|
3471
|
+
recordTimingDetail("finalize.rootCss", rootCssStartedAt);
|
|
3472
|
+
const finalCssAssetsStartedAt = performance.now();
|
|
3403
3473
|
await finalizeMiniProgramCssAssets(bundle, {
|
|
3404
3474
|
cssMatcher: opts.cssMatcher,
|
|
3405
3475
|
debug,
|
|
@@ -3410,6 +3480,8 @@ async function finalizeGenerateBundle(options) {
|
|
|
3410
3480
|
recordCssAssetResult,
|
|
3411
3481
|
styleHandler
|
|
3412
3482
|
});
|
|
3483
|
+
recordTimingDetail("finalize.cssAssets", finalCssAssetsStartedAt);
|
|
3484
|
+
const webCompatStartedAt = performance.now();
|
|
3413
3485
|
if (finalizeCssPipelineContext !== void 0 && cssPipelineStrategy?.shouldApplyFinalWebviewCssCompat?.({
|
|
3414
3486
|
...finalizeCssPipelineContext,
|
|
3415
3487
|
bundleFiles: Object.keys(bundle),
|
|
@@ -3421,6 +3493,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
3421
3493
|
opts,
|
|
3422
3494
|
recordCssAssetResult
|
|
3423
3495
|
});
|
|
3496
|
+
recordTimingDetail("finalize.webCompat", webCompatStartedAt);
|
|
3424
3497
|
const stateUpdateStart = performance.now();
|
|
3425
3498
|
require_source_candidate_scan_signature.updateBundleBuildState(state, snapshot, useIncrementalMode ? linkedByEntry ?? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map(), { incremental: useIncrementalMode });
|
|
3426
3499
|
state.generatorCandidateSignature = generatorCandidateSignature;
|
|
@@ -4237,6 +4310,7 @@ async function processRememberedCssReplay(options) {
|
|
|
4237
4310
|
outputFile,
|
|
4238
4311
|
cssHandlerOptions,
|
|
4239
4312
|
cssUserHandlerOptions: getCssUserHandlerOptions(sourceFile),
|
|
4313
|
+
frameworkPostcssStage: "complete",
|
|
4240
4314
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
4241
4315
|
generatorPlatform,
|
|
4242
4316
|
styleHandler,
|
|
@@ -4833,7 +4907,7 @@ function resolveViteWebCssCompatOptions(context) {
|
|
|
4833
4907
|
return context.currentGeneratorBranch.isWeb ? context.currentGeneratorOptions.webCompat : context.currentGeneratorOptions.webCompat ?? true;
|
|
4834
4908
|
}
|
|
4835
4909
|
//#endregion
|
|
4836
|
-
//#region src/bundlers/vite/generate-bundle.ts
|
|
4910
|
+
//#region src/bundlers/vite/generate-bundle-runtime.ts
|
|
4837
4911
|
function inferPlatformFromViteOutDir$1(outDir) {
|
|
4838
4912
|
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
4839
4913
|
if (!segment) return;
|
|
@@ -4843,7 +4917,7 @@ function inferPlatformFromViteOutDir$1(outDir) {
|
|
|
4843
4917
|
function hasTailwindPluginDirective(source) {
|
|
4844
4918
|
return /@plugin\b/.test(source);
|
|
4845
4919
|
}
|
|
4846
|
-
function createGenerateBundleHook(context) {
|
|
4920
|
+
function createGenerateBundleHook$1(context) {
|
|
4847
4921
|
const state = require_source_candidate_scan_signature.createBundleBuildState();
|
|
4848
4922
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
4849
4923
|
const lastCssSourceHashByFile = /* @__PURE__ */ new Map();
|
|
@@ -5152,16 +5226,16 @@ function createGenerateBundleHook(context) {
|
|
|
5152
5226
|
tailwindcssBasedir: opts.tailwindcssBasedir,
|
|
5153
5227
|
useIncrementalMode
|
|
5154
5228
|
});
|
|
5155
|
-
const createScopedGeneratorRuntime$1 = (outputFile,
|
|
5156
|
-
cssHandlerOptions,
|
|
5157
|
-
fallbackRuntime:
|
|
5229
|
+
const createScopedGeneratorRuntime$1 = (outputFile, cssHandlerOptions2, runtime2, rawSource, sourceFile) => require_source_candidate_scan_signature.createScopedGeneratorRuntime({
|
|
5230
|
+
cssHandlerOptions: cssHandlerOptions2,
|
|
5231
|
+
fallbackRuntime: runtime2,
|
|
5158
5232
|
getSourceCandidatesForEntries: getCombinedSourceCandidatesForEntries,
|
|
5159
5233
|
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
5160
5234
|
outputFile,
|
|
5161
5235
|
rawSource,
|
|
5162
5236
|
shouldExcludeSubpackageSourceCandidates,
|
|
5163
5237
|
sourceFile,
|
|
5164
|
-
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile,
|
|
5238
|
+
scopedSourceCandidateGetter: createScopedSourceCandidateGetter(outputFile, cssHandlerOptions2)
|
|
5165
5239
|
});
|
|
5166
5240
|
const jsEntries = snapshot.jsEntries;
|
|
5167
5241
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
@@ -5312,6 +5386,7 @@ function createGenerateBundleHook(context) {
|
|
|
5312
5386
|
const tasks = [];
|
|
5313
5387
|
const cssTaskFactories = [];
|
|
5314
5388
|
const jsTaskFactories = [];
|
|
5389
|
+
const entryPlanningStartedAt = performance.now();
|
|
5315
5390
|
for (const entry of snapshot.entries) {
|
|
5316
5391
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
5317
5392
|
if (processMarkupAndScripts && type === "html" && originalSource.type === "asset") {
|
|
@@ -5337,8 +5412,8 @@ function createGenerateBundleHook(context) {
|
|
|
5337
5412
|
originalEntrySource,
|
|
5338
5413
|
originalSource,
|
|
5339
5414
|
rememberProcessCacheKey,
|
|
5340
|
-
resolveCurrentSourceCandidateSource: (
|
|
5341
|
-
file,
|
|
5415
|
+
resolveCurrentSourceCandidateSource: (file2) => resolveCurrentSourceCandidateSource({
|
|
5416
|
+
file: file2,
|
|
5342
5417
|
getSourceCandidateSource,
|
|
5343
5418
|
getSourceCandidateSources,
|
|
5344
5419
|
outDir,
|
|
@@ -5358,7 +5433,7 @@ function createGenerateBundleHook(context) {
|
|
|
5358
5433
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
5359
5434
|
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, assetSourceFile, outDir, opts);
|
|
5360
5435
|
const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
|
|
5361
|
-
const
|
|
5436
|
+
const cssPipelineContext2 = {
|
|
5362
5437
|
...createInitialCssPipelineContext(file),
|
|
5363
5438
|
bundle
|
|
5364
5439
|
};
|
|
@@ -5370,7 +5445,7 @@ function createGenerateBundleHook(context) {
|
|
|
5370
5445
|
isWebGeneratorTarget,
|
|
5371
5446
|
matchesCss: opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file),
|
|
5372
5447
|
shouldKeep: () => context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5373
|
-
...
|
|
5448
|
+
...cssPipelineContext2,
|
|
5374
5449
|
css: rawSource,
|
|
5375
5450
|
file: rootImportShellOutputFile
|
|
5376
5451
|
})
|
|
@@ -5380,16 +5455,16 @@ function createGenerateBundleHook(context) {
|
|
|
5380
5455
|
if (importedFile && isRootMiniProgramStyleOutputFile$1(importedFile)) frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, importedFile);
|
|
5381
5456
|
}
|
|
5382
5457
|
if (!rememberedFrameworkRootImportTarget && !isCurrentFrameworkRootImportShell && !isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(file) && opts.mainCssChunkMatcher(rootImportShellOutputFile, opts.appType) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5383
|
-
...
|
|
5458
|
+
...cssPipelineContext2,
|
|
5384
5459
|
css: rawSource,
|
|
5385
5460
|
file: rootImportShellOutputFile
|
|
5386
5461
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5387
|
-
...
|
|
5462
|
+
...cssPipelineContext2,
|
|
5388
5463
|
file: rootImportShellOutputFile
|
|
5389
5464
|
}))) {
|
|
5390
5465
|
const rootGeneratedTargets = /* @__PURE__ */ new Set();
|
|
5391
|
-
for (const
|
|
5392
|
-
const targetFile = resolveMatchedCssSourceOutputFile(
|
|
5466
|
+
for (const entry2 of getConfiguredTailwindV4CssSourceEntries()) {
|
|
5467
|
+
const targetFile = resolveMatchedCssSourceOutputFile(entry2.file);
|
|
5393
5468
|
if (targetFile && isRootMiniProgramStyleOutputFile$1(targetFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootImportShellOutputFile)) rootGeneratedTargets.add(targetFile);
|
|
5394
5469
|
}
|
|
5395
5470
|
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) {
|
|
@@ -5413,11 +5488,11 @@ function createGenerateBundleHook(context) {
|
|
|
5413
5488
|
file,
|
|
5414
5489
|
isWebGeneratorTarget,
|
|
5415
5490
|
opts,
|
|
5416
|
-
pipelineContext:
|
|
5491
|
+
pipelineContext: cssPipelineContext2,
|
|
5417
5492
|
shouldPreserveAppCssExtension
|
|
5418
5493
|
});
|
|
5419
5494
|
if (rememberedFrameworkRootImportTarget && !isWebGeneratorTarget && (opts.cssMatcher(rootImportShellOutputFile) || opts.cssMatcher(file)) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5420
|
-
...
|
|
5495
|
+
...cssPipelineContext2,
|
|
5421
5496
|
css: rawSource,
|
|
5422
5497
|
file: rootImportShellOutputFile
|
|
5423
5498
|
}))) {
|
|
@@ -5430,7 +5505,7 @@ function createGenerateBundleHook(context) {
|
|
|
5430
5505
|
originalFileNames: originalSource.originalFileNames,
|
|
5431
5506
|
resolveOutputFileFromMatchedCssSource: resolveMatchedCssSourceOutputFile
|
|
5432
5507
|
});
|
|
5433
|
-
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((
|
|
5508
|
+
const configuredOriginalSourceEntry = outputFile.replace(/[?#].*$/, "").endsWith(".css") ? getConfiguredTailwindV4CssSourceEntries().find((entry2) => originalSource.originalFileNames?.some((originalFile) => normalizeConfiguredTailwindV4CssEntryFileKey(originalFile) === normalizeConfiguredTailwindV4CssEntryFileKey(entry2.file)) === true) : void 0;
|
|
5434
5509
|
const configuredOriginalOutputFile = configuredOriginalSourceEntry ? resolveMatchedOutputFileForCurrentAsset(configuredOriginalSourceEntry.file) : void 0;
|
|
5435
5510
|
let resolvedFromConfiguredOriginalCssEntry = false;
|
|
5436
5511
|
if (configuredOriginalOutputFile && require_source_candidate_scan_signature.normalizeOutputPathKey(configuredOriginalOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)) {
|
|
@@ -5455,7 +5530,7 @@ function createGenerateBundleHook(context) {
|
|
|
5455
5530
|
file,
|
|
5456
5531
|
originalSource,
|
|
5457
5532
|
outputFile,
|
|
5458
|
-
pipelineContext:
|
|
5533
|
+
pipelineContext: cssPipelineContext2,
|
|
5459
5534
|
source,
|
|
5460
5535
|
viteProcessedCssAsset
|
|
5461
5536
|
});
|
|
@@ -5531,7 +5606,7 @@ function createGenerateBundleHook(context) {
|
|
|
5531
5606
|
if (!hasUsableRememberedTailwindSource) {
|
|
5532
5607
|
const configuredTailwindV4CssSourceEntries = getConfiguredTailwindV4CssSourceEntries();
|
|
5533
5608
|
const isCurrentRootMiniProgramStyleOutput = opts.cssMatcher(outputFile) && isMiniProgramStyleOutputFile(outputFile) && !require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")).includes("/");
|
|
5534
|
-
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((
|
|
5609
|
+
const configuredEntriesForCurrentRootMiniProgramStyle = isCurrentRootMiniProgramStyleOutput && !hasTailwindGenerationSource(rawSource) ? configuredTailwindV4CssSourceEntries.filter((entry2) => hasTailwindPluginDirective(entry2.source)) : configuredTailwindV4CssSourceEntries;
|
|
5535
5610
|
if (isCurrentRootMiniProgramStyleOutput && (hasTailwindGenerationSource(rawSource) || configuredEntriesForCurrentRootMiniProgramStyle.length > 0)) {
|
|
5536
5611
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, configuredEntriesForCurrentRootMiniProgramStyle, rawSource, {
|
|
5537
5612
|
cwd: opts.tailwindcssBasedir,
|
|
@@ -5557,14 +5632,14 @@ function createGenerateBundleHook(context) {
|
|
|
5557
5632
|
}
|
|
5558
5633
|
}
|
|
5559
5634
|
if (!hasUsableRememberedTailwindSource) {
|
|
5560
|
-
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5635
|
+
const inferredSourceStyle = resolveSourceStyleSourceFromOutputFile(outputFile, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug);
|
|
5561
5636
|
const inferredWebviewRootSourceEntry = inferredSourceStyle ? void 0 : selectConfiguredRootCssSourceEntry(outputFile, configuredTailwindV4CssSourceEntries, originalSource.originalFileNames);
|
|
5562
5637
|
const inferredWebviewRootSourceStyle = inferredWebviewRootSourceEntry ? {
|
|
5563
5638
|
outputFile,
|
|
5564
5639
|
rawSource: inferredWebviewRootSourceEntry.source,
|
|
5565
5640
|
sourceFile: inferredWebviewRootSourceEntry.file
|
|
5566
5641
|
} : void 0;
|
|
5567
|
-
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((
|
|
5642
|
+
const inferredOriginalSourceStyle = inferredSourceStyle ?? (outputFile === file ? void 0 : resolveSourceStyleSourceFromOutputFile(file, snapshot, outDir, sourceRoot, getCssSource, getSourceCandidateSources, configuredTailwindV4CssSourceEntries.map((entry2) => [entry2.file, entry2.source]), debug)) ?? inferredWebviewRootSourceStyle;
|
|
5568
5643
|
if (inferredOriginalSourceStyle) {
|
|
5569
5644
|
const matchedOutputFile = require_source_candidate_scan_signature.normalizeOutputPathKey(inferredOriginalSourceStyle.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) ? outputFile : resolveMatchedOutputFileForCurrentAsset(inferredOriginalSourceStyle.sourceFile) ?? outputFile;
|
|
5570
5645
|
debug("source style output resolved: %s -> %s from %s", outputFile, matchedOutputFile, inferredOriginalSourceStyle.sourceFile);
|
|
@@ -5595,7 +5670,7 @@ function createGenerateBundleHook(context) {
|
|
|
5595
5670
|
debug("source style source inferred from temporary configured tailwind v4 css source: %s -> %s", outputFile, resolvedTemporarySource.sourceFile);
|
|
5596
5671
|
}
|
|
5597
5672
|
} else if (!isCurrentRootMiniProgramStyleOutput && hasTailwindGenerationSource(rawSource) && (originalSource.originalFileNames?.length ?? 0) === 0) {
|
|
5598
|
-
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((
|
|
5673
|
+
const availableConfiguredTailwindV4CssSourceEntries = configuredTailwindV4CssSourceEntries.filter((entry2) => !usedConfiguredTailwindV4CssSourceFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(entry2.file)));
|
|
5599
5674
|
const configuredGenerationSource = selectTailwindV4GenerationCssSourceForOutput(outputFile, availableConfiguredTailwindV4CssSourceEntries, rawSource, {
|
|
5600
5675
|
cwd: opts.tailwindcssBasedir,
|
|
5601
5676
|
outputRoot: outDir,
|
|
@@ -5637,11 +5712,11 @@ function createGenerateBundleHook(context) {
|
|
|
5637
5712
|
}
|
|
5638
5713
|
}
|
|
5639
5714
|
if (!isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(rootImportShellOutputFile) && isRootMiniProgramStyleOutputFile$1(outputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(rootImportShellOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) && shouldKeepRootMiniProgramStyleAsImportShell(context.cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
5640
|
-
...
|
|
5715
|
+
...cssPipelineContext2,
|
|
5641
5716
|
css: rawSource,
|
|
5642
5717
|
file: rootImportShellOutputFile
|
|
5643
5718
|
})) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(context.cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
5644
|
-
...
|
|
5719
|
+
...cssPipelineContext2,
|
|
5645
5720
|
file: rootImportShellOutputFile
|
|
5646
5721
|
}))) {
|
|
5647
5722
|
frameworkRootImportShellTargetByFile.set(rootImportShellOutputFile, outputFile);
|
|
@@ -5675,7 +5750,7 @@ function createGenerateBundleHook(context) {
|
|
|
5675
5750
|
usedConfiguredTailwindV4CssSourceFiles.add(require_source_candidate_scan_signature.normalizeOutputPathKey(generatorSourceFile));
|
|
5676
5751
|
temporaryCssAssetSourceResolver.markUsed(generatorSourceFile);
|
|
5677
5752
|
}
|
|
5678
|
-
const
|
|
5753
|
+
const cssHandlerOptions2 = vitePipelineCssAsset ? {
|
|
5679
5754
|
...getCssHandlerOptions(generatorSourceFile),
|
|
5680
5755
|
isMainChunk: resolvedFromTemporaryCssAsset ? false : outputCssHandlerOptions.isMainChunk
|
|
5681
5756
|
} : getCssHandlerOptions(file);
|
|
@@ -5684,9 +5759,9 @@ function createGenerateBundleHook(context) {
|
|
|
5684
5759
|
const shouldUsePipelineSourceAsCssEntry = !isExplicitGeneratorCssEntry && vitePipelineCssAsset && opts.cssMatcher(generatorSourceFile) && hasTailwindGenerationSource(generatorRawSource);
|
|
5685
5760
|
const generatorCssEntries = isExplicitGeneratorCssEntry || shouldUsePipelineSourceAsCssEntry ? [generatorSourceFile] : opts.cssEntries;
|
|
5686
5761
|
const generatorCssHandlerOptions = {
|
|
5687
|
-
...
|
|
5762
|
+
...cssHandlerOptions2,
|
|
5688
5763
|
sourceOptions: {
|
|
5689
|
-
...
|
|
5764
|
+
...cssHandlerOptions2.sourceOptions ?? {},
|
|
5690
5765
|
sourceFile: generatorSourceFile,
|
|
5691
5766
|
cssEntries: generatorCssEntries
|
|
5692
5767
|
}
|
|
@@ -5715,7 +5790,7 @@ function createGenerateBundleHook(context) {
|
|
|
5715
5790
|
const vitePipelineCssInjectionOutputFile = webviewRootCssInjectionTarget ?? outputFile;
|
|
5716
5791
|
const shouldRecordVitePipelineCssByOutput = require_source_candidate_scan_signature.normalizeOutputPathKey(vitePipelineCssInjectionOutputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
5717
5792
|
const shouldInjectVitePipelineCssIntoMain = vitePipelineCssAsset && !resolvedFromConfiguredOriginalCssEntry && outputCssHandlerOptions.isMainChunk !== true && (webviewRootCssInjectionTarget != null || shouldInjectCssIntoMainFromOutput(outputFile, generatorSourceFile, outputCssHandlerOptions));
|
|
5718
|
-
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode ||
|
|
5793
|
+
const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldRegenerateMainPackageCssWithScopedCandidates || hasCurrentTailwindGenerationDirective || hasSameOutputRememberedTailwindGenerationSource || shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions2.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) || shouldRegenerateCollectedViteCss || hasRuntimeAffectingChanges && (alreadyProcessedCssAsset || vitePipelineCssAsset));
|
|
5719
5794
|
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (state.generatorCandidateSignature === void 0 || !generatorCandidatesChanged) && (collectedBundlerGeneratedCssFiles.has(file) || require_hmr_timing.hasBundlerGeneratedCssMarker(rawSource));
|
|
5720
5795
|
const strippedViteProcessedCss = require_hmr_timing.stripBundlerGeneratedCssMarkers(rawSource);
|
|
5721
5796
|
const shouldPreserveStaleGeneratedCssAsset = hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && !strippedViteProcessedCss.includes("weapp-tailwindcss generator-placeholder") && !strippedViteProcessedCss.includes("vite-placeholder") && !hasTailwindGenerationSource(strippedViteProcessedCss) && !require_generator.hasTailwindApplyDirective(strippedViteProcessedCss);
|
|
@@ -5748,7 +5823,7 @@ function createGenerateBundleHook(context) {
|
|
|
5748
5823
|
}) : trackedGeneratorCandidateSignature;
|
|
5749
5824
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
5750
5825
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
|
|
5751
|
-
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${
|
|
5826
|
+
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}:${cssHandlerOptions2.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}:${sourceTraceSignature}`;
|
|
5752
5827
|
const cssCacheKey = outputFile;
|
|
5753
5828
|
const cssHashKey = `${outputFile}:css:${cssRuntimeSignature}:${runtimeState.tailwindRuntime.majorVersion ?? "unknown"}`;
|
|
5754
5829
|
const cssLinkedImpactSignature = runtimeLinkedCssFiles.has(file) || runtimeLinkedCssFiles.has(outputFile) ? [...[...snapshot.runtimeAffectingChangedByType.html].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? ""), ...[...snapshot.runtimeAffectingChangedByType.js].sort().map((changedFile) => snapshot.runtimeAffectingSignatureByFile.get(changedFile) ?? "")].join(":") : "";
|
|
@@ -5813,6 +5888,7 @@ function createGenerateBundleHook(context) {
|
|
|
5813
5888
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
5814
5889
|
getSourceCandidatesForEntries: scopedSourceCandidateGetter,
|
|
5815
5890
|
sourceCandidates: scopedGeneratorRuntime,
|
|
5891
|
+
frameworkPostcssStage: "complete",
|
|
5816
5892
|
generatorPlatform,
|
|
5817
5893
|
styleHandler,
|
|
5818
5894
|
debug,
|
|
@@ -5822,24 +5898,24 @@ function createGenerateBundleHook(context) {
|
|
|
5822
5898
|
}) : void 0;
|
|
5823
5899
|
if (generated) {
|
|
5824
5900
|
const outputCss = transformWebTargetCss(generated.css);
|
|
5825
|
-
const
|
|
5901
|
+
const tracedCss2 = removeRootCoveredCssFromScopedAsset(annotateCss(outputCss));
|
|
5826
5902
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
5827
|
-
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource,
|
|
5828
|
-
debug("css generated result: %s bytes=%d", file,
|
|
5903
|
+
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorRawSource, tracedCss2));
|
|
5904
|
+
debug("css generated result: %s bytes=%d", file, tracedCss2.length);
|
|
5829
5905
|
for (const candidate of generated.classSet ?? []) transformRuntime.add(candidate);
|
|
5830
|
-
recordCssAssetResult?.(outputFile,
|
|
5831
|
-
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile,
|
|
5906
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5907
|
+
if (shouldRecordVitePipelineCssByOutput) recordViteProcessedCssAssetResult?.(vitePipelineCssInjectionOutputFile, tracedCss2, {
|
|
5832
5908
|
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectVitePipelineCssIntoMain,
|
|
5833
5909
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5834
5910
|
});
|
|
5835
|
-
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file,
|
|
5911
|
+
if (vitePipelineCssAsset && shouldInjectVitePipelineCssIntoMain) recordViteProcessedCssAssetResult?.(file, tracedCss2, {
|
|
5836
5912
|
injectIntoMain: shouldInjectVitePipelineCssIntoMain,
|
|
5837
5913
|
outputFile: vitePipelineCssInjectionOutputFile
|
|
5838
5914
|
});
|
|
5839
5915
|
metrics.css.elapsed += measureElapsed(start);
|
|
5840
5916
|
metrics.css.transformed++;
|
|
5841
5917
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, outputFile);
|
|
5842
|
-
return
|
|
5918
|
+
return tracedCss2;
|
|
5843
5919
|
}
|
|
5844
5920
|
if (isWebGeneratorTarget) {
|
|
5845
5921
|
const outputCss = transformWebTargetCss(rawSource);
|
|
@@ -5849,15 +5925,15 @@ function createGenerateBundleHook(context) {
|
|
|
5849
5925
|
return annotateCss(outputCss);
|
|
5850
5926
|
}
|
|
5851
5927
|
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(generatorTransformRawSource)) {
|
|
5852
|
-
const
|
|
5853
|
-
recordCssAssetResult?.(outputFile,
|
|
5928
|
+
const tracedCss2 = annotateCss(generatorTransformRawSource);
|
|
5929
|
+
recordCssAssetResult?.(outputFile, tracedCss2);
|
|
5854
5930
|
metrics.css.elapsed += measureElapsed(start);
|
|
5855
5931
|
metrics.css.transformed++;
|
|
5856
5932
|
debug("css preserve mini-program import shell: %s", outputFile);
|
|
5857
|
-
return
|
|
5933
|
+
return tracedCss2;
|
|
5858
5934
|
}
|
|
5859
|
-
const { css } = await styleHandler(generatorTransformRawSource,
|
|
5860
|
-
const tracedCss = annotateCss(
|
|
5935
|
+
const { css: css2 } = await styleHandler(generatorTransformRawSource, cssHandlerOptions2);
|
|
5936
|
+
const tracedCss = annotateCss(css2);
|
|
5861
5937
|
if (envFlags.debugCssDiff) debug("css diff %s: %s", generatorSourceFile, require_source_candidate_scan_signature.summarizeStringDiff(generatorTransformRawSource, tracedCss));
|
|
5862
5938
|
metrics.css.elapsed += measureElapsed(start);
|
|
5863
5939
|
metrics.css.transformed++;
|
|
@@ -5908,6 +5984,8 @@ function createGenerateBundleHook(context) {
|
|
|
5908
5984
|
useIncrementalMode
|
|
5909
5985
|
});
|
|
5910
5986
|
}
|
|
5987
|
+
recordTimingDetail("entries.plan", entryPlanningStartedAt);
|
|
5988
|
+
const rememberedCssStartedAt = performance.now();
|
|
5911
5989
|
if (processStyles && (shouldProcessTailwindGeneration || useIncrementalMode || isNativeAppStyleTarget)) await processRememberedCssReplay({
|
|
5912
5990
|
addWatchFile,
|
|
5913
5991
|
activeViteCssCacheFiles,
|
|
@@ -5953,6 +6031,7 @@ function createGenerateBundleHook(context) {
|
|
|
5953
6031
|
timeTask,
|
|
5954
6032
|
useIncrementalMode
|
|
5955
6033
|
});
|
|
6034
|
+
recordTimingDetail("rememberedCss.plan", rememberedCssStartedAt);
|
|
5956
6035
|
await finalizeGenerateBundle({
|
|
5957
6036
|
activeProcessCacheKeys,
|
|
5958
6037
|
activeProcessHashKeys,
|
|
@@ -6014,7 +6093,12 @@ function createGenerateBundleHook(context) {
|
|
|
6014
6093
|
};
|
|
6015
6094
|
}
|
|
6016
6095
|
//#endregion
|
|
6017
|
-
//#region src/bundlers/vite/
|
|
6096
|
+
//#region src/bundlers/vite/generate-bundle.ts
|
|
6097
|
+
function createGenerateBundleHook(context) {
|
|
6098
|
+
return createGenerateBundleHook$1(context);
|
|
6099
|
+
}
|
|
6100
|
+
//#endregion
|
|
6101
|
+
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
6018
6102
|
function inferPlatformFromViteOutDir(outDir) {
|
|
6019
6103
|
const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
|
|
6020
6104
|
if (!segment) return;
|
|
@@ -6076,6 +6160,8 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
|
6076
6160
|
shouldApplyWebCssCompat
|
|
6077
6161
|
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
6078
6162
|
}
|
|
6163
|
+
//#endregion
|
|
6164
|
+
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6079
6165
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6080
6166
|
return {
|
|
6081
6167
|
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
@@ -6190,6 +6276,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6190
6276
|
...harmonyCssHandlerOptions,
|
|
6191
6277
|
isMainChunk: false
|
|
6192
6278
|
},
|
|
6279
|
+
frameworkPostcssStage: "complete",
|
|
6193
6280
|
getSourceCandidatesForEntries,
|
|
6194
6281
|
generatorPlatform,
|
|
6195
6282
|
styleHandler: opts.styleHandler,
|
|
@@ -6285,6 +6372,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6285
6372
|
outputFile: file,
|
|
6286
6373
|
cssHandlerOptions: generatorCssHandlerOptions,
|
|
6287
6374
|
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
6375
|
+
frameworkPostcssStage: "complete",
|
|
6288
6376
|
getSourceCandidatesForEntries,
|
|
6289
6377
|
generatorPlatform,
|
|
6290
6378
|
styleHandler: opts.styleHandler,
|
|
@@ -6862,7 +6950,11 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
6862
6950
|
if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
|
|
6863
6951
|
const shouldGenerateInPreTransform = !options.shouldDeferGeneration?.(id, normalizedCode) && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode));
|
|
6864
6952
|
if (options.shouldOwnTailwindGeneration && shouldGenerateInPreTransform) {
|
|
6865
|
-
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode,
|
|
6953
|
+
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, {
|
|
6954
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
6955
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
6956
|
+
frameworkPostcssStage: "pending"
|
|
6957
|
+
});
|
|
6866
6958
|
if (generatedCss !== void 0) return {
|
|
6867
6959
|
code: generatedCss,
|
|
6868
6960
|
map: null
|
|
@@ -7077,7 +7169,11 @@ function createViteCssGenerationPlugins(options) {
|
|
|
7077
7169
|
if (!require_generator.hasTailwindRootDirectives(code)) return;
|
|
7078
7170
|
if (DEFERRED_CSS_HMR_QUERY_RE.test(id)) return;
|
|
7079
7171
|
await options.onTailwindRootCss?.(id, code);
|
|
7080
|
-
const generatedCss = await options.generateCss(id, code,
|
|
7172
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7173
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7174
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7175
|
+
frameworkPostcssStage: "pending"
|
|
7176
|
+
});
|
|
7081
7177
|
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7082
7178
|
return {
|
|
7083
7179
|
code: generatedCss,
|
|
@@ -7093,7 +7189,11 @@ function createViteCssGenerationPlugins(options) {
|
|
|
7093
7189
|
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
7094
7190
|
if (!hasViteCssGenerationDirective(code)) return;
|
|
7095
7191
|
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
7096
|
-
const generatedCss = await options.generateCss(id, code,
|
|
7192
|
+
const generatedCss = await options.generateCss(id, code, {
|
|
7193
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7194
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7195
|
+
frameworkPostcssStage: "pending"
|
|
7196
|
+
});
|
|
7097
7197
|
if (generatedCss === void 0 || generatedCss === code) return;
|
|
7098
7198
|
return {
|
|
7099
7199
|
code: generatedCss,
|
|
@@ -7111,7 +7211,11 @@ function createViteCssGenerationPlugins(options) {
|
|
|
7111
7211
|
if (!extracted) return;
|
|
7112
7212
|
if (!hasViteCssGenerationDirective(extracted.css)) return;
|
|
7113
7213
|
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
7114
|
-
const generatedCss = await options.generateCss(id, extracted.css,
|
|
7214
|
+
const generatedCss = await options.generateCss(id, extracted.css, {
|
|
7215
|
+
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
7216
|
+
...this.emitFile ? { emitFile: this.emitFile.bind(this) } : {},
|
|
7217
|
+
frameworkPostcssStage: "complete"
|
|
7218
|
+
});
|
|
7115
7219
|
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
7116
7220
|
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
7117
7221
|
if (nextCode === void 0 || nextCode === code) return;
|
|
@@ -7220,7 +7324,7 @@ function wrapViteCssPostTransform(config, transformCss) {
|
|
|
7220
7324
|
return true;
|
|
7221
7325
|
}
|
|
7222
7326
|
//#endregion
|
|
7223
|
-
//#region src/bundlers/vite/shared/create-framework-plugins.ts
|
|
7327
|
+
//#region src/bundlers/vite/shared/create-framework-plugins-runtime.ts
|
|
7224
7328
|
const debug = require_wxml.createDebug();
|
|
7225
7329
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
7226
7330
|
const weappTailwindcssDirPosix = require_source_candidate_scan_signature.slash(weappTailwindcssPackageDir);
|
|
@@ -7263,10 +7367,7 @@ function isWebOrNativeAppPlatform(platform) {
|
|
|
7263
7367
|
function isInternalUserDefinedOptions(options) {
|
|
7264
7368
|
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
7265
7369
|
}
|
|
7266
|
-
|
|
7267
|
-
* Vite 各框架分支共享的组合工厂。框架分支只负责选择和拥有各自入口,公共稳定能力放在这里复用。
|
|
7268
|
-
*/
|
|
7269
|
-
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
7370
|
+
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
7270
7371
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
7271
7372
|
const rawOptions = options.__internalViteRawOptions ?? options;
|
|
7272
7373
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
@@ -7362,7 +7463,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7362
7463
|
await sourceCandidateCollector.syncCss(id, css);
|
|
7363
7464
|
cacheCurrentSourceCandidateScan();
|
|
7364
7465
|
};
|
|
7365
|
-
const registerAutoCssSource = async (id, css,
|
|
7466
|
+
const registerAutoCssSource = async (id, css, options2 = {}) => {
|
|
7366
7467
|
if (!shouldOwnTailwindGeneration) return;
|
|
7367
7468
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
7368
7469
|
if (!node_path.default.isAbsolute(file)) return;
|
|
@@ -7396,7 +7497,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7396
7497
|
})) return;
|
|
7397
7498
|
invalidateSourceCandidateScan();
|
|
7398
7499
|
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
7399
|
-
if (
|
|
7500
|
+
if (options2.refresh === false) return;
|
|
7400
7501
|
autoCssSourcesRefresh = (autoCssSourcesRefresh ?? Promise.resolve()).then(async () => {
|
|
7401
7502
|
await refreshRuntimeStateForAutoCssSources?.(true);
|
|
7402
7503
|
await syncSourceCandidateScan({ force: true });
|
|
@@ -7502,8 +7603,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7502
7603
|
recordedGeneratorCandidates = void 0;
|
|
7503
7604
|
};
|
|
7504
7605
|
const getSourceCandidates = () => sourceCandidateCollector.values();
|
|
7505
|
-
const getSourceCandidatesForEntries = (entries,
|
|
7506
|
-
const getSourceCandidateSourcesForEntries = (entries,
|
|
7606
|
+
const getSourceCandidatesForEntries = (entries, options2) => sourceCandidateCollector.valuesForEntries(entries, options2);
|
|
7607
|
+
const getSourceCandidateSourcesForEntries = (entries, options2) => sourceCandidateCollector.sourcesForEntries(entries, options2);
|
|
7507
7608
|
const isWatchBuild = () => resolvedConfig?.command === "build" && resolvedConfig.build.watch != null;
|
|
7508
7609
|
const isWatchLikeBuild = () => isWatchBuild() || resolvedConfig?.command === "serve" || node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
7509
7610
|
const isCurrentWebLikeStylePlatform = () => {
|
|
@@ -7543,10 +7644,10 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7543
7644
|
}
|
|
7544
7645
|
pendingHmrCssTargetFiles = collectPendingHmrCssTargetFiles(cssModules, fallbackCssIds);
|
|
7545
7646
|
};
|
|
7546
|
-
const createViteSourceCandidateChange = (file, change,
|
|
7647
|
+
const createViteSourceCandidateChange = (file, change, options2 = {}) => ({
|
|
7547
7648
|
...change,
|
|
7548
7649
|
file,
|
|
7549
|
-
runtimeAffecting:
|
|
7650
|
+
runtimeAffecting: options2.runtimeAffecting === true || require_hmr_timing.isSourceStyleRequest(file) || hasWebHmrRuntimeAffectingDirectives(sourceCandidateCollector.source(file))
|
|
7550
7651
|
});
|
|
7551
7652
|
const clearPendingHmrCandidateChange = () => {
|
|
7552
7653
|
pendingHmrCandidateChange = void 0;
|
|
@@ -7649,8 +7750,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7649
7750
|
};
|
|
7650
7751
|
const cacheCurrentSourceCandidateScan = () => {
|
|
7651
7752
|
if (sourceCandidateScanSignature) {
|
|
7652
|
-
|
|
7653
|
-
|
|
7753
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7754
|
+
sourceCandidateScanCache.set(sourceCandidateScanSignature, snapshot);
|
|
7755
|
+
sourceCandidateScanSnapshotCache.set(sourceCandidateScanSignature, snapshot);
|
|
7654
7756
|
}
|
|
7655
7757
|
};
|
|
7656
7758
|
const shouldDiscoverAutoCssSources = () => {
|
|
@@ -7658,9 +7760,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7658
7760
|
if (!isWatchLikeBuild()) return true;
|
|
7659
7761
|
return sourceCandidateScanInvalidated;
|
|
7660
7762
|
};
|
|
7661
|
-
async function syncSourceCandidateScan(
|
|
7763
|
+
async function syncSourceCandidateScan(options2 = {}) {
|
|
7662
7764
|
if (!shouldOwnTailwindGeneration) return;
|
|
7663
|
-
if (!
|
|
7765
|
+
if (!options2.force && isWatchLikeBuild() && hasSourceCandidateScanState() && !sourceCandidateScanInvalidated) {
|
|
7664
7766
|
debug("reuse vite source candidate scan definition for watch rebuild");
|
|
7665
7767
|
return;
|
|
7666
7768
|
}
|
|
@@ -7703,8 +7805,9 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7703
7805
|
sourceCandidateScanSignature = nextScanSignature;
|
|
7704
7806
|
sourceCandidateScanInvalidated = false;
|
|
7705
7807
|
if (isWatchLikeBuild()) {
|
|
7706
|
-
|
|
7707
|
-
|
|
7808
|
+
const snapshot = sourceCandidateCollector.snapshot();
|
|
7809
|
+
sourceCandidateScanCache.set(nextScanSignature, snapshot);
|
|
7810
|
+
sourceCandidateScanSnapshotCache.set(nextScanSignature, snapshot);
|
|
7708
7811
|
}
|
|
7709
7812
|
}
|
|
7710
7813
|
const waitForSourceCandidateSyncs = async () => {
|
|
@@ -7746,14 +7849,14 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7746
7849
|
const recordCssAssetResult = (file, css) => {
|
|
7747
7850
|
touchMapEntry(cleanGeneratedCssByFile, normalizeVitePersistentCacheKey(file), css);
|
|
7748
7851
|
};
|
|
7749
|
-
const recordViteProcessedCssAssetResult = (file, css,
|
|
7852
|
+
const recordViteProcessedCssAssetResult = (file, css, options2 = {}) => {
|
|
7750
7853
|
const key = normalizeVitePersistentCacheKey(file);
|
|
7751
7854
|
const previous = viteProcessedCssAssetResults.get(key);
|
|
7752
|
-
const injectIntoMain = previous?.injectIntoMain === true ? true :
|
|
7855
|
+
const injectIntoMain = previous?.injectIntoMain === true ? true : options2.injectIntoMain ?? previous?.injectIntoMain;
|
|
7753
7856
|
touchMapEntry(viteProcessedCssAssetResults, key, {
|
|
7754
7857
|
css,
|
|
7755
7858
|
injectIntoMain,
|
|
7756
|
-
outputFile:
|
|
7859
|
+
outputFile: options2.outputFile ?? previous?.outputFile
|
|
7757
7860
|
});
|
|
7758
7861
|
};
|
|
7759
7862
|
const getViteProcessedCssAssetResults = () => viteProcessedCssAssetResults.entries();
|
|
@@ -7771,8 +7874,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7771
7874
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
7772
7875
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size
|
|
7773
7876
|
});
|
|
7774
|
-
const pruneViteCssCaches = (
|
|
7775
|
-
const activeFiles = new Set([...
|
|
7877
|
+
const pruneViteCssCaches = (options2) => {
|
|
7878
|
+
const activeFiles = new Set([...options2.activeFiles].map(normalizeVitePersistentCacheKey));
|
|
7776
7879
|
for (const key of cleanGeneratedCssByFile.keys()) if (!activeFiles.has(key)) cleanGeneratedCssByFile.delete(key);
|
|
7777
7880
|
for (const key of tracedGeneratedCssByFile.keys()) if (!activeFiles.has(key)) tracedGeneratedCssByFile.delete(key);
|
|
7778
7881
|
for (const key of generatedClassSetByFile.keys()) if (!activeFiles.has(key)) generatedClassSetByFile.delete(key);
|
|
@@ -7780,7 +7883,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7780
7883
|
const outputKey = typeof record.outputFile === "string" ? normalizeVitePersistentCacheKey(record.outputFile) : void 0;
|
|
7781
7884
|
if (!activeFiles.has(key) && (outputKey == null || !activeFiles.has(outputKey))) viteProcessedCssAssetResults.delete(key);
|
|
7782
7885
|
}
|
|
7783
|
-
cssMemory.prune(
|
|
7886
|
+
cssMemory.prune(options2);
|
|
7784
7887
|
};
|
|
7785
7888
|
const normalizeViteProcessedCssFile = (file) => node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
7786
7889
|
const markViteProcessedCssSource = (file) => {
|
|
@@ -7896,7 +7999,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7896
7999
|
const previousTracedCss = tracedGeneratedCssByFile.get(fileKey);
|
|
7897
8000
|
if (previousTracedCss !== void 0) {
|
|
7898
8001
|
finishPendingHmrCssTargetFile(file);
|
|
7899
|
-
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8002
|
+
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8003
|
+
${previousTracedCss}`;
|
|
7900
8004
|
}
|
|
7901
8005
|
}
|
|
7902
8006
|
const sourceCssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(requestFile);
|
|
@@ -7936,6 +8040,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7936
8040
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
7937
8041
|
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7938
8042
|
disableSourceScan: false,
|
|
8043
|
+
frameworkPostcssStage: hookContext?.frameworkPostcssStage,
|
|
7939
8044
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
7940
8045
|
}), {
|
|
7941
8046
|
file,
|
|
@@ -7995,7 +8100,8 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
7995
8100
|
sourceFile: requestFile
|
|
7996
8101
|
});
|
|
7997
8102
|
debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
|
|
7998
|
-
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8103
|
+
return `${require_hmr_timing.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
8104
|
+
${tracedCss}`;
|
|
7999
8105
|
};
|
|
8000
8106
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
8001
8107
|
getAppType: () => opts.appType,
|
|
@@ -8283,14 +8389,16 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8283
8389
|
replacement: node_path.default.join(weappTailwindcssPackageDir, "generator-placeholder.css")
|
|
8284
8390
|
}] } };
|
|
8285
8391
|
if (config.css?.postcss !== void 0) return baseConfig;
|
|
8286
|
-
return (0, _weapp_tailwindcss_postcss.
|
|
8392
|
+
return (0, _weapp_tailwindcss_postcss.resolvePostcssConfig)(root).then((postcssConfig) => {
|
|
8287
8393
|
if (!postcssConfig) return baseConfig;
|
|
8288
|
-
|
|
8394
|
+
const plugins2 = [...postcssConfig.plugins];
|
|
8395
|
+
const removed = (0, _weapp_tailwindcss_postcss.removeTailwindPostcssPlugins)(plugins2);
|
|
8396
|
+
if (removed > 0) debug("inline filtered postcss config without official tailwind plugins in generator mode: %d", removed);
|
|
8289
8397
|
return {
|
|
8290
8398
|
...baseConfig,
|
|
8291
8399
|
css: { postcss: {
|
|
8292
8400
|
...postcssConfig.options,
|
|
8293
|
-
plugins:
|
|
8401
|
+
plugins: plugins2
|
|
8294
8402
|
} }
|
|
8295
8403
|
};
|
|
8296
8404
|
});
|
|
@@ -8335,6 +8443,7 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8335
8443
|
}
|
|
8336
8444
|
}
|
|
8337
8445
|
}
|
|
8446
|
+
require_source_candidate_scan_signature.captureFrameworkPostcssOptions(opts, config.css?.postcss && typeof config.css.postcss === "object" ? config.css.postcss : void 0);
|
|
8338
8447
|
}, { emit: false });
|
|
8339
8448
|
},
|
|
8340
8449
|
generateBundle: {
|
|
@@ -8349,6 +8458,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8349
8458
|
return plugins;
|
|
8350
8459
|
}
|
|
8351
8460
|
//#endregion
|
|
8461
|
+
//#region src/bundlers/vite/shared/create-framework-plugins.ts
|
|
8462
|
+
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
8463
|
+
return createViteFrameworkPlugins$1(options, frameworkBranch);
|
|
8464
|
+
}
|
|
8465
|
+
//#endregion
|
|
8352
8466
|
//#region src/bundlers/vite/frameworks/generic/index.ts
|
|
8353
8467
|
function createGenericVitePlugins(options = {}) {
|
|
8354
8468
|
return createViteFrameworkPlugins(options, {
|