weapp-tailwindcss 5.0.0-next.17 → 5.0.0-next.19
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/README.md +2 -2
- package/dist/{bundle-state-DDgxuERW.js → bundle-state-C9G1XBp0.js} +83 -2
- package/dist/{bundle-state-YW-zLcsc.mjs → bundle-state-u4DFiZEj.mjs} +47 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -0
- package/dist/bundlers/vite/source-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cli.js +63 -61
- package/dist/cli.mjs +63 -61
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-BIEhxFdv.js → generator-CQ8A3YVm.js} +1 -1
- package/dist/{generator-Ber8UVgv.mjs → generator-CbjnpVed.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-CfznDtJ0.js → incremental-runtime-class-set-BMo8s7do.js} +54 -21
- package/dist/{incremental-runtime-class-set-DC0RsBbK.mjs → incremental-runtime-class-set-Cwq1Wbo2.mjs} +52 -19
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-DW08tZXt.mjs → postcss-CLQ3yVXP.mjs} +3 -20
- package/dist/{postcss-DCOUtuwI.js → postcss-CXJLLWRe.js} +3 -20
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-CX-5VqM1.mjs → precheck-Bbcmh24Z.mjs} +2 -2
- package/dist/{precheck-CZfnh4T6.js → precheck-CTRQCNuH.js} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{postcss-CZE8k8oP.js → runtime-registry-D5qnaSpo.js} +33 -0
- package/dist/{source-candidates-DGlDzkvf.mjs → source-candidates-B3NL91dO.mjs} +23 -73
- package/dist/{source-candidates-BDyoPviV.js → source-candidates-CVp7TQFL.js} +23 -75
- package/dist/tailwindcss/source-scan.d.ts +10 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +3 -0
- package/dist/{tailwindcss-BVoa7vx-.js → tailwindcss-DO30H8ux.js} +1 -1
- package/dist/{tailwindcss-D74Wk4ys.mjs → tailwindcss-P0OQvEif.mjs} +1 -1
- package/dist/{v3-engine-CCxDqZ8e.mjs → v3-engine-DHsPM4ye.mjs} +176 -149
- package/dist/{v3-engine-BRInt2DS.js → v3-engine-DpaX1FqH.js} +209 -146
- package/dist/{vite-bmU2kkO6.mjs → vite-BfR3PR2w.mjs} +311 -118
- package/dist/{vite-DnHdmHHD.js → vite-D82lLEfX.js} +318 -123
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5018 -86
- package/dist/weapp-tw-runtime-classset-loader.js +7 -20
- package/dist/{webpack-BkBoEn4k.mjs → webpack-BY-mkkMS.mjs} +67 -16
- package/dist/{webpack-SxEdWHlL.js → webpack-cMf0bWIS.js} +67 -16
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -6
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime_registry = require("./runtime-registry-D5qnaSpo.js");
|
|
2
2
|
let node_buffer = require("node:buffer");
|
|
3
3
|
let node_process = require("node:process");
|
|
4
|
-
node_process =
|
|
4
|
+
node_process = require_runtime_registry.__toESM(node_process);
|
|
5
5
|
let loader_utils = require("loader-utils");
|
|
6
|
-
loader_utils =
|
|
7
|
-
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
8
|
-
/**
|
|
9
|
-
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
10
|
-
*/
|
|
11
|
-
function removeUnsupportedCascadeLayers(root) {
|
|
12
|
-
root.walkAtRules("layer", (atRule) => {
|
|
13
|
-
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
14
|
-
atRule.remove();
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
atRule.replaceWith(...atRule.nodes);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
6
|
+
loader_utils = require_runtime_registry.__toESM(loader_utils);
|
|
21
7
|
//#region src/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.ts
|
|
22
8
|
function isPromiseLike(value) {
|
|
23
9
|
return Boolean(value && typeof value.then === "function");
|
|
@@ -34,8 +20,8 @@ function shouldCleanRuntimeCss(css) {
|
|
|
34
20
|
return css.includes("@layer") || css.includes("@theme");
|
|
35
21
|
}
|
|
36
22
|
function cleanRuntimeCss(css) {
|
|
37
|
-
const root =
|
|
38
|
-
removeUnsupportedCascadeLayers(root);
|
|
23
|
+
const root = require_runtime_registry.postcss_default.parse(css);
|
|
24
|
+
require_runtime_registry.removeUnsupportedCascadeLayers(root);
|
|
39
25
|
removeUnsupportedThemeKeyframes(root);
|
|
40
26
|
return root.toString();
|
|
41
27
|
}
|
|
@@ -48,7 +34,8 @@ function removeUnsupportedThemeKeyframes(root) {
|
|
|
48
34
|
}
|
|
49
35
|
const WeappTwRuntimeClassSetLoader = function(source) {
|
|
50
36
|
if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-runtime-classset-loader] executing for ${this.resourcePath}\n`);
|
|
51
|
-
const
|
|
37
|
+
const rawOptions = getLoaderOptions(this);
|
|
38
|
+
const opt = require_runtime_registry.getWebpackLoaderRuntime(rawOptions?.weappTailwindcssRuntimeKey)?.classSet ?? rawOptions;
|
|
52
39
|
const maybePromise = opt?.getClassSet?.();
|
|
53
40
|
const applyWatchDependencies = (dependencies) => {
|
|
54
41
|
for (const file of dependencies?.files ?? []) this.addDependency?.(file);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-
|
|
3
|
-
import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform, v as refreshTailwindRuntimeState } from "./precheck-
|
|
1
|
+
import { G as resolveTailwindcssOptions, V as createDebug, l as getRuntimeClassSetSignature } from "./v3-engine-DHsPM4ye.mjs";
|
|
2
|
+
import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-Cwq1Wbo2.mjs";
|
|
3
|
+
import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform, v as refreshTailwindRuntimeState } from "./precheck-Bbcmh24Z.mjs";
|
|
4
4
|
import { r as getGroupedEntries } from "./utils-CGBVVNm6.mjs";
|
|
5
|
-
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
6
|
-
import {
|
|
5
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-P0OQvEif.mjs";
|
|
6
|
+
import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-u4DFiZEj.mjs";
|
|
7
7
|
import Module, { createRequire } from "node:module";
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
@@ -264,7 +264,7 @@ function createWebpackSnapshotAssets(assets) {
|
|
|
264
264
|
}));
|
|
265
265
|
}
|
|
266
266
|
function setupWebpackV5ProcessAssetsHook(options) {
|
|
267
|
-
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
267
|
+
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
268
268
|
const { Compilation, sources } = compiler.webpack;
|
|
269
269
|
const { ConcatSource } = sources;
|
|
270
270
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
@@ -352,7 +352,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
352
352
|
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
353
353
|
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
|
|
354
354
|
let runtimeSet;
|
|
355
|
-
|
|
355
|
+
const watchMode = isWatchMode?.() === true;
|
|
356
|
+
if (watchMode && runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) {
|
|
356
357
|
const snapshot = buildBundleSnapshot(createWebpackSnapshotAssets(assets), compilerOptions, outputDir, bundleBuildState);
|
|
357
358
|
if (!webpackWatchRuntimeScanInitialized) {
|
|
358
359
|
for (const entry of snapshot.entries) if (entry.type === "html" || entry.type === "js") snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
|
|
@@ -378,7 +379,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
378
379
|
}
|
|
379
380
|
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
380
381
|
forceRefresh: forceRuntimeRefresh,
|
|
381
|
-
forceCollect:
|
|
382
|
+
forceCollect: !watchMode || forceRuntimeRefresh,
|
|
382
383
|
clearCache: forceRuntimeRefresh,
|
|
383
384
|
allowEmpty: false
|
|
384
385
|
});
|
|
@@ -463,6 +464,28 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
463
464
|
if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
|
|
464
465
|
const [file, originalSource] = element;
|
|
465
466
|
const rawSource = originalSource.source().toString();
|
|
467
|
+
if (isWebpackProcessedCssAsset?.(file, rawSource)) {
|
|
468
|
+
const nextCss = stripBundlerGeneratedCssMarkers(rawSource);
|
|
469
|
+
tasks.push(processCachedTask({
|
|
470
|
+
cache: compilerOptions.cache,
|
|
471
|
+
cacheKey: file,
|
|
472
|
+
hashKey: `${file}:asset`,
|
|
473
|
+
rawSource,
|
|
474
|
+
hash: createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash),
|
|
475
|
+
applyResult(source) {
|
|
476
|
+
compilation.updateAsset(file, source);
|
|
477
|
+
},
|
|
478
|
+
onCacheHit() {
|
|
479
|
+
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
480
|
+
},
|
|
481
|
+
transform: async () => {
|
|
482
|
+
compilerOptions.onUpdate(file, rawSource, nextCss);
|
|
483
|
+
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
484
|
+
return { result: new ConcatSource(nextCss) };
|
|
485
|
+
}
|
|
486
|
+
}));
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
466
489
|
const cacheKey = file;
|
|
467
490
|
const runtimeAwareHash = createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash);
|
|
468
491
|
tasks.push(processCachedTask({
|
|
@@ -514,6 +537,13 @@ const getFilename = () => fileURLToPath(import.meta.url);
|
|
|
514
537
|
const getDirname = () => path.dirname(getFilename());
|
|
515
538
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
516
539
|
//#endregion
|
|
540
|
+
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
541
|
+
const runtimeRegistryHolder = globalThis;
|
|
542
|
+
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
543
|
+
function setWebpackLoaderRuntime(key, entry) {
|
|
544
|
+
runtimeRegistry.set(key, entry);
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
517
547
|
//#region src/bundlers/webpack/shared/loader-anchors.ts
|
|
518
548
|
const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
519
549
|
const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
@@ -544,7 +574,7 @@ function createLoaderAnchorFinders(appType) {
|
|
|
544
574
|
//#endregion
|
|
545
575
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
546
576
|
function setupWebpackV5Loaders(options) {
|
|
547
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
|
|
577
|
+
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;
|
|
548
578
|
const isMpxApp = isMpx(appType);
|
|
549
579
|
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
550
580
|
const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
@@ -553,19 +583,26 @@ function setupWebpackV5Loaders(options) {
|
|
|
553
583
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
554
584
|
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
555
585
|
pkgDir: weappTailwindcssPackageDir,
|
|
586
|
+
compilerOptions,
|
|
587
|
+
runtimeState,
|
|
556
588
|
...appType === void 0 ? {} : { appType },
|
|
557
|
-
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource }
|
|
589
|
+
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource },
|
|
590
|
+
getRuntimeSet: getRuntimeSetInLoader,
|
|
591
|
+
...markWebpackProcessedCssSource === void 0 ? {} : { markGeneratedCssSource: markWebpackProcessedCssSource }
|
|
558
592
|
} : void 0;
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
593
|
+
setWebpackLoaderRuntime(runtimeRegistryKey, {
|
|
594
|
+
classSet: {
|
|
595
|
+
getClassSet: getClassSetInLoader,
|
|
596
|
+
getWatchDependencies: getRuntimeWatchDependencies
|
|
597
|
+
},
|
|
598
|
+
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
599
|
+
});
|
|
563
600
|
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
564
|
-
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
601
|
+
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewriteRuntimeKey: runtimeRegistryKey } : void 0;
|
|
565
602
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
566
603
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
567
604
|
loader: runtimeClassSetLoader,
|
|
568
|
-
options:
|
|
605
|
+
options: { weappTailwindcssRuntimeKey: runtimeRegistryKey },
|
|
569
606
|
ident: null,
|
|
570
607
|
type: null
|
|
571
608
|
});
|
|
@@ -666,6 +703,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
666
703
|
let watchRunObserved = false;
|
|
667
704
|
const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
|
|
668
705
|
const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
|
|
706
|
+
const webpackProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
669
707
|
let runtimeMetadataPrepared = false;
|
|
670
708
|
const updateRuntimeWatchDependencies = async () => {
|
|
671
709
|
runtimeWatchDependencyFiles.clear();
|
|
@@ -724,6 +762,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
724
762
|
});
|
|
725
763
|
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
726
764
|
};
|
|
765
|
+
const markWebpackProcessedCssSource = (file) => {
|
|
766
|
+
webpackProcessedCssSourceFiles.add(path.resolve(file));
|
|
767
|
+
};
|
|
727
768
|
compiler.hooks.invalid?.tap?.(pluginName, (fileName) => {
|
|
728
769
|
if (!fileName) return;
|
|
729
770
|
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([path.resolve(fileName)]);
|
|
@@ -747,6 +788,10 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
747
788
|
runtimeSetSignature = signature;
|
|
748
789
|
runtimeRefreshRequiredForCompilation = false;
|
|
749
790
|
}
|
|
791
|
+
async function getRuntimeSetInLoader() {
|
|
792
|
+
await getClassSetInLoader();
|
|
793
|
+
return ensureRuntimeClassSet(runtimeState, { allowEmpty: true });
|
|
794
|
+
}
|
|
750
795
|
onLoad();
|
|
751
796
|
setupWebpackV5Loaders({
|
|
752
797
|
compiler,
|
|
@@ -756,7 +801,10 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
756
801
|
shouldRewriteCssImports,
|
|
757
802
|
runtimeLoaderPath,
|
|
758
803
|
registerAutoCssSource,
|
|
804
|
+
runtimeState,
|
|
759
805
|
getClassSetInLoader,
|
|
806
|
+
getRuntimeSetInLoader,
|
|
807
|
+
markWebpackProcessedCssSource,
|
|
760
808
|
getRuntimeWatchDependencies() {
|
|
761
809
|
return {
|
|
762
810
|
files: runtimeWatchDependencyFiles,
|
|
@@ -772,6 +820,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
772
820
|
runtimeState,
|
|
773
821
|
getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
|
|
774
822
|
refreshRuntimeMetadata: ensureRuntimeMetadata,
|
|
823
|
+
isWebpackProcessedCssAsset(file, rawSource) {
|
|
824
|
+
return webpackProcessedCssSourceFiles.has(path.resolve(file)) || rawSource.includes("weapp-tailwindcss webpack-generated-css");
|
|
825
|
+
},
|
|
775
826
|
consumeRuntimeRefreshRequirement() {
|
|
776
827
|
runtimeRefreshRequiredForCompilation = false;
|
|
777
828
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-DpaX1FqH.js");
|
|
3
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BMo8s7do.js");
|
|
4
|
+
const require_precheck = require("./precheck-CTRQCNuH.js");
|
|
5
5
|
const require_utils = require("./utils-4ODFyoqD.js");
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_bundle_state = require("./bundle-state-
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-DO30H8ux.js");
|
|
7
|
+
const require_bundle_state = require("./bundle-state-C9G1XBp0.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
10
10
|
let node_module = require("node:module");
|
|
@@ -268,7 +268,7 @@ function createWebpackSnapshotAssets(assets) {
|
|
|
268
268
|
}));
|
|
269
269
|
}
|
|
270
270
|
function setupWebpackV5ProcessAssetsHook(options) {
|
|
271
|
-
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
271
|
+
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, debug } = options;
|
|
272
272
|
const { Compilation, sources } = compiler.webpack;
|
|
273
273
|
const { ConcatSource } = sources;
|
|
274
274
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
@@ -356,7 +356,8 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
356
356
|
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
357
357
|
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
|
|
358
358
|
let runtimeSet;
|
|
359
|
-
|
|
359
|
+
const watchMode = isWatchMode?.() === true;
|
|
360
|
+
if (watchMode && runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) {
|
|
360
361
|
const snapshot = require_bundle_state.buildBundleSnapshot(createWebpackSnapshotAssets(assets), compilerOptions, outputDir, bundleBuildState);
|
|
361
362
|
if (!webpackWatchRuntimeScanInitialized) {
|
|
362
363
|
for (const entry of snapshot.entries) if (entry.type === "html" || entry.type === "js") snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
|
|
@@ -382,7 +383,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
382
383
|
}
|
|
383
384
|
runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, {
|
|
384
385
|
forceRefresh: forceRuntimeRefresh,
|
|
385
|
-
forceCollect:
|
|
386
|
+
forceCollect: !watchMode || forceRuntimeRefresh,
|
|
386
387
|
clearCache: forceRuntimeRefresh,
|
|
387
388
|
allowEmpty: false
|
|
388
389
|
});
|
|
@@ -467,6 +468,28 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
467
468
|
if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
|
|
468
469
|
const [file, originalSource] = element;
|
|
469
470
|
const rawSource = originalSource.source().toString();
|
|
471
|
+
if (isWebpackProcessedCssAsset?.(file, rawSource)) {
|
|
472
|
+
const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
|
|
473
|
+
tasks.push(require_incremental_runtime_class_set.processCachedTask({
|
|
474
|
+
cache: compilerOptions.cache,
|
|
475
|
+
cacheKey: file,
|
|
476
|
+
hashKey: `${file}:asset`,
|
|
477
|
+
rawSource,
|
|
478
|
+
hash: createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash),
|
|
479
|
+
applyResult(source) {
|
|
480
|
+
compilation.updateAsset(file, source);
|
|
481
|
+
},
|
|
482
|
+
onCacheHit() {
|
|
483
|
+
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
484
|
+
},
|
|
485
|
+
transform: async () => {
|
|
486
|
+
compilerOptions.onUpdate(file, rawSource, nextCss);
|
|
487
|
+
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
488
|
+
return { result: new ConcatSource(nextCss) };
|
|
489
|
+
}
|
|
490
|
+
}));
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
470
493
|
const cacheKey = file;
|
|
471
494
|
const runtimeAwareHash = createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), runtimeSetHash);
|
|
472
495
|
tasks.push(require_incremental_runtime_class_set.processCachedTask({
|
|
@@ -513,6 +536,13 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
513
536
|
});
|
|
514
537
|
}
|
|
515
538
|
//#endregion
|
|
539
|
+
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
540
|
+
const runtimeRegistryHolder = globalThis;
|
|
541
|
+
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
542
|
+
function setWebpackLoaderRuntime(key, entry) {
|
|
543
|
+
runtimeRegistry.set(key, entry);
|
|
544
|
+
}
|
|
545
|
+
//#endregion
|
|
516
546
|
//#region src/bundlers/webpack/shared/loader-anchors.ts
|
|
517
547
|
const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
518
548
|
const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
@@ -543,7 +573,7 @@ function createLoaderAnchorFinders(appType) {
|
|
|
543
573
|
//#endregion
|
|
544
574
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
545
575
|
function setupWebpackV5Loaders(options) {
|
|
546
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
|
|
576
|
+
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;
|
|
547
577
|
const isMpxApp = isMpx(appType);
|
|
548
578
|
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
549
579
|
const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
@@ -552,19 +582,26 @@ function setupWebpackV5Loaders(options) {
|
|
|
552
582
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
553
583
|
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
554
584
|
pkgDir: weappTailwindcssPackageDir,
|
|
585
|
+
compilerOptions,
|
|
586
|
+
runtimeState,
|
|
555
587
|
...appType === void 0 ? {} : { appType },
|
|
556
|
-
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource }
|
|
588
|
+
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource },
|
|
589
|
+
getRuntimeSet: getRuntimeSetInLoader,
|
|
590
|
+
...markWebpackProcessedCssSource === void 0 ? {} : { markGeneratedCssSource: markWebpackProcessedCssSource }
|
|
557
591
|
} : void 0;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
592
|
+
setWebpackLoaderRuntime(runtimeRegistryKey, {
|
|
593
|
+
classSet: {
|
|
594
|
+
getClassSet: getClassSetInLoader,
|
|
595
|
+
getWatchDependencies: getRuntimeWatchDependencies
|
|
596
|
+
},
|
|
597
|
+
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
598
|
+
});
|
|
562
599
|
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
563
|
-
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
600
|
+
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewriteRuntimeKey: runtimeRegistryKey } : void 0;
|
|
564
601
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
565
602
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
566
603
|
loader: runtimeClassSetLoader,
|
|
567
|
-
options:
|
|
604
|
+
options: { weappTailwindcssRuntimeKey: runtimeRegistryKey },
|
|
568
605
|
ident: null,
|
|
569
606
|
type: null
|
|
570
607
|
});
|
|
@@ -665,6 +702,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
665
702
|
let watchRunObserved = false;
|
|
666
703
|
const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
|
|
667
704
|
const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
|
|
705
|
+
const webpackProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
668
706
|
let runtimeMetadataPrepared = false;
|
|
669
707
|
const updateRuntimeWatchDependencies = async () => {
|
|
670
708
|
runtimeWatchDependencyFiles.clear();
|
|
@@ -723,6 +761,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
723
761
|
});
|
|
724
762
|
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
725
763
|
};
|
|
764
|
+
const markWebpackProcessedCssSource = (file) => {
|
|
765
|
+
webpackProcessedCssSourceFiles.add(node_path.default.resolve(file));
|
|
766
|
+
};
|
|
726
767
|
compiler.hooks.invalid?.tap?.(require_precheck.pluginName, (fileName) => {
|
|
727
768
|
if (!fileName) return;
|
|
728
769
|
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([node_path.default.resolve(fileName)]);
|
|
@@ -746,6 +787,10 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
746
787
|
runtimeSetSignature = signature;
|
|
747
788
|
runtimeRefreshRequiredForCompilation = false;
|
|
748
789
|
}
|
|
790
|
+
async function getRuntimeSetInLoader() {
|
|
791
|
+
await getClassSetInLoader();
|
|
792
|
+
return require_precheck.ensureRuntimeClassSet(runtimeState, { allowEmpty: true });
|
|
793
|
+
}
|
|
749
794
|
onLoad();
|
|
750
795
|
setupWebpackV5Loaders({
|
|
751
796
|
compiler,
|
|
@@ -755,7 +800,10 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
755
800
|
shouldRewriteCssImports,
|
|
756
801
|
runtimeLoaderPath,
|
|
757
802
|
registerAutoCssSource,
|
|
803
|
+
runtimeState,
|
|
758
804
|
getClassSetInLoader,
|
|
805
|
+
getRuntimeSetInLoader,
|
|
806
|
+
markWebpackProcessedCssSource,
|
|
759
807
|
getRuntimeWatchDependencies() {
|
|
760
808
|
return {
|
|
761
809
|
files: runtimeWatchDependencyFiles,
|
|
@@ -771,6 +819,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
771
819
|
runtimeState,
|
|
772
820
|
getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
|
|
773
821
|
refreshRuntimeMetadata: ensureRuntimeMetadata,
|
|
822
|
+
isWebpackProcessedCssAsset(file, rawSource) {
|
|
823
|
+
return webpackProcessedCssSourceFiles.has(node_path.default.resolve(file)) || rawSource.includes("weapp-tailwindcss webpack-generated-css");
|
|
824
|
+
},
|
|
774
825
|
consumeRuntimeRefreshRequirement() {
|
|
775
826
|
runtimeRefreshRequiredForCompilation = false;
|
|
776
827
|
},
|
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-cMf0bWIS.js");
|
|
3
3
|
exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
|
|
4
4
|
exports.WeappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
|
|
5
5
|
exports.weappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-BY-mkkMS.mjs";
|
|
2
2
|
export { UnifiedWebpackPluginV5, UnifiedWebpackPluginV5 as WeappTailwindcss, UnifiedWebpackPluginV5 as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.19",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -186,14 +186,14 @@
|
|
|
186
186
|
"magic-string": "0.30.21",
|
|
187
187
|
"micromatch": "^4.0.8",
|
|
188
188
|
"postcss-load-config": "^6.0.1",
|
|
189
|
-
"semver": "~7.8.
|
|
190
|
-
"tailwindcss-patch": "9.3.
|
|
189
|
+
"semver": "~7.8.1",
|
|
190
|
+
"tailwindcss-patch": "9.3.7",
|
|
191
191
|
"yaml": "^2.9.0",
|
|
192
|
-
"@weapp-tailwindcss/postcss": "2.2.1-next.
|
|
192
|
+
"@weapp-tailwindcss/postcss": "2.2.1-next.4",
|
|
193
193
|
"@weapp-tailwindcss/reset": "0.1.1-next.0",
|
|
194
194
|
"@weapp-tailwindcss/shared": "1.1.3",
|
|
195
|
-
"
|
|
196
|
-
"tailwindcss
|
|
195
|
+
"tailwindcss-config": "1.1.6-next.1",
|
|
196
|
+
"@weapp-tailwindcss/logger": "1.1.0"
|
|
197
197
|
},
|
|
198
198
|
"scripts": {
|
|
199
199
|
"dev": "tsdown --watch --sourcemap",
|