weapp-tailwindcss 5.0.0-next.10 → 5.0.0-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-state-EUbcdKqo.js → bundle-state-Bz8vLnCf.js} +42 -3
- package/dist/{bundle-state-BWqi5ZyX.mjs → bundle-state-CP2XS3Uj.mjs} +31 -4
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generator-css/directives.d.ts +10 -3
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css.d.ts +5 -1
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +5 -5
- package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
- package/dist/bundlers/vite/source-candidates.d.ts +13 -2
- package/dist/bundlers/vite/source-scan.d.ts +21 -3
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +3 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +3 -3
- package/dist/cache/index.d.ts +6 -6
- package/dist/cli/context.d.ts +1 -11
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +468 -10
- package/dist/cli.mjs +466 -9
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/options.d.ts +8 -6
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-C9H44wEF.mjs +32 -0
- package/dist/generator-CRORPkpW.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +57 -18
- package/dist/gulp.mjs +54 -15
- package/dist/{incremental-runtime-class-set-BYmzQ-_f.js → incremental-runtime-class-set-DN9KKjSi.js} +753 -155
- package/dist/{incremental-runtime-class-set-BgMW6wf2.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +724 -144
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/precheck.d.ts +2 -2
- package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
- package/dist/lightningcss/style-handler.d.ts +3 -3
- package/dist/{postcss-Dg-_lyHS.js → postcss-Ab7YzAbs.js} +37 -23
- package/dist/postcss-CZE8k8oP.js +5483 -0
- package/dist/{postcss-C7efq3hr.mjs → postcss-CtlrNknb.mjs} +26 -12
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-B32p-gLI.js → precheck-CRX-pMKJ.js} +63 -37
- package/dist/{precheck-B4RH6ZNN.mjs → precheck-SG48aLG2.mjs} +56 -30
- package/dist/presets.js +11 -11
- package/dist/presets.mjs +11 -11
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-C4YgmZ8A.js +274 -0
- package/dist/source-candidates-CyupdLKi.mjs +259 -0
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime.d.ts +9 -9
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/patcher.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/types.d.ts +14 -5
- package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-BbTVeQkG.mjs} +52 -33
- package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZ6jVYb4.js} +59 -40
- package/dist/types/index.d.ts +44 -40
- package/dist/types/user-defined-options/general.d.ts +21 -21
- package/dist/types/user-defined-options/important.d.ts +30 -27
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-Btw1iOVV.mjs → utils-CycMvPn_.mjs} +1 -1
- package/dist/{utils-BiShvil9.js → utils-D0MZP_tr.js} +1 -1
- package/dist/v3-engine-D61eilBl.mjs +3208 -0
- package/dist/v3-engine-DwV1E6rX.js +3461 -0
- package/dist/{vite-BU74SkOi.mjs → vite-Ti_qSctn.mjs} +434 -536
- package/dist/{vite-CKjx_5c3.js → vite-xKS6RvLR.js} +437 -542
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +143 -18
- package/dist/weapp-tw-runtime-classset-loader.js +44 -6
- package/dist/{webpack-CAk_ITq7.mjs → webpack-DvptFz7B.mjs} +111 -39
- package/dist/{webpack-damWiYqY.js → webpack-wfNutjMm.js} +115 -43
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +5 -5
- package/dist/cache-BVAiJV3J.js +0 -502
- package/dist/cache-CHs4DXui.mjs +0 -434
- package/dist/generator-DKkhJbOg.js +0 -1531
- package/dist/generator-UBmfduYg.mjs +0 -1432
- package/dist/runtime-patch-CwN5ya72.mjs +0 -71
- package/dist/runtime-patch-D6mBo_KB.js +0 -85
- package/dist/source-scan-BaYvNx-k.js +0 -293
- package/dist/source-scan-cGZxoJqP.mjs +0 -254
- /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
- /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
- /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
- /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-xKS6RvLR.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-Ti_qSctn.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -2,31 +2,31 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const
|
|
5
|
+
const require_postcss = require("./postcss-CZE8k8oP.js");
|
|
6
|
+
let node_buffer = require("node:buffer");
|
|
6
7
|
let node_process = require("node:process");
|
|
7
|
-
node_process =
|
|
8
|
+
node_process = require_postcss.__toESM(node_process);
|
|
8
9
|
let loader_utils = require("loader-utils");
|
|
9
|
-
loader_utils =
|
|
10
|
-
let
|
|
10
|
+
loader_utils = require_postcss.__toESM(loader_utils);
|
|
11
|
+
let node_path = require("node:path");
|
|
12
|
+
node_path = require_postcss.__toESM(node_path);
|
|
11
13
|
let node_util = require("node:util");
|
|
12
14
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
13
|
-
let node_path = require("node:path");
|
|
14
|
-
node_path = require_chunk.__toESM(node_path);
|
|
15
15
|
//#region src/bundlers/shared/css-imports.ts
|
|
16
|
-
const tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
17
|
-
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
16
|
+
const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
|
|
17
|
+
const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
18
18
|
function normalizeTailwindcssSpecifier(specifier) {
|
|
19
|
-
if (specifier === "tailwindcss$"
|
|
19
|
+
if (specifier === "tailwindcss$" || specifier === "weapp-tailwindcss$") return specifier.slice(0, -1);
|
|
20
20
|
return specifier;
|
|
21
21
|
}
|
|
22
22
|
function getTailwindcssSubpath(specifier) {
|
|
23
|
-
if (specifier === "tailwindcss") return "index.css";
|
|
24
|
-
return specifier.
|
|
23
|
+
if (specifier === "tailwindcss" || specifier === "weapp-tailwindcss") return "index.css";
|
|
24
|
+
return specifier.replace(/^(?:tailwindcss|weapp-tailwindcss)\//, "");
|
|
25
25
|
}
|
|
26
26
|
function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
27
27
|
const normalized = normalizeTailwindcssSpecifier(specifier);
|
|
28
28
|
if (!tailwindcssImportRE.test(normalized)) return null;
|
|
29
|
-
if (normalized === "tailwindcss") return options?.rootImport ?? "
|
|
29
|
+
if (normalized === "tailwindcss" || normalized === "weapp-tailwindcss") return options?.rootImport ?? (options?.join ?? node_path.default.join)(pkgDir, "index.css");
|
|
30
30
|
return (options?.join ?? node_path.default.join)(pkgDir, getTailwindcssSubpath(normalized));
|
|
31
31
|
}
|
|
32
32
|
function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
@@ -40,8 +40,113 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
40
40
|
return hasReplacements ? rewritten : void 0;
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
|
-
//#region src/bundlers/
|
|
43
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
44
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
45
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
46
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
50
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
51
|
+
"config",
|
|
52
|
+
"custom-variant",
|
|
53
|
+
"plugin",
|
|
54
|
+
"source",
|
|
55
|
+
"tailwind",
|
|
56
|
+
"theme",
|
|
57
|
+
"utility",
|
|
58
|
+
"variant"
|
|
59
|
+
]);
|
|
44
60
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
61
|
+
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
62
|
+
const TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE = /^\s*@(?:theme|utility|variant|custom-variant)\b[\s\S]*$/;
|
|
63
|
+
function parseImportRequest(params) {
|
|
64
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
65
|
+
}
|
|
66
|
+
function parseConfigRequest(params) {
|
|
67
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
68
|
+
}
|
|
69
|
+
function isPackageJsonImportRequest$1(request) {
|
|
70
|
+
return typeof request === "string" && request.startsWith("#");
|
|
71
|
+
}
|
|
72
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
73
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
74
|
+
}
|
|
75
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
76
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
77
|
+
return request;
|
|
78
|
+
}
|
|
79
|
+
function replaceImportRequest(params, request, replacement) {
|
|
80
|
+
const index = params.indexOf(request);
|
|
81
|
+
if (index === -1) return params;
|
|
82
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
83
|
+
}
|
|
84
|
+
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
85
|
+
if (!options.importFallback || !line.trimStart().startsWith("@import")) return line;
|
|
86
|
+
const request = parseImportRequest(line.trimStart().replace(/^@import\b/, ""));
|
|
87
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
88
|
+
return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
89
|
+
}
|
|
90
|
+
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
91
|
+
const directives = [];
|
|
92
|
+
const seenImports = /* @__PURE__ */ new Set();
|
|
93
|
+
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
94
|
+
const trimmed = line.trim();
|
|
95
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
96
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE.exec(line)?.[0];
|
|
97
|
+
if (!directive) continue;
|
|
98
|
+
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
99
|
+
const normalizedTrimmed = normalized.trim();
|
|
100
|
+
if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
|
|
101
|
+
const request = /^@import\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@import\b/, "")) : void 0;
|
|
102
|
+
if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest$1(request)) continue;
|
|
103
|
+
if (/^@import\b/.test(normalizedTrimmed) && !request) continue;
|
|
104
|
+
if (request && isTailwindImportRequest(request)) {
|
|
105
|
+
const key = normalizedTrimmed;
|
|
106
|
+
if (seenImports.has(key)) continue;
|
|
107
|
+
seenImports.add(key);
|
|
108
|
+
}
|
|
109
|
+
directives.push(normalized);
|
|
110
|
+
}
|
|
111
|
+
return directives;
|
|
112
|
+
}
|
|
113
|
+
function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
114
|
+
const directives = extractTailwindDirectiveLines(rawSource, options);
|
|
115
|
+
return directives.length > 0 ? directives.join("\n") : void 0;
|
|
116
|
+
}
|
|
117
|
+
function hasPreprocessorOnlySyntax(rawSource) {
|
|
118
|
+
return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
|
|
119
|
+
}
|
|
120
|
+
function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
121
|
+
return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
|
|
122
|
+
}
|
|
123
|
+
function isTailwindImportRequest(request) {
|
|
124
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
125
|
+
}
|
|
126
|
+
function isTailwindImportAtRule(node, options = {}) {
|
|
127
|
+
if (node.name === "tailwind") return true;
|
|
128
|
+
if (node.name !== "import") return false;
|
|
129
|
+
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
130
|
+
}
|
|
131
|
+
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
132
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
133
|
+
try {
|
|
134
|
+
const root = require_postcss.postcss_default.parse(rawSource);
|
|
135
|
+
let found = false;
|
|
136
|
+
root.walkAtRules((node) => {
|
|
137
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
138
|
+
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest$1(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
139
|
+
found = true;
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return found;
|
|
144
|
+
} catch {
|
|
145
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
|
|
45
150
|
const getLoaderOptions = loader_utils.default.getOptions;
|
|
46
151
|
function joinPosixPath(base, subpath) {
|
|
47
152
|
if (base.endsWith("/")) return `${base}${subpath}`;
|
|
@@ -56,25 +161,45 @@ function applyCssImportRewrite(source, options) {
|
|
|
56
161
|
appType: rewriteOptions.appType
|
|
57
162
|
}) ?? source;
|
|
58
163
|
}
|
|
164
|
+
function isPackageJsonImportRequest(request) {
|
|
165
|
+
return request.startsWith("#");
|
|
166
|
+
}
|
|
167
|
+
function toRootRelativeConfigPath(configPath, rootContext) {
|
|
168
|
+
if (!rootContext) return (0, _weapp_tailwindcss_shared.ensurePosix)(configPath);
|
|
169
|
+
const relative = (0, _weapp_tailwindcss_shared.ensurePosix)(node_path.default.relative(rootContext, configPath));
|
|
170
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
171
|
+
}
|
|
172
|
+
function normalizeCssConfigDirectives(source, resourcePath, rootContext) {
|
|
173
|
+
if (!resourcePath) return source;
|
|
174
|
+
const base = node_path.default.dirname(resourcePath);
|
|
175
|
+
return source.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
|
|
176
|
+
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
|
|
177
|
+
return `@config ${quote}${toRootRelativeConfigPath(node_path.default.resolve(base, request), rootContext)}${quote};`;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
59
180
|
function transformCssImportRewriteSource(source, options) {
|
|
60
181
|
const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
|
|
61
182
|
const rewritten = applyCssImportRewrite(input, options);
|
|
62
183
|
if (rewritten === input) return source;
|
|
63
|
-
if (node_process.default.env
|
|
184
|
+
if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-css-import-rewrite-loader] rewritten import ${(0, node_util.inspect)({
|
|
64
185
|
before: input.slice(0, 80),
|
|
65
186
|
after: rewritten.slice(0, 80)
|
|
66
187
|
})}\n`);
|
|
67
188
|
return rewritten;
|
|
68
189
|
}
|
|
69
190
|
const WeappTwCssImportRewriteLoader = function(source) {
|
|
70
|
-
if (node_process.default.env
|
|
191
|
+
if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-css-import-rewrite-loader] executing for ${this.resourcePath}\n`);
|
|
71
192
|
const opt = getLoaderOptions(this);
|
|
72
193
|
const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
|
|
73
|
-
const registerTask = typeof input === "string" &&
|
|
194
|
+
const registerTask = typeof input === "string" && hasTailwindRootDirectives(input, { importFallback: true }) ? opt?.tailwindcssImportRewrite?.registerCssSource?.({
|
|
74
195
|
file: this.resourcePath,
|
|
75
|
-
css: input
|
|
196
|
+
css: normalizeCssConfigDirectives(normalizeTailwindSourceForGenerator(input, { importFallback: true }), this.resourcePath, this.rootContext)
|
|
76
197
|
}) : void 0;
|
|
77
|
-
const transform = () =>
|
|
198
|
+
const transform = () => {
|
|
199
|
+
const transformed = transformCssImportRewriteSource(source, opt);
|
|
200
|
+
if (typeof transformed === "string") return normalizeCssConfigDirectives(transformed, this.resourcePath, this.rootContext);
|
|
201
|
+
return transformed;
|
|
202
|
+
};
|
|
78
203
|
if (registerTask && typeof registerTask.then === "function") return Promise.resolve(registerTask).then(transform);
|
|
79
204
|
return transform();
|
|
80
205
|
};
|
|
@@ -1,15 +1,53 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_postcss = require("./postcss-CZE8k8oP.js");
|
|
2
|
+
let node_buffer = require("node:buffer");
|
|
2
3
|
let node_process = require("node:process");
|
|
3
|
-
node_process =
|
|
4
|
+
node_process = require_postcss.__toESM(node_process);
|
|
4
5
|
let loader_utils = require("loader-utils");
|
|
5
|
-
loader_utils =
|
|
6
|
+
loader_utils = require_postcss.__toESM(loader_utils);
|
|
7
|
+
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
8
|
+
/**
|
|
9
|
+
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
10
|
+
*/
|
|
11
|
+
function removeUnsupportedCascadeLayers(root) {
|
|
12
|
+
root.walkAtRules("layer", (atRule) => {
|
|
13
|
+
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
14
|
+
atRule.remove();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
atRule.replaceWith(...atRule.nodes);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
6
21
|
//#region src/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.ts
|
|
7
22
|
function isPromiseLike(value) {
|
|
8
23
|
return Boolean(value && typeof value.then === "function");
|
|
9
24
|
}
|
|
10
25
|
const getLoaderOptions = loader_utils.default.getOptions;
|
|
26
|
+
function normalizeRuntimeCssSource(source) {
|
|
27
|
+
if (node_buffer.Buffer.isBuffer(source)) {
|
|
28
|
+
const css = source.toString("utf8");
|
|
29
|
+
return shouldCleanRuntimeCss(css) ? node_buffer.Buffer.from(cleanRuntimeCss(css)) : source;
|
|
30
|
+
}
|
|
31
|
+
return shouldCleanRuntimeCss(source) ? cleanRuntimeCss(source) : source;
|
|
32
|
+
}
|
|
33
|
+
function shouldCleanRuntimeCss(css) {
|
|
34
|
+
return css.includes("@layer") || css.includes("@theme");
|
|
35
|
+
}
|
|
36
|
+
function cleanRuntimeCss(css) {
|
|
37
|
+
const root = require_postcss.postcss_default.parse(css);
|
|
38
|
+
removeUnsupportedCascadeLayers(root);
|
|
39
|
+
removeUnsupportedThemeKeyframes(root);
|
|
40
|
+
return root.toString();
|
|
41
|
+
}
|
|
42
|
+
function removeUnsupportedThemeKeyframes(root) {
|
|
43
|
+
root.walkAtRules("theme", (themeRule) => {
|
|
44
|
+
themeRule.walkAtRules((atRule) => {
|
|
45
|
+
if (atRule.name.startsWith("-") && atRule.name.endsWith("keyframes")) atRule.remove();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
11
49
|
const WeappTwRuntimeClassSetLoader = function(source) {
|
|
12
|
-
if (node_process.default.env
|
|
50
|
+
if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-runtime-classset-loader] executing for ${this.resourcePath}\n`);
|
|
13
51
|
const opt = getLoaderOptions(this);
|
|
14
52
|
const maybePromise = opt?.getClassSet?.();
|
|
15
53
|
const applyWatchDependencies = (dependencies) => {
|
|
@@ -25,10 +63,10 @@ const WeappTwRuntimeClassSetLoader = function(source) {
|
|
|
25
63
|
};
|
|
26
64
|
if (isPromiseLike(maybePromise)) return Promise.resolve(maybePromise).then(async () => {
|
|
27
65
|
await resolveWatchDependencies();
|
|
28
|
-
return source;
|
|
66
|
+
return normalizeRuntimeCssSource(source);
|
|
29
67
|
});
|
|
30
68
|
resolveWatchDependencies();
|
|
31
|
-
return source;
|
|
69
|
+
return normalizeRuntimeCssSource(source);
|
|
32
70
|
};
|
|
33
71
|
//#endregion
|
|
34
72
|
module.exports = WeappTwRuntimeClassSetLoader;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { c as
|
|
7
|
-
import { c as resolvePluginDisabledState, d as toAbsoluteOutputPath, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, s as resolvePackageDir, t as buildBundleSnapshot, u as resolveOutputSpecifier } from "./bundle-state-BWqi5ZyX.mjs";
|
|
1
|
+
import { F as createDebug, l as getRuntimeClassSetSignature, z as resolveTailwindcssOptions } from "./v3-engine-D61eilBl.mjs";
|
|
2
|
+
import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-Dbn4yPfZ.mjs";
|
|
3
|
+
import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform, v as refreshTailwindRuntimeState } from "./precheck-SG48aLG2.mjs";
|
|
4
|
+
import { r as getGroupedEntries } from "./utils-CycMvPn_.mjs";
|
|
5
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-BbTVeQkG.mjs";
|
|
6
|
+
import { c as resolvePluginDisabledState, f as resolveOutputSpecifier, l as isSourceStyleRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as toAbsoluteOutputPath, r as updateBundleBuildState, s as resolvePackageDir, t as buildBundleSnapshot, u as stripRequestQuery } from "./bundle-state-CP2XS3Uj.mjs";
|
|
8
7
|
import Module, { createRequire } from "node:module";
|
|
8
|
+
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import process from "node:process";
|
|
11
|
-
import fs from "node:fs";
|
|
12
11
|
import { fileURLToPath } from "node:url";
|
|
13
12
|
//#region src/shared/tailwindcss-css-redirect.ts
|
|
14
13
|
const moduleWithMutableResolve = Module;
|
|
@@ -30,6 +29,7 @@ function installTailwindcssCssRedirect(pkgDir) {
|
|
|
30
29
|
//#region src/shared/mpx.ts
|
|
31
30
|
const localRequire = createRequire(import.meta.url);
|
|
32
31
|
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
32
|
+
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
33
33
|
function isMpxStyleResourceQuery(query) {
|
|
34
34
|
if (typeof query !== "string") return false;
|
|
35
35
|
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
@@ -50,19 +50,44 @@ function resolveMpxWebpackPluginDir(compiler) {
|
|
|
50
50
|
const projectRequire = createRequire(path.join(candidate, "package.json"));
|
|
51
51
|
return path.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
52
52
|
} catch {}
|
|
53
|
-
|
|
53
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
54
|
+
if (cachedPackageJson) return path.dirname(cachedPackageJson);
|
|
55
|
+
try {
|
|
56
|
+
return path.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
57
|
+
} catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
function isMpxWebpackPluginRequest(request) {
|
|
56
62
|
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
57
63
|
}
|
|
64
|
+
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
65
|
+
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
66
|
+
return path.join(mpxWebpackPluginDir, request.slice(22));
|
|
67
|
+
}
|
|
58
68
|
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
69
|
+
const recordLoader = path.join(pkgDir, "lib/record-loader");
|
|
70
|
+
const styleCompiler = path.join(pkgDir, "lib/style-compiler/index");
|
|
71
|
+
const stripConditionalLoader = path.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
59
72
|
if (Array.isArray(alias)) alias.push({
|
|
73
|
+
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
74
|
+
alias: recordLoader
|
|
75
|
+
}, {
|
|
76
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
77
|
+
alias: styleCompiler
|
|
78
|
+
}, {
|
|
79
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
80
|
+
alias: stripConditionalLoader
|
|
81
|
+
}, {
|
|
60
82
|
name: /^@mpxjs\/webpack-plugin\//,
|
|
61
83
|
alias: pkgDir
|
|
62
84
|
});
|
|
63
85
|
else {
|
|
64
86
|
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
65
87
|
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
88
|
+
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
89
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
90
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
66
91
|
}
|
|
67
92
|
}
|
|
68
93
|
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
@@ -71,18 +96,48 @@ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
|
71
96
|
compiler.options.resolveLoader.alias = alias;
|
|
72
97
|
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
73
98
|
}
|
|
99
|
+
function resolveMpxWebpackPluginRequire(compiler) {
|
|
100
|
+
const candidates = [
|
|
101
|
+
compiler?.context,
|
|
102
|
+
compiler?.options?.context,
|
|
103
|
+
process.cwd()
|
|
104
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
105
|
+
for (const candidate of candidates) try {
|
|
106
|
+
const projectRequire = createRequire(path.join(candidate, "package.json"));
|
|
107
|
+
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
108
|
+
return projectRequire;
|
|
109
|
+
} catch {}
|
|
110
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
111
|
+
if (cachedPackageJson) return createRequire(cachedPackageJson);
|
|
112
|
+
return localRequire;
|
|
113
|
+
}
|
|
114
|
+
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
115
|
+
if (!mpxWebpackPluginDir) return false;
|
|
116
|
+
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
117
|
+
let normalize;
|
|
118
|
+
try {
|
|
119
|
+
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
120
|
+
} catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (typeof normalize.lib !== "function") return false;
|
|
124
|
+
if (normalize.lib.__weappTwPatched) return true;
|
|
125
|
+
const wrappedLib = (file) => path.join(mpxWebpackPluginDir, "lib", file);
|
|
126
|
+
wrappedLib.__weappTwPatched = true;
|
|
127
|
+
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
128
|
+
normalize.lib = wrappedLib;
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
74
131
|
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
75
132
|
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
76
133
|
compiler.options = compiler.options || {};
|
|
77
134
|
compiler.options.resolve = compiler.options.resolve || {};
|
|
78
135
|
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
79
|
-
|
|
136
|
+
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
137
|
+
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
80
138
|
const alias = compiler.options.resolve.alias ?? {};
|
|
81
139
|
compiler.options.resolve.alias = alias;
|
|
82
140
|
if (Array.isArray(alias)) alias.push({
|
|
83
|
-
name: /^@mpxjs\/webpack-plugin\//,
|
|
84
|
-
alias: mpxWebpackPluginDir
|
|
85
|
-
}, {
|
|
86
141
|
name: "tailwindcss",
|
|
87
142
|
alias: tailwindcssCssEntry
|
|
88
143
|
}, {
|
|
@@ -90,11 +145,10 @@ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
|
90
145
|
alias: tailwindcssCssEntry
|
|
91
146
|
});
|
|
92
147
|
else {
|
|
93
|
-
alias["@mpxjs/webpack-plugin"] = mpxWebpackPluginDir;
|
|
94
|
-
alias["@mpxjs/webpack-plugin$"] = mpxWebpackPluginDir;
|
|
95
148
|
alias.tailwindcss = tailwindcssCssEntry;
|
|
96
149
|
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
97
150
|
}
|
|
151
|
+
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
98
152
|
return tailwindcssCssEntry;
|
|
99
153
|
}
|
|
100
154
|
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
@@ -102,10 +156,11 @@ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
|
102
156
|
const originalResolve = loaderContext.resolve;
|
|
103
157
|
if (originalResolve.__weappTwPatched) return;
|
|
104
158
|
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
159
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
105
160
|
const wrappedResolve = function(context, request, callback) {
|
|
106
161
|
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
107
162
|
if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
|
|
108
|
-
if (isMpxWebpackPluginRequest(request)) return
|
|
163
|
+
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
109
164
|
return originalResolve.call(this, context, request, callback);
|
|
110
165
|
};
|
|
111
166
|
wrappedResolve.__weappTwPatched = true;
|
|
@@ -141,16 +196,13 @@ function getCacheKey(filename) {
|
|
|
141
196
|
}
|
|
142
197
|
function stripResourceQuery(resource) {
|
|
143
198
|
if (typeof resource !== "string") return resource;
|
|
144
|
-
|
|
145
|
-
if (queryIndex !== -1) return resource.slice(0, queryIndex);
|
|
146
|
-
const hashIndex = resource.indexOf("#");
|
|
147
|
-
if (hashIndex !== -1) return resource.slice(0, hashIndex);
|
|
148
|
-
return resource;
|
|
199
|
+
return stripRequestQuery(resource);
|
|
149
200
|
}
|
|
150
201
|
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
151
202
|
if (typeof resource !== "string") return false;
|
|
152
203
|
const normalizedResource = stripResourceQuery(resource);
|
|
153
204
|
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
205
|
+
if (isSourceStyleRequest(resource)) return true;
|
|
154
206
|
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
155
207
|
return false;
|
|
156
208
|
}
|
|
@@ -158,6 +210,13 @@ function hasLoaderEntry(entries, target) {
|
|
|
158
210
|
if (!target) return false;
|
|
159
211
|
return entries.some((entry) => entry.loader?.includes?.(target));
|
|
160
212
|
}
|
|
213
|
+
function normalizeWatchPath(file) {
|
|
214
|
+
return path.resolve(file);
|
|
215
|
+
}
|
|
216
|
+
function isFileInContext(file, context) {
|
|
217
|
+
const relative = path.relative(normalizeWatchPath(context), normalizeWatchPath(file));
|
|
218
|
+
return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
219
|
+
}
|
|
161
220
|
function toChunkFiles(files) {
|
|
162
221
|
if (!files) return [];
|
|
163
222
|
if (Array.isArray(files)) return files;
|
|
@@ -186,8 +245,11 @@ function createAssetHashByChunkMap(chunks) {
|
|
|
186
245
|
function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
|
|
187
246
|
return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
|
|
188
247
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
248
|
+
function isWatchFileInRuntimeDependencies(file, dependencies) {
|
|
249
|
+
const normalizedFile = normalizeWatchPath(file);
|
|
250
|
+
for (const dependency of dependencies.files ?? []) if (normalizeWatchPath(dependency) === normalizedFile) return true;
|
|
251
|
+
for (const context of dependencies.contexts ?? []) if (isFileInContext(normalizedFile, context)) return true;
|
|
252
|
+
return false;
|
|
191
253
|
}
|
|
192
254
|
//#endregion
|
|
193
255
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
|
|
@@ -218,6 +280,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
218
280
|
compilerOptions.onStart();
|
|
219
281
|
debug("start");
|
|
220
282
|
await runtimeState.readyPromise;
|
|
283
|
+
const hmrTimingStartedAt = performance.now();
|
|
221
284
|
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
222
285
|
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
223
286
|
const entries = Object.entries(assets);
|
|
@@ -270,7 +333,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
270
333
|
const created = {
|
|
271
334
|
isMainChunk,
|
|
272
335
|
postcssOptions: { options: { from: file } },
|
|
273
|
-
majorVersion
|
|
336
|
+
...majorVersion === void 0 ? {} : { majorVersion }
|
|
274
337
|
};
|
|
275
338
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
276
339
|
return created;
|
|
@@ -319,10 +382,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
319
382
|
clearCache: forceRuntimeRefresh,
|
|
320
383
|
allowEmpty: false
|
|
321
384
|
});
|
|
322
|
-
if (runtimeSet.size === 0) {
|
|
323
|
-
const syncSet = runtimeState.twPatcher.getClassSetSync?.();
|
|
324
|
-
if (syncSet && syncSet.size > 0) runtimeSet = syncSet;
|
|
325
|
-
}
|
|
326
385
|
}
|
|
327
386
|
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
328
387
|
consumeRuntimeRefreshRequirement();
|
|
@@ -444,12 +503,13 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
444
503
|
pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
445
504
|
await Promise.all(tasks);
|
|
446
505
|
debug("end");
|
|
506
|
+
emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt);
|
|
447
507
|
compilerOptions.onEnd();
|
|
448
508
|
});
|
|
449
509
|
});
|
|
450
510
|
}
|
|
451
511
|
//#endregion
|
|
452
|
-
//#region ../../node_modules/.pnpm/tsdown@0.22.
|
|
512
|
+
//#region ../../node_modules/.pnpm/tsdown@0.22.0_oxc-resolver@11.19.1_@emnapi+core@1.10.0_@emnapi+runtime@1.10.0__tsx@4.22_d5fec98bd6da0af22d9e6961a46a32e3/node_modules/tsdown/esm-shims.js
|
|
453
513
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
454
514
|
const getDirname = () => path.dirname(getFilename());
|
|
455
515
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -493,8 +553,8 @@ function setupWebpackV5Loaders(options) {
|
|
|
493
553
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
494
554
|
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
495
555
|
pkgDir: weappTailwindcssPackageDir,
|
|
496
|
-
appType,
|
|
497
|
-
registerCssSource: registerAutoCssSource
|
|
556
|
+
...appType === void 0 ? {} : { appType },
|
|
557
|
+
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource }
|
|
498
558
|
} : void 0;
|
|
499
559
|
const classSetLoaderOptions = {
|
|
500
560
|
getClassSet: getClassSetInLoader,
|
|
@@ -510,7 +570,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
510
570
|
type: null
|
|
511
571
|
});
|
|
512
572
|
const createCssImportRewriteLoaderEntry = () => {
|
|
513
|
-
if (!runtimeCssImportRewriteLoader) return null;
|
|
573
|
+
if (!runtimeCssImportRewriteLoader || !cssImportRewriteLoaderOptions) return null;
|
|
514
574
|
return {
|
|
515
575
|
loader: runtimeCssImportRewriteLoader,
|
|
516
576
|
options: cssImportRewriteLoaderOptions,
|
|
@@ -527,15 +587,15 @@ function setupWebpackV5Loaders(options) {
|
|
|
527
587
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
528
588
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
529
589
|
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
530
|
-
if (process.env
|
|
590
|
+
if (process.env["WEAPP_TW_LOADER_DEBUG"] && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
531
591
|
rewriteAnchorIdx,
|
|
532
592
|
classSetAnchorIdx
|
|
533
593
|
});
|
|
534
|
-
if (process.env
|
|
594
|
+
if (process.env["WEAPP_TW_LOADER_DEBUG"] && typeof module.resource === "string" && module.resource.includes("app.css")) debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), {
|
|
535
595
|
rewriteAnchorIdx,
|
|
536
596
|
classSetAnchorIdx
|
|
537
597
|
});
|
|
538
|
-
else if (process.env
|
|
598
|
+
else if (process.env["WEAPP_TW_LOADER_DEBUG"] && typeof module.resource === "string" && module.resource.endsWith(".css")) debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
539
599
|
rewriteAnchorIdx,
|
|
540
600
|
classSetAnchorIdx
|
|
541
601
|
});
|
|
@@ -632,13 +692,24 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
632
692
|
await updateRuntimeWatchDependencies();
|
|
633
693
|
runtimeMetadataPrepared = true;
|
|
634
694
|
};
|
|
695
|
+
const collectWatchChangedFiles = () => {
|
|
696
|
+
const compilerLike = compiler;
|
|
697
|
+
return new Set([...compilerLike.modifiedFiles ?? [], ...compilerLike.removedFiles ?? []]);
|
|
698
|
+
};
|
|
699
|
+
const hasRuntimeDependencyChanges = (files) => {
|
|
700
|
+
for (const file of files) if (isWatchFileInRuntimeDependencies(file, {
|
|
701
|
+
contexts: runtimeWatchDependencyContexts,
|
|
702
|
+
files: runtimeWatchDependencyFiles
|
|
703
|
+
})) return true;
|
|
704
|
+
return false;
|
|
705
|
+
};
|
|
635
706
|
const syncRuntimeRefreshRequirement = (markWatchRun = false) => {
|
|
636
707
|
if (markWatchRun) watchRunObserved = true;
|
|
637
|
-
|
|
708
|
+
const changedFiles = collectWatchChangedFiles();
|
|
709
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges(changedFiles);
|
|
638
710
|
};
|
|
639
711
|
const resetRuntimePreparation = () => {
|
|
640
712
|
runtimeSetPrepared = false;
|
|
641
|
-
runtimeMetadataPrepared = false;
|
|
642
713
|
syncRuntimeRefreshRequirement();
|
|
643
714
|
};
|
|
644
715
|
const registerAutoCssSource = async (source) => {
|
|
@@ -653,8 +724,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
653
724
|
});
|
|
654
725
|
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
655
726
|
};
|
|
656
|
-
compiler.hooks.invalid?.tap?.(pluginName, () => {
|
|
657
|
-
|
|
727
|
+
compiler.hooks.invalid?.tap?.(pluginName, (fileName) => {
|
|
728
|
+
if (!fileName) return;
|
|
729
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([path.resolve(fileName)]);
|
|
658
730
|
});
|
|
659
731
|
compiler.hooks.watchRun?.tap?.(pluginName, () => syncRuntimeRefreshRequirement(true));
|
|
660
732
|
if (compiler.hooks.thisCompilation?.tap) compiler.hooks.thisCompilation.tap(pluginName, resetRuntimePreparation);
|