weapp-tailwindcss 5.0.13 → 5.1.0
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.en.md +1 -1
- package/README.md +1 -1
- package/dist/auto-Ba6hDrse.mjs +13 -0
- package/dist/auto-DtU6f3X6.js +18 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +21 -9
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
- package/dist/bundlers/shared/run-tasks.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +10 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +0 -1
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +3 -1
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
- package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
- package/dist/bundlers/vite/source-candidates.d.ts +9 -2
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
- package/dist/bundlers/vite/source-scan.d.ts +2 -2
- package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
- package/dist/bundlers/vite/utils.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
- package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cli/mount-options.d.ts +2 -2
- package/dist/cli.js +124 -437
- package/dist/cli.mjs +120 -433
- package/dist/context/index.d.ts +3 -3
- package/dist/context/style-options.d.ts +4 -1
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/{precheck-B0Z8yW7E.js → context-BHxLe743.js} +391 -153
- package/dist/{precheck-CRI90iL1.mjs → context-Mbzkek1q.mjs} +368 -137
- package/dist/core.js +15 -12
- package/dist/core.mjs +10 -7
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-C_J_kBpw.js → defaults-CVcKbXBG.js} +4 -15
- package/dist/{defaults-Bqx18S1f.mjs → defaults-ZElj1zKc.mjs} +5 -10
- package/dist/defaults.d.ts +1 -7
- package/dist/defaults.js +1 -2
- package/dist/defaults.mjs +2 -2
- package/dist/generator/index.d.ts +6 -7
- package/dist/generator/options.d.ts +3 -3
- package/dist/generator/types.d.ts +9 -10
- package/dist/generator-9rUz4Hcb.js +170 -0
- package/dist/generator-Dc4qaPmT.mjs +123 -0
- package/dist/generator.js +10 -16
- package/dist/generator.mjs +3 -3
- package/dist/{gulp-XT8Jc7lH.js → gulp-B_sdP6dx.js} +47 -87
- package/dist/{gulp-DfOQERcV.mjs → gulp-uM36oIJs.mjs} +40 -80
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-BXMLsF4b.mjs} +1145 -842
- package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CogqkFaF.js} +1262 -881
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/fast-path/oxc.d.ts +4 -0
- package/dist/js/precheck.d.ts +1 -0
- package/dist/postcss.js +3 -4
- package/dist/postcss.mjs +2 -3
- package/dist/presets.js +9 -19
- package/dist/presets.mjs +8 -18
- package/dist/runtime-branch/create-branch.d.ts +2 -0
- package/dist/runtime-branch/generator-target-env.d.ts +4 -0
- package/dist/runtime-branch/index.d.ts +6 -0
- package/dist/runtime-branch/mini-program.d.ts +2 -0
- package/dist/runtime-branch/native-app.d.ts +2 -0
- package/dist/runtime-branch/platform.d.ts +6 -0
- package/dist/runtime-branch/tailwind-version.d.ts +2 -0
- package/dist/runtime-branch/types.d.ts +37 -0
- package/dist/runtime-branch/web.d.ts +2 -0
- package/dist/runtime-branch.d.ts +1 -0
- package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-2ybpptAK.js} +261 -19
- package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
- package/dist/tailwindcss/candidates.d.ts +7 -0
- package/dist/tailwindcss/index.d.ts +2 -2
- package/dist/tailwindcss/runtime/cache.d.ts +6 -6
- package/dist/tailwindcss/runtime-factory.d.ts +12 -0
- package/dist/tailwindcss/runtime-options.d.ts +8 -0
- package/dist/tailwindcss/runtime-types.d.ts +86 -0
- package/dist/tailwindcss/runtime.d.ts +6 -6
- package/dist/tailwindcss/source-scan.d.ts +1 -1
- package/dist/tailwindcss/targets.d.ts +2 -2
- package/dist/tailwindcss/v4/config.d.ts +3 -3
- package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
- package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
- package/dist/tailwindcss/v4/index.d.ts +1 -1
- package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
- package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
- package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
- package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
- package/dist/tailwindcss/version.d.ts +1 -1
- package/dist/tailwindcss-DHIYcqXT.js +1523 -0
- package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
- package/dist/{transform-YmrmxuF3.js → transform-CQVOgmzM.js} +17 -17
- package/dist/{transform-DfcEjsZF.mjs → transform-tExdt40m.mjs} +2 -2
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +16 -17
- package/dist/types/shared.d.ts +1 -1
- package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
- package/dist/types/user-defined-options/general.d.ts +5 -3
- package/dist/types/user-defined-options/important.d.ts +2 -2
- package/dist/uni-app-x/style-asset.d.ts +1 -0
- package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
- package/dist/v4-engine-D4ubP7N5.js +2778 -0
- package/dist/{vite-CXHVsHmX.js → vite-CP0ylSxZ.js} +1081 -542
- package/dist/{vite-DjI09vVN.mjs → vite-CPO83EhA.mjs} +916 -376
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5350 -4165
- package/dist/weapp-tw-runtime-classset-loader.js +15 -4
- package/dist/webpack-Bsek8VhR.js +2094 -0
- package/dist/webpack-BzqhJ8yK.mjs +2082 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -5
- package/dist/auto-CTp6wE5a.js +0 -33
- package/dist/auto-Cl8_hsG6.mjs +0 -22
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
- package/dist/context/tailwindcss/rax.d.ts +0 -2
- package/dist/generator-CzpArpCL.js +0 -92
- package/dist/generator-ITLd7PTl.mjs +0 -67
- package/dist/tailwindcss/patcher-options.d.ts +0 -8
- package/dist/tailwindcss/patcher.d.ts +0 -12
- package/dist/tailwindcss/runtime-patch.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
- package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
- package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
- package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher.d.ts +0 -15
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
- package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
- package/dist/tailwindcss-DZEwT3C_.js +0 -613
- package/dist/v3-engine-2rrgylhn.js +0 -4686
- package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
- package/dist/webpack-BcPpnT90.mjs +0 -1184
- package/dist/webpack-CfkUkMXG.js +0 -1196
- /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
|
@@ -1,1184 +0,0 @@
|
|
|
1
|
-
import { P as removeTailwindSourceDirectives, Y as getTailwindV4IncrementalGenerateCacheStats, a as getTailwindV3IncrementalGenerateCacheStats, h as resolveViteSourceScanEntries, ot as createDebug, u as getRuntimeClassSetSignature, ut as resolveTailwindcssOptions } from "./v3-engine-C6eJ0YzK.mjs";
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-ITLd7PTl.mjs";
|
|
3
|
-
import { b as refreshTailwindRuntimeState, d as _defineProperty, i as pluginName, n as getCompilerContext, r as resolveStyleOptionsFromContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-CRI90iL1.mjs";
|
|
4
|
-
import { r as getGroupedEntries } from "./utils-DodxWHGz.mjs";
|
|
5
|
-
import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-DTq3uYBK.mjs";
|
|
6
|
-
import { _ as createCssSourceTraceCacheSignature, a as createTailwindV3DefaultExtractor, b as processCachedTask, g as annotateCssSourceTrace, h as pruneMiniProgramGeneratedCss, l as pushConcurrentTaskFactories, m as finalizeMiniProgramCss, n as emitHmrTiming, o as createBundleRuntimeClassSetManager, p as isPureLocalCssImportWrapper, r as createSourceCandidateCollector, s as generateCssByGenerator, v as createCssTokenSourceMap, y as isCssSourceTraceEnabled } from "./hmr-timing-DQIP_8qP.mjs";
|
|
7
|
-
import { S as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePackageDir, f as resolvePluginDisabledState, n as createBundleBuildState, r as updateBundleBuildState, t as buildBundleSnapshot, u as stripBundlerGeneratedCssMarkers, v as isSourceStyleRequest, x as resolveOutputSpecifier, y as stripRequestQuery } from "./bundle-state-zQ2MrDdi.mjs";
|
|
8
|
-
import Module, { createRequire } from "node:module";
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import process from "node:process";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
import micromatch from "micromatch";
|
|
14
|
-
//#region src/shared/tailwindcss-css-redirect.ts
|
|
15
|
-
const moduleWithMutableResolve = Module;
|
|
16
|
-
const patched = /* @__PURE__ */ new WeakSet();
|
|
17
|
-
function installTailwindcssCssRedirect(pkgDir) {
|
|
18
|
-
const target = path.join(pkgDir, "index.css");
|
|
19
|
-
const original = moduleWithMutableResolve._resolveFilename;
|
|
20
|
-
if (patched.has(original)) return;
|
|
21
|
-
const replacements = new Set(["tailwindcss", "tailwindcss$"]);
|
|
22
|
-
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
23
|
-
if (replacements.has(request)) return target;
|
|
24
|
-
if (request.startsWith("tailwindcss/")) return path.join(pkgDir, request.slice(12));
|
|
25
|
-
return original(request, parent, isMain, options);
|
|
26
|
-
};
|
|
27
|
-
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
28
|
-
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/shared/mpx.ts
|
|
32
|
-
const localRequire = createRequire(import.meta.url);
|
|
33
|
-
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
34
|
-
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
35
|
-
function isMpxStyleResourceQuery(query) {
|
|
36
|
-
if (typeof query !== "string") return false;
|
|
37
|
-
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
38
|
-
}
|
|
39
|
-
function isMpx(appType) {
|
|
40
|
-
return appType === "mpx";
|
|
41
|
-
}
|
|
42
|
-
function getTailwindcssCssEntry(pkgDir) {
|
|
43
|
-
return path.join(pkgDir, "index.css");
|
|
44
|
-
}
|
|
45
|
-
function resolveMpxWebpackPluginDir(compiler) {
|
|
46
|
-
const candidates = [
|
|
47
|
-
compiler?.context,
|
|
48
|
-
compiler?.options?.context,
|
|
49
|
-
process.cwd()
|
|
50
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
51
|
-
for (const candidate of candidates) try {
|
|
52
|
-
const projectRequire = createRequire(path.join(candidate, "package.json"));
|
|
53
|
-
return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
54
|
-
} catch {}
|
|
55
|
-
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
56
|
-
if (cachedPackageJson) return path.dirname(cachedPackageJson);
|
|
57
|
-
try {
|
|
58
|
-
return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
59
|
-
} catch {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function isMpxWebpackPluginRequest(request) {
|
|
64
|
-
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
65
|
-
}
|
|
66
|
-
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
67
|
-
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
68
|
-
return path.join(mpxWebpackPluginDir, request.slice(22));
|
|
69
|
-
}
|
|
70
|
-
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
71
|
-
const recordLoader = path.join(pkgDir, "lib/record-loader");
|
|
72
|
-
const styleCompiler = path.join(pkgDir, "lib/style-compiler/index");
|
|
73
|
-
const stripConditionalLoader = path.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
74
|
-
if (Array.isArray(alias)) alias.push({
|
|
75
|
-
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
76
|
-
alias: recordLoader
|
|
77
|
-
}, {
|
|
78
|
-
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
79
|
-
alias: styleCompiler
|
|
80
|
-
}, {
|
|
81
|
-
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
82
|
-
alias: stripConditionalLoader
|
|
83
|
-
}, {
|
|
84
|
-
name: /^@mpxjs\/webpack-plugin\//,
|
|
85
|
-
alias: pkgDir
|
|
86
|
-
});
|
|
87
|
-
else {
|
|
88
|
-
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
89
|
-
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
90
|
-
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
91
|
-
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
92
|
-
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
96
|
-
compiler.options.resolveLoader = compiler.options.resolveLoader || {};
|
|
97
|
-
const alias = compiler.options.resolveLoader.alias ?? {};
|
|
98
|
-
compiler.options.resolveLoader.alias = alias;
|
|
99
|
-
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
100
|
-
}
|
|
101
|
-
function resolveMpxWebpackPluginRequire(compiler) {
|
|
102
|
-
const candidates = [
|
|
103
|
-
compiler?.context,
|
|
104
|
-
compiler?.options?.context,
|
|
105
|
-
process.cwd()
|
|
106
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
107
|
-
for (const candidate of candidates) try {
|
|
108
|
-
const projectRequire = createRequire(path.join(candidate, "package.json"));
|
|
109
|
-
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
110
|
-
return projectRequire;
|
|
111
|
-
} catch {}
|
|
112
|
-
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
113
|
-
if (cachedPackageJson) return createRequire(cachedPackageJson);
|
|
114
|
-
return localRequire;
|
|
115
|
-
}
|
|
116
|
-
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
117
|
-
if (!mpxWebpackPluginDir) return false;
|
|
118
|
-
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
119
|
-
let normalize;
|
|
120
|
-
try {
|
|
121
|
-
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
122
|
-
} catch {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
if (typeof normalize.lib !== "function") return false;
|
|
126
|
-
if (normalize.lib.__weappTwPatched) return true;
|
|
127
|
-
const wrappedLib = (file) => path.join(mpxWebpackPluginDir, "lib", file);
|
|
128
|
-
wrappedLib.__weappTwPatched = true;
|
|
129
|
-
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
130
|
-
normalize.lib = wrappedLib;
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
134
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
135
|
-
compiler.options = compiler.options || {};
|
|
136
|
-
compiler.options.resolve = compiler.options.resolve || {};
|
|
137
|
-
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
138
|
-
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
139
|
-
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
140
|
-
const alias = compiler.options.resolve.alias ?? {};
|
|
141
|
-
compiler.options.resolve.alias = alias;
|
|
142
|
-
if (Array.isArray(alias)) alias.push({
|
|
143
|
-
name: "tailwindcss",
|
|
144
|
-
alias: tailwindcssCssEntry
|
|
145
|
-
}, {
|
|
146
|
-
name: "tailwindcss$",
|
|
147
|
-
alias: tailwindcssCssEntry
|
|
148
|
-
});
|
|
149
|
-
else {
|
|
150
|
-
alias.tailwindcss = tailwindcssCssEntry;
|
|
151
|
-
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
152
|
-
}
|
|
153
|
-
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
154
|
-
return tailwindcssCssEntry;
|
|
155
|
-
}
|
|
156
|
-
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
157
|
-
if (!enabled || typeof loaderContext.resolve !== "function") return;
|
|
158
|
-
const originalResolve = loaderContext.resolve;
|
|
159
|
-
if (originalResolve.__weappTwPatched) return;
|
|
160
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
161
|
-
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
162
|
-
const wrappedResolve = function(context, request, callback) {
|
|
163
|
-
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
164
|
-
if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
|
|
165
|
-
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
166
|
-
return originalResolve.call(this, context, request, callback);
|
|
167
|
-
};
|
|
168
|
-
wrappedResolve.__weappTwPatched = true;
|
|
169
|
-
loaderContext.resolve = wrappedResolve;
|
|
170
|
-
}
|
|
171
|
-
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
172
|
-
if (enabled) installTailwindcssCssRedirect(pkgDir);
|
|
173
|
-
}
|
|
174
|
-
const CSS_EXT_RE = /\.css$/i;
|
|
175
|
-
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
176
|
-
var _compiler$options;
|
|
177
|
-
if (!loader) return;
|
|
178
|
-
const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
|
|
179
|
-
moduleOptions.rules = moduleOptions.rules || [];
|
|
180
|
-
const createRule = (match) => ({
|
|
181
|
-
...match,
|
|
182
|
-
enforce: "pre",
|
|
183
|
-
use: [{
|
|
184
|
-
loader,
|
|
185
|
-
options: loaderOptions
|
|
186
|
-
}]
|
|
187
|
-
});
|
|
188
|
-
moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
|
|
189
|
-
test: CSS_EXT_RE,
|
|
190
|
-
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
191
|
-
}));
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
|
|
195
|
-
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
|
|
196
|
-
function getCacheKey(filename) {
|
|
197
|
-
return filename;
|
|
198
|
-
}
|
|
199
|
-
function stripResourceQuery(resource) {
|
|
200
|
-
if (typeof resource !== "string") return resource;
|
|
201
|
-
return stripRequestQuery(resource);
|
|
202
|
-
}
|
|
203
|
-
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
204
|
-
if (typeof resource !== "string") return false;
|
|
205
|
-
const normalizedResource = stripResourceQuery(resource);
|
|
206
|
-
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
207
|
-
if (isSourceStyleRequest(resource)) return true;
|
|
208
|
-
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
function hasLoaderEntry(entries, target) {
|
|
212
|
-
if (!target) return false;
|
|
213
|
-
return entries.some((entry) => entry.loader?.includes?.(target));
|
|
214
|
-
}
|
|
215
|
-
function normalizeWatchPath(file) {
|
|
216
|
-
return path.resolve(file);
|
|
217
|
-
}
|
|
218
|
-
function isFileInContext(file, context) {
|
|
219
|
-
const relative = path.relative(normalizeWatchPath(context), normalizeWatchPath(file));
|
|
220
|
-
return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
221
|
-
}
|
|
222
|
-
function toChunkFiles(files) {
|
|
223
|
-
if (!files) return [];
|
|
224
|
-
if (Array.isArray(files)) return files;
|
|
225
|
-
return [...files];
|
|
226
|
-
}
|
|
227
|
-
function createAssetHashByChunkMap(chunks) {
|
|
228
|
-
const partsByFile = /* @__PURE__ */ new Map();
|
|
229
|
-
for (const chunk of chunks) {
|
|
230
|
-
const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
|
|
231
|
-
if (!hash) continue;
|
|
232
|
-
const chunkId = String(chunk.id ?? chunk.name ?? "");
|
|
233
|
-
for (const file of toChunkFiles(chunk.files)) {
|
|
234
|
-
if (!file) continue;
|
|
235
|
-
let parts = partsByFile.get(file);
|
|
236
|
-
if (!parts) {
|
|
237
|
-
parts = [];
|
|
238
|
-
partsByFile.set(file, parts);
|
|
239
|
-
}
|
|
240
|
-
parts.push(`${chunkId}:${hash}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const hashByFile = /* @__PURE__ */ new Map();
|
|
244
|
-
for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
|
|
245
|
-
return hashByFile;
|
|
246
|
-
}
|
|
247
|
-
function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
|
|
248
|
-
return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
|
|
249
|
-
}
|
|
250
|
-
function isWatchFileInRuntimeDependencies(file, dependencies) {
|
|
251
|
-
const normalizedFile = normalizeWatchPath(file);
|
|
252
|
-
for (const dependency of dependencies.files ?? []) if (normalizeWatchPath(dependency) === normalizedFile) return true;
|
|
253
|
-
for (const context of dependencies.contexts ?? []) if (isFileInContext(normalizedFile, context)) return true;
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.ts
|
|
258
|
-
function createWebpackSnapshotAssets(assets) {
|
|
259
|
-
return Object.fromEntries(Object.entries(assets).map(([file, asset]) => {
|
|
260
|
-
const source = asset.source();
|
|
261
|
-
return [file, {
|
|
262
|
-
fileName: file,
|
|
263
|
-
source: typeof source === "string" ? source : source?.toString() ?? "",
|
|
264
|
-
type: "asset"
|
|
265
|
-
}];
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
function stringifyWebpackSource(source) {
|
|
269
|
-
if (typeof source === "string") return source;
|
|
270
|
-
return source?.toString() ?? "";
|
|
271
|
-
}
|
|
272
|
-
function createWebpackAssetUpdater(options) {
|
|
273
|
-
const getCurrentAssetSource = (file) => {
|
|
274
|
-
const asset = options.compilation.getAsset(file);
|
|
275
|
-
if (!asset) return;
|
|
276
|
-
return stringifyWebpackSource(asset.source.source());
|
|
277
|
-
};
|
|
278
|
-
const updateAssetIfChanged = (file, source, { notifyUpdate = true } = {}) => {
|
|
279
|
-
const nextSource = typeof source === "string" ? source : stringifyWebpackSource(source.source());
|
|
280
|
-
const previousSource = getCurrentAssetSource(file);
|
|
281
|
-
if (previousSource === nextSource) {
|
|
282
|
-
options.debug("asset unchanged, skip update: %s", file);
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
options.compilation.updateAsset(file, typeof source === "string" ? new options.ConcatSource(source) : source);
|
|
286
|
-
if (notifyUpdate) options.onUpdate(file, previousSource ?? "", nextSource);
|
|
287
|
-
return true;
|
|
288
|
-
};
|
|
289
|
-
return {
|
|
290
|
-
getCurrentAssetSource,
|
|
291
|
-
updateAssetIfChanged
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
|
|
296
|
-
const WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX = 128;
|
|
297
|
-
function toMb(bytes) {
|
|
298
|
-
return Math.round(bytes / 1024 / 1024);
|
|
299
|
-
}
|
|
300
|
-
function pruneMapToMaxSize(map, maxSize) {
|
|
301
|
-
while (map.size > maxSize) {
|
|
302
|
-
const oldestKey = map.keys().next().value;
|
|
303
|
-
if (oldestKey === void 0) break;
|
|
304
|
-
map.delete(oldestKey);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
function pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles) {
|
|
308
|
-
const activeSuffixes = [...activeCssFiles].map((file) => `:${file}`);
|
|
309
|
-
for (const key of cssHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssHandlerOptionsCache.delete(key);
|
|
310
|
-
for (const key of cssUserHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssUserHandlerOptionsCache.delete(key);
|
|
311
|
-
pruneMapToMaxSize(cssHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
312
|
-
pruneMapToMaxSize(cssUserHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
313
|
-
}
|
|
314
|
-
function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
315
|
-
return cssHandlerOptions.sourceOptions?.sourceCss ?? rawSource;
|
|
316
|
-
}
|
|
317
|
-
function stripStyleExtension(file) {
|
|
318
|
-
const normalized = file.replace(/[?#].*$/, "");
|
|
319
|
-
const ext = path.extname(normalized);
|
|
320
|
-
return ext ? normalized.slice(0, -ext.length) : normalized;
|
|
321
|
-
}
|
|
322
|
-
function normalizeMatchPath(file) {
|
|
323
|
-
return file.split(path.sep).join("/");
|
|
324
|
-
}
|
|
325
|
-
function isPathWithinRoot(file, root) {
|
|
326
|
-
const relative = path.relative(root, file);
|
|
327
|
-
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
328
|
-
}
|
|
329
|
-
function collectWebpackCssMatchBases(file, roots) {
|
|
330
|
-
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
331
|
-
const bases = /* @__PURE__ */ new Set();
|
|
332
|
-
const addBase = (candidate) => {
|
|
333
|
-
const stripped = normalizeMatchPath(stripStyleExtension(candidate));
|
|
334
|
-
if (stripped.length > 0) {
|
|
335
|
-
bases.add(stripped);
|
|
336
|
-
const withoutWorkspaceSegment = stripped.replace(/^(?:src|dist)\//, "");
|
|
337
|
-
if (withoutWorkspaceSegment !== stripped && withoutWorkspaceSegment.length > 0) bases.add(withoutWorkspaceSegment);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
addBase(normalizedFile);
|
|
341
|
-
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => path.resolve(root));
|
|
342
|
-
if (path.isAbsolute(normalizedFile)) {
|
|
343
|
-
for (const root of resolvedRoots) if (isPathWithinRoot(normalizedFile, root)) addBase(path.relative(root, normalizedFile));
|
|
344
|
-
} else for (const root of resolvedRoots) addBase(path.resolve(root, normalizedFile));
|
|
345
|
-
return bases;
|
|
346
|
-
}
|
|
347
|
-
function scoreWebpackCssSourceFileMatch(outputFile, sourceFile, options) {
|
|
348
|
-
const outputBases = collectWebpackCssMatchBases(outputFile, [options.outputRoot, options.projectRoot]);
|
|
349
|
-
const sourceBases = collectWebpackCssMatchBases(sourceFile, [options.projectRoot]);
|
|
350
|
-
let bestScore = 0;
|
|
351
|
-
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
|
|
352
|
-
else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
353
|
-
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
354
|
-
return bestScore;
|
|
355
|
-
}
|
|
356
|
-
function resolveWebpackMemoryDebugStats(context) {
|
|
357
|
-
if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
|
|
358
|
-
const memory = process.memoryUsage();
|
|
359
|
-
return {
|
|
360
|
-
phase: context.phase,
|
|
361
|
-
process: {
|
|
362
|
-
rssMb: toMb(memory.rss),
|
|
363
|
-
heapTotalMb: toMb(memory.heapTotal),
|
|
364
|
-
heapUsedMb: toMb(memory.heapUsed),
|
|
365
|
-
externalMb: toMb(memory.external),
|
|
366
|
-
arrayBuffersMb: toMb(memory.arrayBuffers)
|
|
367
|
-
},
|
|
368
|
-
assets: {
|
|
369
|
-
active: context.activeAssetFiles,
|
|
370
|
-
activeCss: context.activeCssFiles
|
|
371
|
-
},
|
|
372
|
-
processCache: {
|
|
373
|
-
instance: context.cache.instance.size,
|
|
374
|
-
hashMap: context.cache.hashMap.size,
|
|
375
|
-
activeCacheKeys: context.activeProcessCacheKeys.size,
|
|
376
|
-
activeHashKeys: context.activeProcessHashKeys.size
|
|
377
|
-
},
|
|
378
|
-
webpackCss: {
|
|
379
|
-
handlerOptions: context.cssHandlerOptionsCache.size,
|
|
380
|
-
userHandlerOptions: context.cssUserHandlerOptionsCache.size,
|
|
381
|
-
maxHandlerOptions: WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX
|
|
382
|
-
},
|
|
383
|
-
tailwind: {
|
|
384
|
-
v3: getTailwindV3IncrementalGenerateCacheStats(),
|
|
385
|
-
v4: getTailwindV4IncrementalGenerateCacheStats()
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function setupWebpackV5ProcessAssetsHook(options) {
|
|
390
|
-
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, runtimeClassSetManager, getWebpackCssSources, debug } = options;
|
|
391
|
-
const { Compilation, sources } = compiler.webpack;
|
|
392
|
-
const { ConcatSource } = sources;
|
|
393
|
-
const isWebGeneratorTarget = compilerOptions.generator?.target === "web";
|
|
394
|
-
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
395
|
-
const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
396
|
-
const bundleBuildState = createBundleBuildState();
|
|
397
|
-
const bundleRuntimeClassSetManager = runtimeClassSetManager ?? createBundleRuntimeClassSetManager();
|
|
398
|
-
let webpackWatchRuntimeScanInitialized = false;
|
|
399
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
400
|
-
compilation.hooks.processAssets.tapPromise({
|
|
401
|
-
name: pluginName,
|
|
402
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
403
|
-
}, async (assets) => {
|
|
404
|
-
compilerOptions.onStart();
|
|
405
|
-
debug("start");
|
|
406
|
-
await runtimeState.readyPromise;
|
|
407
|
-
const hmrTimingStartedAt = performance.now();
|
|
408
|
-
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
409
|
-
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
410
|
-
const { updateAssetIfChanged } = createWebpackAssetUpdater({
|
|
411
|
-
compilation,
|
|
412
|
-
ConcatSource,
|
|
413
|
-
onUpdate: compilerOptions.onUpdate,
|
|
414
|
-
debug
|
|
415
|
-
});
|
|
416
|
-
const entries = Object.entries(assets);
|
|
417
|
-
const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
|
|
418
|
-
const outputDir = compilerOutputPath ? path.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? process.cwd();
|
|
419
|
-
const jsAssets = /* @__PURE__ */ new Map();
|
|
420
|
-
for (const [file] of entries) if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
|
|
421
|
-
const absolute = toAbsoluteOutputPath(file, outputDir);
|
|
422
|
-
jsAssets.set(absolute, file);
|
|
423
|
-
}
|
|
424
|
-
const moduleGraphOptions = {
|
|
425
|
-
resolve(specifier, importer) {
|
|
426
|
-
return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
427
|
-
},
|
|
428
|
-
load: (id) => {
|
|
429
|
-
const assetName = jsAssets.get(id);
|
|
430
|
-
if (!assetName) return;
|
|
431
|
-
const asset = compilation.getAsset(assetName);
|
|
432
|
-
if (!asset) return;
|
|
433
|
-
const source = asset.source.source();
|
|
434
|
-
return typeof source === "string" ? source : source.toString();
|
|
435
|
-
},
|
|
436
|
-
filter(id) {
|
|
437
|
-
return jsAssets.has(id);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
const applyLinkedResults = (linked) => {
|
|
441
|
-
if (!linked) return;
|
|
442
|
-
for (const [id, { code }] of Object.entries(linked)) {
|
|
443
|
-
const assetName = jsAssets.get(id);
|
|
444
|
-
if (!assetName) continue;
|
|
445
|
-
const asset = compilation.getAsset(assetName);
|
|
446
|
-
if (!asset) continue;
|
|
447
|
-
const previousSource = asset.source.source();
|
|
448
|
-
if ((typeof previousSource === "string" ? previousSource : previousSource.toString()) === code) continue;
|
|
449
|
-
if (updateAssetIfChanged(assetName, new ConcatSource(code))) debug("js linked handle: %s", assetName);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
const groupedEntries = getGroupedEntries(entries, compilerOptions);
|
|
453
|
-
const activeProcessCacheKeys = /* @__PURE__ */ new Set();
|
|
454
|
-
const activeProcessHashKeys = /* @__PURE__ */ new Set();
|
|
455
|
-
const rememberProcessCacheKey = (cacheKey, hashKey = cacheKey) => {
|
|
456
|
-
activeProcessCacheKeys.add(cacheKey);
|
|
457
|
-
activeProcessHashKeys.add(hashKey);
|
|
458
|
-
};
|
|
459
|
-
for (const chunk of compilation.chunks) if (chunk.id) activeProcessHashKeys.add(chunk.id);
|
|
460
|
-
const cssSources = new Map([...getWebpackCssSources?.() ?? []].map(([file, css]) => [path.resolve(file), css]));
|
|
461
|
-
const cssSourceFiles = [...cssSources.keys()].sort();
|
|
462
|
-
const resolveWebpackCssSourceFile = (file) => {
|
|
463
|
-
if (cssSourceFiles.length === 0) return;
|
|
464
|
-
const matches = cssSourceFiles.map((sourceFile) => ({
|
|
465
|
-
sourceFile,
|
|
466
|
-
score: scoreWebpackCssSourceFileMatch(file, sourceFile, {
|
|
467
|
-
outputRoot: outputDir,
|
|
468
|
-
projectRoot: compilerOptions.tailwindcssBasedir
|
|
469
|
-
})
|
|
470
|
-
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
|
|
471
|
-
const bestScore = matches[0]?.score ?? 0;
|
|
472
|
-
const bestMatches = matches.filter((match) => match.score === bestScore);
|
|
473
|
-
return bestMatches.length === 1 ? bestMatches[0]?.sourceFile : void 0;
|
|
474
|
-
};
|
|
475
|
-
const getCssHandlerOptions = (file) => {
|
|
476
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
477
|
-
const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
|
|
478
|
-
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
479
|
-
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
480
|
-
const cacheKey = [
|
|
481
|
-
majorVersion ?? "unknown",
|
|
482
|
-
isMainChunk ? "1" : "0",
|
|
483
|
-
sourceFile ?? "asset",
|
|
484
|
-
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
485
|
-
file
|
|
486
|
-
].join(":");
|
|
487
|
-
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
488
|
-
if (cached) return cached;
|
|
489
|
-
const created = {
|
|
490
|
-
isMainChunk,
|
|
491
|
-
postcssOptions: { options: { from: sourceFile ?? file } },
|
|
492
|
-
sourceOptions: {
|
|
493
|
-
outputRoot: outputDir,
|
|
494
|
-
...sourceCss === void 0 ? {} : { sourceCss },
|
|
495
|
-
...sourceFile === void 0 ? {} : { sourceFile }
|
|
496
|
-
},
|
|
497
|
-
...majorVersion === void 0 ? {} : { majorVersion }
|
|
498
|
-
};
|
|
499
|
-
cssHandlerOptionsCache.set(cacheKey, created);
|
|
500
|
-
return created;
|
|
501
|
-
};
|
|
502
|
-
const getCssUserHandlerOptions = (file) => {
|
|
503
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
504
|
-
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
505
|
-
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
506
|
-
const cacheKey = [
|
|
507
|
-
majorVersion ?? "unknown",
|
|
508
|
-
sourceFile ?? "asset",
|
|
509
|
-
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
510
|
-
file
|
|
511
|
-
].join(":");
|
|
512
|
-
const cached = cssUserHandlerOptionsCache.get(cacheKey);
|
|
513
|
-
if (cached) return cached;
|
|
514
|
-
const created = {
|
|
515
|
-
...getCssHandlerOptions(file),
|
|
516
|
-
isMainChunk: false
|
|
517
|
-
};
|
|
518
|
-
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
519
|
-
return created;
|
|
520
|
-
};
|
|
521
|
-
const refreshWebpackSourceCandidates = async () => {
|
|
522
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
523
|
-
if (majorVersion !== 3 && majorVersion !== 4) return;
|
|
524
|
-
const root = compilerOptions.tailwindcssBasedir ?? process.cwd();
|
|
525
|
-
let sourceScan;
|
|
526
|
-
try {
|
|
527
|
-
sourceScan = await resolveViteSourceScanEntries(compilerOptions, runtimeState.twPatcher, {
|
|
528
|
-
root,
|
|
529
|
-
outDir: outputDir
|
|
530
|
-
});
|
|
531
|
-
} catch (error) {
|
|
532
|
-
debug("webpack source candidate scan skipped: %O", error);
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const collector = createSourceCandidateCollector({
|
|
536
|
-
bareArbitraryValues: compilerOptions.arbitraryValues?.bareArbitraryValues,
|
|
537
|
-
extractor: majorVersion === 3 ? createTailwindV3DefaultExtractor() : void 0
|
|
538
|
-
});
|
|
539
|
-
await collector.scanRoot({
|
|
540
|
-
entries: sourceScan?.entries,
|
|
541
|
-
explicit: sourceScan?.explicit,
|
|
542
|
-
root,
|
|
543
|
-
outDir: outputDir
|
|
544
|
-
});
|
|
545
|
-
collector.syncInline(sourceScan?.inlineCandidates);
|
|
546
|
-
const candidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
|
|
547
|
-
return {
|
|
548
|
-
candidates,
|
|
549
|
-
getSourceCandidatesForEntries: (entries, options) => collector.valuesForEntries(entries, options),
|
|
550
|
-
signature: compilerOptions.cache.computeHash(JSON.stringify({
|
|
551
|
-
root,
|
|
552
|
-
outDir: outputDir,
|
|
553
|
-
entries: sourceScan?.entries,
|
|
554
|
-
explicit: sourceScan?.explicit ?? false,
|
|
555
|
-
inlineCandidates: sourceScan?.inlineCandidates ? {
|
|
556
|
-
included: [...sourceScan.inlineCandidates.included].sort(),
|
|
557
|
-
excluded: [...sourceScan.inlineCandidates.excluded].sort()
|
|
558
|
-
} : void 0,
|
|
559
|
-
dependencies: [...sourceScan?.dependencies ?? []].sort(),
|
|
560
|
-
candidates: [...candidates].sort()
|
|
561
|
-
})),
|
|
562
|
-
tokenSources: collector.sourcesForEntries(sourceScan?.entries)
|
|
563
|
-
};
|
|
564
|
-
};
|
|
565
|
-
const finalizeCssAssetSource = (source, options = {}) => {
|
|
566
|
-
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
567
|
-
let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
568
|
-
if (isWebGeneratorTarget || options.generatedCss !== true) return finalized;
|
|
569
|
-
try {
|
|
570
|
-
finalized = pruneMiniProgramGeneratedCss(finalized, { preservePreflight: runtimeState.twPatcher.majorVersion === 3 });
|
|
571
|
-
} catch {
|
|
572
|
-
finalized = finalizeMiniProgramCss(finalized, {
|
|
573
|
-
cssPreflight: runtimeState.twPatcher.majorVersion === 4 ? compilerOptions.cssPreflight : void 0,
|
|
574
|
-
isTailwindcssV4: runtimeState.twPatcher.majorVersion === 4,
|
|
575
|
-
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3,
|
|
576
|
-
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
return finalized;
|
|
580
|
-
};
|
|
581
|
-
const finalizeMiniProgramUserCssAssetSource = (source) => {
|
|
582
|
-
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
583
|
-
if (isWebGeneratorTarget) return source;
|
|
584
|
-
return finalizeMiniProgramCss(source, {
|
|
585
|
-
cssPreflight: runtimeState.twPatcher.majorVersion === 4 ? compilerOptions.cssPreflight : void 0,
|
|
586
|
-
isTailwindcssV4: runtimeState.twPatcher.majorVersion === 4,
|
|
587
|
-
preservePseudoContentInit: runtimeState.twPatcher.majorVersion === 3,
|
|
588
|
-
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
589
|
-
});
|
|
590
|
-
};
|
|
591
|
-
const webpackSourceCandidates = groupedEntries.css?.length || isCssSourceTraceEnabled(compilerOptions) ? await refreshWebpackSourceCandidates() : void 0;
|
|
592
|
-
const cssSourceTraceTokenSources = isCssSourceTraceEnabled(compilerOptions) && webpackSourceCandidates ? createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions) : void 0;
|
|
593
|
-
const cssSourceTraceSignature = createCssSourceTraceCacheSignature(cssSourceTraceTokenSources, compilerOptions);
|
|
594
|
-
const annotateCss = (css) => annotateCssSourceTrace(css, {
|
|
595
|
-
opts: compilerOptions,
|
|
596
|
-
tokenSources: cssSourceTraceTokenSources
|
|
597
|
-
});
|
|
598
|
-
const finalizeTracedCss = (css) => {
|
|
599
|
-
const traced = annotateCss(css);
|
|
600
|
-
if (isWebGeneratorTarget || !isCssSourceTraceEnabled(compilerOptions)) return traced;
|
|
601
|
-
return finalizeMiniProgramUserCssAssetSource(traced);
|
|
602
|
-
};
|
|
603
|
-
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
604
|
-
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
|
|
605
|
-
let runtimeSet;
|
|
606
|
-
const watchMode = isWatchMode?.() === true;
|
|
607
|
-
if (watchMode && runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) {
|
|
608
|
-
const snapshot = buildBundleSnapshot(createWebpackSnapshotAssets(assets), compilerOptions, outputDir, bundleBuildState);
|
|
609
|
-
if (!webpackWatchRuntimeScanInitialized) {
|
|
610
|
-
for (const entry of snapshot.entries) if (entry.type === "html" || entry.type === "js") snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
|
|
611
|
-
}
|
|
612
|
-
try {
|
|
613
|
-
runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
614
|
-
} catch (error) {
|
|
615
|
-
debug("webpack incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
616
|
-
await bundleRuntimeClassSetManager.reset();
|
|
617
|
-
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
618
|
-
forceRefresh: false,
|
|
619
|
-
forceCollect: true,
|
|
620
|
-
clearCache: false,
|
|
621
|
-
allowEmpty: false
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
updateBundleBuildState(bundleBuildState, snapshot, /* @__PURE__ */ new Map(), { incremental: true });
|
|
625
|
-
webpackWatchRuntimeScanInitialized = true;
|
|
626
|
-
} else {
|
|
627
|
-
if (forceRuntimeRefresh) {
|
|
628
|
-
await bundleRuntimeClassSetManager.reset();
|
|
629
|
-
webpackWatchRuntimeScanInitialized = false;
|
|
630
|
-
}
|
|
631
|
-
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
632
|
-
forceRefresh: forceRuntimeRefresh,
|
|
633
|
-
forceCollect: !watchMode || forceRuntimeRefresh,
|
|
634
|
-
clearCache: forceRuntimeRefresh,
|
|
635
|
-
allowEmpty: false
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
639
|
-
consumeRuntimeRefreshRequirement();
|
|
640
|
-
const runtimeSetHash = compilerOptions.cache.computeHash([getRuntimeClassSetSignature(runtimeState.twPatcher), [...runtimeSet].sort().join("\n")].join("\n\n"));
|
|
641
|
-
const defaultTemplateHandlerOptions = { runtimeSet };
|
|
642
|
-
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
643
|
-
const tasks = [];
|
|
644
|
-
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
|
|
645
|
-
const [file, originalSource] = element;
|
|
646
|
-
const rawSource = originalSource.source().toString();
|
|
647
|
-
const cacheKey = file;
|
|
648
|
-
const hashKey = `${file}:asset`;
|
|
649
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
650
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
651
|
-
tasks.push(processCachedTask({
|
|
652
|
-
cache: compilerOptions.cache,
|
|
653
|
-
cacheKey,
|
|
654
|
-
hashKey,
|
|
655
|
-
rawSource,
|
|
656
|
-
hash: chunkHash,
|
|
657
|
-
applyResult(source, { cacheHit }) {
|
|
658
|
-
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
659
|
-
},
|
|
660
|
-
onCacheHit() {
|
|
661
|
-
debug("html cache hit: %s", file);
|
|
662
|
-
},
|
|
663
|
-
transform: async () => {
|
|
664
|
-
const source = new ConcatSource(await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions));
|
|
665
|
-
debug("html handle: %s", file);
|
|
666
|
-
return { result: source };
|
|
667
|
-
}
|
|
668
|
-
}));
|
|
669
|
-
}
|
|
670
|
-
const jsTaskFactories = [];
|
|
671
|
-
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
|
|
672
|
-
const cacheKey = getCacheKey(file);
|
|
673
|
-
const asset = compilation.getAsset(file);
|
|
674
|
-
if (!asset) continue;
|
|
675
|
-
const hashKey = `${file}:asset`;
|
|
676
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
677
|
-
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
678
|
-
const initialSource = asset.source.source();
|
|
679
|
-
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
680
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
681
|
-
jsTaskFactories.push(async () => {
|
|
682
|
-
await processCachedTask({
|
|
683
|
-
cache: compilerOptions.cache,
|
|
684
|
-
cacheKey,
|
|
685
|
-
hashKey,
|
|
686
|
-
rawSource: initialRawSource,
|
|
687
|
-
hash: chunkHash,
|
|
688
|
-
applyResult(source, { cacheHit }) {
|
|
689
|
-
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
690
|
-
},
|
|
691
|
-
onCacheHit() {
|
|
692
|
-
debug("js cache hit: %s", file);
|
|
693
|
-
},
|
|
694
|
-
transform: async () => {
|
|
695
|
-
const currentSourceValue = compilation.getAsset(file)?.source.source();
|
|
696
|
-
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
|
|
697
|
-
const handlerOptions = {
|
|
698
|
-
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
699
|
-
filename: absoluteFile,
|
|
700
|
-
moduleGraph: moduleGraphOptions,
|
|
701
|
-
babelParserOptions: { sourceFilename: absoluteFile }
|
|
702
|
-
};
|
|
703
|
-
if (shouldSkipJsTransform(currentSource, {
|
|
704
|
-
...handlerOptions,
|
|
705
|
-
classNameSet: runtimeSet
|
|
706
|
-
})) return { result: new ConcatSource(currentSource) };
|
|
707
|
-
const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
708
|
-
const source = new ConcatSource(code);
|
|
709
|
-
debug("js handle: %s", file);
|
|
710
|
-
applyLinkedResults(linked);
|
|
711
|
-
return { result: source };
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
|
|
717
|
-
const [file, originalSource] = element;
|
|
718
|
-
const rawSource = originalSource.source().toString();
|
|
719
|
-
if (isWebpackProcessedCssAsset?.(file, rawSource)) {
|
|
720
|
-
const nextCss = finalizeCssAssetSource(rawSource, { generatedCss: hasBundlerGeneratedCssMarker(rawSource) });
|
|
721
|
-
const hashKey = `${file}:asset`;
|
|
722
|
-
rememberProcessCacheKey(file, hashKey);
|
|
723
|
-
tasks.push(processCachedTask({
|
|
724
|
-
cache: compilerOptions.cache,
|
|
725
|
-
cacheKey: file,
|
|
726
|
-
hashKey,
|
|
727
|
-
rawSource,
|
|
728
|
-
hash: createRuntimeAwareCssHash(assetHashByChunk.get(file), compilerOptions.cache.computeHash(rawSource), `${runtimeSetHash}:${cssSourceTraceSignature}`),
|
|
729
|
-
applyResult(source, { cacheHit }) {
|
|
730
|
-
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
731
|
-
},
|
|
732
|
-
onCacheHit() {
|
|
733
|
-
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
734
|
-
},
|
|
735
|
-
transform: async () => {
|
|
736
|
-
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
737
|
-
return { result: new ConcatSource(finalizeTracedCss(nextCss)) };
|
|
738
|
-
}
|
|
739
|
-
}));
|
|
740
|
-
continue;
|
|
741
|
-
}
|
|
742
|
-
if (isWebGeneratorTarget) continue;
|
|
743
|
-
const cacheKey = file;
|
|
744
|
-
const hashKey = `${file}:asset`;
|
|
745
|
-
rememberProcessCacheKey(cacheKey, hashKey);
|
|
746
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
747
|
-
const cssSourceHash = (() => {
|
|
748
|
-
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
749
|
-
const sourceCss = sourceFile ? cssSources.get(sourceFile) : void 0;
|
|
750
|
-
return sourceCss === void 0 ? "webpack-css-source:0" : `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}`;
|
|
751
|
-
})();
|
|
752
|
-
const runtimeAwareHash = createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(rawSource), `${runtimeSetHash}:${webpackSourceCandidates?.signature ?? "source-candidates:0"}:${cssSourceTraceSignature}:${cssSourceHash}`);
|
|
753
|
-
tasks.push(processCachedTask({
|
|
754
|
-
cache: compilerOptions.cache,
|
|
755
|
-
cacheKey,
|
|
756
|
-
hashKey,
|
|
757
|
-
rawSource,
|
|
758
|
-
hash: runtimeAwareHash,
|
|
759
|
-
applyResult(source, { cacheHit }) {
|
|
760
|
-
updateAssetIfChanged(file, source, { notifyUpdate: !cacheHit });
|
|
761
|
-
},
|
|
762
|
-
onCacheHit() {
|
|
763
|
-
debug("css cache hit: %s", file);
|
|
764
|
-
},
|
|
765
|
-
transform: async () => {
|
|
766
|
-
await runtimeState.readyPromise;
|
|
767
|
-
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
768
|
-
const generatorRawSource = resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions);
|
|
769
|
-
if (isPureLocalCssImportWrapper(rawSource)) return { result: new ConcatSource(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(rawSource), { importFallback: true })) };
|
|
770
|
-
const generated = await generateCssByGenerator({
|
|
771
|
-
opts: compilerOptions,
|
|
772
|
-
runtimeState,
|
|
773
|
-
runtime: runtimeSet,
|
|
774
|
-
rawSource: generatorRawSource,
|
|
775
|
-
file,
|
|
776
|
-
cssHandlerOptions,
|
|
777
|
-
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
778
|
-
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
779
|
-
styleHandler: compilerOptions.styleHandler,
|
|
780
|
-
debug
|
|
781
|
-
});
|
|
782
|
-
const source = new ConcatSource(finalizeTracedCss(generated?.css ?? finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false })));
|
|
783
|
-
if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
|
|
784
|
-
else debug("css handle: %s", file);
|
|
785
|
-
return { result: source };
|
|
786
|
-
}
|
|
787
|
-
}));
|
|
788
|
-
}
|
|
789
|
-
pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
790
|
-
await Promise.all(tasks);
|
|
791
|
-
compilerOptions.cache.prune?.({
|
|
792
|
-
cacheKeys: activeProcessCacheKeys,
|
|
793
|
-
hashKeys: activeProcessHashKeys
|
|
794
|
-
});
|
|
795
|
-
const activeCssFiles = new Set(groupedEntries.css?.map(([file]) => file) ?? []);
|
|
796
|
-
pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
|
|
797
|
-
debug("end");
|
|
798
|
-
emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, { memoryDebug: resolveWebpackMemoryDebugStats({
|
|
799
|
-
activeAssetFiles: entries.length,
|
|
800
|
-
activeCssFiles: activeCssFiles.size,
|
|
801
|
-
activeProcessCacheKeys,
|
|
802
|
-
activeProcessHashKeys,
|
|
803
|
-
cache: compilerOptions.cache,
|
|
804
|
-
cssHandlerOptionsCache,
|
|
805
|
-
cssUserHandlerOptionsCache,
|
|
806
|
-
phase: "processAssets"
|
|
807
|
-
}) });
|
|
808
|
-
compilerOptions.onEnd();
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
//#endregion
|
|
813
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.2_oxc-resolver@11.20.0_tsx@4.22.4_typescript@6.0.3_unrun@0.2.37_synckit@0.1_c2142480ddc0e0584f1991298dd762a0/node_modules/tsdown/esm-shims.js
|
|
814
|
-
const getFilename = () => fileURLToPath(import.meta.url);
|
|
815
|
-
const getDirname = () => path.dirname(getFilename());
|
|
816
|
-
const __dirname = /* @__PURE__ */ getDirname();
|
|
817
|
-
//#endregion
|
|
818
|
-
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
819
|
-
const runtimeRegistryHolder = globalThis;
|
|
820
|
-
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
821
|
-
function setWebpackLoaderRuntime(key, entry) {
|
|
822
|
-
runtimeRegistry.set(key, entry);
|
|
823
|
-
}
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region src/bundlers/webpack/shared/loader-anchors.ts
|
|
826
|
-
const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
827
|
-
const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
828
|
-
const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
|
|
829
|
-
function createFinder(targets) {
|
|
830
|
-
return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
|
|
831
|
-
}
|
|
832
|
-
function createPrioritizedFinder(targets) {
|
|
833
|
-
return (entries) => {
|
|
834
|
-
for (const target of targets) {
|
|
835
|
-
const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
|
|
836
|
-
if (idx !== -1) return idx;
|
|
837
|
-
}
|
|
838
|
-
return -1;
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
function createLoaderAnchorFinders(appType) {
|
|
842
|
-
if (isMpx(appType)) return {
|
|
843
|
-
findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
|
|
844
|
-
findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
|
|
845
|
-
};
|
|
846
|
-
const fallbackFinder = createFinder(["postcss-loader"]);
|
|
847
|
-
return {
|
|
848
|
-
findRewriteAnchor: fallbackFinder,
|
|
849
|
-
findClassSetAnchor: fallbackFinder
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
854
|
-
function setupWebpackV5Loaders(options) {
|
|
855
|
-
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;
|
|
856
|
-
const isMpxApp = isMpx(appType);
|
|
857
|
-
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
858
|
-
const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
859
|
-
const shouldInjectRuntimeClassSetLoader = compilerOptions.generator?.target !== "web";
|
|
860
|
-
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
861
|
-
const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
|
|
862
|
-
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
863
|
-
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
864
|
-
pkgDir: weappTailwindcssPackageDir,
|
|
865
|
-
compilerOptions,
|
|
866
|
-
runtimeState,
|
|
867
|
-
...appType === void 0 ? {} : { appType },
|
|
868
|
-
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource },
|
|
869
|
-
getRuntimeSet: getRuntimeSetInLoader,
|
|
870
|
-
...markWebpackProcessedCssSource === void 0 ? {} : { markGeneratedCssSource: markWebpackProcessedCssSource }
|
|
871
|
-
} : void 0;
|
|
872
|
-
setWebpackLoaderRuntime(runtimeRegistryKey, {
|
|
873
|
-
classSet: {
|
|
874
|
-
getClassSet: getClassSetInLoader,
|
|
875
|
-
getWatchDependencies: getRuntimeWatchDependencies,
|
|
876
|
-
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile }
|
|
877
|
-
},
|
|
878
|
-
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
879
|
-
});
|
|
880
|
-
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
881
|
-
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewriteRuntimeKey: runtimeRegistryKey } : void 0;
|
|
882
|
-
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
883
|
-
const createRuntimeClassSetLoaderEntry = () => ({
|
|
884
|
-
loader: runtimeClassSetLoader,
|
|
885
|
-
options: { weappTailwindcssRuntimeKey: runtimeRegistryKey },
|
|
886
|
-
ident: null,
|
|
887
|
-
type: null
|
|
888
|
-
});
|
|
889
|
-
const createCssImportRewriteLoaderEntry = () => {
|
|
890
|
-
if (!runtimeCssImportRewriteLoader || !cssImportRewriteLoaderOptions) return null;
|
|
891
|
-
return {
|
|
892
|
-
loader: runtimeCssImportRewriteLoader,
|
|
893
|
-
options: cssImportRewriteLoaderOptions,
|
|
894
|
-
ident: null,
|
|
895
|
-
type: null
|
|
896
|
-
};
|
|
897
|
-
};
|
|
898
|
-
const { NormalModule } = compiler.webpack;
|
|
899
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
900
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
|
|
901
|
-
if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
|
|
902
|
-
patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
|
|
903
|
-
const loaderEntries = module.loaders || [];
|
|
904
|
-
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
905
|
-
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
906
|
-
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
907
|
-
if (process.env["WEAPP_TW_LOADER_DEBUG"] && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
908
|
-
rewriteAnchorIdx,
|
|
909
|
-
classSetAnchorIdx
|
|
910
|
-
});
|
|
911
|
-
if (process.env["WEAPP_TW_LOADER_DEBUG"] && typeof module.resource === "string" && module.resource.includes("app.css")) debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), {
|
|
912
|
-
rewriteAnchorIdx,
|
|
913
|
-
classSetAnchorIdx
|
|
914
|
-
});
|
|
915
|
-
else if (process.env["WEAPP_TW_LOADER_DEBUG"] && typeof module.resource === "string" && module.resource.endsWith(".css")) debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
916
|
-
rewriteAnchorIdx,
|
|
917
|
-
classSetAnchorIdx
|
|
918
|
-
});
|
|
919
|
-
if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) return;
|
|
920
|
-
const anchorlessInsert = (entry, position) => {
|
|
921
|
-
if (position === "after") loaderEntries.push(entry);
|
|
922
|
-
else loaderEntries.unshift(entry);
|
|
923
|
-
};
|
|
924
|
-
if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader) {
|
|
925
|
-
const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
|
|
926
|
-
const rewriteLoaderEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
|
|
927
|
-
if (rewriteLoaderEntry) {
|
|
928
|
-
const anchorIndex = findRewriteAnchor(loaderEntries);
|
|
929
|
-
if (anchorIndex === -1) anchorlessInsert(rewriteLoaderEntry, "after");
|
|
930
|
-
else loaderEntries.splice(anchorIndex + 1, 0, rewriteLoaderEntry);
|
|
931
|
-
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
if (shouldInjectRuntimeClassSetLoader && runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
|
|
935
|
-
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
936
|
-
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
937
|
-
if (anchorIndex === -1) anchorlessInsert(classSetLoaderEntry, "before");
|
|
938
|
-
else {
|
|
939
|
-
const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
|
|
940
|
-
loaderEntries.splice(insertIndex, 0, classSetLoaderEntry);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
});
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
//#endregion
|
|
947
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
948
|
-
const debug = createDebug();
|
|
949
|
-
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
950
|
-
const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
|
|
951
|
-
function normalizeIgnoredList(ignored) {
|
|
952
|
-
return (Array.isArray(ignored) ? [...ignored] : [ignored]).filter((item) => typeof item === "string" || item instanceof RegExp || typeof item === "function");
|
|
953
|
-
}
|
|
954
|
-
function createOutputIgnoredPredicate(ignoredList, ignoredPath) {
|
|
955
|
-
const predicate = (file) => {
|
|
956
|
-
const resolvedFile = path.resolve(file);
|
|
957
|
-
if (resolvedFile === ignoredPath || resolvedFile.startsWith(`${ignoredPath}${path.sep}`)) return true;
|
|
958
|
-
const normalizedFile = file.replace(/\\/g, "/");
|
|
959
|
-
return ignoredList.some((item) => {
|
|
960
|
-
if (typeof item === "string") {
|
|
961
|
-
const resolvedItem = path.resolve(item);
|
|
962
|
-
if (resolvedFile === resolvedItem || resolvedFile.startsWith(`${resolvedItem}${path.sep}`)) return true;
|
|
963
|
-
return micromatch.isMatch(normalizedFile, item);
|
|
964
|
-
}
|
|
965
|
-
if (item instanceof RegExp) return item.test(normalizedFile);
|
|
966
|
-
return item(file);
|
|
967
|
-
});
|
|
968
|
-
};
|
|
969
|
-
predicate[outputIgnoredPredicatePath] = ignoredPath;
|
|
970
|
-
return predicate;
|
|
971
|
-
}
|
|
972
|
-
function appendIgnoredPath(ignored, ignoredPath) {
|
|
973
|
-
if (typeof ignored === "function" && ignored[outputIgnoredPredicatePath] === ignoredPath) return ignored;
|
|
974
|
-
const ignoredList = normalizeIgnoredList(ignored);
|
|
975
|
-
if (ignoredList.some((item) => typeof item !== "string")) return createOutputIgnoredPredicate(ignoredList, ignoredPath);
|
|
976
|
-
if (ignoredList.some((item) => typeof item === "string" && path.resolve(item) === ignoredPath)) return ignored;
|
|
977
|
-
return [...ignoredList, ignoredPath];
|
|
978
|
-
}
|
|
979
|
-
function setupWebpackWatchOutputIgnore(compiler) {
|
|
980
|
-
const appendOutputIgnoredPath = (watchOptions) => {
|
|
981
|
-
const outputPath = compiler.outputPath || compiler.options?.output?.path;
|
|
982
|
-
const outputDir = outputPath ? path.resolve(outputPath) : void 0;
|
|
983
|
-
if (!outputDir) return watchOptions;
|
|
984
|
-
if (watchOptions && typeof watchOptions === "object") {
|
|
985
|
-
const nextIgnored = appendIgnoredPath(watchOptions.ignored, outputDir);
|
|
986
|
-
if (nextIgnored === void 0) delete watchOptions.ignored;
|
|
987
|
-
else watchOptions.ignored = nextIgnored;
|
|
988
|
-
return watchOptions;
|
|
989
|
-
}
|
|
990
|
-
return { ignored: appendIgnoredPath(void 0, outputDir) };
|
|
991
|
-
};
|
|
992
|
-
const compilerWatchOptions = appendOutputIgnoredPath(compiler.options.watchOptions);
|
|
993
|
-
if (compilerWatchOptions) compiler.options.watchOptions = compilerWatchOptions;
|
|
994
|
-
const syncOutputIgnoredPath = () => {
|
|
995
|
-
const outputPath = compiler.outputPath || compiler.options?.output?.path;
|
|
996
|
-
if (!(outputPath ? path.resolve(outputPath) : void 0)) return;
|
|
997
|
-
const watchOptions = compiler.watching?.watchOptions;
|
|
998
|
-
if (watchOptions) appendOutputIgnoredPath(watchOptions);
|
|
999
|
-
};
|
|
1000
|
-
compiler.hooks.watchRun?.tap(pluginName, syncOutputIgnoredPath);
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* @name WeappTailwindcss
|
|
1004
|
-
* @description webpack5 核心转义插件
|
|
1005
|
-
* @link https://tw.icebreaker.top/docs/intro
|
|
1006
|
-
*/
|
|
1007
|
-
var WeappTailwindcss = class {
|
|
1008
|
-
constructor(options = {}) {
|
|
1009
|
-
_defineProperty(this, "options", void 0);
|
|
1010
|
-
_defineProperty(this, "appType", void 0);
|
|
1011
|
-
_defineProperty(this, "hasInitialTailwindCssRoots", void 0);
|
|
1012
|
-
this.hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots(options);
|
|
1013
|
-
this.options = getCompilerContext({
|
|
1014
|
-
...options,
|
|
1015
|
-
__internalDeferMissingCssEntriesWarning: true
|
|
1016
|
-
});
|
|
1017
|
-
this.appType = this.options.appType;
|
|
1018
|
-
}
|
|
1019
|
-
apply(compiler) {
|
|
1020
|
-
compiler.options = compiler.options || {};
|
|
1021
|
-
const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
|
|
1022
|
-
const disabledOptions = resolvePluginDisabledState(disabled);
|
|
1023
|
-
const isTailwindcssV4 = (initialTwPatcher.majorVersion ?? 0) >= 4;
|
|
1024
|
-
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(this.options.generator);
|
|
1025
|
-
const shouldRewriteCssImports = isTailwindcssV4 || generatorOptions.target === "web";
|
|
1026
|
-
const isMpxApp = isMpx(this.appType);
|
|
1027
|
-
if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
1028
|
-
if (disabledOptions.plugin) return;
|
|
1029
|
-
setupWebpackWatchOutputIgnore(compiler);
|
|
1030
|
-
const runtimeState = {
|
|
1031
|
-
twPatcher: initialTwPatcher,
|
|
1032
|
-
readyPromise: createTailwindRuntimeReadyPromise(initialTwPatcher),
|
|
1033
|
-
refreshTailwindcssPatcher
|
|
1034
|
-
};
|
|
1035
|
-
let runtimeSetPrepared = false;
|
|
1036
|
-
let runtimeSetSignature;
|
|
1037
|
-
let runtimeRefreshRequiredForCompilation = false;
|
|
1038
|
-
let watchRunObserved = false;
|
|
1039
|
-
const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
|
|
1040
|
-
const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
|
|
1041
|
-
const webpackProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
1042
|
-
const webpackCssSources = /* @__PURE__ */ new Map();
|
|
1043
|
-
let runtimeMetadataPrepared = false;
|
|
1044
|
-
const updateRuntimeWatchDependencies = async () => {
|
|
1045
|
-
runtimeWatchDependencyFiles.clear();
|
|
1046
|
-
runtimeWatchDependencyContexts.clear();
|
|
1047
|
-
const tailwindOptions = resolveTailwindcssOptions(runtimeState.twPatcher.options);
|
|
1048
|
-
if (tailwindOptions?.config) runtimeWatchDependencyFiles.add(tailwindOptions.config);
|
|
1049
|
-
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) runtimeWatchDependencyFiles.add(entry);
|
|
1050
|
-
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
1051
|
-
if (source.file) runtimeWatchDependencyFiles.add(source.file);
|
|
1052
|
-
for (const dependency of source.dependencies ?? []) runtimeWatchDependencyFiles.add(dependency);
|
|
1053
|
-
}
|
|
1054
|
-
for (const source of tailwindOptions?.v4?.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
|
|
1055
|
-
if (typeof runtimeState.twPatcher.collectContentTokens !== "function") return;
|
|
1056
|
-
try {
|
|
1057
|
-
const report = await runtimeState.twPatcher.collectContentTokens();
|
|
1058
|
-
for (const entry of report.entries ?? []) if (entry.file) runtimeWatchDependencyFiles.add(entry.file);
|
|
1059
|
-
for (const source of report.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
|
|
1060
|
-
} catch (error) {
|
|
1061
|
-
debug("collect runtime watch dependencies failed: %O", error);
|
|
1062
|
-
}
|
|
1063
|
-
};
|
|
1064
|
-
const ensureRuntimeMetadata = async (force = false) => {
|
|
1065
|
-
if (runtimeMetadataPrepared && !force) return;
|
|
1066
|
-
await updateRuntimeWatchDependencies();
|
|
1067
|
-
runtimeMetadataPrepared = true;
|
|
1068
|
-
};
|
|
1069
|
-
const collectWatchChangedFiles = () => {
|
|
1070
|
-
const compilerLike = compiler;
|
|
1071
|
-
return new Set([...compilerLike.modifiedFiles ?? [], ...compilerLike.removedFiles ?? []]);
|
|
1072
|
-
};
|
|
1073
|
-
const hasRuntimeDependencyChanges = (files) => {
|
|
1074
|
-
for (const file of files) if (isWatchFileInRuntimeDependencies(file, {
|
|
1075
|
-
contexts: runtimeWatchDependencyContexts,
|
|
1076
|
-
files: runtimeWatchDependencyFiles
|
|
1077
|
-
})) return true;
|
|
1078
|
-
return false;
|
|
1079
|
-
};
|
|
1080
|
-
const syncRuntimeRefreshRequirement = (markWatchRun = false) => {
|
|
1081
|
-
if (markWatchRun) watchRunObserved = true;
|
|
1082
|
-
const changedFiles = collectWatchChangedFiles();
|
|
1083
|
-
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges(changedFiles);
|
|
1084
|
-
};
|
|
1085
|
-
const resetRuntimePreparation = () => {
|
|
1086
|
-
runtimeSetPrepared = false;
|
|
1087
|
-
syncRuntimeRefreshRequirement();
|
|
1088
|
-
};
|
|
1089
|
-
const registerAutoCssSource = async (source) => {
|
|
1090
|
-
if ((runtimeState.twPatcher.majorVersion ?? 0) < 4 || !source.file) return;
|
|
1091
|
-
if (!upsertTailwindV4CssSource(this.options, source)) return;
|
|
1092
|
-
runtimeSetPrepared = false;
|
|
1093
|
-
runtimeMetadataPrepared = false;
|
|
1094
|
-
runtimeRefreshRequiredForCompilation = true;
|
|
1095
|
-
await refreshTailwindRuntimeState(runtimeState, {
|
|
1096
|
-
force: true,
|
|
1097
|
-
clearCache: true
|
|
1098
|
-
});
|
|
1099
|
-
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
1100
|
-
};
|
|
1101
|
-
const markWebpackProcessedCssSource = (file) => {
|
|
1102
|
-
webpackProcessedCssSourceFiles.add(path.resolve(file));
|
|
1103
|
-
};
|
|
1104
|
-
const registerWebpackCssSourceFile = (source) => {
|
|
1105
|
-
webpackCssSources.set(path.resolve(source.file), source.css);
|
|
1106
|
-
};
|
|
1107
|
-
const isWebpackProcessedTailwindEntryAsset = (file) => {
|
|
1108
|
-
if ((runtimeState.twPatcher.majorVersion ?? 0) < 4 || !this.options.mainCssChunkMatcher(file, this.appType) || webpackProcessedCssSourceFiles.size === 0) return false;
|
|
1109
|
-
const tailwindOptions = resolveTailwindcssOptions(runtimeState.twPatcher.options);
|
|
1110
|
-
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (webpackProcessedCssSourceFiles.has(path.resolve(entry))) return true;
|
|
1111
|
-
for (const source of tailwindOptions?.v4?.cssSources ?? []) if (source.file && webpackProcessedCssSourceFiles.has(path.resolve(source.file))) return true;
|
|
1112
|
-
return false;
|
|
1113
|
-
};
|
|
1114
|
-
compiler.hooks.invalid?.tap?.(pluginName, (fileName) => {
|
|
1115
|
-
if (!fileName) return;
|
|
1116
|
-
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([path.resolve(fileName)]);
|
|
1117
|
-
});
|
|
1118
|
-
compiler.hooks.watchRun?.tap?.(pluginName, () => syncRuntimeRefreshRequirement(true));
|
|
1119
|
-
if (compiler.hooks.thisCompilation?.tap) compiler.hooks.thisCompilation.tap(pluginName, resetRuntimePreparation);
|
|
1120
|
-
else if (compiler.hooks.compilation?.tap) compiler.hooks.compilation.tap(pluginName, resetRuntimePreparation);
|
|
1121
|
-
async function getClassSetInLoader() {
|
|
1122
|
-
if (runtimeSetPrepared) return;
|
|
1123
|
-
const signature = getRuntimeClassSetSignature(runtimeState.twPatcher);
|
|
1124
|
-
const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
|
|
1125
|
-
debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
|
|
1126
|
-
runtimeSetPrepared = true;
|
|
1127
|
-
await ensureRuntimeClassSet(runtimeState, {
|
|
1128
|
-
forceRefresh,
|
|
1129
|
-
forceCollect: forceRefresh || !watchRunObserved,
|
|
1130
|
-
clearCache: forceRefresh,
|
|
1131
|
-
allowEmpty: true
|
|
1132
|
-
});
|
|
1133
|
-
await ensureRuntimeMetadata(forceRefresh);
|
|
1134
|
-
runtimeSetSignature = signature;
|
|
1135
|
-
runtimeRefreshRequiredForCompilation = false;
|
|
1136
|
-
}
|
|
1137
|
-
async function getRuntimeSetInLoader() {
|
|
1138
|
-
await getClassSetInLoader();
|
|
1139
|
-
return ensureRuntimeClassSet(runtimeState, { allowEmpty: true });
|
|
1140
|
-
}
|
|
1141
|
-
onLoad();
|
|
1142
|
-
setupWebpackV5Loaders({
|
|
1143
|
-
compiler,
|
|
1144
|
-
options: this.options,
|
|
1145
|
-
appType: this.appType,
|
|
1146
|
-
weappTailwindcssPackageDir,
|
|
1147
|
-
shouldRewriteCssImports,
|
|
1148
|
-
runtimeLoaderPath,
|
|
1149
|
-
registerAutoCssSource,
|
|
1150
|
-
runtimeState,
|
|
1151
|
-
getClassSetInLoader,
|
|
1152
|
-
getRuntimeSetInLoader,
|
|
1153
|
-
markWebpackProcessedCssSource,
|
|
1154
|
-
registerWebpackCssSourceFile,
|
|
1155
|
-
getRuntimeWatchDependencies() {
|
|
1156
|
-
return {
|
|
1157
|
-
files: runtimeWatchDependencyFiles,
|
|
1158
|
-
contexts: runtimeWatchDependencyContexts
|
|
1159
|
-
};
|
|
1160
|
-
},
|
|
1161
|
-
debug
|
|
1162
|
-
});
|
|
1163
|
-
setupWebpackV5ProcessAssetsHook({
|
|
1164
|
-
compiler,
|
|
1165
|
-
options: this.options,
|
|
1166
|
-
appType: this.appType,
|
|
1167
|
-
runtimeState,
|
|
1168
|
-
getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
|
|
1169
|
-
refreshRuntimeMetadata: ensureRuntimeMetadata,
|
|
1170
|
-
isWebpackProcessedCssAsset(file, rawSource) {
|
|
1171
|
-
return webpackProcessedCssSourceFiles.has(path.resolve(file)) || isWebpackProcessedTailwindEntryAsset(file) || rawSource.includes("weapp-tailwindcss webpack-generated-css");
|
|
1172
|
-
},
|
|
1173
|
-
consumeRuntimeRefreshRequirement() {
|
|
1174
|
-
runtimeRefreshRequiredForCompilation = false;
|
|
1175
|
-
},
|
|
1176
|
-
isWatchMode: () => watchRunObserved || compiler.options?.watch === true,
|
|
1177
|
-
runtimeClassSetManager: this.options.__internalWebpackRuntimeClassSetManager,
|
|
1178
|
-
getWebpackCssSources: () => webpackCssSources,
|
|
1179
|
-
debug
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
//#endregion
|
|
1184
|
-
export { weappTailwindcssPackageDir as n, WeappTailwindcss as t };
|