weapp-tailwindcss 5.0.12 → 5.0.13
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-DU2ATDhw.js → bundle-state-CKWeTEhv.js} +2 -2
- package/dist/{bundle-state-BxMNKjBV.mjs → bundle-state-zQ2MrDdi.mjs} +1 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +7 -2
- package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +5 -22
- package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/vite/css-memory.d.ts +27 -0
- package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +8 -7
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +58 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +77 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +29 -0
- package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
- package/dist/bundlers/vite/map-cache.d.ts +2 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
- package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
- package/dist/bundlers/vite/source-candidates.d.ts +3 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
- package/dist/bundlers/vite/source-scan.d.ts +1 -1
- package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-DH0ZQRhy.mjs → defaults-Bqx18S1f.mjs} +2 -35
- package/dist/{defaults-Boc26eel.js → defaults-C_J_kBpw.js} +2 -35
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/framework/index.d.ts +59 -0
- package/dist/framework.d.ts +1 -0
- package/dist/framework.js +198 -0
- package/dist/framework.mjs +180 -0
- package/dist/{generator-Cb1Zp3Al.js → generator-CzpArpCL.js} +1 -1
- package/dist/{generator-mvNFUvns.mjs → generator-ITLd7PTl.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-BfZpaYSQ.mjs → gulp-DfOQERcV.mjs} +44 -16
- package/dist/{gulp-CxGZU0-v.js → gulp-XT8Jc7lH.js} +44 -16
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-BMftW7Us.js} +298 -221
- package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-DQIP_8qP.mjs} +297 -220
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -4
- package/dist/index.mjs +6 -5
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/{precheck-30zNPRlI.js → precheck-B0Z8yW7E.js} +98 -27
- package/dist/{precheck-CsFr1q2l.mjs → precheck-CRI90iL1.mjs} +97 -26
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +3 -3
- package/dist/{tailwindcss-CK84uGBp.mjs → tailwindcss-DTq3uYBK.mjs} +2 -2
- package/dist/{tailwindcss-Clpkz1oR.js → tailwindcss-DZEwT3C_.js} +3 -3
- package/dist/{transform-Cju08-aJ.mjs → transform-DfcEjsZF.mjs} +29 -21
- package/dist/{transform-CaVEBOuR.js → transform-YmrmxuF3.js} +29 -21
- package/dist/types/user-defined-options/general.d.ts +3 -1
- package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
- package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
- package/dist/{v3-engine-CQE5JJNZ.js → v3-engine-2rrgylhn.js} +53 -6
- package/dist/{v3-engine-DKBaKWGL.mjs → v3-engine-C6eJ0YzK.mjs} +46 -5
- package/dist/{vite-BBGOjh9e.js → vite-CXHVsHmX.js} +1945 -1280
- package/dist/{vite-CS5DE-HD.mjs → vite-DjI09vVN.mjs} +1944 -1279
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +346 -186
- package/dist/weapp-tw-runtime-classset-loader.js +25 -0
- package/dist/{webpack-SPcri_D8.mjs → webpack-BcPpnT90.mjs} +165 -35
- package/dist/{webpack-DIWrcpRo.js → webpack-CfkUkMXG.js} +167 -37
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +9 -4
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
5
|
-
const require_utils = require("./utils-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
-
const require_bundle_state = require("./bundle-state-
|
|
9
|
-
let node_module = require("node:module");
|
|
10
|
-
node_module = require_chunk.__toESM(node_module);
|
|
2
|
+
const require_v3_engine = require("./v3-engine-2rrgylhn.js");
|
|
3
|
+
const require_generator = require("./generator-CzpArpCL.js");
|
|
4
|
+
const require_precheck = require("./precheck-B0Z8yW7E.js");
|
|
5
|
+
const require_utils = require("./utils-BCa37Wqj.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-DZEwT3C_.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-BMftW7Us.js");
|
|
8
|
+
const require_bundle_state = require("./bundle-state-CKWeTEhv.js");
|
|
11
9
|
let node_fs = require("node:fs");
|
|
12
10
|
node_fs = require_chunk.__toESM(node_fs);
|
|
13
11
|
let node_path = require("node:path");
|
|
14
12
|
node_path = require_chunk.__toESM(node_path);
|
|
15
13
|
let node_process = require("node:process");
|
|
16
14
|
node_process = require_chunk.__toESM(node_process);
|
|
15
|
+
let node_module = require("node:module");
|
|
16
|
+
node_module = require_chunk.__toESM(node_module);
|
|
17
17
|
let micromatch = require("micromatch");
|
|
18
18
|
micromatch = require_chunk.__toESM(micromatch);
|
|
19
19
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
@@ -317,6 +317,48 @@ function pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandl
|
|
|
317
317
|
pruneMapToMaxSize(cssHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
318
318
|
pruneMapToMaxSize(cssUserHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
319
319
|
}
|
|
320
|
+
function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
321
|
+
return cssHandlerOptions.sourceOptions?.sourceCss ?? rawSource;
|
|
322
|
+
}
|
|
323
|
+
function stripStyleExtension(file) {
|
|
324
|
+
const normalized = file.replace(/[?#].*$/, "");
|
|
325
|
+
const ext = node_path.default.extname(normalized);
|
|
326
|
+
return ext ? normalized.slice(0, -ext.length) : normalized;
|
|
327
|
+
}
|
|
328
|
+
function normalizeMatchPath(file) {
|
|
329
|
+
return file.split(node_path.default.sep).join("/");
|
|
330
|
+
}
|
|
331
|
+
function isPathWithinRoot(file, root) {
|
|
332
|
+
const relative = node_path.default.relative(root, file);
|
|
333
|
+
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
334
|
+
}
|
|
335
|
+
function collectWebpackCssMatchBases(file, roots) {
|
|
336
|
+
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
337
|
+
const bases = /* @__PURE__ */ new Set();
|
|
338
|
+
const addBase = (candidate) => {
|
|
339
|
+
const stripped = normalizeMatchPath(stripStyleExtension(candidate));
|
|
340
|
+
if (stripped.length > 0) {
|
|
341
|
+
bases.add(stripped);
|
|
342
|
+
const withoutWorkspaceSegment = stripped.replace(/^(?:src|dist)\//, "");
|
|
343
|
+
if (withoutWorkspaceSegment !== stripped && withoutWorkspaceSegment.length > 0) bases.add(withoutWorkspaceSegment);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
addBase(normalizedFile);
|
|
347
|
+
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
|
|
348
|
+
if (node_path.default.isAbsolute(normalizedFile)) {
|
|
349
|
+
for (const root of resolvedRoots) if (isPathWithinRoot(normalizedFile, root)) addBase(node_path.default.relative(root, normalizedFile));
|
|
350
|
+
} else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
|
|
351
|
+
return bases;
|
|
352
|
+
}
|
|
353
|
+
function scoreWebpackCssSourceFileMatch(outputFile, sourceFile, options) {
|
|
354
|
+
const outputBases = collectWebpackCssMatchBases(outputFile, [options.outputRoot, options.projectRoot]);
|
|
355
|
+
const sourceBases = collectWebpackCssMatchBases(sourceFile, [options.projectRoot]);
|
|
356
|
+
let bestScore = 0;
|
|
357
|
+
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
|
|
358
|
+
else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
359
|
+
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
360
|
+
return bestScore;
|
|
361
|
+
}
|
|
320
362
|
function resolveWebpackMemoryDebugStats(context) {
|
|
321
363
|
if (node_process.default.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
|
|
322
364
|
const memory = node_process.default.memoryUsage();
|
|
@@ -351,7 +393,7 @@ function resolveWebpackMemoryDebugStats(context) {
|
|
|
351
393
|
};
|
|
352
394
|
}
|
|
353
395
|
function setupWebpackV5ProcessAssetsHook(options) {
|
|
354
|
-
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
396
|
+
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, getWebpackCssSources, debug } = options;
|
|
355
397
|
const { Compilation, sources } = compiler.webpack;
|
|
356
398
|
const { ConcatSource } = sources;
|
|
357
399
|
const isWebGeneratorTarget = compilerOptions.generator?.target === "web";
|
|
@@ -421,22 +463,58 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
421
463
|
activeProcessHashKeys.add(hashKey);
|
|
422
464
|
};
|
|
423
465
|
for (const chunk of compilation.chunks) if (chunk.id) activeProcessHashKeys.add(chunk.id);
|
|
466
|
+
const cssSources = new Map([...getWebpackCssSources?.() ?? []].map(([file, css]) => [node_path.default.resolve(file), css]));
|
|
467
|
+
const cssSourceFiles = [...cssSources.keys()].sort();
|
|
468
|
+
const resolveWebpackCssSourceFile = (file) => {
|
|
469
|
+
if (cssSourceFiles.length === 0) return;
|
|
470
|
+
const matches = cssSourceFiles.map((sourceFile) => ({
|
|
471
|
+
sourceFile,
|
|
472
|
+
score: scoreWebpackCssSourceFileMatch(file, sourceFile, {
|
|
473
|
+
outputRoot: outputDir,
|
|
474
|
+
projectRoot: compilerOptions.tailwindcssBasedir
|
|
475
|
+
})
|
|
476
|
+
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
477
|
+
const bestScore = matches[0]?.score ?? 0;
|
|
478
|
+
const bestMatches = matches.filter((match) => match.score === bestScore);
|
|
479
|
+
return bestMatches.length === 1 ? bestMatches[0]?.sourceFile : void 0;
|
|
480
|
+
};
|
|
424
481
|
const getCssHandlerOptions = (file) => {
|
|
425
482
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
426
483
|
const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
|
|
427
|
-
const
|
|
484
|
+
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
485
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
486
|
+
const cacheKey = [
|
|
487
|
+
majorVersion ?? "unknown",
|
|
488
|
+
isMainChunk ? "1" : "0",
|
|
489
|
+
sourceFile ?? "asset",
|
|
490
|
+
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
491
|
+
file
|
|
492
|
+
].join(":");
|
|
428
493
|
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
429
494
|
if (cached) return cached;
|
|
430
495
|
const created = {
|
|
431
496
|
isMainChunk,
|
|
432
|
-
postcssOptions: { options: { from: file } },
|
|
497
|
+
postcssOptions: { options: { from: sourceFile ?? file } },
|
|
498
|
+
sourceOptions: {
|
|
499
|
+
outputRoot: outputDir,
|
|
500
|
+
...sourceCss === void 0 ? {} : { sourceCss },
|
|
501
|
+
...sourceFile === void 0 ? {} : { sourceFile }
|
|
502
|
+
},
|
|
433
503
|
...majorVersion === void 0 ? {} : { majorVersion }
|
|
434
504
|
};
|
|
435
505
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
436
506
|
return created;
|
|
437
507
|
};
|
|
438
508
|
const getCssUserHandlerOptions = (file) => {
|
|
439
|
-
const
|
|
509
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
510
|
+
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
511
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
512
|
+
const cacheKey = [
|
|
513
|
+
majorVersion ?? "unknown",
|
|
514
|
+
sourceFile ?? "asset",
|
|
515
|
+
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
516
|
+
file
|
|
517
|
+
].join(":");
|
|
440
518
|
const cached = cssUserHandlerOptionsCache.get(cacheKey);
|
|
441
519
|
if (cached) return cached;
|
|
442
520
|
const created = {
|
|
@@ -446,7 +524,52 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
446
524
|
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
447
525
|
return created;
|
|
448
526
|
};
|
|
527
|
+
const refreshWebpackSourceCandidates = async () => {
|
|
528
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
529
|
+
if (majorVersion !== 3 && majorVersion !== 4) return;
|
|
530
|
+
const root = compilerOptions.tailwindcssBasedir ?? node_process.default.cwd();
|
|
531
|
+
let sourceScan;
|
|
532
|
+
try {
|
|
533
|
+
sourceScan = await require_v3_engine.resolveViteSourceScanEntries(compilerOptions, runtimeState.twPatcher, {
|
|
534
|
+
root,
|
|
535
|
+
outDir: outputDir
|
|
536
|
+
});
|
|
537
|
+
} catch (error) {
|
|
538
|
+
debug("webpack source candidate scan skipped: %O", error);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const collector = require_hmr_timing.createSourceCandidateCollector({
|
|
542
|
+
bareArbitraryValues: compilerOptions.arbitraryValues?.bareArbitraryValues,
|
|
543
|
+
extractor: majorVersion === 3 ? require_hmr_timing.createTailwindV3DefaultExtractor() : void 0
|
|
544
|
+
});
|
|
545
|
+
await collector.scanRoot({
|
|
546
|
+
entries: sourceScan?.entries,
|
|
547
|
+
explicit: sourceScan?.explicit,
|
|
548
|
+
root,
|
|
549
|
+
outDir: outputDir
|
|
550
|
+
});
|
|
551
|
+
collector.syncInline(sourceScan?.inlineCandidates);
|
|
552
|
+
const candidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
|
|
553
|
+
return {
|
|
554
|
+
candidates,
|
|
555
|
+
getSourceCandidatesForEntries: (entries, options) => collector.valuesForEntries(entries, options),
|
|
556
|
+
signature: compilerOptions.cache.computeHash(JSON.stringify({
|
|
557
|
+
root,
|
|
558
|
+
outDir: outputDir,
|
|
559
|
+
entries: sourceScan?.entries,
|
|
560
|
+
explicit: sourceScan?.explicit ?? false,
|
|
561
|
+
inlineCandidates: sourceScan?.inlineCandidates ? {
|
|
562
|
+
included: [...sourceScan.inlineCandidates.included].sort(),
|
|
563
|
+
excluded: [...sourceScan.inlineCandidates.excluded].sort()
|
|
564
|
+
} : void 0,
|
|
565
|
+
dependencies: [...sourceScan?.dependencies ?? []].sort(),
|
|
566
|
+
candidates: [...candidates].sort()
|
|
567
|
+
})),
|
|
568
|
+
tokenSources: collector.sourcesForEntries(sourceScan?.entries)
|
|
569
|
+
};
|
|
570
|
+
};
|
|
449
571
|
const finalizeCssAssetSource = (source, options = {}) => {
|
|
572
|
+
const styleOptions = require_precheck.resolveStyleOptionsFromContext(compilerOptions);
|
|
450
573
|
let finalized = require_v3_engine.removeTailwindSourceDirectives(require_bundle_state.stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
451
574
|
if (isWebGeneratorTarget || options.generatedCss !== true) return finalized;
|
|
452
575
|
try {
|
|
@@ -455,34 +578,24 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
455
578
|
finalized = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(finalized, {
|
|
456
579
|
cssPreflight: runtimeState.twPatcher.majorVersion === 4 ? compilerOptions.cssPreflight : void 0,
|
|
457
580
|
isTailwindcssV4: runtimeState.twPatcher.majorVersion === 4,
|
|
458
|
-
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3
|
|
581
|
+
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3,
|
|
582
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
459
583
|
});
|
|
460
584
|
}
|
|
461
585
|
return finalized;
|
|
462
586
|
};
|
|
463
587
|
const finalizeMiniProgramUserCssAssetSource = (source) => {
|
|
588
|
+
const styleOptions = require_precheck.resolveStyleOptionsFromContext(compilerOptions);
|
|
464
589
|
if (isWebGeneratorTarget) return source;
|
|
465
590
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(source, {
|
|
466
591
|
cssPreflight: runtimeState.twPatcher.majorVersion === 4 ? compilerOptions.cssPreflight : void 0,
|
|
467
592
|
isTailwindcssV4: runtimeState.twPatcher.majorVersion === 4,
|
|
468
|
-
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3
|
|
593
|
+
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3,
|
|
594
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
469
595
|
});
|
|
470
596
|
};
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
const sourceScan = await require_v3_engine.resolveViteSourceScanEntries(compilerOptions, runtimeState.twPatcher, { root });
|
|
474
|
-
const collector = require_hmr_timing.createSourceCandidateCollector({
|
|
475
|
-
bareArbitraryValues: compilerOptions.arbitraryValues?.bareArbitraryValues,
|
|
476
|
-
extractor: runtimeState.twPatcher.majorVersion === 3 ? require_hmr_timing.createTailwindV3DefaultExtractor() : void 0
|
|
477
|
-
});
|
|
478
|
-
await collector.scanRoot({
|
|
479
|
-
entries: sourceScan?.entries,
|
|
480
|
-
explicit: sourceScan?.explicit,
|
|
481
|
-
root
|
|
482
|
-
});
|
|
483
|
-
collector.syncInline(sourceScan?.inlineCandidates);
|
|
484
|
-
return require_hmr_timing.createCssTokenSourceMap(collector.sourcesForEntries(sourceScan?.entries), compilerOptions);
|
|
485
|
-
})() : void 0;
|
|
597
|
+
const webpackSourceCandidates = groupedEntries.css?.length || require_hmr_timing.isCssSourceTraceEnabled(compilerOptions) ? await refreshWebpackSourceCandidates() : void 0;
|
|
598
|
+
const cssSourceTraceTokenSources = require_hmr_timing.isCssSourceTraceEnabled(compilerOptions) && webpackSourceCandidates ? require_hmr_timing.createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions) : void 0;
|
|
486
599
|
const cssSourceTraceSignature = require_hmr_timing.createCssSourceTraceCacheSignature(cssSourceTraceTokenSources, compilerOptions);
|
|
487
600
|
const annotateCss = (css) => require_hmr_timing.annotateCssSourceTrace(css, {
|
|
488
601
|
opts: compilerOptions,
|
|
@@ -632,10 +745,17 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
632
745
|
}));
|
|
633
746
|
continue;
|
|
634
747
|
}
|
|
748
|
+
if (isWebGeneratorTarget) continue;
|
|
635
749
|
const cacheKey = file;
|
|
636
750
|
const hashKey = `${file}:asset`;
|
|
637
751
|
rememberProcessCacheKey(cacheKey, hashKey);
|
|
638
|
-
const
|
|
752
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
753
|
+
const cssSourceHash = (() => {
|
|
754
|
+
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
755
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
756
|
+
return sourceCss === void 0 ? "webpack-css-source:0" : `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}`;
|
|
757
|
+
})();
|
|
758
|
+
const runtimeAwareHash = createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(rawSource), `${runtimeSetHash}:${webpackSourceCandidates?.signature ?? "source-candidates:0"}:${cssSourceTraceSignature}:${cssSourceHash}`);
|
|
639
759
|
tasks.push(require_hmr_timing.processCachedTask({
|
|
640
760
|
cache: compilerOptions.cache,
|
|
641
761
|
cacheKey,
|
|
@@ -651,19 +771,21 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
651
771
|
transform: async () => {
|
|
652
772
|
await runtimeState.readyPromise;
|
|
653
773
|
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
774
|
+
const generatorRawSource = resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions);
|
|
654
775
|
if (require_hmr_timing.isPureLocalCssImportWrapper(rawSource)) return { result: new ConcatSource(require_v3_engine.removeTailwindSourceDirectives(require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource), { importFallback: true })) };
|
|
655
776
|
const generated = await require_hmr_timing.generateCssByGenerator({
|
|
656
777
|
opts: compilerOptions,
|
|
657
778
|
runtimeState,
|
|
658
779
|
runtime: runtimeSet,
|
|
659
|
-
rawSource,
|
|
780
|
+
rawSource: generatorRawSource,
|
|
660
781
|
file,
|
|
661
782
|
cssHandlerOptions,
|
|
662
783
|
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
784
|
+
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
663
785
|
styleHandler: compilerOptions.styleHandler,
|
|
664
786
|
debug
|
|
665
787
|
});
|
|
666
|
-
const source = new ConcatSource(finalizeTracedCss(
|
|
788
|
+
const source = new ConcatSource(finalizeTracedCss(generated?.css ?? finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false })));
|
|
667
789
|
if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
|
|
668
790
|
else debug("css handle: %s", file);
|
|
669
791
|
return { result: source };
|
|
@@ -731,10 +853,11 @@ function createLoaderAnchorFinders(appType) {
|
|
|
731
853
|
//#endregion
|
|
732
854
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
733
855
|
function setupWebpackV5Loaders(options) {
|
|
734
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, getRuntimeWatchDependencies, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
856
|
+
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, registerWebpackCssSourceFile, getRuntimeWatchDependencies, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
735
857
|
const isMpxApp = isMpx(appType);
|
|
736
858
|
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
737
859
|
const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
860
|
+
const shouldInjectRuntimeClassSetLoader = compilerOptions.generator?.target !== "web";
|
|
738
861
|
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? node_path.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
739
862
|
const runtimeClassSetLoaderExists = node_fs.default.existsSync(runtimeClassSetLoader);
|
|
740
863
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
@@ -750,7 +873,8 @@ function setupWebpackV5Loaders(options) {
|
|
|
750
873
|
setWebpackLoaderRuntime(runtimeRegistryKey, {
|
|
751
874
|
classSet: {
|
|
752
875
|
getClassSet: getClassSetInLoader,
|
|
753
|
-
getWatchDependencies: getRuntimeWatchDependencies
|
|
876
|
+
getWatchDependencies: getRuntimeWatchDependencies,
|
|
877
|
+
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile }
|
|
754
878
|
},
|
|
755
879
|
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
756
880
|
});
|
|
@@ -808,7 +932,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
808
932
|
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
809
933
|
}
|
|
810
934
|
}
|
|
811
|
-
if (runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
|
|
935
|
+
if (shouldInjectRuntimeClassSetLoader && runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
|
|
812
936
|
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
813
937
|
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
814
938
|
if (anchorIndex === -1) anchorlessInsert(classSetLoaderEntry, "before");
|
|
@@ -916,6 +1040,7 @@ var WeappTailwindcss = class {
|
|
|
916
1040
|
const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
|
|
917
1041
|
const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
|
|
918
1042
|
const webpackProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
1043
|
+
const webpackCssSources = /* @__PURE__ */ new Map();
|
|
919
1044
|
let runtimeMetadataPrepared = false;
|
|
920
1045
|
const updateRuntimeWatchDependencies = async () => {
|
|
921
1046
|
runtimeWatchDependencyFiles.clear();
|
|
@@ -963,7 +1088,7 @@ var WeappTailwindcss = class {
|
|
|
963
1088
|
syncRuntimeRefreshRequirement();
|
|
964
1089
|
};
|
|
965
1090
|
const registerAutoCssSource = async (source) => {
|
|
966
|
-
if (
|
|
1091
|
+
if ((runtimeState.twPatcher.majorVersion ?? 0) < 4 || !source.file) return;
|
|
967
1092
|
if (!require_tailwindcss.upsertTailwindV4CssSource(this.options, source)) return;
|
|
968
1093
|
runtimeSetPrepared = false;
|
|
969
1094
|
runtimeMetadataPrepared = false;
|
|
@@ -977,6 +1102,9 @@ var WeappTailwindcss = class {
|
|
|
977
1102
|
const markWebpackProcessedCssSource = (file) => {
|
|
978
1103
|
webpackProcessedCssSourceFiles.add(node_path.default.resolve(file));
|
|
979
1104
|
};
|
|
1105
|
+
const registerWebpackCssSourceFile = (source) => {
|
|
1106
|
+
webpackCssSources.set(node_path.default.resolve(source.file), source.css);
|
|
1107
|
+
};
|
|
980
1108
|
const isWebpackProcessedTailwindEntryAsset = (file) => {
|
|
981
1109
|
if ((runtimeState.twPatcher.majorVersion ?? 0) < 4 || !this.options.mainCssChunkMatcher(file, this.appType) || webpackProcessedCssSourceFiles.size === 0) return false;
|
|
982
1110
|
const tailwindOptions = require_v3_engine.resolveTailwindcssOptions(runtimeState.twPatcher.options);
|
|
@@ -1024,6 +1152,7 @@ var WeappTailwindcss = class {
|
|
|
1024
1152
|
getClassSetInLoader,
|
|
1025
1153
|
getRuntimeSetInLoader,
|
|
1026
1154
|
markWebpackProcessedCssSource,
|
|
1155
|
+
registerWebpackCssSourceFile,
|
|
1027
1156
|
getRuntimeWatchDependencies() {
|
|
1028
1157
|
return {
|
|
1029
1158
|
files: runtimeWatchDependencyFiles,
|
|
@@ -1047,6 +1176,7 @@ var WeappTailwindcss = class {
|
|
|
1047
1176
|
},
|
|
1048
1177
|
isWatchMode: () => watchRunObserved || compiler.options?.watch === true,
|
|
1049
1178
|
runtimeClassSetManager: this.options.__internalWebpackRuntimeClassSetManager,
|
|
1179
|
+
getWebpackCssSources: () => webpackCssSources,
|
|
1050
1180
|
debug
|
|
1051
1181
|
});
|
|
1052
1182
|
}
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-CfkUkMXG.js");
|
|
3
3
|
exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_webpack.WeappTailwindcss;
|
|
5
5
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-BcPpnT90.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.13",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,6 +86,11 @@
|
|
|
86
86
|
"import": "./dist/defaults.mjs",
|
|
87
87
|
"require": "./dist/defaults.js"
|
|
88
88
|
},
|
|
89
|
+
"./framework": {
|
|
90
|
+
"types": "./dist/framework.d.ts",
|
|
91
|
+
"import": "./dist/framework.mjs",
|
|
92
|
+
"require": "./dist/framework.js"
|
|
93
|
+
},
|
|
89
94
|
"./presets": {
|
|
90
95
|
"types": "./dist/presets.d.ts",
|
|
91
96
|
"import": "./dist/presets.mjs",
|
|
@@ -172,7 +177,7 @@
|
|
|
172
177
|
"@babel/parser": "~7.29.7",
|
|
173
178
|
"@babel/traverse": "~7.29.7",
|
|
174
179
|
"@babel/types": "~7.29.7",
|
|
175
|
-
"@vue/compiler-dom": "^3.5.
|
|
180
|
+
"@vue/compiler-dom": "^3.5.38",
|
|
176
181
|
"@weapp-core/escape": "~8.0.0",
|
|
177
182
|
"comment-json": "^5.0.0",
|
|
178
183
|
"debug": "~4.4.3",
|
|
@@ -184,10 +189,10 @@
|
|
|
184
189
|
"semver": "~7.8.4",
|
|
185
190
|
"tailwindcss-patch": "9.4.4",
|
|
186
191
|
"yaml": "^2.9.0",
|
|
187
|
-
"@weapp-tailwindcss/postcss": "3.0.7",
|
|
188
192
|
"@weapp-tailwindcss/logger": "2.0.0",
|
|
189
|
-
"@weapp-tailwindcss/
|
|
193
|
+
"@weapp-tailwindcss/postcss": "3.0.8",
|
|
190
194
|
"@weapp-tailwindcss/reset": "0.1.1",
|
|
195
|
+
"@weapp-tailwindcss/shared": "2.0.0",
|
|
191
196
|
"tailwindcss-config": "2.0.0"
|
|
192
197
|
},
|
|
193
198
|
"devDependencies": {
|