weapp-tailwindcss 4.8.12 → 4.8.14
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/{chunk-WILVISNS.js → chunk-2AWOAQD3.js} +34 -32
- package/dist/{chunk-4H3RCNUP.mjs → chunk-2HIXWVX2.mjs} +50 -47
- package/dist/{chunk-HXYNNE6Q.mjs → chunk-3SKEY32E.mjs} +18 -119
- package/dist/{chunk-HHSKDU3Z.mjs → chunk-3VIPMWAG.mjs} +22 -24
- package/dist/{chunk-WIET7TXZ.js → chunk-477TX4LM.js} +5 -5
- package/dist/{chunk-243FNJFQ.js → chunk-63LJ4WHF.js} +7 -7
- package/dist/chunk-6VSFN3NA.js +251 -0
- package/dist/{chunk-XSRP6OF5.mjs → chunk-7UAU27KZ.mjs} +2 -2
- package/dist/{chunk-HMFOJPZG.mjs → chunk-EKF3ABRO.mjs} +2 -2
- package/dist/chunk-FSI2IWUY.mjs +251 -0
- package/dist/{chunk-AVUQQ4GH.mjs → chunk-HJWY5Y6L.mjs} +15 -13
- package/dist/{chunk-ZADOXTZC.js → chunk-J4MI4EJO.js} +16 -18
- package/dist/{chunk-AVR4TFX3.js → chunk-L3AOBWDW.js} +7 -7
- package/dist/{chunk-A5JYBYB2.js → chunk-MB4BR57E.js} +1 -1
- package/dist/{chunk-ZSI6C3R4.js → chunk-ML4F4ZPY.js} +66 -63
- package/dist/{chunk-3DQN7M5U.js → chunk-ORSWL3MI.js} +20 -121
- package/dist/{chunk-MDZGOZZP.mjs → chunk-SM5V25IN.mjs} +1 -1
- package/dist/{chunk-K2Y3FXU7.mjs → chunk-ZC5JYOAR.mjs} +2 -2
- package/dist/cli.js +39 -39
- package/dist/cli.mjs +3 -3
- package/dist/core.js +10 -10
- package/dist/core.mjs +4 -4
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +6 -6
- package/dist/gulp.mjs +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +9 -9
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.d.mts +14 -10
- package/dist/presets.d.ts +14 -10
- package/dist/presets.js +68 -64
- package/dist/presets.mjs +69 -65
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.d.mts +24 -2
- package/dist/types.d.ts +24 -2
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -7
- package/dist/vite.mjs +6 -6
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -18
- package/dist/weapp-tw-runtime-classset-loader.js +1 -3
- package/dist/webpack.js +8 -8
- package/dist/webpack.mjs +7 -7
- package/dist/webpack4.js +37 -35
- package/dist/webpack4.mjs +16 -14
- package/package.json +4 -4
- package/dist/chunk-6LYLDH5F.mjs +0 -136
- package/dist/chunk-BYXBJQAS.js +0 -1
- package/dist/chunk-CGCWO2U6.js +0 -136
|
@@ -4,31 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkCGCWO2U6js = require('./chunk-CGCWO2U6.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
12
|
+
var _chunk6VSFN3NAjs = require('./chunk-6VSFN3NA.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
var _chunkORSWL3MIjs = require('./chunk-ORSWL3MI.js');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
var
|
|
25
|
+
var _chunk477TX4LMjs = require('./chunk-477TX4LM.js');
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
+
var _chunk63LJ4WHFjs = require('./chunk-63LJ4WHF.js');
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -37,11 +38,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
37
38
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
38
39
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
39
40
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
40
|
-
var debug =
|
|
41
|
-
var weappTailwindcssPackageDir =
|
|
41
|
+
var debug = _chunk63LJ4WHFjs.createDebug.call(void 0, );
|
|
42
|
+
var weappTailwindcssPackageDir = _chunkORSWL3MIjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
42
43
|
var UnifiedWebpackPluginV5 = class {
|
|
43
44
|
constructor(options = {}) {
|
|
44
|
-
this.options =
|
|
45
|
+
this.options = _chunk63LJ4WHFjs.getCompilerContext.call(void 0, options);
|
|
45
46
|
this.appType = this.options.appType;
|
|
46
47
|
}
|
|
47
48
|
apply(compiler) {
|
|
@@ -62,21 +63,22 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
62
63
|
twPatcher: initialTwPatcher,
|
|
63
64
|
refreshTailwindcssPatcher
|
|
64
65
|
} = this.options;
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
66
|
+
const disabledOptions = _chunkORSWL3MIjs.resolveDisabledOptions.call(void 0, disabled);
|
|
68
67
|
const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
|
|
69
|
-
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false;
|
|
70
|
-
const isMpxApp =
|
|
68
|
+
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
69
|
+
const isMpxApp = _chunk6VSFN3NAjs.isMpx.call(void 0, this.appType);
|
|
71
70
|
if (shouldRewriteCssImports) {
|
|
72
|
-
|
|
71
|
+
_chunk6VSFN3NAjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
|
|
73
72
|
pkgDir: weappTailwindcssPackageDir,
|
|
74
73
|
enabled: true,
|
|
75
74
|
appType: this.appType
|
|
76
75
|
});
|
|
77
|
-
|
|
76
|
+
_chunk6VSFN3NAjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
|
|
77
|
+
}
|
|
78
|
+
if (disabledOptions.plugin) {
|
|
79
|
+
return;
|
|
78
80
|
}
|
|
79
|
-
const patchRecorderState =
|
|
81
|
+
const patchRecorderState = _chunk477TX4LMjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
80
82
|
source: "runtime",
|
|
81
83
|
cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
82
84
|
});
|
|
@@ -87,14 +89,14 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
87
89
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
88
90
|
};
|
|
89
91
|
const refreshRuntimeState = async (force) => {
|
|
90
|
-
await
|
|
92
|
+
await _chunk63LJ4WHFjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
91
93
|
};
|
|
92
94
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
93
95
|
const { ConcatSource } = sources;
|
|
94
96
|
async function getClassSetInLoader() {
|
|
95
97
|
await refreshRuntimeState(true);
|
|
96
98
|
await runtimeState.patchPromise;
|
|
97
|
-
await
|
|
99
|
+
await _chunk63LJ4WHFjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
98
100
|
}
|
|
99
101
|
const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
|
|
100
102
|
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
|
|
@@ -107,16 +109,16 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
107
109
|
const classSetLoaderOptions = {
|
|
108
110
|
getClassSet: getClassSetInLoader
|
|
109
111
|
};
|
|
110
|
-
const { findRewriteAnchor, findClassSetAnchor } =
|
|
112
|
+
const { findRewriteAnchor, findClassSetAnchor } = _chunk6VSFN3NAjs.createLoaderAnchorFinders.call(void 0, this.appType);
|
|
111
113
|
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
112
114
|
rewriteCssImports: runtimeLoaderRewriteOptions
|
|
113
115
|
} : void 0;
|
|
114
116
|
onLoad();
|
|
115
117
|
if (shouldRewriteCssImports && isMpxApp) {
|
|
116
|
-
|
|
118
|
+
_chunk6VSFN3NAjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
|
|
117
119
|
}
|
|
118
120
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
|
|
119
|
-
|
|
121
|
+
_chunk6VSFN3NAjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
120
122
|
}
|
|
121
123
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
122
124
|
loader: runtimeClassSetLoader,
|
|
@@ -135,17 +137,17 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
135
137
|
type: null
|
|
136
138
|
};
|
|
137
139
|
};
|
|
138
|
-
compiler.hooks.compilation.tap(
|
|
139
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
140
|
+
compiler.hooks.compilation.tap(_chunk63LJ4WHFjs.pluginName, (compilation) => {
|
|
141
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunk63LJ4WHFjs.pluginName, (_loaderContext, module) => {
|
|
140
142
|
const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
|
|
141
143
|
if (!hasRuntimeLoader) {
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
_chunk6VSFN3NAjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
|
|
145
147
|
const loaderEntries = module.loaders || [];
|
|
146
148
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
147
149
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
148
|
-
const isCssModule =
|
|
150
|
+
const isCssModule = _chunk6VSFN3NAjs.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
|
|
149
151
|
if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
|
|
150
152
|
debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
|
|
151
153
|
}
|
|
@@ -177,7 +179,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
177
179
|
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
|
-
if (runtimeClassSetLoaderExists && !
|
|
182
|
+
if (runtimeClassSetLoaderExists && !_chunk6VSFN3NAjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
|
|
181
183
|
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
182
184
|
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
183
185
|
if (anchorIndex === -1) {
|
|
@@ -190,7 +192,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
190
192
|
});
|
|
191
193
|
compilation.hooks.processAssets.tapPromise(
|
|
192
194
|
{
|
|
193
|
-
name:
|
|
195
|
+
name: _chunk63LJ4WHFjs.pluginName,
|
|
194
196
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
195
197
|
},
|
|
196
198
|
async (assets) => {
|
|
@@ -208,13 +210,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
208
210
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
209
211
|
for (const [file] of entries) {
|
|
210
212
|
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
211
|
-
const absolute =
|
|
213
|
+
const absolute = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
212
214
|
jsAssets.set(absolute, file);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
const moduleGraphOptions = {
|
|
216
218
|
resolve(specifier, importer) {
|
|
217
|
-
return
|
|
219
|
+
return _chunkORSWL3MIjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
218
220
|
},
|
|
219
221
|
load: (id) => {
|
|
220
222
|
const assetName = jsAssets.get(id);
|
|
@@ -259,7 +261,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
259
261
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
260
262
|
await refreshRuntimeState(true);
|
|
261
263
|
await runtimeState.patchPromise;
|
|
262
|
-
const runtimeSet = await
|
|
264
|
+
const runtimeSet = await _chunk63LJ4WHFjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
263
265
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
264
266
|
const tasks = [];
|
|
265
267
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -296,12 +298,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
296
298
|
const jsTaskFactories = [];
|
|
297
299
|
if (Array.isArray(groupedEntries.js)) {
|
|
298
300
|
for (const [file] of groupedEntries.js) {
|
|
299
|
-
const cacheKey =
|
|
301
|
+
const cacheKey = _chunk6VSFN3NAjs.getCacheKey.call(void 0, file);
|
|
300
302
|
const asset = compilation.getAsset(file);
|
|
301
303
|
if (!asset) {
|
|
302
304
|
continue;
|
|
303
305
|
}
|
|
304
|
-
const absoluteFile =
|
|
306
|
+
const absoluteFile = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
305
307
|
const initialSource = asset.source.source();
|
|
306
308
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
307
309
|
jsTaskFactories.push(async () => {
|
|
@@ -376,7 +378,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
376
378
|
);
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
|
-
|
|
381
|
+
_chunkORSWL3MIjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
380
382
|
await Promise.all(tasks);
|
|
381
383
|
debug("end");
|
|
382
384
|
onEnd();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pushConcurrentTaskFactories,
|
|
3
|
+
resolveDisabledOptions,
|
|
3
4
|
resolveOutputSpecifier,
|
|
4
5
|
resolvePackageDir,
|
|
5
6
|
resolveTailwindcssImport,
|
|
6
7
|
rewriteTailwindcssImportsInCode,
|
|
7
8
|
toAbsoluteOutputPath
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3SKEY32E.mjs";
|
|
9
10
|
import {
|
|
10
11
|
processCachedTask
|
|
11
12
|
} from "./chunk-RRHPTTCP.mjs";
|
|
12
13
|
import {
|
|
13
14
|
setupPatchRecorder
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7UAU27KZ.mjs";
|
|
15
16
|
import {
|
|
16
17
|
collectRuntimeClassSet,
|
|
17
18
|
createAttributeMatcher,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
replaceWxml,
|
|
23
24
|
toCustomAttributesEntities,
|
|
24
25
|
vitePluginName
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZC5JYOAR.mjs";
|
|
26
27
|
import {
|
|
27
28
|
getGroupedEntries
|
|
28
29
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
@@ -463,8 +464,52 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
463
464
|
uniAppX,
|
|
464
465
|
disabledDefaultTemplateHandler
|
|
465
466
|
} = opts;
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
const disabledOptions = resolveDisabledOptions(disabled);
|
|
468
|
+
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
469
|
+
const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
|
|
470
|
+
const rewritePlugins = !shouldRewriteCssImports ? [] : [
|
|
471
|
+
{
|
|
472
|
+
name: `${vitePluginName}:rewrite-css-imports`,
|
|
473
|
+
enforce: "pre",
|
|
474
|
+
resolveId: {
|
|
475
|
+
order: "pre",
|
|
476
|
+
handler(id, importer) {
|
|
477
|
+
const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
478
|
+
join: joinPosixPath,
|
|
479
|
+
appType
|
|
480
|
+
});
|
|
481
|
+
if (!replacement) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
if (importer && !isCssLikeImporter(importer)) {
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
return replacement;
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
transform: {
|
|
491
|
+
order: "pre",
|
|
492
|
+
handler(code, id) {
|
|
493
|
+
if (!isCSSRequest(id)) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
497
|
+
join: joinPosixPath,
|
|
498
|
+
appType
|
|
499
|
+
});
|
|
500
|
+
if (!rewritten) {
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
code: rewritten,
|
|
505
|
+
map: null
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
];
|
|
511
|
+
if (disabledOptions.plugin) {
|
|
512
|
+
return rewritePlugins.length ? rewritePlugins : void 0;
|
|
468
513
|
}
|
|
469
514
|
const customAttributesEntities = toCustomAttributesEntities(customAttributes);
|
|
470
515
|
const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
|
|
@@ -511,48 +556,6 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
511
556
|
}
|
|
512
557
|
}
|
|
513
558
|
onLoad();
|
|
514
|
-
const shouldRewriteCssImports = opts.rewriteCssImports !== false && (rewriteCssImportsSpecified || (runtimeState.twPatcher.majorVersion ?? 0) >= 4);
|
|
515
|
-
const rewritePlugins = !shouldRewriteCssImports ? [] : [
|
|
516
|
-
{
|
|
517
|
-
name: `${vitePluginName}:rewrite-css-imports`,
|
|
518
|
-
enforce: "pre",
|
|
519
|
-
resolveId: {
|
|
520
|
-
order: "pre",
|
|
521
|
-
handler(id, importer) {
|
|
522
|
-
const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
523
|
-
join: joinPosixPath,
|
|
524
|
-
appType
|
|
525
|
-
});
|
|
526
|
-
if (!replacement) {
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
if (importer && !isCssLikeImporter(importer)) {
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
return replacement;
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
transform: {
|
|
536
|
-
order: "pre",
|
|
537
|
-
handler(code, id) {
|
|
538
|
-
if (!isCSSRequest(id)) {
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
542
|
-
join: joinPosixPath,
|
|
543
|
-
appType
|
|
544
|
-
});
|
|
545
|
-
if (!rewritten) {
|
|
546
|
-
return null;
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
code: rewritten,
|
|
550
|
-
map: null
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
];
|
|
556
559
|
const getResolvedConfig = () => resolvedConfig;
|
|
557
560
|
const uniAppXPlugins = uniAppX ? createUniAppXPlugins({
|
|
558
561
|
appType,
|
|
@@ -53,6 +53,20 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
|
53
53
|
return matchWithExtensions(candidate, hasOutput);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// src/utils/disabled.ts
|
|
57
|
+
function resolveDisabledOptions(disabled) {
|
|
58
|
+
if (disabled === true) {
|
|
59
|
+
return { plugin: true, rewriteCssImports: false };
|
|
60
|
+
}
|
|
61
|
+
if (disabled === false || disabled == null) {
|
|
62
|
+
return { plugin: false, rewriteCssImports: false };
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
plugin: disabled.plugin ?? false,
|
|
66
|
+
rewriteCssImports: disabled.rewriteCssImports ?? false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
// src/utils/resolve-package.ts
|
|
57
71
|
import { createRequire } from "module";
|
|
58
72
|
import path2 from "path";
|
|
@@ -62,119 +76,8 @@ function resolvePackageDir(name) {
|
|
|
62
76
|
return path2.dirname(pkgPath);
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
// src/shared/mpx.ts
|
|
66
|
-
import path4 from "path";
|
|
67
|
-
|
|
68
|
-
// src/shared/tailwindcss-css-redirect.ts
|
|
69
|
-
import Module from "module";
|
|
70
|
-
import path3 from "path";
|
|
71
|
-
var moduleWithMutableResolve = Module;
|
|
72
|
-
var patched = /* @__PURE__ */ new WeakSet();
|
|
73
|
-
function installTailwindcssCssRedirect(pkgDir) {
|
|
74
|
-
const target = path3.join(pkgDir, "index.css");
|
|
75
|
-
const original = moduleWithMutableResolve._resolveFilename;
|
|
76
|
-
if (patched.has(original)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
|
|
80
|
-
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
81
|
-
if (replacements.has(request)) {
|
|
82
|
-
return target;
|
|
83
|
-
}
|
|
84
|
-
if (request.startsWith("tailwindcss/")) {
|
|
85
|
-
return path3.join(pkgDir, request.slice("tailwindcss/".length));
|
|
86
|
-
}
|
|
87
|
-
return original(request, parent, isMain, options);
|
|
88
|
-
};
|
|
89
|
-
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
90
|
-
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// src/shared/mpx.ts
|
|
94
|
-
var MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
|
|
95
|
-
function isMpxStyleResourceQuery(query) {
|
|
96
|
-
if (typeof query !== "string") {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
|
|
100
|
-
}
|
|
101
|
-
function isMpx(appType) {
|
|
102
|
-
return appType === "mpx";
|
|
103
|
-
}
|
|
104
|
-
function getTailwindcssCssEntry(pkgDir) {
|
|
105
|
-
return path4.join(pkgDir, "index.css");
|
|
106
|
-
}
|
|
107
|
-
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
108
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
109
|
-
compiler.options = compiler.options || {};
|
|
110
|
-
compiler.options.resolve = compiler.options.resolve || {};
|
|
111
|
-
const alias = compiler.options.resolve.alias ?? {};
|
|
112
|
-
if (Array.isArray(alias)) {
|
|
113
|
-
alias.push(
|
|
114
|
-
{ name: "tailwindcss", alias: tailwindcssCssEntry },
|
|
115
|
-
{ name: "tailwindcss$", alias: tailwindcssCssEntry }
|
|
116
|
-
);
|
|
117
|
-
} else {
|
|
118
|
-
compiler.options.resolve.alias = alias;
|
|
119
|
-
alias.tailwindcss = tailwindcssCssEntry;
|
|
120
|
-
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
121
|
-
}
|
|
122
|
-
return tailwindcssCssEntry;
|
|
123
|
-
}
|
|
124
|
-
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
125
|
-
if (!enabled || typeof loaderContext.resolve !== "function") {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const originalResolve = loaderContext.resolve;
|
|
129
|
-
if (originalResolve.__weappTwPatched) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
133
|
-
const wrappedResolve = function(context, request, callback) {
|
|
134
|
-
if (request === "tailwindcss" || request === "tailwindcss$") {
|
|
135
|
-
return callback(null, tailwindcssCssEntry);
|
|
136
|
-
}
|
|
137
|
-
if (request?.startsWith("tailwindcss/")) {
|
|
138
|
-
return callback(null, path4.join(pkgDir, request.slice("tailwindcss/".length)));
|
|
139
|
-
}
|
|
140
|
-
return originalResolve.call(this, context, request, callback);
|
|
141
|
-
};
|
|
142
|
-
wrappedResolve.__weappTwPatched = true;
|
|
143
|
-
loaderContext.resolve = wrappedResolve;
|
|
144
|
-
}
|
|
145
|
-
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
146
|
-
if (enabled) {
|
|
147
|
-
installTailwindcssCssRedirect(pkgDir);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
151
|
-
var _a;
|
|
152
|
-
if (!loader) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const moduleOptions = (_a = compiler.options).module ?? (_a.module = { rules: [] });
|
|
156
|
-
moduleOptions.rules = moduleOptions.rules || [];
|
|
157
|
-
const createRule = (match) => ({
|
|
158
|
-
...match,
|
|
159
|
-
enforce: "pre",
|
|
160
|
-
use: [
|
|
161
|
-
{
|
|
162
|
-
loader,
|
|
163
|
-
options: loaderOptions
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
});
|
|
167
|
-
moduleOptions.rules.unshift(
|
|
168
|
-
createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }),
|
|
169
|
-
createRule({
|
|
170
|
-
test: /\.css$/i,
|
|
171
|
-
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
79
|
// src/bundlers/shared/css-imports.ts
|
|
177
|
-
import
|
|
80
|
+
import path3 from "path";
|
|
178
81
|
var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
179
82
|
var tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
180
83
|
function normalizeTailwindcssSpecifier(specifier) {
|
|
@@ -194,10 +97,10 @@ function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
|
194
97
|
if (!tailwindcssImportRE.test(normalized)) {
|
|
195
98
|
return null;
|
|
196
99
|
}
|
|
197
|
-
if (
|
|
100
|
+
if (normalized === "tailwindcss") {
|
|
198
101
|
return "weapp-tailwindcss/index.css";
|
|
199
102
|
}
|
|
200
|
-
const join = options?.join ??
|
|
103
|
+
const join = options?.join ?? path3.join;
|
|
201
104
|
const subpath = getTailwindcssSubpath(normalized);
|
|
202
105
|
return join(pkgDir, subpath);
|
|
203
106
|
}
|
|
@@ -260,12 +163,8 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
|
260
163
|
export {
|
|
261
164
|
toAbsoluteOutputPath,
|
|
262
165
|
resolveOutputSpecifier,
|
|
166
|
+
resolveDisabledOptions,
|
|
263
167
|
resolvePackageDir,
|
|
264
|
-
isMpx,
|
|
265
|
-
ensureMpxTailwindcssAliases,
|
|
266
|
-
patchMpxLoaderResolve,
|
|
267
|
-
setupMpxTailwindcssRedirect,
|
|
268
|
-
injectMpxCssRewritePreRules,
|
|
269
168
|
resolveTailwindcssImport,
|
|
270
169
|
rewriteTailwindcssImportsInCode,
|
|
271
170
|
pushConcurrentTaskFactories
|
|
@@ -2,13 +2,8 @@ import {
|
|
|
2
2
|
defuOverrideArray
|
|
3
3
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
4
4
|
|
|
5
|
-
// src/
|
|
6
|
-
import {
|
|
7
|
-
import { createRequire as createRequire2 } from "module";
|
|
8
|
-
import path4 from "path";
|
|
9
|
-
import process2 from "process";
|
|
10
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11
|
-
import { logger as logger4 } from "@weapp-tailwindcss/logger";
|
|
5
|
+
// src/logger/index.ts
|
|
6
|
+
import { logger } from "@weapp-tailwindcss/logger";
|
|
12
7
|
|
|
13
8
|
// src/context/workspace.ts
|
|
14
9
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
@@ -95,7 +90,7 @@ function findWorkspacePackageDir(rootDir, packageName) {
|
|
|
95
90
|
}
|
|
96
91
|
|
|
97
92
|
// src/tailwindcss/v4/config.ts
|
|
98
|
-
import { logger } from "@weapp-tailwindcss/logger";
|
|
93
|
+
import { logger as logger2 } from "@weapp-tailwindcss/logger";
|
|
99
94
|
var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
100
95
|
function includesToken(list, token) {
|
|
101
96
|
return list.some((candidate) => {
|
|
@@ -189,7 +184,7 @@ function warnMissingCssEntries(ctx, patcher) {
|
|
|
189
184
|
return;
|
|
190
185
|
}
|
|
191
186
|
hasWarnedMissingCssEntries = true;
|
|
192
|
-
|
|
187
|
+
logger2.warn(
|
|
193
188
|
'[tailwindcss@4] \u672A\u68C0\u6D4B\u5230 cssEntries \u914D\u7F6E\u3002\u8BF7\u4F20\u5165\u5305\u542B tailwindcss \u5F15\u7528\u7684 CSS \u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 cssEntries: ["/absolute/path/to/src/app.css"]\uFF0C\u5426\u5219 tailwindcss \u751F\u6210\u7684\u7C7B\u540D\u4E0D\u4F1A\u53C2\u4E0E\u8F6C\u8BD1\u3002'
|
|
194
189
|
);
|
|
195
190
|
}
|
|
@@ -203,7 +198,7 @@ function applyV4CssCalcDefaults(cssCalc, patcher) {
|
|
|
203
198
|
|
|
204
199
|
// src/tailwindcss/v4/patcher.ts
|
|
205
200
|
import path3 from "path";
|
|
206
|
-
import { logger as
|
|
201
|
+
import { logger as logger4 } from "@weapp-tailwindcss/logger";
|
|
207
202
|
|
|
208
203
|
// src/tailwindcss/patcher.ts
|
|
209
204
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -211,7 +206,7 @@ import { createRequire } from "module";
|
|
|
211
206
|
import path2 from "path";
|
|
212
207
|
import process from "process";
|
|
213
208
|
import { fileURLToPath } from "url";
|
|
214
|
-
import { logger as
|
|
209
|
+
import { logger as logger3 } from "@weapp-tailwindcss/logger";
|
|
215
210
|
import { defuOverrideArray as defuOverrideArray2 } from "@weapp-tailwindcss/shared";
|
|
216
211
|
import { TailwindcssPatcher } from "tailwindcss-patch";
|
|
217
212
|
var GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
|
|
@@ -495,7 +490,7 @@ function createTailwindcssPatcher(options) {
|
|
|
495
490
|
...existingResolve,
|
|
496
491
|
paths: Array.from(new Set(sourcePaths))
|
|
497
492
|
};
|
|
498
|
-
|
|
493
|
+
logger3.debug("Tailwind resolve config %O", {
|
|
499
494
|
packageName: resolvedOptions.tailwind.packageName,
|
|
500
495
|
version: resolvedOptions.tailwind.version,
|
|
501
496
|
resolve: resolvedOptions.tailwind.resolve,
|
|
@@ -542,13 +537,13 @@ function createTailwindcssPatcher(options) {
|
|
|
542
537
|
const searchPaths = resolvedOptions.tailwind?.resolve?.paths;
|
|
543
538
|
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
544
539
|
if (!hasLoggedMissingTailwind) {
|
|
545
|
-
|
|
540
|
+
logger3.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
|
|
546
541
|
hasLoggedMissingTailwind = true;
|
|
547
542
|
}
|
|
548
543
|
return createFallbackTailwindcssPatcher();
|
|
549
544
|
}
|
|
550
545
|
if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
|
|
551
|
-
|
|
546
|
+
logger3.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', resolvedOptions.tailwind?.packageName, searchPaths);
|
|
552
547
|
}
|
|
553
548
|
throw error;
|
|
554
549
|
}
|
|
@@ -849,7 +844,7 @@ function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
|
849
844
|
if (groups.size <= 1) {
|
|
850
845
|
return void 0;
|
|
851
846
|
}
|
|
852
|
-
|
|
847
|
+
logger4.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
|
|
853
848
|
const patchers = [];
|
|
854
849
|
for (const [baseDir, entries] of groups) {
|
|
855
850
|
patchers.push(createPatcherForBase(baseDir, entries, options));
|
|
@@ -858,6 +853,12 @@ function tryCreateMultiTailwindcssPatcher(groups, options) {
|
|
|
858
853
|
}
|
|
859
854
|
|
|
860
855
|
// src/context/tailwindcss.ts
|
|
856
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
857
|
+
import { createRequire as createRequire2 } from "module";
|
|
858
|
+
import path4 from "path";
|
|
859
|
+
import process2 from "process";
|
|
860
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
861
|
+
import { logger as logger5 } from "@weapp-tailwindcss/logger";
|
|
861
862
|
var ENV_BASEDIR_KEYS = [
|
|
862
863
|
"WEAPP_TAILWINDCSS_BASEDIR",
|
|
863
864
|
"WEAPP_TAILWINDCSS_BASE_DIR",
|
|
@@ -900,7 +901,7 @@ function detectCallerBasedir() {
|
|
|
900
901
|
return void 0;
|
|
901
902
|
}
|
|
902
903
|
if (process2.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
903
|
-
|
|
904
|
+
logger5.debug("caller stack: %s", stack);
|
|
904
905
|
}
|
|
905
906
|
const lines = stack.split("\n");
|
|
906
907
|
for (const line of lines) {
|
|
@@ -945,7 +946,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
945
946
|
const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
|
|
946
947
|
const resolveRelative = (value) => path4.isAbsolute(value) ? path4.normalize(value) : path4.normalize(path4.resolve(anchor, value));
|
|
947
948
|
if (process2.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
948
|
-
|
|
949
|
+
logger5.debug("resolveTailwindcssBasedir anchor %O", {
|
|
949
950
|
basedir,
|
|
950
951
|
envBasedir,
|
|
951
952
|
envBasedirKey,
|
|
@@ -983,12 +984,12 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
983
984
|
const anchorRequire = createRequire2(path4.join(anchor, "__resolve_tailwindcss_basedir__.cjs"));
|
|
984
985
|
const packageJsonPath = anchorRequire.resolve(`${packageName}/package.json`);
|
|
985
986
|
if (process2.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
986
|
-
|
|
987
|
+
logger5.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
|
|
987
988
|
}
|
|
988
989
|
return path4.normalize(path4.dirname(packageJsonPath));
|
|
989
990
|
} catch {
|
|
990
991
|
if (process2.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
991
|
-
|
|
992
|
+
logger5.debug("failed to resolve package json for %s", packageName);
|
|
992
993
|
}
|
|
993
994
|
const workspaceRoot = findWorkspaceRoot(anchor);
|
|
994
995
|
if (workspaceRoot) {
|
|
@@ -1076,7 +1077,7 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
1076
1077
|
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
1077
1078
|
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
1078
1079
|
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
1079
|
-
|
|
1080
|
+
logger5.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
|
|
1080
1081
|
let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
|
|
1081
1082
|
if (!normalizedCssEntries) {
|
|
1082
1083
|
normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
|
|
@@ -1114,9 +1115,6 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
1114
1115
|
);
|
|
1115
1116
|
}
|
|
1116
1117
|
|
|
1117
|
-
// src/logger/index.ts
|
|
1118
|
-
import { logger as logger5 } from "@weapp-tailwindcss/logger";
|
|
1119
|
-
|
|
1120
1118
|
export {
|
|
1121
1119
|
findWorkspaceRoot,
|
|
1122
1120
|
findNearestPackageRoot,
|
|
@@ -1124,5 +1122,5 @@ export {
|
|
|
1124
1122
|
applyV4CssCalcDefaults,
|
|
1125
1123
|
resolveTailwindcssBasedir,
|
|
1126
1124
|
createTailwindcssPatcherFromContext,
|
|
1127
|
-
|
|
1125
|
+
logger
|
|
1128
1126
|
};
|