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,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-
|
|
1
|
+
import { $ as normalizeTailwindConfigDirectives, A as isCommentOnlyCss, B as removeTailwindV4GeneratedUserCssArtifacts, Dt as resolveSourceScanPath, E as resolveTailwindcssOptions, F as finalizeMiniProgramCss, L as pruneMiniProgramGeneratedCss, M as removeTailwindV4GeneratorAtRules, N as stripTailwindSourceMediaFragments, Nt as getTailwindV4IncrementalGenerateCacheStats, P as stripUnmatchedTailwindSourceMediaCloseFragments, Q as hasTailwindSourceDirectives, Y as hasTailwindApplyDirective, Z as hasTailwindRootDirectives, ct as hasTailwindGeneratedCss, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, j as removeMiniProgramHoverSelectors, lt as hasTailwindGeneratedCssMarkers, nt as parseImportRequest, o as resolveRuntimeBranch, rt as removeTailwindSourceDirectives, z as stripMiniProgramCssSpecificityPlaceholders } from "./generator-Bv7myuhY.mjs";
|
|
2
|
+
import { g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-BTcXX8Ka.mjs";
|
|
3
3
|
import { r as getGroupedEntries } from "./utils-MVwpU07P.mjs";
|
|
4
4
|
import { b as md5Hash, c as _defineProperty, y as createDebug } from "./wxml-DdGdeqaH.mjs";
|
|
5
|
-
import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-
|
|
5
|
+
import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-JzwzSX36.mjs";
|
|
6
6
|
import { getDefaultCssPreflight } from "./defaults.mjs";
|
|
7
|
-
import { A as
|
|
8
|
-
import { D as toAbsoluteOutputPath, E as resolveOutputSpecifier,
|
|
7
|
+
import { A as processCachedTask, C as hasBundlerGeneratedCssMarker, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, F as resolveSourceCandidateScanFiles, I as createBundleRuntimeClassSetManager, L as collectStrictEscapedRuntimeCandidates, M as createSourceCandidateStore, N as isSourceCandidateRequest, O as createCssTokenSourceMap, R as createEscapeFragments, T as stripBundlerGeneratedCssMarkers, c as pushConcurrentTaskFactories, g as isSourceStyleRequest, h as hasMiniProgramTailwindV4PreflightReset, k as isCssSourceTraceEnabled, l as resolveTaskConcurrency, n as emitHmrTiming, p as createCssSourceOrderAppend, s as collectRawSourceClassSelectors, v as stripRequestQuery, x as removeGeneratedSelectorCompatCss, y as scoreTailwindV4CssSourceFileMatch, z as isPureLocalCssImportWrapper } from "./hmr-timing-BXg7nI8N.mjs";
|
|
8
|
+
import { A as collectFrameworkPostcssOptionsFromLoaderEntries, D as toAbsoluteOutputPath, E as resolveOutputSpecifier, I as webpackStyleInjectorDelegates, M as resolvePluginDisabledState, P as createBuiltinWebpackStyleInjectorPlugin, R as resolveWebpackFrameworkProfile, a as createCandidateSignature, f as classifyBundleEntry, j as resolvePackageDir, k as captureResolvedFrameworkPostcssOptions, m as updateBundleBuildState, p as createBundleBuildState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, w as generateTailwindV4Css, x as createRuntimeAffectingSourceSignature } from "./source-candidate-scan-signature-CtK-mB_C.mjs";
|
|
9
9
|
import Module, { createRequire } from "node:module";
|
|
10
10
|
import fs from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
@@ -153,13 +153,243 @@ function isWatchFileInRuntimeDependencies(file, dependencies) {
|
|
|
153
153
|
return false;
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
|
-
//#region src/bundlers/webpack/
|
|
157
|
-
function
|
|
158
|
-
return
|
|
156
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.ts
|
|
157
|
+
function isRuntimeTransformCandidate(candidate) {
|
|
158
|
+
return candidate.length > 0 && !candidate.includes("=") && !candidate.includes("<") && !candidate.includes(">") && !candidate.includes("${");
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.ts
|
|
162
|
+
function collectWebpackAssetUserCssMarkers(source) {
|
|
163
|
+
const markers = /* @__PURE__ */ new Set();
|
|
164
|
+
for (const match of source.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
165
|
+
for (const match of source.matchAll(/@(?:-[\w-]+-)?keyframes\s+((?:\\.|[-\w\u00A0-\uFFFF])+)/gi)) markers.add(`keyframes:${match[1]}`);
|
|
166
|
+
try {
|
|
167
|
+
const root = postcss.parse(source);
|
|
168
|
+
root.walkRules((rule) => {
|
|
169
|
+
for (const selector of rule.selectors) if (!/(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector)) markers.add(`selector:${selector.trim().replace(/\s+/g, " ")}`);
|
|
170
|
+
rule.walkDecls((decl) => {
|
|
171
|
+
if (decl.prop.startsWith("--")) markers.add(`custom-property:${decl.prop}`);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
root.walkAtRules("font-face", (rule) => {
|
|
175
|
+
rule.walkDecls("font-family", (decl) => {
|
|
176
|
+
markers.add(`font-face:${decl.value.trim()}`);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
} catch {}
|
|
180
|
+
return markers;
|
|
159
181
|
}
|
|
160
182
|
//#endregion
|
|
161
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.ts
|
|
162
|
-
const
|
|
183
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.ts
|
|
184
|
+
const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
|
|
185
|
+
"theme",
|
|
186
|
+
"base",
|
|
187
|
+
"utilities"
|
|
188
|
+
]);
|
|
189
|
+
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
190
|
+
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
191
|
+
const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
|
|
192
|
+
const WEBPACK_TAILWIND_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
193
|
+
"*",
|
|
194
|
+
":after",
|
|
195
|
+
":before",
|
|
196
|
+
"::after",
|
|
197
|
+
"::before",
|
|
198
|
+
"::backdrop",
|
|
199
|
+
"view",
|
|
200
|
+
"text"
|
|
201
|
+
]);
|
|
202
|
+
const WEBPACK_TAILWIND_PREFLIGHT_PROPS = /* @__PURE__ */ new Set([
|
|
203
|
+
"box-sizing",
|
|
204
|
+
"border",
|
|
205
|
+
"border-width",
|
|
206
|
+
"border-style",
|
|
207
|
+
"border-color",
|
|
208
|
+
"margin",
|
|
209
|
+
"padding"
|
|
210
|
+
]);
|
|
211
|
+
const WEBPACK_TAILWIND_THEME_TOKEN_RE = /^--(?:tw-|color-|spacing|breakpoint-|container-|text-|font-|tracking-|leading-|radius-|shadow-|inset-shadow-|drop-shadow-|ease-|animate-|blur-|perspective-|aspect-|default-)/;
|
|
212
|
+
function parseWebpackCssLayerNames(params) {
|
|
213
|
+
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
214
|
+
}
|
|
215
|
+
function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
216
|
+
const cleaned = removeTailwindV4GeneratedUserCssArtifacts(source);
|
|
217
|
+
try {
|
|
218
|
+
const root = postcss.parse(cleaned);
|
|
219
|
+
let changed = false;
|
|
220
|
+
let removingBannerPrefix = false;
|
|
221
|
+
for (const node of [...root.nodes]) {
|
|
222
|
+
if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
|
|
223
|
+
node.remove();
|
|
224
|
+
changed = true;
|
|
225
|
+
removingBannerPrefix = true;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (!removingBannerPrefix) continue;
|
|
229
|
+
if (isWebpackTailwindGeneratedPrefixNode(node)) {
|
|
230
|
+
node.remove();
|
|
231
|
+
changed = true;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
removingBannerPrefix = false;
|
|
235
|
+
}
|
|
236
|
+
root.walkAtRules("layer", (rule) => {
|
|
237
|
+
const names = parseWebpackCssLayerNames(rule.params);
|
|
238
|
+
const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
239
|
+
const isLayerDeclaration = rule.nodes === void 0;
|
|
240
|
+
const shouldRemoveLayer = isLayerDeclaration ? hasGeneratedLayerName : names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
241
|
+
if (shouldRemoveLayer && isLayerDeclaration) {
|
|
242
|
+
rule.remove();
|
|
243
|
+
changed = true;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (shouldRemoveLayer && !names.includes("utilities")) {
|
|
247
|
+
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
248
|
+
child.remove();
|
|
249
|
+
changed = true;
|
|
250
|
+
}
|
|
251
|
+
if (rule.nodes?.length === 0) {
|
|
252
|
+
rule.remove();
|
|
253
|
+
changed = true;
|
|
254
|
+
}
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (shouldRemoveLayer) {
|
|
258
|
+
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
259
|
+
child.remove();
|
|
260
|
+
changed = true;
|
|
261
|
+
}
|
|
262
|
+
if (rule.nodes?.length === 0) {
|
|
263
|
+
rule.remove();
|
|
264
|
+
changed = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
root.walkRules((rule) => {
|
|
269
|
+
if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
|
|
270
|
+
const selector = rule.selector.trim();
|
|
271
|
+
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || isWebpackTailwindGeneratedPreflightRule(rule)) {
|
|
272
|
+
rule.remove();
|
|
273
|
+
changed = true;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
root.walkComments((comment) => {
|
|
277
|
+
if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
|
|
278
|
+
comment.remove();
|
|
279
|
+
changed = true;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
root.walkAtRules((rule) => {
|
|
283
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
284
|
+
rule.remove();
|
|
285
|
+
changed = true;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
return changed ? root.toString() : cleaned;
|
|
289
|
+
} catch {
|
|
290
|
+
return cleaned;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function isWebpackTailwindGeneratedPrefixNode(node) {
|
|
294
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, [
|
|
295
|
+
"theme",
|
|
296
|
+
"base",
|
|
297
|
+
"utilities"
|
|
298
|
+
], true);
|
|
299
|
+
if (node.type !== "atrule") return false;
|
|
300
|
+
const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
|
|
301
|
+
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
302
|
+
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) {
|
|
303
|
+
if (node.nodes === void 0) return true;
|
|
304
|
+
return node.nodes.length > 0 && node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, names));
|
|
305
|
+
}
|
|
306
|
+
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
307
|
+
return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
|
|
308
|
+
}
|
|
309
|
+
function isWebpackTailwindGeneratedLayerNode(node, layerNames) {
|
|
310
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, layerNames, false);
|
|
311
|
+
if (node.type !== "atrule") return false;
|
|
312
|
+
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
313
|
+
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
314
|
+
return node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, layerNames));
|
|
315
|
+
}
|
|
316
|
+
function isWebpackTailwindGeneratedRule(rule, layerNames, includePrefix) {
|
|
317
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
318
|
+
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), includePrefix))) return true;
|
|
319
|
+
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true))) return true;
|
|
320
|
+
if (layerNames.includes("theme") && isWebpackTailwindGeneratedThemeRule(rule)) return true;
|
|
321
|
+
if (layerNames.includes("base") && isWebpackTailwindGeneratedPreflightRule(rule)) return true;
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
function isWebpackTailwindGeneratedThemeRule(rule) {
|
|
325
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
326
|
+
return declarations.length > 0 && declarations.every((decl) => WEBPACK_TAILWIND_THEME_TOKEN_RE.test(decl.prop) || decl.value.includes("--theme("));
|
|
327
|
+
}
|
|
328
|
+
function isWebpackTailwindGeneratedPreflightRule(rule) {
|
|
329
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
330
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
331
|
+
return selectors.length > 0 && declarations.length > 0 && selectors.every((selector) => {
|
|
332
|
+
const normalized = selector.trim().replace(/\s+/g, " ");
|
|
333
|
+
return WEBPACK_TAILWIND_PREFLIGHT_SELECTORS.has(normalized);
|
|
334
|
+
}) && declarations.every((decl) => WEBPACK_TAILWIND_PREFLIGHT_PROPS.has(decl.prop));
|
|
335
|
+
}
|
|
336
|
+
function isOnlyWebpackTailwindGeneratedPreflightCss(source) {
|
|
337
|
+
try {
|
|
338
|
+
const nodes = postcss.parse(source).nodes ?? [];
|
|
339
|
+
return nodes.length > 0 && nodes.every((node) => {
|
|
340
|
+
if (node.type === "rule") return isWebpackTailwindGeneratedPreflightRule(node);
|
|
341
|
+
return node.type === "atrule" && (node.nodes === void 0 || node.nodes.length === 0);
|
|
342
|
+
});
|
|
343
|
+
} catch {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
|
|
348
|
+
return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
|
|
349
|
+
}
|
|
350
|
+
function collectWebpackCssRuleIdentityMarkers(source) {
|
|
351
|
+
const markers = /* @__PURE__ */ new Set();
|
|
352
|
+
try {
|
|
353
|
+
const root = postcss.parse(source);
|
|
354
|
+
root.walkRules((rule) => {
|
|
355
|
+
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
356
|
+
});
|
|
357
|
+
root.walkAtRules("keyframes", (rule) => {
|
|
358
|
+
if (rule.params) markers.add(`keyframes:${rule.params}`);
|
|
359
|
+
});
|
|
360
|
+
} catch {}
|
|
361
|
+
return markers;
|
|
362
|
+
}
|
|
363
|
+
function unescapeCssIdentifier(value) {
|
|
364
|
+
return value.replace(/\\([0-9a-f]{1,6}\s?|.)/gi, (_match, escaped) => {
|
|
365
|
+
const hex = escaped.trim();
|
|
366
|
+
if (/^[0-9a-f]+$/i.test(hex)) return String.fromCodePoint(Number.parseInt(hex, 16));
|
|
367
|
+
return escaped;
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function collectGeneratedCssRuntimeCandidates(source) {
|
|
371
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
372
|
+
if (hasBundlerGeneratedCssMarker(source) || !hasTailwindGeneratedCss(source) && !hasTailwindGeneratedCssMarkers(source)) return candidates;
|
|
373
|
+
try {
|
|
374
|
+
postcss.parse(source).walkRules((rule) => {
|
|
375
|
+
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[\w\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/g)) {
|
|
376
|
+
const candidate = unescapeCssIdentifier(match[1]);
|
|
377
|
+
if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
} catch {}
|
|
381
|
+
return candidates;
|
|
382
|
+
}
|
|
383
|
+
function hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource) {
|
|
384
|
+
const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
|
|
385
|
+
if (rawMarkers.size === 0) return false;
|
|
386
|
+
const generatorMarkers = collectWebpackAssetUserCssMarkers(generatorRawSource);
|
|
387
|
+
for (const marker of rawMarkers) if (!generatorMarkers.has(marker)) return true;
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
function hasWebpackTailwindSourceDirectives(source) {
|
|
391
|
+
return Boolean(source) && (hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source) || hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source));
|
|
392
|
+
}
|
|
163
393
|
function resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) {
|
|
164
394
|
return styleOptions.cssPreflight ?? compilerOptions.cssPreflight ?? getDefaultCssPreflight();
|
|
165
395
|
}
|
|
@@ -269,9 +499,6 @@ function removeTailwindV4StandaloneHostPreflightRule(source) {
|
|
|
269
499
|
return source;
|
|
270
500
|
}
|
|
271
501
|
}
|
|
272
|
-
function isRuntimeTransformCandidate(candidate) {
|
|
273
|
-
return candidate.length > 0 && !candidate.includes("=") && !candidate.includes("<") && !candidate.includes(">") && !candidate.includes("${");
|
|
274
|
-
}
|
|
275
502
|
function collectRuntimeTokenSignatureParts(source) {
|
|
276
503
|
return source.match(/[\w-]+_[A-Z][\w-]*/gi) ?? [];
|
|
277
504
|
}
|
|
@@ -315,27 +542,242 @@ function pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandl
|
|
|
315
542
|
const activeSuffixes = [...activeCssFiles].map((file) => `:${file}`);
|
|
316
543
|
for (const key of cssHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssHandlerOptionsCache.delete(key);
|
|
317
544
|
for (const key of cssUserHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssUserHandlerOptionsCache.delete(key);
|
|
318
|
-
pruneMapToMaxSize(cssHandlerOptionsCache,
|
|
319
|
-
pruneMapToMaxSize(cssUserHandlerOptionsCache,
|
|
320
|
-
}
|
|
321
|
-
function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
322
|
-
const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
|
|
323
|
-
if (sourceCss && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss) || hasTailwindGeneratedCss(sourceCss) || hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
|
|
324
|
-
return rawSource;
|
|
325
|
-
}
|
|
326
|
-
function shouldConsumeWebpackLoaderGeneratedCss(options) {
|
|
327
|
-
if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
|
|
328
|
-
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
329
|
-
if (options.hasBundlerGeneratedCssMarker) return true;
|
|
330
|
-
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
331
|
-
return Boolean(options.allowMarkerlessRegistryMatch && options.loaderGeneratedClassSet && options.sourceCandidates && !hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates) && !hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates));
|
|
332
|
-
}
|
|
333
|
-
function hasDeferredWebpackGeneratedCss(source, generatedClassSets) {
|
|
334
|
-
const selectors = collectRawSourceClassSelectors(source);
|
|
335
|
-
for (const classSet of generatedClassSets) for (const candidate of classSet) if (selectors.has(candidate)) return true;
|
|
336
|
-
return false;
|
|
545
|
+
pruneMapToMaxSize(cssHandlerOptionsCache, 128);
|
|
546
|
+
pruneMapToMaxSize(cssUserHandlerOptionsCache, 128);
|
|
337
547
|
}
|
|
338
|
-
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.ts
|
|
550
|
+
function resolveWebpackMemoryDebugStats(context) {
|
|
551
|
+
if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
|
|
552
|
+
const memory = process.memoryUsage();
|
|
553
|
+
const processCacheInstanceSize = context.cache.instance.size;
|
|
554
|
+
const processCacheHashMapSize = context.cache.hashMap.size;
|
|
555
|
+
return {
|
|
556
|
+
phase: context.phase,
|
|
557
|
+
process: {
|
|
558
|
+
rssMb: toMb(memory.rss),
|
|
559
|
+
heapTotalMb: toMb(memory.heapTotal),
|
|
560
|
+
heapUsedMb: toMb(memory.heapUsed),
|
|
561
|
+
externalMb: toMb(memory.external),
|
|
562
|
+
arrayBuffersMb: toMb(memory.arrayBuffers)
|
|
563
|
+
},
|
|
564
|
+
assets: {
|
|
565
|
+
active: context.activeAssetFiles,
|
|
566
|
+
activeCss: context.activeCssFiles
|
|
567
|
+
},
|
|
568
|
+
processCache: {
|
|
569
|
+
instance: processCacheInstanceSize,
|
|
570
|
+
hashMap: processCacheHashMapSize,
|
|
571
|
+
activeCacheKeys: context.activeProcessCacheKeys.size,
|
|
572
|
+
activeHashKeys: context.activeProcessHashKeys.size,
|
|
573
|
+
staleCacheKeys: Math.max(0, processCacheInstanceSize - context.activeProcessCacheKeys.size),
|
|
574
|
+
staleHashKeys: Math.max(0, processCacheHashMapSize - context.activeProcessHashKeys.size),
|
|
575
|
+
pruned: true,
|
|
576
|
+
pruneSkipped: false
|
|
577
|
+
},
|
|
578
|
+
webpackCss: {
|
|
579
|
+
handlerOptions: context.cssHandlerOptionsCache.size,
|
|
580
|
+
userHandlerOptions: context.cssUserHandlerOptionsCache.size,
|
|
581
|
+
maxHandlerOptions: 128
|
|
582
|
+
},
|
|
583
|
+
sourceCandidateScan: context.sourceCandidateScan,
|
|
584
|
+
tailwind: { v4: getTailwindV4IncrementalGenerateCacheStats() }
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function shouldInjectWebpackCssTracePreflight(_appType, cssHandlerOptions) {
|
|
588
|
+
if (includesTailwindPreflightImport(cssHandlerOptions.sourceOptions?.sourceCss)) return true;
|
|
589
|
+
return cssHandlerOptions.isMainChunk !== false;
|
|
590
|
+
}
|
|
591
|
+
function includesTailwindPreflightImport(source) {
|
|
592
|
+
if (!source) return false;
|
|
593
|
+
try {
|
|
594
|
+
let includesPreflight = false;
|
|
595
|
+
postcss.parse(source).walkAtRules((rule) => {
|
|
596
|
+
if (rule.name === "tailwind") {
|
|
597
|
+
includesPreflight || (includesPreflight = rule.params.trim() === "base");
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (rule.name !== "import") return;
|
|
601
|
+
const request = parseImportRequest(rule.params)?.replaceAll("\\", "/");
|
|
602
|
+
includesPreflight || (includesPreflight = request === "tailwindcss" || request === "tailwindcss/preflight.css" || request?.endsWith("/tailwindcss/index.css") === true || request?.endsWith("/tailwindcss/preflight.css") === true);
|
|
603
|
+
});
|
|
604
|
+
return includesPreflight;
|
|
605
|
+
} catch {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
610
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
611
|
+
if (isWebGeneratorTarget) return source;
|
|
612
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeTailwindV4StandaloneHostPreflightRule(finalizeMiniProgramCss(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
|
|
613
|
+
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0,
|
|
614
|
+
isTailwindcssV4: true,
|
|
615
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
616
|
+
})));
|
|
617
|
+
}
|
|
618
|
+
function shouldFallbackToWebpackUserCssOnGeneratorError(options) {
|
|
619
|
+
return !hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindSourceDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindApplyDirective(options.generatorRawSource) && !options.hasExplicitTailwindV4SourceCss && options.configuredMainCssEntryFilesLength === 0;
|
|
620
|
+
}
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.ts
|
|
623
|
+
function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
|
|
624
|
+
if (options.finalized === true) return options.annotateCss(css);
|
|
625
|
+
if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return options.annotateCss(css);
|
|
626
|
+
const finalized = finalizeMiniProgramUserCssAssetSource(css, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
|
|
627
|
+
return options.annotateCss(finalized);
|
|
628
|
+
}
|
|
629
|
+
function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
630
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
631
|
+
if (isWebGeneratorTarget) {
|
|
632
|
+
if (options.generatedCss === true) return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(stripBundlerGeneratedCssMarkers(source))));
|
|
633
|
+
return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
|
|
634
|
+
}
|
|
635
|
+
let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
636
|
+
if (options.generatedCss !== true) {
|
|
637
|
+
finalized = finalizeMiniProgramCss(finalized, {
|
|
638
|
+
cssPreflight: false,
|
|
639
|
+
isTailwindcssV4: true,
|
|
640
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
641
|
+
});
|
|
642
|
+
finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
643
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
644
|
+
}
|
|
645
|
+
try {
|
|
646
|
+
finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: options.cssPreflight !== false });
|
|
647
|
+
} catch {}
|
|
648
|
+
const shouldRemoveExistingPreflight = options.cssPreflight === false && options.preserveExistingPreflight === false;
|
|
649
|
+
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
650
|
+
const hasExistingMiniProgramPreflight = options.preserveExistingPreflight !== false && hasMiniProgramPreflightSelector(source);
|
|
651
|
+
finalized = finalizeMiniProgramCss(finalized, {
|
|
652
|
+
cssPreflight: options.cssPreflight === false && !hasExistingMiniProgramPreflight ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) : void 0,
|
|
653
|
+
isTailwindcssV4: true,
|
|
654
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
655
|
+
});
|
|
656
|
+
finalized = ensureWebpackMiniProgramTwContentInit(finalized);
|
|
657
|
+
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
658
|
+
else finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
659
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
660
|
+
}
|
|
661
|
+
function finalizeWebpackCssAssetOutputSource(source, compilerOptions, isWebGeneratorTarget) {
|
|
662
|
+
if (isWebGeneratorTarget) return source;
|
|
663
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
664
|
+
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(dedupeCoveredCssRules(dedupeMiniProgramPreflightSelectorRules(source)), styleOptions.cssRemoveHoverPseudoClass));
|
|
665
|
+
}
|
|
666
|
+
function collectWebpackJsRuntimeCandidatesFromAssets(options) {
|
|
667
|
+
if (options.isWebGeneratorTarget) return;
|
|
668
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
669
|
+
for (const file of options.jsAssets) {
|
|
670
|
+
const sourceLike = options.getAssetSource(file);
|
|
671
|
+
if (sourceLike === void 0) continue;
|
|
672
|
+
const source = stringifyWebpackSourceLike(sourceLike);
|
|
673
|
+
for (const candidate of collectStrictEscapedRuntimeCandidates(source, MappingChars2String, options.escapeFragments)) if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
674
|
+
}
|
|
675
|
+
return candidates;
|
|
676
|
+
}
|
|
677
|
+
function collectWebpackJsRuntimeTokenSignature(options) {
|
|
678
|
+
if (options.isWebGeneratorTarget) return "";
|
|
679
|
+
const tokens = [];
|
|
680
|
+
for (const file of options.jsAssets) {
|
|
681
|
+
const sourceLike = options.getAssetSource(file);
|
|
682
|
+
if (sourceLike === void 0) continue;
|
|
683
|
+
tokens.push(...collectRuntimeTokenSignatureParts(stringifyWebpackSourceLike(sourceLike)));
|
|
684
|
+
}
|
|
685
|
+
return tokens.sort().join("\n");
|
|
686
|
+
}
|
|
687
|
+
function addRuntimeTransformCandidates(target, candidates) {
|
|
688
|
+
if (!candidates?.size) return;
|
|
689
|
+
for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate)) target.add(candidate);
|
|
690
|
+
}
|
|
691
|
+
function createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates) {
|
|
692
|
+
if (!isCssSourceTraceEnabled(compilerOptions) || !webpackSourceCandidates) return;
|
|
693
|
+
return createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions);
|
|
694
|
+
}
|
|
695
|
+
function stringifyOptionalWebpackSourceValue(value) {
|
|
696
|
+
return typeof value === "string" ? value : value?.toString() ?? "";
|
|
697
|
+
}
|
|
698
|
+
function stringifyWebpackSourceLike(source) {
|
|
699
|
+
if (typeof source === "string") return source;
|
|
700
|
+
const value = source.source();
|
|
701
|
+
return typeof value === "string" ? value : value.toString();
|
|
702
|
+
}
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.ts
|
|
705
|
+
function isWindowsAbsoluteResourcePath(file) {
|
|
706
|
+
return /^[a-z]:[\\/]/i.test(file) || /^[/\\]{2}[^/\\]/.test(file);
|
|
707
|
+
}
|
|
708
|
+
function isPosixAbsoluteResourcePath(file) {
|
|
709
|
+
return file.startsWith("/");
|
|
710
|
+
}
|
|
711
|
+
function resolveWebpackResourcePath(file, base) {
|
|
712
|
+
if (isWindowsAbsoluteResourcePath(file)) return path.win32.resolve(file);
|
|
713
|
+
if (isPosixAbsoluteResourcePath(file)) return path.posix.resolve(file);
|
|
714
|
+
if (base) {
|
|
715
|
+
if (isWindowsAbsoluteResourcePath(base)) return path.win32.resolve(base, file);
|
|
716
|
+
if (isPosixAbsoluteResourcePath(base)) return path.posix.resolve(base, file);
|
|
717
|
+
return path.resolve(base, file);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function dirnameWebpackResourcePath(file) {
|
|
721
|
+
if (isWindowsAbsoluteResourcePath(file)) return path.win32.dirname(file);
|
|
722
|
+
if (isPosixAbsoluteResourcePath(file)) return path.posix.dirname(file);
|
|
723
|
+
return path.dirname(file);
|
|
724
|
+
}
|
|
725
|
+
function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
|
|
726
|
+
if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
|
|
727
|
+
const normalized = stripResourceQuery(resource);
|
|
728
|
+
if (!normalized) return;
|
|
729
|
+
const absoluteResource = resolveWebpackResourcePath(normalized);
|
|
730
|
+
if (absoluteResource) return absoluteResource;
|
|
731
|
+
const issuerResource = issuer?.resource ? stripResourceQuery(issuer.resource) : void 0;
|
|
732
|
+
const issuerResourcePath = issuerResource ? resolveWebpackResourcePath(issuerResource) : void 0;
|
|
733
|
+
return resolveWebpackResourcePath(normalized, issuerResourcePath ? dirnameWebpackResourcePath(issuerResourcePath) : issuer?.context);
|
|
734
|
+
}
|
|
735
|
+
function isSameWebpackCssSourceScope(options) {
|
|
736
|
+
if (!options.currentSourceFile) return false;
|
|
737
|
+
const candidateKey = resolveWebpackResourcePath(options.candidateSourceFile) ?? path.resolve(options.candidateSourceFile);
|
|
738
|
+
if (candidateKey === (resolveWebpackResourcePath(options.currentSourceFile) ?? path.resolve(options.currentSourceFile))) return true;
|
|
739
|
+
const outputResources = options.resourcesByAsset.get(options.outputFile);
|
|
740
|
+
if (!outputResources) return false;
|
|
741
|
+
return [...outputResources].some((resource) => {
|
|
742
|
+
return (resolveWebpackResourcePath(resource) ?? path.resolve(resource)) === candidateKey;
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function shouldAppendCurrentWebpackAssetUserCss(options) {
|
|
746
|
+
const hasGeneratedAssetUserCss = options.currentAssetLooksGenerated && options.currentAssetHasUserCss;
|
|
747
|
+
return !options.currentAssetHasBundlerGeneratedMarker && !options.shouldPreserveGeneratedWebAssetUserCss && (hasGeneratedAssetUserCss || !options.sourceCssProcessed || options.registeredUserRawSource === void 0 || options.currentAssetHasUserCss) && !(options.sourceCssProcessed && options.currentAssetLooksGenerated && !options.currentAssetHasUserCss);
|
|
748
|
+
}
|
|
749
|
+
function createWebpackCurrentAssetUserRawSource(options) {
|
|
750
|
+
if (!options.shouldAppendCurrentAssetUserCss) return;
|
|
751
|
+
if (options.sourceCssProcessed) return {
|
|
752
|
+
css: options.currentAssetUserCssSource,
|
|
753
|
+
processed: true
|
|
754
|
+
};
|
|
755
|
+
if (!options.currentAssetHasUserCss) return;
|
|
756
|
+
return {
|
|
757
|
+
css: options.currentAssetUserCssSource,
|
|
758
|
+
processed: options.currentAssetLooksGenerated
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.ts
|
|
763
|
+
function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
764
|
+
const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
|
|
765
|
+
if (sourceCss && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss) || hasTailwindGeneratedCss(sourceCss) || hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
|
|
766
|
+
return rawSource;
|
|
767
|
+
}
|
|
768
|
+
function shouldConsumeWebpackLoaderGeneratedCss(options) {
|
|
769
|
+
if (!options.shouldRegenerateExplicitTailwindV4CssSource) return true;
|
|
770
|
+
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
771
|
+
if (options.hasBundlerGeneratedCssMarker) return true;
|
|
772
|
+
if (options.watchMode === true && options.loaderGeneratedClassSet && options.sourceCandidates && hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates)) return false;
|
|
773
|
+
return Boolean(options.allowMarkerlessRegistryMatch && options.loaderGeneratedClassSet && options.sourceCandidates && !hasMissingRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates) && !hasStaleRuntimeCandidates(options.loaderGeneratedClassSet, options.sourceCandidates));
|
|
774
|
+
}
|
|
775
|
+
function hasDeferredWebpackGeneratedCss(source, generatedClassSets) {
|
|
776
|
+
const selectors = collectRawSourceClassSelectors(source);
|
|
777
|
+
for (const classSet of generatedClassSets) for (const candidate of classSet) if (selectors.has(candidate)) return true;
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
function hasUsableWebpackGeneratorCssSources(cssSources) {
|
|
339
781
|
return Array.isArray(cssSources) && cssSources.some((source) => typeof source?.css === "string" && source.css.length > 0);
|
|
340
782
|
}
|
|
341
783
|
function normalizeWebpackGeneratorCssSources(cssSources) {
|
|
@@ -389,26 +831,6 @@ function shouldUseWebpackAssetAsGeneratorUserCss(rawSource, generatorRawSource,
|
|
|
389
831
|
const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
|
|
390
832
|
return rawSource !== generatorRawSource && (options.processed === true || !rawSource.includes("data:")) && !hasTailwindRootDirectives(rawSource, { importFallback: true }) && !hasTailwindSourceDirectives(rawSource, { importFallback: true }) && !hasTailwindApplyDirective(rawSource) && rawMarkers.size > 0 && !isOnlyWebpackTailwindGeneratedPreflightCss(rawSource) && (!hasTailwindGeneratedCssMarkers(rawSource) || hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource));
|
|
391
833
|
}
|
|
392
|
-
function collectWebpackAssetUserCssMarkers(source) {
|
|
393
|
-
const markers = /* @__PURE__ */ new Set();
|
|
394
|
-
for (const match of source.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
395
|
-
for (const match of source.matchAll(/@(?:-[\w-]+-)?keyframes\s+((?:\\.|[-\w\u00A0-\uFFFF])+)/gi)) markers.add(`keyframes:${match[1]}`);
|
|
396
|
-
try {
|
|
397
|
-
const root = postcss.parse(source);
|
|
398
|
-
root.walkRules((rule) => {
|
|
399
|
-
for (const selector of rule.selectors) if (!/(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector)) markers.add(`selector:${selector.trim().replace(/\s+/g, " ")}`);
|
|
400
|
-
rule.walkDecls((decl) => {
|
|
401
|
-
if (decl.prop.startsWith("--")) markers.add(`custom-property:${decl.prop}`);
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
root.walkAtRules("font-face", (rule) => {
|
|
405
|
-
rule.walkDecls("font-family", (decl) => {
|
|
406
|
-
markers.add(`font-face:${decl.value.trim()}`);
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
} catch {}
|
|
410
|
-
return markers;
|
|
411
|
-
}
|
|
412
834
|
function hasWebpackClassSelector(selector) {
|
|
413
835
|
return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
|
|
414
836
|
}
|
|
@@ -448,215 +870,8 @@ function collectWebpackBareSelectorUserCss(source) {
|
|
|
448
870
|
return "";
|
|
449
871
|
}
|
|
450
872
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
"base",
|
|
454
|
-
"utilities"
|
|
455
|
-
]);
|
|
456
|
-
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
457
|
-
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
458
|
-
const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
|
|
459
|
-
const WEBPACK_TAILWIND_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
460
|
-
"*",
|
|
461
|
-
":after",
|
|
462
|
-
":before",
|
|
463
|
-
"::after",
|
|
464
|
-
"::before",
|
|
465
|
-
"::backdrop",
|
|
466
|
-
"view",
|
|
467
|
-
"text"
|
|
468
|
-
]);
|
|
469
|
-
const WEBPACK_TAILWIND_PREFLIGHT_PROPS = /* @__PURE__ */ new Set([
|
|
470
|
-
"box-sizing",
|
|
471
|
-
"border",
|
|
472
|
-
"border-width",
|
|
473
|
-
"border-style",
|
|
474
|
-
"border-color",
|
|
475
|
-
"margin",
|
|
476
|
-
"padding"
|
|
477
|
-
]);
|
|
478
|
-
const WEBPACK_TAILWIND_THEME_TOKEN_RE = /^--(?:tw-|color-|spacing|breakpoint-|container-|text-|font-|tracking-|leading-|radius-|shadow-|inset-shadow-|drop-shadow-|ease-|animate-|blur-|perspective-|aspect-|default-)/;
|
|
479
|
-
function parseWebpackCssLayerNames(params) {
|
|
480
|
-
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
481
|
-
}
|
|
482
|
-
function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
483
|
-
const cleaned = removeTailwindV4GeneratedUserCssArtifacts(source);
|
|
484
|
-
try {
|
|
485
|
-
const root = postcss.parse(cleaned);
|
|
486
|
-
let changed = false;
|
|
487
|
-
let removingBannerPrefix = false;
|
|
488
|
-
for (const node of [...root.nodes]) {
|
|
489
|
-
if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
|
|
490
|
-
node.remove();
|
|
491
|
-
changed = true;
|
|
492
|
-
removingBannerPrefix = true;
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
if (!removingBannerPrefix) continue;
|
|
496
|
-
if (isWebpackTailwindGeneratedPrefixNode(node)) {
|
|
497
|
-
node.remove();
|
|
498
|
-
changed = true;
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
removingBannerPrefix = false;
|
|
502
|
-
}
|
|
503
|
-
root.walkAtRules("layer", (rule) => {
|
|
504
|
-
const names = parseWebpackCssLayerNames(rule.params);
|
|
505
|
-
const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
506
|
-
const isLayerDeclaration = rule.nodes === void 0;
|
|
507
|
-
const shouldRemoveLayer = isLayerDeclaration ? hasGeneratedLayerName : names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
508
|
-
if (shouldRemoveLayer && isLayerDeclaration) {
|
|
509
|
-
rule.remove();
|
|
510
|
-
changed = true;
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
if (shouldRemoveLayer && !names.includes("utilities")) {
|
|
514
|
-
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
515
|
-
child.remove();
|
|
516
|
-
changed = true;
|
|
517
|
-
}
|
|
518
|
-
if (rule.nodes?.length === 0) {
|
|
519
|
-
rule.remove();
|
|
520
|
-
changed = true;
|
|
521
|
-
}
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
if (shouldRemoveLayer) {
|
|
525
|
-
for (const child of [...rule.nodes ?? []]) if (isWebpackTailwindGeneratedLayerNode(child, names)) {
|
|
526
|
-
child.remove();
|
|
527
|
-
changed = true;
|
|
528
|
-
}
|
|
529
|
-
if (rule.nodes?.length === 0) {
|
|
530
|
-
rule.remove();
|
|
531
|
-
changed = true;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
root.walkRules((rule) => {
|
|
536
|
-
if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
|
|
537
|
-
const selector = rule.selector.trim();
|
|
538
|
-
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || isWebpackTailwindGeneratedPreflightRule(rule)) {
|
|
539
|
-
rule.remove();
|
|
540
|
-
changed = true;
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
root.walkComments((comment) => {
|
|
544
|
-
if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
|
|
545
|
-
comment.remove();
|
|
546
|
-
changed = true;
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
root.walkAtRules((rule) => {
|
|
550
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
551
|
-
rule.remove();
|
|
552
|
-
changed = true;
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
return changed ? root.toString() : cleaned;
|
|
556
|
-
} catch {
|
|
557
|
-
return cleaned;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function isWebpackTailwindGeneratedPrefixNode(node) {
|
|
561
|
-
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, [
|
|
562
|
-
"theme",
|
|
563
|
-
"base",
|
|
564
|
-
"utilities"
|
|
565
|
-
], true);
|
|
566
|
-
if (node.type !== "atrule") return false;
|
|
567
|
-
const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
|
|
568
|
-
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
569
|
-
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) {
|
|
570
|
-
if (node.nodes === void 0) return true;
|
|
571
|
-
return node.nodes.length > 0 && node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, names));
|
|
572
|
-
}
|
|
573
|
-
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
574
|
-
return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
|
|
575
|
-
}
|
|
576
|
-
function isWebpackTailwindGeneratedLayerNode(node, layerNames) {
|
|
577
|
-
if (node.type === "rule") return isWebpackTailwindGeneratedRule(node, layerNames, false);
|
|
578
|
-
if (node.type !== "atrule") return false;
|
|
579
|
-
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
580
|
-
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
581
|
-
return node.nodes.every((child) => isWebpackTailwindGeneratedLayerNode(child, layerNames));
|
|
582
|
-
}
|
|
583
|
-
function isWebpackTailwindGeneratedRule(rule, layerNames, includePrefix) {
|
|
584
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
585
|
-
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), includePrefix))) return true;
|
|
586
|
-
if (selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true))) return true;
|
|
587
|
-
if (layerNames.includes("theme") && isWebpackTailwindGeneratedThemeRule(rule)) return true;
|
|
588
|
-
if (layerNames.includes("base") && isWebpackTailwindGeneratedPreflightRule(rule)) return true;
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
function isWebpackTailwindGeneratedThemeRule(rule) {
|
|
592
|
-
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
593
|
-
return declarations.length > 0 && declarations.every((decl) => WEBPACK_TAILWIND_THEME_TOKEN_RE.test(decl.prop) || decl.value.includes("--theme("));
|
|
594
|
-
}
|
|
595
|
-
function isWebpackTailwindGeneratedPreflightRule(rule) {
|
|
596
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
597
|
-
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
598
|
-
return selectors.length > 0 && declarations.length > 0 && selectors.every((selector) => {
|
|
599
|
-
const normalized = selector.trim().replace(/\s+/g, " ");
|
|
600
|
-
return WEBPACK_TAILWIND_PREFLIGHT_SELECTORS.has(normalized);
|
|
601
|
-
}) && declarations.every((decl) => WEBPACK_TAILWIND_PREFLIGHT_PROPS.has(decl.prop));
|
|
602
|
-
}
|
|
603
|
-
function isOnlyWebpackTailwindGeneratedPreflightCss(source) {
|
|
604
|
-
try {
|
|
605
|
-
const nodes = postcss.parse(source).nodes ?? [];
|
|
606
|
-
return nodes.length > 0 && nodes.every((node) => {
|
|
607
|
-
if (node.type === "rule") return isWebpackTailwindGeneratedPreflightRule(node);
|
|
608
|
-
return node.type === "atrule" && (node.nodes === void 0 || node.nodes.length === 0);
|
|
609
|
-
});
|
|
610
|
-
} catch {
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
|
|
615
|
-
return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
|
|
616
|
-
}
|
|
617
|
-
function collectWebpackCssRuleIdentityMarkers(source) {
|
|
618
|
-
const markers = /* @__PURE__ */ new Set();
|
|
619
|
-
try {
|
|
620
|
-
const root = postcss.parse(source);
|
|
621
|
-
root.walkRules((rule) => {
|
|
622
|
-
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
623
|
-
});
|
|
624
|
-
root.walkAtRules("keyframes", (rule) => {
|
|
625
|
-
if (rule.params) markers.add(`keyframes:${rule.params}`);
|
|
626
|
-
});
|
|
627
|
-
} catch {}
|
|
628
|
-
return markers;
|
|
629
|
-
}
|
|
630
|
-
function unescapeCssIdentifier(value) {
|
|
631
|
-
return value.replace(/\\([0-9a-f]{1,6}\s?|.)/gi, (_match, escaped) => {
|
|
632
|
-
const hex = escaped.trim();
|
|
633
|
-
if (/^[0-9a-f]+$/i.test(hex)) return String.fromCodePoint(Number.parseInt(hex, 16));
|
|
634
|
-
return escaped;
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
function collectGeneratedCssRuntimeCandidates(source) {
|
|
638
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
639
|
-
if (hasBundlerGeneratedCssMarker(source) || !hasTailwindGeneratedCss(source) && !hasTailwindGeneratedCssMarkers(source)) return candidates;
|
|
640
|
-
try {
|
|
641
|
-
postcss.parse(source).walkRules((rule) => {
|
|
642
|
-
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[\w\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/g)) {
|
|
643
|
-
const candidate = unescapeCssIdentifier(match[1]);
|
|
644
|
-
if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
} catch {}
|
|
648
|
-
return candidates;
|
|
649
|
-
}
|
|
650
|
-
function hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource) {
|
|
651
|
-
const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
|
|
652
|
-
if (rawMarkers.size === 0) return false;
|
|
653
|
-
const generatorMarkers = collectWebpackAssetUserCssMarkers(generatorRawSource);
|
|
654
|
-
for (const marker of rawMarkers) if (!generatorMarkers.has(marker)) return true;
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
function hasWebpackTailwindSourceDirectives(source) {
|
|
658
|
-
return Boolean(source) && (hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source) || hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source));
|
|
659
|
-
}
|
|
873
|
+
//#endregion
|
|
874
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.ts
|
|
660
875
|
function isWebpackTailwindImportRequest(request) {
|
|
661
876
|
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/") || request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
662
877
|
}
|
|
@@ -683,264 +898,57 @@ function isWebpackCssSourceRepresentedInAsset(rawSource, sourceCss) {
|
|
|
683
898
|
for (const marker of sourceMarkers) if (!rawMarkers.has(marker)) return false;
|
|
684
899
|
return true;
|
|
685
900
|
}
|
|
686
|
-
function createWebpackGeneratorCssSource(file, css) {
|
|
687
|
-
if (!file || !css || !hasWebpackTailwindSourceDirectives(css)) return;
|
|
688
|
-
return {
|
|
689
|
-
file,
|
|
690
|
-
base: path.dirname(file),
|
|
691
|
-
css,
|
|
692
|
-
dependencies: [file]
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
function createWebpackUserCssSourceAppend(sources, generatorRawSource, currentSourceFile, shouldIncludeSource) {
|
|
696
|
-
const matchedSources = [];
|
|
697
|
-
const seen = /* @__PURE__ */ new Set();
|
|
698
|
-
for (const source of sources) {
|
|
699
|
-
const css = source.css;
|
|
700
|
-
if (!css || seen.has(css)) continue;
|
|
701
|
-
if (shouldIncludeSource && !shouldIncludeSource(source.file)) continue;
|
|
702
|
-
seen.add(css);
|
|
703
|
-
if ((source.processed === true || !css.includes("data:")) && hasAdditionalWebpackAssetUserCssMarkers(css, generatorRawSource)) matchedSources.push({
|
|
704
|
-
css,
|
|
705
|
-
file: source.file,
|
|
706
|
-
processed: source.processed === true
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
const currentFile = currentSourceFile ? path.resolve(currentSourceFile) : void 0;
|
|
710
|
-
const parts = matchedSources.sort((a, b) => {
|
|
711
|
-
const aCurrent = currentFile !== void 0 && path.resolve(a.file) === currentFile;
|
|
712
|
-
if (aCurrent !== (currentFile !== void 0 && path.resolve(b.file) === currentFile)) return aCurrent ? -1 : 1;
|
|
713
|
-
return a.file.localeCompare(b.file);
|
|
714
|
-
}).map((source) => source.css);
|
|
715
|
-
return parts.length > 0 ? {
|
|
716
|
-
css: parts.join("\n"),
|
|
717
|
-
processed: matchedSources.every((source) => source.processed)
|
|
718
|
-
} : void 0;
|
|
719
|
-
}
|
|
720
|
-
function createWebpackGeneratorUserCssSourceAppend(...sources) {
|
|
721
|
-
const parts = sources.filter((source) => source !== void 0 && source.css.trim().length > 0);
|
|
722
|
-
if (parts.length === 0) return;
|
|
723
|
-
let css = "";
|
|
724
|
-
const usedParts = [];
|
|
725
|
-
for (const source of parts) {
|
|
726
|
-
const merged = css.trim().length > 0 ? mergeCoveredCssRuleDeclarations(css, source.css) : void 0;
|
|
727
|
-
if (merged?.changed) css = merged.baseCss;
|
|
728
|
-
const nextCss = css.trim().length > 0 ? filterExistingCssRules(css, merged?.css ?? source.css) : source.css;
|
|
729
|
-
if (!(nextCss.trim().length > 0)) continue;
|
|
730
|
-
css = createCssSourceOrderAppend(css, nextCss);
|
|
731
|
-
usedParts.push(source);
|
|
732
|
-
}
|
|
733
|
-
return {
|
|
734
|
-
css,
|
|
735
|
-
processed: usedParts.every((source) => source.processed)
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
function resolveWebpackMemoryDebugStats(context) {
|
|
739
|
-
if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
|
|
740
|
-
const memory = process.memoryUsage();
|
|
741
|
-
const processCacheInstanceSize = context.cache.instance.size;
|
|
742
|
-
const processCacheHashMapSize = context.cache.hashMap.size;
|
|
743
|
-
return {
|
|
744
|
-
phase: context.phase,
|
|
745
|
-
process: {
|
|
746
|
-
rssMb: toMb(memory.rss),
|
|
747
|
-
heapTotalMb: toMb(memory.heapTotal),
|
|
748
|
-
heapUsedMb: toMb(memory.heapUsed),
|
|
749
|
-
externalMb: toMb(memory.external),
|
|
750
|
-
arrayBuffersMb: toMb(memory.arrayBuffers)
|
|
751
|
-
},
|
|
752
|
-
assets: {
|
|
753
|
-
active: context.activeAssetFiles,
|
|
754
|
-
activeCss: context.activeCssFiles
|
|
755
|
-
},
|
|
756
|
-
processCache: {
|
|
757
|
-
instance: processCacheInstanceSize,
|
|
758
|
-
hashMap: processCacheHashMapSize,
|
|
759
|
-
activeCacheKeys: context.activeProcessCacheKeys.size,
|
|
760
|
-
activeHashKeys: context.activeProcessHashKeys.size,
|
|
761
|
-
staleCacheKeys: Math.max(0, processCacheInstanceSize - context.activeProcessCacheKeys.size),
|
|
762
|
-
staleHashKeys: Math.max(0, processCacheHashMapSize - context.activeProcessHashKeys.size),
|
|
763
|
-
pruned: true,
|
|
764
|
-
pruneSkipped: false
|
|
765
|
-
},
|
|
766
|
-
webpackCss: {
|
|
767
|
-
handlerOptions: context.cssHandlerOptionsCache.size,
|
|
768
|
-
userHandlerOptions: context.cssUserHandlerOptionsCache.size,
|
|
769
|
-
maxHandlerOptions: WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX
|
|
770
|
-
},
|
|
771
|
-
sourceCandidateScan: context.sourceCandidateScan,
|
|
772
|
-
tailwind: { v4: getTailwindV4IncrementalGenerateCacheStats() }
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
function shouldInjectWebpackCssTracePreflight(_appType, cssHandlerOptions) {
|
|
776
|
-
if (includesTailwindPreflightImport(cssHandlerOptions.sourceOptions?.sourceCss)) return true;
|
|
777
|
-
return cssHandlerOptions.isMainChunk !== false;
|
|
778
|
-
}
|
|
779
|
-
function includesTailwindPreflightImport(source) {
|
|
780
|
-
if (!source) return false;
|
|
781
|
-
try {
|
|
782
|
-
let includesPreflight = false;
|
|
783
|
-
postcss.parse(source).walkAtRules((rule) => {
|
|
784
|
-
if (rule.name === "tailwind") {
|
|
785
|
-
includesPreflight || (includesPreflight = rule.params.trim() === "base");
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
if (rule.name !== "import") return;
|
|
789
|
-
const request = parseImportRequest(rule.params)?.replaceAll("\\", "/");
|
|
790
|
-
includesPreflight || (includesPreflight = request === "tailwindcss" || request === "tailwindcss/preflight.css" || request?.endsWith("/tailwindcss/index.css") === true || request?.endsWith("/tailwindcss/preflight.css") === true);
|
|
791
|
-
});
|
|
792
|
-
return includesPreflight;
|
|
793
|
-
} catch {
|
|
794
|
-
return false;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
798
|
-
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
799
|
-
if (isWebGeneratorTarget) return source;
|
|
800
|
-
return stripMiniProgramCssSpecificityPlaceholders(removeTailwindV4StandaloneHostPreflightRule(finalizeMiniProgramCss(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
|
|
801
|
-
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? resolveConfiguredWebpackCssPreflight(compilerOptions, styleOptions) : void 0,
|
|
802
|
-
isTailwindcssV4: true,
|
|
803
|
-
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
804
|
-
})));
|
|
805
|
-
}
|
|
806
|
-
function shouldFallbackToWebpackUserCssOnGeneratorError(options) {
|
|
807
|
-
return !hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindSourceDirectives(options.generatorRawSource, { importFallback: true }) && !hasTailwindApplyDirective(options.generatorRawSource) && !options.hasExplicitTailwindV4SourceCss && options.configuredMainCssEntryFilesLength === 0;
|
|
808
|
-
}
|
|
809
|
-
function isWindowsAbsoluteResourcePath(file) {
|
|
810
|
-
return /^[a-z]:[\\/]/i.test(file) || /^[/\\]{2}[^/\\]/.test(file);
|
|
811
|
-
}
|
|
812
|
-
function isPosixAbsoluteResourcePath(file) {
|
|
813
|
-
return file.startsWith("/");
|
|
814
|
-
}
|
|
815
|
-
function resolveWebpackResourcePath(file, base) {
|
|
816
|
-
if (isWindowsAbsoluteResourcePath(file)) return path.win32.resolve(file);
|
|
817
|
-
if (isPosixAbsoluteResourcePath(file)) return path.posix.resolve(file);
|
|
818
|
-
if (base) {
|
|
819
|
-
if (isWindowsAbsoluteResourcePath(base)) return path.win32.resolve(base, file);
|
|
820
|
-
if (isPosixAbsoluteResourcePath(base)) return path.posix.resolve(base, file);
|
|
821
|
-
return path.resolve(base, file);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
function dirnameWebpackResourcePath(file) {
|
|
825
|
-
if (isWindowsAbsoluteResourcePath(file)) return path.win32.dirname(file);
|
|
826
|
-
if (isPosixAbsoluteResourcePath(file)) return path.posix.dirname(file);
|
|
827
|
-
return path.dirname(file);
|
|
828
|
-
}
|
|
829
|
-
function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
|
|
830
|
-
if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
|
|
831
|
-
const normalized = stripResourceQuery(resource);
|
|
832
|
-
if (!normalized) return;
|
|
833
|
-
const absoluteResource = resolveWebpackResourcePath(normalized);
|
|
834
|
-
if (absoluteResource) return absoluteResource;
|
|
835
|
-
const issuerResource = issuer?.resource ? stripResourceQuery(issuer.resource) : void 0;
|
|
836
|
-
const issuerResourcePath = issuerResource ? resolveWebpackResourcePath(issuerResource) : void 0;
|
|
837
|
-
return resolveWebpackResourcePath(normalized, issuerResourcePath ? dirnameWebpackResourcePath(issuerResourcePath) : issuer?.context);
|
|
838
|
-
}
|
|
839
|
-
function isSameWebpackCssSourceScope(options) {
|
|
840
|
-
if (!options.currentSourceFile) return false;
|
|
841
|
-
const candidateKey = resolveWebpackResourcePath(options.candidateSourceFile) ?? path.resolve(options.candidateSourceFile);
|
|
842
|
-
if (candidateKey === (resolveWebpackResourcePath(options.currentSourceFile) ?? path.resolve(options.currentSourceFile))) return true;
|
|
843
|
-
const outputResources = options.resourcesByAsset.get(options.outputFile);
|
|
844
|
-
if (!outputResources) return false;
|
|
845
|
-
return [...outputResources].some((resource) => {
|
|
846
|
-
return (resolveWebpackResourcePath(resource) ?? path.resolve(resource)) === candidateKey;
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
function shouldAppendCurrentWebpackAssetUserCss(options) {
|
|
850
|
-
const hasGeneratedAssetUserCss = options.currentAssetLooksGenerated && options.currentAssetHasUserCss;
|
|
851
|
-
return !options.currentAssetHasBundlerGeneratedMarker && !options.shouldPreserveGeneratedWebAssetUserCss && (hasGeneratedAssetUserCss || !options.sourceCssProcessed || options.registeredUserRawSource === void 0 || options.currentAssetHasUserCss) && !(options.sourceCssProcessed && options.currentAssetLooksGenerated && !options.currentAssetHasUserCss);
|
|
852
|
-
}
|
|
853
|
-
function createWebpackCurrentAssetUserRawSource(options) {
|
|
854
|
-
if (!options.shouldAppendCurrentAssetUserCss) return;
|
|
855
|
-
if (options.sourceCssProcessed) return {
|
|
856
|
-
css: options.currentAssetUserCssSource,
|
|
857
|
-
processed: true
|
|
858
|
-
};
|
|
859
|
-
if (!options.currentAssetHasUserCss) return;
|
|
860
|
-
return {
|
|
861
|
-
css: options.currentAssetUserCssSource,
|
|
862
|
-
processed: options.currentAssetLooksGenerated
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
|
|
866
|
-
if (options.finalized === true) return options.annotateCss(css);
|
|
867
|
-
if (options.isWebGeneratorTarget || !isCssSourceTraceEnabled(options.compilerOptions)) return options.annotateCss(css);
|
|
868
|
-
const finalized = finalizeMiniProgramUserCssAssetSource(css, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
|
|
869
|
-
return options.annotateCss(finalized);
|
|
870
|
-
}
|
|
871
|
-
function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
872
|
-
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
873
|
-
if (isWebGeneratorTarget) {
|
|
874
|
-
if (options.generatedCss === true) return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(stripBundlerGeneratedCssMarkers(source))));
|
|
875
|
-
return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
|
|
876
|
-
}
|
|
877
|
-
let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
878
|
-
if (options.generatedCss !== true) {
|
|
879
|
-
finalized = finalizeMiniProgramCss(finalized, {
|
|
880
|
-
cssPreflight: false,
|
|
881
|
-
isTailwindcssV4: true,
|
|
882
|
-
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
883
|
-
});
|
|
884
|
-
finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
885
|
-
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
886
|
-
}
|
|
887
|
-
try {
|
|
888
|
-
finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: options.cssPreflight !== false });
|
|
889
|
-
} catch {}
|
|
890
|
-
const shouldRemoveExistingPreflight = options.cssPreflight === false && options.preserveExistingPreflight === false;
|
|
891
|
-
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
892
|
-
const hasExistingMiniProgramPreflight = options.preserveExistingPreflight !== false && hasMiniProgramPreflightSelector(source);
|
|
893
|
-
finalized = finalizeMiniProgramCss(finalized, {
|
|
894
|
-
cssPreflight: options.cssPreflight === false && !hasExistingMiniProgramPreflight ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? resolveExistingWebpackCssPreflight(compilerOptions, styleOptions, source) : void 0,
|
|
895
|
-
isTailwindcssV4: true,
|
|
896
|
-
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
897
|
-
});
|
|
898
|
-
finalized = ensureWebpackMiniProgramTwContentInit(finalized);
|
|
899
|
-
if (shouldRemoveExistingPreflight) finalized = removeMiniProgramPreflightSelectorRule(finalized);
|
|
900
|
-
else finalized = dedupeMiniProgramPreflightSelectorRules(finalized);
|
|
901
|
-
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
902
|
-
}
|
|
903
|
-
function finalizeWebpackCssAssetOutputSource(source, compilerOptions, isWebGeneratorTarget) {
|
|
904
|
-
if (isWebGeneratorTarget) return source;
|
|
905
|
-
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
906
|
-
return stripMiniProgramCssSpecificityPlaceholders(removeMiniProgramHoverSelectors(dedupeCoveredCssRules(dedupeMiniProgramPreflightSelectorRules(source)), styleOptions.cssRemoveHoverPseudoClass));
|
|
907
|
-
}
|
|
908
|
-
function collectWebpackJsRuntimeCandidatesFromAssets(options) {
|
|
909
|
-
if (options.isWebGeneratorTarget) return;
|
|
910
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
911
|
-
for (const file of options.jsAssets) {
|
|
912
|
-
const sourceLike = options.getAssetSource(file);
|
|
913
|
-
if (sourceLike === void 0) continue;
|
|
914
|
-
const source = stringifyWebpackSourceLike(sourceLike);
|
|
915
|
-
for (const candidate of collectStrictEscapedRuntimeCandidates(source, MappingChars2String, options.escapeFragments)) if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
916
|
-
}
|
|
917
|
-
return candidates;
|
|
918
|
-
}
|
|
919
|
-
function collectWebpackJsRuntimeTokenSignature(options) {
|
|
920
|
-
if (options.isWebGeneratorTarget) return "";
|
|
921
|
-
const tokens = [];
|
|
922
|
-
for (const file of options.jsAssets) {
|
|
923
|
-
const sourceLike = options.getAssetSource(file);
|
|
924
|
-
if (sourceLike === void 0) continue;
|
|
925
|
-
tokens.push(...collectRuntimeTokenSignatureParts(stringifyWebpackSourceLike(sourceLike)));
|
|
926
|
-
}
|
|
927
|
-
return tokens.sort().join("\n");
|
|
928
|
-
}
|
|
929
|
-
function addRuntimeTransformCandidates(target, candidates) {
|
|
930
|
-
if (!candidates?.size) return;
|
|
931
|
-
for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate)) target.add(candidate);
|
|
932
|
-
}
|
|
933
|
-
function createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates) {
|
|
934
|
-
if (!isCssSourceTraceEnabled(compilerOptions) || !webpackSourceCandidates) return;
|
|
935
|
-
return createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions);
|
|
901
|
+
function createWebpackGeneratorCssSource(file, css) {
|
|
902
|
+
if (!file || !css || !hasWebpackTailwindSourceDirectives(css)) return;
|
|
903
|
+
return {
|
|
904
|
+
file,
|
|
905
|
+
base: path.dirname(file),
|
|
906
|
+
css,
|
|
907
|
+
dependencies: [file]
|
|
908
|
+
};
|
|
936
909
|
}
|
|
937
|
-
function
|
|
938
|
-
|
|
910
|
+
function createWebpackUserCssSourceAppend(sources, generatorRawSource, currentSourceFile, shouldIncludeSource) {
|
|
911
|
+
const matchedSources = [];
|
|
912
|
+
const seen = /* @__PURE__ */ new Set();
|
|
913
|
+
for (const source of sources) {
|
|
914
|
+
const css = source.css;
|
|
915
|
+
if (!css || seen.has(css)) continue;
|
|
916
|
+
if (shouldIncludeSource && !shouldIncludeSource(source.file)) continue;
|
|
917
|
+
seen.add(css);
|
|
918
|
+
if ((source.processed === true || !css.includes("data:")) && hasAdditionalWebpackAssetUserCssMarkers(css, generatorRawSource)) matchedSources.push({
|
|
919
|
+
css,
|
|
920
|
+
file: source.file,
|
|
921
|
+
processed: source.processed === true
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
const currentFile = currentSourceFile ? path.resolve(currentSourceFile) : void 0;
|
|
925
|
+
const parts = matchedSources.sort((a, b) => {
|
|
926
|
+
const aCurrent = currentFile !== void 0 && path.resolve(a.file) === currentFile;
|
|
927
|
+
if (aCurrent !== (currentFile !== void 0 && path.resolve(b.file) === currentFile)) return aCurrent ? -1 : 1;
|
|
928
|
+
return a.file.localeCompare(b.file);
|
|
929
|
+
}).map((source) => source.css);
|
|
930
|
+
return parts.length > 0 ? {
|
|
931
|
+
css: parts.join("\n"),
|
|
932
|
+
processed: matchedSources.every((source) => source.processed)
|
|
933
|
+
} : void 0;
|
|
939
934
|
}
|
|
940
|
-
function
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
935
|
+
function createWebpackGeneratorUserCssSourceAppend(...sources) {
|
|
936
|
+
const parts = sources.filter((source) => source !== void 0 && source.css.trim().length > 0);
|
|
937
|
+
if (parts.length === 0) return;
|
|
938
|
+
let css = "";
|
|
939
|
+
const usedParts = [];
|
|
940
|
+
for (const source of parts) {
|
|
941
|
+
const merged = css.trim().length > 0 ? mergeCoveredCssRuleDeclarations(css, source.css) : void 0;
|
|
942
|
+
if (merged?.changed) css = merged.baseCss;
|
|
943
|
+
const nextCss = css.trim().length > 0 ? filterExistingCssRules(css, merged?.css ?? source.css) : source.css;
|
|
944
|
+
if (!(nextCss.trim().length > 0)) continue;
|
|
945
|
+
css = createCssSourceOrderAppend(css, nextCss);
|
|
946
|
+
usedParts.push(source);
|
|
947
|
+
}
|
|
948
|
+
return {
|
|
949
|
+
css,
|
|
950
|
+
processed: usedParts.every((source) => source.processed)
|
|
951
|
+
};
|
|
944
952
|
}
|
|
945
953
|
//#endregion
|
|
946
954
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.ts
|
|
@@ -1196,6 +1204,343 @@ function createWebpackCssSourceResolvers(options) {
|
|
|
1196
1204
|
};
|
|
1197
1205
|
}
|
|
1198
1206
|
//#endregion
|
|
1207
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.ts
|
|
1208
|
+
async function finalizeWebpackProcessAssets(context) {
|
|
1209
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeWebpackCssSourceFiles, compilerOptions, cssAssetResources, cssHandlerOptionsCache, cssTaskFactories, cssUserHandlerOptionsCache, debug, entries, groupedEntries, hmrTimingStartedAt, htmlTaskFactories, jsTaskFactories, pruneWebpackCssSources, recordTimingDetail, registeredWebpackCssSourceFiles, taskConcurrency, tasks, timingDetails, watchMode, webpackSourceCandidateScanCache } = context;
|
|
1210
|
+
if (!watchMode) {
|
|
1211
|
+
pushConcurrentTaskFactories(tasks, htmlTaskFactories, taskConcurrency);
|
|
1212
|
+
await Promise.all(tasks);
|
|
1213
|
+
tasks.length = 0;
|
|
1214
|
+
pushConcurrentTaskFactories(tasks, jsTaskFactories, taskConcurrency);
|
|
1215
|
+
await Promise.all(tasks);
|
|
1216
|
+
tasks.length = 0;
|
|
1217
|
+
pushConcurrentTaskFactories(tasks, cssTaskFactories, taskConcurrency);
|
|
1218
|
+
}
|
|
1219
|
+
const taskWaitStartedAt = performance.now();
|
|
1220
|
+
await Promise.all(tasks);
|
|
1221
|
+
recordTimingDetail("tasks.wait", taskWaitStartedAt);
|
|
1222
|
+
const pruneStartedAt = performance.now();
|
|
1223
|
+
compilerOptions.cache.prune?.({
|
|
1224
|
+
cacheKeys: activeProcessCacheKeys,
|
|
1225
|
+
hashKeys: activeProcessHashKeys
|
|
1226
|
+
});
|
|
1227
|
+
const activeCssFiles = new Set(groupedEntries.css.map(([file]) => file));
|
|
1228
|
+
pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
|
|
1229
|
+
if (activeCssFiles.size > 0) pruneWebpackCssSources?.(/* @__PURE__ */ new Set([
|
|
1230
|
+
...registeredWebpackCssSourceFiles,
|
|
1231
|
+
...activeWebpackCssSourceFiles,
|
|
1232
|
+
...[...cssAssetResources.values()].flatMap((resources) => [...resources])
|
|
1233
|
+
]), { watchMode });
|
|
1234
|
+
recordTimingDetail("cache.prune", pruneStartedAt);
|
|
1235
|
+
debug("end");
|
|
1236
|
+
emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, {
|
|
1237
|
+
...timingDetails,
|
|
1238
|
+
memoryDebug: resolveWebpackMemoryDebugStats({
|
|
1239
|
+
activeAssetFiles: entries.length,
|
|
1240
|
+
activeCssFiles: activeCssFiles.size,
|
|
1241
|
+
activeProcessCacheKeys,
|
|
1242
|
+
activeProcessHashKeys,
|
|
1243
|
+
cache: compilerOptions.cache,
|
|
1244
|
+
cssHandlerOptionsCache,
|
|
1245
|
+
cssUserHandlerOptionsCache,
|
|
1246
|
+
phase: "processAssets",
|
|
1247
|
+
sourceCandidateScan: webpackSourceCandidateScanCache.getMemoryStats()
|
|
1248
|
+
})
|
|
1249
|
+
});
|
|
1250
|
+
compilerOptions.onEnd();
|
|
1251
|
+
}
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region src/bundlers/webpack/shared/css-loader-runtime.ts
|
|
1254
|
+
function isWebpackCssLoaderRuntimeSource(source) {
|
|
1255
|
+
return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && source.includes("module.exports = ___CSS_LOADER_EXPORT___");
|
|
1256
|
+
}
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.ts
|
|
1259
|
+
async function finalizeWebpackGeneratedCssResult(context) {
|
|
1260
|
+
const { ConcatSource, compilerOptions, cssHandlerOptions, currentRawSource, debug, file, finalizeCssAssetSource, finalizeTracedCss, generated, generatorRawSource, generatorRuntimeSet, isWebGeneratorTarget, runtimeState, shouldPreserveExistingPreflight, sourceCss, sourceCssProcessed, userRawSource } = context;
|
|
1261
|
+
const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
|
|
1262
|
+
css: generated.css,
|
|
1263
|
+
processed: true
|
|
1264
|
+
}, {
|
|
1265
|
+
css: removeWebpackTailwindGeneratedAssetCss(currentRawSource),
|
|
1266
|
+
processed: true
|
|
1267
|
+
})?.css ?? generated.css : generated.css, {
|
|
1268
|
+
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1269
|
+
generatedCss: true,
|
|
1270
|
+
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
1271
|
+
}) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
|
|
1272
|
+
const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
|
|
1273
|
+
userRawSource,
|
|
1274
|
+
sourceCss === void 0 ? void 0 : {
|
|
1275
|
+
css: sourceCss,
|
|
1276
|
+
processed: sourceCssProcessed
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
css: generatorRawSource,
|
|
1280
|
+
processed: false
|
|
1281
|
+
}
|
|
1282
|
+
].map((source) => {
|
|
1283
|
+
if (source === void 0) return;
|
|
1284
|
+
return {
|
|
1285
|
+
css: collectWebpackBareSelectorUserCss(source.css),
|
|
1286
|
+
processed: source.processed
|
|
1287
|
+
};
|
|
1288
|
+
}));
|
|
1289
|
+
const handledSourceBareUserCss = sourceBareUserCss === void 0 ? "" : sourceBareUserCss.processed ? sourceBareUserCss.css : (await compilerOptions.styleHandler(sourceBareUserCss.css, cssHandlerOptions)).css;
|
|
1290
|
+
const finalizedSourceBareUserCss = handledSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledSourceBareUserCss, {
|
|
1291
|
+
cssPreflight: false,
|
|
1292
|
+
generatedCss: false
|
|
1293
|
+
});
|
|
1294
|
+
const missingSourceBareUserCss = finalizedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedGeneratedCss, finalizedSourceBareUserCss);
|
|
1295
|
+
const source = new ConcatSource(finalizeTracedCss(missingSourceBareUserCss.trim().length === 0 ? finalizedGeneratedCss : createWebpackGeneratorUserCssSourceAppend({
|
|
1296
|
+
css: finalizedGeneratedCss,
|
|
1297
|
+
processed: true
|
|
1298
|
+
}, {
|
|
1299
|
+
css: missingSourceBareUserCss,
|
|
1300
|
+
processed: true
|
|
1301
|
+
}).css, cssHandlerOptions, { finalized: true }));
|
|
1302
|
+
if (generated) {
|
|
1303
|
+
for (const className of generated.classSet) generatorRuntimeSet.add(className);
|
|
1304
|
+
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
|
|
1305
|
+
} else debug("css handle: %s", file);
|
|
1306
|
+
return { result: source };
|
|
1307
|
+
}
|
|
1308
|
+
//#endregion
|
|
1309
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.ts
|
|
1310
|
+
async function processWebpackGeneratedCssAsset(element, context) {
|
|
1311
|
+
const { ConcatSource, assetHashByChunk, compilation, compilerOptions, configuredCssEntryFiles, configuredMainCssEntryFiles, createRuntimeSetHash, cssSourceTraceSignature, cssSources, cssTaskFactories, debug, enqueueTask, finalizeCssAssetSource, finalizeTracedCss, generatedCssSources, generatorRuntimeSet, getCssHandlerOptions, getCssUserHandlerOptions, getGeneratorRuntimeSet, hasConfiguredTailwindV4SourceRoots, isSameWebpackSourceScope, isWebGeneratorTarget, rememberProcessCacheKey, resolveWebpackCssSourceFile, runtimeAffectingSourceHash, runtimeState, transformRuntimeSet, updateAssetIfChanged, watchMode, webpackSourceCandidateValueSignature, webpackSourceCandidates } = context;
|
|
1312
|
+
const [file, originalSource] = element;
|
|
1313
|
+
const currentRawSource = originalSource.source().toString();
|
|
1314
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1315
|
+
const cacheKey = file;
|
|
1316
|
+
const hashKey = `${file}:asset`;
|
|
1317
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1318
|
+
const cssHandlerOptionsForHash = getCssHandlerOptions(file, currentRawSource);
|
|
1319
|
+
const cssChunkHash = watchMode && cssHandlerOptionsForHash.isMainChunk ? void 0 : chunkHash;
|
|
1320
|
+
const cssSourceHash = (() => {
|
|
1321
|
+
const sourceFile = resolveWebpackCssSourceFile(file, currentRawSource);
|
|
1322
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
1323
|
+
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
1324
|
+
if (sourceCss === void 0) return sourceFile === void 0 ? "webpack-css-source:0" : `webpack-css-source:0:${sourceFile}`;
|
|
1325
|
+
return `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}:${generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss)}`;
|
|
1326
|
+
})();
|
|
1327
|
+
const runtimeAwareHash = createRuntimeAwareCssHash(cssChunkHash, compilerOptions.cache.computeHash(currentRawSource), `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}:${cssSourceHash}`);
|
|
1328
|
+
await enqueueTask(async () => {
|
|
1329
|
+
await processCachedTask({
|
|
1330
|
+
cache: compilerOptions.cache,
|
|
1331
|
+
cacheKey,
|
|
1332
|
+
hashKey,
|
|
1333
|
+
rawSource: currentRawSource,
|
|
1334
|
+
hash: runtimeAwareHash,
|
|
1335
|
+
applyResult(source, { cacheHit }) {
|
|
1336
|
+
updateAssetIfChanged(file, source, {
|
|
1337
|
+
compare: !cacheHit,
|
|
1338
|
+
notifyUpdate: !cacheHit
|
|
1339
|
+
});
|
|
1340
|
+
},
|
|
1341
|
+
onCacheHit() {
|
|
1342
|
+
debug("css cache hit: %s", file);
|
|
1343
|
+
},
|
|
1344
|
+
transform: async () => {
|
|
1345
|
+
await runtimeState.readyPromise;
|
|
1346
|
+
const cssHandlerOptions = getCssHandlerOptions(file, currentRawSource);
|
|
1347
|
+
const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
|
|
1348
|
+
if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
|
|
1349
|
+
const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
|
|
1350
|
+
const sourceCss = sourceFile ? cssSources.get(path.resolve(sourceFile))?.css : void 0;
|
|
1351
|
+
const isConfiguredCssSource = sourceFile !== void 0 && configuredCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
1352
|
+
const isConfiguredMainCssSource = sourceFile !== void 0 && configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
1353
|
+
const sourceCssHasTailwindRoot = sourceCss !== void 0 && hasTailwindRootDirectives(sourceCss, { importFallback: true });
|
|
1354
|
+
const shouldPreserveExistingPreflight = cssHandlerOptions.isMainChunk || !isConfiguredMainCssSource && (isConfiguredCssSource || sourceCssHasTailwindRoot);
|
|
1355
|
+
const loaderGeneratedCss = sourceFile ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
|
|
1356
|
+
const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1357
|
+
const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await resolveTailwindV4EntriesFromCssCached(sourceCss, path.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
|
|
1358
|
+
if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
|
|
1359
|
+
allowMarkerlessRegistryMatch: configuredCssEntryFiles.length === 1,
|
|
1360
|
+
hasBundlerGeneratedCssMarker: hasBundlerGeneratedCssMarker(currentRawSource),
|
|
1361
|
+
loaderGeneratedClassSet: loaderGeneratedCss.classSet,
|
|
1362
|
+
sourceCandidates: explicitTailwindV4SourceCandidates,
|
|
1363
|
+
shouldRegenerateExplicitTailwindV4CssSource,
|
|
1364
|
+
watchMode
|
|
1365
|
+
})) {
|
|
1366
|
+
for (const className of loaderGeneratedCss.classSet) {
|
|
1367
|
+
generatorRuntimeSet.add(className);
|
|
1368
|
+
transformRuntimeSet.add(className);
|
|
1369
|
+
}
|
|
1370
|
+
for (const dependency of loaderGeneratedCss.dependencies) compilation.fileDependencies?.add?.(dependency);
|
|
1371
|
+
const currentRawSourceWithoutBundlerMarkers = stripBundlerGeneratedCssMarkers(currentRawSource);
|
|
1372
|
+
const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
|
|
1373
|
+
const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
|
|
1374
|
+
const loaderGeneratedCssWithoutMarkers = stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
|
|
1375
|
+
const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : stripBundlerGeneratedCssMarkers(currentAssetUserCss);
|
|
1376
|
+
const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : filterExistingCssRules(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
|
|
1377
|
+
if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk) {
|
|
1378
|
+
debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
|
|
1379
|
+
const userCss = currentAssetMissingUserCss.trim().length === 0 || isCommentOnlyCss(currentAssetMissingUserCss) ? "" : finalizeCssAssetSource(currentAssetMissingUserCss, {
|
|
1380
|
+
cssPreflight: false,
|
|
1381
|
+
generatedCss: false
|
|
1382
|
+
});
|
|
1383
|
+
return { result: new ConcatSource(finalizeTracedCss(userCss, cssHandlerOptions)) };
|
|
1384
|
+
}
|
|
1385
|
+
const mergedLoaderCss = currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
|
|
1386
|
+
css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : filterExistingCssRules(currentAssetUserCss, loaderGeneratedCss.css),
|
|
1387
|
+
processed: true
|
|
1388
|
+
}, currentAssetUserCss === void 0 ? void 0 : {
|
|
1389
|
+
css: currentAssetUserCss,
|
|
1390
|
+
processed: true
|
|
1391
|
+
}).css;
|
|
1392
|
+
const handledLoaderCss = isWebGeneratorTarget ? mergedLoaderCss : (await compilerOptions.styleHandler(mergedLoaderCss, cssHandlerOptions)).css;
|
|
1393
|
+
const finalizedLoaderCss = finalizeCssAssetSource(handledLoaderCss, {
|
|
1394
|
+
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
1395
|
+
generatedCss: true,
|
|
1396
|
+
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
1397
|
+
});
|
|
1398
|
+
const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
|
|
1399
|
+
css: currentAssetUserCss,
|
|
1400
|
+
processed: true
|
|
1401
|
+
}, sourceCss === void 0 ? void 0 : {
|
|
1402
|
+
css: sourceCss,
|
|
1403
|
+
processed: false
|
|
1404
|
+
}].map((source) => {
|
|
1405
|
+
if (source === void 0) return;
|
|
1406
|
+
return {
|
|
1407
|
+
css: collectWebpackBareSelectorUserCss(source.css),
|
|
1408
|
+
processed: source.processed
|
|
1409
|
+
};
|
|
1410
|
+
}));
|
|
1411
|
+
const handledLoaderSourceBareUserCss = loaderSourceBareUserCss === void 0 ? "" : loaderSourceBareUserCss.processed ? loaderSourceBareUserCss.css : (await compilerOptions.styleHandler(loaderSourceBareUserCss.css, cssHandlerOptions)).css;
|
|
1412
|
+
const finalizedLoaderSourceBareUserCss = handledLoaderSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledLoaderSourceBareUserCss, {
|
|
1413
|
+
cssPreflight: false,
|
|
1414
|
+
generatedCss: false
|
|
1415
|
+
});
|
|
1416
|
+
const missingLoaderSourceBareUserCss = finalizedLoaderSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedLoaderCss, finalizedLoaderSourceBareUserCss);
|
|
1417
|
+
const css = finalizeTracedCss(missingLoaderSourceBareUserCss.trim().length === 0 ? finalizedLoaderCss : createWebpackGeneratorUserCssSourceAppend({
|
|
1418
|
+
css: finalizedLoaderCss,
|
|
1419
|
+
processed: true
|
|
1420
|
+
}, {
|
|
1421
|
+
css: missingLoaderSourceBareUserCss,
|
|
1422
|
+
processed: true
|
|
1423
|
+
}).css, cssHandlerOptions, { finalized: true });
|
|
1424
|
+
debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
|
|
1425
|
+
return { result: new ConcatSource(css) };
|
|
1426
|
+
}
|
|
1427
|
+
const sourceCssProcessed = sourceFile ? cssSources.get(path.resolve(sourceFile))?.processed === true : false;
|
|
1428
|
+
const registeredUserRawSource = createWebpackUserCssSourceAppend([...cssSources.entries()].map(([registeredSourceFile, source]) => ({
|
|
1429
|
+
...source,
|
|
1430
|
+
file: registeredSourceFile
|
|
1431
|
+
})), generatorRawSource, sourceFile, (registeredSourceFile) => isSameWebpackSourceScope(file, registeredSourceFile, sourceFile));
|
|
1432
|
+
const currentAssetLooksGenerated = hasTailwindGeneratedCss(currentRawSource) || hasTailwindGeneratedCssMarkers(currentRawSource);
|
|
1433
|
+
const currentAssetHasBundlerGeneratedMarker = hasBundlerGeneratedCssMarker(currentRawSource);
|
|
1434
|
+
const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
|
|
1435
|
+
if (sourceFile === void 0 && currentAssetHasBundlerGeneratedMarker && (currentAssetUserCssSource.trim().length === 0 || isCommentOnlyCss(currentAssetUserCssSource))) return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
|
|
1436
|
+
const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
|
|
1437
|
+
const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
|
|
1438
|
+
const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
|
|
1439
|
+
const currentAssetHasUserCss = (sourceCssProcessed || hasExplicitSourceCssForCurrentAsset) && currentAssetLooksGenerated && !shouldPreserveGeneratedWebAssetUserCss ? currentAssetHasAdditionalUserCss : shouldUseWebpackAssetAsGeneratorUserCss(currentAssetUserCssSource, generatorRawSource, { processed: sourceCssProcessed || shouldPreserveGeneratedWebAssetUserCss });
|
|
1440
|
+
const userRawSource = createWebpackGeneratorUserCssSourceAppend(createWebpackCurrentAssetUserRawSource({
|
|
1441
|
+
currentAssetHasUserCss,
|
|
1442
|
+
currentAssetLooksGenerated,
|
|
1443
|
+
currentAssetUserCssSource,
|
|
1444
|
+
shouldAppendCurrentAssetUserCss: shouldAppendCurrentWebpackAssetUserCss({
|
|
1445
|
+
currentAssetHasBundlerGeneratedMarker,
|
|
1446
|
+
currentAssetHasUserCss,
|
|
1447
|
+
currentAssetLooksGenerated,
|
|
1448
|
+
registeredUserRawSource,
|
|
1449
|
+
shouldPreserveGeneratedWebAssetUserCss,
|
|
1450
|
+
sourceCssProcessed
|
|
1451
|
+
}),
|
|
1452
|
+
sourceCssProcessed
|
|
1453
|
+
}), registeredUserRawSource);
|
|
1454
|
+
if (isPureLocalCssImportWrapper(currentRawSource)) return { result: new ConcatSource(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
|
|
1455
|
+
const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
|
|
1456
|
+
const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1457
|
+
const currentAssetHasTailwindDirectives = hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || hasTailwindApplyDirective(generatorRawSource);
|
|
1458
|
+
const shouldForceTailwindV4Generation = hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 && sourceFile !== void 0 || currentAssetHasTailwindDirectives || hasExplicitTailwindV4SourceCss);
|
|
1459
|
+
const shouldSkipUnmatchedMainCssGeneration = !isWebGeneratorTarget && cssHandlerOptions.isMainChunk && sourceFile === void 0 && configuredMainCssEntryFiles.length > 0 && !currentAssetHasTailwindDirectives;
|
|
1460
|
+
const shouldSkipPlainNonMainCssGeneration = !cssHandlerOptions.isMainChunk && sourceCss !== void 0 && !hasExplicitSourceCssForCurrentAsset && !hasExplicitTailwindV4SourceCss && !currentAssetHasTailwindDirectives;
|
|
1461
|
+
const shouldMergeFallbackGeneratorRuntime = cssHandlerOptions.isMainChunk || currentAssetHasTailwindDirectives || hasExplicitSourceCssForCurrentAsset;
|
|
1462
|
+
const scopedFallbackGeneratorRuntimeSet = hasExplicitTailwindV4SourceCss || !shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet;
|
|
1463
|
+
const resolvedScopedGeneratorRuntimeSet = await createScopedGeneratorRuntime({
|
|
1464
|
+
cssHandlerOptions,
|
|
1465
|
+
fallbackRuntime: scopedFallbackGeneratorRuntimeSet,
|
|
1466
|
+
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
1467
|
+
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1468
|
+
outputFile: file,
|
|
1469
|
+
rawSource: sourceFile ? cssSources.get(path.resolve(sourceFile))?.css ?? generatorRawSource : generatorRawSource,
|
|
1470
|
+
shouldExcludeSubpackageSourceCandidates: () => false,
|
|
1471
|
+
sourceFile: sourceFile ?? file,
|
|
1472
|
+
scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
|
|
1473
|
+
});
|
|
1474
|
+
const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== scopedFallbackGeneratorRuntimeSet && shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
|
|
1475
|
+
const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
|
|
1476
|
+
const scopedGeneratorCompilerOptions = scopeWebpackGeneratorOptionsToCssSource(compilerOptions, sourceFile, { disableUnmatchedCssEntries: !isWebGeneratorTarget && cssHandlerOptions.isMainChunk });
|
|
1477
|
+
const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
|
|
1478
|
+
...cssHandlerOptions,
|
|
1479
|
+
sourceOptions: {
|
|
1480
|
+
...cssHandlerOptions.sourceOptions,
|
|
1481
|
+
cssSources: generatorCssSources
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
const generatorOptions = {
|
|
1485
|
+
opts: scopedGeneratorCompilerOptions,
|
|
1486
|
+
runtimeState,
|
|
1487
|
+
runtime: scopedGeneratorRuntimeSet,
|
|
1488
|
+
rawSource: generatorRawSource,
|
|
1489
|
+
forceGenerator: shouldForceTailwindV4Generation,
|
|
1490
|
+
...hasUsableWebpackGeneratorCssSources(generatorCssSources) ? { cssSources: generatorCssSources } : {},
|
|
1491
|
+
...userRawSource === void 0 ? {} : { userRawSource: userRawSource.css },
|
|
1492
|
+
...userRawSource?.processed === true ? { userRawSourceProcessed: true } : {},
|
|
1493
|
+
file,
|
|
1494
|
+
cssHandlerOptions: generatorCssHandlerOptions,
|
|
1495
|
+
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
1496
|
+
frameworkPostcssOwner: compilerOptions,
|
|
1497
|
+
frameworkPostcssStage: "complete",
|
|
1498
|
+
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
1499
|
+
sourceCandidates: scopedGeneratorRuntimeSet,
|
|
1500
|
+
restoreLocalCssImports: false,
|
|
1501
|
+
styleHandler: compilerOptions.styleHandler,
|
|
1502
|
+
debug
|
|
1503
|
+
};
|
|
1504
|
+
let generated;
|
|
1505
|
+
if (!shouldSkipUnmatchedMainCssGeneration && !shouldSkipPlainNonMainCssGeneration) try {
|
|
1506
|
+
generated = await generateTailwindV4Css({
|
|
1507
|
+
...generatorOptions,
|
|
1508
|
+
outputFile: file
|
|
1509
|
+
});
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
if (!shouldFallbackToWebpackUserCssOnGeneratorError({
|
|
1512
|
+
configuredMainCssEntryFilesLength: configuredMainCssEntryFiles.length,
|
|
1513
|
+
generatorRawSource,
|
|
1514
|
+
hasExplicitTailwindV4SourceCss
|
|
1515
|
+
})) throw error;
|
|
1516
|
+
debug("css generator skipped for plain webpack css asset: %s %O", file, error);
|
|
1517
|
+
generated = void 0;
|
|
1518
|
+
}
|
|
1519
|
+
else debug("css generator skipped for plain webpack css asset: %s", file);
|
|
1520
|
+
return finalizeWebpackGeneratedCssResult({
|
|
1521
|
+
ConcatSource,
|
|
1522
|
+
compilerOptions,
|
|
1523
|
+
cssHandlerOptions,
|
|
1524
|
+
currentRawSource,
|
|
1525
|
+
debug,
|
|
1526
|
+
file,
|
|
1527
|
+
finalizeCssAssetSource,
|
|
1528
|
+
finalizeTracedCss,
|
|
1529
|
+
generated,
|
|
1530
|
+
generatorRawSource,
|
|
1531
|
+
generatorRuntimeSet,
|
|
1532
|
+
isWebGeneratorTarget,
|
|
1533
|
+
runtimeState,
|
|
1534
|
+
shouldPreserveExistingPreflight,
|
|
1535
|
+
sourceCss,
|
|
1536
|
+
sourceCssProcessed,
|
|
1537
|
+
userRawSource
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
}, cssTaskFactories, "tasks.css");
|
|
1542
|
+
}
|
|
1543
|
+
//#endregion
|
|
1199
1544
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.ts
|
|
1200
1545
|
function createChangedByType() {
|
|
1201
1546
|
return {
|
|
@@ -1311,6 +1656,112 @@ function createWebpackAssetUpdater(options) {
|
|
|
1311
1656
|
};
|
|
1312
1657
|
}
|
|
1313
1658
|
//#endregion
|
|
1659
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.ts
|
|
1660
|
+
async function enqueueWebpackHtmlAndJsTasks(context) {
|
|
1661
|
+
const { ConcatSource, applyWebpackLinkedJsResults, assetHashByChunk, compilation, compilerOptions, debug, defaultTemplateHandlerOptions, enqueueTask, groupedEntries, isWebGeneratorTarget, jsAssets, moduleGraphOptions, outputDir, rememberProcessCacheKey, rememberTransformedRuntimeCandidates, runtimeState, transformRuntimeSet, updateAssetIfChanged } = context;
|
|
1662
|
+
const htmlTaskFactories = [];
|
|
1663
|
+
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
|
|
1664
|
+
const [file, originalSource] = element;
|
|
1665
|
+
let rawSource;
|
|
1666
|
+
const readRawSource = () => {
|
|
1667
|
+
rawSource ?? (rawSource = originalSource.source().toString());
|
|
1668
|
+
return rawSource;
|
|
1669
|
+
};
|
|
1670
|
+
const cacheKey = file;
|
|
1671
|
+
const hashKey = `${file}:asset`;
|
|
1672
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1673
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1674
|
+
await enqueueTask(async () => {
|
|
1675
|
+
await processCachedTask({
|
|
1676
|
+
cache: compilerOptions.cache,
|
|
1677
|
+
cacheKey,
|
|
1678
|
+
hashKey,
|
|
1679
|
+
rawSource: chunkHash === void 0 ? readRawSource() : void 0,
|
|
1680
|
+
hash: chunkHash,
|
|
1681
|
+
applyResult(source, { cacheHit }) {
|
|
1682
|
+
updateAssetIfChanged(file, source, {
|
|
1683
|
+
compare: !cacheHit,
|
|
1684
|
+
notifyUpdate: !cacheHit
|
|
1685
|
+
});
|
|
1686
|
+
},
|
|
1687
|
+
onCacheHit() {
|
|
1688
|
+
debug("html cache hit: %s", file);
|
|
1689
|
+
},
|
|
1690
|
+
transform: async () => {
|
|
1691
|
+
const wxml = await compilerOptions.templateHandler(readRawSource(), defaultTemplateHandlerOptions);
|
|
1692
|
+
const source = new ConcatSource(wxml);
|
|
1693
|
+
debug("html handle: %s", file);
|
|
1694
|
+
return { result: source };
|
|
1695
|
+
}
|
|
1696
|
+
});
|
|
1697
|
+
}, htmlTaskFactories, "tasks.html");
|
|
1698
|
+
}
|
|
1699
|
+
const jsTaskFactories = [];
|
|
1700
|
+
const enqueueJsTask = async (factory) => {
|
|
1701
|
+
await enqueueTask(factory, jsTaskFactories, "tasks.js");
|
|
1702
|
+
};
|
|
1703
|
+
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
|
|
1704
|
+
const cacheKey = getCacheKey(file);
|
|
1705
|
+
const asset = compilation.getAsset(file);
|
|
1706
|
+
if (!asset) continue;
|
|
1707
|
+
const hashKey = `${file}:asset`;
|
|
1708
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1709
|
+
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
1710
|
+
const initialSource = asset.source.source();
|
|
1711
|
+
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
1712
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1713
|
+
await enqueueJsTask(async () => {
|
|
1714
|
+
await processCachedTask({
|
|
1715
|
+
cache: compilerOptions.cache,
|
|
1716
|
+
cacheKey,
|
|
1717
|
+
hashKey,
|
|
1718
|
+
rawSource: chunkHash === void 0 ? initialRawSource : void 0,
|
|
1719
|
+
hash: chunkHash,
|
|
1720
|
+
applyResult(source, { cacheHit }) {
|
|
1721
|
+
if (updateAssetIfChanged(file, source, {
|
|
1722
|
+
compare: !cacheHit,
|
|
1723
|
+
notifyUpdate: !cacheHit
|
|
1724
|
+
})) rememberTransformedRuntimeCandidates(source);
|
|
1725
|
+
},
|
|
1726
|
+
onCacheHit() {
|
|
1727
|
+
debug("js cache hit: %s", file);
|
|
1728
|
+
},
|
|
1729
|
+
transform: async () => {
|
|
1730
|
+
const currentSourceValue = compilation.getAsset(file)?.source.source();
|
|
1731
|
+
const currentSource = stringifyOptionalWebpackSourceValue(currentSourceValue);
|
|
1732
|
+
const handlerOptions = {
|
|
1733
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1734
|
+
generateMap: false,
|
|
1735
|
+
filename: absoluteFile,
|
|
1736
|
+
moduleGraph: moduleGraphOptions,
|
|
1737
|
+
babelParserOptions: { sourceFilename: absoluteFile }
|
|
1738
|
+
};
|
|
1739
|
+
if (shouldSkipJsTransform(currentSource, {
|
|
1740
|
+
...handlerOptions,
|
|
1741
|
+
classNameSet: transformRuntimeSet
|
|
1742
|
+
})) return { result: new ConcatSource(currentSource) };
|
|
1743
|
+
const { code, linked } = await compilerOptions.jsHandler(currentSource, transformRuntimeSet, handlerOptions);
|
|
1744
|
+
const source = new ConcatSource(code);
|
|
1745
|
+
debug("js handle: %s", file);
|
|
1746
|
+
applyWebpackLinkedJsResults({
|
|
1747
|
+
ConcatSource,
|
|
1748
|
+
compilation,
|
|
1749
|
+
compilerOptions,
|
|
1750
|
+
debug,
|
|
1751
|
+
jsAssets,
|
|
1752
|
+
linked
|
|
1753
|
+
});
|
|
1754
|
+
return { result: source };
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
return {
|
|
1760
|
+
htmlTaskFactories,
|
|
1761
|
+
jsTaskFactories
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
//#endregion
|
|
1314
1765
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.ts
|
|
1315
1766
|
function createWebpackJsAssetModuleGraph(options) {
|
|
1316
1767
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
@@ -1355,6 +1806,144 @@ function applyWebpackLinkedJsResults(options) {
|
|
|
1355
1806
|
}
|
|
1356
1807
|
}
|
|
1357
1808
|
//#endregion
|
|
1809
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.ts
|
|
1810
|
+
async function processWebpackProcessedCssAsset(element, context) {
|
|
1811
|
+
const { ConcatSource, assetHashByChunk, compilerOptions, configuredMainCssEntryFiles, createRuntimeSetHash, cssSourceTraceSignature, cssSources, cssTaskFactories, debug, enqueueTask, finalizeCssAssetSource, finalizeTracedCss, generatedCssSources, getCssHandlerOptions, getGeneratorRuntimeSet, hasConfiguredTailwindV4SourceRoots, isKnownWebpackProcessedCssAsset, isWebGeneratorTarget, isWebpackProcessedCssAsset, processedCssAssetSkipDecisionCache, rememberProcessCacheKey, runtimeAffectingSourceHash, updateAssetIfChanged, watchMode, webpackSourceCandidateSet, webpackSourceCandidateValueSignature, webpackSourceCandidates } = context;
|
|
1812
|
+
const [file, originalSource] = element;
|
|
1813
|
+
let rawSource;
|
|
1814
|
+
const readRawSource = () => {
|
|
1815
|
+
rawSource ?? (rawSource = originalSource.source().toString());
|
|
1816
|
+
return rawSource;
|
|
1817
|
+
};
|
|
1818
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1819
|
+
const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file, readRawSource());
|
|
1820
|
+
const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
|
|
1821
|
+
const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
|
|
1822
|
+
const processedSourceCss = processedSourceFile ? cssSources.get(path.resolve(processedSourceFile))?.css : void 0;
|
|
1823
|
+
const shouldRegenerateProcessedTailwindV4SourceCss = processedSourceCss !== void 0 && (hasTailwindSourceDirectives(processedSourceCss, { importFallback: true }) || processedSourceCss.includes("@config"));
|
|
1824
|
+
const processedCssAssetKnown = isKnownWebpackProcessedCssAsset?.(file, processedCssAssetMetadata) === true;
|
|
1825
|
+
const processedLoaderGeneratedCss = processedSourceFile ? generatedCssSources.get(path.resolve(processedSourceFile)) : void 0;
|
|
1826
|
+
const processedAssetSourceHash = watchMode && isWebGeneratorTarget && cssHandlerOptionsForProcessedAsset.isMainChunk ? compilerOptions.cache.computeHash(readRawSource()) : chunkHash === void 0 ? processedCssAssetKnown ? "webpack-css-asset:known" : compilerOptions.cache.computeHash(readRawSource()) : "webpack-css-asset:chunk";
|
|
1827
|
+
const processedCssDecisionCacheKey = `${file}:${createRuntimeAwareCssHash(chunkHash, processedAssetSourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`)}`;
|
|
1828
|
+
let currentProcessedRawSource;
|
|
1829
|
+
let hasGeneratedCssMarker = false;
|
|
1830
|
+
let hasTailwindGeneratedAssetCss = false;
|
|
1831
|
+
const readCurrentProcessedRawSource = () => {
|
|
1832
|
+
currentProcessedRawSource ?? (currentProcessedRawSource = readRawSource());
|
|
1833
|
+
return currentProcessedRawSource;
|
|
1834
|
+
};
|
|
1835
|
+
const cachedSkipProcessedCssAsset = processedCssAssetKnown ? processedCssAssetSkipDecisionCache.get(processedCssDecisionCacheKey) : void 0;
|
|
1836
|
+
const shouldRegenerateStaleProcessedWebCssAsset = isWebGeneratorTarget && !processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && webpackSourceCandidateSet !== void 0 && (hasMissingRuntimeCandidates(processedLoaderGeneratedCss?.classSet, webpackSourceCandidateSet) || hasMissingRuntimeCandidates(resolveGeneratedCssRuntimeCandidates(readCurrentProcessedRawSource(), processedLoaderGeneratedCss?.classSet), webpackSourceCandidateSet));
|
|
1837
|
+
if (cachedSkipProcessedCssAsset !== void 0) {
|
|
1838
|
+
hasGeneratedCssMarker = cachedSkipProcessedCssAsset && cssHandlerOptionsForProcessedAsset.isMainChunk;
|
|
1839
|
+
hasTailwindGeneratedAssetCss = hasGeneratedCssMarker;
|
|
1840
|
+
} else {
|
|
1841
|
+
const source = readCurrentProcessedRawSource();
|
|
1842
|
+
hasGeneratedCssMarker = hasBundlerGeneratedCssMarker(source);
|
|
1843
|
+
hasTailwindGeneratedAssetCss = hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source);
|
|
1844
|
+
}
|
|
1845
|
+
const hasProcessedAssetTailwindDirectives = () => {
|
|
1846
|
+
const source = readCurrentProcessedRawSource();
|
|
1847
|
+
return hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
|
|
1848
|
+
};
|
|
1849
|
+
const shouldForceConfiguredMainCssGeneration = cssHandlerOptionsForProcessedAsset.isMainChunk && hasConfiguredTailwindV4SourceRoots() && !hasGeneratedCssMarker && (configuredMainCssEntryFiles.length > 0 || shouldRegenerateProcessedTailwindV4SourceCss || hasProcessedAssetTailwindDirectives());
|
|
1850
|
+
const hasProcessedMainAssetUserCss = cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss) && createWebpackUserCssSourceAppend([...cssSources.entries()].map(([sourceFile, source]) => ({
|
|
1851
|
+
...source,
|
|
1852
|
+
file: sourceFile
|
|
1853
|
+
})), readCurrentProcessedRawSource()) !== void 0;
|
|
1854
|
+
const hasProcessedLoaderGeneratedUserCss = cachedSkipProcessedCssAsset === void 0 && processedLoaderGeneratedCss !== void 0 && hasAdditionalWebpackAssetUserCssMarkers(processedLoaderGeneratedCss.css, readCurrentProcessedRawSource());
|
|
1855
|
+
const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
|
|
1856
|
+
const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1857
|
+
const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && !hasProcessedLoaderGeneratedUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1858
|
+
const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
|
|
1859
|
+
if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
|
|
1860
|
+
if (shouldSkipProcessedCssAsset) {
|
|
1861
|
+
const hashKey = `${file}:asset`;
|
|
1862
|
+
const sourceHash = processedAssetSourceHash;
|
|
1863
|
+
rememberProcessCacheKey(file, hashKey);
|
|
1864
|
+
await enqueueTask(async () => {
|
|
1865
|
+
await processCachedTask({
|
|
1866
|
+
cache: compilerOptions.cache,
|
|
1867
|
+
cacheKey: file,
|
|
1868
|
+
hashKey,
|
|
1869
|
+
rawSource: chunkHash === void 0 && !processedCssAssetKnown ? readCurrentProcessedRawSource() : void 0,
|
|
1870
|
+
hash: createRuntimeAwareCssHash(chunkHash, sourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`),
|
|
1871
|
+
applyResult(source, { cacheHit }) {
|
|
1872
|
+
updateAssetIfChanged(file, source, {
|
|
1873
|
+
compare: !cacheHit,
|
|
1874
|
+
notifyUpdate: !cacheHit
|
|
1875
|
+
});
|
|
1876
|
+
},
|
|
1877
|
+
onCacheHit() {
|
|
1878
|
+
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
1879
|
+
},
|
|
1880
|
+
transform: async () => {
|
|
1881
|
+
const source = readCurrentProcessedRawSource();
|
|
1882
|
+
const missingProcessedLoaderGeneratedCss = isWebGeneratorTarget && processedLoaderGeneratedCss ? filterExistingCssRules(source, stripBundlerGeneratedCssMarkers(processedLoaderGeneratedCss.css)) : "";
|
|
1883
|
+
const sourceWithLoaderGeneratedCss = missingProcessedLoaderGeneratedCss.trim().length === 0 ? source : createWebpackGeneratorUserCssSourceAppend({
|
|
1884
|
+
css: source,
|
|
1885
|
+
processed: true
|
|
1886
|
+
}, {
|
|
1887
|
+
css: missingProcessedLoaderGeneratedCss,
|
|
1888
|
+
processed: true
|
|
1889
|
+
}).css;
|
|
1890
|
+
const processedBareSelectorSourceCss = processedSourceCss ?? (hasTailwindGeneratedAssetCss ? removeWebpackTailwindGeneratedAssetCss(sourceWithLoaderGeneratedCss) : void 0);
|
|
1891
|
+
const handledCss = hasTailwindGeneratedAssetCss && (!hasGeneratedCssMarker || !isWebGeneratorTarget && hasDeferredWebpackGeneratedCss(source, [...generatedCssSources.values()].map((item) => item.classSet))) ? isWebGeneratorTarget ? sourceWithLoaderGeneratedCss : (await compilerOptions.styleHandler(sourceWithLoaderGeneratedCss, cssHandlerOptionsForProcessedAsset)).css : sourceWithLoaderGeneratedCss;
|
|
1892
|
+
const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(handledCss, {
|
|
1893
|
+
cssPreflight: cssHandlerOptionsForProcessedAsset.isMainChunk,
|
|
1894
|
+
generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss
|
|
1895
|
+
}));
|
|
1896
|
+
const processedSourceBareUserCss = isWebGeneratorTarget || processedBareSelectorSourceCss === void 0 ? void 0 : createWebpackGeneratorUserCssSourceAppend({
|
|
1897
|
+
css: collectWebpackBareSelectorUserCss(processedBareSelectorSourceCss),
|
|
1898
|
+
processed: false
|
|
1899
|
+
});
|
|
1900
|
+
const finalizedProcessedSourceBareUserCss = processedSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(processedSourceBareUserCss.css, {
|
|
1901
|
+
cssPreflight: false,
|
|
1902
|
+
generatedCss: false
|
|
1903
|
+
});
|
|
1904
|
+
const missingProcessedSourceBareUserCss = finalizedProcessedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(nextCss, finalizedProcessedSourceBareUserCss);
|
|
1905
|
+
const css = missingProcessedSourceBareUserCss.trim().length === 0 ? nextCss : createWebpackGeneratorUserCssSourceAppend({
|
|
1906
|
+
css: nextCss,
|
|
1907
|
+
processed: true
|
|
1908
|
+
}, {
|
|
1909
|
+
css: missingProcessedSourceBareUserCss,
|
|
1910
|
+
processed: true
|
|
1911
|
+
}).css;
|
|
1912
|
+
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
1913
|
+
return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset, { finalized: true })) };
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
}, cssTaskFactories, "tasks.css");
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
const currentRawSource = readRawSource();
|
|
1920
|
+
if (isWebpackCssLoaderRuntimeSource(currentRawSource)) {
|
|
1921
|
+
const hashKey = `${file}:asset`;
|
|
1922
|
+
rememberProcessCacheKey(file, hashKey);
|
|
1923
|
+
await enqueueTask(async () => {
|
|
1924
|
+
await processCachedTask({
|
|
1925
|
+
cache: compilerOptions.cache,
|
|
1926
|
+
cacheKey: file,
|
|
1927
|
+
hashKey,
|
|
1928
|
+
rawSource: currentRawSource,
|
|
1929
|
+
hash: createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(currentRawSource), "webpack-css-loader-runtime"),
|
|
1930
|
+
applyResult(source, { cacheHit }) {
|
|
1931
|
+
updateAssetIfChanged(file, source, {
|
|
1932
|
+
compare: !cacheHit,
|
|
1933
|
+
notifyUpdate: !cacheHit
|
|
1934
|
+
});
|
|
1935
|
+
},
|
|
1936
|
+
onCacheHit() {
|
|
1937
|
+
debug("css-loader runtime cache hit: %s", file);
|
|
1938
|
+
},
|
|
1939
|
+
transform: async () => ({ result: new ConcatSource(currentRawSource) })
|
|
1940
|
+
});
|
|
1941
|
+
}, cssTaskFactories, "tasks.css");
|
|
1942
|
+
return true;
|
|
1943
|
+
}
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
//#endregion
|
|
1358
1947
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.ts
|
|
1359
1948
|
const WEBPACK_SOURCE_CANDIDATE_SCAN_CACHE_MAX = 2;
|
|
1360
1949
|
function trimScanCache(cache) {
|
|
@@ -1587,6 +2176,11 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1587
2176
|
debug("start");
|
|
1588
2177
|
await runtimeState.readyPromise;
|
|
1589
2178
|
const hmrTimingStartedAt = performance.now();
|
|
2179
|
+
const timingDetails = {};
|
|
2180
|
+
const recordTimingDetail = (name, startedAt) => {
|
|
2181
|
+
timingDetails[name] = (timingDetails[name] ?? 0) + Math.max(0, performance.now() - startedAt);
|
|
2182
|
+
};
|
|
2183
|
+
const setupStartedAt = performance.now();
|
|
1590
2184
|
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
1591
2185
|
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
1592
2186
|
const { updateAssetIfChanged } = createWebpackAssetUpdater({
|
|
@@ -1643,7 +2237,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1643
2237
|
runtimeState
|
|
1644
2238
|
});
|
|
1645
2239
|
const finalizeCssAssetSource = (source, options = {}) => finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options);
|
|
1646
|
-
const
|
|
2240
|
+
const shouldRefreshWebpackSourceCandidates = !isWebGeneratorTarget && groupedEntries.css.length > 0 || cssSources.size > 0 || generatedCssSources.size > 0 || isCssSourceTraceEnabled(compilerOptions);
|
|
2241
|
+
recordTimingDetail("setup", setupStartedAt);
|
|
2242
|
+
const sourceCandidatesStartedAt = performance.now();
|
|
2243
|
+
const webpackSourceCandidates = shouldRefreshWebpackSourceCandidates ? await refreshWebpackSourceCandidates({
|
|
1647
2244
|
compilerOptions,
|
|
1648
2245
|
debug,
|
|
1649
2246
|
outputDir,
|
|
@@ -1653,6 +2250,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1653
2250
|
watchMode
|
|
1654
2251
|
}) : void 0;
|
|
1655
2252
|
const webpackSourceCandidateValueSignature = webpackSourceCandidates ? createCandidateSignature(webpackSourceCandidates.getSourceCandidatesForEntries(void 0)) : "source-candidates:0";
|
|
2253
|
+
recordTimingDetail("sourceCandidates", sourceCandidatesStartedAt);
|
|
1656
2254
|
const cssSourceTraceTokenSources = createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates);
|
|
1657
2255
|
const cssSourceTraceSignature = createCssSourceTraceCacheSignature(cssSourceTraceTokenSources, compilerOptions);
|
|
1658
2256
|
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
@@ -1666,6 +2264,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1666
2264
|
isWebGeneratorTarget
|
|
1667
2265
|
});
|
|
1668
2266
|
const hasRuntimeTransformAssets = Boolean(!isWebGeneratorTarget && ((groupedEntries.html?.length ?? 0) > 0 || (groupedEntries.js?.length ?? 0) > 0));
|
|
2267
|
+
const runtimeStartedAt = performance.now();
|
|
1669
2268
|
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
1670
2269
|
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.tailwindRuntime.majorVersion ?? "unknown");
|
|
1671
2270
|
let runtimeSet;
|
|
@@ -1703,6 +2302,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1703
2302
|
}
|
|
1704
2303
|
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
1705
2304
|
consumeRuntimeRefreshRequirement();
|
|
2305
|
+
recordTimingDetail("runtime", runtimeStartedAt);
|
|
1706
2306
|
const webpackSourceCandidateSet = webpackSourceCandidates?.getSourceCandidatesForEntries(void 0);
|
|
1707
2307
|
const generatorRuntimeSet = new Set(runtimeSet);
|
|
1708
2308
|
addRuntimeTransformCandidates(generatorRuntimeSet, webpackSourceCandidateSet);
|
|
@@ -1757,532 +2357,107 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1757
2357
|
const defaultTemplateHandlerOptions = { runtimeSet: transformRuntimeSet };
|
|
1758
2358
|
debug("get runtimeSet, class count: %d, transform class count: %d", runtimeSet.size, transformRuntimeSet.size);
|
|
1759
2359
|
const tasks = [];
|
|
1760
|
-
const htmlTaskFactories = [];
|
|
1761
2360
|
const cssTaskFactories = [];
|
|
1762
|
-
const enqueueTask = async (factory, target) => {
|
|
2361
|
+
const enqueueTask = async (factory, target, phase) => {
|
|
2362
|
+
const timedFactory = async () => {
|
|
2363
|
+
const startedAt = performance.now();
|
|
2364
|
+
try {
|
|
2365
|
+
await factory();
|
|
2366
|
+
} finally {
|
|
2367
|
+
recordTimingDetail(phase, startedAt);
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
1763
2370
|
if (watchMode) {
|
|
1764
|
-
await
|
|
2371
|
+
await timedFactory();
|
|
1765
2372
|
return;
|
|
1766
2373
|
}
|
|
1767
|
-
target.push(
|
|
2374
|
+
target.push(timedFactory);
|
|
1768
2375
|
};
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2376
|
+
const { htmlTaskFactories, jsTaskFactories } = await enqueueWebpackHtmlAndJsTasks({
|
|
2377
|
+
ConcatSource,
|
|
2378
|
+
applyWebpackLinkedJsResults,
|
|
2379
|
+
assetHashByChunk,
|
|
2380
|
+
compilation,
|
|
2381
|
+
compilerOptions,
|
|
2382
|
+
debug,
|
|
2383
|
+
defaultTemplateHandlerOptions,
|
|
2384
|
+
enqueueTask,
|
|
2385
|
+
groupedEntries,
|
|
2386
|
+
isWebGeneratorTarget,
|
|
2387
|
+
jsAssets,
|
|
2388
|
+
moduleGraphOptions,
|
|
2389
|
+
outputDir,
|
|
2390
|
+
rememberProcessCacheKey,
|
|
2391
|
+
rememberTransformedRuntimeCandidates,
|
|
2392
|
+
runtimeState,
|
|
2393
|
+
transformRuntimeSet,
|
|
2394
|
+
updateAssetIfChanged
|
|
2395
|
+
});
|
|
2396
|
+
const cssTaskContext = {
|
|
2397
|
+
ConcatSource,
|
|
2398
|
+
assetHashByChunk,
|
|
2399
|
+
compilation,
|
|
2400
|
+
compilerOptions,
|
|
2401
|
+
configuredCssEntryFiles,
|
|
2402
|
+
configuredMainCssEntryFiles,
|
|
2403
|
+
createRuntimeSetHash,
|
|
2404
|
+
cssSourceTraceSignature,
|
|
2405
|
+
cssSources,
|
|
2406
|
+
cssTaskFactories,
|
|
2407
|
+
debug,
|
|
2408
|
+
enqueueTask,
|
|
2409
|
+
finalizeCssAssetSource,
|
|
2410
|
+
finalizeTracedCss,
|
|
2411
|
+
generatedCssSources,
|
|
2412
|
+
generatorRuntimeSet,
|
|
2413
|
+
getCssHandlerOptions,
|
|
2414
|
+
getCssUserHandlerOptions,
|
|
2415
|
+
getGeneratorRuntimeSet,
|
|
2416
|
+
hasConfiguredTailwindV4SourceRoots,
|
|
2417
|
+
isKnownWebpackProcessedCssAsset,
|
|
2418
|
+
isSameWebpackSourceScope,
|
|
2419
|
+
isWebGeneratorTarget,
|
|
2420
|
+
isWebpackProcessedCssAsset,
|
|
2421
|
+
processedCssAssetSkipDecisionCache,
|
|
2422
|
+
rememberProcessCacheKey,
|
|
2423
|
+
resolveWebpackCssSourceFile,
|
|
2424
|
+
runtimeAffectingSourceHash,
|
|
2425
|
+
runtimeState,
|
|
2426
|
+
transformRuntimeSet,
|
|
2427
|
+
updateAssetIfChanged,
|
|
2428
|
+
watchMode,
|
|
2429
|
+
webpackSourceCandidateSet,
|
|
2430
|
+
webpackSourceCandidateValueSignature,
|
|
2431
|
+
webpackSourceCandidates
|
|
1808
2432
|
};
|
|
1809
|
-
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
|
|
1810
|
-
const cacheKey = getCacheKey(file);
|
|
1811
|
-
const asset = compilation.getAsset(file);
|
|
1812
|
-
if (!asset) continue;
|
|
1813
|
-
const hashKey = `${file}:asset`;
|
|
1814
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1815
|
-
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
1816
|
-
const initialSource = asset.source.source();
|
|
1817
|
-
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
1818
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
1819
|
-
await enqueueJsTask(async () => {
|
|
1820
|
-
await processCachedTask({
|
|
1821
|
-
cache: compilerOptions.cache,
|
|
1822
|
-
cacheKey,
|
|
1823
|
-
hashKey,
|
|
1824
|
-
rawSource: chunkHash === void 0 ? initialRawSource : void 0,
|
|
1825
|
-
hash: chunkHash,
|
|
1826
|
-
applyResult(source, { cacheHit }) {
|
|
1827
|
-
if (updateAssetIfChanged(file, source, {
|
|
1828
|
-
compare: !cacheHit,
|
|
1829
|
-
notifyUpdate: !cacheHit
|
|
1830
|
-
})) rememberTransformedRuntimeCandidates(source);
|
|
1831
|
-
},
|
|
1832
|
-
onCacheHit() {
|
|
1833
|
-
debug("js cache hit: %s", file);
|
|
1834
|
-
},
|
|
1835
|
-
transform: async () => {
|
|
1836
|
-
const currentSourceValue = compilation.getAsset(file)?.source.source();
|
|
1837
|
-
const currentSource = stringifyOptionalWebpackSourceValue(currentSourceValue);
|
|
1838
|
-
const handlerOptions = {
|
|
1839
|
-
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1840
|
-
generateMap: false,
|
|
1841
|
-
filename: absoluteFile,
|
|
1842
|
-
moduleGraph: moduleGraphOptions,
|
|
1843
|
-
babelParserOptions: { sourceFilename: absoluteFile }
|
|
1844
|
-
};
|
|
1845
|
-
if (shouldSkipJsTransform(currentSource, {
|
|
1846
|
-
...handlerOptions,
|
|
1847
|
-
classNameSet: transformRuntimeSet
|
|
1848
|
-
})) return { result: new ConcatSource(currentSource) };
|
|
1849
|
-
const { code, linked } = await compilerOptions.jsHandler(currentSource, transformRuntimeSet, handlerOptions);
|
|
1850
|
-
const source = new ConcatSource(code);
|
|
1851
|
-
debug("js handle: %s", file);
|
|
1852
|
-
applyWebpackLinkedJsResults({
|
|
1853
|
-
ConcatSource,
|
|
1854
|
-
compilation,
|
|
1855
|
-
compilerOptions,
|
|
1856
|
-
debug,
|
|
1857
|
-
jsAssets,
|
|
1858
|
-
linked
|
|
1859
|
-
});
|
|
1860
|
-
return { result: source };
|
|
1861
|
-
}
|
|
1862
|
-
});
|
|
1863
|
-
});
|
|
1864
|
-
}
|
|
1865
2433
|
for (const element of groupedEntries.css) {
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
const readRawSource = () => {
|
|
1869
|
-
rawSource ?? (rawSource = originalSource.source().toString());
|
|
1870
|
-
return rawSource;
|
|
1871
|
-
};
|
|
1872
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
1873
|
-
const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file, readRawSource());
|
|
1874
|
-
const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
|
|
1875
|
-
const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
|
|
1876
|
-
const processedSourceCss = processedSourceFile ? cssSources.get(path.resolve(processedSourceFile))?.css : void 0;
|
|
1877
|
-
const shouldRegenerateProcessedTailwindV4SourceCss = processedSourceCss !== void 0 && (hasTailwindSourceDirectives(processedSourceCss, { importFallback: true }) || processedSourceCss.includes("@config"));
|
|
1878
|
-
const processedCssAssetKnown = isKnownWebpackProcessedCssAsset?.(file, processedCssAssetMetadata) === true;
|
|
1879
|
-
const processedLoaderGeneratedCss = processedSourceFile ? generatedCssSources.get(path.resolve(processedSourceFile)) : void 0;
|
|
1880
|
-
const processedAssetSourceHash = watchMode && isWebGeneratorTarget && cssHandlerOptionsForProcessedAsset.isMainChunk ? compilerOptions.cache.computeHash(readRawSource()) : chunkHash === void 0 ? processedCssAssetKnown ? "webpack-css-asset:known" : compilerOptions.cache.computeHash(readRawSource()) : "webpack-css-asset:chunk";
|
|
1881
|
-
const processedCssDecisionCacheKey = `${file}:${createRuntimeAwareCssHash(chunkHash, processedAssetSourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`)}`;
|
|
1882
|
-
let currentProcessedRawSource;
|
|
1883
|
-
let hasGeneratedCssMarker = false;
|
|
1884
|
-
let hasTailwindGeneratedAssetCss = false;
|
|
1885
|
-
const readCurrentProcessedRawSource = () => {
|
|
1886
|
-
currentProcessedRawSource ?? (currentProcessedRawSource = readRawSource());
|
|
1887
|
-
return currentProcessedRawSource;
|
|
1888
|
-
};
|
|
1889
|
-
const cachedSkipProcessedCssAsset = processedCssAssetKnown ? processedCssAssetSkipDecisionCache.get(processedCssDecisionCacheKey) : void 0;
|
|
1890
|
-
const shouldRegenerateStaleProcessedWebCssAsset = isWebGeneratorTarget && !processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && webpackSourceCandidateSet !== void 0 && (hasMissingRuntimeCandidates(processedLoaderGeneratedCss?.classSet, webpackSourceCandidateSet) || hasMissingRuntimeCandidates(resolveGeneratedCssRuntimeCandidates(readCurrentProcessedRawSource(), processedLoaderGeneratedCss?.classSet), webpackSourceCandidateSet));
|
|
1891
|
-
if (cachedSkipProcessedCssAsset !== void 0) {
|
|
1892
|
-
hasGeneratedCssMarker = cachedSkipProcessedCssAsset && cssHandlerOptionsForProcessedAsset.isMainChunk;
|
|
1893
|
-
hasTailwindGeneratedAssetCss = hasGeneratedCssMarker;
|
|
1894
|
-
} else {
|
|
1895
|
-
const source = readCurrentProcessedRawSource();
|
|
1896
|
-
hasGeneratedCssMarker = hasBundlerGeneratedCssMarker(source);
|
|
1897
|
-
hasTailwindGeneratedAssetCss = hasTailwindGeneratedCss(source) || hasTailwindGeneratedCssMarkers(source);
|
|
1898
|
-
}
|
|
1899
|
-
const hasProcessedAssetTailwindDirectives = () => {
|
|
1900
|
-
const source = readCurrentProcessedRawSource();
|
|
1901
|
-
return hasTailwindRootDirectives(source, { importFallback: true }) || hasTailwindSourceDirectives(source, { importFallback: true }) || hasTailwindApplyDirective(source);
|
|
1902
|
-
};
|
|
1903
|
-
const shouldForceConfiguredMainCssGeneration = cssHandlerOptionsForProcessedAsset.isMainChunk && hasConfiguredTailwindV4SourceRoots() && !hasGeneratedCssMarker && (configuredMainCssEntryFiles.length > 0 || shouldRegenerateProcessedTailwindV4SourceCss || hasProcessedAssetTailwindDirectives());
|
|
1904
|
-
const hasProcessedMainAssetUserCss = cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss) && createWebpackUserCssSourceAppend([...cssSources.entries()].map(([sourceFile, source]) => ({
|
|
1905
|
-
...source,
|
|
1906
|
-
file: sourceFile
|
|
1907
|
-
})), readCurrentProcessedRawSource()) !== void 0;
|
|
1908
|
-
const hasProcessedLoaderGeneratedUserCss = cachedSkipProcessedCssAsset === void 0 && processedLoaderGeneratedCss !== void 0 && hasAdditionalWebpackAssetUserCssMarkers(processedLoaderGeneratedCss.css, readCurrentProcessedRawSource());
|
|
1909
|
-
const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
|
|
1910
|
-
const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1911
|
-
const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && !hasProcessedLoaderGeneratedUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1912
|
-
const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
|
|
1913
|
-
if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
|
|
1914
|
-
if (shouldSkipProcessedCssAsset) {
|
|
1915
|
-
const hashKey = `${file}:asset`;
|
|
1916
|
-
const sourceHash = processedAssetSourceHash;
|
|
1917
|
-
rememberProcessCacheKey(file, hashKey);
|
|
1918
|
-
await enqueueTask(async () => {
|
|
1919
|
-
await processCachedTask({
|
|
1920
|
-
cache: compilerOptions.cache,
|
|
1921
|
-
cacheKey: file,
|
|
1922
|
-
hashKey,
|
|
1923
|
-
rawSource: chunkHash === void 0 && !processedCssAssetKnown ? readCurrentProcessedRawSource() : void 0,
|
|
1924
|
-
hash: createRuntimeAwareCssHash(chunkHash, sourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`),
|
|
1925
|
-
applyResult(source, { cacheHit }) {
|
|
1926
|
-
updateAssetIfChanged(file, source, {
|
|
1927
|
-
compare: !cacheHit,
|
|
1928
|
-
notifyUpdate: !cacheHit
|
|
1929
|
-
});
|
|
1930
|
-
},
|
|
1931
|
-
onCacheHit() {
|
|
1932
|
-
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
1933
|
-
},
|
|
1934
|
-
transform: async () => {
|
|
1935
|
-
const source = readCurrentProcessedRawSource();
|
|
1936
|
-
const missingProcessedLoaderGeneratedCss = isWebGeneratorTarget && processedLoaderGeneratedCss ? filterExistingCssRules(source, stripBundlerGeneratedCssMarkers(processedLoaderGeneratedCss.css)) : "";
|
|
1937
|
-
const sourceWithLoaderGeneratedCss = missingProcessedLoaderGeneratedCss.trim().length === 0 ? source : createWebpackGeneratorUserCssSourceAppend({
|
|
1938
|
-
css: source,
|
|
1939
|
-
processed: true
|
|
1940
|
-
}, {
|
|
1941
|
-
css: missingProcessedLoaderGeneratedCss,
|
|
1942
|
-
processed: true
|
|
1943
|
-
}).css;
|
|
1944
|
-
const processedBareSelectorSourceCss = processedSourceCss ?? (hasTailwindGeneratedAssetCss ? removeWebpackTailwindGeneratedAssetCss(sourceWithLoaderGeneratedCss) : void 0);
|
|
1945
|
-
const handledCss = hasTailwindGeneratedAssetCss && (!hasGeneratedCssMarker || !isWebGeneratorTarget && hasDeferredWebpackGeneratedCss(source, [...generatedCssSources.values()].map((item) => item.classSet))) ? isWebGeneratorTarget ? sourceWithLoaderGeneratedCss : (await compilerOptions.styleHandler(sourceWithLoaderGeneratedCss, cssHandlerOptionsForProcessedAsset)).css : sourceWithLoaderGeneratedCss;
|
|
1946
|
-
const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(handledCss, {
|
|
1947
|
-
cssPreflight: cssHandlerOptionsForProcessedAsset.isMainChunk,
|
|
1948
|
-
generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss
|
|
1949
|
-
}));
|
|
1950
|
-
const processedSourceBareUserCss = isWebGeneratorTarget || processedBareSelectorSourceCss === void 0 ? void 0 : createWebpackGeneratorUserCssSourceAppend({
|
|
1951
|
-
css: collectWebpackBareSelectorUserCss(processedBareSelectorSourceCss),
|
|
1952
|
-
processed: false
|
|
1953
|
-
});
|
|
1954
|
-
const finalizedProcessedSourceBareUserCss = processedSourceBareUserCss === void 0 ? "" : finalizeCssAssetSource(processedSourceBareUserCss.css, {
|
|
1955
|
-
cssPreflight: false,
|
|
1956
|
-
generatedCss: false
|
|
1957
|
-
});
|
|
1958
|
-
const missingProcessedSourceBareUserCss = finalizedProcessedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(nextCss, finalizedProcessedSourceBareUserCss);
|
|
1959
|
-
const css = missingProcessedSourceBareUserCss.trim().length === 0 ? nextCss : createWebpackGeneratorUserCssSourceAppend({
|
|
1960
|
-
css: nextCss,
|
|
1961
|
-
processed: true
|
|
1962
|
-
}, {
|
|
1963
|
-
css: missingProcessedSourceBareUserCss,
|
|
1964
|
-
processed: true
|
|
1965
|
-
}).css;
|
|
1966
|
-
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
1967
|
-
return { result: new ConcatSource(finalizeTracedCss(css, cssHandlerOptionsForProcessedAsset, { finalized: true })) };
|
|
1968
|
-
}
|
|
1969
|
-
});
|
|
1970
|
-
}, cssTaskFactories);
|
|
1971
|
-
continue;
|
|
1972
|
-
}
|
|
1973
|
-
const currentRawSource = readRawSource();
|
|
1974
|
-
if (isWebpackCssLoaderRuntimeSource(currentRawSource)) {
|
|
1975
|
-
const hashKey = `${file}:asset`;
|
|
1976
|
-
rememberProcessCacheKey(file, hashKey);
|
|
1977
|
-
await enqueueTask(async () => {
|
|
1978
|
-
await processCachedTask({
|
|
1979
|
-
cache: compilerOptions.cache,
|
|
1980
|
-
cacheKey: file,
|
|
1981
|
-
hashKey,
|
|
1982
|
-
rawSource: currentRawSource,
|
|
1983
|
-
hash: createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(currentRawSource), "webpack-css-loader-runtime"),
|
|
1984
|
-
applyResult(source, { cacheHit }) {
|
|
1985
|
-
updateAssetIfChanged(file, source, {
|
|
1986
|
-
compare: !cacheHit,
|
|
1987
|
-
notifyUpdate: !cacheHit
|
|
1988
|
-
});
|
|
1989
|
-
},
|
|
1990
|
-
onCacheHit() {
|
|
1991
|
-
debug("css-loader runtime cache hit: %s", file);
|
|
1992
|
-
},
|
|
1993
|
-
transform: async () => ({ result: new ConcatSource(currentRawSource) })
|
|
1994
|
-
});
|
|
1995
|
-
}, cssTaskFactories);
|
|
1996
|
-
continue;
|
|
1997
|
-
}
|
|
1998
|
-
const cacheKey = file;
|
|
1999
|
-
const hashKey = `${file}:asset`;
|
|
2000
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
2001
|
-
const cssHandlerOptionsForHash = getCssHandlerOptions(file, currentRawSource);
|
|
2002
|
-
const cssChunkHash = watchMode && cssHandlerOptionsForHash.isMainChunk ? void 0 : chunkHash;
|
|
2003
|
-
const cssSourceHash = (() => {
|
|
2004
|
-
const sourceFile = resolveWebpackCssSourceFile(file, currentRawSource);
|
|
2005
|
-
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
2006
|
-
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
2007
|
-
if (sourceCss === void 0) return sourceFile === void 0 ? "webpack-css-source:0" : `webpack-css-source:0:${sourceFile}`;
|
|
2008
|
-
return `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}:${generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss)}`;
|
|
2009
|
-
})();
|
|
2010
|
-
const runtimeAwareHash = createRuntimeAwareCssHash(cssChunkHash, compilerOptions.cache.computeHash(currentRawSource), `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}:${cssSourceHash}`);
|
|
2011
|
-
await enqueueTask(async () => {
|
|
2012
|
-
await processCachedTask({
|
|
2013
|
-
cache: compilerOptions.cache,
|
|
2014
|
-
cacheKey,
|
|
2015
|
-
hashKey,
|
|
2016
|
-
rawSource: currentRawSource,
|
|
2017
|
-
hash: runtimeAwareHash,
|
|
2018
|
-
applyResult(source, { cacheHit }) {
|
|
2019
|
-
updateAssetIfChanged(file, source, {
|
|
2020
|
-
compare: !cacheHit,
|
|
2021
|
-
notifyUpdate: !cacheHit
|
|
2022
|
-
});
|
|
2023
|
-
},
|
|
2024
|
-
onCacheHit() {
|
|
2025
|
-
debug("css cache hit: %s", file);
|
|
2026
|
-
},
|
|
2027
|
-
transform: async () => {
|
|
2028
|
-
await runtimeState.readyPromise;
|
|
2029
|
-
const cssHandlerOptions = getCssHandlerOptions(file, currentRawSource);
|
|
2030
|
-
const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
|
|
2031
|
-
if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
|
|
2032
|
-
const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
|
|
2033
|
-
const sourceCss = sourceFile ? cssSources.get(path.resolve(sourceFile))?.css : void 0;
|
|
2034
|
-
const isConfiguredCssSource = sourceFile !== void 0 && configuredCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
2035
|
-
const isConfiguredMainCssSource = sourceFile !== void 0 && configuredMainCssEntryFiles.some((entry) => path.resolve(entry) === path.resolve(sourceFile));
|
|
2036
|
-
const sourceCssHasTailwindRoot = sourceCss !== void 0 && hasTailwindRootDirectives(sourceCss, { importFallback: true });
|
|
2037
|
-
const shouldPreserveExistingPreflight = cssHandlerOptions.isMainChunk || !isConfiguredMainCssSource && (isConfiguredCssSource || sourceCssHasTailwindRoot);
|
|
2038
|
-
const loaderGeneratedCss = sourceFile ? generatedCssSources.get(path.resolve(sourceFile)) : void 0;
|
|
2039
|
-
const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
2040
|
-
const explicitTailwindV4SourceCandidates = shouldRegenerateExplicitTailwindV4CssSource && sourceCss && sourceFile && webpackSourceCandidates?.getSourceCandidatesForEntries ? await resolveTailwindV4EntriesFromCssCached(sourceCss, path.dirname(sourceFile)).then((resolved) => resolved?.entries ? webpackSourceCandidates.getSourceCandidatesForEntries(resolved.entries) : void 0) : void 0;
|
|
2041
|
-
if (loaderGeneratedCss && shouldConsumeWebpackLoaderGeneratedCss({
|
|
2042
|
-
allowMarkerlessRegistryMatch: configuredCssEntryFiles.length === 1,
|
|
2043
|
-
hasBundlerGeneratedCssMarker: hasBundlerGeneratedCssMarker(currentRawSource),
|
|
2044
|
-
loaderGeneratedClassSet: loaderGeneratedCss.classSet,
|
|
2045
|
-
sourceCandidates: explicitTailwindV4SourceCandidates,
|
|
2046
|
-
shouldRegenerateExplicitTailwindV4CssSource,
|
|
2047
|
-
watchMode
|
|
2048
|
-
})) {
|
|
2049
|
-
for (const className of loaderGeneratedCss.classSet) {
|
|
2050
|
-
generatorRuntimeSet.add(className);
|
|
2051
|
-
transformRuntimeSet.add(className);
|
|
2052
|
-
}
|
|
2053
|
-
for (const dependency of loaderGeneratedCss.dependencies) compilation.fileDependencies?.add?.(dependency);
|
|
2054
|
-
const currentRawSourceWithoutBundlerMarkers = stripBundlerGeneratedCssMarkers(currentRawSource);
|
|
2055
|
-
const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
|
|
2056
|
-
const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
|
|
2057
|
-
const loaderGeneratedCssWithoutMarkers = stripBundlerGeneratedCssMarkers(loaderGeneratedCss.css);
|
|
2058
|
-
const currentAssetUserCssWithoutMarkers = currentAssetUserCss === void 0 ? "" : stripBundlerGeneratedCssMarkers(currentAssetUserCss);
|
|
2059
|
-
const currentAssetMissingUserCss = !(currentAssetUserCssWithoutMarkers.trim().length > 0 && !isCommentOnlyCss(currentAssetUserCssWithoutMarkers)) ? "" : filterExistingCssRules(currentAssetUserCssWithoutMarkers, loaderGeneratedCssWithoutMarkers);
|
|
2060
|
-
if (isConfiguredMainCssSource && !cssHandlerOptions.isMainChunk) {
|
|
2061
|
-
debug("css skip duplicate webpack loader main generation: %s <- %s", file, sourceFile);
|
|
2062
|
-
const userCss = currentAssetMissingUserCss.trim().length === 0 || isCommentOnlyCss(currentAssetMissingUserCss) ? "" : finalizeCssAssetSource(currentAssetMissingUserCss, {
|
|
2063
|
-
cssPreflight: false,
|
|
2064
|
-
generatedCss: false
|
|
2065
|
-
});
|
|
2066
|
-
return { result: new ConcatSource(finalizeTracedCss(userCss, cssHandlerOptions)) };
|
|
2067
|
-
}
|
|
2068
|
-
const mergedLoaderCss = currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
|
|
2069
|
-
css: currentAssetUserCss === void 0 ? loaderGeneratedCss.css : currentAssetHasProcessedUrl ? removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : filterExistingCssRules(currentAssetUserCss, loaderGeneratedCss.css),
|
|
2070
|
-
processed: true
|
|
2071
|
-
}, currentAssetUserCss === void 0 ? void 0 : {
|
|
2072
|
-
css: currentAssetUserCss,
|
|
2073
|
-
processed: true
|
|
2074
|
-
}).css;
|
|
2075
|
-
const handledLoaderCss = isWebGeneratorTarget ? mergedLoaderCss : (await compilerOptions.styleHandler(mergedLoaderCss, cssHandlerOptions)).css;
|
|
2076
|
-
const finalizedLoaderCss = finalizeCssAssetSource(handledLoaderCss, {
|
|
2077
|
-
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
2078
|
-
generatedCss: true,
|
|
2079
|
-
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
2080
|
-
});
|
|
2081
|
-
const loaderSourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[currentAssetUserCss === void 0 ? void 0 : {
|
|
2082
|
-
css: currentAssetUserCss,
|
|
2083
|
-
processed: true
|
|
2084
|
-
}, sourceCss === void 0 ? void 0 : {
|
|
2085
|
-
css: sourceCss,
|
|
2086
|
-
processed: false
|
|
2087
|
-
}].map((source) => {
|
|
2088
|
-
if (source === void 0) return;
|
|
2089
|
-
return {
|
|
2090
|
-
css: collectWebpackBareSelectorUserCss(source.css),
|
|
2091
|
-
processed: source.processed
|
|
2092
|
-
};
|
|
2093
|
-
}));
|
|
2094
|
-
const handledLoaderSourceBareUserCss = loaderSourceBareUserCss === void 0 ? "" : loaderSourceBareUserCss.processed ? loaderSourceBareUserCss.css : (await compilerOptions.styleHandler(loaderSourceBareUserCss.css, cssHandlerOptions)).css;
|
|
2095
|
-
const finalizedLoaderSourceBareUserCss = handledLoaderSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledLoaderSourceBareUserCss, {
|
|
2096
|
-
cssPreflight: false,
|
|
2097
|
-
generatedCss: false
|
|
2098
|
-
});
|
|
2099
|
-
const missingLoaderSourceBareUserCss = finalizedLoaderSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedLoaderCss, finalizedLoaderSourceBareUserCss);
|
|
2100
|
-
const css = finalizeTracedCss(missingLoaderSourceBareUserCss.trim().length === 0 ? finalizedLoaderCss : createWebpackGeneratorUserCssSourceAppend({
|
|
2101
|
-
css: finalizedLoaderCss,
|
|
2102
|
-
processed: true
|
|
2103
|
-
}, {
|
|
2104
|
-
css: missingLoaderSourceBareUserCss,
|
|
2105
|
-
processed: true
|
|
2106
|
-
}).css, cssHandlerOptions, { finalized: true });
|
|
2107
|
-
debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
|
|
2108
|
-
return { result: new ConcatSource(css) };
|
|
2109
|
-
}
|
|
2110
|
-
const sourceCssProcessed = sourceFile ? cssSources.get(path.resolve(sourceFile))?.processed === true : false;
|
|
2111
|
-
const registeredUserRawSource = createWebpackUserCssSourceAppend([...cssSources.entries()].map(([registeredSourceFile, source]) => ({
|
|
2112
|
-
...source,
|
|
2113
|
-
file: registeredSourceFile
|
|
2114
|
-
})), generatorRawSource, sourceFile, (registeredSourceFile) => isSameWebpackSourceScope(file, registeredSourceFile, sourceFile));
|
|
2115
|
-
const currentAssetLooksGenerated = hasTailwindGeneratedCss(currentRawSource) || hasTailwindGeneratedCssMarkers(currentRawSource);
|
|
2116
|
-
const currentAssetHasBundlerGeneratedMarker = hasBundlerGeneratedCssMarker(currentRawSource);
|
|
2117
|
-
const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
|
|
2118
|
-
if (sourceFile === void 0 && currentAssetHasBundlerGeneratedMarker && (currentAssetUserCssSource.trim().length === 0 || isCommentOnlyCss(currentAssetUserCssSource))) return { result: new ConcatSource(finalizeTracedCss("", cssHandlerOptions)) };
|
|
2119
|
-
const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
|
|
2120
|
-
const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
|
|
2121
|
-
const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
|
|
2122
|
-
const currentAssetHasUserCss = (sourceCssProcessed || hasExplicitSourceCssForCurrentAsset) && currentAssetLooksGenerated && !shouldPreserveGeneratedWebAssetUserCss ? currentAssetHasAdditionalUserCss : shouldUseWebpackAssetAsGeneratorUserCss(currentAssetUserCssSource, generatorRawSource, { processed: sourceCssProcessed || shouldPreserveGeneratedWebAssetUserCss });
|
|
2123
|
-
const userRawSource = createWebpackGeneratorUserCssSourceAppend(createWebpackCurrentAssetUserRawSource({
|
|
2124
|
-
currentAssetHasUserCss,
|
|
2125
|
-
currentAssetLooksGenerated,
|
|
2126
|
-
currentAssetUserCssSource,
|
|
2127
|
-
shouldAppendCurrentAssetUserCss: shouldAppendCurrentWebpackAssetUserCss({
|
|
2128
|
-
currentAssetHasBundlerGeneratedMarker,
|
|
2129
|
-
currentAssetHasUserCss,
|
|
2130
|
-
currentAssetLooksGenerated,
|
|
2131
|
-
registeredUserRawSource,
|
|
2132
|
-
shouldPreserveGeneratedWebAssetUserCss,
|
|
2133
|
-
sourceCssProcessed
|
|
2134
|
-
}),
|
|
2135
|
-
sourceCssProcessed
|
|
2136
|
-
}), registeredUserRawSource);
|
|
2137
|
-
if (isPureLocalCssImportWrapper(currentRawSource)) return { result: new ConcatSource(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
|
|
2138
|
-
const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
|
|
2139
|
-
const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
2140
|
-
const currentAssetHasTailwindDirectives = hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || hasTailwindApplyDirective(generatorRawSource);
|
|
2141
|
-
const shouldForceTailwindV4Generation = hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 && sourceFile !== void 0 || currentAssetHasTailwindDirectives || hasExplicitTailwindV4SourceCss);
|
|
2142
|
-
const shouldSkipUnmatchedMainCssGeneration = !isWebGeneratorTarget && cssHandlerOptions.isMainChunk && sourceFile === void 0 && configuredMainCssEntryFiles.length > 0 && !currentAssetHasTailwindDirectives;
|
|
2143
|
-
const shouldSkipPlainNonMainCssGeneration = !cssHandlerOptions.isMainChunk && sourceCss !== void 0 && !hasExplicitSourceCssForCurrentAsset && !hasExplicitTailwindV4SourceCss && !currentAssetHasTailwindDirectives;
|
|
2144
|
-
const shouldMergeFallbackGeneratorRuntime = cssHandlerOptions.isMainChunk || currentAssetHasTailwindDirectives || hasExplicitSourceCssForCurrentAsset;
|
|
2145
|
-
const scopedFallbackGeneratorRuntimeSet = hasExplicitTailwindV4SourceCss || !shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet;
|
|
2146
|
-
const resolvedScopedGeneratorRuntimeSet = await createScopedGeneratorRuntime({
|
|
2147
|
-
cssHandlerOptions,
|
|
2148
|
-
fallbackRuntime: scopedFallbackGeneratorRuntimeSet,
|
|
2149
|
-
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
2150
|
-
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2151
|
-
outputFile: file,
|
|
2152
|
-
rawSource: sourceFile ? cssSources.get(path.resolve(sourceFile))?.css ?? generatorRawSource : generatorRawSource,
|
|
2153
|
-
shouldExcludeSubpackageSourceCandidates: () => false,
|
|
2154
|
-
sourceFile: sourceFile ?? file,
|
|
2155
|
-
scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
|
|
2156
|
-
});
|
|
2157
|
-
const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== scopedFallbackGeneratorRuntimeSet && shouldMergeFallbackGeneratorRuntime ? /* @__PURE__ */ new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
|
|
2158
|
-
const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
|
|
2159
|
-
const scopedGeneratorCompilerOptions = scopeWebpackGeneratorOptionsToCssSource(compilerOptions, sourceFile, { disableUnmatchedCssEntries: !isWebGeneratorTarget && cssHandlerOptions.isMainChunk });
|
|
2160
|
-
const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
|
|
2161
|
-
...cssHandlerOptions,
|
|
2162
|
-
sourceOptions: {
|
|
2163
|
-
...cssHandlerOptions.sourceOptions,
|
|
2164
|
-
cssSources: generatorCssSources
|
|
2165
|
-
}
|
|
2166
|
-
};
|
|
2167
|
-
const generatorOptions = {
|
|
2168
|
-
opts: scopedGeneratorCompilerOptions,
|
|
2169
|
-
runtimeState,
|
|
2170
|
-
runtime: scopedGeneratorRuntimeSet,
|
|
2171
|
-
rawSource: generatorRawSource,
|
|
2172
|
-
forceGenerator: shouldForceTailwindV4Generation,
|
|
2173
|
-
...hasUsableWebpackGeneratorCssSources(generatorCssSources) ? { cssSources: generatorCssSources } : {},
|
|
2174
|
-
...userRawSource === void 0 ? {} : { userRawSource: userRawSource.css },
|
|
2175
|
-
...userRawSource?.processed === true ? { userRawSourceProcessed: true } : {},
|
|
2176
|
-
file,
|
|
2177
|
-
cssHandlerOptions: generatorCssHandlerOptions,
|
|
2178
|
-
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
2179
|
-
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
2180
|
-
sourceCandidates: scopedGeneratorRuntimeSet,
|
|
2181
|
-
restoreLocalCssImports: false,
|
|
2182
|
-
styleHandler: compilerOptions.styleHandler,
|
|
2183
|
-
debug
|
|
2184
|
-
};
|
|
2185
|
-
let generated;
|
|
2186
|
-
if (!shouldSkipUnmatchedMainCssGeneration && !shouldSkipPlainNonMainCssGeneration) try {
|
|
2187
|
-
generated = await generateTailwindV4Css({
|
|
2188
|
-
...generatorOptions,
|
|
2189
|
-
outputFile: file
|
|
2190
|
-
});
|
|
2191
|
-
} catch (error) {
|
|
2192
|
-
if (!shouldFallbackToWebpackUserCssOnGeneratorError({
|
|
2193
|
-
configuredMainCssEntryFilesLength: configuredMainCssEntryFiles.length,
|
|
2194
|
-
generatorRawSource,
|
|
2195
|
-
hasExplicitTailwindV4SourceCss
|
|
2196
|
-
})) throw error;
|
|
2197
|
-
debug("css generator skipped for plain webpack css asset: %s %O", file, error);
|
|
2198
|
-
generated = void 0;
|
|
2199
|
-
}
|
|
2200
|
-
else debug("css generator skipped for plain webpack css asset: %s", file);
|
|
2201
|
-
const finalizedGeneratedCss = generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
|
|
2202
|
-
css: generated.css,
|
|
2203
|
-
processed: true
|
|
2204
|
-
}, {
|
|
2205
|
-
css: removeWebpackTailwindGeneratedAssetCss(currentRawSource),
|
|
2206
|
-
processed: true
|
|
2207
|
-
})?.css ?? generated.css : generated.css, {
|
|
2208
|
-
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
2209
|
-
generatedCss: true,
|
|
2210
|
-
preserveExistingPreflight: shouldPreserveExistingPreflight
|
|
2211
|
-
}) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false });
|
|
2212
|
-
const sourceBareUserCss = isWebGeneratorTarget ? void 0 : createWebpackGeneratorUserCssSourceAppend(...[
|
|
2213
|
-
userRawSource,
|
|
2214
|
-
sourceCss === void 0 ? void 0 : {
|
|
2215
|
-
css: sourceCss,
|
|
2216
|
-
processed: sourceCssProcessed
|
|
2217
|
-
},
|
|
2218
|
-
{
|
|
2219
|
-
css: generatorRawSource,
|
|
2220
|
-
processed: false
|
|
2221
|
-
}
|
|
2222
|
-
].map((source) => {
|
|
2223
|
-
if (source === void 0) return;
|
|
2224
|
-
return {
|
|
2225
|
-
css: collectWebpackBareSelectorUserCss(source.css),
|
|
2226
|
-
processed: source.processed
|
|
2227
|
-
};
|
|
2228
|
-
}));
|
|
2229
|
-
const handledSourceBareUserCss = sourceBareUserCss === void 0 ? "" : sourceBareUserCss.processed ? sourceBareUserCss.css : (await compilerOptions.styleHandler(sourceBareUserCss.css, cssHandlerOptions)).css;
|
|
2230
|
-
const finalizedSourceBareUserCss = handledSourceBareUserCss.trim().length === 0 ? "" : finalizeCssAssetSource(handledSourceBareUserCss, {
|
|
2231
|
-
cssPreflight: false,
|
|
2232
|
-
generatedCss: false
|
|
2233
|
-
});
|
|
2234
|
-
const missingSourceBareUserCss = finalizedSourceBareUserCss.trim().length === 0 ? "" : filterExistingCssRules(finalizedGeneratedCss, finalizedSourceBareUserCss);
|
|
2235
|
-
const css = finalizeTracedCss(missingSourceBareUserCss.trim().length === 0 ? finalizedGeneratedCss : createWebpackGeneratorUserCssSourceAppend({
|
|
2236
|
-
css: finalizedGeneratedCss,
|
|
2237
|
-
processed: true
|
|
2238
|
-
}, {
|
|
2239
|
-
css: missingSourceBareUserCss,
|
|
2240
|
-
processed: true
|
|
2241
|
-
}).css, cssHandlerOptions, { finalized: true });
|
|
2242
|
-
const source = new ConcatSource(css);
|
|
2243
|
-
if (generated) {
|
|
2244
|
-
for (const className of generated.classSet) generatorRuntimeSet.add(className);
|
|
2245
|
-
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
|
|
2246
|
-
} else debug("css handle: %s", file);
|
|
2247
|
-
return { result: source };
|
|
2248
|
-
}
|
|
2249
|
-
});
|
|
2250
|
-
}, cssTaskFactories);
|
|
2251
|
-
}
|
|
2252
|
-
if (!watchMode) {
|
|
2253
|
-
pushConcurrentTaskFactories(tasks, htmlTaskFactories, taskConcurrency);
|
|
2254
|
-
await Promise.all(tasks);
|
|
2255
|
-
tasks.length = 0;
|
|
2256
|
-
pushConcurrentTaskFactories(tasks, jsTaskFactories, taskConcurrency);
|
|
2257
|
-
await Promise.all(tasks);
|
|
2258
|
-
tasks.length = 0;
|
|
2259
|
-
pushConcurrentTaskFactories(tasks, cssTaskFactories, taskConcurrency);
|
|
2434
|
+
if (await processWebpackProcessedCssAsset(element, cssTaskContext)) continue;
|
|
2435
|
+
await processWebpackGeneratedCssAsset(element, cssTaskContext);
|
|
2260
2436
|
}
|
|
2261
|
-
await
|
|
2262
|
-
compilerOptions.cache.prune?.({
|
|
2263
|
-
cacheKeys: activeProcessCacheKeys,
|
|
2264
|
-
hashKeys: activeProcessHashKeys
|
|
2265
|
-
});
|
|
2266
|
-
const activeCssFiles = new Set(groupedEntries.css.map(([file]) => file));
|
|
2267
|
-
pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
|
|
2268
|
-
if (activeCssFiles.size > 0) pruneWebpackCssSources?.(/* @__PURE__ */ new Set([
|
|
2269
|
-
...registeredWebpackCssSourceFiles,
|
|
2270
|
-
...activeWebpackCssSourceFiles,
|
|
2271
|
-
...[...cssAssetResources.values()].flatMap((resources) => [...resources])
|
|
2272
|
-
]), { watchMode });
|
|
2273
|
-
debug("end");
|
|
2274
|
-
emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, { memoryDebug: resolveWebpackMemoryDebugStats({
|
|
2275
|
-
activeAssetFiles: entries.length,
|
|
2276
|
-
activeCssFiles: activeCssFiles.size,
|
|
2437
|
+
await finalizeWebpackProcessAssets({
|
|
2277
2438
|
activeProcessCacheKeys,
|
|
2278
2439
|
activeProcessHashKeys,
|
|
2279
|
-
|
|
2440
|
+
activeWebpackCssSourceFiles,
|
|
2441
|
+
compilerOptions,
|
|
2442
|
+
cssAssetResources,
|
|
2280
2443
|
cssHandlerOptionsCache,
|
|
2444
|
+
cssTaskFactories,
|
|
2281
2445
|
cssUserHandlerOptionsCache,
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2446
|
+
debug,
|
|
2447
|
+
entries,
|
|
2448
|
+
groupedEntries,
|
|
2449
|
+
hmrTimingStartedAt,
|
|
2450
|
+
htmlTaskFactories,
|
|
2451
|
+
jsTaskFactories,
|
|
2452
|
+
pruneWebpackCssSources,
|
|
2453
|
+
recordTimingDetail,
|
|
2454
|
+
registeredWebpackCssSourceFiles,
|
|
2455
|
+
taskConcurrency,
|
|
2456
|
+
tasks,
|
|
2457
|
+
timingDetails,
|
|
2458
|
+
watchMode,
|
|
2459
|
+
webpackSourceCandidateScanCache
|
|
2460
|
+
});
|
|
2286
2461
|
});
|
|
2287
2462
|
if (!isWebGeneratorTarget) compilation.hooks.processAssets.tapPromise({
|
|
2288
2463
|
name: `${pluginName}:finalize-css-assets`,
|
|
@@ -2303,11 +2478,106 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
2303
2478
|
});
|
|
2304
2479
|
}
|
|
2305
2480
|
//#endregion
|
|
2306
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.
|
|
2481
|
+
//#region ../../node_modules/.pnpm/tsdown@0.22.8_oxc-resolver@11.20.0_tsx@4.23.1_typescript@6.0.3_unrun@0.2.37_synckit@0.1_6382f73c03b72307015b1b16541a6d64/node_modules/tsdown/esm-shims.js
|
|
2307
2482
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
2308
2483
|
const getDirname = () => path.dirname(getFilename());
|
|
2309
2484
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
2310
2485
|
//#endregion
|
|
2486
|
+
//#region src/shared/mpx-plugin-owner.ts
|
|
2487
|
+
const localRequire = createRequire(import.meta.url);
|
|
2488
|
+
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
2489
|
+
const MPX_WEBPACK_PLUGIN_LIB_RE = /^(.*[\\/]@mpxjs[\\/]webpack-plugin)[\\/]lib[\\/]/;
|
|
2490
|
+
const MPX_RECORD_RESOURCE_MAP_DEPENDENCY_RE = /@mpxjs[\\/]webpack-plugin[\\/]lib[\\/]dependencies[\\/]RecordResourceMapDependency(?:\.js)?$/;
|
|
2491
|
+
const compilationOwnerDirs = /* @__PURE__ */ new WeakMap();
|
|
2492
|
+
function findMpxWebpackPluginDir(value) {
|
|
2493
|
+
if (typeof value === "string") return value.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1];
|
|
2494
|
+
if (Array.isArray(value)) {
|
|
2495
|
+
for (const item of value) {
|
|
2496
|
+
const result = findMpxWebpackPluginDir(item);
|
|
2497
|
+
if (result) return result;
|
|
2498
|
+
}
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2501
|
+
if (value && typeof value === "object") for (const key of [
|
|
2502
|
+
"loader",
|
|
2503
|
+
"use",
|
|
2504
|
+
"rules",
|
|
2505
|
+
"oneOf"
|
|
2506
|
+
]) {
|
|
2507
|
+
const result = findMpxWebpackPluginDir(value[key]);
|
|
2508
|
+
if (result) return result;
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
function resolveContextPluginDir(context) {
|
|
2512
|
+
if (typeof context !== "string" || context.length === 0) return;
|
|
2513
|
+
try {
|
|
2514
|
+
const projectRequire = createRequire(path.join(context, "package.json"));
|
|
2515
|
+
return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2516
|
+
} catch {
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
function resolveCompilationPluginDir(compilation, candidates) {
|
|
2521
|
+
const getTemplate = compilation?.dependencyTemplates?.get;
|
|
2522
|
+
if (typeof getTemplate !== "function") return;
|
|
2523
|
+
if (compilation && typeof compilation === "object") {
|
|
2524
|
+
const cached = compilationOwnerDirs.get(compilation);
|
|
2525
|
+
if (cached) return cached;
|
|
2526
|
+
}
|
|
2527
|
+
const rememberOwner = (pluginDir) => {
|
|
2528
|
+
if (pluginDir && compilation && typeof compilation === "object") compilationOwnerDirs.set(compilation, pluginDir);
|
|
2529
|
+
return pluginDir;
|
|
2530
|
+
};
|
|
2531
|
+
for (const [file, module] of Object.entries(localRequire.cache)) {
|
|
2532
|
+
if (!MPX_RECORD_RESOURCE_MAP_DEPENDENCY_RE.test(file)) continue;
|
|
2533
|
+
if (getTemplate.call(compilation.dependencyTemplates, module?.exports)) return rememberOwner(file.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1]);
|
|
2534
|
+
}
|
|
2535
|
+
for (const pluginDir of candidates) try {
|
|
2536
|
+
const dependency = createRequire(path.join(pluginDir, "package.json"))(path.join(pluginDir, "lib/dependencies/RecordResourceMapDependency"));
|
|
2537
|
+
if (getTemplate.call(compilation.dependencyTemplates, dependency)) return rememberOwner(pluginDir);
|
|
2538
|
+
} catch {}
|
|
2539
|
+
}
|
|
2540
|
+
function collectMpxWebpackPluginDirs(owner, fallback) {
|
|
2541
|
+
const activeLoaderPluginDir = findMpxWebpackPluginDir([owner?._module?.loaders, owner?.loaders]);
|
|
2542
|
+
const contextPluginDirs = [
|
|
2543
|
+
owner?.rootContext,
|
|
2544
|
+
owner?.context,
|
|
2545
|
+
owner?.options?.context,
|
|
2546
|
+
process.cwd()
|
|
2547
|
+
].map(resolveContextPluginDir).filter((item) => Boolean(item));
|
|
2548
|
+
const configuredRulePluginDir = findMpxWebpackPluginDir(owner?.options?.module?.rules);
|
|
2549
|
+
const cachedPluginDirs = Object.keys(localRequire.cache).map((file) => file.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1] ?? (MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file) ? path.dirname(file) : void 0)).filter((item) => Boolean(item));
|
|
2550
|
+
const localPluginDir = (() => {
|
|
2551
|
+
try {
|
|
2552
|
+
return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2553
|
+
} catch {
|
|
2554
|
+
return;
|
|
2555
|
+
}
|
|
2556
|
+
})();
|
|
2557
|
+
return {
|
|
2558
|
+
activeLoaderPluginDir,
|
|
2559
|
+
candidates: new Set([
|
|
2560
|
+
activeLoaderPluginDir,
|
|
2561
|
+
...contextPluginDirs,
|
|
2562
|
+
configuredRulePluginDir,
|
|
2563
|
+
fallback,
|
|
2564
|
+
...cachedPluginDirs,
|
|
2565
|
+
localPluginDir
|
|
2566
|
+
].filter((item) => Boolean(item))),
|
|
2567
|
+
configuredRulePluginDir,
|
|
2568
|
+
contextPluginDirs,
|
|
2569
|
+
cachedPluginDirs,
|
|
2570
|
+
localPluginDir
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
function resolveMpxWebpackPluginCompilationOwnerDir(owner, compilation, fallback) {
|
|
2574
|
+
return resolveCompilationPluginDir(compilation, collectMpxWebpackPluginDirs(owner, fallback).candidates);
|
|
2575
|
+
}
|
|
2576
|
+
function resolveMpxWebpackPluginDir(owner, fallback, compilation = owner?._compilation ?? owner?.compilation) {
|
|
2577
|
+
const { activeLoaderPluginDir, candidates, configuredRulePluginDir, contextPluginDirs, cachedPluginDirs, localPluginDir } = collectMpxWebpackPluginDirs(owner, fallback);
|
|
2578
|
+
return resolveCompilationPluginDir(compilation, candidates) ?? activeLoaderPluginDir ?? contextPluginDirs[0] ?? configuredRulePluginDir ?? fallback ?? cachedPluginDirs[0] ?? localPluginDir;
|
|
2579
|
+
}
|
|
2580
|
+
//#endregion
|
|
2311
2581
|
//#region src/shared/tailwindcss-css-redirect.ts
|
|
2312
2582
|
const moduleWithMutableResolve = Module;
|
|
2313
2583
|
const patched = /* @__PURE__ */ new WeakSet();
|
|
@@ -2326,33 +2596,8 @@ function installTailwindcssCssRedirect(pkgDir) {
|
|
|
2326
2596
|
}
|
|
2327
2597
|
//#endregion
|
|
2328
2598
|
//#region src/shared/mpx.ts
|
|
2329
|
-
const localRequire = createRequire(import.meta.url);
|
|
2330
2599
|
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
|
|
2331
|
-
const
|
|
2332
|
-
const MPX_WEBPACK_PLUGIN_LIB_RE = /^(.*[\\/]@mpxjs[\\/]webpack-plugin)[\\/]lib[\\/]/;
|
|
2333
|
-
const MPX_WEBPACK_PLUGIN_REQUEST_RE = /@mpxjs\/webpack-plugin\/([^!?]+)/g;
|
|
2334
|
-
function findMpxWebpackPluginDirFromRules(rules) {
|
|
2335
|
-
const visit = (value) => {
|
|
2336
|
-
if (typeof value === "string") return value.match(MPX_WEBPACK_PLUGIN_LIB_RE)?.[1];
|
|
2337
|
-
if (Array.isArray(value)) {
|
|
2338
|
-
for (const item of value) {
|
|
2339
|
-
const result = visit(item);
|
|
2340
|
-
if (result) return result;
|
|
2341
|
-
}
|
|
2342
|
-
return;
|
|
2343
|
-
}
|
|
2344
|
-
if (value && typeof value === "object") for (const key of [
|
|
2345
|
-
"loader",
|
|
2346
|
-
"use",
|
|
2347
|
-
"rules",
|
|
2348
|
-
"oneOf"
|
|
2349
|
-
]) {
|
|
2350
|
-
const result = visit(value[key]);
|
|
2351
|
-
if (result) return result;
|
|
2352
|
-
}
|
|
2353
|
-
};
|
|
2354
|
-
return visit(rules);
|
|
2355
|
-
}
|
|
2600
|
+
const MPX_WEBPACK_PLUGIN_REQUEST_PATH_RE = /(?:^|[\\/])@mpxjs[\\/]webpack-plugin(?:[\\/](.+))?$/;
|
|
2356
2601
|
function isMpxStyleResourceQuery(query) {
|
|
2357
2602
|
if (typeof query !== "string") return false;
|
|
2358
2603
|
return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
|
|
@@ -2360,34 +2605,16 @@ function isMpxStyleResourceQuery(query) {
|
|
|
2360
2605
|
function getTailwindcssCssEntry(pkgDir) {
|
|
2361
2606
|
return path.join(pkgDir, "index.css");
|
|
2362
2607
|
}
|
|
2363
|
-
function resolveMpxWebpackPluginDir(compiler) {
|
|
2364
|
-
const rulePluginDir = findMpxWebpackPluginDirFromRules([
|
|
2365
|
-
compiler?._module?.loaders,
|
|
2366
|
-
compiler?.loaders,
|
|
2367
|
-
compiler?.options?.module?.rules
|
|
2368
|
-
]);
|
|
2369
|
-
if (rulePluginDir) return rulePluginDir;
|
|
2370
|
-
const candidates = [
|
|
2371
|
-
compiler?.context,
|
|
2372
|
-
compiler?.options?.context,
|
|
2373
|
-
process.cwd()
|
|
2374
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
2375
|
-
for (const candidate of candidates) try {
|
|
2376
|
-
const projectRequire = createRequire(path.join(candidate, "package.json"));
|
|
2377
|
-
return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2378
|
-
} catch {}
|
|
2379
|
-
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
2380
|
-
if (cachedPackageJson) return path.dirname(cachedPackageJson);
|
|
2381
|
-
try {
|
|
2382
|
-
return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
2383
|
-
} catch {
|
|
2384
|
-
return;
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
2608
|
function rewriteMpxWebpackPluginRequests(request, mpxWebpackPluginDir, pathImpl = path) {
|
|
2388
|
-
return request.
|
|
2389
|
-
|
|
2390
|
-
|
|
2609
|
+
return request.split("!").map((segment) => {
|
|
2610
|
+
const queryIndex = segment.indexOf("?");
|
|
2611
|
+
const requestPath = queryIndex === -1 ? segment : segment.slice(0, queryIndex);
|
|
2612
|
+
const query = queryIndex === -1 ? "" : segment.slice(queryIndex);
|
|
2613
|
+
const match = requestPath.match(MPX_WEBPACK_PLUGIN_REQUEST_PATH_RE);
|
|
2614
|
+
if (!match) return segment;
|
|
2615
|
+
const subpath = match[1];
|
|
2616
|
+
return `${subpath ? pathImpl.join(mpxWebpackPluginDir, ...subpath.split(/[\\/]/)) : mpxWebpackPluginDir}${query}`;
|
|
2617
|
+
}).join("!");
|
|
2391
2618
|
}
|
|
2392
2619
|
function patchMpxWebpackPluginRequests(compiler, mpxWebpackPluginDir) {
|
|
2393
2620
|
if (!mpxWebpackPluginDir || !compiler) return false;
|
|
@@ -2395,26 +2622,37 @@ function patchMpxWebpackPluginRequests(compiler, mpxWebpackPluginDir) {
|
|
|
2395
2622
|
const patchedCompilers = /* @__PURE__ */ new WeakSet();
|
|
2396
2623
|
const patchedLoaderResolvers = /* @__PURE__ */ new WeakSet();
|
|
2397
2624
|
const patchedResolverFactories = /* @__PURE__ */ new WeakSet();
|
|
2625
|
+
let activePluginDir = mpxWebpackPluginDir;
|
|
2626
|
+
const getActivePluginDir = () => activePluginDir;
|
|
2398
2627
|
const install = (targetCompiler) => {
|
|
2399
2628
|
if (!targetCompiler || typeof targetCompiler !== "object" || patchedCompilers.has(targetCompiler)) return;
|
|
2400
2629
|
patchedCompilers.add(targetCompiler);
|
|
2401
|
-
ensureResolveLoaderAlias(targetCompiler,
|
|
2630
|
+
ensureResolveLoaderAlias(targetCompiler, activePluginDir);
|
|
2402
2631
|
const resolverFactory = targetCompiler.resolverFactory;
|
|
2403
2632
|
if (resolverFactory && typeof resolverFactory === "object" && !patchedResolverFactories.has(resolverFactory)) {
|
|
2404
2633
|
patchedResolverFactories.add(resolverFactory);
|
|
2405
|
-
installMpxResolveLoaderAlias(targetCompiler,
|
|
2634
|
+
installMpxResolveLoaderAlias(targetCompiler, getActivePluginDir);
|
|
2406
2635
|
}
|
|
2407
2636
|
targetCompiler.hooks?.normalModuleFactory?.tap?.(pluginName, (normalModuleFactory) => {
|
|
2408
2637
|
const loaderResolver = normalModuleFactory.getResolver?.("loader");
|
|
2409
2638
|
if (loaderResolver && typeof loaderResolver === "object" && !patchedLoaderResolvers.has(loaderResolver)) {
|
|
2410
2639
|
patchedLoaderResolvers.add(loaderResolver);
|
|
2411
|
-
patchMpxLoaderResolver(loaderResolver,
|
|
2640
|
+
patchMpxLoaderResolver(loaderResolver, getActivePluginDir);
|
|
2412
2641
|
}
|
|
2413
2642
|
normalModuleFactory.hooks.beforeResolve.tap(pluginName, (resolveData) => {
|
|
2414
|
-
|
|
2643
|
+
const pluginDir = getActivePluginDir();
|
|
2644
|
+
if (pluginDir && typeof resolveData?.request === "string") resolveData.request = rewriteMpxWebpackPluginRequests(resolveData.request, pluginDir);
|
|
2415
2645
|
});
|
|
2416
2646
|
});
|
|
2417
2647
|
targetCompiler.hooks?.compilation?.tap?.(pluginName, (compilation) => {
|
|
2648
|
+
const compilationPluginDir = resolveMpxWebpackPluginCompilationOwnerDir(targetCompiler, compilation, activePluginDir);
|
|
2649
|
+
if (compilationPluginDir) {
|
|
2650
|
+
activePluginDir = compilationPluginDir;
|
|
2651
|
+
patchMpxWebpackPluginNormalizeLib(targetCompiler, compilationPluginDir);
|
|
2652
|
+
ensureResolveLoaderAlias(targetCompiler, compilationPluginDir);
|
|
2653
|
+
const alias = targetCompiler.options?.resolve?.alias;
|
|
2654
|
+
if (alias) addMpxWebpackPluginAlias(alias, compilationPluginDir);
|
|
2655
|
+
}
|
|
2418
2656
|
compilation.hooks?.childCompiler?.tap?.(pluginName, (childCompiler) => {
|
|
2419
2657
|
install(childCompiler);
|
|
2420
2658
|
});
|
|
@@ -2434,20 +2672,33 @@ function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
|
2434
2672
|
const recordLoader = path.join(pkgDir, "lib/record-loader");
|
|
2435
2673
|
const styleCompiler = path.join(pkgDir, "lib/style-compiler/index");
|
|
2436
2674
|
const stripConditionalLoader = path.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
2437
|
-
if (Array.isArray(alias))
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2675
|
+
if (Array.isArray(alias)) {
|
|
2676
|
+
const entries = [
|
|
2677
|
+
{
|
|
2678
|
+
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
2679
|
+
alias: recordLoader
|
|
2680
|
+
},
|
|
2681
|
+
{
|
|
2682
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
2683
|
+
alias: styleCompiler
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
2687
|
+
alias: stripConditionalLoader
|
|
2688
|
+
},
|
|
2689
|
+
{
|
|
2690
|
+
name: /^@mpxjs\/webpack-plugin\//,
|
|
2691
|
+
alias: pkgDir
|
|
2692
|
+
}
|
|
2693
|
+
];
|
|
2694
|
+
const managedNames = new Set(entries.filter((entry) => typeof entry.name === "string").map((entry) => entry.name));
|
|
2695
|
+
const managedPatterns = new Set(entries.filter((entry) => entry.name instanceof RegExp).map((entry) => `${entry.name.source}/${entry.name.flags}`));
|
|
2696
|
+
for (let index = alias.length - 1; index >= 0; index--) {
|
|
2697
|
+
const name = alias[index]?.name;
|
|
2698
|
+
if (managedNames.has(name) || name instanceof RegExp && managedPatterns.has(`${name.source}/${name.flags}`)) alias.splice(index, 1);
|
|
2699
|
+
}
|
|
2700
|
+
alias.unshift(...entries);
|
|
2701
|
+
} else {
|
|
2451
2702
|
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
2452
2703
|
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
2453
2704
|
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
@@ -2461,13 +2712,15 @@ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
|
2461
2712
|
compiler.options.resolveLoader.alias = alias;
|
|
2462
2713
|
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
2463
2714
|
}
|
|
2464
|
-
function installMpxResolveLoaderAlias(compiler,
|
|
2715
|
+
function installMpxResolveLoaderAlias(compiler, getMpxWebpackPluginDir) {
|
|
2465
2716
|
const resolveOptionsHook = compiler?.resolverFactory?.hooks?.resolveOptions?.for?.("loader");
|
|
2466
2717
|
if (!resolveOptionsHook?.tap) return;
|
|
2467
2718
|
resolveOptionsHook.tap({
|
|
2468
2719
|
name: "weapp-tailwindcss-mpx-loader-resolve",
|
|
2469
2720
|
stage: 100
|
|
2470
2721
|
}, (resolveOptions) => {
|
|
2722
|
+
const mpxWebpackPluginDir = getMpxWebpackPluginDir();
|
|
2723
|
+
if (!mpxWebpackPluginDir) return resolveOptions;
|
|
2471
2724
|
const alias = Array.isArray(resolveOptions.alias) ? [...resolveOptions.alias] : { ...resolveOptions.alias };
|
|
2472
2725
|
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
2473
2726
|
return {
|
|
@@ -2476,13 +2729,14 @@ function installMpxResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
|
2476
2729
|
};
|
|
2477
2730
|
});
|
|
2478
2731
|
}
|
|
2479
|
-
function patchMpxLoaderResolver(resolver,
|
|
2732
|
+
function patchMpxLoaderResolver(resolver, getMpxWebpackPluginDir) {
|
|
2480
2733
|
const originalResolve = resolver?.resolve;
|
|
2481
2734
|
if (typeof originalResolve !== "function" || originalResolve.__weappTwPatched) return;
|
|
2482
2735
|
const wrappedResolve = function(...args) {
|
|
2483
2736
|
const requestIndex = typeof args[0] === "string" ? 1 : 2;
|
|
2484
2737
|
const request = args[requestIndex];
|
|
2485
|
-
|
|
2738
|
+
const mpxWebpackPluginDir = getMpxWebpackPluginDir();
|
|
2739
|
+
if (mpxWebpackPluginDir && typeof request === "string" && isMpxWebpackPluginRequest(request)) args[requestIndex] = resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir);
|
|
2486
2740
|
return originalResolve.apply(this, args);
|
|
2487
2741
|
};
|
|
2488
2742
|
wrappedResolve.__weappTwPatched = true;
|
|
@@ -2532,12 +2786,13 @@ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
|
2532
2786
|
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
2533
2787
|
if (!enabled) return;
|
|
2534
2788
|
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
2535
|
-
const
|
|
2789
|
+
const getMpxWebpackPluginDir = () => resolveMpxWebpackPluginDir(loaderContext);
|
|
2536
2790
|
const originalResolve = loaderContext.resolve;
|
|
2537
2791
|
if (typeof originalResolve === "function" && !originalResolve.__weappTwPatched) {
|
|
2538
2792
|
const wrappedResolve = function(context, request, callback) {
|
|
2539
2793
|
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
2540
2794
|
if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
|
|
2795
|
+
const mpxWebpackPluginDir = getMpxWebpackPluginDir();
|
|
2541
2796
|
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
2542
2797
|
return originalResolve.call(this, context, request, callback);
|
|
2543
2798
|
};
|
|
@@ -2545,9 +2800,10 @@ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
|
2545
2800
|
loaderContext.resolve = wrappedResolve;
|
|
2546
2801
|
}
|
|
2547
2802
|
const originalImportModule = loaderContext.importModule;
|
|
2548
|
-
if (
|
|
2803
|
+
if (typeof originalImportModule === "function" && !originalImportModule.__weappTwPatched) {
|
|
2549
2804
|
const wrappedImportModule = function(request, ...args) {
|
|
2550
|
-
const
|
|
2805
|
+
const mpxWebpackPluginDir = getMpxWebpackPluginDir();
|
|
2806
|
+
const resolvedRequest = mpxWebpackPluginDir && typeof request === "string" ? rewriteMpxWebpackPluginRequests(request, mpxWebpackPluginDir) : request;
|
|
2551
2807
|
return originalImportModule.call(this, resolvedRequest, ...args);
|
|
2552
2808
|
};
|
|
2553
2809
|
wrappedImportModule.__weappTwPatched = true;
|
|
@@ -2619,7 +2875,7 @@ function createDefaultLoaderAnchorFinders() {
|
|
|
2619
2875
|
//#endregion
|
|
2620
2876
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
2621
2877
|
function setupWebpackV5Loaders(options) {
|
|
2622
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, loaderAnchorFinders = createDefaultLoaderAnchorFinders(), mpxCssImportRewrite = false, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
2878
|
+
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, updateWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, loaderAnchorFinders = createDefaultLoaderAnchorFinders(), mpxCssImportRewrite = false, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
2623
2879
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(compilerOptions.generator, {
|
|
2624
2880
|
appType: compilerOptions.appType,
|
|
2625
2881
|
platform: compilerOptions.cssOptions?.platform ?? compilerOptions.platform,
|
|
@@ -2659,7 +2915,8 @@ function setupWebpackV5Loaders(options) {
|
|
|
2659
2915
|
classSet: {
|
|
2660
2916
|
getClassSet: getClassSetInLoader,
|
|
2661
2917
|
getWatchDependencies: getRuntimeWatchDependencies,
|
|
2662
|
-
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile }
|
|
2918
|
+
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile },
|
|
2919
|
+
...updateWebpackGeneratedCss === void 0 ? {} : { updateGeneratedCss: updateWebpackGeneratedCss }
|
|
2663
2920
|
},
|
|
2664
2921
|
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
2665
2922
|
});
|
|
@@ -2711,6 +2968,10 @@ function setupWebpackV5Loaders(options) {
|
|
|
2711
2968
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
2712
2969
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
2713
2970
|
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
2971
|
+
if (isCssModule) {
|
|
2972
|
+
const frameworkPostcssOptions = collectFrameworkPostcssOptionsFromLoaderEntries(loaderEntries, _loaderContext);
|
|
2973
|
+
if (frameworkPostcssOptions) captureResolvedFrameworkPostcssOptions(compilerOptions, frameworkPostcssOptions);
|
|
2974
|
+
}
|
|
2714
2975
|
if (isCssModule && typeof module.resource === "string") markWebpackCssSourceModule?.(module.resource);
|
|
2715
2976
|
if (process.env["WEAPP_TW_LOADER_DEBUG"] && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
2716
2977
|
rewriteAnchorIdx,
|
|
@@ -2758,7 +3019,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
2758
3019
|
});
|
|
2759
3020
|
}
|
|
2760
3021
|
//#endregion
|
|
2761
|
-
//#region src/bundlers/webpack/shared/create-framework-plugin.ts
|
|
3022
|
+
//#region src/bundlers/webpack/shared/create-framework-plugin/watch-output.ts
|
|
2762
3023
|
const debug = createDebug();
|
|
2763
3024
|
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
2764
3025
|
const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
|
|
@@ -2824,6 +3085,8 @@ function setupWebpackWatchOutputIgnore(compiler) {
|
|
|
2824
3085
|
}
|
|
2825
3086
|
});
|
|
2826
3087
|
}
|
|
3088
|
+
//#endregion
|
|
3089
|
+
//#region src/bundlers/webpack/shared/create-framework-plugin/plugin.ts
|
|
2827
3090
|
function isInternalUserDefinedOptions(options) {
|
|
2828
3091
|
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
2829
3092
|
}
|
|
@@ -2969,6 +3232,15 @@ var WebpackFrameworkPlugin = class {
|
|
|
2969
3232
|
});
|
|
2970
3233
|
currentWebpackCssSourceFiles.add(file);
|
|
2971
3234
|
};
|
|
3235
|
+
const updateWebpackGeneratedCss = (source) => {
|
|
3236
|
+
const file = path.resolve(source.file);
|
|
3237
|
+
const previous = webpackGeneratedCssSources.get(file);
|
|
3238
|
+
if (!previous) return;
|
|
3239
|
+
webpackGeneratedCssSources.set(file, {
|
|
3240
|
+
...previous,
|
|
3241
|
+
css: source.css
|
|
3242
|
+
});
|
|
3243
|
+
};
|
|
2972
3244
|
const pruneWebpackCssSources = (activeSourceFiles, _options = {}) => {
|
|
2973
3245
|
const tailwindOptions = resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
2974
3246
|
const configuredSourceFiles = /* @__PURE__ */ new Set();
|
|
@@ -3046,6 +3318,7 @@ var WebpackFrameworkPlugin = class {
|
|
|
3046
3318
|
markWebpackCssSourceModule,
|
|
3047
3319
|
registerWebpackCssSourceFile,
|
|
3048
3320
|
registerWebpackGeneratedCss,
|
|
3321
|
+
updateWebpackGeneratedCss,
|
|
3049
3322
|
getRuntimeWatchDependencies() {
|
|
3050
3323
|
return {
|
|
3051
3324
|
files: runtimeWatchDependencyFiles,
|