weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundlers/shared/generator-css.d.ts +5 -2
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -0
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
- package/dist/cli/context.d.ts +0 -3
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli.js +8 -2
- package/dist/cli.mjs +8 -2
- package/dist/constants.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.d.ts +1 -0
- package/dist/defaults.js +5 -7
- package/dist/defaults.mjs +5 -7
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +3 -4
- package/dist/{generator-mmhXzZnv.js → generator-9UEp8OoQ.js} +259 -21
- package/dist/{generator-Y-Ikv4Fu.mjs → generator-Dpp-5s8z.mjs} +260 -22
- package/dist/{generator-css-CRLrHW4F.js → generator-css-CGueCYbX.js} +173 -32
- package/dist/{generator-css-Bwy_Uz89.mjs → generator-css-MyjZhF0z.mjs} +173 -32
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +15 -11
- package/dist/gulp.mjs +15 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/{logger-BoVx1Dbt.mjs → logger-1gx9UllH.mjs} +21 -51
- package/dist/{logger-BZ45DZJT.js → logger-D9clu_3f.js} +21 -51
- package/dist/patcher-options-DnqazL9E.js +34 -0
- package/dist/patcher-options-GuOwX0-k.mjs +17 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +37 -28
- package/dist/postcss.mjs +37 -28
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/{recorder-XdFvVASS.mjs → recorder-BIW3Kuke.mjs} +5 -12
- package/dist/{recorder-GdTJ3QqX.js → recorder-D4BKt75Q.js} +5 -12
- package/dist/reset.d.ts +1 -0
- package/dist/{css-imports-BbrbluP9.js → run-tasks-Cq5A5nVD.js} +6 -55
- package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DUVrDJGl.mjs} +5 -42
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +1 -3
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +0 -2
- package/dist/types/user-defined-options/important.d.ts +3 -3
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/version-CWBxRFPB.js +56 -0
- package/dist/version-WNz3MwRv.mjs +49 -0
- package/dist/{vite-DgRh_GXn.js → vite-BkMGwDeH.js} +106 -39
- package/dist/{vite-BDywuCjn.mjs → vite-fDM-UQpR.mjs} +89 -22
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
- package/dist/{webpack-CAJR4hhP.js → webpack-CICGEKT9.js} +225 -43
- package/dist/{webpack-CiHqVZTg.mjs → webpack-D2Wdk28V.mjs} +214 -27
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +21 -30
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
|
@@ -1,18 +1,180 @@
|
|
|
1
|
-
import { r as resolveTailwindcssOptions } from "./patcher-options-
|
|
2
|
-
import { g as ensureRuntimeClassSet, n as shouldSkipJsTransform, p as pluginName, r as getCompilerContext, t as setupPatchRecorder, v as createDebug } from "./recorder-
|
|
1
|
+
import { r as resolveTailwindcssOptions } from "./patcher-options-GuOwX0-k.mjs";
|
|
2
|
+
import { g as ensureRuntimeClassSet, n as shouldSkipJsTransform, p as pluginName, r as getCompilerContext, t as setupPatchRecorder, v as createDebug } from "./recorder-BIW3Kuke.mjs";
|
|
3
3
|
import { r as getGroupedEntries } from "./utils-7DUGTFED.mjs";
|
|
4
|
-
import { d as getRuntimeClassSetSignature } from "./logger-
|
|
5
|
-
import { i as processCachedTask, t as generateCssByGenerator } from "./generator-css-
|
|
6
|
-
import { a as
|
|
7
|
-
import
|
|
4
|
+
import { d as getRuntimeClassSetSignature } from "./logger-1gx9UllH.mjs";
|
|
5
|
+
import { i as processCachedTask, t as generateCssByGenerator } from "./generator-css-MyjZhF0z.mjs";
|
|
6
|
+
import { a as resolveOutputSpecifier, n as resolvePackageDir, o as toAbsoluteOutputPath, r as resolvePluginDisabledState, t as pushConcurrentTaskFactories } from "./run-tasks-DUVrDJGl.mjs";
|
|
7
|
+
import Module, { createRequire } from "node:module";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import process from "node:process";
|
|
10
10
|
import fs from "node:fs";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
//#region src/shared/tailwindcss-css-redirect.ts
|
|
13
|
+
const moduleWithMutableResolve = Module;
|
|
14
|
+
const patched = /* @__PURE__ */ new WeakSet();
|
|
15
|
+
function installTailwindcssCssRedirect(pkgDir) {
|
|
16
|
+
const target = path.join(pkgDir, "index.css");
|
|
17
|
+
const original = moduleWithMutableResolve._resolveFilename;
|
|
18
|
+
if (patched.has(original)) return;
|
|
19
|
+
const replacements = new Set(["tailwindcss", "tailwindcss$"]);
|
|
20
|
+
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
21
|
+
if (replacements.has(request)) return target;
|
|
22
|
+
if (request.startsWith("tailwindcss/")) return path.join(pkgDir, request.slice(12));
|
|
23
|
+
return original(request, parent, isMain, options);
|
|
24
|
+
};
|
|
25
|
+
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
26
|
+
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/shared/mpx.ts
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
const MPX_STYLE_RESOURCE_QUERY_RE$1 = /(?:^|[?&])type=styles(?:&|$)/;
|
|
32
|
+
function isMpxStyleResourceQuery(query) {
|
|
33
|
+
if (typeof query !== "string") return false;
|
|
34
|
+
return MPX_STYLE_RESOURCE_QUERY_RE$1.test(query);
|
|
35
|
+
}
|
|
36
|
+
function isMpx(appType) {
|
|
37
|
+
return appType === "mpx";
|
|
38
|
+
}
|
|
39
|
+
function getTailwindcssCssEntry(pkgDir) {
|
|
40
|
+
return path.join(pkgDir, "index.css");
|
|
41
|
+
}
|
|
42
|
+
function isMpxWebpackPluginRequest(request) {
|
|
43
|
+
return request === "@mpxjs/webpack-plugin" || Boolean(request?.startsWith("@mpxjs/webpack-plugin/"));
|
|
44
|
+
}
|
|
45
|
+
function addMpxWebpackPluginAlias(alias, pkgDir) {
|
|
46
|
+
if (Array.isArray(alias)) alias.push({
|
|
47
|
+
name: /^@mpxjs\/webpack-plugin\//,
|
|
48
|
+
alias: pkgDir
|
|
49
|
+
});
|
|
50
|
+
else {
|
|
51
|
+
alias["@mpxjs/webpack-plugin"] = pkgDir;
|
|
52
|
+
alias["@mpxjs/webpack-plugin$"] = pkgDir;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir) {
|
|
56
|
+
compiler.options.resolveLoader = compiler.options.resolveLoader || {};
|
|
57
|
+
const alias = compiler.options.resolveLoader.alias ?? {};
|
|
58
|
+
compiler.options.resolveLoader.alias = alias;
|
|
59
|
+
addMpxWebpackPluginAlias(alias, mpxWebpackPluginDir);
|
|
60
|
+
}
|
|
61
|
+
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
62
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
63
|
+
const mpxWebpackPluginDir = path.dirname(require.resolve("@mpxjs/webpack-plugin/package.json"));
|
|
64
|
+
compiler.options = compiler.options || {};
|
|
65
|
+
compiler.options.resolve = compiler.options.resolve || {};
|
|
66
|
+
ensureResolveLoaderAlias(compiler, mpxWebpackPluginDir);
|
|
67
|
+
const alias = compiler.options.resolve.alias ?? {};
|
|
68
|
+
compiler.options.resolve.alias = alias;
|
|
69
|
+
if (Array.isArray(alias)) alias.push({
|
|
70
|
+
name: /^@mpxjs\/webpack-plugin\//,
|
|
71
|
+
alias: mpxWebpackPluginDir
|
|
72
|
+
}, {
|
|
73
|
+
name: "tailwindcss",
|
|
74
|
+
alias: tailwindcssCssEntry
|
|
75
|
+
}, {
|
|
76
|
+
name: "tailwindcss$",
|
|
77
|
+
alias: tailwindcssCssEntry
|
|
78
|
+
});
|
|
79
|
+
else {
|
|
80
|
+
alias["@mpxjs/webpack-plugin"] = mpxWebpackPluginDir;
|
|
81
|
+
alias["@mpxjs/webpack-plugin$"] = mpxWebpackPluginDir;
|
|
82
|
+
alias.tailwindcss = tailwindcssCssEntry;
|
|
83
|
+
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
84
|
+
}
|
|
85
|
+
return tailwindcssCssEntry;
|
|
86
|
+
}
|
|
87
|
+
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
88
|
+
if (!enabled || typeof loaderContext.resolve !== "function") return;
|
|
89
|
+
const originalResolve = loaderContext.resolve;
|
|
90
|
+
if (originalResolve.__weappTwPatched) return;
|
|
91
|
+
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
92
|
+
const wrappedResolve = function(context, request, callback) {
|
|
93
|
+
if (request === "tailwindcss" || request === "tailwindcss$") return callback(null, tailwindcssCssEntry);
|
|
94
|
+
if (request?.startsWith("tailwindcss/")) return callback(null, path.join(pkgDir, request.slice(12)));
|
|
95
|
+
if (isMpxWebpackPluginRequest(request)) return originalResolve.call(this, process.cwd(), request, callback);
|
|
96
|
+
return originalResolve.call(this, context, request, callback);
|
|
97
|
+
};
|
|
98
|
+
wrappedResolve.__weappTwPatched = true;
|
|
99
|
+
loaderContext.resolve = wrappedResolve;
|
|
100
|
+
}
|
|
101
|
+
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
102
|
+
if (enabled) installTailwindcssCssRedirect(pkgDir);
|
|
103
|
+
}
|
|
104
|
+
const CSS_EXT_RE = /\.css$/i;
|
|
105
|
+
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
106
|
+
var _compiler$options;
|
|
107
|
+
if (!loader) return;
|
|
108
|
+
const moduleOptions = (_compiler$options = compiler.options).module ?? (_compiler$options.module = { rules: [] });
|
|
109
|
+
moduleOptions.rules = moduleOptions.rules || [];
|
|
110
|
+
const createRule = (match) => ({
|
|
111
|
+
...match,
|
|
112
|
+
enforce: "pre",
|
|
113
|
+
use: [{
|
|
114
|
+
loader,
|
|
115
|
+
options: loaderOptions
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
moduleOptions.rules.unshift(createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }), createRule({
|
|
119
|
+
test: CSS_EXT_RE,
|
|
120
|
+
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
|
|
125
|
+
const MPX_STYLE_RESOURCE_QUERY_RE = /(?:\?|&)type=styles\b/;
|
|
126
|
+
function getCacheKey(filename) {
|
|
127
|
+
return filename;
|
|
128
|
+
}
|
|
129
|
+
function stripResourceQuery(resource) {
|
|
130
|
+
if (typeof resource !== "string") return resource;
|
|
131
|
+
const queryIndex = resource.indexOf("?");
|
|
132
|
+
if (queryIndex !== -1) return resource.slice(0, queryIndex);
|
|
133
|
+
const hashIndex = resource.indexOf("#");
|
|
134
|
+
if (hashIndex !== -1) return resource.slice(0, hashIndex);
|
|
135
|
+
return resource;
|
|
136
|
+
}
|
|
137
|
+
function isCssLikeModuleResource(resource, cssMatcher, appType) {
|
|
138
|
+
if (typeof resource !== "string") return false;
|
|
139
|
+
const normalizedResource = stripResourceQuery(resource);
|
|
140
|
+
if (normalizedResource && cssMatcher(normalizedResource)) return true;
|
|
141
|
+
if (appType === "mpx") return MPX_STYLE_RESOURCE_QUERY_RE.test(resource);
|
|
14
142
|
return false;
|
|
15
143
|
}
|
|
144
|
+
function hasLoaderEntry(entries, target) {
|
|
145
|
+
if (!target) return false;
|
|
146
|
+
return entries.some((entry) => entry.loader?.includes?.(target));
|
|
147
|
+
}
|
|
148
|
+
function toChunkFiles(files) {
|
|
149
|
+
if (!files) return [];
|
|
150
|
+
if (Array.isArray(files)) return files;
|
|
151
|
+
return [...files];
|
|
152
|
+
}
|
|
153
|
+
function createAssetHashByChunkMap(chunks) {
|
|
154
|
+
const partsByFile = /* @__PURE__ */ new Map();
|
|
155
|
+
for (const chunk of chunks) {
|
|
156
|
+
const hash = typeof chunk.hash === "string" ? chunk.hash : void 0;
|
|
157
|
+
if (!hash) continue;
|
|
158
|
+
const chunkId = String(chunk.id ?? chunk.name ?? "");
|
|
159
|
+
for (const file of toChunkFiles(chunk.files)) {
|
|
160
|
+
if (!file) continue;
|
|
161
|
+
let parts = partsByFile.get(file);
|
|
162
|
+
if (!parts) {
|
|
163
|
+
parts = [];
|
|
164
|
+
partsByFile.set(file, parts);
|
|
165
|
+
}
|
|
166
|
+
parts.push(`${chunkId}:${hash}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const hashByFile = /* @__PURE__ */ new Map();
|
|
170
|
+
for (const [file, parts] of partsByFile.entries()) hashByFile.set(file, parts.sort().join("|"));
|
|
171
|
+
return hashByFile;
|
|
172
|
+
}
|
|
173
|
+
function hasWatchChanges(compiler) {
|
|
174
|
+
return (compiler.modifiedFiles?.size ?? 0) > 0 || (compiler.removedFiles?.size ?? 0) > 0;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets.ts
|
|
16
178
|
function setupWebpackV5ProcessAssetsHook(options) {
|
|
17
179
|
const { compiler, options: compilerOptions, appType, runtimeState, getRuntimeRefreshRequirement, refreshRuntimeMetadata, consumeRuntimeRefreshRequirement, debug } = options;
|
|
18
180
|
const { Compilation, sources } = compiler.webpack;
|
|
@@ -95,7 +257,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
95
257
|
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
96
258
|
return created;
|
|
97
259
|
};
|
|
98
|
-
const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
|
|
99
260
|
const forceRuntimeRefresh = getRuntimeRefreshRequirement();
|
|
100
261
|
debug("processAssets ensure runtime set forceRefresh=%s major=%s", forceRuntimeRefresh, runtimeState.twPatcher.majorVersion ?? "unknown");
|
|
101
262
|
const runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
@@ -106,6 +267,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
106
267
|
});
|
|
107
268
|
await refreshRuntimeMetadata(forceRuntimeRefresh);
|
|
108
269
|
consumeRuntimeRefreshRequirement();
|
|
270
|
+
const runtimeSetHash = compilerOptions.cache.computeHash([getRuntimeClassSetSignature(runtimeState.twPatcher), [...runtimeSet].sort().join("\n")].join("\n\n"));
|
|
109
271
|
const defaultTemplateHandlerOptions = { runtimeSet };
|
|
110
272
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
111
273
|
const tasks = [];
|
|
@@ -161,7 +323,6 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
161
323
|
const currentSourceValue = compilation.getAsset(file)?.source.source();
|
|
162
324
|
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : currentSourceValue?.toString() ?? "";
|
|
163
325
|
const handlerOptions = {
|
|
164
|
-
staleClassNameFallback,
|
|
165
326
|
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
166
327
|
filename: absoluteFile,
|
|
167
328
|
moduleGraph: moduleGraphOptions,
|
|
@@ -183,12 +344,13 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
183
344
|
const rawSource = originalSource.source().toString();
|
|
184
345
|
const cacheKey = file;
|
|
185
346
|
const chunkHash = assetHashByChunk.get(file);
|
|
347
|
+
const runtimeAwareHash = chunkHash ? `${chunkHash}:${runtimeSetHash}` : void 0;
|
|
186
348
|
tasks.push(processCachedTask({
|
|
187
349
|
cache: compilerOptions.cache,
|
|
188
350
|
cacheKey,
|
|
189
351
|
hashKey: `${file}:asset`,
|
|
190
352
|
rawSource,
|
|
191
|
-
hash:
|
|
353
|
+
hash: runtimeAwareHash,
|
|
192
354
|
applyResult(source) {
|
|
193
355
|
compilation.updateAsset(file, source);
|
|
194
356
|
},
|
|
@@ -226,13 +388,46 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
226
388
|
});
|
|
227
389
|
}
|
|
228
390
|
//#endregion
|
|
391
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.12_typescript@5.9.3_vue-tsc@3.2.8_typescript@5.9.3_/node_modules/tsdown/esm-shims.js
|
|
392
|
+
const getFilename = () => fileURLToPath(import.meta.url);
|
|
393
|
+
const getDirname = () => path.dirname(getFilename());
|
|
394
|
+
const __dirname = /* @__PURE__ */ getDirname();
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/bundlers/webpack/shared/loader-anchors.ts
|
|
397
|
+
const MPX_STRIP_CONDITIONAL_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/strip-conditional-loader";
|
|
398
|
+
const MPX_STYLE_COMPILER_LOADER = "@mpxjs/webpack-plugin/lib/style-compiler/index";
|
|
399
|
+
const MPX_REWRITE_PRECEDENCE_LOADERS = [MPX_STYLE_COMPILER_LOADER, MPX_STRIP_CONDITIONAL_LOADER];
|
|
400
|
+
function createFinder(targets) {
|
|
401
|
+
return (entries) => entries.findIndex((entry) => targets.some((target) => entry?.loader?.includes?.(target)));
|
|
402
|
+
}
|
|
403
|
+
function createPrioritizedFinder(targets) {
|
|
404
|
+
return (entries) => {
|
|
405
|
+
for (const target of targets) {
|
|
406
|
+
const idx = entries.findIndex((entry) => entry?.loader?.includes?.(target));
|
|
407
|
+
if (idx !== -1) return idx;
|
|
408
|
+
}
|
|
409
|
+
return -1;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function createLoaderAnchorFinders(appType) {
|
|
413
|
+
if (isMpx(appType)) return {
|
|
414
|
+
findRewriteAnchor: createPrioritizedFinder(MPX_REWRITE_PRECEDENCE_LOADERS),
|
|
415
|
+
findClassSetAnchor: createFinder([MPX_STYLE_COMPILER_LOADER])
|
|
416
|
+
};
|
|
417
|
+
const fallbackFinder = createFinder(["postcss-loader"]);
|
|
418
|
+
return {
|
|
419
|
+
findRewriteAnchor: fallbackFinder,
|
|
420
|
+
findClassSetAnchor: fallbackFinder
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
229
424
|
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.ts
|
|
230
425
|
function setupWebpackV5Loaders(options) {
|
|
231
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath,
|
|
426
|
+
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, getClassSetInLoader, getRuntimeWatchDependencies, debug } = options;
|
|
232
427
|
const isMpxApp = isMpx(appType);
|
|
233
428
|
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
234
429
|
const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
235
|
-
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ?
|
|
430
|
+
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
236
431
|
const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
|
|
237
432
|
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
238
433
|
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
@@ -244,7 +439,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
244
439
|
getWatchDependencies: getRuntimeWatchDependencies
|
|
245
440
|
};
|
|
246
441
|
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
247
|
-
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
442
|
+
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { tailwindcssImportRewrite: runtimeLoaderRewriteOptions } : void 0;
|
|
248
443
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
249
444
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
250
445
|
loader: runtimeClassSetLoader,
|
|
@@ -325,18 +520,11 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
325
520
|
}
|
|
326
521
|
apply(compiler) {
|
|
327
522
|
compiler.options = compiler.options || {};
|
|
328
|
-
const { disabled, onLoad, runtimeLoaderPath,
|
|
329
|
-
const disabledOptions =
|
|
330
|
-
const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4
|
|
523
|
+
const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
|
|
524
|
+
const disabledOptions = resolvePluginDisabledState(disabled);
|
|
525
|
+
const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4;
|
|
331
526
|
const isMpxApp = isMpx(this.appType);
|
|
332
|
-
if (shouldRewriteCssImports)
|
|
333
|
-
applyTailwindcssCssImportRewrite(compiler, {
|
|
334
|
-
pkgDir: weappTailwindcssPackageDir,
|
|
335
|
-
enabled: true,
|
|
336
|
-
appType: this.appType
|
|
337
|
-
});
|
|
338
|
-
setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
339
|
-
}
|
|
527
|
+
if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
340
528
|
if (disabledOptions.plugin) return;
|
|
341
529
|
const patchRecorderState = setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
342
530
|
source: "runtime",
|
|
@@ -413,7 +601,6 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
413
601
|
weappTailwindcssPackageDir,
|
|
414
602
|
shouldRewriteCssImports,
|
|
415
603
|
runtimeLoaderPath,
|
|
416
|
-
runtimeCssImportRewriteLoaderPath,
|
|
417
604
|
getClassSetInLoader,
|
|
418
605
|
getRuntimeWatchDependencies() {
|
|
419
606
|
return {
|
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-CICGEKT9.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-D2Wdk28V.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.5",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,11 +61,6 @@
|
|
|
61
61
|
"import": "./dist/webpack.mjs",
|
|
62
62
|
"require": "./dist/webpack.js"
|
|
63
63
|
},
|
|
64
|
-
"./webpack4": {
|
|
65
|
-
"types": "./dist/webpack4.d.ts",
|
|
66
|
-
"import": "./dist/webpack4.mjs",
|
|
67
|
-
"require": "./dist/webpack4.js"
|
|
68
|
-
},
|
|
69
64
|
"./core": {
|
|
70
65
|
"types": "./dist/core.d.ts",
|
|
71
66
|
"import": "./dist/core.mjs",
|
|
@@ -150,7 +145,6 @@
|
|
|
150
145
|
}
|
|
151
146
|
},
|
|
152
147
|
"bin": {
|
|
153
|
-
"weapp-tailwindcss-webpack-plugin": "bin/weapp-tailwindcss.js",
|
|
154
148
|
"weapp-tailwindcss": "bin/weapp-tailwindcss.js",
|
|
155
149
|
"weapp-tw": "bin/weapp-tailwindcss.js"
|
|
156
150
|
},
|
|
@@ -161,7 +155,6 @@
|
|
|
161
155
|
"generator-placeholder.css",
|
|
162
156
|
"index.css",
|
|
163
157
|
"preflight.css",
|
|
164
|
-
"scripts/postinstall.mjs",
|
|
165
158
|
"theme.css",
|
|
166
159
|
"uni-app-x.css",
|
|
167
160
|
"utilities.css",
|
|
@@ -195,42 +188,40 @@
|
|
|
195
188
|
"magic-string": "0.30.21",
|
|
196
189
|
"postcss-load-config": "^6.0.1",
|
|
197
190
|
"semver": "~7.7.4",
|
|
198
|
-
"tailwindcss-patch": "9.2
|
|
191
|
+
"tailwindcss-patch": "9.3.2",
|
|
199
192
|
"webpack-sources": "3.3.4",
|
|
200
193
|
"yaml": "^2.8.4",
|
|
194
|
+
"@weapp-tailwindcss/postcss": "2.2.1-next.0",
|
|
201
195
|
"@weapp-tailwindcss/logger": "1.1.0",
|
|
202
|
-
"@weapp-tailwindcss/
|
|
203
|
-
"@weapp-tailwindcss/
|
|
204
|
-
"tailwindcss-config": "1.1.6-next.0"
|
|
205
|
-
"@weapp-tailwindcss/shared": "1.1.3"
|
|
196
|
+
"@weapp-tailwindcss/reset": "0.1.1-next.0",
|
|
197
|
+
"@weapp-tailwindcss/shared": "1.1.3",
|
|
198
|
+
"tailwindcss-config": "1.1.6-next.0"
|
|
206
199
|
},
|
|
207
200
|
"scripts": {
|
|
208
201
|
"dev": "tsdown --watch --sourcemap",
|
|
209
|
-
"build": "tsdown && pnpm run build:types &&
|
|
210
|
-
"build:types": "tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --declarationDir dist --noEmit false &&
|
|
202
|
+
"build": "tsdown && pnpm run build:types && pnpm --filter @weapp-tailwindcss/scripts ensure-escape-dts",
|
|
203
|
+
"build:types": "tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --declarationDir dist --noEmit false && pnpm --filter @weapp-tailwindcss/scripts build:types",
|
|
211
204
|
"build:tsc": "cross-env NODE_ENV=development tsc --build tsconfig.json",
|
|
212
205
|
"build:cli": "cd plugins/cli && pnpm run build",
|
|
213
|
-
"build:css": "
|
|
214
|
-
"build:weapp-theme": "
|
|
215
|
-
"test": "
|
|
206
|
+
"build:css": "pnpm --filter @weapp-tailwindcss/scripts build:css",
|
|
207
|
+
"build:weapp-theme": "pnpm --filter @weapp-tailwindcss/scripts build:weapp-theme",
|
|
208
|
+
"test": "vitest run",
|
|
216
209
|
"test:dev": "vitest",
|
|
217
210
|
"test:ui": "vitest --ui",
|
|
218
211
|
"bench": "vitest bench --config ./vitest.config.ts",
|
|
219
|
-
"bench:vite-perf": "
|
|
220
|
-
"bench:vite-perf:summary": "
|
|
221
|
-
"bench:js-handlers": "
|
|
222
|
-
"bench:js-diff": "
|
|
212
|
+
"bench:vite-perf": "pnpm --filter @weapp-tailwindcss/scripts bench:vite-perf",
|
|
213
|
+
"bench:vite-perf:summary": "pnpm --filter @weapp-tailwindcss/scripts bench:vite-perf:summary",
|
|
214
|
+
"bench:js-handlers": "pnpm --filter @weapp-tailwindcss/scripts bench:js-handlers",
|
|
215
|
+
"bench:js-diff": "pnpm --filter @weapp-tailwindcss/scripts bench:js-diff",
|
|
223
216
|
"tsd": "tsd",
|
|
224
|
-
"clean": "
|
|
225
|
-
"get-decl": "
|
|
217
|
+
"clean": "pnpm --filter @weapp-tailwindcss/scripts clean:core",
|
|
218
|
+
"get-decl": "pnpm --filter @weapp-tailwindcss/scripts get-decl",
|
|
226
219
|
"ls:pack": "npm pack --dry-run",
|
|
227
|
-
"
|
|
228
|
-
"
|
|
229
|
-
"release": "tsx scripts/release.ts",
|
|
220
|
+
"colors": "pnpm --filter @weapp-tailwindcss/scripts colors",
|
|
221
|
+
"release": "pnpm --filter @weapp-tailwindcss/scripts release",
|
|
230
222
|
"lint": "eslint .",
|
|
231
223
|
"lint:fix": "eslint ./src --fix",
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"test:watch-hmr": "node --import tsx scripts/watch-hmr-regression/index.ts"
|
|
224
|
+
"bench:vite-dev-hmr": "pnpm --filter @weapp-tailwindcss/scripts bench:vite-dev-hmr",
|
|
225
|
+
"test:watch-hmr": "pnpm --filter @weapp-tailwindcss/scripts test:watch-hmr"
|
|
235
226
|
}
|
|
236
227
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack4';
|
|
2
|
-
import type { AppType, InternalUserDefinedOptions } from '../../../types';
|
|
3
|
-
interface SetupWebpackV4EmitHookOptions {
|
|
4
|
-
compiler: Compiler;
|
|
5
|
-
options: InternalUserDefinedOptions;
|
|
6
|
-
appType?: AppType;
|
|
7
|
-
runtimeState: {
|
|
8
|
-
twPatcher: InternalUserDefinedOptions['twPatcher'];
|
|
9
|
-
patchPromise: Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
debug: (format: string, ...args: unknown[]) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare function setupWebpackV4EmitHook(options: SetupWebpackV4EmitHookOptions): void;
|
|
14
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack4';
|
|
2
|
-
import type { AppType, InternalUserDefinedOptions } from '../../../types';
|
|
3
|
-
interface SetupWebpackV4LoadersOptions {
|
|
4
|
-
compiler: Compiler;
|
|
5
|
-
options: InternalUserDefinedOptions;
|
|
6
|
-
appType?: AppType;
|
|
7
|
-
weappTailwindcssPackageDir: string;
|
|
8
|
-
shouldRewriteCssImports: boolean;
|
|
9
|
-
runtimeLoaderPath?: string;
|
|
10
|
-
runtimeCssImportRewriteLoaderPath?: string;
|
|
11
|
-
getClassSetInLoader: () => Promise<void>;
|
|
12
|
-
debug: (format: string, ...args: unknown[]) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function setupWebpackV4Loaders(options: SetupWebpackV4LoadersOptions): void;
|
|
15
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack4';
|
|
2
|
-
import type { AppType, IBaseWebpackPlugin, InternalUserDefinedOptions, UserDefinedOptions } from '../../../types';
|
|
3
|
-
export declare const weappTailwindcssPackageDir: string;
|
|
4
|
-
export declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
|
|
5
|
-
options: InternalUserDefinedOptions;
|
|
6
|
-
appType?: AppType;
|
|
7
|
-
constructor(options?: UserDefinedOptions);
|
|
8
|
-
apply(compiler: Compiler): void;
|
|
9
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface Oxcast {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}
|
|
4
|
-
export declare function parseWithOxc(code: string): Oxcast;
|
|
5
|
-
export declare function getIdentifierName(node: any): string | undefined;
|
|
6
|
-
export declare function isStringLiteral(node: any): node is {
|
|
7
|
-
type: string;
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function isTemplateLiteral(node: any): boolean;
|
|
11
|
-
export declare function getTemplateQuasis(node: any): any[];
|
|
12
|
-
export declare function getTplElementRaw(elem: any): string | undefined;
|
|
13
|
-
export declare function isTaggedTemplate(node: any): boolean;
|
|
14
|
-
export declare function getTaggedTemplateTag(node: any): any;
|
|
15
|
-
export declare function isCallExpression(node: any): boolean;
|
|
16
|
-
export declare function getCallCallee(node: any): any;
|
|
17
|
-
export declare function getCallArguments(node: any): any[];
|
|
18
|
-
export declare function isImportDeclaration(node: any): boolean;
|
|
19
|
-
export declare function isExportAllDeclaration(node: any): boolean;
|
|
20
|
-
export declare function getImportSourceLiteral(node: any): any | undefined;
|
|
21
|
-
export declare function sliceStringLiteralText(code: string, node: any): {
|
|
22
|
-
start: number;
|
|
23
|
-
end: number;
|
|
24
|
-
text: string;
|
|
25
|
-
} | undefined;
|
|
26
|
-
export declare function sliceTplElementText(code: string, elem: any): {
|
|
27
|
-
start: number;
|
|
28
|
-
end: number;
|
|
29
|
-
text: string;
|
|
30
|
-
} | undefined;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { IJsHandlerOptions } from '../../types';
|
|
2
|
-
export declare function shouldTransformClassName(candidate: string, options: Pick<IJsHandlerOptions, 'alwaysEscape' | 'classNameSet' | 'jsPreserveClass'>): boolean;
|
|
3
|
-
export declare function transformLiteralText(literal: string, options: IJsHandlerOptions): string | undefined;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { getPattern, getReplacement } from './shared/cache';
|
|
2
|
-
export { shouldTransformClassName, transformLiteralText } from './shared/transform';
|
|
3
|
-
export declare function createToken(start: number, end: number, value: string): {
|
|
4
|
-
start: number;
|
|
5
|
-
end: number;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function createNameMatcher(patterns: (string | RegExp)[] | undefined, exact?: boolean): (name: string) => boolean;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface SwcAst {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}
|
|
4
|
-
export declare function parseWithSwc(code: string): SwcAst;
|
|
5
|
-
export declare function getIdentifierName(node: any): string | undefined;
|
|
6
|
-
export declare function isStringLiteral(node: any): node is {
|
|
7
|
-
type: string;
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function isTemplateLiteral(node: any): boolean;
|
|
11
|
-
export declare function getTemplateQuasis(node: any): any[];
|
|
12
|
-
export declare function getTplElementRaw(elem: any): string | undefined;
|
|
13
|
-
export declare function isTaggedTemplate(node: any): boolean;
|
|
14
|
-
export declare function getTaggedTemplateTag(node: any): any;
|
|
15
|
-
export declare function isCallExpression(node: any): boolean;
|
|
16
|
-
export declare function getCallCallee(node: any): any;
|
|
17
|
-
export declare function getCallArguments(node: any): any[];
|
|
18
|
-
export declare function isImportDeclaration(node: any): boolean;
|
|
19
|
-
export declare function isExportAllDeclaration(node: any): boolean;
|
|
20
|
-
export declare function getImportSourceLiteral(node: any): any | undefined;
|
|
21
|
-
export declare function sliceStringLiteralText(code: string, node: any): {
|
|
22
|
-
start: number;
|
|
23
|
-
end: number;
|
|
24
|
-
text: string;
|
|
25
|
-
} | undefined;
|
|
26
|
-
export declare function sliceTplElementText(code: string, elem: any): {
|
|
27
|
-
start: number;
|
|
28
|
-
end: number;
|
|
29
|
-
text: string;
|
|
30
|
-
} | undefined;
|