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
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-DwV1E6rX.js");
|
|
3
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-DN9KKjSi.js");
|
|
4
|
+
const require_precheck = require("./precheck-CRX-pMKJ.js");
|
|
5
|
+
const require_utils = require("./utils-D0MZP_tr.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-DZ6jVYb4.js");
|
|
7
|
+
const require_bundle_state = require("./bundle-state-Bz8vLnCf.js");
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
9
10
|
let node_module = require("node:module");
|
|
10
11
|
node_module = require_chunk.__toESM(node_module);
|
|
11
12
|
let node_path = require("node:path");
|
|
12
13
|
node_path = require_chunk.__toESM(node_path);
|
|
13
14
|
let node_process = require("node:process");
|
|
14
15
|
node_process = require_chunk.__toESM(node_process);
|
|
15
|
-
let node_fs = require("node:fs");
|
|
16
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
17
16
|
//#region src/shared/tailwindcss-css-redirect.ts
|
|
18
17
|
const moduleWithMutableResolve = node_module.default;
|
|
19
18
|
const patched = /* @__PURE__ */ new WeakSet();
|
|
@@ -34,6 +33,7 @@ function installTailwindcssCssRedirect(pkgDir) {
|
|
|
34
33
|
//#region src/shared/mpx.ts
|
|
35
34
|
const localRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
36
35
|
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
36
|
+
const MPX_WEBPACK_PLUGIN_PACKAGE_RE = /@mpxjs[\\/]webpack-plugin[\\/]package\.json$/;
|
|
37
37
|
function isMpxStyleResourceQuery(query) {
|
|
38
38
|
if (typeof query !== "string") return false;
|
|
39
39
|
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
@@ -54,19 +54,44 @@ function resolveMpxWebpackPluginDir(compiler) {
|
|
|
54
54
|
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
55
55
|
return node_path.default.dirname(projectRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
56
56
|
} catch {}
|
|
57
|
-
|
|
57
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
58
|
+
if (cachedPackageJson) return node_path.default.dirname(cachedPackageJson);
|
|
59
|
+
try {
|
|
60
|
+
return node_path.default.dirname(localRequire.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
function isMpxWebpackPluginRequest(request) {
|
|
60
66
|
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
61
67
|
}
|
|
68
|
+
function resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir) {
|
|
69
|
+
if (request === "@mpxjs/webpack-plugin") return mpxWebpackPluginDir;
|
|
70
|
+
return node_path.default.join(mpxWebpackPluginDir, request.slice(22));
|
|
71
|
+
}
|
|
62
72
|
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
73
|
+
const recordLoader = node_path.default.join(pkgDir, "lib/record-loader");
|
|
74
|
+
const styleCompiler = node_path.default.join(pkgDir, "lib/style-compiler/index");
|
|
75
|
+
const stripConditionalLoader = node_path.default.join(pkgDir, "lib/style-compiler/strip-conditional-loader");
|
|
63
76
|
if (Array.isArray(alias)) alias.push({
|
|
77
|
+
name: "@mpxjs/webpack-plugin/lib/record-loader",
|
|
78
|
+
alias: recordLoader
|
|
79
|
+
}, {
|
|
80
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/index",
|
|
81
|
+
alias: styleCompiler
|
|
82
|
+
}, {
|
|
83
|
+
name: "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader",
|
|
84
|
+
alias: stripConditionalLoader
|
|
85
|
+
}, {
|
|
64
86
|
name: /^@mpxjs\/webpack-plugin\//,
|
|
65
87
|
alias: pkgDir
|
|
66
88
|
});
|
|
67
89
|
else {
|
|
68
90
|
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
69
91
|
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
92
|
+
alias["@mpxjs/webpack-plugin/lib/record-loader"] = recordLoader;
|
|
93
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/index"] = styleCompiler;
|
|
94
|
+
alias["@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader"] = stripConditionalLoader;
|
|
70
95
|
}
|
|
71
96
|
}
|
|
72
97
|
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
@@ -75,18 +100,48 @@ function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
|
75
100
|
compiler.options.resolveLoader.alias = alias;
|
|
76
101
|
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
77
102
|
}
|
|
103
|
+
function resolveMpxWebpackPluginRequire(compiler) {
|
|
104
|
+
const candidates = [
|
|
105
|
+
compiler?.context,
|
|
106
|
+
compiler?.options?.context,
|
|
107
|
+
node_process.default.cwd()
|
|
108
|
+
].filter((item) => typeof item === "string" && item.length > 0);
|
|
109
|
+
for (const candidate of candidates) try {
|
|
110
|
+
const projectRequire = (0, node_module.createRequire)(node_path.default.join(candidate, "package.json"));
|
|
111
|
+
projectRequire.resolve("@mpxjs/webpack-plugin/package.json");
|
|
112
|
+
return projectRequire;
|
|
113
|
+
} catch {}
|
|
114
|
+
const cachedPackageJson = Object.keys(localRequire.cache).find((file) => MPX_WEBPACK_PLUGIN_PACKAGE_RE.test(file));
|
|
115
|
+
if (cachedPackageJson) return (0, node_module.createRequire)(cachedPackageJson);
|
|
116
|
+
return localRequire;
|
|
117
|
+
}
|
|
118
|
+
function patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir) {
|
|
119
|
+
if (!mpxWebpackPluginDir) return false;
|
|
120
|
+
const projectRequire = resolveMpxWebpackPluginRequire(compiler);
|
|
121
|
+
let normalize;
|
|
122
|
+
try {
|
|
123
|
+
normalize = projectRequire("@mpxjs/webpack-plugin/lib/utils/normalize");
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
if (typeof normalize.lib !== "function") return false;
|
|
128
|
+
if (normalize.lib.__weappTwPatched) return true;
|
|
129
|
+
const wrappedLib = (file) => node_path.default.join(mpxWebpackPluginDir, "lib", file);
|
|
130
|
+
wrappedLib.__weappTwPatched = true;
|
|
131
|
+
wrappedLib.__weappTwOriginal = normalize.lib;
|
|
132
|
+
normalize.lib = wrappedLib;
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
78
135
|
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
79
136
|
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
80
137
|
compiler.options = compiler.options || {};
|
|
81
138
|
compiler.options.resolve = compiler.options.resolve || {};
|
|
82
139
|
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(compiler);
|
|
83
|
-
|
|
140
|
+
patchMpxWebpackPluginNormalizeLib(compiler, mpxWebpackPluginDir);
|
|
141
|
+
if (mpxWebpackPluginDir) ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
84
142
|
const alias = compiler.options.resolve.alias ?? {};
|
|
85
143
|
compiler.options.resolve.alias = alias;
|
|
86
144
|
if (Array.isArray(alias)) alias.push({
|
|
87
|
-
name: /^@mpxjs\/webpack-plugin\//,
|
|
88
|
-
alias: mpxWebpackPluginDir
|
|
89
|
-
}, {
|
|
90
145
|
name: "tailwindcss",
|
|
91
146
|
alias: tailwindcssCssEntry
|
|
92
147
|
}, {
|
|
@@ -94,11 +149,10 @@ function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
|
94
149
|
alias: tailwindcssCssEntry
|
|
95
150
|
});
|
|
96
151
|
else {
|
|
97
|
-
alias["@mpxjs/webpack-plugin"] = mpxWebpackPluginDir;
|
|
98
|
-
alias["@mpxjs/webpack-plugin$"] = mpxWebpackPluginDir;
|
|
99
152
|
alias.tailwindcss = tailwindcssCssEntry;
|
|
100
153
|
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
101
154
|
}
|
|
155
|
+
if (mpxWebpackPluginDir) addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
102
156
|
return tailwindcssCssEntry;
|
|
103
157
|
}
|
|
104
158
|
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
@@ -106,10 +160,11 @@ function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
|
106
160
|
const originalResolve = loaderContext.resolve;
|
|
107
161
|
if (originalResolve.__weappTwPatched) return;
|
|
108
162
|
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
163
|
+
const mpxWebpackPluginDir = resolveMpxWebpackPluginDir(loaderContext);
|
|
109
164
|
const wrappedResolve = function(context, request, callback) {
|
|
110
165
|
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
111
166
|
if (request?.startsWith("tailwindcss/")) return callback(null, node_path.default.join(pkgDir, request.slice(12)));
|
|
112
|
-
if (isMpxWebpackPluginRequest(request)) return
|
|
167
|
+
if (mpxWebpackPluginDir && isMpxWebpackPluginRequest(request)) return callback(null, resolveMpxWebpackPluginRequest(request, mpxWebpackPluginDir));
|
|
113
168
|
return originalResolve.call(this, context, request, callback);
|
|
114
169
|
};
|
|
115
170
|
wrappedResolve.__weappTwPatched = true;
|
|
@@ -145,16 +200,13 @@ function getCacheKey(filename) {
|
|
|
145
200
|
}
|
|
146
201
|
function stripResourceQuery(resource) {
|
|
147
202
|
if (typeof resource !== "string") return resource;
|
|
148
|
-
|
|
149
|
-
if (queryIndex !== -1) return resource.slice(0, queryIndex);
|
|
150
|
-
const hashIndex = resource.indexOf("#");
|
|
151
|
-
if (hashIndex !== -1) return resource.slice(0, hashIndex);
|
|
152
|
-
return resource;
|
|
203
|
+
return require_bundle_state.stripRequestQuery(resource);
|
|
153
204
|
}
|
|
154
205
|
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
155
206
|
if (typeof resource !== "string") return false;
|
|
156
207
|
const normalizedResource = stripResourceQuery(resource);
|
|
157
208
|
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
209
|
+
if (require_bundle_state.isSourceStyleRequest(resource)) return true;
|
|
158
210
|
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
159
211
|
return false;
|
|
160
212
|
}
|
|
@@ -162,6 +214,13 @@ function hasLoaderEntry(entries, target) {
|
|
|
162
214
|
if (!target) return false;
|
|
163
215
|
return entries.some((entry) => entry.loader?.includes?.(target));
|
|
164
216
|
}
|
|
217
|
+
function normalizeWatchPath(file) {
|
|
218
|
+
return node_path.default.resolve(file);
|
|
219
|
+
}
|
|
220
|
+
function isFileInContext(file, context) {
|
|
221
|
+
const relative = node_path.default.relative(normalizeWatchPath(context), normalizeWatchPath(file));
|
|
222
|
+
return relative.length > 0 && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
223
|
+
}
|
|
165
224
|
function toChunkFiles(files) {
|
|
166
225
|
if (!files) return [];
|
|
167
226
|
if (Array.isArray(files)) return files;
|
|
@@ -190,8 +249,11 @@ function createAssetHashByChunkMap(chunks) {
|
|
|
190
249
|
function createRuntimeAwareCssHash(assetHash, sourceHash, runtimeSetHash) {
|
|
191
250
|
return `${assetHash ?? sourceHash}:${runtimeSetHash}`;
|
|
192
251
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
252
|
+
function isWatchFileInRuntimeDependencies(file, dependencies) {
|
|
253
|
+
const normalizedFile = normalizeWatchPath(file);
|
|
254
|
+
for (const dependency of dependencies.files ?? []) if (normalizeWatchPath(dependency) === normalizedFile) return true;
|
|
255
|
+
for (const context of dependencies.contexts ?? []) if (isFileInContext(normalizedFile, context)) return true;
|
|
256
|
+
return false;
|
|
195
257
|
}
|
|
196
258
|
//#endregion
|
|
197
259
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
|
|
@@ -222,6 +284,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
222
284
|
compilerOptions.onStart();
|
|
223
285
|
debug("start");
|
|
224
286
|
await runtimeState.readyPromise;
|
|
287
|
+
const hmrTimingStartedAt = performance.now();
|
|
225
288
|
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
226
289
|
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
227
290
|
const entries = Object.entries(assets);
|
|
@@ -274,7 +337,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
274
337
|
const created = {
|
|
275
338
|
isMainChunk,
|
|
276
339
|
postcssOptions: { options: { from: file } },
|
|
277
|
-
majorVersion
|
|
340
|
+
...majorVersion === void 0 ? {} : { majorVersion }
|
|
278
341
|
};
|
|
279
342
|
cssHandlerOptionsCache.set(cacheKey, created);
|
|
280
343
|
return created;
|
|
@@ -323,14 +386,10 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
323
386
|
clearCache: forceRuntimeRefresh,
|
|
324
387
|
allowEmpty: false
|
|
325
388
|
});
|
|
326
|
-
if (runtimeSet.size === 0) {
|
|
327
|
-
const syncSet = runtimeState.twPatcher.getClassSetSync?.();
|
|
328
|
-
if (syncSet && syncSet.size > 0) runtimeSet = syncSet;
|
|
329
|
-
}
|
|
330
389
|
}
|
|
331
390
|
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
332
391
|
consumeRuntimeRefreshRequirement();
|
|
333
|
-
const runtimeSetHash = compilerOptions.cache.computeHash([
|
|
392
|
+
const runtimeSetHash = compilerOptions.cache.computeHash([require_v3_engine.getRuntimeClassSetSignature(runtimeState.twPatcher), [...runtimeSet].sort().join("\n")].join("\n\n"));
|
|
334
393
|
const defaultTemplateHandlerOptions = { runtimeSet };
|
|
335
394
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
336
395
|
const tasks = [];
|
|
@@ -448,6 +507,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
448
507
|
require_bundle_state.pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
449
508
|
await Promise.all(tasks);
|
|
450
509
|
debug("end");
|
|
510
|
+
require_incremental_runtime_class_set.emitHmrTiming("webpack", "processAssets", performance.now() - hmrTimingStartedAt);
|
|
451
511
|
compilerOptions.onEnd();
|
|
452
512
|
});
|
|
453
513
|
});
|
|
@@ -492,8 +552,8 @@ function setupWebpackV5Loaders(options) {
|
|
|
492
552
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? node_fs.default.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
493
553
|
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
494
554
|
pkgDir: weappTailwindcssPackageDir,
|
|
495
|
-
appType,
|
|
496
|
-
registerCssSource: registerAutoCssSource
|
|
555
|
+
...appType === void 0 ? {} : { appType },
|
|
556
|
+
...registerAutoCssSource === void 0 ? {} : { registerCssSource: registerAutoCssSource }
|
|
497
557
|
} : void 0;
|
|
498
558
|
const classSetLoaderOptions = {
|
|
499
559
|
getClassSet: getClassSetInLoader,
|
|
@@ -509,7 +569,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
509
569
|
type: null
|
|
510
570
|
});
|
|
511
571
|
const createCssImportRewriteLoaderEntry = () => {
|
|
512
|
-
if (!runtimeCssImportRewriteLoader) return null;
|
|
572
|
+
if (!runtimeCssImportRewriteLoader || !cssImportRewriteLoaderOptions) return null;
|
|
513
573
|
return {
|
|
514
574
|
loader: runtimeCssImportRewriteLoader,
|
|
515
575
|
options: cssImportRewriteLoaderOptions,
|
|
@@ -526,15 +586,15 @@ function setupWebpackV5Loaders(options) {
|
|
|
526
586
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
527
587
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
528
588
|
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
529
|
-
if (node_process.default.env
|
|
589
|
+
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), {
|
|
530
590
|
rewriteAnchorIdx,
|
|
531
591
|
classSetAnchorIdx
|
|
532
592
|
});
|
|
533
|
-
if (node_process.default.env
|
|
593
|
+
if (node_process.default.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), {
|
|
534
594
|
rewriteAnchorIdx,
|
|
535
595
|
classSetAnchorIdx
|
|
536
596
|
});
|
|
537
|
-
else if (node_process.default.env
|
|
597
|
+
else 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), {
|
|
538
598
|
rewriteAnchorIdx,
|
|
539
599
|
classSetAnchorIdx
|
|
540
600
|
});
|
|
@@ -567,7 +627,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
567
627
|
}
|
|
568
628
|
//#endregion
|
|
569
629
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
570
|
-
const debug =
|
|
630
|
+
const debug = require_v3_engine.createDebug();
|
|
571
631
|
const weappTailwindcssPackageDir = require_bundle_state.resolvePackageDir("weapp-tailwindcss");
|
|
572
632
|
/**
|
|
573
633
|
* @name UnifiedWebpackPluginV5
|
|
@@ -609,7 +669,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
609
669
|
const updateRuntimeWatchDependencies = async () => {
|
|
610
670
|
runtimeWatchDependencyFiles.clear();
|
|
611
671
|
runtimeWatchDependencyContexts.clear();
|
|
612
|
-
const tailwindOptions =
|
|
672
|
+
const tailwindOptions = require_v3_engine.resolveTailwindcssOptions(runtimeState.twPatcher.options);
|
|
613
673
|
if (tailwindOptions?.config) runtimeWatchDependencyFiles.add(tailwindOptions.config);
|
|
614
674
|
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) runtimeWatchDependencyFiles.add(entry);
|
|
615
675
|
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
@@ -631,13 +691,24 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
631
691
|
await updateRuntimeWatchDependencies();
|
|
632
692
|
runtimeMetadataPrepared = true;
|
|
633
693
|
};
|
|
694
|
+
const collectWatchChangedFiles = () => {
|
|
695
|
+
const compilerLike = compiler;
|
|
696
|
+
return new Set([...compilerLike.modifiedFiles ?? [], ...compilerLike.removedFiles ?? []]);
|
|
697
|
+
};
|
|
698
|
+
const hasRuntimeDependencyChanges = (files) => {
|
|
699
|
+
for (const file of files) if (isWatchFileInRuntimeDependencies(file, {
|
|
700
|
+
contexts: runtimeWatchDependencyContexts,
|
|
701
|
+
files: runtimeWatchDependencyFiles
|
|
702
|
+
})) return true;
|
|
703
|
+
return false;
|
|
704
|
+
};
|
|
634
705
|
const syncRuntimeRefreshRequirement = (markWatchRun = false) => {
|
|
635
706
|
if (markWatchRun) watchRunObserved = true;
|
|
636
|
-
|
|
707
|
+
const changedFiles = collectWatchChangedFiles();
|
|
708
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges(changedFiles);
|
|
637
709
|
};
|
|
638
710
|
const resetRuntimePreparation = () => {
|
|
639
711
|
runtimeSetPrepared = false;
|
|
640
|
-
runtimeMetadataPrepared = false;
|
|
641
712
|
syncRuntimeRefreshRequirement();
|
|
642
713
|
};
|
|
643
714
|
const registerAutoCssSource = async (source) => {
|
|
@@ -652,15 +723,16 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
652
723
|
});
|
|
653
724
|
debug("detected tailwindcss v4 css source from webpack css module: %s", source.file);
|
|
654
725
|
};
|
|
655
|
-
compiler.hooks.invalid?.tap?.(require_precheck.pluginName, () => {
|
|
656
|
-
|
|
726
|
+
compiler.hooks.invalid?.tap?.(require_precheck.pluginName, (fileName) => {
|
|
727
|
+
if (!fileName) return;
|
|
728
|
+
runtimeRefreshRequiredForCompilation = runtimeRefreshRequiredForCompilation || hasRuntimeDependencyChanges([node_path.default.resolve(fileName)]);
|
|
657
729
|
});
|
|
658
730
|
compiler.hooks.watchRun?.tap?.(require_precheck.pluginName, () => syncRuntimeRefreshRequirement(true));
|
|
659
731
|
if (compiler.hooks.thisCompilation?.tap) compiler.hooks.thisCompilation.tap(require_precheck.pluginName, resetRuntimePreparation);
|
|
660
732
|
else if (compiler.hooks.compilation?.tap) compiler.hooks.compilation.tap(require_precheck.pluginName, resetRuntimePreparation);
|
|
661
733
|
async function getClassSetInLoader() {
|
|
662
734
|
if (runtimeSetPrepared) return;
|
|
663
|
-
const signature =
|
|
735
|
+
const signature = require_v3_engine.getRuntimeClassSetSignature(runtimeState.twPatcher);
|
|
664
736
|
const forceRefresh = runtimeRefreshRequiredForCompilation || signature !== runtimeSetSignature;
|
|
665
737
|
debug("runtime loader ensure class set forceRefresh=%s watchDirty=%s signatureChanged=%s", forceRefresh, runtimeRefreshRequiredForCompilation, signature !== runtimeSetSignature);
|
|
666
738
|
runtimeSetPrepared = true;
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-wfNutjMm.js");
|
|
3
3
|
exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
|
|
4
4
|
exports.WeappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
|
|
5
5
|
exports.weappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-DvptFz7B.mjs";
|
|
2
2
|
export { UnifiedWebpackPluginV5, UnifiedWebpackPluginV5 as WeappTailwindcss, UnifiedWebpackPluginV5 as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.13",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -187,13 +187,13 @@
|
|
|
187
187
|
"micromatch": "^4.0.8",
|
|
188
188
|
"postcss-load-config": "^6.0.1",
|
|
189
189
|
"semver": "~7.8.0",
|
|
190
|
-
"tailwindcss-patch": "9.3.
|
|
190
|
+
"tailwindcss-patch": "9.3.5",
|
|
191
191
|
"yaml": "^2.9.0",
|
|
192
192
|
"@weapp-tailwindcss/logger": "1.1.0",
|
|
193
|
-
"@weapp-tailwindcss/postcss": "2.2.1-next.
|
|
193
|
+
"@weapp-tailwindcss/postcss": "2.2.1-next.2",
|
|
194
194
|
"@weapp-tailwindcss/reset": "0.1.1-next.0",
|
|
195
|
-
"tailwindcss
|
|
196
|
-
"
|
|
195
|
+
"@weapp-tailwindcss/shared": "1.1.3",
|
|
196
|
+
"tailwindcss-config": "1.1.6-next.1"
|
|
197
197
|
},
|
|
198
198
|
"scripts": {
|
|
199
199
|
"dev": "tsdown --watch --sourcemap",
|