weapp-tailwindcss 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-state-CBF5YX1m.js → bundle-state-Bvj01pW7.js} +35 -3
- package/dist/{bundle-state-CQmxxx0R.mjs → bundle-state-DY3eq4Gz.mjs} +24 -4
- package/dist/bundlers/shared/generated-css-marker.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -5
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -0
- package/dist/bundlers/shared/generator-css.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +5 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +12 -3
- package/dist/bundlers/vite/generate-bundle.d.ts +22 -6
- package/dist/bundlers/vite/processed-css-assets.d.ts +10 -2
- package/dist/bundlers/vite/source-candidates.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +8 -0
- package/dist/cli.js +1 -0
- package/dist/cli.mjs +1 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CvmsIQFI.js → generator-Bd1LntD3.js} +1 -1
- package/dist/{generator-DDtsUvkH.mjs → generator-DRHWC1t-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +16 -10
- package/dist/gulp.mjs +14 -8
- package/dist/{incremental-runtime-class-set-BffodqHh.js → incremental-runtime-class-set-Bl18sFqt.js} +540 -694
- package/dist/{incremental-runtime-class-set-DArodvWs.mjs → incremental-runtime-class-set-CAEuUesH.mjs} +495 -619
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-BzNYQUOH.mjs → postcss-CJrmfXvi.mjs} +4 -4
- package/dist/{postcss-DE0TOtV9.js → postcss-DfnqZ4Bm.js} +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-BzYPm-EG.js → precheck-Bj5ReSOU.js} +2 -2
- package/dist/{precheck-jZvTVXXG.mjs → precheck-CUr1DYyy.mjs} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-BuTlMabx.mjs → source-candidates-D7b-Jzsx.mjs} +44 -11
- package/dist/{source-candidates-CxoIaS88.js → source-candidates-DQxvGPSw.js} +49 -10
- package/dist/tailwindcss/source-scan.d.ts +3 -1
- package/dist/{tailwindcss-CCZcu0lr.mjs → tailwindcss-D5RogwtV.mjs} +2 -2
- package/dist/{tailwindcss-DZckITp1.js → tailwindcss-jvoYizzX.js} +7 -1
- package/dist/{v3-engine-DGBhUnjn.mjs → v3-engine-BCUGX3gX.mjs} +637 -31
- package/dist/{v3-engine-M6Aqru5T.js → v3-engine-CmIF_gsq.js} +768 -30
- package/dist/{vite-DgRkWVPG.js → vite-D1ZdgbWa.js} +533 -290
- package/dist/{vite-BBcQIJpD.mjs → vite-jBTi5CwO.mjs} +532 -289
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/{runtime-registry-DpcR3IHI.js → watch-dependencies-zwx4EhBn.js} +39 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +1932 -1621
- package/dist/weapp-tw-runtime-classset-loader.js +6 -6
- package/dist/{webpack-D43aMQzO.mjs → webpack-CChDqRrl.mjs} +6 -6
- package/dist/{webpack-D-gb4ZvO.js → webpack-vk2uqSnK.js} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const
|
|
5
|
-
const require_precheck = require("./precheck-BzYPm-EG.js");
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CmIF_gsq.js");
|
|
3
|
+
const require_generator = require("./generator-Bd1LntD3.js");
|
|
4
|
+
const require_precheck = require("./precheck-Bj5ReSOU.js");
|
|
6
5
|
const require_utils = require("./utils-D7Ygohep.js");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-jvoYizzX.js");
|
|
7
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-Bl18sFqt.js");
|
|
8
|
+
const require_source_candidates = require("./source-candidates-DQxvGPSw.js");
|
|
9
|
+
const require_bundle_state = require("./bundle-state-Bvj01pW7.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -19,6 +19,7 @@ let node_path = require("node:path");
|
|
|
19
19
|
node_path = require_chunk.__toESM(node_path);
|
|
20
20
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
21
21
|
let node_fs_promises = require("node:fs/promises");
|
|
22
|
+
let node_buffer = require("node:buffer");
|
|
22
23
|
let magic_string = require("magic-string");
|
|
23
24
|
magic_string = require_chunk.__toESM(magic_string);
|
|
24
25
|
let _weapp_tailwindcss_postcss_html_transform = require("@weapp-tailwindcss/postcss/html-transform");
|
|
@@ -22352,200 +22353,6 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
22352
22353
|
};
|
|
22353
22354
|
}
|
|
22354
22355
|
//#endregion
|
|
22355
|
-
//#region src/bundlers/vite/processed-css-assets.ts
|
|
22356
|
-
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
22357
|
-
function isCssOutputFile(file) {
|
|
22358
|
-
return CSS_OUTPUT_FILE_RE.test(file);
|
|
22359
|
-
}
|
|
22360
|
-
function getAssetFile(bundleFile, asset) {
|
|
22361
|
-
return asset.fileName || bundleFile;
|
|
22362
|
-
}
|
|
22363
|
-
function readAssetSource(asset) {
|
|
22364
|
-
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
22365
|
-
}
|
|
22366
|
-
function appendCss(baseCss, css) {
|
|
22367
|
-
if (baseCss.length === 0) return css;
|
|
22368
|
-
if (css.length === 0) return baseCss;
|
|
22369
|
-
return `${baseCss}\n${css}`;
|
|
22370
|
-
}
|
|
22371
|
-
function collectViteProcessedCssAssetResults(bundle, options) {
|
|
22372
|
-
let collected = 0;
|
|
22373
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
22374
|
-
if (output.type !== "asset") continue;
|
|
22375
|
-
const file = getAssetFile(bundleFile, output);
|
|
22376
|
-
if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
22377
|
-
const rawSource = readAssetSource(output);
|
|
22378
|
-
const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
22379
|
-
if (nextCss !== rawSource) output.source = nextCss;
|
|
22380
|
-
options.markCssAssetProcessed?.(output, file);
|
|
22381
|
-
options.recordCssAssetResult?.(file, nextCss);
|
|
22382
|
-
options.recordViteProcessedCssAssetResult?.(file, nextCss);
|
|
22383
|
-
options.debug?.("collect vite-processed css asset: %s bytes=%d", file, nextCss.length);
|
|
22384
|
-
collected++;
|
|
22385
|
-
}
|
|
22386
|
-
return collected;
|
|
22387
|
-
}
|
|
22388
|
-
function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
22389
|
-
const viteCssResults = [...options.getViteProcessedCssAssetResults?.() ?? []].filter(([, css]) => css.length > 0);
|
|
22390
|
-
if (viteCssResults.length === 0) return 0;
|
|
22391
|
-
let injected = 0;
|
|
22392
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
22393
|
-
if (output.type !== "asset") continue;
|
|
22394
|
-
const file = getAssetFile(bundleFile, output);
|
|
22395
|
-
if (!options.opts.cssMatcher(file) || !options.opts.mainCssChunkMatcher(file, options.opts.appType)) continue;
|
|
22396
|
-
const mainFileKey = require_bundle_state.normalizeOutputPathKey(file);
|
|
22397
|
-
const originalSource = readAssetSource(output);
|
|
22398
|
-
let nextCss = originalSource;
|
|
22399
|
-
for (const [sourceFile, sourceCss] of viteCssResults) {
|
|
22400
|
-
if (require_bundle_state.normalizeOutputPathKey(sourceFile) === mainFileKey || options.opts.mainCssChunkMatcher(sourceFile, options.opts.appType)) continue;
|
|
22401
|
-
const css = require_bundle_state.stripBundlerGeneratedCssMarkers(sourceCss).trim();
|
|
22402
|
-
if (css.length === 0) continue;
|
|
22403
|
-
const mergedLayerCss = require_incremental_runtime_class_set.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
22404
|
-
if (mergedLayerCss.merged) {
|
|
22405
|
-
nextCss = mergedLayerCss.css;
|
|
22406
|
-
continue;
|
|
22407
|
-
}
|
|
22408
|
-
if (nextCss.includes(css)) continue;
|
|
22409
|
-
nextCss = appendCss(nextCss, css);
|
|
22410
|
-
}
|
|
22411
|
-
if (nextCss === originalSource) continue;
|
|
22412
|
-
output.source = nextCss;
|
|
22413
|
-
options.markCssAssetProcessed?.(output, file);
|
|
22414
|
-
options.recordCssAssetResult?.(file, nextCss);
|
|
22415
|
-
options.onUpdate?.(file, originalSource, nextCss);
|
|
22416
|
-
options.debug?.("inject vite-processed css into main css asset: %s bytes=%d", file, nextCss.length);
|
|
22417
|
-
injected++;
|
|
22418
|
-
}
|
|
22419
|
-
return injected;
|
|
22420
|
-
}
|
|
22421
|
-
//#endregion
|
|
22422
|
-
//#region src/bundlers/vite/css-finalizer.ts
|
|
22423
|
-
function isAddWatchFileInvalidRollupPhaseError$1(error) {
|
|
22424
|
-
const candidate = error;
|
|
22425
|
-
return candidate?.code === "INVALID_ROLLUP_PHASE" || candidate?.pluginCode === "INVALID_ROLLUP_PHASE" || candidate?.message?.includes("Cannot call \"addWatchFile\" after the build has finished.") === true;
|
|
22426
|
-
}
|
|
22427
|
-
function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
22428
|
-
if (typeof ctx.addWatchFile !== "function") return;
|
|
22429
|
-
for (const dependency of dependencies ?? []) try {
|
|
22430
|
-
ctx.addWatchFile(dependency);
|
|
22431
|
-
} catch (error) {
|
|
22432
|
-
if (isAddWatchFileInvalidRollupPhaseError$1(error)) {
|
|
22433
|
-
_weapp_tailwindcss_logger.logger.debug("跳过生成模式依赖监听注册,当前 Rollup 阶段不允许 addWatchFile: %s", dependency);
|
|
22434
|
-
continue;
|
|
22435
|
-
}
|
|
22436
|
-
throw error;
|
|
22437
|
-
}
|
|
22438
|
-
}
|
|
22439
|
-
function createCssHandlerOptions(opts, majorVersion, file) {
|
|
22440
|
-
return {
|
|
22441
|
-
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
22442
|
-
postcssOptions: { options: { from: file } },
|
|
22443
|
-
...majorVersion === void 0 ? {} : { majorVersion }
|
|
22444
|
-
};
|
|
22445
|
-
}
|
|
22446
|
-
function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
|
|
22447
|
-
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
22448
|
-
if (generatorOptions.target === "web" && opts.twPatcher.majorVersion !== 3) return false;
|
|
22449
|
-
if (require_incremental_runtime_class_set.hasTailwindGeneratedCssMarkers(rawSource) || require_incremental_runtime_class_set.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
22450
|
-
if (opts.twPatcher.majorVersion === 3) return false;
|
|
22451
|
-
return processed && shouldFinalizeProcessedCssAsset(opts, file);
|
|
22452
|
-
}
|
|
22453
|
-
function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
22454
|
-
return opts.mainCssChunkMatcher(file, opts.appType);
|
|
22455
|
-
}
|
|
22456
|
-
function createViteCssFinalizerOutputPlugin(context) {
|
|
22457
|
-
return {
|
|
22458
|
-
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
22459
|
-
enforce: "post",
|
|
22460
|
-
generateBundle: {
|
|
22461
|
-
order: "post",
|
|
22462
|
-
async handler(_options, bundle) {
|
|
22463
|
-
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource, isViteProcessedCssAsset } = context;
|
|
22464
|
-
if (getResolvedConfig()?.command !== "build") return;
|
|
22465
|
-
collectViteProcessedCssAssetResults(bundle, {
|
|
22466
|
-
isViteProcessedCssAsset,
|
|
22467
|
-
markCssAssetProcessed,
|
|
22468
|
-
recordCssAssetResult,
|
|
22469
|
-
recordViteProcessedCssAssetResult,
|
|
22470
|
-
debug
|
|
22471
|
-
});
|
|
22472
|
-
const isCssOutputAssetEntry = (entry) => {
|
|
22473
|
-
const [, output] = entry;
|
|
22474
|
-
return output.type === "asset" && opts.cssMatcher(output.fileName) && (!isCssAssetProcessed(output, output.fileName) || shouldFinalizeProcessedCssAsset(opts, output.fileName));
|
|
22475
|
-
};
|
|
22476
|
-
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
22477
|
-
if (entries.length === 0) {
|
|
22478
|
-
injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
22479
|
-
opts,
|
|
22480
|
-
getViteProcessedCssAssetResults,
|
|
22481
|
-
markCssAssetProcessed,
|
|
22482
|
-
recordCssAssetResult,
|
|
22483
|
-
debug,
|
|
22484
|
-
onUpdate: opts.onUpdate
|
|
22485
|
-
});
|
|
22486
|
-
return;
|
|
22487
|
-
}
|
|
22488
|
-
await runtimeState.readyPromise;
|
|
22489
|
-
await waitForSourceCandidateSyncs?.();
|
|
22490
|
-
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
22491
|
-
const runtime = getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet();
|
|
22492
|
-
const collectedGeneratorCandidates = new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
22493
|
-
const generatorRuntime = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp" ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
22494
|
-
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
22495
|
-
const file = output.fileName || bundleFile;
|
|
22496
|
-
const rawSource = output.source.toString();
|
|
22497
|
-
if (isViteProcessedCssAsset?.(output, file)) {
|
|
22498
|
-
const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
22499
|
-
output.source = nextCss;
|
|
22500
|
-
markCssAssetProcessed(output, file);
|
|
22501
|
-
recordCssAssetResult?.(file, nextCss);
|
|
22502
|
-
debug("css finalizer skip vite-processed css: %s", file);
|
|
22503
|
-
return;
|
|
22504
|
-
}
|
|
22505
|
-
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.twPatcher.majorVersion, file);
|
|
22506
|
-
const cssUserHandlerOptions = {
|
|
22507
|
-
...cssHandlerOptions,
|
|
22508
|
-
isMainChunk: false
|
|
22509
|
-
};
|
|
22510
|
-
const processed = isCssAssetProcessed(output, file);
|
|
22511
|
-
const generatorRawSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) ?? rawSource : rawSource;
|
|
22512
|
-
const generated = shouldGenerateCssByGenerator(opts, file, generatorRawSource, processed) ? await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
22513
|
-
opts,
|
|
22514
|
-
runtimeState,
|
|
22515
|
-
runtime: generatorRuntime,
|
|
22516
|
-
rawSource: generatorRawSource,
|
|
22517
|
-
file,
|
|
22518
|
-
cssHandlerOptions,
|
|
22519
|
-
cssUserHandlerOptions,
|
|
22520
|
-
getSourceCandidatesForEntries,
|
|
22521
|
-
styleHandler: opts.styleHandler,
|
|
22522
|
-
debug
|
|
22523
|
-
}) : void 0;
|
|
22524
|
-
const nextCss = generated?.css ?? (generatorOptions.target === "web" ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css);
|
|
22525
|
-
if (generated) {
|
|
22526
|
-
registerGeneratorDependencies$1(this, generated.dependencies);
|
|
22527
|
-
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
22528
|
-
recordCssAssetResult?.(file, nextCss);
|
|
22529
|
-
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file, generatorRawSource);
|
|
22530
|
-
}
|
|
22531
|
-
output.source = nextCss;
|
|
22532
|
-
markCssAssetProcessed(output, file);
|
|
22533
|
-
opts.onUpdate(file, rawSource, nextCss);
|
|
22534
|
-
debug("css finalizer handle: %s", file);
|
|
22535
|
-
}));
|
|
22536
|
-
injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
22537
|
-
opts,
|
|
22538
|
-
getViteProcessedCssAssetResults,
|
|
22539
|
-
markCssAssetProcessed,
|
|
22540
|
-
recordCssAssetResult,
|
|
22541
|
-
debug,
|
|
22542
|
-
onUpdate: opts.onUpdate
|
|
22543
|
-
});
|
|
22544
|
-
}
|
|
22545
|
-
}
|
|
22546
|
-
};
|
|
22547
|
-
}
|
|
22548
|
-
//#endregion
|
|
22549
22356
|
//#region src/bundlers/vite/generate-bundle/candidates.ts
|
|
22550
22357
|
const MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
22551
22358
|
const QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
@@ -22625,12 +22432,13 @@ function createCssHandlerOptionsCache(options) {
|
|
|
22625
22432
|
const appType = options.getAppType();
|
|
22626
22433
|
const isMainChunk = options.mainCssChunkMatcher(file, appType);
|
|
22627
22434
|
const outputRoot = options.getOutputRoot?.();
|
|
22435
|
+
const from = outputRoot ? node_path.default.resolve(outputRoot, file) : file;
|
|
22628
22436
|
const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}`;
|
|
22629
22437
|
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
22630
22438
|
if (cached) return cached;
|
|
22631
22439
|
const created = {
|
|
22632
22440
|
isMainChunk,
|
|
22633
|
-
postcssOptions: { options: { from
|
|
22441
|
+
postcssOptions: { options: { from } },
|
|
22634
22442
|
majorVersion,
|
|
22635
22443
|
sourceOptions: { outputRoot }
|
|
22636
22444
|
};
|
|
@@ -22680,7 +22488,7 @@ function createCssTransformShareScope(file, rawSource) {
|
|
|
22680
22488
|
function createCssTransformShareScopeKey(opts, file, rawSource) {
|
|
22681
22489
|
if (opts.mainCssChunkMatcher(file, opts.appType)) return `main:${require_bundle_state.normalizeOutputPathKey(file)}`;
|
|
22682
22490
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
22683
|
-
if (
|
|
22491
|
+
if (require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }) || opts.twPatcher.majorVersion === 3 && (opts.cssEntries?.length ?? 0) > 1 && rawSource.includes("@tailwind")) return `source:${require_bundle_state.normalizeOutputPathKey(file)}`;
|
|
22684
22492
|
return createCssTransformShareScope(file, rawSource);
|
|
22685
22493
|
}
|
|
22686
22494
|
function createCssRuntimeSignature(runtimeSignature, generatorCandidateSignature) {
|
|
@@ -22806,16 +22614,16 @@ function createReplayCssAsset(fileName, source) {
|
|
|
22806
22614
|
originalFileNames: []
|
|
22807
22615
|
};
|
|
22808
22616
|
}
|
|
22809
|
-
function isAddWatchFileInvalidRollupPhaseError(error) {
|
|
22617
|
+
function isAddWatchFileInvalidRollupPhaseError$1(error) {
|
|
22810
22618
|
const candidate = error;
|
|
22811
22619
|
return candidate?.code === "INVALID_ROLLUP_PHASE" || candidate?.pluginCode === "INVALID_ROLLUP_PHASE" || candidate?.message?.includes("Cannot call \"addWatchFile\" after the build has finished.") === true;
|
|
22812
22620
|
}
|
|
22813
|
-
function registerGeneratorDependencies(ctx, dependencies) {
|
|
22621
|
+
function registerGeneratorDependencies$1(ctx, dependencies) {
|
|
22814
22622
|
if (typeof ctx.addWatchFile !== "function") return;
|
|
22815
22623
|
for (const dependency of dependencies ?? []) try {
|
|
22816
22624
|
ctx.addWatchFile(dependency);
|
|
22817
22625
|
} catch (error) {
|
|
22818
|
-
if (isAddWatchFileInvalidRollupPhaseError(error)) {
|
|
22626
|
+
if (isAddWatchFileInvalidRollupPhaseError$1(error)) {
|
|
22819
22627
|
_weapp_tailwindcss_logger.logger.debug("跳过生成模式依赖监听注册,当前 Rollup 阶段不允许 addWatchFile: %s", dependency);
|
|
22820
22628
|
continue;
|
|
22821
22629
|
}
|
|
@@ -22871,6 +22679,111 @@ function hasRuntimeAffectingSourceChanges(changedByType) {
|
|
|
22871
22679
|
return changedByType.html.size > 0 || changedByType.js.size > 0;
|
|
22872
22680
|
}
|
|
22873
22681
|
//#endregion
|
|
22682
|
+
//#region src/bundlers/vite/processed-css-assets.ts
|
|
22683
|
+
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
22684
|
+
function isCssOutputFile(file) {
|
|
22685
|
+
return CSS_OUTPUT_FILE_RE.test(file);
|
|
22686
|
+
}
|
|
22687
|
+
function getAssetFile(bundleFile, asset) {
|
|
22688
|
+
return asset.fileName || bundleFile;
|
|
22689
|
+
}
|
|
22690
|
+
function readAssetSource(asset) {
|
|
22691
|
+
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
22692
|
+
}
|
|
22693
|
+
function appendCss(baseCss, css) {
|
|
22694
|
+
if (baseCss.length === 0) return css;
|
|
22695
|
+
if (css.length === 0) return baseCss;
|
|
22696
|
+
return `${baseCss}\n${css}`;
|
|
22697
|
+
}
|
|
22698
|
+
function stripStyleExtension(file) {
|
|
22699
|
+
return file.replace(/[?#].*$/, "").replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)$/i, "");
|
|
22700
|
+
}
|
|
22701
|
+
function isAppOriginCssFile$1(file) {
|
|
22702
|
+
return stripStyleExtension(file).split("/").pop() === "app-origin";
|
|
22703
|
+
}
|
|
22704
|
+
function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
|
|
22705
|
+
return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
|
|
22706
|
+
}
|
|
22707
|
+
function isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
22708
|
+
if (!markerFile) return false;
|
|
22709
|
+
return require_bundle_state.normalizeOutputPathKey(stripStyleExtension(targetFile)) === require_bundle_state.normalizeOutputPathKey(stripStyleExtension(normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile)));
|
|
22710
|
+
}
|
|
22711
|
+
function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcessedCssOutputFile) {
|
|
22712
|
+
const blocks = require_bundle_state.parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
|
|
22713
|
+
if (blocks.length <= 1) return require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
22714
|
+
const matchedCss = blocks.filter((block) => isMatchingGeneratedCssMarkerFile(file, block.file, resolveViteProcessedCssOutputFile)).map((block) => block.css);
|
|
22715
|
+
return matchedCss.length > 0 ? matchedCss.join("\n") : require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
22716
|
+
}
|
|
22717
|
+
function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, options) {
|
|
22718
|
+
if (options.injectIntoMain === true) return true;
|
|
22719
|
+
const targetFileKey = require_bundle_state.normalizeOutputPathKey(targetFile);
|
|
22720
|
+
const sourceFileKey = require_bundle_state.normalizeOutputPathKey(sourceFile);
|
|
22721
|
+
const sourceBaseName = sourceFileKey.replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i, "").split("/").pop();
|
|
22722
|
+
return sourceFileKey !== targetFileKey && (opts.mainCssChunkMatcher(sourceFile, opts.appType) || sourceBaseName === "app" || sourceBaseName === "main");
|
|
22723
|
+
}
|
|
22724
|
+
function collectViteProcessedCssAssetResults(bundle, options) {
|
|
22725
|
+
let collected = 0;
|
|
22726
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
22727
|
+
if (output.type !== "asset") continue;
|
|
22728
|
+
const file = getAssetFile(bundleFile, output);
|
|
22729
|
+
if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
22730
|
+
const rawSource = readAssetSource(output);
|
|
22731
|
+
const nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
22732
|
+
if (nextCss !== rawSource) output.source = nextCss;
|
|
22733
|
+
options.markCssAssetProcessed?.(output, file);
|
|
22734
|
+
options.recordCssAssetResult?.(file, nextCss);
|
|
22735
|
+
const resolvedOutputFile = options.resolveViteProcessedCssOutputFile?.(file) ?? file;
|
|
22736
|
+
const shouldReplayIntoMainCss = options.opts != null && (require_bundle_state.normalizeOutputPathKey(resolvedOutputFile) !== require_bundle_state.normalizeOutputPathKey(file) && options.opts.mainCssChunkMatcher(resolvedOutputFile, options.opts.appType) || isAppOriginCssFile$1(file));
|
|
22737
|
+
options.recordViteProcessedCssAssetResult?.(file, nextCss, { injectIntoMain: shouldReplayIntoMainCss || void 0 });
|
|
22738
|
+
options.debug?.("collect vite-processed css asset: %s bytes=%d", file, nextCss.length);
|
|
22739
|
+
collected++;
|
|
22740
|
+
}
|
|
22741
|
+
return collected;
|
|
22742
|
+
}
|
|
22743
|
+
function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
22744
|
+
const viteCssResults = [...options.getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => {
|
|
22745
|
+
return typeof record === "string" ? {
|
|
22746
|
+
file,
|
|
22747
|
+
css: record,
|
|
22748
|
+
injectIntoMain: void 0
|
|
22749
|
+
} : {
|
|
22750
|
+
file,
|
|
22751
|
+
css: record.css,
|
|
22752
|
+
injectIntoMain: record.injectIntoMain
|
|
22753
|
+
};
|
|
22754
|
+
}).filter((record) => record.css.length > 0);
|
|
22755
|
+
if (viteCssResults.length === 0) return 0;
|
|
22756
|
+
let injected = 0;
|
|
22757
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
22758
|
+
if (output.type !== "asset") continue;
|
|
22759
|
+
const file = getAssetFile(bundleFile, output);
|
|
22760
|
+
if (!options.opts.cssMatcher(file) || !options.opts.mainCssChunkMatcher(file, options.opts.appType)) continue;
|
|
22761
|
+
const mainFileKey = require_bundle_state.normalizeOutputPathKey(file);
|
|
22762
|
+
const originalSource = readAssetSource(output);
|
|
22763
|
+
let nextCss = originalSource;
|
|
22764
|
+
for (const record of viteCssResults) {
|
|
22765
|
+
if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
|
|
22766
|
+
const css = require_bundle_state.stripBundlerGeneratedCssMarkers(record.css).trim();
|
|
22767
|
+
if (css.length === 0) continue;
|
|
22768
|
+
const mergedLayerCss = require_incremental_runtime_class_set.mergeMarkedUserLayerComponentsCss(nextCss, css);
|
|
22769
|
+
if (mergedLayerCss.merged) {
|
|
22770
|
+
nextCss = mergedLayerCss.css;
|
|
22771
|
+
continue;
|
|
22772
|
+
}
|
|
22773
|
+
if (nextCss.includes(css)) continue;
|
|
22774
|
+
nextCss = appendCss(nextCss, css);
|
|
22775
|
+
}
|
|
22776
|
+
if (nextCss === originalSource) continue;
|
|
22777
|
+
output.source = nextCss;
|
|
22778
|
+
options.markCssAssetProcessed?.(output, file);
|
|
22779
|
+
options.recordCssAssetResult?.(file, nextCss);
|
|
22780
|
+
options.onUpdate?.(file, originalSource, nextCss);
|
|
22781
|
+
options.debug?.("inject vite-processed css into main css asset: %s bytes=%d", file, nextCss.length);
|
|
22782
|
+
injected++;
|
|
22783
|
+
}
|
|
22784
|
+
return injected;
|
|
22785
|
+
}
|
|
22786
|
+
//#endregion
|
|
22874
22787
|
//#region src/bundlers/vite/generate-bundle.ts
|
|
22875
22788
|
function addSiblingCssFile(files, file) {
|
|
22876
22789
|
if (file.endsWith(".wxml")) files.add(file.replace(/\.wxml$/, ".wxss"));
|
|
@@ -22888,11 +22801,18 @@ function resolveReplayCssOutputFile(rootDir, file) {
|
|
|
22888
22801
|
return normalizedFile;
|
|
22889
22802
|
}
|
|
22890
22803
|
const SOURCE_STYLE_OUTPUT_EXT_RE = /\.(?:less|sass|scss|styl|stylus|pcss|postcss)$/i;
|
|
22804
|
+
const CSS_SOURCE_OUTPUT_EXT_RE = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)$/i;
|
|
22805
|
+
const MINI_PROGRAM_STYLE_OUTPUT_EXT_RE = /\.(?:wx|ac|jx|tt|q|ty)ss$/i;
|
|
22891
22806
|
const SOURCE_STYLE_NON_CSS_SYNTAX_RE = /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@(?:use|forward|mixin|include|function)\b)/;
|
|
22892
22807
|
function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget) {
|
|
22893
22808
|
if (isWebGeneratorTarget || opts.cssMatcher(file) || !SOURCE_STYLE_OUTPUT_EXT_RE.test(file) || !require_bundle_state.isCSSRequest(file)) return file;
|
|
22894
22809
|
return file.replace(SOURCE_STYLE_OUTPUT_EXT_RE, ".wxss");
|
|
22895
22810
|
}
|
|
22811
|
+
function resolveViteCssPipelineOutputFile(file, _opts, rootDir, isWebGeneratorTarget = false) {
|
|
22812
|
+
const normalizedFile = resolveReplayCssOutputFile(rootDir, file);
|
|
22813
|
+
if (isWebGeneratorTarget || MINI_PROGRAM_STYLE_OUTPUT_EXT_RE.test(normalizedFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedFile) || !require_bundle_state.isCSSRequest(normalizedFile)) return normalizedFile;
|
|
22814
|
+
return normalizedFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".wxss");
|
|
22815
|
+
}
|
|
22896
22816
|
function canProcessViteSourceStyleAsCss(source, file) {
|
|
22897
22817
|
if (SOURCE_STYLE_NON_CSS_SYNTAX_RE.test(source)) return false;
|
|
22898
22818
|
try {
|
|
@@ -22902,6 +22822,120 @@ function canProcessViteSourceStyleAsCss(source, file) {
|
|
|
22902
22822
|
return false;
|
|
22903
22823
|
}
|
|
22904
22824
|
}
|
|
22825
|
+
function isPackageJsonImportRequest(request) {
|
|
22826
|
+
return request.startsWith("#");
|
|
22827
|
+
}
|
|
22828
|
+
function normalizeMatchedCssSourcePath(file) {
|
|
22829
|
+
if (!file || !node_path.default.isAbsolute(file)) return;
|
|
22830
|
+
return node_path.default.resolve(file.replace(/[?#].*$/, ""));
|
|
22831
|
+
}
|
|
22832
|
+
function stripStyleFileExtension(file) {
|
|
22833
|
+
const normalized = file.replace(/[?#].*$/, "");
|
|
22834
|
+
const ext = node_path.default.extname(normalized);
|
|
22835
|
+
return ext ? normalized.slice(0, -ext.length) : normalized;
|
|
22836
|
+
}
|
|
22837
|
+
function isAppOriginCssFile(file) {
|
|
22838
|
+
return node_path.default.basename(stripStyleFileExtension(file)) === "app-origin";
|
|
22839
|
+
}
|
|
22840
|
+
function normalizeCssSourceForCompare(css) {
|
|
22841
|
+
return css.trim();
|
|
22842
|
+
}
|
|
22843
|
+
async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fallbackSignature, getSourceCandidatesForEntries, options = {}) {
|
|
22844
|
+
if (!getSourceCandidatesForEntries || !rawSource.includes("@source")) return fallbackSignature;
|
|
22845
|
+
const resolved = await require_v3_engine.resolveTailwindV4EntriesFromCssCached(rawSource, node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, ""))));
|
|
22846
|
+
if (resolved?.entries === void 0) return fallbackSignature;
|
|
22847
|
+
const scopedSignature = createCandidateSignature(getSourceCandidatesForEntries(resolved.entries));
|
|
22848
|
+
return options.includeFallbackSignature === true ? `${scopedSignature}:${fallbackSignature}` : scopedSignature;
|
|
22849
|
+
}
|
|
22850
|
+
function isMatchingCssSourceFile(outputFile, cssSourceFile, outputRoot) {
|
|
22851
|
+
return stripStyleFileExtension(node_path.default.resolve(outputRoot, outputFile)) === stripStyleFileExtension(node_path.default.resolve(cssSourceFile));
|
|
22852
|
+
}
|
|
22853
|
+
function collectStyleFileMatchBases(file, roots) {
|
|
22854
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
22855
|
+
const bases = /* @__PURE__ */ new Set();
|
|
22856
|
+
const addBase = (candidate) => {
|
|
22857
|
+
const base = require_bundle_state.slash(stripStyleFileExtension(candidate));
|
|
22858
|
+
if (base.length > 0) bases.add(base);
|
|
22859
|
+
};
|
|
22860
|
+
addBase(normalizedFile);
|
|
22861
|
+
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
|
|
22862
|
+
if (node_path.default.isAbsolute(normalizedFile)) for (const root of resolvedRoots) {
|
|
22863
|
+
const relative = node_path.default.relative(root, normalizedFile);
|
|
22864
|
+
if (relative && !relative.startsWith("..") && !node_path.default.isAbsolute(relative)) addBase(relative);
|
|
22865
|
+
}
|
|
22866
|
+
else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
|
|
22867
|
+
return bases;
|
|
22868
|
+
}
|
|
22869
|
+
function collectParentDirectories(file) {
|
|
22870
|
+
const directories = [];
|
|
22871
|
+
let current = node_path.default.dirname(node_path.default.resolve(file.replace(/[?#].*$/, "")));
|
|
22872
|
+
while (true) {
|
|
22873
|
+
directories.push(current);
|
|
22874
|
+
const parent = node_path.default.dirname(current);
|
|
22875
|
+
if (parent === current) break;
|
|
22876
|
+
current = parent;
|
|
22877
|
+
}
|
|
22878
|
+
return directories;
|
|
22879
|
+
}
|
|
22880
|
+
function hasMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) {
|
|
22881
|
+
const outputBases = collectStyleFileMatchBases(outputFile, [outputRoot]);
|
|
22882
|
+
const sourceBases = collectStyleFileMatchBases(sourceFile, [sourceRoot, ...collectParentDirectories(sourceFile)]);
|
|
22883
|
+
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
|
|
22884
|
+
return false;
|
|
22885
|
+
}
|
|
22886
|
+
function collectConfiguredTailwindV4CssSources(opts) {
|
|
22887
|
+
const patcherCssSources = opts.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? [];
|
|
22888
|
+
return [...opts.tailwindcss?.v4?.cssSources ?? [], ...patcherCssSources ?? []];
|
|
22889
|
+
}
|
|
22890
|
+
function collectConfiguredCssEntries(opts) {
|
|
22891
|
+
const patcherCssEntries = opts.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? [];
|
|
22892
|
+
return [
|
|
22893
|
+
...opts.cssEntries ?? [],
|
|
22894
|
+
...opts.tailwindcss?.v4?.cssEntries ?? [],
|
|
22895
|
+
...patcherCssEntries ?? []
|
|
22896
|
+
].filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
22897
|
+
}
|
|
22898
|
+
function collectCssConfigBaseCandidates(source, file, outputRoot, opts) {
|
|
22899
|
+
const candidates = [];
|
|
22900
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22901
|
+
const addCandidate = (candidate) => {
|
|
22902
|
+
if (!candidate) return;
|
|
22903
|
+
const normalized = node_path.default.resolve(candidate);
|
|
22904
|
+
if (seen.has(normalized)) return;
|
|
22905
|
+
seen.add(normalized);
|
|
22906
|
+
candidates.push(normalized);
|
|
22907
|
+
};
|
|
22908
|
+
addCandidate(node_path.default.dirname(node_path.default.resolve(outputRoot, file.replace(/[?#].*$/, ""))));
|
|
22909
|
+
const normalizedSource = normalizeCssSourceForCompare(source);
|
|
22910
|
+
const patcherProjectRoot = typeof opts.tailwindcssPatcherOptions?.projectRoot === "string" ? opts.tailwindcssPatcherOptions.projectRoot : void 0;
|
|
22911
|
+
const sourceBaseFallback = opts.tailwindcss?.v4?.base ?? patcherProjectRoot ?? opts.tailwindcssBasedir ?? outputRoot;
|
|
22912
|
+
const sourceRoot = opts.tailwindcssBasedir ?? patcherProjectRoot;
|
|
22913
|
+
const configuredCssEntries = collectConfiguredCssEntries(opts);
|
|
22914
|
+
for (const cssEntry of configuredCssEntries) {
|
|
22915
|
+
const resolvedCssEntry = node_path.default.resolve(cssEntry);
|
|
22916
|
+
if (configuredCssEntries.length === 1 || isMatchingCssSourceFile(file, resolvedCssEntry, outputRoot) || hasMatchingStyleFileBase(file, resolvedCssEntry, outputRoot, sourceRoot)) addCandidate(node_path.default.dirname(resolvedCssEntry));
|
|
22917
|
+
}
|
|
22918
|
+
for (const cssSource of collectConfiguredTailwindV4CssSources(opts)) {
|
|
22919
|
+
const cssSourceFile = normalizeMatchedCssSourcePath(cssSource.file);
|
|
22920
|
+
const cssSourceCss = typeof cssSource.css === "string" ? normalizeCssSourceForCompare(cssSource.css) : void 0;
|
|
22921
|
+
if (cssSourceFile && !isMatchingCssSourceFile(file, cssSourceFile, outputRoot) && cssSourceCss !== normalizedSource) continue;
|
|
22922
|
+
addCandidate(cssSourceFile ? node_path.default.dirname(cssSourceFile) : void 0);
|
|
22923
|
+
addCandidate(require_v3_engine.resolveTailwindV4CssSourceBase(cssSource, sourceBaseFallback));
|
|
22924
|
+
}
|
|
22925
|
+
return candidates;
|
|
22926
|
+
}
|
|
22927
|
+
function normalizeRelativeCssConfigDirectives(source, file, outputRoot, opts) {
|
|
22928
|
+
if (!source.includes("@config")) return source;
|
|
22929
|
+
const baseCandidates = collectCssConfigBaseCandidates(source, file, outputRoot, opts);
|
|
22930
|
+
return source.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
|
|
22931
|
+
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
|
|
22932
|
+
for (const base of baseCandidates) {
|
|
22933
|
+
const configFile = node_path.default.resolve(base, request);
|
|
22934
|
+
if ((0, node_fs.existsSync)(configFile)) return `@config ${quote}${require_bundle_state.slash(configFile)}${quote};`;
|
|
22935
|
+
}
|
|
22936
|
+
return full;
|
|
22937
|
+
});
|
|
22938
|
+
}
|
|
22905
22939
|
function createGenerateBundleHook(context) {
|
|
22906
22940
|
const state = require_bundle_state.createBundleBuildState();
|
|
22907
22941
|
const lastCssResultByFile = /* @__PURE__ */ new Map();
|
|
@@ -22914,20 +22948,25 @@ function createGenerateBundleHook(context) {
|
|
|
22914
22948
|
});
|
|
22915
22949
|
return async function generateBundle(_opt, bundle) {
|
|
22916
22950
|
const addWatchFile = (id) => this.addWatchFile?.(id);
|
|
22917
|
-
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs,
|
|
22951
|
+
const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, recordGeneratorCandidates, hmrTimingRecorder } = context;
|
|
22918
22952
|
const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
|
|
22919
22953
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
22920
22954
|
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
22921
22955
|
const shouldGenerateWebCssByGenerator = isWebGeneratorTarget && runtimeState.twPatcher.majorVersion === 3;
|
|
22922
22956
|
const { getCssHandlerOptions, getCssUserHandlerOptions } = cssHandlerOptions;
|
|
22957
|
+
const resolvedConfig = getResolvedConfig();
|
|
22958
|
+
const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
22959
|
+
const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
22923
22960
|
await runtimeState.readyPromise;
|
|
22924
22961
|
debug("start");
|
|
22925
22962
|
onStart();
|
|
22926
22963
|
collectViteProcessedCssAssetResults(bundle, {
|
|
22964
|
+
opts,
|
|
22927
22965
|
isViteProcessedCssAsset,
|
|
22928
22966
|
markCssAssetProcessed,
|
|
22929
22967
|
recordCssAssetResult,
|
|
22930
22968
|
recordViteProcessedCssAssetResult,
|
|
22969
|
+
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget),
|
|
22931
22970
|
debug
|
|
22932
22971
|
});
|
|
22933
22972
|
const hmrTimingStartedAt = performance.now();
|
|
@@ -22949,16 +22988,14 @@ function createGenerateBundleHook(context) {
|
|
|
22949
22988
|
const disableJsPrecheck = node_process.default.env["WEAPP_TW_VITE_DISABLE_JS_PRECHECK"] === "1";
|
|
22950
22989
|
const debugCssDiff = node_process.default.env["WEAPP_TW_VITE_DEBUG_CSS_DIFF"] === "1";
|
|
22951
22990
|
const disableV3OxideSourceRuntime = node_process.default.env["WEAPP_TW_VITE_DISABLE_V3_OXIDE_RUNTIME"] === "1";
|
|
22952
|
-
const resolvedConfig = getResolvedConfig();
|
|
22953
22991
|
const bundleFiles = Object.keys(bundle);
|
|
22954
22992
|
const buildCommand = resolvedConfig?.command === "build";
|
|
22955
22993
|
const hasPreviousBundleState = state.iteration > 0 || state.sourceHashByFile.size > 0;
|
|
22956
|
-
const
|
|
22957
|
-
const
|
|
22958
|
-
const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
22994
|
+
const hasOmittedKnownFiles = hasOmittedKnownBundleFiles(bundleFiles, state.sourceHashByFile.keys());
|
|
22995
|
+
const useIncrementalMode = !buildCommand || hasPreviousBundleState || hasOmittedKnownFiles;
|
|
22959
22996
|
currentOutDir = outDir;
|
|
22960
22997
|
const snapshotStart = performance.now();
|
|
22961
|
-
const snapshot = require_bundle_state.buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization || !useIncrementalMode);
|
|
22998
|
+
const snapshot = require_bundle_state.buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization || !useIncrementalMode, { hasOmittedKnownFiles });
|
|
22962
22999
|
recordTimingDetail("snapshot", snapshotStart);
|
|
22963
23000
|
const useBundleRuntimeClassSet = !isWebGeneratorTarget && (useIncrementalMode || runtimeState.twPatcher.majorVersion === 4);
|
|
22964
23001
|
const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
@@ -22988,10 +23025,11 @@ function createGenerateBundleHook(context) {
|
|
|
22988
23025
|
if (useV3OxideSourceRuntime) debug("[tailwindcss:v3] use oxide source candidates as runtime input, candidates=%d", sourceCandidates.size);
|
|
22989
23026
|
const shouldFilterTailwindV4MiniProgramCandidates = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp";
|
|
22990
23027
|
const collectedGeneratorCandidates = new Set([...runtime, ...sourceCandidates]);
|
|
22991
|
-
|
|
23028
|
+
const filteredGeneratorCandidates = shouldFilterTailwindV4MiniProgramCandidates ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
22992
23029
|
let transformRuntime = transformBaseRuntime ?? runtime;
|
|
22993
|
-
|
|
22994
|
-
|
|
23030
|
+
let generatorRuntime = collectLegacyContainerCompatCandidates(sourceCandidates, runtimeState.twPatcher.majorVersion === 3 && hasRuntimeAffectingChanges && transformBaseRuntime ? new Set([...filteredGeneratorCandidates, ...transformBaseRuntime]) : filteredGeneratorCandidates);
|
|
23031
|
+
const cssEntries = snapshot.entries.filter((entry) => entry.type === "css" && entry.output.type === "asset");
|
|
23032
|
+
if (runtimeState.twPatcher.majorVersion === 3 && useV3OxideSourceRuntime && generatorRuntime.size > 0 && (state.iteration === 0 || !hasRuntimeAffectingChanges) && cssEntries.length <= 1) {
|
|
22995
23033
|
const mainCssEntry = cssEntries.find((entry) => getCssHandlerOptions(entry.file).isMainChunk) ?? cssEntries[0];
|
|
22996
23034
|
if (mainCssEntry) {
|
|
22997
23035
|
const validatedRuntime = await require_incremental_runtime_class_set.validateCandidatesByGenerator({
|
|
@@ -23074,7 +23112,7 @@ function createGenerateBundleHook(context) {
|
|
|
23074
23112
|
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
23075
23113
|
const allowedRetryCandidates = fullRuntimeSet.size === 0 ? unresolvedDynamicCandidates : unresolvedDynamicCandidates.filter((candidate) => dynamicRetryCandidates.has(candidate) || fullRuntimeSet.has(candidate));
|
|
23076
23114
|
retryRuntimeSet = new Set([...fullRuntimeSet, ...allowedRetryCandidates]);
|
|
23077
|
-
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet
|
|
23115
|
+
unresolvedDynamicCandidates = unresolvedDynamicCandidates.filter((candidate) => retryRuntimeSet?.has(candidate) === true);
|
|
23078
23116
|
}
|
|
23079
23117
|
if (retryRuntimeSet && unresolvedDynamicCandidates.length > 0) {
|
|
23080
23118
|
_weapp_tailwindcss_logger.logger.warn("检测到已提取 WXML 动态类名未完成转译,已回退到完整 runtimeSet 重试: %s -> %O", file, unresolvedDynamicCandidates);
|
|
@@ -23093,7 +23131,7 @@ function createGenerateBundleHook(context) {
|
|
|
23093
23131
|
}
|
|
23094
23132
|
if (type === "css" && originalSource.type === "asset") {
|
|
23095
23133
|
metrics.css.total++;
|
|
23096
|
-
const rawSource = originalEntrySource;
|
|
23134
|
+
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource, file, outDir, opts);
|
|
23097
23135
|
const outputFile = resolveViteCssOutputFile(file, opts, isWebGeneratorTarget);
|
|
23098
23136
|
if (outputFile !== file && !canProcessViteSourceStyleAsCss(rawSource, file)) {
|
|
23099
23137
|
delete bundle[file];
|
|
@@ -23108,12 +23146,45 @@ function createGenerateBundleHook(context) {
|
|
|
23108
23146
|
fileName: outputFile,
|
|
23109
23147
|
source
|
|
23110
23148
|
});
|
|
23111
|
-
else bundle[outputFile] =
|
|
23149
|
+
else bundle[outputFile] = createReplayCssAsset(outputFile, source);
|
|
23112
23150
|
originalSource.fileName = outputFile;
|
|
23113
23151
|
}
|
|
23114
23152
|
originalSource.source = source;
|
|
23115
23153
|
};
|
|
23116
|
-
if (
|
|
23154
|
+
if (isWebGeneratorTarget && !shouldGenerateWebCssByGenerator) {
|
|
23155
|
+
applyCssResult(rawSource);
|
|
23156
|
+
markCssAssetProcessed?.(originalSource, outputFile);
|
|
23157
|
+
onUpdate(outputFile, rawSource, rawSource);
|
|
23158
|
+
debug("css skip web target: %s", outputFile);
|
|
23159
|
+
continue;
|
|
23160
|
+
}
|
|
23161
|
+
const hasViteProcessedCssRecord = getViteProcessedCssAssetResult?.(file) != null;
|
|
23162
|
+
const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
|
|
23163
|
+
const cssAssetProcessed = isCssAssetProcessed?.(originalSource, file) === true;
|
|
23164
|
+
const alreadyProcessedCssAsset = viteProcessedCssAsset || cssAssetProcessed;
|
|
23165
|
+
const rememberedCssSource = viteProcessedCssAsset && getRememberedCssSources != null ? [...getRememberedCssSources()].map(([, remembered]) => remembered).find((remembered) => {
|
|
23166
|
+
const originalFiles = [
|
|
23167
|
+
file,
|
|
23168
|
+
originalSource.originalFileName,
|
|
23169
|
+
...originalSource.originalFileNames ?? []
|
|
23170
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
23171
|
+
return require_bundle_state.normalizeOutputPathKey(remembered.outputFile) === require_bundle_state.normalizeOutputPathKey(outputFile) || originalFiles.some((originalFile) => require_bundle_state.normalizeOutputPathKey(remembered.sourceFile) === require_bundle_state.normalizeOutputPathKey(originalFile));
|
|
23172
|
+
}) : void 0;
|
|
23173
|
+
const generatorRawSource = viteProcessedCssAsset ? rememberedCssSource?.rawSource ?? rawSource : rawSource;
|
|
23174
|
+
const generatorSourceFile = viteProcessedCssAsset ? rememberedCssSource?.sourceFile ?? file : file;
|
|
23175
|
+
const outputCssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
23176
|
+
const cssHandlerOptions = viteProcessedCssAsset ? {
|
|
23177
|
+
...getCssHandlerOptions(generatorSourceFile),
|
|
23178
|
+
isMainChunk: outputCssHandlerOptions.isMainChunk || isAppOriginCssFile(file)
|
|
23179
|
+
} : getCssHandlerOptions(file);
|
|
23180
|
+
const generatorCssUserHandlerOptions = getCssUserHandlerOptions(generatorSourceFile);
|
|
23181
|
+
const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? require_bundle_state.createRuntimeAffectingSourceSignature(generatorRawSource, "css");
|
|
23182
|
+
const cssRuntimeAffectingHash = snapshot.runtimeAffectingHashByFile.get(file) ?? cache.computeHash(cssRuntimeAffectingSignature);
|
|
23183
|
+
const cssShareScope = createCssTransformShareScopeKey(opts, generatorSourceFile, generatorRawSource);
|
|
23184
|
+
const shouldRegenerateAppOriginCss = viteProcessedCssAsset && isAppOriginCssFile(file);
|
|
23185
|
+
const shouldTrackGeneratorRuntime = shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || shouldRegenerateAppOriginCss);
|
|
23186
|
+
const canRegenerateProcessedMainCss = cssHandlerOptions.isMainChunk && (getViteProcessedCssAssetResult?.(file)?.injectIntoMain === true || shouldRegenerateAppOriginCss);
|
|
23187
|
+
if (alreadyProcessedCssAsset && (!shouldTrackGeneratorRuntime || !canRegenerateProcessedMainCss)) {
|
|
23117
23188
|
const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
23118
23189
|
applyCssResult(nextCss);
|
|
23119
23190
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
@@ -23122,18 +23193,8 @@ function createGenerateBundleHook(context) {
|
|
|
23122
23193
|
debug("css skip vite-processed asset: %s", outputFile);
|
|
23123
23194
|
continue;
|
|
23124
23195
|
}
|
|
23125
|
-
|
|
23126
|
-
|
|
23127
|
-
markCssAssetProcessed?.(originalSource, outputFile);
|
|
23128
|
-
onUpdate(outputFile, rawSource, rawSource);
|
|
23129
|
-
debug("css skip web target: %s", outputFile);
|
|
23130
|
-
continue;
|
|
23131
|
-
}
|
|
23132
|
-
const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? rawSource;
|
|
23133
|
-
const cssShareScope = createCssTransformShareScopeKey(opts, file, rawSource);
|
|
23134
|
-
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
23135
|
-
const shouldTrackGeneratorRuntime = shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file));
|
|
23136
|
-
const scopedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? generatorCandidateSignature : "generator:stable";
|
|
23196
|
+
const trackedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? generatorCandidateSignature : "generator:stable";
|
|
23197
|
+
const scopedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? await createScopedGeneratorCandidateSignature(generatorRawSource, generatorSourceFile, trackedGeneratorCandidateSignature, getSourceCandidatesForEntries, { includeFallbackSignature: cssHandlerOptions.isMainChunk }) : trackedGeneratorCandidateSignature;
|
|
23137
23198
|
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
|
|
23138
23199
|
const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingSignature}`;
|
|
23139
23200
|
if (!shouldTrackGeneratorRuntime) {
|
|
@@ -23150,12 +23211,16 @@ function createGenerateBundleHook(context) {
|
|
|
23150
23211
|
cache,
|
|
23151
23212
|
cacheKey: file,
|
|
23152
23213
|
hashKey: `${file}:css:${cssRuntimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}`,
|
|
23153
|
-
hash: `${getSnapshotHash(snapshot.runtimeAffectingHashByFile, file,
|
|
23214
|
+
hash: `${getSnapshotHash(snapshot.runtimeAffectingHashByFile, file, cssRuntimeAffectingHash)}:${scopedGeneratorCandidateSignature}`,
|
|
23154
23215
|
applyResult(source) {
|
|
23155
23216
|
applyCssResult(source);
|
|
23156
23217
|
lastCssResultByFile.set(outputFile, source);
|
|
23157
23218
|
markCssAssetProcessed?.(originalSource, outputFile);
|
|
23158
|
-
|
|
23219
|
+
rememberCssSource?.({
|
|
23220
|
+
outputFile,
|
|
23221
|
+
rawSource: generatorRawSource,
|
|
23222
|
+
sourceFile: generatorSourceFile
|
|
23223
|
+
}, cssRuntimeSignature);
|
|
23159
23224
|
},
|
|
23160
23225
|
onCacheHit() {
|
|
23161
23226
|
metrics.css.cacheHits++;
|
|
@@ -23175,25 +23240,26 @@ function createGenerateBundleHook(context) {
|
|
|
23175
23240
|
const runTransform = async () => {
|
|
23176
23241
|
const start = performance.now();
|
|
23177
23242
|
await runtimeState.readyPromise;
|
|
23178
|
-
const previousCss = useIncrementalMode && !snapshot.changedByType.css.has(file) ? lastCssResultByFile.get(file) : void 0;
|
|
23243
|
+
const previousCss = useIncrementalMode && !hasRuntimeAffectingChanges && !snapshot.changedByType.css.has(file) ? lastCssResultByFile.get(outputFile) ?? lastCssResultByFile.get(file) : void 0;
|
|
23179
23244
|
const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
23180
23245
|
opts,
|
|
23181
23246
|
runtimeState,
|
|
23182
23247
|
runtime: generatorRuntime,
|
|
23183
|
-
rawSource,
|
|
23184
|
-
file,
|
|
23248
|
+
rawSource: generatorRawSource,
|
|
23249
|
+
file: generatorSourceFile,
|
|
23185
23250
|
cssHandlerOptions,
|
|
23186
|
-
cssUserHandlerOptions:
|
|
23251
|
+
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
23187
23252
|
getSourceCandidatesForEntries,
|
|
23188
23253
|
styleHandler,
|
|
23189
23254
|
debug,
|
|
23190
23255
|
previousCss
|
|
23191
23256
|
});
|
|
23192
23257
|
if (generated) {
|
|
23193
|
-
registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
|
|
23194
|
-
if (debugCssDiff) debug("css diff %s: %s",
|
|
23258
|
+
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
23259
|
+
if (debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorRawSource, generated.css));
|
|
23195
23260
|
debug("css generated result: %s bytes=%d", file, generated.css.length);
|
|
23196
23261
|
recordCssAssetResult?.(outputFile, generated.css);
|
|
23262
|
+
if (viteProcessedCssAsset && cssHandlerOptions.isMainChunk) recordViteProcessedCssAssetResult?.(file, generated.css, { injectIntoMain: true });
|
|
23197
23263
|
metrics.css.elapsed += measureElapsed(start);
|
|
23198
23264
|
metrics.css.transformed++;
|
|
23199
23265
|
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, outputFile);
|
|
@@ -23321,30 +23387,32 @@ function createGenerateBundleHook(context) {
|
|
|
23321
23387
|
});
|
|
23322
23388
|
}
|
|
23323
23389
|
}
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
const
|
|
23390
|
+
if (useIncrementalMode) for (const [key, remembered] of getRememberedCssSources?.() ?? []) {
|
|
23391
|
+
const { outputFile: rememberedOutputFile, rawSource, sourceFile } = remembered;
|
|
23392
|
+
const outputFile = resolveViteCssPipelineOutputFile(rememberedOutputFile, opts, rootDir, isWebGeneratorTarget);
|
|
23393
|
+
const cssHandlerOptions = getCssHandlerOptions(sourceFile);
|
|
23394
|
+
const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, await createScopedGeneratorCandidateSignature(rawSource, sourceFile, generatorCandidateSignature, getSourceCandidatesForEntries, { includeFallbackSignature: cssHandlerOptions.isMainChunk }));
|
|
23395
|
+
if (bundleFiles.includes(outputFile) || bundleFiles.includes(sourceFile) || getRememberedCssSignature?.(key) === cssRuntimeSignature) continue;
|
|
23328
23396
|
tasks.push(timeTask("css.replay", async () => {
|
|
23329
23397
|
const start = performance.now();
|
|
23330
|
-
const cssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
23331
23398
|
const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
23332
23399
|
opts,
|
|
23333
23400
|
runtimeState,
|
|
23334
23401
|
runtime: generatorRuntime,
|
|
23335
23402
|
rawSource,
|
|
23336
|
-
file:
|
|
23403
|
+
file: sourceFile,
|
|
23337
23404
|
cssHandlerOptions,
|
|
23338
|
-
cssUserHandlerOptions: getCssUserHandlerOptions(
|
|
23405
|
+
cssUserHandlerOptions: getCssUserHandlerOptions(sourceFile),
|
|
23339
23406
|
getSourceCandidatesForEntries,
|
|
23340
23407
|
styleHandler,
|
|
23341
23408
|
debug
|
|
23342
23409
|
});
|
|
23343
23410
|
const css = generated?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
|
|
23344
|
-
|
|
23411
|
+
setRememberedCssSignature?.(key, cssRuntimeSignature);
|
|
23345
23412
|
if (generated) {
|
|
23346
|
-
registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
|
|
23413
|
+
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
23347
23414
|
recordCssAssetResult?.(outputFile, generated.css);
|
|
23415
|
+
recordViteProcessedCssAssetResult?.(sourceFile, generated.css, { injectIntoMain: cssHandlerOptions.isMainChunk });
|
|
23348
23416
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
23349
23417
|
}
|
|
23350
23418
|
const replayAsset = createReplayCssAsset(outputFile, css);
|
|
@@ -23388,6 +23456,145 @@ function createGenerateBundleHook(context) {
|
|
|
23388
23456
|
};
|
|
23389
23457
|
}
|
|
23390
23458
|
//#endregion
|
|
23459
|
+
//#region src/bundlers/vite/css-finalizer.ts
|
|
23460
|
+
function isAddWatchFileInvalidRollupPhaseError(error) {
|
|
23461
|
+
const candidate = error;
|
|
23462
|
+
return candidate?.code === "INVALID_ROLLUP_PHASE" || candidate?.pluginCode === "INVALID_ROLLUP_PHASE" || candidate?.message?.includes("Cannot call \"addWatchFile\" after the build has finished.") === true;
|
|
23463
|
+
}
|
|
23464
|
+
function registerGeneratorDependencies(ctx, dependencies) {
|
|
23465
|
+
if (typeof ctx.addWatchFile !== "function") return;
|
|
23466
|
+
for (const dependency of dependencies ?? []) try {
|
|
23467
|
+
ctx.addWatchFile(dependency);
|
|
23468
|
+
} catch (error) {
|
|
23469
|
+
if (isAddWatchFileInvalidRollupPhaseError(error)) {
|
|
23470
|
+
_weapp_tailwindcss_logger.logger.debug("跳过生成模式依赖监听注册,当前 Rollup 阶段不允许 addWatchFile: %s", dependency);
|
|
23471
|
+
continue;
|
|
23472
|
+
}
|
|
23473
|
+
throw error;
|
|
23474
|
+
}
|
|
23475
|
+
}
|
|
23476
|
+
function createCssHandlerOptions(opts, majorVersion, file) {
|
|
23477
|
+
return {
|
|
23478
|
+
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
23479
|
+
postcssOptions: { options: { from: file } },
|
|
23480
|
+
...majorVersion === void 0 ? {} : { majorVersion }
|
|
23481
|
+
};
|
|
23482
|
+
}
|
|
23483
|
+
function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
|
|
23484
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
23485
|
+
if (generatorOptions.target === "web" && opts.twPatcher.majorVersion !== 3) return false;
|
|
23486
|
+
if (require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
23487
|
+
if (opts.twPatcher.majorVersion === 3) return false;
|
|
23488
|
+
return processed && shouldFinalizeProcessedCssAsset(opts, file);
|
|
23489
|
+
}
|
|
23490
|
+
function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
23491
|
+
return opts.mainCssChunkMatcher(file, opts.appType);
|
|
23492
|
+
}
|
|
23493
|
+
function createViteCssFinalizerOutputPlugin(context) {
|
|
23494
|
+
return {
|
|
23495
|
+
name: "weapp-tailwindcss:adaptor:css-finalizer",
|
|
23496
|
+
enforce: "post",
|
|
23497
|
+
generateBundle: {
|
|
23498
|
+
order: "post",
|
|
23499
|
+
async handler(_options, bundle) {
|
|
23500
|
+
const { opts, runtimeState, ensureRuntimeClassSet, isCssAssetProcessed, markCssAssetProcessed, debug, getResolvedConfig, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getRecordedGeneratorCandidates, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberMainCssSource, getRememberedMainCssSource, isViteProcessedCssAsset } = context;
|
|
23501
|
+
const resolvedConfig = getResolvedConfig();
|
|
23502
|
+
if (resolvedConfig?.command !== "build") return;
|
|
23503
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
23504
|
+
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
23505
|
+
const rootDir = resolvedConfig.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
23506
|
+
collectViteProcessedCssAssetResults(bundle, {
|
|
23507
|
+
opts,
|
|
23508
|
+
isViteProcessedCssAsset,
|
|
23509
|
+
markCssAssetProcessed,
|
|
23510
|
+
recordCssAssetResult,
|
|
23511
|
+
recordViteProcessedCssAssetResult,
|
|
23512
|
+
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget),
|
|
23513
|
+
debug
|
|
23514
|
+
});
|
|
23515
|
+
const isCssOutputAssetEntry = (entry) => {
|
|
23516
|
+
const [, output] = entry;
|
|
23517
|
+
return output.type === "asset" && opts.cssMatcher(output.fileName) && !isCssAssetProcessed(output, output.fileName);
|
|
23518
|
+
};
|
|
23519
|
+
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
23520
|
+
if (entries.length === 0) {
|
|
23521
|
+
injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
23522
|
+
opts,
|
|
23523
|
+
getViteProcessedCssAssetResults,
|
|
23524
|
+
markCssAssetProcessed,
|
|
23525
|
+
recordCssAssetResult,
|
|
23526
|
+
debug,
|
|
23527
|
+
onUpdate: opts.onUpdate
|
|
23528
|
+
});
|
|
23529
|
+
return;
|
|
23530
|
+
}
|
|
23531
|
+
await runtimeState.readyPromise;
|
|
23532
|
+
await waitForSourceCandidateSyncs?.();
|
|
23533
|
+
const runtime = getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet();
|
|
23534
|
+
const collectedGeneratorCandidates = new Set([...runtime, ...getSourceCandidates?.() ?? []]);
|
|
23535
|
+
const generatorRuntime = runtimeState.twPatcher.majorVersion === 4 && generatorOptions.target === "weapp" ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(collectedGeneratorCandidates) : collectedGeneratorCandidates;
|
|
23536
|
+
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
23537
|
+
const file = output.fileName || bundleFile;
|
|
23538
|
+
const rawSource = output.source.toString();
|
|
23539
|
+
if (isViteProcessedCssAsset?.(output, file)) {
|
|
23540
|
+
const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
23541
|
+
output.source = nextCss;
|
|
23542
|
+
markCssAssetProcessed(output, file);
|
|
23543
|
+
recordCssAssetResult?.(file, nextCss);
|
|
23544
|
+
debug("css finalizer skip vite-processed css: %s", file);
|
|
23545
|
+
return;
|
|
23546
|
+
}
|
|
23547
|
+
const cssHandlerOptions = createCssHandlerOptions(opts, runtimeState.twPatcher.majorVersion, file);
|
|
23548
|
+
const cssUserHandlerOptions = {
|
|
23549
|
+
...cssHandlerOptions,
|
|
23550
|
+
isMainChunk: false
|
|
23551
|
+
};
|
|
23552
|
+
const processed = isCssAssetProcessed(output, file);
|
|
23553
|
+
const rememberedMainCssSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) : void 0;
|
|
23554
|
+
const generatorRawSource = rememberedMainCssSource?.rawSource ?? rawSource;
|
|
23555
|
+
const generatorSourceFile = rememberedMainCssSource?.sourceFile ?? file;
|
|
23556
|
+
const generatorCssHandlerOptions = rememberedMainCssSource ? createCssHandlerOptions(opts, runtimeState.twPatcher.majorVersion, generatorSourceFile) : cssHandlerOptions;
|
|
23557
|
+
const generatorCssUserHandlerOptions = rememberedMainCssSource ? {
|
|
23558
|
+
...generatorCssHandlerOptions,
|
|
23559
|
+
isMainChunk: false
|
|
23560
|
+
} : cssUserHandlerOptions;
|
|
23561
|
+
const generated = shouldGenerateCssByGenerator(opts, file, generatorRawSource, processed) ? await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
23562
|
+
opts,
|
|
23563
|
+
runtimeState,
|
|
23564
|
+
runtime: generatorRuntime,
|
|
23565
|
+
rawSource: generatorRawSource,
|
|
23566
|
+
file: generatorSourceFile,
|
|
23567
|
+
cssHandlerOptions: generatorCssHandlerOptions,
|
|
23568
|
+
cssUserHandlerOptions: generatorCssUserHandlerOptions,
|
|
23569
|
+
getSourceCandidatesForEntries,
|
|
23570
|
+
styleHandler: opts.styleHandler,
|
|
23571
|
+
debug
|
|
23572
|
+
}) : void 0;
|
|
23573
|
+
const nextCss = generated?.css ?? (generatorOptions.target === "web" ? rawSource : (await opts.styleHandler(rawSource, cssHandlerOptions)).css);
|
|
23574
|
+
if (generated) {
|
|
23575
|
+
registerGeneratorDependencies(this, generated.dependencies);
|
|
23576
|
+
debug("css finalizer generated result: %s bytes=%d", file, nextCss.length);
|
|
23577
|
+
recordCssAssetResult?.(file, nextCss);
|
|
23578
|
+
if (cssHandlerOptions.isMainChunk) rememberMainCssSource?.(file, generatorRawSource);
|
|
23579
|
+
}
|
|
23580
|
+
output.source = nextCss;
|
|
23581
|
+
markCssAssetProcessed(output, file);
|
|
23582
|
+
opts.onUpdate(file, rawSource, nextCss);
|
|
23583
|
+
debug("css finalizer handle: %s", file);
|
|
23584
|
+
}));
|
|
23585
|
+
injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
23586
|
+
opts,
|
|
23587
|
+
getViteProcessedCssAssetResults,
|
|
23588
|
+
markCssAssetProcessed,
|
|
23589
|
+
recordCssAssetResult,
|
|
23590
|
+
debug,
|
|
23591
|
+
onUpdate: opts.onUpdate
|
|
23592
|
+
});
|
|
23593
|
+
}
|
|
23594
|
+
}
|
|
23595
|
+
};
|
|
23596
|
+
}
|
|
23597
|
+
//#endregion
|
|
23391
23598
|
//#region src/bundlers/vite/official-tailwind-plugins.ts
|
|
23392
23599
|
const tailwindPostcssPluginNames = new Set(["tailwindcss", "@tailwindcss/postcss"]);
|
|
23393
23600
|
function getPostcssPluginName(plugin) {
|
|
@@ -23595,10 +23802,12 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
23595
23802
|
},
|
|
23596
23803
|
async transform(code, id) {
|
|
23597
23804
|
if (!require_bundle_state.isCSSRequest(id)) return null;
|
|
23598
|
-
|
|
23599
|
-
|
|
23805
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
23806
|
+
const normalizedCode = require_v3_engine.hasTailwindRootDirectives(code) ? require_v3_engine.normalizeTailwindConfigDirectives(code, node_path.default.dirname(file)) : code;
|
|
23807
|
+
if (require_v3_engine.hasTailwindRootDirectives(normalizedCode)) {
|
|
23808
|
+
await options.onTailwindRootCss?.(id, normalizedCode);
|
|
23600
23809
|
if (options.shouldOwnTailwindGeneration) {
|
|
23601
|
-
const generatedCss = await options.generateTailwindCss?.(id,
|
|
23810
|
+
const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, this);
|
|
23602
23811
|
if (generatedCss !== void 0) return {
|
|
23603
23812
|
code: generatedCss,
|
|
23604
23813
|
map: null
|
|
@@ -23606,12 +23815,12 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
23606
23815
|
}
|
|
23607
23816
|
}
|
|
23608
23817
|
if (!options.shouldRewrite) return null;
|
|
23609
|
-
const rewritten = rewriteTailwindcssImportsInCode(
|
|
23818
|
+
const rewritten = rewriteTailwindcssImportsInCode(normalizedCode, weappTailwindcssDirPosix, {
|
|
23610
23819
|
join: joinPosixPath,
|
|
23611
23820
|
appType: resolveAppType(),
|
|
23612
23821
|
rootImport
|
|
23613
23822
|
});
|
|
23614
|
-
const nextCode = shouldOwnTailwindGeneration ? stripTailwindConfigDirectives(rewritten ??
|
|
23823
|
+
const nextCode = shouldOwnTailwindGeneration ? stripTailwindConfigDirectives(rewritten ?? normalizedCode) : rewritten;
|
|
23615
23824
|
if (!nextCode || nextCode === code) return null;
|
|
23616
23825
|
return {
|
|
23617
23826
|
code: nextCode,
|
|
@@ -23802,7 +24011,7 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
23802
24011
|
enforce: "pre",
|
|
23803
24012
|
async transform(code, id) {
|
|
23804
24013
|
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
23805
|
-
if (!
|
|
24014
|
+
if (!require_v3_engine.hasTailwindRootDirectives(code)) return;
|
|
23806
24015
|
await options.onTailwindRootCss?.(id, code);
|
|
23807
24016
|
const generatedCss = await options.generateCss(id, code, this);
|
|
23808
24017
|
if (generatedCss === void 0 || generatedCss === code) return;
|
|
@@ -23896,6 +24105,14 @@ function WeappTailwindcss(options = {}) {
|
|
|
23896
24105
|
...options,
|
|
23897
24106
|
__internalDeferMissingCssEntriesWarning: true
|
|
23898
24107
|
});
|
|
24108
|
+
const normalizedCssEntries = require_tailwindcss.normalizeCssEntries(options.cssEntries, opts.tailwindcssBasedir ?? node_process.default.cwd());
|
|
24109
|
+
if (normalizedCssEntries) opts.cssEntries ?? (opts.cssEntries = normalizedCssEntries);
|
|
24110
|
+
if (opts.cssEntries?.length) {
|
|
24111
|
+
var _opts$tailwindcss, _opts$tailwindcss$v;
|
|
24112
|
+
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
24113
|
+
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
24114
|
+
(_opts$tailwindcss$v = opts.tailwindcss.v4).cssEntries ?? (_opts$tailwindcss$v.cssEntries = opts.cssEntries);
|
|
24115
|
+
}
|
|
23899
24116
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, twPatcher: initialTwPatcher, refreshTailwindcssPatcher, uniAppX, disabledDefaultTemplateHandler } = opts;
|
|
23900
24117
|
const uniAppXEnabled = require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
23901
24118
|
const disabledOptions = require_bundle_state.resolvePluginDisabledState(disabled);
|
|
@@ -23921,16 +24138,16 @@ function WeappTailwindcss(options = {}) {
|
|
|
23921
24138
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
23922
24139
|
if (!node_path.default.isAbsolute(file)) return;
|
|
23923
24140
|
const sourceFile = node_path.default.normalize(file);
|
|
23924
|
-
const
|
|
24141
|
+
const sourceBase = node_path.default.dirname(sourceFile);
|
|
24142
|
+
const sourceCss = require_v3_engine.normalizeTailwindSourceForGenerator(require_v3_engine.normalizeTailwindConfigDirectives(css, sourceBase), { importFallback: true });
|
|
23925
24143
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
|
|
23926
24144
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
23927
24145
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
23928
|
-
const dependencies = await require_v3_engine.resolveViteTailwindV4CssDependencies(sourceCss, node_path.default.dirname(sourceFile));
|
|
23929
24146
|
if (!require_tailwindcss.upsertTailwindV4CssSource(opts, {
|
|
23930
24147
|
file: sourceFile,
|
|
23931
|
-
base:
|
|
24148
|
+
base: sourceBase,
|
|
23932
24149
|
css: sourceCss,
|
|
23933
|
-
dependencies
|
|
24150
|
+
dependencies: await require_v3_engine.resolveViteTailwindV4CssDependencies(sourceCss, sourceBase)
|
|
23934
24151
|
})) return;
|
|
23935
24152
|
invalidateSourceCandidateScan();
|
|
23936
24153
|
debug("detected tailwindcss v4 css source from vite css module: %s", sourceFile);
|
|
@@ -23948,16 +24165,16 @@ function WeappTailwindcss(options = {}) {
|
|
|
23948
24165
|
let changed = false;
|
|
23949
24166
|
for (const cssEntry of cssEntries) {
|
|
23950
24167
|
const sourceFile = node_path.default.resolve(cssEntry);
|
|
23951
|
-
const
|
|
24168
|
+
const sourceBase = node_path.default.dirname(sourceFile);
|
|
24169
|
+
const sourceCss = require_v3_engine.normalizeTailwindSourceForGenerator(require_v3_engine.normalizeTailwindConfigDirectives(await (0, node_fs_promises.readFile)(sourceFile, "utf8"), sourceBase), { importFallback: true });
|
|
23952
24170
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) continue;
|
|
23953
24171
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
23954
24172
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
23955
|
-
const resolved = await require_v3_engine.resolveTailwindV4EntriesFromCssCached(sourceCss, node_path.default.dirname(sourceFile));
|
|
23956
24173
|
changed = require_tailwindcss.upsertTailwindV4CssSource(opts, {
|
|
23957
24174
|
file: sourceFile,
|
|
23958
|
-
base:
|
|
24175
|
+
base: sourceBase,
|
|
23959
24176
|
css: sourceCss,
|
|
23960
|
-
dependencies:
|
|
24177
|
+
dependencies: (await require_v3_engine.resolveTailwindV4EntriesFromCssCached(sourceCss, sourceBase))?.dependencies ?? []
|
|
23961
24178
|
}) || changed;
|
|
23962
24179
|
}
|
|
23963
24180
|
if (!changed) return;
|
|
@@ -23967,7 +24184,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
23967
24184
|
const customAttributesEntities = require_precheck.toCustomAttributesEntities(customAttributes);
|
|
23968
24185
|
let resolvedConfig;
|
|
23969
24186
|
let recordedGeneratorCandidates;
|
|
23970
|
-
const
|
|
24187
|
+
const sourceCandidateExtractor = tailwindcssMajorVersion === 3 ? require_source_candidates.createTailwindV3DefaultExtractor() : void 0;
|
|
24188
|
+
const sourceCandidateCollector = require_source_candidates.createSourceCandidateCollector({
|
|
24189
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
24190
|
+
extractor: sourceCandidateExtractor
|
|
24191
|
+
});
|
|
23971
24192
|
const sourceCandidateScanCache = /* @__PURE__ */ new Map();
|
|
23972
24193
|
let sourceScanEntries;
|
|
23973
24194
|
let sourceScanMatcher;
|
|
@@ -23978,12 +24199,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
23978
24199
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
23979
24200
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
23980
24201
|
const processedCssAssets = /* @__PURE__ */ new WeakSet();
|
|
23981
|
-
const processedCssAssetFiles = /* @__PURE__ */ new Set();
|
|
23982
24202
|
const viteProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
23983
24203
|
const viteGeneratedCssByFile = /* @__PURE__ */ new Map();
|
|
23984
24204
|
const viteProcessedCssAssetResults = /* @__PURE__ */ new Map();
|
|
23985
|
-
const
|
|
23986
|
-
const
|
|
24205
|
+
const rememberedCssSources = /* @__PURE__ */ new Map();
|
|
24206
|
+
const rememberedCssSignatureByFile = /* @__PURE__ */ new Map();
|
|
23987
24207
|
const tailwindRootCssModuleIds = /* @__PURE__ */ new Set();
|
|
23988
24208
|
const { runtimeState, refreshRuntimeState, ensureRuntimeClassSet, ensureBundleRuntimeClassSet } = createViteRuntimeClassSet({
|
|
23989
24209
|
opts,
|
|
@@ -23998,12 +24218,15 @@ function WeappTailwindcss(options = {}) {
|
|
|
23998
24218
|
refreshRuntimeStateForAutoCssSources = refreshRuntimeState;
|
|
23999
24219
|
onLoad();
|
|
24000
24220
|
const getResolvedConfig = () => resolvedConfig;
|
|
24001
|
-
const markCssAssetProcessed = (asset,
|
|
24221
|
+
const markCssAssetProcessed = (asset, _file) => {
|
|
24002
24222
|
processedCssAssets.add(asset);
|
|
24003
|
-
if (file) processedCssAssetFiles.add(require_bundle_state.normalizeOutputPathKey(file));
|
|
24004
24223
|
};
|
|
24005
24224
|
const isCssAssetProcessed = (asset, file) => {
|
|
24006
|
-
|
|
24225
|
+
if (processedCssAssets.has(asset)) return true;
|
|
24226
|
+
if (!file) return false;
|
|
24227
|
+
const record = viteProcessedCssAssetResults.get(require_bundle_state.normalizeOutputPathKey(file));
|
|
24228
|
+
if (!record) return false;
|
|
24229
|
+
return (typeof asset.source === "string" ? asset.source : asset.source instanceof Uint8Array ? node_buffer.Buffer.from(asset.source).toString() : String(asset.source ?? "")) === record.css;
|
|
24007
24230
|
};
|
|
24008
24231
|
const recordGeneratorCandidates = (candidates) => {
|
|
24009
24232
|
recordedGeneratorCandidates = new Set(candidates);
|
|
@@ -24150,23 +24373,28 @@ function WeappTailwindcss(options = {}) {
|
|
|
24150
24373
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
24151
24374
|
return !/\.(?:vue|uvue|nvue|svelte|mpx)$/i.test(file);
|
|
24152
24375
|
};
|
|
24153
|
-
const
|
|
24154
|
-
|
|
24155
|
-
|
|
24376
|
+
const rememberCssSource = (entry, cssRuntimeSignature) => {
|
|
24377
|
+
const key = require_bundle_state.normalizeOutputPathKey(entry.outputFile);
|
|
24378
|
+
rememberedCssSources.set(key, entry);
|
|
24379
|
+
if (cssRuntimeSignature) rememberedCssSignatureByFile.set(key, cssRuntimeSignature);
|
|
24156
24380
|
};
|
|
24157
|
-
const
|
|
24158
|
-
const
|
|
24159
|
-
const
|
|
24160
|
-
const
|
|
24161
|
-
|
|
24381
|
+
const getRememberedCssSources = () => rememberedCssSources;
|
|
24382
|
+
const getRememberedCssSourceEntry = (file) => rememberedCssSources.get(require_bundle_state.normalizeOutputPathKey(file));
|
|
24383
|
+
const getRememberedCssSignature = (file) => rememberedCssSignatureByFile.get(require_bundle_state.normalizeOutputPathKey(file));
|
|
24384
|
+
const setRememberedCssSignature = (file, cssRuntimeSignature) => {
|
|
24385
|
+
rememberedCssSignatureByFile.set(require_bundle_state.normalizeOutputPathKey(file), cssRuntimeSignature);
|
|
24162
24386
|
};
|
|
24163
24387
|
const recordCssAssetResult = (file, css) => {
|
|
24164
24388
|
viteGeneratedCssByFile.set(file, css);
|
|
24165
24389
|
};
|
|
24166
|
-
const recordViteProcessedCssAssetResult = (file, css) => {
|
|
24167
|
-
viteProcessedCssAssetResults.set(require_bundle_state.normalizeOutputPathKey(file),
|
|
24390
|
+
const recordViteProcessedCssAssetResult = (file, css, options = {}) => {
|
|
24391
|
+
viteProcessedCssAssetResults.set(require_bundle_state.normalizeOutputPathKey(file), {
|
|
24392
|
+
css,
|
|
24393
|
+
injectIntoMain: options.injectIntoMain
|
|
24394
|
+
});
|
|
24168
24395
|
};
|
|
24169
24396
|
const getViteProcessedCssAssetResults = () => viteProcessedCssAssetResults.entries();
|
|
24397
|
+
const getViteProcessedCssAssetResult = (file) => viteProcessedCssAssetResults.get(require_bundle_state.normalizeOutputPathKey(file));
|
|
24170
24398
|
const normalizeViteProcessedCssFile = (file) => node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
24171
24399
|
const markViteProcessedCssSource = (file) => {
|
|
24172
24400
|
viteProcessedCssSourceFiles.add(normalizeViteProcessedCssFile(file));
|
|
@@ -24269,27 +24497,34 @@ function WeappTailwindcss(options = {}) {
|
|
|
24269
24497
|
await waitForSourceCandidateSyncs();
|
|
24270
24498
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
24271
24499
|
const runtime = getRecordedGeneratorCandidates() ?? getSourceCandidates() ?? await ensureRuntimeClassSet();
|
|
24500
|
+
const cssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(file);
|
|
24272
24501
|
const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
|
|
24273
24502
|
opts,
|
|
24274
24503
|
runtimeState,
|
|
24275
24504
|
runtime,
|
|
24276
24505
|
rawSource: code,
|
|
24277
24506
|
file,
|
|
24278
|
-
cssHandlerOptions
|
|
24507
|
+
cssHandlerOptions,
|
|
24279
24508
|
cssUserHandlerOptions: transformCssHandlerOptions.getCssUserHandlerOptions(file),
|
|
24280
24509
|
getSourceCandidatesForEntries,
|
|
24281
24510
|
styleHandler,
|
|
24282
24511
|
debug,
|
|
24283
|
-
previousCss: viteGeneratedCssByFile.get(file)
|
|
24512
|
+
previousCss: viteGeneratedCssByFile.get(file),
|
|
24513
|
+
deferEmptyScopedCssSource: true
|
|
24284
24514
|
});
|
|
24285
24515
|
if (!generated) return;
|
|
24516
|
+
const outputFile = resolveViteCssPipelineOutputFile(file, opts, resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd(), generatorOptions.target === "web");
|
|
24286
24517
|
for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
|
|
24287
24518
|
viteGeneratedCssByFile.set(file, generated.css);
|
|
24288
|
-
if (generated.css.includes("weapp-tailwindcss layer components start")) recordViteProcessedCssAssetResult(file, generated.css);
|
|
24519
|
+
if (generated.css.includes("weapp-tailwindcss layer components start")) recordViteProcessedCssAssetResult(file, generated.css, { injectIntoMain: cssHandlerOptions.isMainChunk });
|
|
24289
24520
|
markViteProcessedCssSource(file);
|
|
24290
24521
|
rememberTailwindRootCssModule(id);
|
|
24291
24522
|
recordGeneratorCandidates(runtime);
|
|
24292
|
-
|
|
24523
|
+
rememberCssSource({
|
|
24524
|
+
outputFile,
|
|
24525
|
+
rawSource: code,
|
|
24526
|
+
sourceFile: file
|
|
24527
|
+
});
|
|
24293
24528
|
debug("css generated for vite postcss pipeline: %s bytes=%d", file, generated.css.length);
|
|
24294
24529
|
return `${require_bundle_state.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}\n${generated.css}`;
|
|
24295
24530
|
};
|
|
@@ -24311,17 +24546,19 @@ function WeappTailwindcss(options = {}) {
|
|
|
24311
24546
|
debug,
|
|
24312
24547
|
getResolvedConfig,
|
|
24313
24548
|
markCssAssetProcessed,
|
|
24549
|
+
isCssAssetProcessed,
|
|
24314
24550
|
isViteProcessedCssAsset,
|
|
24315
24551
|
recordCssAssetResult,
|
|
24316
24552
|
recordViteProcessedCssAssetResult,
|
|
24317
24553
|
getViteProcessedCssAssetResults,
|
|
24554
|
+
getViteProcessedCssAssetResult,
|
|
24318
24555
|
getSourceCandidates,
|
|
24319
24556
|
getSourceCandidatesForEntries,
|
|
24320
24557
|
waitForSourceCandidateSyncs,
|
|
24321
|
-
|
|
24322
|
-
|
|
24323
|
-
|
|
24324
|
-
|
|
24558
|
+
rememberCssSource,
|
|
24559
|
+
getRememberedCssSources,
|
|
24560
|
+
getRememberedCssSignature,
|
|
24561
|
+
setRememberedCssSignature,
|
|
24325
24562
|
recordGeneratorCandidates,
|
|
24326
24563
|
hmrTimingRecorder
|
|
24327
24564
|
});
|
|
@@ -24341,8 +24578,12 @@ function WeappTailwindcss(options = {}) {
|
|
|
24341
24578
|
getSourceCandidates,
|
|
24342
24579
|
getSourceCandidatesForEntries,
|
|
24343
24580
|
waitForSourceCandidateSyncs,
|
|
24344
|
-
rememberMainCssSource,
|
|
24345
|
-
|
|
24581
|
+
rememberMainCssSource: (file, rawSource) => rememberCssSource({
|
|
24582
|
+
outputFile: file,
|
|
24583
|
+
rawSource,
|
|
24584
|
+
sourceFile: file
|
|
24585
|
+
}),
|
|
24586
|
+
getRememberedMainCssSource: getRememberedCssSourceEntry
|
|
24346
24587
|
});
|
|
24347
24588
|
const isIosPlatform = require_utils.resolveUniUtsPlatform().isAppIos;
|
|
24348
24589
|
const prepareTailwindGeneration = async () => {
|
|
@@ -24370,6 +24611,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
24370
24611
|
async transform(code, id) {
|
|
24371
24612
|
if (!shouldOwnTailwindGeneration || !require_source_candidates.isSourceCandidateRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
|
|
24372
24613
|
return hmrTimingRecorder.measure("sourceCandidates.transform", async () => {
|
|
24614
|
+
invalidateRecordedGeneratorCandidates();
|
|
24373
24615
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
24374
24616
|
if (sourceScanMatcher && !sourceScanMatcher(file)) {
|
|
24375
24617
|
sourceCandidateCollector.remove(file);
|
|
@@ -24386,6 +24628,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
24386
24628
|
},
|
|
24387
24629
|
async watchChange(id, change) {
|
|
24388
24630
|
await hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
24631
|
+
if (shouldOwnTailwindGeneration && require_source_candidates.isSourceCandidateRequest(id)) invalidateRecordedGeneratorCandidates();
|
|
24389
24632
|
if (isSourceScanDependency(id)) invalidateSourceCandidateScan();
|
|
24390
24633
|
if (change.event === "delete") {
|
|
24391
24634
|
sourceCandidateCollector.remove(id);
|
|
@@ -24399,7 +24642,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
24399
24642
|
return hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
24400
24643
|
const isSourceCandidateHotUpdate = shouldOwnTailwindGeneration && require_source_candidates.isSourceCandidateRequest(ctx.file);
|
|
24401
24644
|
await syncChangedSourceCandidateFile(ctx.file);
|
|
24402
|
-
invalidateRecordedGeneratorCandidates();
|
|
24645
|
+
if (isSourceCandidateHotUpdate) invalidateRecordedGeneratorCandidates();
|
|
24403
24646
|
const cssModules = resolveHotTailwindCssModules(ctx);
|
|
24404
24647
|
if (isSourceCandidateHotUpdate && !require_bundle_state.isSourceStyleRequest(ctx.file) && (!hasSelfAcceptingNonStyleHotModule(ctx.modules) && cssModules.length === 0 || cssModules.length > 0 && isUniViteProject())) {
|
|
24405
24648
|
sendFullReloadForUnresolvedHotUpdate(ctx);
|