weapp-tailwindcss 5.0.0-next.32 → 5.0.0-next.35
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/{bundle-state-C4ib5xPG.js → bundle-state-8w8DM8Lw.js} +1 -1
- package/dist/{bundle-state-BIsgsoNW.mjs → bundle-state-Bsr05EFW.mjs} +1 -1
- package/dist/bundlers/shared/cache.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
- package/dist/cli.js +9 -10
- package/dist/cli.mjs +10 -11
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-BEXaaUzP.js → generator-BtpQoQEH.js} +1 -1
- package/dist/{generator-CpsHA4Wd.mjs → generator-CmLpVJgw.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-D2fsgk5t.mjs → incremental-runtime-class-set-W61zZU00.mjs} +72 -10
- package/dist/{incremental-runtime-class-set-CLP1Qv8F.js → incremental-runtime-class-set-vqTU-eph.js} +77 -9
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/replacement-cache.d.ts +5 -0
- package/dist/{postcss-BvkdIZr8.mjs → postcss-DGprmeke.mjs} +2 -2
- package/dist/{postcss-DN7IQzYb.js → postcss-DSvNrY0J.js} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-CQeqnfo5.js → precheck-Bp-V1T_Q.js} +12 -12
- package/dist/{precheck-nITnYBDn.mjs → precheck-nPDKYr8V.mjs} +13 -13
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-7Q-kTOSb.js → source-candidates-BjB4wSga.js} +1 -1
- package/dist/{source-candidates-_x8bq0Mz.mjs → source-candidates-l12JBkKU.mjs} +1 -1
- package/dist/{tailwindcss-udhXxMX9.mjs → tailwindcss-D6zEhnyE.mjs} +1 -1
- package/dist/{tailwindcss-Cl7hUlYV.js → tailwindcss-bNXguXhC.js} +1 -1
- package/dist/{v3-engine-C_KeUQG3.mjs → v3-engine-BYcGCWUY.mjs} +33 -0
- package/dist/{v3-engine-DwY4Fixu.js → v3-engine-KDOfD-6F.js} +33 -0
- package/dist/{vite-BAHjBu8j.mjs → vite-C8SUICPv.mjs} +103 -42
- package/dist/{vite-CYkkJZ3Q.js → vite-CMzi0wR2.js} +103 -42
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +33 -1
- package/dist/{webpack-CPwDaKy3.js → webpack-2v1sQKyZ.js} +65 -29
- package/dist/{webpack-xxmiRxcy.mjs → webpack-pdpdIv_X.mjs} +65 -29
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-KDOfD-6F.js");
|
|
3
|
+
const require_generator = require("./generator-BtpQoQEH.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-vqTU-eph.js");
|
|
5
|
+
const require_precheck = require("./precheck-Bp-V1T_Q.js");
|
|
6
6
|
const require_utils = require("./utils-D7Ygohep.js");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_source_candidates = require("./source-candidates-
|
|
9
|
-
const require_bundle_state = require("./bundle-state-
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-bNXguXhC.js");
|
|
8
|
+
const require_source_candidates = require("./source-candidates-BjB4wSga.js");
|
|
9
|
+
const require_bundle_state = require("./bundle-state-8w8DM8Lw.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -17,10 +17,10 @@ node_process = require_chunk.__toESM(node_process);
|
|
|
17
17
|
let node_path = require("node:path");
|
|
18
18
|
node_path = require_chunk.__toESM(node_path);
|
|
19
19
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
20
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
20
21
|
let node_fs_promises = require("node:fs/promises");
|
|
21
22
|
let magic_string = require("magic-string");
|
|
22
23
|
magic_string = require_chunk.__toESM(magic_string);
|
|
23
|
-
let _weapp_tailwindcss_shared_extractors = require("@weapp-tailwindcss/shared/extractors");
|
|
24
24
|
let _weapp_tailwindcss_postcss_html_transform = require("@weapp-tailwindcss/postcss/html-transform");
|
|
25
25
|
_weapp_tailwindcss_postcss_html_transform = require_chunk.__toESM(_weapp_tailwindcss_postcss_html_transform);
|
|
26
26
|
let comment_json = require("comment-json");
|
|
@@ -21916,14 +21916,11 @@ function createStableHash(input) {
|
|
|
21916
21916
|
return (hash >>> 0).toString(36);
|
|
21917
21917
|
}
|
|
21918
21918
|
function extractLiteralValue(path) {
|
|
21919
|
-
const allowDoubleQuotes = path.isTemplateElement();
|
|
21920
21919
|
if (path.isStringLiteral()) return {
|
|
21921
|
-
allowDoubleQuotes,
|
|
21922
21920
|
literal: path.node.value,
|
|
21923
21921
|
offset: 1
|
|
21924
21922
|
};
|
|
21925
21923
|
return {
|
|
21926
|
-
allowDoubleQuotes,
|
|
21927
21924
|
literal: typeof path.node.value === "string" ? path.node.value : path.node.value.raw,
|
|
21928
21925
|
offset: 0
|
|
21929
21926
|
};
|
|
@@ -21955,7 +21952,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21955
21952
|
return alias;
|
|
21956
21953
|
}
|
|
21957
21954
|
rewriteLiteral(literal, shouldInclude) {
|
|
21958
|
-
const candidates = (0,
|
|
21955
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
21959
21956
|
if (candidates.length === 0) return literal;
|
|
21960
21957
|
let rewritten = literal;
|
|
21961
21958
|
for (const candidate of candidates) {
|
|
@@ -21975,8 +21972,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21975
21972
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
21976
21973
|
}), {}, void 0, false);
|
|
21977
21974
|
for (const path of analysis.targetPaths) {
|
|
21978
|
-
const { literal
|
|
21979
|
-
const candidates = (0,
|
|
21975
|
+
const { literal } = extractLiteralValue(path);
|
|
21976
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
21980
21977
|
const classContext = options.wrapExpression || require_precheck.isClassContextLiteralPath(path);
|
|
21981
21978
|
for (const candidate of candidates) {
|
|
21982
21979
|
if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
@@ -21996,8 +21993,8 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
21996
21993
|
if (analysis.targetPaths.length === 0) return rawSource;
|
|
21997
21994
|
const updater = new require_precheck.JsTokenUpdater();
|
|
21998
21995
|
for (const path of analysis.targetPaths) {
|
|
21999
|
-
const { literal,
|
|
22000
|
-
const candidates = (0,
|
|
21996
|
+
const { literal, offset } = extractLiteralValue(path);
|
|
21997
|
+
const candidates = (0, tailwindcss_patch.splitCandidateTokens)(literal);
|
|
22001
21998
|
if (candidates.length === 0) continue;
|
|
22002
21999
|
let rewritten = literal;
|
|
22003
22000
|
let mutated = false;
|
|
@@ -22552,19 +22549,60 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
22552
22549
|
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
22553
22550
|
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
22554
22551
|
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
22552
|
+
const CLASS_ATTRIBUTE_RE = /\bclass\s*=\s*/g;
|
|
22553
|
+
const MUSTACHE_OPEN = "{{";
|
|
22554
|
+
const MUSTACHE_CLOSE = "}}";
|
|
22555
|
+
function isUrlLikeCandidate(candidate) {
|
|
22556
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
22557
|
+
}
|
|
22555
22558
|
function isArbitraryValueCandidate(candidate) {
|
|
22556
|
-
return candidate.includes("[") && candidate.includes("]");
|
|
22559
|
+
return candidate.includes("[") && candidate.includes("]") && !isUrlLikeCandidate(candidate.trim());
|
|
22557
22560
|
}
|
|
22558
|
-
function
|
|
22561
|
+
function collectClassAttributeValues(source) {
|
|
22562
|
+
const values = [];
|
|
22563
|
+
CLASS_ATTRIBUTE_RE.lastIndex = 0;
|
|
22564
|
+
let matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22565
|
+
while (matched !== null) {
|
|
22566
|
+
const quoteIndex = CLASS_ATTRIBUTE_RE.lastIndex;
|
|
22567
|
+
const quote = source[quoteIndex];
|
|
22568
|
+
if (quote !== "\"" && quote !== "'") {
|
|
22569
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22570
|
+
continue;
|
|
22571
|
+
}
|
|
22572
|
+
let expressionDepth = 0;
|
|
22573
|
+
for (let index = quoteIndex + 1; index < source.length; index++) {
|
|
22574
|
+
if (source.startsWith(MUSTACHE_OPEN, index)) {
|
|
22575
|
+
expressionDepth++;
|
|
22576
|
+
index += 1;
|
|
22577
|
+
continue;
|
|
22578
|
+
}
|
|
22579
|
+
if (expressionDepth > 0 && source.startsWith(MUSTACHE_CLOSE, index)) {
|
|
22580
|
+
expressionDepth--;
|
|
22581
|
+
index += 1;
|
|
22582
|
+
continue;
|
|
22583
|
+
}
|
|
22584
|
+
if (expressionDepth === 0 && source[index] === quote) {
|
|
22585
|
+
values.push(source.slice(quoteIndex + 1, index));
|
|
22586
|
+
CLASS_ATTRIBUTE_RE.lastIndex = index + 1;
|
|
22587
|
+
break;
|
|
22588
|
+
}
|
|
22589
|
+
}
|
|
22590
|
+
matched = CLASS_ATTRIBUTE_RE.exec(source);
|
|
22591
|
+
}
|
|
22592
|
+
return values;
|
|
22593
|
+
}
|
|
22594
|
+
function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
22559
22595
|
const matches = /* @__PURE__ */ new Set();
|
|
22560
|
-
|
|
22596
|
+
const shouldFilterByAllowedCandidates = allowedCandidates !== void 0 && allowedCandidates.size > 0;
|
|
22597
|
+
for (const classValue of collectClassAttributeValues(source)) for (const expression of classValue.match(MUSTACHE_EXPRESSION_RE) ?? []) {
|
|
22561
22598
|
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
22562
22599
|
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
22563
22600
|
while (quoted !== null) {
|
|
22564
22601
|
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
22565
|
-
for (const candidate of (0,
|
|
22602
|
+
for (const candidate of (0, tailwindcss_patch.splitCandidateTokens)(literal)) {
|
|
22566
22603
|
const normalized = candidate.trim();
|
|
22567
22604
|
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
22605
|
+
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
22568
22606
|
matches.add(normalized);
|
|
22569
22607
|
}
|
|
22570
22608
|
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
@@ -22942,6 +22980,7 @@ function createGenerateBundleHook(context) {
|
|
|
22942
22980
|
const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
22943
22981
|
const useV3OxideSourceRuntime = runtimeState.twPatcher.majorVersion === 3 && sourceCandidates.size > 0 && hasCssAssetEntry && !forceRuntimeRefreshByEnv && !disableV3OxideSourceRuntime;
|
|
22944
22982
|
const runtimeStart = performance.now();
|
|
22983
|
+
const transformBaseRuntime = useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, { transformOnly: true }) : void 0;
|
|
22945
22984
|
const runtime = isWebGeneratorTarget && !shouldGenerateWebCssByGenerator ? /* @__PURE__ */ new Set() : useV3OxideSourceRuntime ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv, {
|
|
22946
22985
|
allowBaselineOnlyInitialSync: true,
|
|
22947
22986
|
baseClassSet: sourceCandidates
|
|
@@ -22950,8 +22989,8 @@ function createGenerateBundleHook(context) {
|
|
|
22950
22989
|
const shouldFilterTailwindV4MiniProgramCandidates = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp";
|
|
22951
22990
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
22952
22991
|
let generatorRuntime = collectLegacyContainerCompatCandidates(sourceCandidates, shouldFilterTailwindV4MiniProgramCandidates ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates);
|
|
22953
|
-
let transformRuntime = runtime;
|
|
22954
|
-
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0
|
|
22992
|
+
let transformRuntime = transformBaseRuntime ?? runtime;
|
|
22993
|
+
if (runtimeState.twPatcher.majorVersion === 3 && generatorRuntime.size > 0) {
|
|
22955
22994
|
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
22956
22995
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
22957
22996
|
if (mainCssEntry) {
|
|
@@ -22979,6 +23018,11 @@ function createGenerateBundleHook(context) {
|
|
|
22979
23018
|
const generatorCandidatesChanged = state.generatorCandidateSignature !== generatorCandidateSignature;
|
|
22980
23019
|
const runtimeLinkedCssFiles = collectRuntimeLinkedCssFiles(snapshot);
|
|
22981
23020
|
recordGeneratorCandidates?.(generatorRuntime);
|
|
23021
|
+
const dynamicRetryCandidates = new Set([
|
|
23022
|
+
...sourceCandidates,
|
|
23023
|
+
...generatorRuntime,
|
|
23024
|
+
...transformRuntime
|
|
23025
|
+
]);
|
|
22982
23026
|
const defaultTemplateHandlerOptions = { runtimeSet: transformRuntime };
|
|
22983
23027
|
metrics.runtimeSet = measureElapsed(runtimeStart);
|
|
22984
23028
|
timingDetails["runtime"] = metrics.runtimeSet;
|
|
@@ -23025,11 +23069,18 @@ function createGenerateBundleHook(context) {
|
|
|
23025
23069
|
const start = performance.now();
|
|
23026
23070
|
let transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
23027
23071
|
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
23072
|
+
let retryRuntimeSet;
|
|
23028
23073
|
if (unresolvedDynamicCandidates.length > 0) {
|
|
23029
|
-
|
|
23030
|
-
|
|
23031
|
-
|
|
23032
|
-
|
|
23074
|
+
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
23075
|
+
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
23076
|
+
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
23077
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet.has(candidate));
|
|
23078
|
+
}
|
|
23079
|
+
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
23080
|
+
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23081
|
+
transformed = await templateHandler(rawSource, { runtimeSet: retryRuntimeSet });
|
|
23082
|
+
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed, retryRuntimeSet);
|
|
23083
|
+
if (unresolvedDynamicCandidates.length > 0) _weapp_tailwindcss_logger.logger.warn("已提取 WXML 动态类名在完整 runtimeSet 重试后仍未完成转译: %s -> %O", file, unresolvedDynamicCandidates);
|
|
23033
23084
|
}
|
|
23034
23085
|
metrics.html.elapsed += measureElapsed(start);
|
|
23035
23086
|
metrics.html.transformed++;
|
|
@@ -23579,6 +23630,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23579
23630
|
refreshTailwindcssPatcher
|
|
23580
23631
|
};
|
|
23581
23632
|
const bundleRuntimeClassSetManager = require_incremental_runtime_class_set.createBundleRuntimeClassSetManager();
|
|
23633
|
+
const transformRuntimeClassSetManager = require_incremental_runtime_class_set.createBundleRuntimeClassSetManager();
|
|
23582
23634
|
let runtimeSet;
|
|
23583
23635
|
let runtimeSetPromise;
|
|
23584
23636
|
let runtimeRefreshSignature;
|
|
@@ -23646,6 +23698,7 @@ function createViteRuntimeClassSet(options) {
|
|
|
23646
23698
|
runtimeSet = void 0;
|
|
23647
23699
|
runtimeSetPromise = void 0;
|
|
23648
23700
|
await bundleRuntimeClassSetManager.reset();
|
|
23701
|
+
await transformRuntimeClassSetManager.reset();
|
|
23649
23702
|
}
|
|
23650
23703
|
if (runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) try {
|
|
23651
23704
|
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
@@ -23655,22 +23708,30 @@ function createViteRuntimeClassSet(options) {
|
|
|
23655
23708
|
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23656
23709
|
await bundleRuntimeClassSetManager.reset();
|
|
23657
23710
|
}
|
|
23658
|
-
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh)
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
}
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23711
|
+
if (runtimeState.twPatcher.majorVersion === 3 && !forceRuntimeRefresh) {
|
|
23712
|
+
if (options.transformOnly) try {
|
|
23713
|
+
return await transformRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
23714
|
+
} catch (error) {
|
|
23715
|
+
debug("incremental transform runtime set sync failed, fallback to full collect: %O", error);
|
|
23716
|
+
await transformRuntimeClassSetManager.reset();
|
|
23717
|
+
}
|
|
23718
|
+
try {
|
|
23719
|
+
let baseClassSet = options.baseClassSet;
|
|
23720
|
+
if (!baseClassSet && (!runtimeSet || shouldRefreshPatcher)) baseClassSet = await require_precheck.collectRuntimeClassSet(runtimeState.twPatcher, {
|
|
23721
|
+
force: true,
|
|
23722
|
+
skipRefresh: shouldRefreshPatcher,
|
|
23723
|
+
clearCache: shouldRefreshPatcher
|
|
23724
|
+
});
|
|
23725
|
+
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot, {
|
|
23726
|
+
baseClassSet: baseClassSet ?? (options.allowBaselineOnlyInitialSync === true ? runtimeSet : void 0),
|
|
23727
|
+
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync === true && Boolean(runtimeSet)
|
|
23728
|
+
});
|
|
23729
|
+
runtimeSet = nextRuntimeSet;
|
|
23730
|
+
return nextRuntimeSet;
|
|
23731
|
+
} catch (error) {
|
|
23732
|
+
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
23733
|
+
await bundleRuntimeClassSetManager.reset();
|
|
23734
|
+
}
|
|
23674
23735
|
}
|
|
23675
23736
|
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) return runtimeSet;
|
|
23676
23737
|
const task = require_precheck.collectRuntimeClassSet(runtimeState.twPatcher, {
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-CMzi0wR2.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-C8SUICPv.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -30,7 +30,6 @@ _babel_traverse = require_runtime_registry.__toESM(_babel_traverse);
|
|
|
30
30
|
require("@babel/parser");
|
|
31
31
|
require("@babel/types");
|
|
32
32
|
require("@ast-core/escape");
|
|
33
|
-
require("@weapp-tailwindcss/shared/extractors");
|
|
34
33
|
//#region src/bundlers/shared/css-imports.ts
|
|
35
34
|
const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
|
|
36
35
|
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
@@ -1833,6 +1832,10 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
|
1833
1832
|
function collectCandidates$1(candidates) {
|
|
1834
1833
|
return new Set(candidates ?? []);
|
|
1835
1834
|
}
|
|
1835
|
+
function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
|
|
1836
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
1837
|
+
return false;
|
|
1838
|
+
}
|
|
1836
1839
|
function normalizeRpxTextCandidate(candidate) {
|
|
1837
1840
|
return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
|
|
1838
1841
|
}
|
|
@@ -2145,6 +2148,18 @@ function createTailwindV4Engine(source) {
|
|
|
2145
2148
|
});
|
|
2146
2149
|
const cached = incrementalGenerateCache$1.get(cacheKey);
|
|
2147
2150
|
if (cached) {
|
|
2151
|
+
if (hasRemovedCandidates$1(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
2152
|
+
const generated = await generateOnce(source, options);
|
|
2153
|
+
seedIncrementalGenerateCache({
|
|
2154
|
+
compatibleSource,
|
|
2155
|
+
generated,
|
|
2156
|
+
requestedCandidates,
|
|
2157
|
+
styleOptions,
|
|
2158
|
+
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
|
|
2159
|
+
target
|
|
2160
|
+
});
|
|
2161
|
+
return generated;
|
|
2162
|
+
});
|
|
2148
2163
|
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
2149
2164
|
if (missingCandidates.length === 0) return {
|
|
2150
2165
|
css: cached.css,
|
|
@@ -2792,6 +2807,10 @@ function createChangedContentEntries(candidates, sources) {
|
|
|
2792
2807
|
function collectCandidates(candidates) {
|
|
2793
2808
|
return new Set(candidates ?? []);
|
|
2794
2809
|
}
|
|
2810
|
+
function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
2811
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
2812
|
+
return false;
|
|
2813
|
+
}
|
|
2795
2814
|
function collectApplyCandidatesFromCss(css) {
|
|
2796
2815
|
if (!css.includes("@apply")) return [];
|
|
2797
2816
|
const candidates = /* @__PURE__ */ new Set();
|
|
@@ -3096,6 +3115,19 @@ function createTailwindV3Engine(source) {
|
|
|
3096
3115
|
const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions);
|
|
3097
3116
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
3098
3117
|
if (cached) {
|
|
3118
|
+
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
|
|
3119
|
+
const generated = await generateOnce(source, options);
|
|
3120
|
+
incrementalGenerateCache.set(cacheKey, {
|
|
3121
|
+
context: generated.context,
|
|
3122
|
+
seenCandidates: new Set(requestedCandidates),
|
|
3123
|
+
classSet: new Set(generated.classSet),
|
|
3124
|
+
css: generated.css,
|
|
3125
|
+
rawCss: generated.rawCss,
|
|
3126
|
+
dependencies: generated.dependencies,
|
|
3127
|
+
target: generated.target
|
|
3128
|
+
});
|
|
3129
|
+
return generated;
|
|
3130
|
+
}
|
|
3099
3131
|
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
3100
3132
|
if (missingCandidates.length === 0) return {
|
|
3101
3133
|
css: cached.css,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-KDOfD-6F.js");
|
|
3
|
+
const require_generator = require("./generator-BtpQoQEH.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-vqTU-eph.js");
|
|
5
|
+
const require_precheck = require("./precheck-Bp-V1T_Q.js");
|
|
6
6
|
const require_utils = require("./utils-D7Ygohep.js");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_bundle_state = require("./bundle-state-
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-bNXguXhC.js");
|
|
8
|
+
const require_bundle_state = require("./bundle-state-8w8DM8Lw.js");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
10
10
|
node_fs = require_chunk.__toESM(node_fs);
|
|
11
11
|
let node_module = require("node:module");
|
|
@@ -268,6 +268,10 @@ function createWebpackSnapshotAssets(assets) {
|
|
|
268
268
|
}];
|
|
269
269
|
}));
|
|
270
270
|
}
|
|
271
|
+
function stringifyWebpackSource(source) {
|
|
272
|
+
if (typeof source === "string") return source;
|
|
273
|
+
return source?.toString() ?? "";
|
|
274
|
+
}
|
|
271
275
|
function setupWebpackV5ProcessAssetsHook(options) {
|
|
272
276
|
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
273
277
|
const { Compilation, sources } = compiler.webpack;
|
|
@@ -289,6 +293,22 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
289
293
|
const hmrTimingStartedAt = performance.now();
|
|
290
294
|
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
291
295
|
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
296
|
+
const getCurrentAssetSource = (file) => {
|
|
297
|
+
const asset = compilation.getAsset(file);
|
|
298
|
+
if (!asset) return;
|
|
299
|
+
return stringifyWebpackSource(asset.source.source());
|
|
300
|
+
};
|
|
301
|
+
const updateAssetIfChanged = (file, source, { notifyUpdate = true } = {}) => {
|
|
302
|
+
const nextSource = stringifyWebpackSource(source.source());
|
|
303
|
+
const previousSource = getCurrentAssetSource(file);
|
|
304
|
+
if (previousSource === nextSource) {
|
|
305
|
+
debug("asset unchanged, skip update: %s", file);
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
compilation.updateAsset(file, source);
|
|
309
|
+
if (notifyUpdate) compilerOptions.onUpdate(file, previousSource ?? "", nextSource);
|
|
310
|
+
return true;
|
|
311
|
+
};
|
|
292
312
|
const entries = Object.entries(assets);
|
|
293
313
|
const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
|
|
294
314
|
const outputDir = compilerOutputPath ? node_path.default.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? node_process.default.cwd();
|
|
@@ -321,12 +341,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
321
341
|
const asset = compilation.getAsset(assetName);
|
|
322
342
|
if (!asset) continue;
|
|
323
343
|
const previousSource = asset.source.source();
|
|
324
|
-
|
|
325
|
-
if (
|
|
326
|
-
const source = new ConcatSource(code);
|
|
327
|
-
compilation.updateAsset(assetName, source);
|
|
328
|
-
compilerOptions.onUpdate(assetName, previous, code);
|
|
329
|
-
debug("js linked handle: %s", assetName);
|
|
344
|
+
if ((typeof previousSource === "string" ? previousSource : previousSource.toString()) === code) continue;
|
|
345
|
+
if (updateAssetIfChanged(assetName, new ConcatSource(code))) debug("js linked handle: %s", assetName);
|
|
330
346
|
}
|
|
331
347
|
};
|
|
332
348
|
const groupedEntries = require_utils.getGroupedEntries(entries, compilerOptions);
|
|
@@ -355,6 +371,9 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
355
371
|
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
356
372
|
return created;
|
|
357
373
|
};
|
|
374
|
+
const finalizeCssAssetSource = (source) => {
|
|
375
|
+
return require_incremental_runtime_class_set.removeTailwindSourceDirectives(require_bundle_state.stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
376
|
+
};
|
|
358
377
|
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
359
378
|
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
|
|
360
379
|
let runtimeSet;
|
|
@@ -407,16 +426,14 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
407
426
|
hashKey: `${file}:asset`,
|
|
408
427
|
rawSource,
|
|
409
428
|
hash: chunkHash,
|
|
410
|
-
applyResult(source) {
|
|
411
|
-
|
|
429
|
+
applyResult(source, { cacheHit }) {
|
|
430
|
+
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
412
431
|
},
|
|
413
432
|
onCacheHit() {
|
|
414
433
|
debug("html cache hit: %s", file);
|
|
415
434
|
},
|
|
416
435
|
transform: async () => {
|
|
417
|
-
const
|
|
418
|
-
const source = new ConcatSource(wxml);
|
|
419
|
-
compilerOptions.onUpdate(file, rawSource, wxml);
|
|
436
|
+
const source = new ConcatSource(await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions));
|
|
420
437
|
debug("html handle: %s", file);
|
|
421
438
|
return { result: source };
|
|
422
439
|
}
|
|
@@ -438,8 +455,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
438
455
|
hashKey: `${file}:asset`,
|
|
439
456
|
rawSource: initialRawSource,
|
|
440
457
|
hash: chunkHash,
|
|
441
|
-
applyResult(source) {
|
|
442
|
-
|
|
458
|
+
applyResult(source, { cacheHit }) {
|
|
459
|
+
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
443
460
|
},
|
|
444
461
|
onCacheHit() {
|
|
445
462
|
debug("js cache hit: %s", file);
|
|
@@ -459,7 +476,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
459
476
|
})) return { result: new ConcatSource(currentSource) };
|
|
460
477
|
const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
461
478
|
const source = new ConcatSource(code);
|
|
462
|
-
compilerOptions.onUpdate(file, currentSource, code);
|
|
463
479
|
debug("js handle: %s", file);
|
|
464
480
|
applyLinkedResults(linked);
|
|
465
481
|
return { result: source };
|
|
@@ -471,21 +487,20 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
471
487
|
const [file, originalSource] = element;
|
|
472
488
|
const rawSource = originalSource.source().toString();
|
|
473
489
|
if (isWebpackProcessedCssAsset?.(file, rawSource)) {
|
|
474
|
-
const nextCss =
|
|
490
|
+
const nextCss = finalizeCssAssetSource(rawSource);
|
|
475
491
|
tasks.push(require_incremental_runtime_class_set.processCachedTask({
|
|
476
492
|
cache: compilerOptions.cache,
|
|
477
493
|
cacheKey: file,
|
|
478
494
|
hashKey: `${file}:asset`,
|
|
479
495
|
rawSource,
|
|
480
496
|
hash: createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash),
|
|
481
|
-
applyResult(source) {
|
|
482
|
-
|
|
497
|
+
applyResult(source, { cacheHit }) {
|
|
498
|
+
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
483
499
|
},
|
|
484
500
|
onCacheHit() {
|
|
485
501
|
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
486
502
|
},
|
|
487
503
|
transform: async () => {
|
|
488
|
-
compilerOptions.onUpdate(file, rawSource, nextCss);
|
|
489
504
|
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
490
505
|
return { result: new ConcatSource(nextCss) };
|
|
491
506
|
}
|
|
@@ -500,8 +515,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
500
515
|
hashKey: `${file}:asset`,
|
|
501
516
|
rawSource,
|
|
502
517
|
hash: runtimeAwareHash,
|
|
503
|
-
applyResult(source) {
|
|
504
|
-
|
|
518
|
+
applyResult(source, { cacheHit }) {
|
|
519
|
+
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
505
520
|
},
|
|
506
521
|
onCacheHit() {
|
|
507
522
|
debug("css cache hit: %s", file);
|
|
@@ -520,9 +535,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
520
535
|
styleHandler: compilerOptions.styleHandler,
|
|
521
536
|
debug
|
|
522
537
|
});
|
|
523
|
-
const
|
|
524
|
-
const source = new ConcatSource(css);
|
|
525
|
-
compilerOptions.onUpdate(file, rawSource, css);
|
|
538
|
+
const source = new ConcatSource(finalizeCssAssetSource(generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
526
539
|
if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
|
|
527
540
|
else debug("css handle: %s", file);
|
|
528
541
|
return { result: source };
|
|
@@ -669,6 +682,28 @@ function setupWebpackV5Loaders(options) {
|
|
|
669
682
|
require_precheck.init_defineProperty();
|
|
670
683
|
const debug = require_v3_engine.createDebug();
|
|
671
684
|
const weappTailwindcssPackageDir = require_bundle_state.resolvePackageDir("weapp-tailwindcss");
|
|
685
|
+
function normalizeIgnoredList(ignored) {
|
|
686
|
+
if (Array.isArray(ignored)) return ignored;
|
|
687
|
+
return ignored == null ? [] : [ignored];
|
|
688
|
+
}
|
|
689
|
+
function appendIgnoredPath(ignored, ignoredPath) {
|
|
690
|
+
const ignoredList = normalizeIgnoredList(ignored);
|
|
691
|
+
if (ignoredList.some((item) => typeof item === "string" && node_path.default.resolve(item) === ignoredPath)) return ignored;
|
|
692
|
+
return [...ignoredList, ignoredPath];
|
|
693
|
+
}
|
|
694
|
+
function setupWebpackWatchOutputIgnore(compiler) {
|
|
695
|
+
const originalWatch = compiler.watch?.bind(compiler);
|
|
696
|
+
if (typeof originalWatch !== "function") return;
|
|
697
|
+
compiler.watch = ((watchOptions, handler) => {
|
|
698
|
+
const outputPath = compiler.outputPath || compiler.options?.output?.path;
|
|
699
|
+
const outputDir = outputPath ? node_path.default.resolve(outputPath) : void 0;
|
|
700
|
+
if (!outputDir) return originalWatch(watchOptions, handler);
|
|
701
|
+
return originalWatch({
|
|
702
|
+
...watchOptions,
|
|
703
|
+
ignored: appendIgnoredPath(watchOptions.ignored, outputDir)
|
|
704
|
+
}, handler);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
672
707
|
/**
|
|
673
708
|
* @name WeappTailwindcss
|
|
674
709
|
* @description webpack5 核心转义插件
|
|
@@ -696,6 +731,7 @@ var WeappTailwindcss = class {
|
|
|
696
731
|
const isMpxApp = isMpx(this.appType);
|
|
697
732
|
if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
698
733
|
if (disabledOptions.plugin) return;
|
|
734
|
+
setupWebpackWatchOutputIgnore(compiler);
|
|
699
735
|
const runtimeState = {
|
|
700
736
|
twPatcher: initialTwPatcher,
|
|
701
737
|
readyPromise: require_precheck.createTailwindRuntimeReadyPromise(initialTwPatcher),
|