weapp-tailwindcss 5.0.13 → 5.1.1
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/class-selectors.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +10 -6
- 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 +2 -2
- 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/generator-css/validate.d.ts +1 -0
- 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 +16 -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-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +39 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +26 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +25 -0
- 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/source-candidate-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +15 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +2 -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/plugin-cache.d.ts +15 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -4
- 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 +26 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +34 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +37 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +199 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +11 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -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 +138 -444
- package/dist/cli.mjs +134 -440
- package/dist/context/index.d.ts +3 -3
- package/dist/context/style-options.d.ts +5 -1
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/{precheck-B0Z8yW7E.js → context-B6hVF7dr.js} +405 -156
- package/dist/{precheck-CRI90iL1.mjs → context-DlpKD7aN.mjs} +377 -141
- package/dist/core.js +15 -12
- package/dist/core.mjs +10 -7
- package/dist/css-macro/index.d.ts +3 -7
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-Bqx18S1f.mjs → defaults-BhE26nSw.mjs} +12 -13
- package/dist/{defaults-C_J_kBpw.js → defaults-CmFBmxsr.js} +11 -18
- package/dist/defaults.d.ts +2 -8
- 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-6oMJtTDO.js +170 -0
- package/dist/generator-CjzBK7h-.mjs +123 -0
- package/dist/generator.js +10 -16
- package/dist/generator.mjs +3 -3
- package/dist/{gulp-XT8Jc7lH.js → gulp-BtGq6LP9.js} +49 -87
- package/dist/{gulp-DfOQERcV.mjs → gulp-DNU10Vtc.mjs} +42 -80
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-B0KuWDjV.mjs} +1197 -858
- package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CegXR9O4.js} +1356 -927
- 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-zQ2MrDdi.mjs → source-candidate-scan-signature-B5af2Ahe.mjs} +187 -17
- package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-BKYb9jxa.js} +261 -19
- 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 +87 -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 +15 -7
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -10
- package/dist/tailwindcss/version.d.ts +1 -1
- package/dist/tailwindcss-B5mRo0-M.mjs +1423 -0
- package/dist/tailwindcss-dbrbY4cd.js +1528 -0
- package/dist/{transform-DfcEjsZF.mjs → transform-fRBeuuK-.mjs} +2 -2
- package/dist/{transform-YmrmxuF3.js → transform-vLwZpiTE.js} +17 -17
- 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/types/user-defined-options/matcher.d.ts +7 -0
- package/dist/uni-app-x/style-asset.d.ts +1 -0
- package/dist/v4-engine-C3qSwQ-e.mjs +2376 -0
- package/dist/v4-engine-ON_oSLfO.js +2752 -0
- package/dist/{vite-DjI09vVN.mjs → vite-CWRooooa.mjs} +1417 -540
- package/dist/{vite-CXHVsHmX.js → vite-w-RkgaTY.js} +1575 -698
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5665 -4443
- package/dist/weapp-tw-runtime-classset-loader.js +15 -4
- package/dist/webpack-8PaV1gG3.mjs +2334 -0
- package/dist/webpack-CGgBOx9l.js +2346 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -7
- 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
|
@@ -0,0 +1,2346 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
+
const require_v4_engine = require("./v4-engine-ON_oSLfO.js");
|
|
3
|
+
const require_generator = require("./generator-6oMJtTDO.js");
|
|
4
|
+
const require_utils = require("./utils-BCa37Wqj.js");
|
|
5
|
+
const require_context = require("./context-B6hVF7dr.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-dbrbY4cd.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-CegXR9O4.js");
|
|
8
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BKYb9jxa.js");
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
11
|
+
let node_path = require("node:path");
|
|
12
|
+
node_path = require_chunk.__toESM(node_path);
|
|
13
|
+
let node_process = require("node:process");
|
|
14
|
+
node_process = require_chunk.__toESM(node_process);
|
|
15
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
16
|
+
let node_fs_promises = require("node:fs/promises");
|
|
17
|
+
let micromatch = require("micromatch");
|
|
18
|
+
micromatch = require_chunk.__toESM(micromatch);
|
|
19
|
+
let node_module = require("node:module");
|
|
20
|
+
node_module = require_chunk.__toESM(node_module);
|
|
21
|
+
let _weapp_core_escape = require("@weapp-core/escape");
|
|
22
|
+
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
23
|
+
//#region src/shared/tailwindcss-css-redirect.ts
|
|
24
|
+
const moduleWithMutableResolve = node_module.default;
|
|
25
|
+
const patched = /* @__PURE__ */ new WeakSet();
|
|
26
|
+
function installTailwindcssCssRedirect(pkgDir) {
|
|
27
|
+
const target = node_path.default.join(pkgDir, "index.css");
|
|
28
|
+
const original = moduleWithMutableResolve._resolveFilename;
|
|
29
|
+
if (patched.has(original)) return;
|
|
30
|
+
const replacements = new Set(["tailwindcss", "tailwindcss$"]);
|
|
31
|
+
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
32
|
+
if (replacements.has(request)) return target;
|
|
33
|
+
if (request.startsWith("tailwindcss/")) return node_path.default.join(pkgDir, request.slice(12));
|
|
34
|
+
return original(request, parent, isMain, options);
|
|
35
|
+
};
|
|
36
|
+
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
37
|
+
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/shared/mpx.ts
|
|
41
|
+
const localRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
42
|
+
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
43
|
+
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
44
|
+
function isMpxStyleResourceQuery(query) {
|
|
45
|
+
if (typeof query !== "string") return false;
|
|
46
|
+
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
47
|
+
}
|
|
48
|
+
function isMpx(appType) {
|
|
49
|
+
return appType === "mpx";
|
|
50
|
+
}
|
|
51
|
+
function getTailwindcssCssEntry(pkgDir) {
|
|
52
|
+
return node_path.default.join(pkgDir, "index.css");
|
|
53
|
+
}
|
|
54
|
+
function resolveMpxWebpackPluginDir(compiler) {
|
|
55
|
+
const candidates = [
|
|
56
|
+
compiler?.context,
|
|
57
|
+
compiler?.options?.context,
|
|
58
|
+
node_process.default.cwd()
|
|
59
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
60
|
+
for (const candidate of candidates) try {
|
|
61
|
+
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
62
|
+
return node_path.default.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
63
|
+
} catch {}
|
|
64
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
65
|
+
if (cachedPackageJson) return node_path.default.dirname(cachedPackageJson);
|
|
66
|
+
try {
|
|
67
|
+
return node_path.default.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
68
|
+
} catch {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function isMpxWebpackPluginRequest(request) {
|
|
73
|
+
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
74
|
+
}
|
|
75
|
+
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
76
|
+
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
77
|
+
return node_path.default.join(mpxWebpackPluginDir, request.slice(22));
|
|
78
|
+
}
|
|
79
|
+
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
80
|
+
const recordLoader = node_path.default.join(pkgDir, "lib/record-loader");
|
|
81
|
+
const styleCompiler = node_path.default.join(pkgDir, "lib/style-compiler/index");
|
|
82
|
+
const stripConditionalLoader = node_path.default.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
83
|
+
if (Array.isArray(alias)) alias.push({
|
|
84
|
+
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
85
|
+
alias: recordLoader
|
|
86
|
+
}, {
|
|
87
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
88
|
+
alias: styleCompiler
|
|
89
|
+
}, {
|
|
90
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
91
|
+
alias: stripConditionalLoader
|
|
92
|
+
}, {
|
|
93
|
+
name: /^@mpxjs\/webpack-plugin\//,
|
|
94
|
+
alias: pkgDir
|
|
95
|
+
});
|
|
96
|
+
else {
|
|
97
|
+
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
98
|
+
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
99
|
+
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
100
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
101
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
105
|
+
compiler.options.resolveLoader = compiler.options.resolveLoader || {};
|
|
106
|
+
const alias = compiler.options.resolveLoader.alias ?? {};
|
|
107
|
+
compiler.options.resolveLoader.alias = alias;
|
|
108
|
+
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
109
|
+
}
|
|
110
|
+
function resolveMpxWebpackPluginRequire(compiler) {
|
|
111
|
+
const candidates = [
|
|
112
|
+
compiler?.context,
|
|
113
|
+
compiler?.options?.context,
|
|
114
|
+
node_process.default.cwd()
|
|
115
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
116
|
+
for (const candidate of candidates) try {
|
|
117
|
+
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
118
|
+
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
119
|
+
return projectRequire;
|
|
120
|
+
} catch {}
|
|
121
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
122
|
+
if (cachedPackageJson) return (0, node_module.createRequire)(cachedPackageJson);
|
|
123
|
+
return localRequire;
|
|
124
|
+
}
|
|
125
|
+
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
126
|
+
if (!mpxWebpackPluginDir) return false;
|
|
127
|
+
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
128
|
+
let normalize;
|
|
129
|
+
try {
|
|
130
|
+
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
131
|
+
} catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (typeof normalize.lib !== "function") return false;
|
|
135
|
+
if (normalize.lib.__weappTwPatched) return true;
|
|
136
|
+
const wrappedLib = (file) => node_path.default.join(mpxWebpackPluginDir, "lib", file);
|
|
137
|
+
wrappedLib.__weappTwPatched = true;
|
|
138
|
+
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
139
|
+
normalize.lib = wrappedLib;
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
143
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
144
|
+
compiler.options = compiler.options || {};
|
|
145
|
+
compiler.options.resolve = compiler.options.resolve || {};
|
|
146
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
147
|
+
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
148
|
+
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
149
|
+
const alias = compiler.options.resolve.alias ?? {};
|
|
150
|
+
compiler.options.resolve.alias = alias;
|
|
151
|
+
if (Array.isArray(alias)) alias.push({
|
|
152
|
+
name: "tailwindcss",
|
|
153
|
+
alias: tailwindcssCssEntry
|
|
154
|
+
}, {
|
|
155
|
+
name: "tailwindcss$",
|
|
156
|
+
alias: tailwindcssCssEntry
|
|
157
|
+
});
|
|
158
|
+
else {
|
|
159
|
+
alias.tailwindcss = tailwindcssCssEntry;
|
|
160
|
+
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
161
|
+
}
|
|
162
|
+
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
163
|
+
return tailwindcssCssEntry;
|
|
164
|
+
}
|
|
165
|
+
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
166
|
+
if (!enabled || typeof loaderContext.resolve !== "function") return;
|
|
167
|
+
const originalResolve = loaderContext.resolve;
|
|
168
|
+
if (originalResolve.__weappTwPatched) return;
|
|
169
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
170
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
171
|
+
const wrappedResolve = function(context, request, callback) {
|
|
172
|
+
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
173
|
+
if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
|
|
174
|
+
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
175
|
+
return originalResolve.call(this, context, request, callback);
|
|
176
|
+
};
|
|
177
|
+
wrappedResolve.__weappTwPatched = true;
|
|
178
|
+
loaderContext.resolve = wrappedResolve;
|
|
179
|
+
}
|
|
180
|
+
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
181
|
+
if (enabled) installTailwindcssCssRedirect(pkgDir);
|
|
182
|
+
}
|
|
183
|
+
const CSS_EXT_RE = /\.css$/i;
|
|
184
|
+
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
185
|
+
var _compiler$options;
|
|
186
|
+
if (!loader) return;
|
|
187
|
+
const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
|
|
188
|
+
moduleOptions.rules = moduleOptions.rules || [];
|
|
189
|
+
const createRule = (match) => ({
|
|
190
|
+
...match,
|
|
191
|
+
enforce: "pre",
|
|
192
|
+
use: [{
|
|
193
|
+
loader,
|
|
194
|
+
options: loaderOptions
|
|
195
|
+
}]
|
|
196
|
+
});
|
|
197
|
+
moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
|
|
198
|
+
test: CSS_EXT_RE,
|
|
199
|
+
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
|
|
204
|
+
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
|
|
205
|
+
function getCacheKey(filename) {
|
|
206
|
+
return filename;
|
|
207
|
+
}
|
|
208
|
+
function stripResourceQuery(resource) {
|
|
209
|
+
if (typeof resource !== "string") return resource;
|
|
210
|
+
return require_source_candidate_scan_signature.stripRequestQuery(resource);
|
|
211
|
+
}
|
|
212
|
+
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
213
|
+
if (typeof resource !== "string") return false;
|
|
214
|
+
const normalizedResource = stripResourceQuery(resource);
|
|
215
|
+
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
216
|
+
if (require_source_candidate_scan_signature.isSourceStyleRequest(resource)) return true;
|
|
217
|
+
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
function hasLoaderEntry(entries, target) {
|
|
221
|
+
if (!target) return false;
|
|
222
|
+
return entries.some((entry) => entry.loader?.includes?.(target));
|
|
223
|
+
}
|
|
224
|
+
function normalizeWatchPath(file) {
|
|
225
|
+
return node_path.default.resolve(file);
|
|
226
|
+
}
|
|
227
|
+
function isFileInContext(file, context) {
|
|
228
|
+
const relative = node_path.default.relative(normalizeWatchPath(context), normalizeWatchPath(file));
|
|
229
|
+
return relative.length > 0 && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
230
|
+
}
|
|
231
|
+
function toChunkFiles(files) {
|
|
232
|
+
if (!files) return [];
|
|
233
|
+
if (Array.isArray(files)) return files;
|
|
234
|
+
return [...files];
|
|
235
|
+
}
|
|
236
|
+
function inferWebpackMainCssFiles(chunks, cssMatcher, options = {}) {
|
|
237
|
+
const mainCssFiles = /* @__PURE__ */ new Set();
|
|
238
|
+
const shouldCheckSourceResources = Boolean(options.mainSourceFiles?.size);
|
|
239
|
+
for (const chunk of chunks) {
|
|
240
|
+
const files = toChunkFiles(chunk.files);
|
|
241
|
+
if (!(chunk.hasRuntime?.() === true)) continue;
|
|
242
|
+
for (const file of files) {
|
|
243
|
+
if (!cssMatcher(file)) continue;
|
|
244
|
+
if (shouldCheckSourceResources) {
|
|
245
|
+
const resources = options.resourcesByAsset?.get(file);
|
|
246
|
+
if (!resources || ![...resources].some((resource) => options.mainSourceFiles?.has(resource))) continue;
|
|
247
|
+
}
|
|
248
|
+
mainCssFiles.add(file);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return mainCssFiles;
|
|
252
|
+
}
|
|
253
|
+
function resolveSingleActiveWebpackCssResource(assetResources, activeWebpackAssetResourceFiles) {
|
|
254
|
+
const activeAssetResourceMatches = [...assetResources ?? []].map((sourceFile) => node_path.default.resolve(sourceFile)).filter((sourceFile) => activeWebpackAssetResourceFiles.has(sourceFile)).sort();
|
|
255
|
+
return activeAssetResourceMatches.length === 1 ? activeAssetResourceMatches[0] : void 0;
|
|
256
|
+
}
|
|
257
|
+
function createWebpackCssAssetResourceMap(chunks, chunkGraph, cssMatcher, normalizeResource) {
|
|
258
|
+
const resourcesByAsset = /* @__PURE__ */ new Map();
|
|
259
|
+
if (!chunkGraph?.getChunkModulesIterable) return resourcesByAsset;
|
|
260
|
+
const collectModuleResources = (module, resources, seen = /* @__PURE__ */ new Set()) => {
|
|
261
|
+
if (!module || seen.has(module)) return;
|
|
262
|
+
seen.add(module);
|
|
263
|
+
for (const candidate of [
|
|
264
|
+
module.resource,
|
|
265
|
+
module.request,
|
|
266
|
+
module.userRequest
|
|
267
|
+
]) {
|
|
268
|
+
if (typeof candidate !== "string") continue;
|
|
269
|
+
const normalized = normalizeResource(candidate, module);
|
|
270
|
+
if (normalized) resources.add(normalized);
|
|
271
|
+
}
|
|
272
|
+
for (const nested of [module.rootModule, chunkGraph.getIssuer?.(module)]) if (nested) collectModuleResources(nested, resources, seen);
|
|
273
|
+
for (const nested of module.modules ?? []) collectModuleResources(nested, resources, seen);
|
|
274
|
+
for (const dependency of module.dependencies ?? []) {
|
|
275
|
+
const dependencyLike = dependency;
|
|
276
|
+
for (const candidate of [dependencyLike.request, dependencyLike.userRequest]) {
|
|
277
|
+
if (typeof candidate !== "string") continue;
|
|
278
|
+
const normalized = normalizeResource(candidate, module);
|
|
279
|
+
if (normalized) resources.add(normalized);
|
|
280
|
+
}
|
|
281
|
+
const dependencyModule = chunkGraph.getModule?.(dependency);
|
|
282
|
+
if (dependencyModule) collectModuleResources(dependencyModule, resources, seen);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
for (const chunk of chunks) {
|
|
286
|
+
const cssFiles = toChunkFiles(chunk.files).filter((file) => cssMatcher(file));
|
|
287
|
+
if (cssFiles.length === 0) continue;
|
|
288
|
+
const modules = chunkGraph.getChunkModulesIterable(chunk);
|
|
289
|
+
if (!modules) continue;
|
|
290
|
+
const cssResources = /* @__PURE__ */ new Set();
|
|
291
|
+
for (const module of modules) collectModuleResources(module, cssResources);
|
|
292
|
+
if (cssResources.size === 0) continue;
|
|
293
|
+
for (const cssFile of cssFiles) resourcesByAsset.set(cssFile, cssResources);
|
|
294
|
+
}
|
|
295
|
+
return resourcesByAsset;
|
|
296
|
+
}
|
|
297
|
+
function createAssetHashByChunkMap(chunks) {
|
|
298
|
+
const partsByFile = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const chunk of chunks) {
|
|
300
|
+
const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
|
|
301
|
+
if (!hash) continue;
|
|
302
|
+
const chunkId = String(chunk.id ?? chunk.name ?? "");
|
|
303
|
+
for (const file of toChunkFiles(chunk.files)) {
|
|
304
|
+
if (!file) continue;
|
|
305
|
+
let parts = partsByFile.get(file);
|
|
306
|
+
if (!parts) {
|
|
307
|
+
parts = [];
|
|
308
|
+
partsByFile.set(file, parts);
|
|
309
|
+
}
|
|
310
|
+
parts.push(`${chunkId}:${hash}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const hashByFile = /* @__PURE__ */ new Map();
|
|
314
|
+
for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
|
|
315
|
+
return hashByFile;
|
|
316
|
+
}
|
|
317
|
+
function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
|
|
318
|
+
return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
|
|
319
|
+
}
|
|
320
|
+
function isWatchFileInRuntimeDependencies(file, dependencies) {
|
|
321
|
+
const normalizedFile = normalizeWatchPath(file);
|
|
322
|
+
for (const dependency of dependencies.files ?? []) if (normalizeWatchPath(dependency) === normalizedFile) return true;
|
|
323
|
+
for (const context of dependencies.contexts ?? []) if (isFileInContext(normalizedFile, context)) return true;
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/bundlers/webpack/shared/css-loader-runtime.ts
|
|
328
|
+
function isWebpackCssLoaderRuntimeSource(source) {
|
|
329
|
+
return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && source.includes("module.exports = ___CSS_LOADER_EXPORT___");
|
|
330
|
+
}
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.ts
|
|
333
|
+
const WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX = 128;
|
|
334
|
+
function removeTailwindV4StandaloneHostPreflightRule(source) {
|
|
335
|
+
if (!source.includes("--theme(")) return source;
|
|
336
|
+
try {
|
|
337
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
338
|
+
let changed = false;
|
|
339
|
+
root.walkRules((rule) => {
|
|
340
|
+
if (rule.selector.trim() !== ":host") return;
|
|
341
|
+
if (!rule.nodes?.some((node) => node.type === "decl" && node.value?.includes("--theme("))) return;
|
|
342
|
+
rule.remove();
|
|
343
|
+
changed = true;
|
|
344
|
+
});
|
|
345
|
+
return changed ? root.toString() : source;
|
|
346
|
+
} catch {
|
|
347
|
+
return source;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function isRuntimeTransformCandidate(candidate) {
|
|
351
|
+
return candidate.length > 0 && !candidate.includes("=") && !candidate.includes("<") && !candidate.includes(">") && !candidate.includes("${");
|
|
352
|
+
}
|
|
353
|
+
function collectRuntimeTokenSignatureParts(source) {
|
|
354
|
+
return source.match(/[\w-]+_[A-Z][\w-]*/gi) ?? [];
|
|
355
|
+
}
|
|
356
|
+
function hasMissingRuntimeCandidates(classSet, candidates) {
|
|
357
|
+
if (!classSet || !candidates?.size) return false;
|
|
358
|
+
for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate) && !classSet.has(candidate)) return true;
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
function resolveGeneratedCssRuntimeCandidates(source, fallbackClassSet) {
|
|
362
|
+
const classSet = collectGeneratedCssRuntimeCandidates(source);
|
|
363
|
+
if (classSet.size > 0 || fallbackClassSet === void 0) return classSet;
|
|
364
|
+
return fallbackClassSet;
|
|
365
|
+
}
|
|
366
|
+
function getRuntimeClassSetSync(tailwindRuntime) {
|
|
367
|
+
if (typeof tailwindRuntime.getClassSetSync !== "function") return /* @__PURE__ */ new Set();
|
|
368
|
+
try {
|
|
369
|
+
return new Set(tailwindRuntime.getClassSetSync() ?? []);
|
|
370
|
+
} catch {
|
|
371
|
+
return /* @__PURE__ */ new Set();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function toMb(bytes) {
|
|
375
|
+
return Math.round(bytes / 1024 / 1024);
|
|
376
|
+
}
|
|
377
|
+
function pruneMapToMaxSize(map, maxSize) {
|
|
378
|
+
while (map.size > maxSize) {
|
|
379
|
+
const oldestKey = map.keys().next().value;
|
|
380
|
+
if (oldestKey === void 0) break;
|
|
381
|
+
map.delete(oldestKey);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function stripTrailingLineWhitespace(source) {
|
|
385
|
+
return source.replace(/[ \t]+$/gm, "");
|
|
386
|
+
}
|
|
387
|
+
function pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles) {
|
|
388
|
+
const activeSuffixes = [...activeCssFiles].map((file) => `:${file}`);
|
|
389
|
+
for (const key of cssHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssHandlerOptionsCache.delete(key);
|
|
390
|
+
for (const key of cssUserHandlerOptionsCache.keys()) if (!activeSuffixes.some((suffix) => key.endsWith(suffix))) cssUserHandlerOptionsCache.delete(key);
|
|
391
|
+
pruneMapToMaxSize(cssHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
392
|
+
pruneMapToMaxSize(cssUserHandlerOptionsCache, WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX);
|
|
393
|
+
}
|
|
394
|
+
function resolveWebpackGeneratorRawSource(rawSource, cssHandlerOptions) {
|
|
395
|
+
const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
|
|
396
|
+
if (sourceCss && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss) || require_v4_engine.hasTailwindGeneratedCss(sourceCss) || require_v4_engine.hasTailwindGeneratedCssMarkers(sourceCss))) return sourceCss;
|
|
397
|
+
return rawSource;
|
|
398
|
+
}
|
|
399
|
+
function hasUsableWebpackGeneratorCssSources(cssSources) {
|
|
400
|
+
return Array.isArray(cssSources) && cssSources.some((source) => typeof source?.css === "string" && source.css.length > 0);
|
|
401
|
+
}
|
|
402
|
+
function normalizeWebpackGeneratorCssSources(cssSources) {
|
|
403
|
+
if (!Array.isArray(cssSources)) return;
|
|
404
|
+
const normalized = cssSources.filter((source) => typeof source?.css === "string" && source.css.length > 0);
|
|
405
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
406
|
+
}
|
|
407
|
+
function hasProcessedCssAssetUrl(css) {
|
|
408
|
+
return /url\(\s*["']?data:/i.test(css);
|
|
409
|
+
}
|
|
410
|
+
function shouldUseWebpackAssetAsGeneratorUserCss(rawSource, generatorRawSource, options = {}) {
|
|
411
|
+
return rawSource !== generatorRawSource && (options.processed === true || !rawSource.includes("data:")) && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) && !require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) && !require_v4_engine.hasTailwindApplyDirective(rawSource) && /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(rawSource) && (!require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) || hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource));
|
|
412
|
+
}
|
|
413
|
+
function collectWebpackAssetUserCssMarkers(source) {
|
|
414
|
+
const markers = /* @__PURE__ */ new Set();
|
|
415
|
+
for (const match of source.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
416
|
+
for (const match of source.matchAll(/@(?:-[\w-]+-)?keyframes\s+((?:\\.|[-\w\u00A0-\uFFFF])+)/gi)) markers.add(`keyframes:${match[1]}`);
|
|
417
|
+
try {
|
|
418
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
419
|
+
root.walkRules((rule) => {
|
|
420
|
+
for (const selector of rule.selectors) if (!/(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector)) markers.add(`selector:${selector.trim().replace(/\s+/g, " ")}`);
|
|
421
|
+
rule.walkDecls((decl) => {
|
|
422
|
+
if (decl.prop.startsWith("--")) markers.add(`custom-property:${decl.prop}`);
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
root.walkAtRules("font-face", (rule) => {
|
|
426
|
+
rule.walkDecls("font-family", (decl) => {
|
|
427
|
+
markers.add(`font-face:${decl.value.trim()}`);
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
} catch {}
|
|
431
|
+
return markers;
|
|
432
|
+
}
|
|
433
|
+
const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = new Set([
|
|
434
|
+
"theme",
|
|
435
|
+
"base",
|
|
436
|
+
"utilities"
|
|
437
|
+
]);
|
|
438
|
+
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
439
|
+
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
440
|
+
function parseWebpackCssLayerNames(params) {
|
|
441
|
+
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
442
|
+
}
|
|
443
|
+
function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
444
|
+
const cleaned = require_hmr_timing.removeTailwindV4GeneratedUserCssArtifacts(source);
|
|
445
|
+
try {
|
|
446
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(cleaned);
|
|
447
|
+
let changed = false;
|
|
448
|
+
root.walkAtRules("layer", (rule) => {
|
|
449
|
+
const names = parseWebpackCssLayerNames(rule.params);
|
|
450
|
+
const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
451
|
+
const isLayerDeclaration = rule.nodes === void 0;
|
|
452
|
+
const shouldRemoveLayer = isLayerDeclaration ? hasGeneratedLayerName : names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
453
|
+
if (shouldRemoveLayer && isLayerDeclaration) {
|
|
454
|
+
rule.remove();
|
|
455
|
+
changed = true;
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (shouldRemoveLayer && !names.includes("utilities")) {
|
|
459
|
+
rule.remove();
|
|
460
|
+
changed = true;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (shouldRemoveLayer) {
|
|
464
|
+
rule.walkRules((nestedRule) => {
|
|
465
|
+
const selector = nestedRule.selector.trim();
|
|
466
|
+
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector)) {
|
|
467
|
+
nestedRule.remove();
|
|
468
|
+
changed = true;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
if (rule.nodes?.length === 0) {
|
|
472
|
+
rule.remove();
|
|
473
|
+
changed = true;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
root.walkAtRules((rule) => {
|
|
478
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
479
|
+
rule.remove();
|
|
480
|
+
changed = true;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
return changed ? root.toString() : cleaned;
|
|
484
|
+
} catch {
|
|
485
|
+
return cleaned;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function collectWebpackCssRuleIdentityMarkers(source) {
|
|
489
|
+
const markers = /* @__PURE__ */ new Set();
|
|
490
|
+
try {
|
|
491
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
492
|
+
root.walkRules((rule) => {
|
|
493
|
+
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
494
|
+
});
|
|
495
|
+
root.walkAtRules("keyframes", (rule) => {
|
|
496
|
+
if (rule.params) markers.add(`keyframes:${rule.params}`);
|
|
497
|
+
});
|
|
498
|
+
} catch {}
|
|
499
|
+
return markers;
|
|
500
|
+
}
|
|
501
|
+
function unescapeCssIdentifier(value) {
|
|
502
|
+
return value.replace(/\\([0-9a-f]{1,6}\s?|.)/gi, (_match, escaped) => {
|
|
503
|
+
const hex = escaped.trim();
|
|
504
|
+
if (/^[0-9a-f]+$/i.test(hex)) return String.fromCodePoint(Number.parseInt(hex, 16));
|
|
505
|
+
return escaped;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function collectGeneratedCssRuntimeCandidates(source) {
|
|
509
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
510
|
+
if (require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(source) || !require_v4_engine.hasTailwindGeneratedCss(source) && !require_v4_engine.hasTailwindGeneratedCssMarkers(source)) return candidates;
|
|
511
|
+
try {
|
|
512
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
513
|
+
for (const selector of rule.selectors) for (const match of selector.matchAll(/\.((?:\\.|[\w\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/g)) {
|
|
514
|
+
const candidate = unescapeCssIdentifier(match[1]);
|
|
515
|
+
if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
} catch {}
|
|
519
|
+
return candidates;
|
|
520
|
+
}
|
|
521
|
+
function hasAdditionalWebpackAssetUserCssMarkers(rawSource, generatorRawSource) {
|
|
522
|
+
const rawMarkers = collectWebpackAssetUserCssMarkers(rawSource);
|
|
523
|
+
if (rawMarkers.size === 0) return false;
|
|
524
|
+
const generatorMarkers = collectWebpackAssetUserCssMarkers(generatorRawSource);
|
|
525
|
+
for (const marker of rawMarkers) if (!generatorMarkers.has(marker)) return true;
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
function hasWebpackTailwindSourceDirectives(source) {
|
|
529
|
+
return Boolean(source) && (require_v4_engine.hasTailwindRootDirectives(source, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(source, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(source) || require_v4_engine.hasTailwindGeneratedCss(source) || require_v4_engine.hasTailwindGeneratedCssMarkers(source));
|
|
530
|
+
}
|
|
531
|
+
function isWebpackTailwindImportRequest(request) {
|
|
532
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/") || request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
533
|
+
}
|
|
534
|
+
function removeWebpackGeneratorNonTailwindImports(source) {
|
|
535
|
+
if (!source?.includes("@import")) return source;
|
|
536
|
+
try {
|
|
537
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
538
|
+
let changed = false;
|
|
539
|
+
root.walkAtRules("import", (rule) => {
|
|
540
|
+
if (isWebpackTailwindImportRequest(require_v4_engine.parseImportRequest(rule.params))) return;
|
|
541
|
+
rule.remove();
|
|
542
|
+
changed = true;
|
|
543
|
+
});
|
|
544
|
+
return changed ? root.toString() : source;
|
|
545
|
+
} catch {
|
|
546
|
+
return source;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function isWebpackCssSourceRepresentedInAsset(rawSource, sourceCss) {
|
|
550
|
+
if (!sourceCss || !hasWebpackTailwindSourceDirectives(sourceCss)) return false;
|
|
551
|
+
const sourceMarkers = collectWebpackCssRuleIdentityMarkers(sourceCss);
|
|
552
|
+
if (sourceMarkers.size === 0) return false;
|
|
553
|
+
const rawMarkers = collectWebpackCssRuleIdentityMarkers(rawSource);
|
|
554
|
+
for (const marker of sourceMarkers) if (!rawMarkers.has(marker)) return false;
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
function createWebpackGeneratorCssSource(file, css) {
|
|
558
|
+
if (!file || !css || !hasWebpackTailwindSourceDirectives(css)) return;
|
|
559
|
+
return {
|
|
560
|
+
file,
|
|
561
|
+
base: node_path.default.dirname(file),
|
|
562
|
+
css,
|
|
563
|
+
dependencies: [file]
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
function createWebpackUserCssSourceAppend(sources, generatorRawSource, currentSourceFile, shouldIncludeSource) {
|
|
567
|
+
const matchedSources = [];
|
|
568
|
+
const seen = /* @__PURE__ */ new Set();
|
|
569
|
+
for (const source of sources) {
|
|
570
|
+
const css = source.css;
|
|
571
|
+
if (!css || seen.has(css)) continue;
|
|
572
|
+
if (shouldIncludeSource && !shouldIncludeSource(source.file)) continue;
|
|
573
|
+
seen.add(css);
|
|
574
|
+
if ((source.processed === true || !css.includes("data:")) && hasAdditionalWebpackAssetUserCssMarkers(css, generatorRawSource)) matchedSources.push({
|
|
575
|
+
css,
|
|
576
|
+
file: source.file,
|
|
577
|
+
processed: source.processed === true
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
const currentFile = currentSourceFile ? node_path.default.resolve(currentSourceFile) : void 0;
|
|
581
|
+
const parts = matchedSources.sort((a, b) => {
|
|
582
|
+
const aCurrent = currentFile !== void 0 && node_path.default.resolve(a.file) === currentFile;
|
|
583
|
+
if (aCurrent !== (currentFile !== void 0 && node_path.default.resolve(b.file) === currentFile)) return aCurrent ? -1 : 1;
|
|
584
|
+
return a.file.localeCompare(b.file);
|
|
585
|
+
}).map((source) => source.css);
|
|
586
|
+
return parts.length > 0 ? {
|
|
587
|
+
css: parts.join("\n"),
|
|
588
|
+
processed: matchedSources.every((source) => source.processed)
|
|
589
|
+
} : void 0;
|
|
590
|
+
}
|
|
591
|
+
function createWebpackGeneratorUserCssSourceAppend(...sources) {
|
|
592
|
+
const parts = sources.filter((source) => source !== void 0 && source.css.trim().length > 0);
|
|
593
|
+
if (parts.length === 0) return;
|
|
594
|
+
let css = "";
|
|
595
|
+
const usedParts = [];
|
|
596
|
+
for (const source of parts) {
|
|
597
|
+
const nextCss = css.trim().length > 0 ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, source.css) : source.css;
|
|
598
|
+
if (!(nextCss.trim().length > 0)) continue;
|
|
599
|
+
css = require_hmr_timing.createCssSourceOrderAppend(css, nextCss);
|
|
600
|
+
usedParts.push(source);
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
css,
|
|
604
|
+
processed: usedParts.every((source) => source.processed)
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function resolveWebpackMemoryDebugStats(context) {
|
|
608
|
+
if (node_process.default.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
|
|
609
|
+
const memory = node_process.default.memoryUsage();
|
|
610
|
+
const processCacheInstanceSize = context.cache.instance.size;
|
|
611
|
+
const processCacheHashMapSize = context.cache.hashMap.size;
|
|
612
|
+
return {
|
|
613
|
+
phase: context.phase,
|
|
614
|
+
process: {
|
|
615
|
+
rssMb: toMb(memory.rss),
|
|
616
|
+
heapTotalMb: toMb(memory.heapTotal),
|
|
617
|
+
heapUsedMb: toMb(memory.heapUsed),
|
|
618
|
+
externalMb: toMb(memory.external),
|
|
619
|
+
arrayBuffersMb: toMb(memory.arrayBuffers)
|
|
620
|
+
},
|
|
621
|
+
assets: {
|
|
622
|
+
active: context.activeAssetFiles,
|
|
623
|
+
activeCss: context.activeCssFiles
|
|
624
|
+
},
|
|
625
|
+
processCache: {
|
|
626
|
+
instance: processCacheInstanceSize,
|
|
627
|
+
hashMap: processCacheHashMapSize,
|
|
628
|
+
activeCacheKeys: context.activeProcessCacheKeys.size,
|
|
629
|
+
activeHashKeys: context.activeProcessHashKeys.size,
|
|
630
|
+
staleCacheKeys: Math.max(0, processCacheInstanceSize - context.activeProcessCacheKeys.size),
|
|
631
|
+
staleHashKeys: Math.max(0, processCacheHashMapSize - context.activeProcessHashKeys.size),
|
|
632
|
+
pruned: true,
|
|
633
|
+
pruneSkipped: false
|
|
634
|
+
},
|
|
635
|
+
webpackCss: {
|
|
636
|
+
handlerOptions: context.cssHandlerOptionsCache.size,
|
|
637
|
+
userHandlerOptions: context.cssUserHandlerOptionsCache.size,
|
|
638
|
+
maxHandlerOptions: WEBPACK_CSS_HANDLER_OPTIONS_CACHE_MAX
|
|
639
|
+
},
|
|
640
|
+
sourceCandidateScan: context.sourceCandidateScan,
|
|
641
|
+
tailwind: { v4: require_v4_engine.getTailwindV4IncrementalGenerateCacheStats() }
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function shouldInjectWebpackCssTracePreflight(appType, cssHandlerOptions) {
|
|
645
|
+
return appType !== "mpx" || cssHandlerOptions.isMainChunk !== false;
|
|
646
|
+
}
|
|
647
|
+
function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
648
|
+
const styleOptions = require_context.resolveStyleOptionsFromContext(compilerOptions);
|
|
649
|
+
if (isWebGeneratorTarget) return source;
|
|
650
|
+
return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(removeTailwindV4StandaloneHostPreflightRule((0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(require_hmr_timing.removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
|
|
651
|
+
cssPreflight: options.cssPreflight !== false && !require_hmr_timing.hasMiniProgramTailwindV4PreflightReset(source) ? compilerOptions.cssPreflight : void 0,
|
|
652
|
+
isTailwindcssV4: true,
|
|
653
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
654
|
+
})));
|
|
655
|
+
}
|
|
656
|
+
function shouldFallbackToWebpackUserCssOnGeneratorError(options) {
|
|
657
|
+
return !require_v4_engine.hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true }) && !require_v4_engine.hasTailwindSourceDirectives(options.generatorRawSource, { importFallback: true }) && !require_v4_engine.hasTailwindApplyDirective(options.generatorRawSource) && !options.hasExplicitTailwindV4SourceCss && options.configuredMainCssEntryFilesLength === 0;
|
|
658
|
+
}
|
|
659
|
+
function isWindowsAbsoluteResourcePath(file) {
|
|
660
|
+
return /^[a-z]:[\\/]/i.test(file) || /^[/\\]{2}[^/\\]/.test(file);
|
|
661
|
+
}
|
|
662
|
+
function isPosixAbsoluteResourcePath(file) {
|
|
663
|
+
return file.startsWith("/");
|
|
664
|
+
}
|
|
665
|
+
function resolveWebpackResourcePath(file, base) {
|
|
666
|
+
if (isWindowsAbsoluteResourcePath(file)) return node_path.default.win32.resolve(file);
|
|
667
|
+
if (isPosixAbsoluteResourcePath(file)) return node_path.default.posix.resolve(file);
|
|
668
|
+
if (base) {
|
|
669
|
+
if (isWindowsAbsoluteResourcePath(base)) return node_path.default.win32.resolve(base, file);
|
|
670
|
+
if (isPosixAbsoluteResourcePath(base)) return node_path.default.posix.resolve(base, file);
|
|
671
|
+
return node_path.default.resolve(base, file);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function dirnameWebpackResourcePath(file) {
|
|
675
|
+
if (isWindowsAbsoluteResourcePath(file)) return node_path.default.win32.dirname(file);
|
|
676
|
+
if (isPosixAbsoluteResourcePath(file)) return node_path.default.posix.dirname(file);
|
|
677
|
+
return node_path.default.dirname(file);
|
|
678
|
+
}
|
|
679
|
+
function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
|
|
680
|
+
if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
|
|
681
|
+
const normalized = stripResourceQuery(resource);
|
|
682
|
+
if (!normalized) return;
|
|
683
|
+
const absoluteResource = resolveWebpackResourcePath(normalized);
|
|
684
|
+
if (absoluteResource) return absoluteResource;
|
|
685
|
+
const issuerResource = issuer?.resource ? stripResourceQuery(issuer.resource) : void 0;
|
|
686
|
+
const issuerResourcePath = issuerResource ? resolveWebpackResourcePath(issuerResource) : void 0;
|
|
687
|
+
return resolveWebpackResourcePath(normalized, issuerResourcePath ? dirnameWebpackResourcePath(issuerResourcePath) : issuer?.context);
|
|
688
|
+
}
|
|
689
|
+
function isSameWebpackCssSourceScope(options) {
|
|
690
|
+
if (!options.currentSourceFile) return false;
|
|
691
|
+
const candidateKey = resolveWebpackResourcePath(options.candidateSourceFile) ?? node_path.default.resolve(options.candidateSourceFile);
|
|
692
|
+
if (candidateKey === (resolveWebpackResourcePath(options.currentSourceFile) ?? node_path.default.resolve(options.currentSourceFile))) return true;
|
|
693
|
+
const outputResources = options.resourcesByAsset.get(options.outputFile);
|
|
694
|
+
if (!outputResources) return false;
|
|
695
|
+
return [...outputResources].some((resource) => {
|
|
696
|
+
return (resolveWebpackResourcePath(resource) ?? node_path.default.resolve(resource)) === candidateKey;
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function shouldAppendCurrentWebpackAssetUserCss(options) {
|
|
700
|
+
const hasGeneratedAssetUserCss = options.currentAssetLooksGenerated && options.currentAssetHasUserCss;
|
|
701
|
+
return !options.currentAssetHasBundlerGeneratedMarker && !options.shouldPreserveGeneratedWebAssetUserCss && (hasGeneratedAssetUserCss || !options.sourceCssProcessed || options.registeredUserRawSource === void 0 || options.currentAssetHasUserCss) && !(options.sourceCssProcessed && options.currentAssetLooksGenerated && !options.currentAssetHasUserCss);
|
|
702
|
+
}
|
|
703
|
+
function createWebpackCurrentAssetUserRawSource(options) {
|
|
704
|
+
if (!options.shouldAppendCurrentAssetUserCss) return;
|
|
705
|
+
if (options.sourceCssProcessed) return {
|
|
706
|
+
css: options.currentAssetUserCssSource,
|
|
707
|
+
processed: true
|
|
708
|
+
};
|
|
709
|
+
if (!options.currentAssetHasUserCss) return;
|
|
710
|
+
return {
|
|
711
|
+
css: options.currentAssetUserCssSource,
|
|
712
|
+
processed: options.currentAssetLooksGenerated
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function finalizeTracedWebpackCssAsset(css, cssHandlerOptions, options) {
|
|
716
|
+
const traced = options.annotateCss(css);
|
|
717
|
+
if (options.isWebGeneratorTarget || !require_hmr_timing.isCssSourceTraceEnabled(options.compilerOptions)) return traced;
|
|
718
|
+
return finalizeMiniProgramUserCssAssetSource(traced, options.compilerOptions, options.isWebGeneratorTarget, { cssPreflight: shouldInjectWebpackCssTracePreflight(options.compilerOptions.appType, cssHandlerOptions) });
|
|
719
|
+
}
|
|
720
|
+
function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
721
|
+
const styleOptions = require_context.resolveStyleOptionsFromContext(compilerOptions);
|
|
722
|
+
if (isWebGeneratorTarget) {
|
|
723
|
+
if (options.generatedCss === true) return stripTrailingLineWhitespace(require_hmr_timing.stripUnmatchedTailwindSourceMediaCloseFragments(require_hmr_timing.stripTailwindSourceMediaFragments(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(source))));
|
|
724
|
+
return stripTrailingLineWhitespace(require_hmr_timing.stripUnmatchedTailwindSourceMediaCloseFragments(require_hmr_timing.stripTailwindSourceMediaFragments(require_hmr_timing.removeTailwindV4GeneratorAtRules(require_v4_engine.removeTailwindSourceDirectives(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
|
|
725
|
+
}
|
|
726
|
+
let finalized = require_v4_engine.removeTailwindSourceDirectives(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
727
|
+
if (options.generatedCss !== true) return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(require_hmr_timing.removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
728
|
+
try {
|
|
729
|
+
finalized = (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(finalized, { preservePreflight: true });
|
|
730
|
+
} catch {
|
|
731
|
+
finalized = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(finalized, {
|
|
732
|
+
cssPreflight: !require_hmr_timing.hasMiniProgramTailwindV4PreflightReset(finalized) ? compilerOptions.cssPreflight : void 0,
|
|
733
|
+
isTailwindcssV4: true,
|
|
734
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(require_hmr_timing.removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
738
|
+
}
|
|
739
|
+
function collectWebpackJsRuntimeCandidatesFromAssets(options) {
|
|
740
|
+
if (options.isWebGeneratorTarget) return;
|
|
741
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
742
|
+
for (const file of options.jsAssets) {
|
|
743
|
+
const sourceLike = options.getAssetSource(file);
|
|
744
|
+
if (sourceLike === void 0) continue;
|
|
745
|
+
const source = stringifyWebpackSourceLike(sourceLike);
|
|
746
|
+
for (const candidate of require_hmr_timing.collectStrictEscapedRuntimeCandidates(source, _weapp_core_escape.MappingChars2String, options.escapeFragments)) if (isRuntimeTransformCandidate(candidate)) candidates.add(candidate);
|
|
747
|
+
}
|
|
748
|
+
return candidates;
|
|
749
|
+
}
|
|
750
|
+
function collectWebpackJsRuntimeTokenSignature(options) {
|
|
751
|
+
if (options.isWebGeneratorTarget) return "";
|
|
752
|
+
const tokens = [];
|
|
753
|
+
for (const file of options.jsAssets) {
|
|
754
|
+
const sourceLike = options.getAssetSource(file);
|
|
755
|
+
if (sourceLike === void 0) continue;
|
|
756
|
+
tokens.push(...collectRuntimeTokenSignatureParts(stringifyWebpackSourceLike(sourceLike)));
|
|
757
|
+
}
|
|
758
|
+
return tokens.sort().join("\n");
|
|
759
|
+
}
|
|
760
|
+
function addRuntimeTransformCandidates(target, candidates) {
|
|
761
|
+
if (!candidates?.size) return;
|
|
762
|
+
for (const candidate of candidates) if (isRuntimeTransformCandidate(candidate)) target.add(candidate);
|
|
763
|
+
}
|
|
764
|
+
function createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates) {
|
|
765
|
+
if (!require_hmr_timing.isCssSourceTraceEnabled(compilerOptions) || !webpackSourceCandidates) return;
|
|
766
|
+
return require_hmr_timing.createCssTokenSourceMap(webpackSourceCandidates.tokenSources, compilerOptions);
|
|
767
|
+
}
|
|
768
|
+
function stringifyOptionalWebpackSourceValue(value) {
|
|
769
|
+
return typeof value === "string" ? value : value?.toString() ?? "";
|
|
770
|
+
}
|
|
771
|
+
function stringifyWebpackSourceLike(source) {
|
|
772
|
+
if (typeof source === "string") return source;
|
|
773
|
+
const value = source.source();
|
|
774
|
+
return typeof value === "string" ? value : value.toString();
|
|
775
|
+
}
|
|
776
|
+
//#endregion
|
|
777
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.ts
|
|
778
|
+
function createWebpackCssSourceResolvers(options) {
|
|
779
|
+
const { activeWebpackAssetResourceFiles, appType, compilerOptions, compilation, cssAssetResources, cssHandlerOptionsCache, cssSources, cssUserHandlerOptionsCache, groupedCssEntriesLength, singleCssAssetFile, isWebGeneratorTarget, outputDir, runtimeState } = options;
|
|
780
|
+
const hasConfiguredTailwindV4SourceRoots = () => {
|
|
781
|
+
const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
782
|
+
return (tailwindOptions?.v4?.cssEntries?.length ?? 0) > 0 || (tailwindOptions?.v4?.cssSources?.length ?? 0) > 0;
|
|
783
|
+
};
|
|
784
|
+
const configuredMainCssEntryFiles = (() => {
|
|
785
|
+
return [...require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options)?.v4?.cssEntries ?? []].filter((file) => typeof file === "string" && file.length > 0).map((file) => node_path.default.resolve(file));
|
|
786
|
+
})();
|
|
787
|
+
const inferredMainCssFiles = inferWebpackMainCssFiles(compilation.chunks, compilerOptions.cssMatcher, {
|
|
788
|
+
mainSourceFiles: new Set(configuredMainCssEntryFiles),
|
|
789
|
+
resourcesByAsset: cssAssetResources
|
|
790
|
+
});
|
|
791
|
+
const singleConfiguredCssAsset = isWebGeneratorTarget && configuredMainCssEntryFiles.length > 0 && groupedCssEntriesLength === 1 ? singleCssAssetFile : void 0;
|
|
792
|
+
const isMainCssChunk = (file) => compilerOptions.mainCssChunkMatcher(file, appType) || inferredMainCssFiles.has(file) || file === singleConfiguredCssAsset;
|
|
793
|
+
const activeWebpackCssSourceFiles = /* @__PURE__ */ new Set();
|
|
794
|
+
const resolveConfiguredMainCssSourceFile = (file) => {
|
|
795
|
+
if (!isMainCssChunk(file)) return;
|
|
796
|
+
for (const sourceFile of configuredMainCssEntryFiles) if (cssSources.has(sourceFile)) {
|
|
797
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
798
|
+
return sourceFile;
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
const resolveWebpackCssSourceFile = (file, rawSource) => {
|
|
802
|
+
const assetResources = cssAssetResources.get(file);
|
|
803
|
+
const activeAssetResource = resolveSingleActiveWebpackCssResource(assetResources, activeWebpackAssetResourceFiles);
|
|
804
|
+
if (cssSources.size === 0) {
|
|
805
|
+
if (activeAssetResource) {
|
|
806
|
+
activeWebpackCssSourceFiles.add(activeAssetResource);
|
|
807
|
+
return activeAssetResource;
|
|
808
|
+
}
|
|
809
|
+
if (assetResources && assetResources.size > 0) return;
|
|
810
|
+
return resolveConfiguredMainCssSourceFile(file);
|
|
811
|
+
}
|
|
812
|
+
const resourceMatches = [...assetResources ?? []].filter((sourceFile) => cssSources.has(sourceFile)).sort();
|
|
813
|
+
if (resourceMatches.length === 1) {
|
|
814
|
+
const sourceFile = resourceMatches[0];
|
|
815
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
816
|
+
return sourceFile;
|
|
817
|
+
}
|
|
818
|
+
const tailwindSourceMatches = resourceMatches.filter((sourceFile) => {
|
|
819
|
+
const sourceCss = cssSources.get(sourceFile)?.css;
|
|
820
|
+
return sourceCss && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss) || require_v4_engine.hasTailwindGeneratedCss(sourceCss) || require_v4_engine.hasTailwindGeneratedCssMarkers(sourceCss));
|
|
821
|
+
});
|
|
822
|
+
if (tailwindSourceMatches.length === 1) {
|
|
823
|
+
const sourceFile = tailwindSourceMatches[0];
|
|
824
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
825
|
+
return sourceFile;
|
|
826
|
+
}
|
|
827
|
+
if (activeAssetResource) {
|
|
828
|
+
activeWebpackCssSourceFiles.add(activeAssetResource);
|
|
829
|
+
return activeAssetResource;
|
|
830
|
+
}
|
|
831
|
+
if (rawSource) {
|
|
832
|
+
const representedTailwindSourceMatches = [...cssSources.entries()].filter(([, source]) => isWebpackCssSourceRepresentedInAsset(rawSource, source.css)).map(([sourceFile]) => ({
|
|
833
|
+
sourceFile,
|
|
834
|
+
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(file, sourceFile, {
|
|
835
|
+
outputRoot: outputDir,
|
|
836
|
+
projectRoot: compilerOptions.tailwindcssBasedir,
|
|
837
|
+
cwd: compilerOptions.tailwindcssBasedir
|
|
838
|
+
})
|
|
839
|
+
})).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.sourceFile.localeCompare(b.sourceFile));
|
|
840
|
+
const bestScore = representedTailwindSourceMatches[0]?.score ?? 0;
|
|
841
|
+
const bestMatches = representedTailwindSourceMatches.filter((match) => match.score === bestScore);
|
|
842
|
+
if (bestMatches.length === 1) {
|
|
843
|
+
const sourceFile = bestMatches[0].sourceFile;
|
|
844
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
845
|
+
return sourceFile;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
const pathMatches = [...cssSources.keys()].map((sourceFile) => ({
|
|
849
|
+
sourceFile,
|
|
850
|
+
score: require_hmr_timing.scoreTailwindV4CssSourceFileMatch(file, sourceFile, {
|
|
851
|
+
outputRoot: outputDir,
|
|
852
|
+
projectRoot: compilerOptions.tailwindcssBasedir,
|
|
853
|
+
cwd: compilerOptions.tailwindcssBasedir
|
|
854
|
+
})
|
|
855
|
+
})).filter((match) => match.score >= 1e3).sort((a, b) => b.score - a.score || a.sourceFile.localeCompare(b.sourceFile));
|
|
856
|
+
const bestPathScore = pathMatches[0]?.score ?? 0;
|
|
857
|
+
const bestPathMatches = pathMatches.filter((match) => match.score === bestPathScore);
|
|
858
|
+
if (bestPathMatches.length === 1) {
|
|
859
|
+
const sourceFile = bestPathMatches[0].sourceFile;
|
|
860
|
+
activeWebpackCssSourceFiles.add(sourceFile);
|
|
861
|
+
return sourceFile;
|
|
862
|
+
}
|
|
863
|
+
if (assetResources && assetResources.size > 0) return;
|
|
864
|
+
return resolveConfiguredMainCssSourceFile(file);
|
|
865
|
+
};
|
|
866
|
+
const isSameWebpackSourceScope = (outputFile, candidateSourceFile, currentSourceFile) => isSameWebpackCssSourceScope({
|
|
867
|
+
candidateSourceFile,
|
|
868
|
+
currentSourceFile,
|
|
869
|
+
outputFile,
|
|
870
|
+
resourcesByAsset: cssAssetResources
|
|
871
|
+
});
|
|
872
|
+
const getCssHandlerOptions = (file, rawSource) => {
|
|
873
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
874
|
+
const isMainChunk = isMainCssChunk(file);
|
|
875
|
+
const sourceFile = resolveWebpackCssSourceFile(file, rawSource);
|
|
876
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
877
|
+
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
878
|
+
const generatorCssSource = createWebpackGeneratorCssSource(sourceFile, generatorSourceCss);
|
|
879
|
+
const cacheKey = [
|
|
880
|
+
majorVersion ?? "unknown",
|
|
881
|
+
isMainChunk ? "1" : "0",
|
|
882
|
+
sourceFile ?? "asset",
|
|
883
|
+
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
884
|
+
generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss),
|
|
885
|
+
file
|
|
886
|
+
].join(":");
|
|
887
|
+
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
888
|
+
if (cached) return cached;
|
|
889
|
+
const created = {
|
|
890
|
+
isMainChunk,
|
|
891
|
+
postcssOptions: { options: { from: sourceFile ?? file } },
|
|
892
|
+
sourceOptions: {
|
|
893
|
+
outputRoot: outputDir,
|
|
894
|
+
...generatorCssSource === void 0 ? {} : { cssSources: [generatorCssSource] },
|
|
895
|
+
...generatorSourceCss === void 0 ? {} : { sourceCss: generatorSourceCss },
|
|
896
|
+
...sourceFile === void 0 ? {} : { sourceFile }
|
|
897
|
+
},
|
|
898
|
+
...require_context.normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
899
|
+
};
|
|
900
|
+
cssHandlerOptionsCache.set(cacheKey, created);
|
|
901
|
+
return created;
|
|
902
|
+
};
|
|
903
|
+
const getCssUserHandlerOptions = (file) => {
|
|
904
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
905
|
+
const sourceFile = resolveWebpackCssSourceFile(file);
|
|
906
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
907
|
+
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
908
|
+
const cacheKey = [
|
|
909
|
+
majorVersion ?? "unknown",
|
|
910
|
+
sourceFile ?? "asset",
|
|
911
|
+
sourceCss === void 0 ? "source:0" : compilerOptions.cache.computeHash(sourceCss),
|
|
912
|
+
generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss),
|
|
913
|
+
file
|
|
914
|
+
].join(":");
|
|
915
|
+
const cached = cssUserHandlerOptionsCache.get(cacheKey);
|
|
916
|
+
if (cached) return cached;
|
|
917
|
+
const created = {
|
|
918
|
+
...getCssHandlerOptions(file),
|
|
919
|
+
isMainChunk: false
|
|
920
|
+
};
|
|
921
|
+
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
922
|
+
return created;
|
|
923
|
+
};
|
|
924
|
+
return {
|
|
925
|
+
activeWebpackCssSourceFiles,
|
|
926
|
+
configuredMainCssEntryFiles,
|
|
927
|
+
getCssHandlerOptions,
|
|
928
|
+
getCssUserHandlerOptions,
|
|
929
|
+
hasConfiguredTailwindV4SourceRoots,
|
|
930
|
+
isSameWebpackSourceScope,
|
|
931
|
+
resolveWebpackCssSourceFile
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.ts
|
|
936
|
+
function createChangedByType() {
|
|
937
|
+
return {
|
|
938
|
+
html: /* @__PURE__ */ new Set(),
|
|
939
|
+
js: /* @__PURE__ */ new Set(),
|
|
940
|
+
css: /* @__PURE__ */ new Set(),
|
|
941
|
+
other: /* @__PURE__ */ new Set()
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function createProcessFiles() {
|
|
945
|
+
return {
|
|
946
|
+
html: /* @__PURE__ */ new Set(),
|
|
947
|
+
js: /* @__PURE__ */ new Set(),
|
|
948
|
+
css: /* @__PURE__ */ new Set()
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function markProcessFile(type, file, processFiles) {
|
|
952
|
+
if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
|
|
953
|
+
}
|
|
954
|
+
function buildWebpackBundleSnapshot(assets, opts, state, compilation) {
|
|
955
|
+
const sourceHashByFile = /* @__PURE__ */ new Map();
|
|
956
|
+
const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
|
|
957
|
+
const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
|
|
958
|
+
const changedByType = createChangedByType();
|
|
959
|
+
const runtimeAffectingChangedByType = createChangedByType();
|
|
960
|
+
const processFiles = createProcessFiles();
|
|
961
|
+
const entries = [];
|
|
962
|
+
const firstRun = state.iteration === 0 && state.sourceHashByFile.size === 0;
|
|
963
|
+
for (const [file, asset] of Object.entries(assets)) {
|
|
964
|
+
const type = require_source_candidate_scan_signature.classifyBundleEntry(file, opts);
|
|
965
|
+
if (type !== "html" && type !== "js") continue;
|
|
966
|
+
const source = stringifyWebpackSource(compilation?.getAsset(file)?.source.source() ?? asset.source());
|
|
967
|
+
const hash = opts.cache.computeHash(source);
|
|
968
|
+
sourceHashByFile.set(file, hash);
|
|
969
|
+
const previousHash = state.sourceHashByFile.get(file);
|
|
970
|
+
const changed = previousHash == null || previousHash !== hash;
|
|
971
|
+
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
972
|
+
const runtimeAffectingHash = !changed && previousRuntimeAffectingHash != null ? previousRuntimeAffectingHash : (() => {
|
|
973
|
+
const runtimeAffectingSignature = require_source_candidate_scan_signature.createRuntimeAffectingSourceSignature(source, type);
|
|
974
|
+
runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
|
|
975
|
+
return opts.cache.computeHash(runtimeAffectingSignature);
|
|
976
|
+
})();
|
|
977
|
+
runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
978
|
+
if (changed) changedByType[type].add(file);
|
|
979
|
+
if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
|
|
980
|
+
if (firstRun) markProcessFile(type, file, processFiles);
|
|
981
|
+
else if (type === "html") processFiles.html.add(file);
|
|
982
|
+
else if (changed) processFiles.js.add(file);
|
|
983
|
+
entries.push({
|
|
984
|
+
file,
|
|
985
|
+
output: {
|
|
986
|
+
fileName: file,
|
|
987
|
+
name: void 0,
|
|
988
|
+
names: [],
|
|
989
|
+
needsCodeReference: false,
|
|
990
|
+
originalFileName: null,
|
|
991
|
+
originalFileNames: [],
|
|
992
|
+
source,
|
|
993
|
+
type: "asset"
|
|
994
|
+
},
|
|
995
|
+
source,
|
|
996
|
+
type
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
entries,
|
|
1001
|
+
jsEntries: /* @__PURE__ */ new Map(),
|
|
1002
|
+
sourceHashByFile,
|
|
1003
|
+
runtimeAffectingSignatureByFile,
|
|
1004
|
+
runtimeAffectingHashByFile,
|
|
1005
|
+
hasOmittedKnownFiles: false,
|
|
1006
|
+
changedByType,
|
|
1007
|
+
runtimeAffectingChangedByType,
|
|
1008
|
+
processFiles,
|
|
1009
|
+
linkedImpactsByEntry: /* @__PURE__ */ new Map()
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
function releaseWebpackBundleSnapshotSources(snapshot) {
|
|
1013
|
+
for (const entry of snapshot.entries) {
|
|
1014
|
+
entry.source = "";
|
|
1015
|
+
if (entry.output.type === "asset") entry.output.source = "";
|
|
1016
|
+
else entry.output.code = "";
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function stringifyWebpackSource(source) {
|
|
1020
|
+
if (typeof source === "string") return source;
|
|
1021
|
+
return source?.toString() ?? "";
|
|
1022
|
+
}
|
|
1023
|
+
function createWebpackAssetUpdater(options) {
|
|
1024
|
+
const getCurrentAssetSource = (file) => {
|
|
1025
|
+
const asset = options.compilation.getAsset(file);
|
|
1026
|
+
if (!asset) return;
|
|
1027
|
+
return stringifyWebpackSource(asset.source.source());
|
|
1028
|
+
};
|
|
1029
|
+
const updateAssetIfChanged = (file, source, { compare = true, notifyUpdate = true } = {}) => {
|
|
1030
|
+
if (!compare) {
|
|
1031
|
+
options.compilation.updateAsset(file, typeof source === "string" ? new options.ConcatSource(source) : source);
|
|
1032
|
+
return true;
|
|
1033
|
+
}
|
|
1034
|
+
const nextSource = typeof source === "string" ? source : stringifyWebpackSource(source.source());
|
|
1035
|
+
const previousSource = getCurrentAssetSource(file);
|
|
1036
|
+
if (previousSource === nextSource) {
|
|
1037
|
+
options.debug("asset unchanged, skip update: %s", file);
|
|
1038
|
+
return false;
|
|
1039
|
+
}
|
|
1040
|
+
options.compilation.updateAsset(file, typeof source === "string" ? new options.ConcatSource(source) : source);
|
|
1041
|
+
if (notifyUpdate) options.onUpdate(file, previousSource ?? "", nextSource);
|
|
1042
|
+
return true;
|
|
1043
|
+
};
|
|
1044
|
+
return {
|
|
1045
|
+
getCurrentAssetSource,
|
|
1046
|
+
updateAssetIfChanged
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.ts
|
|
1051
|
+
function createWebpackJsAssetModuleGraph(options) {
|
|
1052
|
+
const jsAssets = /* @__PURE__ */ new Map();
|
|
1053
|
+
for (const [file] of options.entries) if (options.compilerOptions.jsMatcher(file) || options.compilerOptions.wxsMatcher(file)) {
|
|
1054
|
+
const absolute = require_source_candidate_scan_signature.toAbsoluteOutputPath(file, options.outputDir);
|
|
1055
|
+
jsAssets.set(absolute, file);
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
jsAssets,
|
|
1059
|
+
moduleGraphOptions: {
|
|
1060
|
+
resolve(specifier, importer) {
|
|
1061
|
+
return require_source_candidate_scan_signature.resolveOutputSpecifier(specifier, importer, options.outputDir, (candidate) => jsAssets.has(candidate));
|
|
1062
|
+
},
|
|
1063
|
+
load: (id) => {
|
|
1064
|
+
const assetName = jsAssets.get(id);
|
|
1065
|
+
if (!assetName) return;
|
|
1066
|
+
const asset = options.compilation.getAsset(assetName);
|
|
1067
|
+
if (!asset) return;
|
|
1068
|
+
const source = asset.source.source();
|
|
1069
|
+
return source == null ? "" : String(source);
|
|
1070
|
+
},
|
|
1071
|
+
filter(id) {
|
|
1072
|
+
return jsAssets.has(id);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
function applyWebpackLinkedJsResults(options) {
|
|
1078
|
+
if (!options.linked) return;
|
|
1079
|
+
for (const [id, { code }] of Object.entries(options.linked)) {
|
|
1080
|
+
const assetName = options.jsAssets.get(id);
|
|
1081
|
+
if (!assetName) continue;
|
|
1082
|
+
const asset = options.compilation.getAsset(assetName);
|
|
1083
|
+
if (!asset) continue;
|
|
1084
|
+
const previousSource = asset.source.source();
|
|
1085
|
+
const previous = previousSource == null ? "" : String(previousSource);
|
|
1086
|
+
if (previous === code) continue;
|
|
1087
|
+
const source = new options.ConcatSource(code);
|
|
1088
|
+
options.compilation.updateAsset(assetName, source);
|
|
1089
|
+
options.compilerOptions.onUpdate(assetName, previous, code);
|
|
1090
|
+
options.debug("js linked handle: %s", assetName);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.ts
|
|
1095
|
+
const WEBPACK_SOURCE_CANDIDATE_SCAN_CACHE_MAX = 2;
|
|
1096
|
+
function trimScanCache(cache) {
|
|
1097
|
+
while (cache.size > WEBPACK_SOURCE_CANDIDATE_SCAN_CACHE_MAX) {
|
|
1098
|
+
const oldestKey = cache.keys().next().value;
|
|
1099
|
+
if (oldestKey === void 0) break;
|
|
1100
|
+
cache.delete(oldestKey);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
function collectWebpackSourceCandidateScanRoots(root, entries, explicit) {
|
|
1104
|
+
const dedupedEntries = dedupeSourceEntries(entries);
|
|
1105
|
+
if (dedupedEntries?.length) return [{
|
|
1106
|
+
entries: dedupedEntries,
|
|
1107
|
+
explicit,
|
|
1108
|
+
root
|
|
1109
|
+
}];
|
|
1110
|
+
if (explicit && dedupedEntries !== void 0) return [];
|
|
1111
|
+
return [{
|
|
1112
|
+
entries: dedupedEntries,
|
|
1113
|
+
root
|
|
1114
|
+
}];
|
|
1115
|
+
}
|
|
1116
|
+
function dedupeSourceEntries(entries) {
|
|
1117
|
+
if (!entries?.length) return entries;
|
|
1118
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1119
|
+
const nextEntries = [];
|
|
1120
|
+
for (const entry of entries) {
|
|
1121
|
+
const key = JSON.stringify({
|
|
1122
|
+
base: node_path.default.resolve(entry.base),
|
|
1123
|
+
negated: entry.negated,
|
|
1124
|
+
pattern: entry.pattern
|
|
1125
|
+
});
|
|
1126
|
+
if (seen.has(key)) continue;
|
|
1127
|
+
seen.add(key);
|
|
1128
|
+
nextEntries.push(entry);
|
|
1129
|
+
}
|
|
1130
|
+
return nextEntries;
|
|
1131
|
+
}
|
|
1132
|
+
function createWebpackSourceCandidateCacheRecord(collector, sourceScan, signatureHash) {
|
|
1133
|
+
return {
|
|
1134
|
+
getSourceCandidatesForEntries: (entries, options) => collector.valuesForEntries(entries, options),
|
|
1135
|
+
signatureHash,
|
|
1136
|
+
tokenSources: collector.sourcesForEntries(sourceScan?.entries)
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
function compactSnapshot(snapshot) {
|
|
1140
|
+
return {
|
|
1141
|
+
candidatesById: [],
|
|
1142
|
+
cssCandidatesById: void 0,
|
|
1143
|
+
inlineExcludedCandidates: snapshot.inlineExcludedCandidates,
|
|
1144
|
+
inlineIncludedCandidates: snapshot.inlineIncludedCandidates,
|
|
1145
|
+
scanCandidatesById: snapshot.scanCandidatesById,
|
|
1146
|
+
sourceById: void 0,
|
|
1147
|
+
transformCandidatesById: void 0
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
function normalizeChangedFiles(changedFiles) {
|
|
1151
|
+
return new Set([...changedFiles ?? []].map((file) => require_v4_engine.resolveSourceScanPath(file)));
|
|
1152
|
+
}
|
|
1153
|
+
async function resolveScanFileSnapshot(file) {
|
|
1154
|
+
try {
|
|
1155
|
+
const stats = await (0, node_fs_promises.stat)(file);
|
|
1156
|
+
const source = await (0, node_fs_promises.readFile)(file, "utf8");
|
|
1157
|
+
return {
|
|
1158
|
+
meta: {
|
|
1159
|
+
contentHash: (0, _weapp_tailwindcss_shared_node.md5)(source),
|
|
1160
|
+
mtimeMs: stats.mtimeMs,
|
|
1161
|
+
size: stats.size
|
|
1162
|
+
},
|
|
1163
|
+
source
|
|
1164
|
+
};
|
|
1165
|
+
} catch (error) {
|
|
1166
|
+
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") return;
|
|
1167
|
+
throw error;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
function isSameFileMeta(left, right) {
|
|
1171
|
+
return left?.contentHash === right?.contentHash && left?.mtimeMs === right?.mtimeMs && left?.size === right?.size;
|
|
1172
|
+
}
|
|
1173
|
+
async function resolveScanFiles(roots, outDir) {
|
|
1174
|
+
const files = /* @__PURE__ */ new Set();
|
|
1175
|
+
await Promise.all(roots.map(async (root) => {
|
|
1176
|
+
const rootFiles = await require_hmr_timing.resolveSourceCandidateScanFiles({
|
|
1177
|
+
entries: root.entries,
|
|
1178
|
+
explicit: root.explicit,
|
|
1179
|
+
filter: require_hmr_timing.isSourceCandidateRequest,
|
|
1180
|
+
outDir,
|
|
1181
|
+
root: root.root
|
|
1182
|
+
});
|
|
1183
|
+
for (const file of rootFiles) files.add(require_v4_engine.resolveSourceScanPath(file));
|
|
1184
|
+
}));
|
|
1185
|
+
return files;
|
|
1186
|
+
}
|
|
1187
|
+
async function syncChangedScanFiles(collector, cachedScan, scanFiles, changedFiles) {
|
|
1188
|
+
for (const file of cachedScan.files.keys()) {
|
|
1189
|
+
if (scanFiles.has(file)) continue;
|
|
1190
|
+
collector.remove(file);
|
|
1191
|
+
cachedScan.files.delete(file);
|
|
1192
|
+
}
|
|
1193
|
+
await Promise.all([...scanFiles].map(async (file) => {
|
|
1194
|
+
const nextSnapshot = await resolveScanFileSnapshot(file);
|
|
1195
|
+
if (!nextSnapshot) {
|
|
1196
|
+
collector.remove(file);
|
|
1197
|
+
cachedScan.files.delete(file);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const previousMeta = cachedScan.files.get(file);
|
|
1201
|
+
if (previousMeta && isSameFileMeta(previousMeta, nextSnapshot.meta) && !changedFiles.has(file)) return;
|
|
1202
|
+
await collector.sync(file, nextSnapshot.source);
|
|
1203
|
+
cachedScan.files.set(file, nextSnapshot.meta);
|
|
1204
|
+
}));
|
|
1205
|
+
}
|
|
1206
|
+
function createWebpackSourceCandidateScanCache() {
|
|
1207
|
+
const scans = /* @__PURE__ */ new Map();
|
|
1208
|
+
let lastHit = false;
|
|
1209
|
+
let lastSignatureHash;
|
|
1210
|
+
async function resolve({ changedFiles, collector, outDir, root, sourceScan, watchMode }) {
|
|
1211
|
+
const explicit = sourceScan?.explicit ?? false;
|
|
1212
|
+
const roots = collectWebpackSourceCandidateScanRoots(root, sourceScan?.entries, explicit);
|
|
1213
|
+
const nextSignatureHash = (0, _weapp_tailwindcss_shared_node.md5)(require_source_candidate_scan_signature.createSourceCandidateScanSignature({
|
|
1214
|
+
inlineCandidates: sourceScan?.inlineCandidates,
|
|
1215
|
+
outDir,
|
|
1216
|
+
roots,
|
|
1217
|
+
scanAllSources: !explicit
|
|
1218
|
+
}));
|
|
1219
|
+
const scanFiles = await resolveScanFiles(roots, outDir);
|
|
1220
|
+
const cachedScan = watchMode ? scans.get(nextSignatureHash) : void 0;
|
|
1221
|
+
if (cachedScan) {
|
|
1222
|
+
collector.restore(cachedScan.snapshot);
|
|
1223
|
+
collector.syncInline(sourceScan?.inlineCandidates);
|
|
1224
|
+
await syncChangedScanFiles(collector, cachedScan, scanFiles, normalizeChangedFiles(changedFiles));
|
|
1225
|
+
cachedScan.snapshot = compactSnapshot(collector.snapshot());
|
|
1226
|
+
lastHit = true;
|
|
1227
|
+
lastSignatureHash = nextSignatureHash;
|
|
1228
|
+
return createWebpackSourceCandidateCacheRecord(collector, sourceScan, nextSignatureHash);
|
|
1229
|
+
}
|
|
1230
|
+
collector.clearScan();
|
|
1231
|
+
collector.syncInline(sourceScan?.inlineCandidates);
|
|
1232
|
+
const files = /* @__PURE__ */ new Map();
|
|
1233
|
+
await Promise.all([...scanFiles].map(async (file) => {
|
|
1234
|
+
const nextSnapshot = await resolveScanFileSnapshot(file);
|
|
1235
|
+
if (!nextSnapshot) return;
|
|
1236
|
+
await collector.sync(file, nextSnapshot.source);
|
|
1237
|
+
files.set(file, nextSnapshot.meta);
|
|
1238
|
+
}));
|
|
1239
|
+
if (watchMode) {
|
|
1240
|
+
scans.set(nextSignatureHash, {
|
|
1241
|
+
files,
|
|
1242
|
+
snapshot: compactSnapshot(collector.snapshot())
|
|
1243
|
+
});
|
|
1244
|
+
trimScanCache(scans);
|
|
1245
|
+
} else scans.clear();
|
|
1246
|
+
lastHit = false;
|
|
1247
|
+
lastSignatureHash = nextSignatureHash;
|
|
1248
|
+
return createWebpackSourceCandidateCacheRecord(collector, sourceScan, nextSignatureHash);
|
|
1249
|
+
}
|
|
1250
|
+
function getMemoryStats() {
|
|
1251
|
+
const cachedScans = [...scans.values()];
|
|
1252
|
+
return {
|
|
1253
|
+
entries: cachedScans.reduce((count, scan) => count + (scan.snapshot.scanCandidatesById?.length ?? scan.snapshot.candidatesById.length), 0),
|
|
1254
|
+
files: cachedScans.reduce((count, scan) => count + scan.files.size, 0),
|
|
1255
|
+
lastHit,
|
|
1256
|
+
signatureHash: lastSignatureHash,
|
|
1257
|
+
snapshots: scans.size
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
return {
|
|
1261
|
+
getMemoryStats,
|
|
1262
|
+
resolve
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
//#endregion
|
|
1266
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.ts
|
|
1267
|
+
async function refreshWebpackSourceCandidates(options) {
|
|
1268
|
+
const root = options.compilerOptions.tailwindcssBasedir ?? node_process.default.cwd();
|
|
1269
|
+
let sourceScan;
|
|
1270
|
+
try {
|
|
1271
|
+
sourceScan = await require_tailwindcss.resolveViteSourceScanEntries(options.compilerOptions, options.runtimeState.tailwindRuntime, {
|
|
1272
|
+
root,
|
|
1273
|
+
outDir: options.outputDir
|
|
1274
|
+
});
|
|
1275
|
+
} catch (error) {
|
|
1276
|
+
options.debug("webpack source candidate scan skipped: %O", error);
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
if (!sourceScan || !sourceScan.explicit && !sourceScan.entries?.length && !sourceScan.inlineCandidates) return;
|
|
1280
|
+
return options.scanCache.resolve({
|
|
1281
|
+
changedFiles: options.watchChangedFiles,
|
|
1282
|
+
collector: require_hmr_timing.createSourceCandidateStore({ bareArbitraryValues: options.compilerOptions.arbitraryValues?.bareArbitraryValues }),
|
|
1283
|
+
outDir: options.outputDir,
|
|
1284
|
+
root,
|
|
1285
|
+
sourceScan,
|
|
1286
|
+
watchMode: options.watchMode
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
|
|
1291
|
+
function setupWebpackV5ProcessAssetsHook(options) {
|
|
1292
|
+
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, isKnownWebpackProcessedCssAsset, isWebpackProcessedCssAsset, consumeRuntimeRefreshRequirement, isWatchMode, getWatchChangedFiles, runtimeClassSetManager, getWebpackCssSources, getWebpackGeneratedCssSources, pruneWebpackCssSources, prepareWebpackCssSources, debug } = options;
|
|
1293
|
+
const { Compilation, sources } = compiler.webpack;
|
|
1294
|
+
const { ConcatSource } = sources;
|
|
1295
|
+
const isWebGeneratorTarget = compilerOptions.generator?.target === "web";
|
|
1296
|
+
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
1297
|
+
const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
1298
|
+
const webpackSourceCandidateScanCache = createWebpackSourceCandidateScanCache();
|
|
1299
|
+
const bundleBuildState = require_source_candidate_scan_signature.createBundleBuildState();
|
|
1300
|
+
const bundleRuntimeClassSetManager = runtimeClassSetManager ?? require_hmr_timing.createBundleRuntimeClassSetManager();
|
|
1301
|
+
const escapeFragments = require_hmr_timing.createEscapeFragments(_weapp_core_escape.MappingChars2String);
|
|
1302
|
+
const processedCssAssetSkipDecisionCache = /* @__PURE__ */ new Map();
|
|
1303
|
+
let webpackWatchRuntimeScanInitialized = false;
|
|
1304
|
+
compiler.hooks.compilation.tap(require_context.pluginName, (compilation) => {
|
|
1305
|
+
compilation.hooks.processAssets.tapPromise({
|
|
1306
|
+
name: require_context.pluginName,
|
|
1307
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
1308
|
+
}, async (assets) => {
|
|
1309
|
+
const entries = Object.entries(assets);
|
|
1310
|
+
if (entries.length === 0) return;
|
|
1311
|
+
const groupedEntries = require_utils.getGroupedEntries(entries, compilerOptions);
|
|
1312
|
+
if (isWebGeneratorTarget && groupedEntries.css.length === 0) return;
|
|
1313
|
+
compilerOptions.onStart();
|
|
1314
|
+
debug("start");
|
|
1315
|
+
await runtimeState.readyPromise;
|
|
1316
|
+
const hmrTimingStartedAt = performance.now();
|
|
1317
|
+
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
1318
|
+
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
1319
|
+
const { updateAssetIfChanged } = createWebpackAssetUpdater({
|
|
1320
|
+
compilation,
|
|
1321
|
+
ConcatSource,
|
|
1322
|
+
onUpdate: compilerOptions.onUpdate,
|
|
1323
|
+
debug
|
|
1324
|
+
});
|
|
1325
|
+
const compilerOutputPath = compilation.compiler?.outputPath ?? compiler.outputPath;
|
|
1326
|
+
const outputDir = compilerOutputPath ? node_path.default.resolve(compilerOutputPath) : compilation.outputOptions?.path ?? node_process.default.cwd();
|
|
1327
|
+
const { jsAssets, moduleGraphOptions } = createWebpackJsAssetModuleGraph({
|
|
1328
|
+
compilation,
|
|
1329
|
+
compilerOptions,
|
|
1330
|
+
entries,
|
|
1331
|
+
outputDir
|
|
1332
|
+
});
|
|
1333
|
+
const watchMode = isWatchMode?.() === true;
|
|
1334
|
+
const cssAssetResources = createWebpackCssAssetResourceMap(compilation.chunks, compilation.chunkGraph, compilerOptions.cssMatcher, (resource, issuer) => resolveWebpackCssAssetModuleResource(resource, issuer, {
|
|
1335
|
+
appType,
|
|
1336
|
+
cssMatcher: compilerOptions.cssMatcher
|
|
1337
|
+
}));
|
|
1338
|
+
const watchChangedFiles = new Set([...getWatchChangedFiles?.() ?? []].map((file) => node_path.default.resolve(file)));
|
|
1339
|
+
const taskConcurrency = watchMode ? require_hmr_timing.resolveTaskConcurrency(1) : void 0;
|
|
1340
|
+
const activeProcessCacheKeys = /* @__PURE__ */ new Set();
|
|
1341
|
+
const activeProcessHashKeys = /* @__PURE__ */ new Set();
|
|
1342
|
+
const rememberProcessCacheKey = (cacheKey, hashKey = cacheKey) => {
|
|
1343
|
+
activeProcessCacheKeys.add(cacheKey);
|
|
1344
|
+
activeProcessHashKeys.add(hashKey);
|
|
1345
|
+
};
|
|
1346
|
+
const activeWebpackAssetResourceFiles = new Set([...cssAssetResources.values()].flatMap((resources) => [...resources].map((resource) => node_path.default.resolve(resource))));
|
|
1347
|
+
const registeredWebpackCssSourceFiles = prepareWebpackCssSources?.(activeWebpackAssetResourceFiles) ?? /* @__PURE__ */ new Set();
|
|
1348
|
+
for (const chunk of compilation.chunks) if (chunk.id) activeProcessHashKeys.add(chunk.id);
|
|
1349
|
+
const cssSources = new Map([...getWebpackCssSources?.() ?? []].map(([file, source]) => [node_path.default.resolve(file), source]));
|
|
1350
|
+
const generatedCssSources = new Map([...getWebpackGeneratedCssSources?.() ?? []].map(([file, source]) => [node_path.default.resolve(file), source]));
|
|
1351
|
+
const { activeWebpackCssSourceFiles, configuredMainCssEntryFiles, getCssHandlerOptions, getCssUserHandlerOptions, hasConfiguredTailwindV4SourceRoots, isSameWebpackSourceScope, resolveWebpackCssSourceFile } = createWebpackCssSourceResolvers({
|
|
1352
|
+
activeWebpackAssetResourceFiles,
|
|
1353
|
+
appType,
|
|
1354
|
+
compilerOptions,
|
|
1355
|
+
compilation,
|
|
1356
|
+
cssAssetResources,
|
|
1357
|
+
cssHandlerOptionsCache,
|
|
1358
|
+
cssSources,
|
|
1359
|
+
cssUserHandlerOptionsCache,
|
|
1360
|
+
groupedCssEntriesLength: groupedEntries.css.length,
|
|
1361
|
+
singleCssAssetFile: groupedEntries.css[0]?.[0],
|
|
1362
|
+
isWebGeneratorTarget,
|
|
1363
|
+
outputDir,
|
|
1364
|
+
runtimeState
|
|
1365
|
+
});
|
|
1366
|
+
const finalizeCssAssetSource = (source, options = {}) => finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options);
|
|
1367
|
+
const webpackSourceCandidates = !isWebGeneratorTarget && groupedEntries.css.length > 0 || cssSources.size > 0 || generatedCssSources.size > 0 || require_hmr_timing.isCssSourceTraceEnabled(compilerOptions) ? await refreshWebpackSourceCandidates({
|
|
1368
|
+
compilerOptions,
|
|
1369
|
+
debug,
|
|
1370
|
+
outputDir,
|
|
1371
|
+
runtimeState,
|
|
1372
|
+
scanCache: webpackSourceCandidateScanCache,
|
|
1373
|
+
watchChangedFiles,
|
|
1374
|
+
watchMode
|
|
1375
|
+
}) : void 0;
|
|
1376
|
+
const webpackSourceCandidateValueSignature = webpackSourceCandidates ? require_source_candidate_scan_signature.createCandidateSignature(webpackSourceCandidates.getSourceCandidatesForEntries(void 0)) : "source-candidates:0";
|
|
1377
|
+
const cssSourceTraceTokenSources = createWebpackCssSourceTraceTokenSources(compilerOptions, webpackSourceCandidates);
|
|
1378
|
+
const cssSourceTraceSignature = require_hmr_timing.createCssSourceTraceCacheSignature(cssSourceTraceTokenSources, compilerOptions);
|
|
1379
|
+
const annotateCss = (css) => require_hmr_timing.annotateCssSourceTrace(css, {
|
|
1380
|
+
opts: compilerOptions,
|
|
1381
|
+
tokenSources: cssSourceTraceTokenSources
|
|
1382
|
+
});
|
|
1383
|
+
const finalizeTracedCss = (css, cssHandlerOptions) => finalizeTracedWebpackCssAsset(css, cssHandlerOptions, {
|
|
1384
|
+
annotateCss,
|
|
1385
|
+
compilerOptions,
|
|
1386
|
+
isWebGeneratorTarget
|
|
1387
|
+
});
|
|
1388
|
+
const hasRuntimeTransformAssets = Boolean(!isWebGeneratorTarget && ((groupedEntries.html?.length ?? 0) > 0 || (groupedEntries.js?.length ?? 0) > 0));
|
|
1389
|
+
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
1390
|
+
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.tailwindRuntime.majorVersion ?? "unknown");
|
|
1391
|
+
let runtimeSet;
|
|
1392
|
+
let runtimeAffectingSourceHash = "runtime-affecting:0";
|
|
1393
|
+
if (isWebGeneratorTarget && !hasRuntimeTransformAssets && !forceRuntimeRefresh) runtimeSet = getRuntimeClassSetSync(runtimeState.tailwindRuntime);
|
|
1394
|
+
else if (watchMode && !forceRuntimeRefresh) {
|
|
1395
|
+
const baseRuntimeSet = getRuntimeClassSetSync(runtimeState.tailwindRuntime);
|
|
1396
|
+
const snapshot = buildWebpackBundleSnapshot(assets, compilerOptions, bundleBuildState, compilation);
|
|
1397
|
+
if (!webpackWatchRuntimeScanInitialized) for (const entry of snapshot.entries) snapshot.runtimeAffectingChangedByType[entry.type].add(entry.file);
|
|
1398
|
+
runtimeAffectingSourceHash = compilerOptions.cache.computeHash([...groupedEntries.html.map(([file, source]) => `${file}:${compilerOptions.cache.computeHash(source.source().toString())}`), ...groupedEntries.js.map(([file, source]) => `${file}:${compilerOptions.cache.computeHash(source.source().toString())}`)].sort().join("\n\n"));
|
|
1399
|
+
try {
|
|
1400
|
+
runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
|
|
1401
|
+
baseClassSet: baseRuntimeSet,
|
|
1402
|
+
skipInitialFullScanWithBase: false
|
|
1403
|
+
});
|
|
1404
|
+
} catch (error) {
|
|
1405
|
+
debug("webpack incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
1406
|
+
await bundleRuntimeClassSetManager.reset();
|
|
1407
|
+
runtimeSet = getRuntimeClassSetSync(runtimeState.tailwindRuntime);
|
|
1408
|
+
}
|
|
1409
|
+
releaseWebpackBundleSnapshotSources(snapshot);
|
|
1410
|
+
require_source_candidate_scan_signature.updateBundleBuildState(bundleBuildState, snapshot, /* @__PURE__ */ new Map(), { incremental: true });
|
|
1411
|
+
webpackWatchRuntimeScanInitialized = true;
|
|
1412
|
+
} else {
|
|
1413
|
+
if (forceRuntimeRefresh) {
|
|
1414
|
+
await bundleRuntimeClassSetManager.reset();
|
|
1415
|
+
webpackWatchRuntimeScanInitialized = false;
|
|
1416
|
+
}
|
|
1417
|
+
runtimeSet = await require_context.ensureRuntimeClassSet(runtimeState, {
|
|
1418
|
+
forceRefresh: forceRuntimeRefresh,
|
|
1419
|
+
forceCollect: !watchMode || forceRuntimeRefresh,
|
|
1420
|
+
clearCache: forceRuntimeRefresh,
|
|
1421
|
+
allowEmpty: false
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
1425
|
+
consumeRuntimeRefreshRequirement();
|
|
1426
|
+
const webpackSourceCandidateSet = webpackSourceCandidates?.getSourceCandidatesForEntries(void 0);
|
|
1427
|
+
const generatorRuntimeSet = new Set(runtimeSet);
|
|
1428
|
+
addRuntimeTransformCandidates(generatorRuntimeSet, webpackSourceCandidateSet);
|
|
1429
|
+
const transformRuntimeSet = new Set(runtimeSet);
|
|
1430
|
+
if (hasRuntimeTransformAssets) for (const [, originalSource] of groupedEntries.css) for (const candidate of collectGeneratedCssRuntimeCandidates(originalSource.source().toString())) transformRuntimeSet.add(candidate);
|
|
1431
|
+
const transformedJsRuntimeCandidates = /* @__PURE__ */ new Set();
|
|
1432
|
+
let currentJsRuntimeCandidates;
|
|
1433
|
+
let currentJsRuntimeTokenSignature;
|
|
1434
|
+
const getWebpackAssetSource = (file) => {
|
|
1435
|
+
return compilation.getAsset(file)?.source;
|
|
1436
|
+
};
|
|
1437
|
+
const getCurrentJsRuntimeCandidates = () => {
|
|
1438
|
+
if (currentJsRuntimeCandidates) return currentJsRuntimeCandidates;
|
|
1439
|
+
currentJsRuntimeCandidates = collectWebpackJsRuntimeCandidatesFromAssets({
|
|
1440
|
+
escapeFragments,
|
|
1441
|
+
getAssetSource: getWebpackAssetSource,
|
|
1442
|
+
isWebGeneratorTarget,
|
|
1443
|
+
jsAssets: jsAssets.values()
|
|
1444
|
+
});
|
|
1445
|
+
return currentJsRuntimeCandidates;
|
|
1446
|
+
};
|
|
1447
|
+
const getCurrentJsRuntimeTokenSignature = () => {
|
|
1448
|
+
if (currentJsRuntimeTokenSignature !== void 0) return currentJsRuntimeTokenSignature;
|
|
1449
|
+
currentJsRuntimeTokenSignature = collectWebpackJsRuntimeTokenSignature({
|
|
1450
|
+
getAssetSource: getWebpackAssetSource,
|
|
1451
|
+
isWebGeneratorTarget,
|
|
1452
|
+
jsAssets: jsAssets.values()
|
|
1453
|
+
});
|
|
1454
|
+
return currentJsRuntimeTokenSignature;
|
|
1455
|
+
};
|
|
1456
|
+
const rememberTransformedRuntimeCandidates = (source) => {
|
|
1457
|
+
currentJsRuntimeCandidates = void 0;
|
|
1458
|
+
currentJsRuntimeTokenSignature = void 0;
|
|
1459
|
+
const code = stringifyWebpackSourceLike(source);
|
|
1460
|
+
for (const candidate of require_hmr_timing.collectStrictEscapedRuntimeCandidates(code, _weapp_core_escape.MappingChars2String, escapeFragments)) if (isRuntimeTransformCandidate(candidate)) transformedJsRuntimeCandidates.add(candidate);
|
|
1461
|
+
};
|
|
1462
|
+
const createRuntimeSetHash = (generatorRuntimeSet) => compilerOptions.cache.computeHash([
|
|
1463
|
+
require_tailwindcss.getRuntimeClassSetSignature(runtimeState.tailwindRuntime),
|
|
1464
|
+
[...runtimeSet].sort().join("\n"),
|
|
1465
|
+
[...transformRuntimeSet].sort().join("\n"),
|
|
1466
|
+
[...generatorRuntimeSet].sort().join("\n"),
|
|
1467
|
+
getCurrentJsRuntimeTokenSignature()
|
|
1468
|
+
].join("\n\n"));
|
|
1469
|
+
const getGeneratorRuntimeSet = () => {
|
|
1470
|
+
const currentJsCandidates = getCurrentJsRuntimeCandidates();
|
|
1471
|
+
if (transformedJsRuntimeCandidates.size === 0 && (!currentJsCandidates || currentJsCandidates.size === 0)) return generatorRuntimeSet;
|
|
1472
|
+
const nextRuntimeSet = new Set(generatorRuntimeSet);
|
|
1473
|
+
for (const candidate of currentJsCandidates) nextRuntimeSet.add(candidate);
|
|
1474
|
+
for (const candidate of transformedJsRuntimeCandidates) nextRuntimeSet.add(candidate);
|
|
1475
|
+
return nextRuntimeSet;
|
|
1476
|
+
};
|
|
1477
|
+
const defaultTemplateHandlerOptions = { runtimeSet: transformRuntimeSet };
|
|
1478
|
+
debug("get runtimeSet, class count: %d, transform class count: %d", runtimeSet.size, transformRuntimeSet.size);
|
|
1479
|
+
const tasks = [];
|
|
1480
|
+
const htmlTaskFactories = [];
|
|
1481
|
+
const cssTaskFactories = [];
|
|
1482
|
+
const enqueueTask = async (factory, target) => {
|
|
1483
|
+
if (watchMode) {
|
|
1484
|
+
await factory();
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
target.push(factory);
|
|
1488
|
+
};
|
|
1489
|
+
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
|
|
1490
|
+
const [file, originalSource] = element;
|
|
1491
|
+
let rawSource;
|
|
1492
|
+
const readRawSource = () => {
|
|
1493
|
+
rawSource ?? (rawSource = originalSource.source().toString());
|
|
1494
|
+
return rawSource;
|
|
1495
|
+
};
|
|
1496
|
+
const cacheKey = file;
|
|
1497
|
+
const hashKey = `${file}:asset`;
|
|
1498
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1499
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1500
|
+
await enqueueTask(async () => {
|
|
1501
|
+
await require_hmr_timing.processCachedTask({
|
|
1502
|
+
cache: compilerOptions.cache,
|
|
1503
|
+
cacheKey,
|
|
1504
|
+
hashKey,
|
|
1505
|
+
rawSource: chunkHash === void 0 ? readRawSource() : void 0,
|
|
1506
|
+
hash: chunkHash,
|
|
1507
|
+
applyResult(source, { cacheHit }) {
|
|
1508
|
+
updateAssetIfChanged(file, source, {
|
|
1509
|
+
compare: !cacheHit,
|
|
1510
|
+
notifyUpdate: !cacheHit
|
|
1511
|
+
});
|
|
1512
|
+
},
|
|
1513
|
+
onCacheHit() {
|
|
1514
|
+
debug("html cache hit: %s", file);
|
|
1515
|
+
},
|
|
1516
|
+
transform: async () => {
|
|
1517
|
+
const source = new ConcatSource(await compilerOptions.templateHandler(readRawSource(), defaultTemplateHandlerOptions));
|
|
1518
|
+
debug("html handle: %s", file);
|
|
1519
|
+
return { result: source };
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
}, htmlTaskFactories);
|
|
1523
|
+
}
|
|
1524
|
+
const jsTaskFactories = [];
|
|
1525
|
+
const enqueueJsTask = async (factory) => {
|
|
1526
|
+
await enqueueTask(factory, jsTaskFactories);
|
|
1527
|
+
};
|
|
1528
|
+
if (!isWebGeneratorTarget && Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
|
|
1529
|
+
const cacheKey = getCacheKey(file);
|
|
1530
|
+
const asset = compilation.getAsset(file);
|
|
1531
|
+
if (!asset) continue;
|
|
1532
|
+
const hashKey = `${file}:asset`;
|
|
1533
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1534
|
+
const absoluteFile = require_source_candidate_scan_signature.toAbsoluteOutputPath(file, outputDir);
|
|
1535
|
+
const initialSource = asset.source.source();
|
|
1536
|
+
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
1537
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1538
|
+
await enqueueJsTask(async () => {
|
|
1539
|
+
await require_hmr_timing.processCachedTask({
|
|
1540
|
+
cache: compilerOptions.cache,
|
|
1541
|
+
cacheKey,
|
|
1542
|
+
hashKey,
|
|
1543
|
+
rawSource: chunkHash === void 0 ? initialRawSource : void 0,
|
|
1544
|
+
hash: chunkHash,
|
|
1545
|
+
applyResult(source, { cacheHit }) {
|
|
1546
|
+
if (updateAssetIfChanged(file, source, {
|
|
1547
|
+
compare: !cacheHit,
|
|
1548
|
+
notifyUpdate: !cacheHit
|
|
1549
|
+
})) rememberTransformedRuntimeCandidates(source);
|
|
1550
|
+
},
|
|
1551
|
+
onCacheHit() {
|
|
1552
|
+
debug("js cache hit: %s", file);
|
|
1553
|
+
},
|
|
1554
|
+
transform: async () => {
|
|
1555
|
+
const currentSourceValue = compilation.getAsset(file)?.source.source();
|
|
1556
|
+
const currentSource = stringifyOptionalWebpackSourceValue(currentSourceValue);
|
|
1557
|
+
const handlerOptions = {
|
|
1558
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1559
|
+
generateMap: false,
|
|
1560
|
+
filename: absoluteFile,
|
|
1561
|
+
moduleGraph: moduleGraphOptions,
|
|
1562
|
+
babelParserOptions: { sourceFilename: absoluteFile }
|
|
1563
|
+
};
|
|
1564
|
+
if (require_context.shouldSkipJsTransform(currentSource, {
|
|
1565
|
+
...handlerOptions,
|
|
1566
|
+
classNameSet: transformRuntimeSet
|
|
1567
|
+
})) return { result: new ConcatSource(currentSource) };
|
|
1568
|
+
const { code, linked } = await compilerOptions.jsHandler(currentSource, transformRuntimeSet, handlerOptions);
|
|
1569
|
+
const source = new ConcatSource(code);
|
|
1570
|
+
debug("js handle: %s", file);
|
|
1571
|
+
applyWebpackLinkedJsResults({
|
|
1572
|
+
ConcatSource,
|
|
1573
|
+
compilation,
|
|
1574
|
+
compilerOptions,
|
|
1575
|
+
debug,
|
|
1576
|
+
jsAssets,
|
|
1577
|
+
linked
|
|
1578
|
+
});
|
|
1579
|
+
return { result: source };
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
for (const element of groupedEntries.css) {
|
|
1585
|
+
const [file, originalSource] = element;
|
|
1586
|
+
let rawSource;
|
|
1587
|
+
const readRawSource = () => {
|
|
1588
|
+
rawSource ?? (rawSource = originalSource.source().toString());
|
|
1589
|
+
return rawSource;
|
|
1590
|
+
};
|
|
1591
|
+
const chunkHash = assetHashByChunk.get(file);
|
|
1592
|
+
const cssHandlerOptionsForProcessedAsset = getCssHandlerOptions(file);
|
|
1593
|
+
const processedCssAssetMetadata = { isMainCssChunk: cssHandlerOptionsForProcessedAsset.isMainChunk };
|
|
1594
|
+
const processedSourceFile = cssHandlerOptionsForProcessedAsset.sourceOptions?.sourceFile;
|
|
1595
|
+
const processedSourceCss = processedSourceFile ? cssSources.get(node_path.default.resolve(processedSourceFile))?.css : void 0;
|
|
1596
|
+
const shouldRegenerateProcessedTailwindV4SourceCss = processedSourceCss !== void 0 && (require_v4_engine.hasTailwindSourceDirectives(processedSourceCss, { importFallback: true }) || processedSourceCss.includes("@config"));
|
|
1597
|
+
const processedCssAssetKnown = isKnownWebpackProcessedCssAsset?.(file, processedCssAssetMetadata) === true;
|
|
1598
|
+
const processedLoaderGeneratedCss = processedSourceFile ? generatedCssSources.get(node_path.default.resolve(processedSourceFile)) : void 0;
|
|
1599
|
+
const processedAssetSourceHash = watchMode && isWebGeneratorTarget && cssHandlerOptionsForProcessedAsset.isMainChunk ? compilerOptions.cache.computeHash(readRawSource()) : chunkHash === void 0 ? processedCssAssetKnown ? "webpack-css-asset:known" : compilerOptions.cache.computeHash(readRawSource()) : "webpack-css-asset:chunk";
|
|
1600
|
+
const processedCssDecisionCacheKey = `${file}:${createRuntimeAwareCssHash(chunkHash, processedAssetSourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`)}`;
|
|
1601
|
+
let currentProcessedRawSource;
|
|
1602
|
+
let hasGeneratedCssMarker = false;
|
|
1603
|
+
let hasTailwindGeneratedAssetCss = false;
|
|
1604
|
+
const readCurrentProcessedRawSource = () => {
|
|
1605
|
+
currentProcessedRawSource ?? (currentProcessedRawSource = readRawSource());
|
|
1606
|
+
return currentProcessedRawSource;
|
|
1607
|
+
};
|
|
1608
|
+
const cachedSkipProcessedCssAsset = processedCssAssetKnown ? processedCssAssetSkipDecisionCache.get(processedCssDecisionCacheKey) : void 0;
|
|
1609
|
+
const shouldRegenerateStaleProcessedWebCssAsset = isWebGeneratorTarget && !processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && webpackSourceCandidateSet !== void 0 && (hasMissingRuntimeCandidates(processedLoaderGeneratedCss?.classSet, webpackSourceCandidateSet) || hasMissingRuntimeCandidates(resolveGeneratedCssRuntimeCandidates(readCurrentProcessedRawSource(), processedLoaderGeneratedCss?.classSet), webpackSourceCandidateSet));
|
|
1610
|
+
if (cachedSkipProcessedCssAsset !== void 0) {
|
|
1611
|
+
hasGeneratedCssMarker = cachedSkipProcessedCssAsset && cssHandlerOptionsForProcessedAsset.isMainChunk;
|
|
1612
|
+
hasTailwindGeneratedAssetCss = hasGeneratedCssMarker;
|
|
1613
|
+
} else {
|
|
1614
|
+
const source = readCurrentProcessedRawSource();
|
|
1615
|
+
hasGeneratedCssMarker = require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(source);
|
|
1616
|
+
hasTailwindGeneratedAssetCss = require_v4_engine.hasTailwindGeneratedCss(source) || require_v4_engine.hasTailwindGeneratedCssMarkers(source);
|
|
1617
|
+
}
|
|
1618
|
+
const hasProcessedAssetTailwindDirectives = () => {
|
|
1619
|
+
const source = readCurrentProcessedRawSource();
|
|
1620
|
+
return require_v4_engine.hasTailwindRootDirectives(source, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(source, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(source);
|
|
1621
|
+
};
|
|
1622
|
+
const shouldForceConfiguredMainCssGeneration = cssHandlerOptionsForProcessedAsset.isMainChunk && hasConfiguredTailwindV4SourceRoots() && !hasGeneratedCssMarker && (configuredMainCssEntryFiles.length > 0 || shouldRegenerateProcessedTailwindV4SourceCss || hasProcessedAssetTailwindDirectives());
|
|
1623
|
+
const hasProcessedMainAssetUserCss = cachedSkipProcessedCssAsset === void 0 && cssHandlerOptionsForProcessedAsset.isMainChunk && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss) && createWebpackUserCssSourceAppend([...cssSources.entries()].map(([sourceFile, source]) => ({
|
|
1624
|
+
...source,
|
|
1625
|
+
file: sourceFile
|
|
1626
|
+
})), readCurrentProcessedRawSource()) !== void 0;
|
|
1627
|
+
const shouldFinalizeProcessedWebCssAsset = isWebGeneratorTarget && !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && require_v4_engine.hasTailwindSourceDirectives(readCurrentProcessedRawSource(), { importFallback: true });
|
|
1628
|
+
const shouldPreserveFinalWebCssAsset = isWebGeneratorTarget && processedSourceFile === void 0 && !shouldForceConfiguredMainCssGeneration && (hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1629
|
+
const shouldSkipKnownProcessedCssAsset = !shouldForceConfiguredMainCssGeneration && !shouldRegenerateProcessedTailwindV4SourceCss && !shouldRegenerateStaleProcessedWebCssAsset && (processedCssAssetKnown || isWebpackProcessedCssAsset?.(file, readCurrentProcessedRawSource(), processedCssAssetMetadata)) && !hasProcessedMainAssetUserCss && (!cssHandlerOptionsForProcessedAsset.isMainChunk || hasGeneratedCssMarker || hasTailwindGeneratedAssetCss);
|
|
1630
|
+
const shouldSkipProcessedCssAsset = cachedSkipProcessedCssAsset ?? (shouldFinalizeProcessedWebCssAsset || shouldPreserveFinalWebCssAsset || shouldSkipKnownProcessedCssAsset);
|
|
1631
|
+
if (processedCssAssetKnown && cachedSkipProcessedCssAsset === void 0 && !shouldFinalizeProcessedWebCssAsset && !shouldPreserveFinalWebCssAsset) processedCssAssetSkipDecisionCache.set(processedCssDecisionCacheKey, shouldSkipProcessedCssAsset === true);
|
|
1632
|
+
if (shouldSkipProcessedCssAsset) {
|
|
1633
|
+
const hashKey = `${file}:asset`;
|
|
1634
|
+
const sourceHash = processedAssetSourceHash;
|
|
1635
|
+
rememberProcessCacheKey(file, hashKey);
|
|
1636
|
+
await enqueueTask(async () => {
|
|
1637
|
+
await require_hmr_timing.processCachedTask({
|
|
1638
|
+
cache: compilerOptions.cache,
|
|
1639
|
+
cacheKey: file,
|
|
1640
|
+
hashKey,
|
|
1641
|
+
rawSource: chunkHash === void 0 && !processedCssAssetKnown ? readCurrentProcessedRawSource() : void 0,
|
|
1642
|
+
hash: createRuntimeAwareCssHash(chunkHash, sourceHash, `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}`),
|
|
1643
|
+
applyResult(source, { cacheHit }) {
|
|
1644
|
+
updateAssetIfChanged(file, source, {
|
|
1645
|
+
compare: !cacheHit,
|
|
1646
|
+
notifyUpdate: !cacheHit
|
|
1647
|
+
});
|
|
1648
|
+
},
|
|
1649
|
+
onCacheHit() {
|
|
1650
|
+
debug("css webpack-loader-pipeline cache hit: %s", file);
|
|
1651
|
+
},
|
|
1652
|
+
transform: async () => {
|
|
1653
|
+
const source = readCurrentProcessedRawSource();
|
|
1654
|
+
const nextCss = stripTrailingLineWhitespace(finalizeCssAssetSource(hasTailwindGeneratedAssetCss && !hasGeneratedCssMarker ? isWebGeneratorTarget ? source : (await compilerOptions.styleHandler(source, cssHandlerOptionsForProcessedAsset)).css : source, { generatedCss: hasGeneratedCssMarker || hasTailwindGeneratedAssetCss }));
|
|
1655
|
+
debug("css skip webpack-loader-pipeline asset: %s", file);
|
|
1656
|
+
return { result: new ConcatSource(finalizeTracedCss(nextCss, cssHandlerOptionsForProcessedAsset)) };
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
}, cssTaskFactories);
|
|
1660
|
+
continue;
|
|
1661
|
+
}
|
|
1662
|
+
const currentRawSource = readRawSource();
|
|
1663
|
+
if (isWebpackCssLoaderRuntimeSource(currentRawSource)) {
|
|
1664
|
+
const hashKey = `${file}:asset`;
|
|
1665
|
+
rememberProcessCacheKey(file, hashKey);
|
|
1666
|
+
await enqueueTask(async () => {
|
|
1667
|
+
await require_hmr_timing.processCachedTask({
|
|
1668
|
+
cache: compilerOptions.cache,
|
|
1669
|
+
cacheKey: file,
|
|
1670
|
+
hashKey,
|
|
1671
|
+
rawSource: currentRawSource,
|
|
1672
|
+
hash: createRuntimeAwareCssHash(chunkHash, compilerOptions.cache.computeHash(currentRawSource), "webpack-css-loader-runtime"),
|
|
1673
|
+
applyResult(source, { cacheHit }) {
|
|
1674
|
+
updateAssetIfChanged(file, source, {
|
|
1675
|
+
compare: !cacheHit,
|
|
1676
|
+
notifyUpdate: !cacheHit
|
|
1677
|
+
});
|
|
1678
|
+
},
|
|
1679
|
+
onCacheHit() {
|
|
1680
|
+
debug("css-loader runtime cache hit: %s", file);
|
|
1681
|
+
},
|
|
1682
|
+
transform: async () => ({ result: new ConcatSource(currentRawSource) })
|
|
1683
|
+
});
|
|
1684
|
+
}, cssTaskFactories);
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
const cacheKey = file;
|
|
1688
|
+
const hashKey = `${file}:asset`;
|
|
1689
|
+
rememberProcessCacheKey(cacheKey, hashKey);
|
|
1690
|
+
const cssHandlerOptionsForHash = getCssHandlerOptions(file, currentRawSource);
|
|
1691
|
+
const cssChunkHash = watchMode && cssHandlerOptionsForHash.isMainChunk ? void 0 : chunkHash;
|
|
1692
|
+
const cssSourceHash = (() => {
|
|
1693
|
+
const sourceFile = resolveWebpackCssSourceFile(file, currentRawSource);
|
|
1694
|
+
const sourceCss = sourceFile ? cssSources.get(sourceFile)?.css : void 0;
|
|
1695
|
+
const generatorSourceCss = removeWebpackGeneratorNonTailwindImports(sourceCss);
|
|
1696
|
+
if (sourceCss === void 0) return sourceFile === void 0 ? "webpack-css-source:0" : `webpack-css-source:0:${sourceFile}`;
|
|
1697
|
+
return `webpack-css-source:1:${compilerOptions.cache.computeHash(sourceCss)}:${generatorSourceCss === sourceCss || generatorSourceCss === void 0 ? "generator-source:0" : compilerOptions.cache.computeHash(generatorSourceCss)}`;
|
|
1698
|
+
})();
|
|
1699
|
+
const runtimeAwareHash = createRuntimeAwareCssHash(cssChunkHash, compilerOptions.cache.computeHash(currentRawSource), `${createRuntimeSetHash(getGeneratorRuntimeSet())}:${runtimeAffectingSourceHash}:${webpackSourceCandidates?.signatureHash ?? "source-candidates:0"}:${webpackSourceCandidateValueSignature}:${cssSourceTraceSignature}:${cssSourceHash}`);
|
|
1700
|
+
await enqueueTask(async () => {
|
|
1701
|
+
await require_hmr_timing.processCachedTask({
|
|
1702
|
+
cache: compilerOptions.cache,
|
|
1703
|
+
cacheKey,
|
|
1704
|
+
hashKey,
|
|
1705
|
+
rawSource: currentRawSource,
|
|
1706
|
+
hash: runtimeAwareHash,
|
|
1707
|
+
applyResult(source, { cacheHit }) {
|
|
1708
|
+
updateAssetIfChanged(file, source, {
|
|
1709
|
+
compare: !cacheHit,
|
|
1710
|
+
notifyUpdate: !cacheHit
|
|
1711
|
+
});
|
|
1712
|
+
},
|
|
1713
|
+
onCacheHit() {
|
|
1714
|
+
debug("css cache hit: %s", file);
|
|
1715
|
+
},
|
|
1716
|
+
transform: async () => {
|
|
1717
|
+
await runtimeState.readyPromise;
|
|
1718
|
+
const cssHandlerOptions = getCssHandlerOptions(file, currentRawSource);
|
|
1719
|
+
const generatorRawSource = resolveWebpackGeneratorRawSource(currentRawSource, cssHandlerOptions);
|
|
1720
|
+
if (isWebpackCssLoaderRuntimeSource(generatorRawSource)) return { result: new ConcatSource(currentRawSource) };
|
|
1721
|
+
const sourceFile = cssHandlerOptions.sourceOptions?.sourceFile;
|
|
1722
|
+
const loaderGeneratedCss = sourceFile && !isWebGeneratorTarget ? generatedCssSources.get(node_path.default.resolve(sourceFile)) : void 0;
|
|
1723
|
+
const sourceCss = sourceFile ? cssSources.get(node_path.default.resolve(sourceFile))?.css : void 0;
|
|
1724
|
+
const shouldRegenerateExplicitTailwindV4CssSource = sourceCss !== void 0 && (require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1725
|
+
if (loaderGeneratedCss && (!shouldRegenerateExplicitTailwindV4CssSource || require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(currentRawSource))) {
|
|
1726
|
+
for (const className of loaderGeneratedCss.classSet) {
|
|
1727
|
+
generatorRuntimeSet.add(className);
|
|
1728
|
+
transformRuntimeSet.add(className);
|
|
1729
|
+
}
|
|
1730
|
+
for (const dependency of loaderGeneratedCss.dependencies) compilation.fileDependencies?.add?.(dependency);
|
|
1731
|
+
const currentRawSourceWithoutBundlerMarkers = require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(currentRawSource);
|
|
1732
|
+
const currentAssetHasProcessedUrl = hasProcessedCssAssetUrl(currentRawSourceWithoutBundlerMarkers) && currentRawSourceWithoutBundlerMarkers !== loaderGeneratedCss.css;
|
|
1733
|
+
const currentAssetUserCss = currentAssetHasProcessedUrl ? currentRawSourceWithoutBundlerMarkers : shouldUseWebpackAssetAsGeneratorUserCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css, { processed: true }) ? require_hmr_timing.removeGeneratedSelectorCompatCss(currentRawSourceWithoutBundlerMarkers, loaderGeneratedCss.css) : void 0;
|
|
1734
|
+
const css = finalizeTracedCss(finalizeCssAssetSource(currentAssetUserCss === void 0 ? loaderGeneratedCss.css : createWebpackGeneratorUserCssSourceAppend({
|
|
1735
|
+
css: currentAssetHasProcessedUrl ? require_hmr_timing.removeGeneratedSelectorCompatCss(loaderGeneratedCss.css, currentAssetUserCss) : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(currentAssetUserCss, loaderGeneratedCss.css),
|
|
1736
|
+
processed: true
|
|
1737
|
+
}, {
|
|
1738
|
+
css: currentAssetUserCss,
|
|
1739
|
+
processed: true
|
|
1740
|
+
}).css, { generatedCss: true }), cssHandlerOptions);
|
|
1741
|
+
debug("css consume webpack loader generation: %s <- %s", file, sourceFile);
|
|
1742
|
+
return { result: new ConcatSource(css) };
|
|
1743
|
+
}
|
|
1744
|
+
const sourceCssProcessed = sourceFile ? cssSources.get(node_path.default.resolve(sourceFile))?.processed === true : false;
|
|
1745
|
+
const registeredUserRawSource = createWebpackUserCssSourceAppend([...cssSources.entries()].map(([registeredSourceFile, source]) => ({
|
|
1746
|
+
...source,
|
|
1747
|
+
file: registeredSourceFile
|
|
1748
|
+
})), generatorRawSource, sourceFile, (registeredSourceFile) => isSameWebpackSourceScope(file, registeredSourceFile, sourceFile));
|
|
1749
|
+
const currentAssetLooksGenerated = require_v4_engine.hasTailwindGeneratedCss(currentRawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(currentRawSource);
|
|
1750
|
+
const currentAssetHasBundlerGeneratedMarker = require_source_candidate_scan_signature.hasBundlerGeneratedCssMarker(currentRawSource);
|
|
1751
|
+
const currentAssetUserCssSource = currentAssetLooksGenerated ? removeWebpackTailwindGeneratedAssetCss(currentRawSource) : currentRawSource;
|
|
1752
|
+
const currentAssetHasAdditionalUserCss = currentAssetLooksGenerated && (hasAdditionalWebpackAssetUserCssMarkers(currentAssetUserCssSource, generatorRawSource) || currentAssetUserCssSource.trim().length > 0);
|
|
1753
|
+
const shouldPreserveGeneratedWebAssetUserCss = isWebGeneratorTarget && currentAssetLooksGenerated && !currentAssetHasBundlerGeneratedMarker && !currentAssetHasAdditionalUserCss;
|
|
1754
|
+
const hasExplicitSourceCssForCurrentAsset = sourceCss !== void 0 && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss));
|
|
1755
|
+
const currentAssetHasUserCss = (sourceCssProcessed || hasExplicitSourceCssForCurrentAsset) && currentAssetLooksGenerated && !shouldPreserveGeneratedWebAssetUserCss ? currentAssetHasAdditionalUserCss : shouldUseWebpackAssetAsGeneratorUserCss(currentAssetUserCssSource, generatorRawSource, { processed: sourceCssProcessed || shouldPreserveGeneratedWebAssetUserCss });
|
|
1756
|
+
const userRawSource = createWebpackGeneratorUserCssSourceAppend(createWebpackCurrentAssetUserRawSource({
|
|
1757
|
+
currentAssetHasUserCss,
|
|
1758
|
+
currentAssetLooksGenerated,
|
|
1759
|
+
currentAssetUserCssSource,
|
|
1760
|
+
shouldAppendCurrentAssetUserCss: shouldAppendCurrentWebpackAssetUserCss({
|
|
1761
|
+
currentAssetHasBundlerGeneratedMarker,
|
|
1762
|
+
currentAssetHasUserCss,
|
|
1763
|
+
currentAssetLooksGenerated,
|
|
1764
|
+
registeredUserRawSource,
|
|
1765
|
+
shouldPreserveGeneratedWebAssetUserCss,
|
|
1766
|
+
sourceCssProcessed
|
|
1767
|
+
}),
|
|
1768
|
+
sourceCssProcessed
|
|
1769
|
+
}), registeredUserRawSource);
|
|
1770
|
+
if (require_hmr_timing.isPureLocalCssImportWrapper(currentRawSource)) return { result: new ConcatSource(require_v4_engine.removeTailwindSourceDirectives(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
|
|
1771
|
+
const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
|
|
1772
|
+
const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1773
|
+
const shouldForceTailwindV4Generation = cssHandlerOptions.isMainChunk && hasConfiguredTailwindV4SourceRoots() && (configuredMainCssEntryFiles.length > 0 || require_v4_engine.hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(generatorRawSource) || hasExplicitTailwindV4SourceCss);
|
|
1774
|
+
const resolvedScopedGeneratorRuntimeSet = await require_source_candidate_scan_signature.createScopedGeneratorRuntime({
|
|
1775
|
+
cssHandlerOptions,
|
|
1776
|
+
fallbackRuntime: hasExplicitTailwindV4SourceCss ? /* @__PURE__ */ new Set() : fallbackGeneratorRuntimeSet,
|
|
1777
|
+
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
1778
|
+
majorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1779
|
+
outputFile: file,
|
|
1780
|
+
rawSource: sourceFile ? cssSources.get(node_path.default.resolve(sourceFile))?.css ?? generatorRawSource : generatorRawSource,
|
|
1781
|
+
shouldExcludeSubpackageSourceCandidates: () => false,
|
|
1782
|
+
sourceFile: sourceFile ?? file,
|
|
1783
|
+
scopedSourceCandidateGetter: webpackSourceCandidates?.getSourceCandidatesForEntries
|
|
1784
|
+
});
|
|
1785
|
+
const scopedGeneratorRuntimeSet = !hasExplicitTailwindV4SourceCss && resolvedScopedGeneratorRuntimeSet !== fallbackGeneratorRuntimeSet ? new Set([...fallbackGeneratorRuntimeSet, ...resolvedScopedGeneratorRuntimeSet]) : resolvedScopedGeneratorRuntimeSet;
|
|
1786
|
+
const generatorCssSources = normalizeWebpackGeneratorCssSources(cssHandlerOptions.sourceOptions?.cssSources);
|
|
1787
|
+
const generatorCssHandlerOptions = generatorCssSources === void 0 ? cssHandlerOptions : {
|
|
1788
|
+
...cssHandlerOptions,
|
|
1789
|
+
sourceOptions: {
|
|
1790
|
+
...cssHandlerOptions.sourceOptions,
|
|
1791
|
+
cssSources: generatorCssSources
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
const generatorOptions = {
|
|
1795
|
+
opts: compilerOptions,
|
|
1796
|
+
runtimeState,
|
|
1797
|
+
runtime: scopedGeneratorRuntimeSet,
|
|
1798
|
+
rawSource: generatorRawSource,
|
|
1799
|
+
forceGenerator: shouldForceTailwindV4Generation,
|
|
1800
|
+
...hasUsableWebpackGeneratorCssSources(generatorCssSources) ? { cssSources: generatorCssSources } : {},
|
|
1801
|
+
...userRawSource === void 0 ? {} : { userRawSource: userRawSource.css },
|
|
1802
|
+
...userRawSource?.processed === true ? { userRawSourceProcessed: true } : {},
|
|
1803
|
+
file,
|
|
1804
|
+
cssHandlerOptions: generatorCssHandlerOptions,
|
|
1805
|
+
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
1806
|
+
getSourceCandidatesForEntries: webpackSourceCandidates?.getSourceCandidatesForEntries,
|
|
1807
|
+
sourceCandidates: scopedGeneratorRuntimeSet,
|
|
1808
|
+
restoreLocalCssImports: false,
|
|
1809
|
+
styleHandler: compilerOptions.styleHandler,
|
|
1810
|
+
debug
|
|
1811
|
+
};
|
|
1812
|
+
let generated;
|
|
1813
|
+
try {
|
|
1814
|
+
generated = await require_source_candidate_scan_signature.generateTailwindV4Css({
|
|
1815
|
+
...generatorOptions,
|
|
1816
|
+
outputFile: file
|
|
1817
|
+
});
|
|
1818
|
+
} catch (error) {
|
|
1819
|
+
if (!shouldFallbackToWebpackUserCssOnGeneratorError({
|
|
1820
|
+
configuredMainCssEntryFilesLength: configuredMainCssEntryFiles.length,
|
|
1821
|
+
generatorRawSource,
|
|
1822
|
+
hasExplicitTailwindV4SourceCss
|
|
1823
|
+
})) throw error;
|
|
1824
|
+
debug("css generator skipped for plain webpack css asset: %s %O", file, error);
|
|
1825
|
+
generated = void 0;
|
|
1826
|
+
}
|
|
1827
|
+
const source = new ConcatSource(finalizeTracedCss(generated ? finalizeCssAssetSource(isWebGeneratorTarget && currentRawSource.includes("tailwindcss v4.") ? createWebpackGeneratorUserCssSourceAppend({
|
|
1828
|
+
css: generated.css,
|
|
1829
|
+
processed: true
|
|
1830
|
+
}, {
|
|
1831
|
+
css: removeWebpackTailwindGeneratedAssetCss(currentRawSource),
|
|
1832
|
+
processed: true
|
|
1833
|
+
})?.css ?? generated.css : generated.css, { generatedCss: true }) : isWebGeneratorTarget ? finalizeCssAssetSource(generatorRawSource, { generatedCss: false }) : finalizeCssAssetSource((await compilerOptions.styleHandler(generatorRawSource, cssHandlerOptions)).css, { generatedCss: false }), cssHandlerOptions));
|
|
1834
|
+
if (generated) {
|
|
1835
|
+
for (const className of generated.classSet) generatorRuntimeSet.add(className);
|
|
1836
|
+
debug("css handle via tailwind v%s engine(%s): %s", runtimeState.tailwindRuntime.majorVersion, generated.target, file);
|
|
1837
|
+
} else debug("css handle: %s", file);
|
|
1838
|
+
return { result: source };
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
}, cssTaskFactories);
|
|
1842
|
+
}
|
|
1843
|
+
if (!watchMode) {
|
|
1844
|
+
require_hmr_timing.pushConcurrentTaskFactories(tasks, htmlTaskFactories, taskConcurrency);
|
|
1845
|
+
await Promise.all(tasks);
|
|
1846
|
+
tasks.length = 0;
|
|
1847
|
+
require_hmr_timing.pushConcurrentTaskFactories(tasks, jsTaskFactories, taskConcurrency);
|
|
1848
|
+
await Promise.all(tasks);
|
|
1849
|
+
tasks.length = 0;
|
|
1850
|
+
require_hmr_timing.pushConcurrentTaskFactories(tasks, cssTaskFactories, taskConcurrency);
|
|
1851
|
+
}
|
|
1852
|
+
await Promise.all(tasks);
|
|
1853
|
+
compilerOptions.cache.prune?.({
|
|
1854
|
+
cacheKeys: activeProcessCacheKeys,
|
|
1855
|
+
hashKeys: activeProcessHashKeys
|
|
1856
|
+
});
|
|
1857
|
+
const activeCssFiles = new Set(groupedEntries.css.map(([file]) => file));
|
|
1858
|
+
pruneWebpackCssHandlerOptionCaches(cssHandlerOptionsCache, cssUserHandlerOptionsCache, activeCssFiles);
|
|
1859
|
+
if (activeCssFiles.size > 0) pruneWebpackCssSources?.(new Set([
|
|
1860
|
+
...registeredWebpackCssSourceFiles,
|
|
1861
|
+
...activeWebpackCssSourceFiles,
|
|
1862
|
+
...[...cssAssetResources.values()].flatMap((resources) => [...resources])
|
|
1863
|
+
]), { watchMode });
|
|
1864
|
+
debug("end");
|
|
1865
|
+
require_hmr_timing.emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt, { memoryDebug: resolveWebpackMemoryDebugStats({
|
|
1866
|
+
activeAssetFiles: entries.length,
|
|
1867
|
+
activeCssFiles: activeCssFiles.size,
|
|
1868
|
+
activeProcessCacheKeys,
|
|
1869
|
+
activeProcessHashKeys,
|
|
1870
|
+
cache: compilerOptions.cache,
|
|
1871
|
+
cssHandlerOptionsCache,
|
|
1872
|
+
cssUserHandlerOptionsCache,
|
|
1873
|
+
phase: "processAssets",
|
|
1874
|
+
sourceCandidateScan: webpackSourceCandidateScanCache.getMemoryStats()
|
|
1875
|
+
}) });
|
|
1876
|
+
compilerOptions.onEnd();
|
|
1877
|
+
});
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
//#endregion
|
|
1881
|
+
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
1882
|
+
const runtimeRegistryHolder = globalThis;
|
|
1883
|
+
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
1884
|
+
function setWebpackLoaderRuntime(key, entry) {
|
|
1885
|
+
runtimeRegistry.set(key, entry);
|
|
1886
|
+
}
|
|
1887
|
+
function deleteWebpackLoaderRuntime(key) {
|
|
1888
|
+
runtimeRegistry.delete(key);
|
|
1889
|
+
}
|
|
1890
|
+
//#endregion
|
|
1891
|
+
//#region src/bundlers/webpack/shared/loader-anchors.ts
|
|
1892
|
+
const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
1893
|
+
const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
1894
|
+
const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
|
|
1895
|
+
function createFinder(targets) {
|
|
1896
|
+
return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
|
|
1897
|
+
}
|
|
1898
|
+
function createPrioritizedFinder(targets) {
|
|
1899
|
+
return (entries) => {
|
|
1900
|
+
for (const target of targets) {
|
|
1901
|
+
const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
|
|
1902
|
+
if (idx !== -1) return idx;
|
|
1903
|
+
}
|
|
1904
|
+
return -1;
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
function createLoaderAnchorFinders(appType) {
|
|
1908
|
+
if (isMpx(appType)) return {
|
|
1909
|
+
findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
|
|
1910
|
+
findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
|
|
1911
|
+
};
|
|
1912
|
+
const fallbackFinder = createFinder(["postcss-loader"]);
|
|
1913
|
+
return {
|
|
1914
|
+
findRewriteAnchor: fallbackFinder,
|
|
1915
|
+
findClassSetAnchor: fallbackFinder
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
//#endregion
|
|
1919
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
1920
|
+
function setupWebpackV5Loaders(options) {
|
|
1921
|
+
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, registerAutoCssSource, runtimeState, getClassSetInLoader, getRuntimeSetInLoader, markWebpackProcessedCssSource, markWebpackCssSourceModule, registerWebpackGeneratedCss, registerWebpackCssSourceFile, getRuntimeWatchDependencies, runtimeRegistryKey = `weapp-tailwindcss-${Date.now()}-${Math.random().toString(36).slice(2)}`, debug } = options;
|
|
1922
|
+
const isMpxApp = isMpx(appType);
|
|
1923
|
+
const generatorTarget = compilerOptions.generator?.target ?? require_v4_engine.inferGeneratorTargetFromEnv();
|
|
1924
|
+
const generatorBranch = require_generator.resolveRuntimeBranch({
|
|
1925
|
+
appType: compilerOptions.appType,
|
|
1926
|
+
generatorTarget,
|
|
1927
|
+
platform: compilerOptions.cssOptions?.platform ?? compilerOptions.platform,
|
|
1928
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
1929
|
+
uniAppX: compilerOptions.uniAppX
|
|
1930
|
+
});
|
|
1931
|
+
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
1932
|
+
const runtimeClassSetLoader = runtimeLoaderPath ?? node_path.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
1933
|
+
const shouldInjectRuntimeClassSetLoader = !generatorBranch.isWeb;
|
|
1934
|
+
const shouldInjectCssImportRewriteLoader = shouldRewriteCssImports || !generatorBranch.isWeb || runtimeState.tailwindRuntime.majorVersion === 4;
|
|
1935
|
+
const runtimeCssImportRewriteLoader = shouldInjectCssImportRewriteLoader ? node_path.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
1936
|
+
const runtimeClassSetLoaderExists = node_fs.default.existsSync(runtimeClassSetLoader);
|
|
1937
|
+
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
1938
|
+
const runtimeLoaderRewriteOptions = shouldInjectCssImportRewriteLoader ? {
|
|
1939
|
+
pkgDir: weappTailwindcssPackageDir,
|
|
1940
|
+
compilerOptions,
|
|
1941
|
+
runtimeState,
|
|
1942
|
+
...appType === void 0 ? {} : { appType },
|
|
1943
|
+
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource },
|
|
1944
|
+
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile },
|
|
1945
|
+
getRuntimeSet: getRuntimeSetInLoader,
|
|
1946
|
+
...markWebpackProcessedCssSource === void 0 ? {} : { markGeneratedCssSource: markWebpackProcessedCssSource },
|
|
1947
|
+
...registerWebpackGeneratedCss === void 0 ? {} : { registerGeneratedCss: registerWebpackGeneratedCss }
|
|
1948
|
+
} : void 0;
|
|
1949
|
+
setWebpackLoaderRuntime(runtimeRegistryKey, {
|
|
1950
|
+
classSet: {
|
|
1951
|
+
getClassSet: getClassSetInLoader,
|
|
1952
|
+
getWatchDependencies: getRuntimeWatchDependencies,
|
|
1953
|
+
...registerWebpackCssSourceFile === void 0 ? {} : { registerCssSourceFile: registerWebpackCssSourceFile }
|
|
1954
|
+
},
|
|
1955
|
+
...runtimeLoaderRewriteOptions === void 0 ? {} : { cssImportRewrite: runtimeLoaderRewriteOptions }
|
|
1956
|
+
});
|
|
1957
|
+
const cleanupWebpackLoaderRuntime = () => {
|
|
1958
|
+
deleteWebpackLoaderRuntime(runtimeRegistryKey);
|
|
1959
|
+
};
|
|
1960
|
+
compiler.hooks.watchClose?.tap?.(require_context.pluginName, cleanupWebpackLoaderRuntime);
|
|
1961
|
+
compiler.hooks.shutdown?.tap?.(require_context.pluginName, cleanupWebpackLoaderRuntime);
|
|
1962
|
+
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
1963
|
+
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewriteRuntimeKey: runtimeRegistryKey } : void 0;
|
|
1964
|
+
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
1965
|
+
const createRuntimeClassSetLoaderEntry = () => ({
|
|
1966
|
+
loader: runtimeClassSetLoader,
|
|
1967
|
+
options: { weappTailwindcssRuntimeKey: runtimeRegistryKey },
|
|
1968
|
+
ident: null,
|
|
1969
|
+
type: null
|
|
1970
|
+
});
|
|
1971
|
+
const createCssImportRewriteLoaderEntry = () => {
|
|
1972
|
+
if (!runtimeCssImportRewriteLoader || !cssImportRewriteLoaderOptions) return null;
|
|
1973
|
+
return {
|
|
1974
|
+
loader: runtimeCssImportRewriteLoader,
|
|
1975
|
+
options: cssImportRewriteLoaderOptions,
|
|
1976
|
+
ident: null,
|
|
1977
|
+
type: null
|
|
1978
|
+
};
|
|
1979
|
+
};
|
|
1980
|
+
const { NormalModule } = compiler.webpack;
|
|
1981
|
+
compiler.hooks.compilation.tap(require_context.pluginName, (compilation) => {
|
|
1982
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(require_context.pluginName, (_loaderContext, module) => {
|
|
1983
|
+
if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
|
|
1984
|
+
patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
|
|
1985
|
+
const loaderEntries = module.loaders || [];
|
|
1986
|
+
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
1987
|
+
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
1988
|
+
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
1989
|
+
if (isCssModule && typeof module.resource === "string") markWebpackCssSourceModule?.(module.resource);
|
|
1990
|
+
if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"] && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
1991
|
+
rewriteAnchorIdx,
|
|
1992
|
+
classSetAnchorIdx
|
|
1993
|
+
});
|
|
1994
|
+
if (node_process.default.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), {
|
|
1995
|
+
rewriteAnchorIdx,
|
|
1996
|
+
classSetAnchorIdx
|
|
1997
|
+
});
|
|
1998
|
+
if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) return;
|
|
1999
|
+
const anchorlessInsert = (entry, position) => {
|
|
2000
|
+
if (position === "after") loaderEntries.push(entry);
|
|
2001
|
+
else loaderEntries.unshift(entry);
|
|
2002
|
+
};
|
|
2003
|
+
if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader && isCssModule) {
|
|
2004
|
+
const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
|
|
2005
|
+
const rewriteLoaderEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
|
|
2006
|
+
if (rewriteLoaderEntry) {
|
|
2007
|
+
const anchorIndex = findRewriteAnchor(loaderEntries);
|
|
2008
|
+
if (anchorIndex === -1) anchorlessInsert(rewriteLoaderEntry, "after");
|
|
2009
|
+
else loaderEntries.splice(anchorIndex + 1, 0, rewriteLoaderEntry);
|
|
2010
|
+
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (shouldInjectRuntimeClassSetLoader && runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
|
|
2014
|
+
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
2015
|
+
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
2016
|
+
if (anchorIndex === -1) anchorlessInsert(classSetLoaderEntry, "before");
|
|
2017
|
+
else {
|
|
2018
|
+
const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
|
|
2019
|
+
loaderEntries.splice(insertIndex, 0, classSetLoaderEntry);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
//#endregion
|
|
2026
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
2027
|
+
const debug = require_context.createDebug();
|
|
2028
|
+
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
2029
|
+
const outputIgnoredPredicatePath = Symbol("weapp-tailwindcss.outputIgnoredPredicatePath");
|
|
2030
|
+
function normalizeIgnoredList(ignored) {
|
|
2031
|
+
return (Array.isArray(ignored) ? [...ignored] : [ignored]).filter((item) => typeof item === "string" || item instanceof RegExp || typeof item === "function");
|
|
2032
|
+
}
|
|
2033
|
+
function createOutputIgnoredPredicate(ignoredList, ignoredPath) {
|
|
2034
|
+
const predicate = (file) => {
|
|
2035
|
+
const resolvedFile = node_path.default.resolve(file);
|
|
2036
|
+
if (resolvedFile === ignoredPath || resolvedFile.startsWith(`${ignoredPath}${node_path.default.sep}`)) return true;
|
|
2037
|
+
const normalizedFile = file.replace(/\\/g, "/");
|
|
2038
|
+
return ignoredList.some((item) => {
|
|
2039
|
+
if (typeof item === "string") {
|
|
2040
|
+
const resolvedItem = node_path.default.resolve(item);
|
|
2041
|
+
if (resolvedFile === resolvedItem || resolvedFile.startsWith(`${resolvedItem}${node_path.default.sep}`)) return true;
|
|
2042
|
+
return micromatch.default.isMatch(normalizedFile, item);
|
|
2043
|
+
}
|
|
2044
|
+
if (item instanceof RegExp) return item.test(normalizedFile);
|
|
2045
|
+
return item(file);
|
|
2046
|
+
});
|
|
2047
|
+
};
|
|
2048
|
+
predicate[outputIgnoredPredicatePath] = ignoredPath;
|
|
2049
|
+
return predicate;
|
|
2050
|
+
}
|
|
2051
|
+
function appendIgnoredPath(ignored, ignoredPath) {
|
|
2052
|
+
if (typeof ignored === "function" && ignored[outputIgnoredPredicatePath] === ignoredPath) return ignored;
|
|
2053
|
+
const ignoredList = normalizeIgnoredList(ignored);
|
|
2054
|
+
if (ignoredList.some((item) => typeof item !== "string")) return createOutputIgnoredPredicate(ignoredList, ignoredPath);
|
|
2055
|
+
if (ignoredList.some((item) => typeof item === "string" && node_path.default.resolve(item) === ignoredPath)) return ignored;
|
|
2056
|
+
return [...ignoredList, ignoredPath];
|
|
2057
|
+
}
|
|
2058
|
+
function setupWebpackWatchOutputIgnore(compiler) {
|
|
2059
|
+
const appendOutputIgnoredPath = (watchOptions, outputPath) => {
|
|
2060
|
+
const resolvedOutputPath = outputPath || compiler.outputPath || compiler.options?.output?.path;
|
|
2061
|
+
const outputDir = resolvedOutputPath ? node_path.default.resolve(resolvedOutputPath) : void 0;
|
|
2062
|
+
if (!outputDir) return watchOptions;
|
|
2063
|
+
if (watchOptions && typeof watchOptions === "object") {
|
|
2064
|
+
const nextIgnored = appendIgnoredPath(watchOptions.ignored, outputDir);
|
|
2065
|
+
if (nextIgnored === void 0) delete watchOptions.ignored;
|
|
2066
|
+
else watchOptions.ignored = nextIgnored;
|
|
2067
|
+
return watchOptions;
|
|
2068
|
+
}
|
|
2069
|
+
return { ignored: appendIgnoredPath(void 0, outputDir) };
|
|
2070
|
+
};
|
|
2071
|
+
const compilerWatchOptions = appendOutputIgnoredPath(compiler.options.watchOptions);
|
|
2072
|
+
if (compilerWatchOptions) compiler.options.watchOptions = compilerWatchOptions;
|
|
2073
|
+
const syncOutputIgnoredPath = () => {
|
|
2074
|
+
const outputPath = compiler.outputPath || compiler.options?.output?.path;
|
|
2075
|
+
const watchOptions = compiler.watching?.watchOptions;
|
|
2076
|
+
if (watchOptions) appendOutputIgnoredPath(watchOptions, outputPath);
|
|
2077
|
+
};
|
|
2078
|
+
compiler.hooks.watchRun?.tap(require_context.pluginName, syncOutputIgnoredPath);
|
|
2079
|
+
compiler.hooks.thisCompilation?.tap(require_context.pluginName, (compilation) => {
|
|
2080
|
+
const outputPath = compilation.compiler?.outputPath || compilation.outputOptions?.path;
|
|
2081
|
+
const watchOptions = compiler.watching?.watchOptions;
|
|
2082
|
+
if (watchOptions) appendOutputIgnoredPath(watchOptions, outputPath);
|
|
2083
|
+
else {
|
|
2084
|
+
const compilerWatchOptions = appendOutputIgnoredPath(compiler.options.watchOptions, outputPath);
|
|
2085
|
+
if (compilerWatchOptions) compiler.options.watchOptions = compilerWatchOptions;
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* @name WeappTailwindcss
|
|
2091
|
+
* @description webpack5 核心转义插件
|
|
2092
|
+
* @link https://tw.icebreaker.top/docs/intro
|
|
2093
|
+
*/
|
|
2094
|
+
var WeappTailwindcss = class {
|
|
2095
|
+
constructor(options = {}) {
|
|
2096
|
+
require_context._defineProperty(this, "options", void 0);
|
|
2097
|
+
require_context._defineProperty(this, "appType", void 0);
|
|
2098
|
+
require_context._defineProperty(this, "hasInitialTailwindCssRoots", void 0);
|
|
2099
|
+
this.hasInitialTailwindCssRoots = require_v4_engine.hasConfiguredTailwindV4CssRoots(options);
|
|
2100
|
+
this.options = require_context.getCompilerContext({
|
|
2101
|
+
...options,
|
|
2102
|
+
__internalDeferMissingCssEntriesWarning: true
|
|
2103
|
+
});
|
|
2104
|
+
this.appType = this.options.appType;
|
|
2105
|
+
}
|
|
2106
|
+
apply(compiler) {
|
|
2107
|
+
compiler.options = compiler.options || {};
|
|
2108
|
+
const { disabled, onLoad, runtimeLoaderPath, tailwindRuntime, refreshTailwindcssRuntime } = this.options;
|
|
2109
|
+
const initialTailwindRuntime = tailwindRuntime;
|
|
2110
|
+
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
2111
|
+
const disabledOptions = require_source_candidate_scan_signature.resolvePluginDisabledState(disabled);
|
|
2112
|
+
const shouldRewriteCssImports = this.options.rewriteCssImports === true;
|
|
2113
|
+
const isMpxApp = isMpx(this.appType);
|
|
2114
|
+
if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
2115
|
+
if (disabledOptions.plugin) return;
|
|
2116
|
+
if (initialTailwindRuntime.majorVersion !== 4) throw new Error("weapp-tailwindcss/webpack 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
2117
|
+
setupWebpackWatchOutputIgnore(compiler);
|
|
2118
|
+
const runtimeState = {
|
|
2119
|
+
tailwindRuntime: initialTailwindRuntime,
|
|
2120
|
+
readyPromise: require_context.createTailwindRuntimeReadyPromise(initialTailwindRuntime),
|
|
2121
|
+
refreshTailwindcssRuntime: refreshTailwindRuntime
|
|
2122
|
+
};
|
|
2123
|
+
let runtimeSetPrepared = false;
|
|
2124
|
+
let runtimeSetSignature;
|
|
2125
|
+
let runtimeRefreshRequiredForCompilation = false;
|
|
2126
|
+
let watchRunObserved = false;
|
|
2127
|
+
const runtimeWatchDependencyFiles = /* @__PURE__ */ new Set();
|
|
2128
|
+
const runtimeWatchDependencyContexts = /* @__PURE__ */ new Set();
|
|
2129
|
+
const webpackProcessedCssSourceFiles = /* @__PURE__ */ new Set();
|
|
2130
|
+
const webpackCssSources = /* @__PURE__ */ new Map();
|
|
2131
|
+
const webpackGeneratedCssSources = /* @__PURE__ */ new Map();
|
|
2132
|
+
const currentWebpackCssSourceFiles = /* @__PURE__ */ new Set();
|
|
2133
|
+
const currentWebpackCssSourceModules = /* @__PURE__ */ new Set();
|
|
2134
|
+
let runtimeMetadataPrepared = false;
|
|
2135
|
+
const updateRuntimeWatchDependencies = async () => {
|
|
2136
|
+
runtimeWatchDependencyFiles.clear();
|
|
2137
|
+
runtimeWatchDependencyContexts.clear();
|
|
2138
|
+
const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
2139
|
+
if (tailwindOptions?.config) runtimeWatchDependencyFiles.add(tailwindOptions.config);
|
|
2140
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) runtimeWatchDependencyFiles.add(entry);
|
|
2141
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
2142
|
+
if (source.file) runtimeWatchDependencyFiles.add(source.file);
|
|
2143
|
+
for (const dependency of source.dependencies ?? []) runtimeWatchDependencyFiles.add(dependency);
|
|
2144
|
+
}
|
|
2145
|
+
for (const source of tailwindOptions?.v4?.sources ?? []) if (source?.base) runtimeWatchDependencyContexts.add(source.base);
|
|
2146
|
+
if (typeof runtimeState.tailwindRuntime.collectContentTokens !== "function") return;
|
|
2147
|
+
try {
|
|
2148
|
+
const report = await runtimeState.tailwindRuntime.collectContentTokens();
|
|
2149
|
+
for (const entry of report.entries ?? []) {
|
|
2150
|
+
const file = typeof entry === "object" && entry !== null && "file" in entry ? entry.file : void 0;
|
|
2151
|
+
if (typeof file === "string") runtimeWatchDependencyFiles.add(file);
|
|
2152
|
+
}
|
|
2153
|
+
for (const source of report.sources ?? []) {
|
|
2154
|
+
const base = typeof source === "object" && source !== null && "base" in source ? source.base : void 0;
|
|
2155
|
+
if (typeof base === "string") runtimeWatchDependencyContexts.add(base);
|
|
2156
|
+
}
|
|
2157
|
+
} catch (error) {
|
|
2158
|
+
debug("collect runtime watch dependencies failed: %O", error);
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2161
|
+
const ensureRuntimeMetadata = async (force = false) => {
|
|
2162
|
+
if (runtimeMetadataPrepared && !force) return;
|
|
2163
|
+
await updateRuntimeWatchDependencies();
|
|
2164
|
+
runtimeMetadataPrepared = true;
|
|
2165
|
+
};
|
|
2166
|
+
const collectWatchChangedFiles = () => {
|
|
2167
|
+
const compilerLike = compiler;
|
|
2168
|
+
return new Set([...compilerLike.modifiedFiles ?? [], ...compilerLike.removedFiles ?? []]);
|
|
2169
|
+
};
|
|
2170
|
+
const hasRuntimeDependencyChanges = (files) => {
|
|
2171
|
+
for (const file of files) if (isWatchFileInRuntimeDependencies(file, {
|
|
2172
|
+
contexts: runtimeWatchDependencyContexts,
|
|
2173
|
+
files: runtimeWatchDependencyFiles
|
|
2174
|
+
})) return true;
|
|
2175
|
+
return false;
|
|
2176
|
+
};
|
|
2177
|
+
const syncRuntimeRefreshRequirement = (markWatchRun = false) => {
|
|
2178
|
+
if (markWatchRun) watchRunObserved = true;
|
|
2179
|
+
const changedFiles = collectWatchChangedFiles();
|
|
2180
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges(changedFiles);
|
|
2181
|
+
};
|
|
2182
|
+
const resetRuntimePreparation = () => {
|
|
2183
|
+
runtimeSetPrepared = false;
|
|
2184
|
+
syncRuntimeRefreshRequirement();
|
|
2185
|
+
};
|
|
2186
|
+
const registerAutoCssSource = async (source) => {
|
|
2187
|
+
if (!source.file) return;
|
|
2188
|
+
if (!require_v4_engine.upsertTailwindV4CssSource(this.options, source)) return;
|
|
2189
|
+
runtimeSetPrepared = false;
|
|
2190
|
+
runtimeMetadataPrepared = false;
|
|
2191
|
+
runtimeRefreshRequiredForCompilation = true;
|
|
2192
|
+
await require_context.refreshTailwindRuntimeState(runtimeState, {
|
|
2193
|
+
force: true,
|
|
2194
|
+
clearCache: true
|
|
2195
|
+
});
|
|
2196
|
+
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
2197
|
+
};
|
|
2198
|
+
const markWebpackProcessedCssSource = (file) => {
|
|
2199
|
+
webpackProcessedCssSourceFiles.add(node_path.default.resolve(file));
|
|
2200
|
+
};
|
|
2201
|
+
const markWebpackCssSourceModule = (file) => {
|
|
2202
|
+
currentWebpackCssSourceModules.add(node_path.default.resolve(file));
|
|
2203
|
+
};
|
|
2204
|
+
const registerWebpackCssSourceFile = (source) => {
|
|
2205
|
+
const file = node_path.default.resolve(source.file);
|
|
2206
|
+
const previous = webpackCssSources.get(file);
|
|
2207
|
+
if (source.processed === true && previous?.processed === false) {
|
|
2208
|
+
currentWebpackCssSourceFiles.add(file);
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
webpackCssSources.set(file, {
|
|
2212
|
+
css: typeof source.css === "string" ? require_v4_engine.normalizeTailwindConfigDirectives(source.css, node_path.default.dirname(file)) : source.css,
|
|
2213
|
+
processed: source.processed
|
|
2214
|
+
});
|
|
2215
|
+
currentWebpackCssSourceFiles.add(file);
|
|
2216
|
+
};
|
|
2217
|
+
const registerWebpackGeneratedCss = (source) => {
|
|
2218
|
+
const file = node_path.default.resolve(source.file);
|
|
2219
|
+
webpackGeneratedCssSources.set(file, {
|
|
2220
|
+
...source,
|
|
2221
|
+
file
|
|
2222
|
+
});
|
|
2223
|
+
currentWebpackCssSourceFiles.add(file);
|
|
2224
|
+
};
|
|
2225
|
+
const pruneWebpackCssSources = (activeSourceFiles, _options = {}) => {
|
|
2226
|
+
const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
2227
|
+
const configuredSourceFiles = /* @__PURE__ */ new Set();
|
|
2228
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) configuredSourceFiles.add(node_path.default.resolve(entry));
|
|
2229
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) if (source.file) configuredSourceFiles.add(node_path.default.resolve(source.file));
|
|
2230
|
+
for (const file of webpackCssSources.keys()) if (!activeSourceFiles.has(file) && !configuredSourceFiles.has(file)) webpackCssSources.delete(file);
|
|
2231
|
+
for (const file of webpackGeneratedCssSources.keys()) if (!activeSourceFiles.has(file) && !configuredSourceFiles.has(file)) webpackGeneratedCssSources.delete(file);
|
|
2232
|
+
};
|
|
2233
|
+
const prepareWebpackCssSources = (activeAssetResources = /* @__PURE__ */ new Set()) => {
|
|
2234
|
+
const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
2235
|
+
const configuredSourceFiles = /* @__PURE__ */ new Set();
|
|
2236
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) configuredSourceFiles.add(node_path.default.resolve(entry));
|
|
2237
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) if (source.file) configuredSourceFiles.add(node_path.default.resolve(source.file));
|
|
2238
|
+
const activeSourceFiles = new Set([
|
|
2239
|
+
...configuredSourceFiles,
|
|
2240
|
+
...currentWebpackCssSourceModules,
|
|
2241
|
+
...activeAssetResources,
|
|
2242
|
+
...[...currentWebpackCssSourceFiles].filter((file) => currentWebpackCssSourceModules.has(file)),
|
|
2243
|
+
...[...currentWebpackCssSourceFiles].filter((file) => activeAssetResources.has(file))
|
|
2244
|
+
]);
|
|
2245
|
+
currentWebpackCssSourceFiles.clear();
|
|
2246
|
+
currentWebpackCssSourceModules.clear();
|
|
2247
|
+
return activeSourceFiles;
|
|
2248
|
+
};
|
|
2249
|
+
const isWebpackProcessedTailwindEntryAsset = (isMainCssChunk) => {
|
|
2250
|
+
if (isMainCssChunk !== true || webpackProcessedCssSourceFiles.size === 0) return false;
|
|
2251
|
+
const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(runtimeState.tailwindRuntime.options);
|
|
2252
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (webpackProcessedCssSourceFiles.has(node_path.default.resolve(entry))) return true;
|
|
2253
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) if (source.file && webpackProcessedCssSourceFiles.has(node_path.default.resolve(source.file))) return true;
|
|
2254
|
+
return false;
|
|
2255
|
+
};
|
|
2256
|
+
compiler.hooks.invalid?.tap?.(require_context.pluginName, (fileName) => {
|
|
2257
|
+
if (!fileName) return;
|
|
2258
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([node_path.default.resolve(fileName)]);
|
|
2259
|
+
});
|
|
2260
|
+
compiler.hooks.watchRun?.tap?.(require_context.pluginName, () => syncRuntimeRefreshRequirement(true));
|
|
2261
|
+
if (compiler.hooks.thisCompilation?.tap) compiler.hooks.thisCompilation.tap(require_context.pluginName, resetRuntimePreparation);
|
|
2262
|
+
else if (compiler.hooks.compilation?.tap) compiler.hooks.compilation.tap(require_context.pluginName, resetRuntimePreparation);
|
|
2263
|
+
async function getClassSetInLoader() {
|
|
2264
|
+
if (runtimeSetPrepared) return;
|
|
2265
|
+
const signature = require_tailwindcss.getRuntimeClassSetSignature(runtimeState.tailwindRuntime);
|
|
2266
|
+
const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
|
|
2267
|
+
debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
|
|
2268
|
+
runtimeSetPrepared = true;
|
|
2269
|
+
await require_context.ensureRuntimeClassSet(runtimeState, {
|
|
2270
|
+
forceRefresh,
|
|
2271
|
+
forceCollect: forceRefresh || !watchRunObserved,
|
|
2272
|
+
clearCache: forceRefresh,
|
|
2273
|
+
allowEmpty: true
|
|
2274
|
+
});
|
|
2275
|
+
await ensureRuntimeMetadata(forceRefresh);
|
|
2276
|
+
runtimeSetSignature = signature;
|
|
2277
|
+
runtimeRefreshRequiredForCompilation = false;
|
|
2278
|
+
}
|
|
2279
|
+
async function getRuntimeSetInLoader() {
|
|
2280
|
+
await getClassSetInLoader();
|
|
2281
|
+
return require_context.ensureRuntimeClassSet(runtimeState, { allowEmpty: true });
|
|
2282
|
+
}
|
|
2283
|
+
onLoad();
|
|
2284
|
+
setupWebpackV5Loaders({
|
|
2285
|
+
compiler,
|
|
2286
|
+
options: this.options,
|
|
2287
|
+
appType: this.appType,
|
|
2288
|
+
weappTailwindcssPackageDir,
|
|
2289
|
+
shouldRewriteCssImports,
|
|
2290
|
+
runtimeLoaderPath,
|
|
2291
|
+
registerAutoCssSource,
|
|
2292
|
+
runtimeState,
|
|
2293
|
+
getClassSetInLoader,
|
|
2294
|
+
getRuntimeSetInLoader,
|
|
2295
|
+
markWebpackProcessedCssSource,
|
|
2296
|
+
markWebpackCssSourceModule,
|
|
2297
|
+
registerWebpackCssSourceFile,
|
|
2298
|
+
registerWebpackGeneratedCss,
|
|
2299
|
+
getRuntimeWatchDependencies() {
|
|
2300
|
+
return {
|
|
2301
|
+
files: runtimeWatchDependencyFiles,
|
|
2302
|
+
contexts: runtimeWatchDependencyContexts
|
|
2303
|
+
};
|
|
2304
|
+
},
|
|
2305
|
+
debug
|
|
2306
|
+
});
|
|
2307
|
+
setupWebpackV5ProcessAssetsHook({
|
|
2308
|
+
compiler,
|
|
2309
|
+
options: this.options,
|
|
2310
|
+
appType: this.appType,
|
|
2311
|
+
runtimeState,
|
|
2312
|
+
getRuntimeRefreshRequirement: () => runtimeRefreshRequiredForCompilation,
|
|
2313
|
+
refreshRuntimeMetadata: ensureRuntimeMetadata,
|
|
2314
|
+
isKnownWebpackProcessedCssAsset(file, metadata) {
|
|
2315
|
+
return webpackProcessedCssSourceFiles.has(node_path.default.resolve(file)) || isWebpackProcessedTailwindEntryAsset(metadata?.isMainCssChunk);
|
|
2316
|
+
},
|
|
2317
|
+
isWebpackProcessedCssAsset(file, rawSource, metadata) {
|
|
2318
|
+
return webpackProcessedCssSourceFiles.has(node_path.default.resolve(file)) || isWebpackProcessedTailwindEntryAsset(metadata?.isMainCssChunk) || require_v4_engine.hasTailwindGeneratedCss(rawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) || rawSource.includes("weapp-tailwindcss webpack-generated-css");
|
|
2319
|
+
},
|
|
2320
|
+
consumeRuntimeRefreshRequirement() {
|
|
2321
|
+
runtimeRefreshRequiredForCompilation = false;
|
|
2322
|
+
},
|
|
2323
|
+
isWatchMode: () => watchRunObserved || compiler.options?.watch === true,
|
|
2324
|
+
getWatchChangedFiles: collectWatchChangedFiles,
|
|
2325
|
+
runtimeClassSetManager: this.options.__internalWebpackRuntimeClassSetManager,
|
|
2326
|
+
getWebpackCssSources: () => webpackCssSources,
|
|
2327
|
+
getWebpackGeneratedCssSources: () => webpackGeneratedCssSources,
|
|
2328
|
+
pruneWebpackCssSources,
|
|
2329
|
+
prepareWebpackCssSources,
|
|
2330
|
+
debug
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
//#endregion
|
|
2335
|
+
Object.defineProperty(exports, "WeappTailwindcss", {
|
|
2336
|
+
enumerable: true,
|
|
2337
|
+
get: function() {
|
|
2338
|
+
return WeappTailwindcss;
|
|
2339
|
+
}
|
|
2340
|
+
});
|
|
2341
|
+
Object.defineProperty(exports, "weappTailwindcssPackageDir", {
|
|
2342
|
+
enumerable: true,
|
|
2343
|
+
get: function() {
|
|
2344
|
+
return weappTailwindcssPackageDir;
|
|
2345
|
+
}
|
|
2346
|
+
});
|