weapp-tailwindcss 4.10.3 → 4.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3XVUGMTY.mjs → chunk-2LH6PZH3.mjs} +8 -4
- package/dist/{chunk-3WUHHFLF.mjs → chunk-35EI5JMK.mjs} +4 -2
- package/dist/{chunk-RYC23C3K.js → chunk-4LPOQMFS.js} +203 -198
- package/dist/{chunk-5U24PLVV.js → chunk-ACTJYB33.js} +4 -2
- package/dist/chunk-CZLXTEHN.js +1936 -0
- package/dist/{chunk-TNYEOBAC.mjs → chunk-DOH7FULQ.mjs} +1 -1
- package/dist/{chunk-E7775SFS.mjs → chunk-FZNYV7VH.mjs} +914 -334
- package/dist/{chunk-6Z4GEN2Y.js → chunk-G3G437UE.js} +2 -2
- package/dist/{chunk-DEIJXHGJ.js → chunk-G5NLM3AL.js} +978 -398
- package/dist/{chunk-W2N6G2QQ.js → chunk-GWDHNCL2.js} +60 -46
- package/dist/{chunk-QOTLDKI4.mjs → chunk-IEZ5RBMG.mjs} +197 -192
- package/dist/{chunk-RM3SY4S4.mjs → chunk-JBM3HGHP.mjs} +52 -12
- package/dist/{chunk-WXT2GI5R.mjs → chunk-KKT2DKMW.mjs} +30 -16
- package/dist/chunk-LD7LZ4IK.mjs +1933 -0
- package/dist/{chunk-GCRL3ZYP.js → chunk-NOKJXG3W.js} +5 -5
- package/dist/{chunk-YUTKX7JZ.js → chunk-OV7FX6XR.js} +1 -1
- package/dist/{chunk-SR4GC2F4.js → chunk-OYSABARD.js} +8 -4
- package/dist/{chunk-LICQ6EGN.mjs → chunk-QYZCRG7F.mjs} +2 -2
- package/dist/{chunk-UYTCZXNE.mjs → chunk-R6KEYO3F.mjs} +6 -5
- package/dist/{chunk-WF636Q5E.js → chunk-SQG2MOFQ.js} +10 -9
- package/dist/{chunk-L7OBNTRI.js → chunk-W2EMGF7H.js} +57 -17
- package/dist/cli.js +45 -42
- package/dist/cli.mjs +9 -6
- package/dist/core.d.mts +4 -3
- package/dist/core.d.ts +4 -3
- package/dist/core.js +124 -30
- package/dist/core.mjs +119 -25
- package/dist/css-macro/postcss.js +6 -5
- package/dist/css-macro/postcss.mjs +4 -3
- package/dist/css-macro.js +5 -5
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/escape.js +2 -1
- package/dist/escape.mjs +2 -1
- package/dist/gulp.d.mts +1 -1
- package/dist/gulp.d.ts +1 -1
- package/dist/gulp.js +8 -7
- package/dist/gulp.mjs +8 -7
- package/dist/index.js +11 -11
- 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.js +5 -5
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +9 -8
- package/dist/vite.mjs +8 -7
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +10 -9
- package/dist/webpack.mjs +8 -7
- package/dist/webpack4.d.mts +1 -1
- package/dist/webpack4.d.ts +1 -1
- package/dist/webpack4.js +64 -49
- package/dist/webpack4.mjs +33 -18
- package/package.json +7 -7
- package/dist/chunk-PALDKVKG.mjs +0 -1291
- package/dist/chunk-YJSFFRNZ.js +0 -1291
|
@@ -10,27 +10,27 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkSQG2MOFQjs = require('./chunk-SQG2MOFQ.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkG3G437UEjs = require('./chunk-G3G437UE.js');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunkNOKJXG3Wjs = require('./chunk-NOKJXG3W.js');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkG5NLM3ALjs = require('./chunk-G5NLM3AL.js');
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
@@ -57,10 +57,11 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
57
57
|
} = options;
|
|
58
58
|
const { Compilation, sources } = compiler.webpack;
|
|
59
59
|
const { ConcatSource } = sources;
|
|
60
|
-
|
|
60
|
+
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
61
|
+
compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, (compilation) => {
|
|
61
62
|
compilation.hooks.processAssets.tapPromise(
|
|
62
63
|
{
|
|
63
|
-
name:
|
|
64
|
+
name: _chunkG5NLM3ALjs.pluginName,
|
|
64
65
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
65
66
|
},
|
|
66
67
|
async (assets) => {
|
|
@@ -72,20 +73,20 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
72
73
|
compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
const assetHashByChunk =
|
|
76
|
+
const assetHashByChunk = _chunkSQG2MOFQjs.createAssetHashByChunkMap.call(void 0, compilation.chunks);
|
|
76
77
|
const entries = Object.entries(assets);
|
|
77
78
|
const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _ => _.compiler, 'optionalAccess', _2 => _2.outputPath]), () => ( compiler.outputPath));
|
|
78
79
|
const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _3 => _3.outputOptions, 'optionalAccess', _4 => _4.path]), () => ( _process2.default.cwd()));
|
|
79
80
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
80
81
|
for (const [file] of entries) {
|
|
81
82
|
if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
|
|
82
|
-
const absolute =
|
|
83
|
+
const absolute = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
83
84
|
jsAssets.set(absolute, file);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
const moduleGraphOptions = {
|
|
87
88
|
resolve(specifier, importer) {
|
|
88
|
-
return
|
|
89
|
+
return _chunkG3G437UEjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
89
90
|
},
|
|
90
91
|
load: (id) => {
|
|
91
92
|
const assetName = jsAssets.get(id);
|
|
@@ -128,13 +129,36 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
const groupedEntries = _chunkDYLQ6UOIjs.getGroupedEntries.call(void 0, entries, compilerOptions);
|
|
132
|
+
const getCssHandlerOptions = (file) => {
|
|
133
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
134
|
+
const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
|
|
135
|
+
const cacheKey = `${_nullishCoalesce(majorVersion, () => ( "unknown"))}:${isMainChunk ? "1" : "0"}:${file}`;
|
|
136
|
+
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
137
|
+
if (cached) {
|
|
138
|
+
return cached;
|
|
139
|
+
}
|
|
140
|
+
const created = {
|
|
141
|
+
isMainChunk,
|
|
142
|
+
postcssOptions: {
|
|
143
|
+
options: {
|
|
144
|
+
from: file
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
majorVersion
|
|
148
|
+
};
|
|
149
|
+
cssHandlerOptionsCache.set(cacheKey, created);
|
|
150
|
+
return created;
|
|
151
|
+
};
|
|
131
152
|
const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
|
|
132
|
-
const runtimeSet = await
|
|
153
|
+
const runtimeSet = await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
133
154
|
// webpack 的 script-only 热更新可能不会触发 runtime classset loader,
|
|
134
155
|
// 这里强制收集可避免沿用上轮 class set,保证 JS 仅按最新集合精确命中。
|
|
135
156
|
forceCollect: true,
|
|
136
157
|
allowEmpty: false
|
|
137
158
|
});
|
|
159
|
+
const defaultTemplateHandlerOptions = {
|
|
160
|
+
runtimeSet
|
|
161
|
+
};
|
|
138
162
|
debug2("get runtimeSet, class count: %d", runtimeSet.size);
|
|
139
163
|
const tasks = [];
|
|
140
164
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -157,9 +181,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
157
181
|
debug2("html cache hit: %s", file);
|
|
158
182
|
},
|
|
159
183
|
transform: async () => {
|
|
160
|
-
const wxml = await compilerOptions.templateHandler(rawSource,
|
|
161
|
-
runtimeSet
|
|
162
|
-
});
|
|
184
|
+
const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
163
185
|
const source = new ConcatSource(wxml);
|
|
164
186
|
compilerOptions.onUpdate(file, rawSource, wxml);
|
|
165
187
|
debug2("html handle: %s", file);
|
|
@@ -174,12 +196,12 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
174
196
|
const jsTaskFactories = [];
|
|
175
197
|
if (Array.isArray(groupedEntries.js)) {
|
|
176
198
|
for (const [file] of groupedEntries.js) {
|
|
177
|
-
const cacheKey =
|
|
199
|
+
const cacheKey = _chunkSQG2MOFQjs.getCacheKey.call(void 0, file);
|
|
178
200
|
const asset = compilation.getAsset(file);
|
|
179
201
|
if (!asset) {
|
|
180
202
|
continue;
|
|
181
203
|
}
|
|
182
|
-
const absoluteFile =
|
|
204
|
+
const absoluteFile = _chunkG3G437UEjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
183
205
|
const initialSource = asset.source.source();
|
|
184
206
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
185
207
|
const chunkHash = assetHashByChunk.get(file);
|
|
@@ -242,15 +264,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
242
264
|
},
|
|
243
265
|
transform: async () => {
|
|
244
266
|
await runtimeState.patchPromise;
|
|
245
|
-
const { css } = await compilerOptions.styleHandler(rawSource,
|
|
246
|
-
isMainChunk: compilerOptions.mainCssChunkMatcher(file, appType),
|
|
247
|
-
postcssOptions: {
|
|
248
|
-
options: {
|
|
249
|
-
from: file
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
majorVersion: runtimeState.twPatcher.majorVersion
|
|
253
|
-
});
|
|
267
|
+
const { css } = await compilerOptions.styleHandler(rawSource, getCssHandlerOptions(file));
|
|
254
268
|
const source = new ConcatSource(css);
|
|
255
269
|
compilerOptions.onUpdate(file, rawSource, css);
|
|
256
270
|
debug2("css handle: %s", file);
|
|
@@ -262,7 +276,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
262
276
|
);
|
|
263
277
|
}
|
|
264
278
|
}
|
|
265
|
-
|
|
279
|
+
_chunkG3G437UEjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
266
280
|
await Promise.all(tasks);
|
|
267
281
|
debug2("end");
|
|
268
282
|
compilerOptions.onEnd();
|
|
@@ -287,9 +301,9 @@ function setupWebpackV5Loaders(options) {
|
|
|
287
301
|
getClassSetInLoader,
|
|
288
302
|
debug: debug2
|
|
289
303
|
} = options;
|
|
290
|
-
const isMpxApp =
|
|
304
|
+
const isMpxApp = _chunkSQG2MOFQjs.isMpx.call(void 0, appType);
|
|
291
305
|
if (shouldRewriteCssImports && isMpxApp) {
|
|
292
|
-
|
|
306
|
+
_chunkSQG2MOFQjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir2);
|
|
293
307
|
}
|
|
294
308
|
const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
|
|
295
309
|
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
|
|
@@ -302,12 +316,12 @@ function setupWebpackV5Loaders(options) {
|
|
|
302
316
|
const classSetLoaderOptions = {
|
|
303
317
|
getClassSet: getClassSetInLoader
|
|
304
318
|
};
|
|
305
|
-
const { findRewriteAnchor, findClassSetAnchor } =
|
|
319
|
+
const { findRewriteAnchor, findClassSetAnchor } = _chunkSQG2MOFQjs.createLoaderAnchorFinders.call(void 0, appType);
|
|
306
320
|
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
307
321
|
rewriteCssImports: runtimeLoaderRewriteOptions
|
|
308
322
|
} : void 0;
|
|
309
323
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
|
|
310
|
-
|
|
324
|
+
_chunkSQG2MOFQjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
311
325
|
}
|
|
312
326
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
313
327
|
loader: runtimeClassSetLoader,
|
|
@@ -327,17 +341,17 @@ function setupWebpackV5Loaders(options) {
|
|
|
327
341
|
};
|
|
328
342
|
};
|
|
329
343
|
const { NormalModule } = compiler.webpack;
|
|
330
|
-
compiler.hooks.compilation.tap(
|
|
331
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
344
|
+
compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, (compilation) => {
|
|
345
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkG5NLM3ALjs.pluginName, (_loaderContext, module) => {
|
|
332
346
|
const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
|
|
333
347
|
if (!hasRuntimeLoader) {
|
|
334
348
|
return;
|
|
335
349
|
}
|
|
336
|
-
|
|
350
|
+
_chunkSQG2MOFQjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir2, shouldRewriteCssImports && isMpxApp);
|
|
337
351
|
const loaderEntries = module.loaders || [];
|
|
338
352
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
339
353
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
340
|
-
const isCssModule =
|
|
354
|
+
const isCssModule = _chunkSQG2MOFQjs.isCssLikeModuleResource.call(void 0, module.resource, compilerOptions.cssMatcher, appType);
|
|
341
355
|
if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
|
|
342
356
|
debug2("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
|
|
343
357
|
}
|
|
@@ -369,7 +383,7 @@ function setupWebpackV5Loaders(options) {
|
|
|
369
383
|
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
370
384
|
}
|
|
371
385
|
}
|
|
372
|
-
if (runtimeClassSetLoaderExists && !
|
|
386
|
+
if (runtimeClassSetLoaderExists && !_chunkSQG2MOFQjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
|
|
373
387
|
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
374
388
|
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
375
389
|
if (anchorIndex === -1) {
|
|
@@ -384,11 +398,11 @@ function setupWebpackV5Loaders(options) {
|
|
|
384
398
|
}
|
|
385
399
|
|
|
386
400
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
387
|
-
var debug =
|
|
388
|
-
var weappTailwindcssPackageDir =
|
|
401
|
+
var debug = _chunkG5NLM3ALjs.createDebug.call(void 0, );
|
|
402
|
+
var weappTailwindcssPackageDir = _chunkG3G437UEjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
389
403
|
var UnifiedWebpackPluginV5 = class {
|
|
390
404
|
constructor(options = {}) {
|
|
391
|
-
this.options =
|
|
405
|
+
this.options = _chunkG5NLM3ALjs.getCompilerContext.call(void 0, options);
|
|
392
406
|
this.appType = this.options.appType;
|
|
393
407
|
}
|
|
394
408
|
apply(compiler) {
|
|
@@ -401,22 +415,22 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
401
415
|
twPatcher: initialTwPatcher,
|
|
402
416
|
refreshTailwindcssPatcher
|
|
403
417
|
} = this.options;
|
|
404
|
-
const disabledOptions =
|
|
418
|
+
const disabledOptions = _chunkG3G437UEjs.resolveDisabledOptions.call(void 0, disabled);
|
|
405
419
|
const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
|
|
406
420
|
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
407
|
-
const isMpxApp =
|
|
421
|
+
const isMpxApp = _chunkSQG2MOFQjs.isMpx.call(void 0, this.appType);
|
|
408
422
|
if (shouldRewriteCssImports) {
|
|
409
|
-
|
|
423
|
+
_chunkSQG2MOFQjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
|
|
410
424
|
pkgDir: weappTailwindcssPackageDir,
|
|
411
425
|
enabled: true,
|
|
412
426
|
appType: this.appType
|
|
413
427
|
});
|
|
414
|
-
|
|
428
|
+
_chunkSQG2MOFQjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
|
|
415
429
|
}
|
|
416
430
|
if (disabledOptions.plugin) {
|
|
417
431
|
return;
|
|
418
432
|
}
|
|
419
|
-
const patchRecorderState =
|
|
433
|
+
const patchRecorderState = _chunkNOKJXG3Wjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
420
434
|
source: "runtime",
|
|
421
435
|
cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
422
436
|
});
|
|
@@ -432,18 +446,18 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
432
446
|
runtimeSetPrepared = false;
|
|
433
447
|
};
|
|
434
448
|
if (_optionalChain([compiler, 'access', _13 => _13.hooks, 'access', _14 => _14.thisCompilation, 'optionalAccess', _15 => _15.tap])) {
|
|
435
|
-
compiler.hooks.thisCompilation.tap(
|
|
449
|
+
compiler.hooks.thisCompilation.tap(_chunkG5NLM3ALjs.pluginName, resetRuntimePreparation);
|
|
436
450
|
} else if (_optionalChain([compiler, 'access', _16 => _16.hooks, 'access', _17 => _17.compilation, 'optionalAccess', _18 => _18.tap])) {
|
|
437
|
-
compiler.hooks.compilation.tap(
|
|
451
|
+
compiler.hooks.compilation.tap(_chunkG5NLM3ALjs.pluginName, resetRuntimePreparation);
|
|
438
452
|
}
|
|
439
453
|
async function getClassSetInLoader() {
|
|
440
454
|
if (runtimeSetPrepared) {
|
|
441
455
|
return;
|
|
442
456
|
}
|
|
443
|
-
const signature =
|
|
457
|
+
const signature = _chunkG5NLM3ALjs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
|
|
444
458
|
const forceRefresh = signature !== runtimeSetSignature;
|
|
445
459
|
runtimeSetPrepared = true;
|
|
446
|
-
await
|
|
460
|
+
await _chunkG5NLM3ALjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
447
461
|
forceRefresh,
|
|
448
462
|
forceCollect: true,
|
|
449
463
|
clearCache: forceRefresh,
|