weapp-tailwindcss 5.2.14 → 5.3.0
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 +55 -8
- package/README.zh-CN.md +64 -0
- package/dist/bundlers/rspack/rule-match.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +7 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-plugin-order.d.ts +2 -0
- package/dist/{transform-BiHG42Rp.cjs → component-local-style-BirkN5f8.cjs} +33 -168
- package/dist/{transform-52FLRu-0.js → component-local-style-CFL4ClhS.js} +22 -174
- package/dist/generator/index.d.ts +2 -2
- package/dist/generator.cjs +7 -0
- package/dist/generator.js +2 -2
- package/dist/{gulp-DzIR7eO3.cjs → gulp-B0qcNiuP.cjs} +2 -2
- package/dist/{gulp-DG6cWPF4.js → gulp-D1vDx4H1.js} +1 -1
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CoyM6Dg2.js → hmr-timing-Dq1_msos.js} +5 -7
- package/dist/{hmr-timing-BIPr9t9m.cjs → hmr-timing-pF6k35pP.cjs} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/{pipeline-helpers-Bp343-ik.cjs → pipeline-helpers-DA5-EzbO.cjs} +1 -1
- package/dist/rspack.cjs +124 -7
- package/dist/rspack.js +124 -7
- package/dist/{source-candidate-scan-signature-J9EW91KX.cjs → source-candidate-scan-signature-DGQufJk3.cjs} +1 -1
- package/dist/{source-candidate-scan-signature-BLXoEZN5.js → source-candidate-scan-signature-DSsjYtlq.js} +1 -1
- package/dist/tailwindcss/candidates.d.ts +2 -2
- package/dist/transform-BYhgJszj.cjs +200 -0
- package/dist/transform-Ck31voUU.js +201 -0
- package/dist/uni-app-x/component-local-style.d.ts +3 -1
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +1 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +6 -0
- package/dist/{v4-generation-core-CCnEsAgV.cjs → v4-generation-core-BEYGV4eB.cjs} +5 -7
- package/dist/{vite-DNTQV3gN.js → vite-DBgbFsei.js} +184 -64
- package/dist/{vite-RJpkDte7.cjs → vite-jftHIupF.cjs} +184 -64
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +2 -2
- package/dist/{webpack-DYoIysDo.js → webpack-BSIWFzAA.js} +3 -3
- package/dist/{webpack-BY5y7f0X.cjs → webpack-DhwW2cva.cjs} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +9 -14
- package/README.en.md +0 -17
- package/bin/weapp-tailwindcss.cjs +0 -8
- package/dist/cli/context.d.ts +0 -3
- package/dist/cli/doctor/constants.d.ts +0 -7
- package/dist/cli/doctor/types.d.ts +0 -31
- package/dist/cli/doctor.d.ts +0 -4
- package/dist/cli/helpers/options/format.d.ts +0 -2
- package/dist/cli/helpers/options/parse.d.ts +0 -3
- package/dist/cli/helpers/options/resolve.d.ts +0 -1
- package/dist/cli/helpers/options.d.ts +0 -3
- package/dist/cli/helpers.d.ts +0 -4
- package/dist/cli/mount-options.d.ts +0 -4
- package/dist/cli/types.d.ts +0 -15
- package/dist/cli/vscode-entry.d.ts +0 -14
- package/dist/cli.cjs +0 -37065
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2298
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { n as _defineProperty } from "./object-B-8IHefx.js";
|
|
2
|
-
import { g as traverse
|
|
2
|
+
import { g as traverse, h as babelParse, i as analyzeSource, o as JsTokenUpdater, p as replaceWxml, u as isClassContextLiteralPath } from "./wxml-B7OAVpXJ.js";
|
|
3
3
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
4
4
|
import MagicString from "magic-string";
|
|
5
|
-
import { NodeTypes, parse } from "@vue/compiler-dom";
|
|
6
5
|
//#region src/uni-app-x/component-local-style-binding.ts
|
|
7
6
|
const OPTIONS_CLASS_SECTIONS = /* @__PURE__ */ new Set(["computed", "methods"]);
|
|
8
7
|
function readStaticName(path) {
|
|
@@ -59,14 +58,14 @@ function isClassAssignmentTarget(path, names) {
|
|
|
59
58
|
return object.isThisExpression() && isClassBindingName(property, names);
|
|
60
59
|
}
|
|
61
60
|
function collectClassBindingNames(ast, names) {
|
|
62
|
-
traverse
|
|
61
|
+
traverse(ast, { ReferencedIdentifier(path) {
|
|
63
62
|
names.add(path.node.name);
|
|
64
63
|
} });
|
|
65
64
|
}
|
|
66
65
|
function collectClassBindingRoots(ast, names) {
|
|
67
66
|
const roots = /* @__PURE__ */ new WeakSet();
|
|
68
67
|
if (names.size === 0) return roots;
|
|
69
|
-
traverse
|
|
68
|
+
traverse(ast, {
|
|
70
69
|
Program(path) {
|
|
71
70
|
for (const name of names) {
|
|
72
71
|
const binding = path.scope.getBinding(name);
|
|
@@ -121,6 +120,10 @@ function extractLiteralValue(path) {
|
|
|
121
120
|
function createAlias(fileId, utility, index) {
|
|
122
121
|
return `wtu-${createStableHash(`${fileId}:${utility}`)}-${index.toString(36)}`;
|
|
123
122
|
}
|
|
123
|
+
function serializeApplyUtility(utility) {
|
|
124
|
+
if (!utility.endsWith("!") || utility.endsWith("\\!")) return utility;
|
|
125
|
+
return `${utility.slice(0, -1)}#{'!'}`;
|
|
126
|
+
}
|
|
124
127
|
function isRuntimeCandidate(candidate, runtimeSet) {
|
|
125
128
|
if (!runtimeSet || runtimeSet.size === 0) return false;
|
|
126
129
|
return runtimeSet.has(candidate) || runtimeSet.has(replaceWxml(candidate));
|
|
@@ -180,6 +183,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
180
183
|
_defineProperty(this, "aliasByUtility", /* @__PURE__ */ new Map());
|
|
181
184
|
_defineProperty(this, "aliasByLookup", /* @__PURE__ */ new Map());
|
|
182
185
|
_defineProperty(this, "classBindingNames", /* @__PURE__ */ new Set());
|
|
186
|
+
_defineProperty(this, "deepUtilities", /* @__PURE__ */ new Set());
|
|
183
187
|
}
|
|
184
188
|
ensureAlias(utility) {
|
|
185
189
|
const cached = this.aliasByUtility.get(utility);
|
|
@@ -200,8 +204,12 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
200
204
|
}
|
|
201
205
|
return rewritten;
|
|
202
206
|
}
|
|
203
|
-
collectAndRewriteStaticClass(literal) {
|
|
204
|
-
|
|
207
|
+
collectAndRewriteStaticClass(literal, options = {}) {
|
|
208
|
+
const rewritten = this.rewriteLiteral(literal);
|
|
209
|
+
if (options.deep) {
|
|
210
|
+
for (const candidate of splitCandidateTokens(literal)) if (this.aliasByUtility.has(candidate)) this.deepUtilities.add(candidate);
|
|
211
|
+
}
|
|
212
|
+
return rewritten;
|
|
205
213
|
}
|
|
206
214
|
collectRuntimeClasses(rawSource, options = {}) {
|
|
207
215
|
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
@@ -219,7 +227,10 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
219
227
|
const classContext = options.wrapExpression || isClassContextLiteralPath(path) || isClassBindingLiteralPath(path, classBindingRoots);
|
|
220
228
|
for (const candidate of candidates) {
|
|
221
229
|
if (!candidate || !classContext || !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
222
|
-
if (!hasTopLevelVariant(candidate))
|
|
230
|
+
if (!hasTopLevelVariant(candidate)) {
|
|
231
|
+
this.ensureAlias(candidate);
|
|
232
|
+
if (options.deep) this.deepUtilities.add(candidate);
|
|
233
|
+
}
|
|
223
234
|
}
|
|
224
235
|
}
|
|
225
236
|
} catch {}
|
|
@@ -283,176 +294,13 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
283
294
|
if (!this.hasStyles()) return "";
|
|
284
295
|
const lines = [];
|
|
285
296
|
for (const [utility, alias] of this.aliasByUtility) {
|
|
286
|
-
|
|
287
|
-
lines.push(
|
|
297
|
+
const selector = this.deepUtilities.has(utility) ? `.${alias}, :deep(.${alias})` : `.${alias}`;
|
|
298
|
+
lines.push(`${selector} {`);
|
|
299
|
+
lines.push(` @apply ${serializeApplyUtility(utility)};`);
|
|
288
300
|
lines.push("}");
|
|
289
301
|
}
|
|
290
302
|
return `${lines.join("\n")}\n`;
|
|
291
303
|
}
|
|
292
304
|
};
|
|
293
305
|
//#endregion
|
|
294
|
-
|
|
295
|
-
function traverse(node, visitor) {
|
|
296
|
-
visitor(node);
|
|
297
|
-
if (Array.isArray(node.children)) {
|
|
298
|
-
for (const child of node.children) if (child && typeof child === "object" && "type" in child) traverse(child, visitor);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function updateStaticAttribute(ms, prop, offset, content = prop.value?.content) {
|
|
302
|
-
if (!prop.value) return;
|
|
303
|
-
const start = offset + prop.value.loc.start.offset + 1;
|
|
304
|
-
const end = offset + prop.value.loc.end.offset - 1;
|
|
305
|
-
if (start < end) ms.update(start, end, replaceWxml(content ?? ""));
|
|
306
|
-
}
|
|
307
|
-
function updateStaticAttributeWithLocalStyle(ms, prop, offset, collector, content = prop.value?.content) {
|
|
308
|
-
if (!prop.value) return;
|
|
309
|
-
const start = offset + prop.value.loc.start.offset + 1;
|
|
310
|
-
const end = offset + prop.value.loc.end.offset - 1;
|
|
311
|
-
if (start < end) ms.update(start, end, collector.collectAndRewriteStaticClass(content ?? ""));
|
|
312
|
-
}
|
|
313
|
-
function updateDirectiveExpression(ms, prop, offset, jsHandler, runtimeSet) {
|
|
314
|
-
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION) return;
|
|
315
|
-
const expression = prop.exp.content;
|
|
316
|
-
const start = offset + prop.exp.loc.start.offset;
|
|
317
|
-
const end = offset + prop.exp.loc.end.offset;
|
|
318
|
-
if (start >= end) return;
|
|
319
|
-
const generated = generateCode(expression, {
|
|
320
|
-
jsHandler,
|
|
321
|
-
runtimeSet,
|
|
322
|
-
wrapExpression: true
|
|
323
|
-
});
|
|
324
|
-
ms.update(start, end, generated);
|
|
325
|
-
}
|
|
326
|
-
function updateDirectiveExpressionWithLocalStyle(ms, prop, offset, jsHandler, collector, runtimeSet) {
|
|
327
|
-
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION) return;
|
|
328
|
-
const expression = prop.exp.content;
|
|
329
|
-
const start = offset + prop.exp.loc.start.offset;
|
|
330
|
-
const end = offset + prop.exp.loc.end.offset;
|
|
331
|
-
if (start >= end) return;
|
|
332
|
-
collector.collectRuntimeClasses(expression, { wrapExpression: true });
|
|
333
|
-
const generated = generateCode(expression, {
|
|
334
|
-
jsHandler,
|
|
335
|
-
runtimeSet,
|
|
336
|
-
wrapExpression: true
|
|
337
|
-
});
|
|
338
|
-
ms.update(start, end, collector.rewriteTransformedCode(generated, { wrapExpression: true }));
|
|
339
|
-
}
|
|
340
|
-
function shouldEnableLocalStyle(id, options) {
|
|
341
|
-
if (options.enableComponentLocalStyle && shouldEnableComponentLocalStyle(id)) return true;
|
|
342
|
-
if (options.enablePageLocalStyle && shouldEnablePageLocalStyle(id)) return true;
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute) {
|
|
346
|
-
const lowerName = attrName.toLowerCase();
|
|
347
|
-
const shouldHandleDefault = !disabledDefaultTemplateHandler && lowerName === "class";
|
|
348
|
-
const shouldHandleCustom = matchCustomAttribute?.(tag, attrName) ?? false;
|
|
349
|
-
return {
|
|
350
|
-
shouldHandleDefault,
|
|
351
|
-
shouldHandleCustom,
|
|
352
|
-
shouldHandle: shouldHandleDefault || shouldHandleCustom
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
const defaultCreateJsHandlerOptions = { babelParserOptions: { plugins: ["typescript"] } };
|
|
356
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
357
|
-
const SFC_BLOCK_RE = /<(template|script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
|
|
358
|
-
const SCRIPT_SETUP_RE = /(?:^|\s)setup(?:\s|=|$)/;
|
|
359
|
-
const STYLE_SCOPED_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
360
|
-
function parseSfc(code) {
|
|
361
|
-
const descriptor = {
|
|
362
|
-
errors: [],
|
|
363
|
-
styles: []
|
|
364
|
-
};
|
|
365
|
-
for (const match of code.matchAll(SFC_BLOCK_RE)) {
|
|
366
|
-
const type = match[1];
|
|
367
|
-
const attrs = match[2] ?? "";
|
|
368
|
-
const content = match[3] ?? "";
|
|
369
|
-
const full = match[0];
|
|
370
|
-
const contentStart = (match.index ?? 0) + full.indexOf(">") + 1;
|
|
371
|
-
const block = {
|
|
372
|
-
content,
|
|
373
|
-
start: contentStart,
|
|
374
|
-
end: contentStart + content.length,
|
|
375
|
-
attrs
|
|
376
|
-
};
|
|
377
|
-
if (type === "template" && !descriptor.template) {
|
|
378
|
-
try {
|
|
379
|
-
descriptor.template = {
|
|
380
|
-
...block,
|
|
381
|
-
ast: parse(content)
|
|
382
|
-
};
|
|
383
|
-
} catch (error) {
|
|
384
|
-
descriptor.errors.push(error);
|
|
385
|
-
descriptor.template = block;
|
|
386
|
-
}
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
|
-
if (type === "script") {
|
|
390
|
-
if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
|
|
391
|
-
else descriptor.script ?? (descriptor.script = block);
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
if (type === "style") descriptor.styles.push(block);
|
|
395
|
-
}
|
|
396
|
-
return descriptor;
|
|
397
|
-
}
|
|
398
|
-
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
399
|
-
if (!UVUE_NVUE_RE.test(id)) return;
|
|
400
|
-
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
401
|
-
const matchCustomAttribute = createAttributeMatcher(customAttributesEntities);
|
|
402
|
-
const ms = new MagicString(code);
|
|
403
|
-
const descriptor = parseSfc(code);
|
|
404
|
-
const localStyleCollector = shouldEnableLocalStyle(id, options) ? new UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
|
|
405
|
-
if (descriptor.errors.length === 0) {
|
|
406
|
-
if (descriptor.template?.ast) {
|
|
407
|
-
const templateOffset = descriptor.template.start;
|
|
408
|
-
traverse(descriptor.template.ast, (node) => {
|
|
409
|
-
if (node.type !== NodeTypes.ELEMENT) return;
|
|
410
|
-
const tag = node.tag;
|
|
411
|
-
for (const prop of node.props) if (prop.type === NodeTypes.ATTRIBUTE) {
|
|
412
|
-
const { shouldHandle, shouldHandleDefault } = shouldHandleAttribute(tag, prop.name, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
413
|
-
if (!shouldHandle) continue;
|
|
414
|
-
if (shouldHandleDefault && localStyleCollector) updateStaticAttributeWithLocalStyle(ms, prop, templateOffset, localStyleCollector);
|
|
415
|
-
else updateStaticAttribute(ms, prop, templateOffset);
|
|
416
|
-
if (shouldHandleDefault) continue;
|
|
417
|
-
} else if (prop.type === NodeTypes.DIRECTIVE && prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic) {
|
|
418
|
-
const attrName = prop.arg.content;
|
|
419
|
-
const { shouldHandle } = shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
420
|
-
if (!shouldHandle) continue;
|
|
421
|
-
if (attrName.toLowerCase() === "class" && localStyleCollector) updateDirectiveExpressionWithLocalStyle(ms, prop, templateOffset, jsHandler, localStyleCollector, runtimeSet);
|
|
422
|
-
else updateDirectiveExpression(ms, prop, templateOffset, jsHandler, runtimeSet);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
if (descriptor.script) {
|
|
427
|
-
localStyleCollector?.collectRuntimeClasses(descriptor.script.content);
|
|
428
|
-
const { code } = jsHandler(descriptor.script.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
429
|
-
ms.update(descriptor.script.start, descriptor.script.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
430
|
-
}
|
|
431
|
-
if (descriptor.scriptSetup) {
|
|
432
|
-
localStyleCollector?.collectRuntimeClasses(descriptor.scriptSetup.content);
|
|
433
|
-
const { code } = jsHandler(descriptor.scriptSetup.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
434
|
-
ms.update(descriptor.scriptSetup.start, descriptor.scriptSetup.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
435
|
-
}
|
|
436
|
-
if (localStyleCollector?.hasStyles()) {
|
|
437
|
-
const scopedStyle = descriptor.styles.findLast((style) => STYLE_SCOPED_RE.test(style.attrs));
|
|
438
|
-
if (scopedStyle) {
|
|
439
|
-
const separator = scopedStyle.content.endsWith("\n") ? "" : "\n";
|
|
440
|
-
ms.appendLeft(scopedStyle.end, `${separator}${localStyleCollector.toStyleRules()}`);
|
|
441
|
-
} else ms.append(`\n${localStyleCollector.toStyleBlock()}`);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
const result = {
|
|
445
|
-
code: ms.toString(),
|
|
446
|
-
map: null
|
|
447
|
-
};
|
|
448
|
-
Object.defineProperty(result, "map", {
|
|
449
|
-
configurable: true,
|
|
450
|
-
enumerable: true,
|
|
451
|
-
get() {
|
|
452
|
-
return ms.generateMap();
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
return result;
|
|
456
|
-
}
|
|
457
|
-
//#endregion
|
|
458
|
-
export { transformUVue };
|
|
306
|
+
export { shouldEnableComponentLocalStyle as n, shouldEnablePageLocalStyle as r, UniAppXComponentLocalStyleCollector as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TailwindResolvedSource, WeappTailwindcssGenerator } from './types.js';
|
|
2
2
|
import type { TailwindcssRuntimeLike } from '../types/index.js';
|
|
3
|
-
import { resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp } from '../tailwindcss/v4-engine/index.js';
|
|
3
|
+
import { loadTailwindV4DesignSystem, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp } from '../tailwindcss/v4-engine/index.js';
|
|
4
4
|
export declare function createWeappTailwindcssGenerator(source: TailwindResolvedSource): WeappTailwindcssGenerator;
|
|
5
5
|
export declare function resolveTailwindSourceFromRuntime(tailwindRuntime: TailwindcssRuntimeLike): Promise<TailwindResolvedSource>;
|
|
6
6
|
export declare function createWeappTailwindcssGeneratorFromRuntime(tailwindRuntime: TailwindcssRuntimeLike): Promise<WeappTailwindcssGenerator>;
|
|
7
7
|
export { normalizeWeappTailwindcssGeneratorOptions, } from './options.js';
|
|
8
|
-
export { resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp, };
|
|
8
|
+
export { loadTailwindV4DesignSystem, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp, };
|
|
9
9
|
export type { NormalizedWeappTailwindcssGeneratorOptions, WeappTailwindcssGeneratorOptions, WeappTailwindcssGeneratorUserOptions, } from './options.js';
|
|
10
10
|
export type { TailwindCandidateSource, TailwindGeneratorVersion, TailwindResolvedSource, TailwindV4CandidateSource, TailwindV4DesignSystem, TailwindV4Engine, TailwindV4GenerateOptions, TailwindV4GenerateResult, TailwindV4GenerateTarget, TailwindV4ResolvedSource, TailwindV4SourceOptions, WeappTailwindcssGenerateOptions, WeappTailwindcssGenerateResult, WeappTailwindcssGenerator, WeappTailwindcssGeneratorTarget, } from './types.js';
|
package/dist/generator.cjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
3
|
+
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
3
4
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
|
4
5
|
exports.createWeappTailwindcssGeneratorFromRuntime = require_generator.createWeappTailwindcssGeneratorFromRuntime;
|
|
6
|
+
Object.defineProperty(exports, "loadTailwindV4DesignSystem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _tailwindcss_mangle_engine.loadTailwindV4DesignSystem;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
5
12
|
exports.normalizeWeappTailwindcssGeneratorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions;
|
|
6
13
|
exports.resolveTailwindSourceFromRuntime = require_generator.resolveTailwindSourceFromRuntime;
|
|
7
14
|
exports.resolveTailwindV4Source = require_generator.resolveTailwindV4Source;
|
package/dist/generator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Mt as transformTailwindV4CssToWeapp, d as resolveTailwindV4SourceFromRuntime, f as resolveTailwindV4SourceFromRuntimeOptions, i as normalizeWeappTailwindcssGeneratorOptions, jt as transformTailwindV4CssByTarget, n as createWeappTailwindcssGeneratorFromRuntime, p as resolveTailwindV4SourceOptionsFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-BP4WmgIo.js";
|
|
2
|
-
export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromRuntime, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromRuntime, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
|
|
1
|
+
import { Lt as loadTailwindV4DesignSystem, Mt as transformTailwindV4CssToWeapp, d as resolveTailwindV4SourceFromRuntime, f as resolveTailwindV4SourceFromRuntimeOptions, i as normalizeWeappTailwindcssGeneratorOptions, jt as transformTailwindV4CssByTarget, n as createWeappTailwindcssGeneratorFromRuntime, p as resolveTailwindV4SourceOptionsFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-BP4WmgIo.js";
|
|
2
|
+
export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromRuntime, loadTailwindV4DesignSystem, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromRuntime, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
3
3
|
const require_options = require("./options-DbYws6lr.cjs");
|
|
4
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
4
|
+
const require_v4_generation_core = require("./v4-generation-core-BEYGV4eB.cjs");
|
|
5
5
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
6
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
6
|
+
const require_hmr_timing = require("./hmr-timing-pF6k35pP.cjs");
|
|
7
7
|
const require_context = require("./context-vWlNv-Cf.cjs");
|
|
8
8
|
const require_tailwindcss = require("./tailwindcss-D1M2xj5O.cjs");
|
|
9
9
|
const require_style_options = require("./style-options-Cta1OP3i.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, _ as upsertTailwindV4CssSource, et as normalizeTailwindConfigDirectives, g as removeTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, nt as normalizeTailwindSourceForGenerator, vt as prependConfigDirective } from "./generator-BP4WmgIo.js";
|
|
2
2
|
import { f as resolveSourceScanEntries, l as getRuntimeClassSetSignature } from "./tailwindcss-C2K-vjJv.js";
|
|
3
|
-
import { $ as getCompilationScopeDependencyRevision, A as annotateCssSourceTrace, B as splitLocalCssImports, D as stripBundlerGeneratedCssMarkers, F as createRuntimeClassSetManager, G as removeRuntimeCompilationBuildStateFiles, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, Z as getCompilerShadowRunSnapshot, b as finalizeMiniProgramGeneratorCss, et as invalidateCompilationScope, j as createCssSourceTraceCacheSignature, n as emitHmrTiming, nt as createCompilationDependencyChanges, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker, z as rewriteLocalCssImportRequestsForOutput } from "./hmr-timing-
|
|
3
|
+
import { $ as getCompilationScopeDependencyRevision, A as annotateCssSourceTrace, B as splitLocalCssImports, D as stripBundlerGeneratedCssMarkers, F as createRuntimeClassSetManager, G as removeRuntimeCompilationBuildStateFiles, H as buildRuntimeCompilationSnapshot, J as createRuntimeAffectingSourceSignature, M as createCssTokenSourceMap, O as finalizeMiniProgramCssStructure, P as processCachedTask, Q as AssetEmissionPlan, T as hasBundlerGeneratedCssMarker, V as finalizeCompilerShadowRun, W as createRuntimeCompilationBuildState, X as beginCompilerShadowRun, Y as disposeCompilerOwner, Z as getCompilerShadowRunSnapshot, b as finalizeMiniProgramGeneratorCss, et as invalidateCompilationScope, j as createCssSourceTraceCacheSignature, n as emitHmrTiming, nt as createCompilationDependencyChanges, q as updateRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createSourceCandidateCollector, tt as recordCompilationDependencyChanges, w as createBundlerGeneratedCssMarker, z as rewriteLocalCssImportRequestsForOutput } from "./hmr-timing-Dq1_msos.js";
|
|
4
4
|
import { m as createDebug } from "./wxml-B7OAVpXJ.js";
|
|
5
5
|
import { l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-CKQKq4Mv.js";
|
|
6
6
|
import fs from "node:fs";
|
package/dist/gulp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_gulp = require("./gulp-
|
|
2
|
+
const require_gulp = require("./gulp-B0qcNiuP.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_gulp.createPlugins;
|
|
4
4
|
exports.createPlugins = require_gulp.createPlugins;
|
|
5
5
|
exports.weappTailwindcss = require_gulp.createPlugins;
|
package/dist/gulp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createPlugins } from "./gulp-
|
|
1
|
+
import { t as createPlugins } from "./gulp-D1vDx4H1.js";
|
|
2
2
|
export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
|
|
@@ -5247,9 +5247,9 @@ function resolveCompilationDependencies(dependencies) {
|
|
|
5247
5247
|
}));
|
|
5248
5248
|
}
|
|
5249
5249
|
async function executeGeneratorPipeline(context) {
|
|
5250
|
-
return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context));
|
|
5250
|
+
return runCompilerOwnerActivity(context.runtimeState, () => executeGeneratorPipelineWithOwner(context, getCompilationSessionPool(context.runtimeState), getTailwindGenerationSessionPool(context.runtimeState)));
|
|
5251
5251
|
}
|
|
5252
|
-
async function executeGeneratorPipelineWithOwner(context) {
|
|
5252
|
+
async function executeGeneratorPipelineWithOwner(context, compilationPool, generationSession) {
|
|
5253
5253
|
const { cssHandlerOptions, debug, file, generatorBranch, generatorOptions, generatorRawSource, getSourceCandidatesForEntries, hasGeneratedCss, hasGeneratedMarkers, localImports, majorVersion, normalizeGeneratorSource, normalizedCssSources, options, opts, runtime, runtimeState, useMiniProgramCssBranch } = context;
|
|
5254
5254
|
await runtimeState.readyPromise;
|
|
5255
5255
|
const currentCssCandidates = collectGeneratorCssCandidates(generatorRawSource);
|
|
@@ -5272,7 +5272,6 @@ async function executeGeneratorPipelineWithOwner(context) {
|
|
|
5272
5272
|
const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
|
|
5273
5273
|
const configuredContainerCompat = hasConfiguredContainerCompatSources(generatorSourceRecords.map((record) => record.source));
|
|
5274
5274
|
const sourceConcurrency = resolveGeneratorSourceConcurrency();
|
|
5275
|
-
const generationSession = getTailwindGenerationSessionPool(runtimeState);
|
|
5276
5275
|
const preparedGenerationInputs = (await runWithConcurrency(generatorSourceRecords.map((record, index) => async () => {
|
|
5277
5276
|
const { metadata: sourceMetadata, source } = record;
|
|
5278
5277
|
const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
|
|
@@ -5332,7 +5331,7 @@ async function executeGeneratorPipelineWithOwner(context) {
|
|
|
5332
5331
|
let compilationRevision;
|
|
5333
5332
|
let generated;
|
|
5334
5333
|
if (options.compilation?.enabled) {
|
|
5335
|
-
const execution = await
|
|
5334
|
+
const execution = await compilationPool.run({
|
|
5336
5335
|
scope: options.compilation.scope,
|
|
5337
5336
|
outputId: options.outputFile ?? file,
|
|
5338
5337
|
changes: options.compilation.changes,
|
|
@@ -5588,9 +5587,9 @@ async function generateCssByGenerator(options) {
|
|
|
5588
5587
|
//#endregion
|
|
5589
5588
|
//#region src/bundlers/shared/generator-css/validate.ts
|
|
5590
5589
|
async function validateCandidatesByGenerator(options) {
|
|
5591
|
-
return runCompilerOwnerActivity(options.runtimeState, () => validateCandidatesByGeneratorWithOwner(options));
|
|
5590
|
+
return runCompilerOwnerActivity(options.runtimeState, () => validateCandidatesByGeneratorWithOwner(options, getTailwindGenerationSessionPool(options.runtimeState)));
|
|
5592
5591
|
}
|
|
5593
|
-
async function validateCandidatesByGeneratorWithOwner(options) {
|
|
5592
|
+
async function validateCandidatesByGeneratorWithOwner(options, generationSession) {
|
|
5594
5593
|
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
5595
5594
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
5596
5595
|
if (majorVersion !== 4 || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
@@ -5605,7 +5604,6 @@ async function validateCandidatesByGeneratorWithOwner(options) {
|
|
|
5605
5604
|
cssEntries: opts.cssEntries,
|
|
5606
5605
|
runtime: candidates
|
|
5607
5606
|
});
|
|
5608
|
-
const generationSession = getTailwindGenerationSessionPool(runtimeState);
|
|
5609
5607
|
const classSets = await Promise.all(sourceRecords.map(async ({ source }) => {
|
|
5610
5608
|
return generationSession.validateCandidates(source, candidates);
|
|
5611
5609
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
3
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BEYGV4eB.cjs");
|
|
4
4
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
5
5
|
const require_tailwindcss = require("./tailwindcss-D1M2xj5O.cjs");
|
|
6
6
|
let node_process = require("node:process");
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
3
|
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
4
|
-
const require_gulp = require("./gulp-
|
|
4
|
+
const require_gulp = require("./gulp-B0qcNiuP.cjs");
|
|
5
5
|
const require_postcss = require("./postcss.cjs");
|
|
6
|
-
const require_vite = require("./vite-
|
|
7
|
-
const require_webpack = require("./webpack-
|
|
6
|
+
const require_vite = require("./vite-jftHIupF.cjs");
|
|
7
|
+
const require_webpack = require("./webpack-DhwW2cva.cjs");
|
|
8
8
|
require("./webpack.cjs");
|
|
9
9
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
10
10
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform } from "./framework.js";
|
|
2
2
|
import { t as createWeappTailwindcssGenerator } from "./generator-BP4WmgIo.js";
|
|
3
|
-
import { t as createPlugins } from "./gulp-
|
|
3
|
+
import { t as createPlugins } from "./gulp-D1vDx4H1.js";
|
|
4
4
|
import weappTailwindcssPostcssPlugin from "./postcss.js";
|
|
5
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
6
|
-
import { n as weappTailwindcssPackageDir } from "./webpack-
|
|
5
|
+
import { t as WeappTailwindcss } from "./vite-DBgbFsei.js";
|
|
6
|
+
import { n as weappTailwindcssPackageDir } from "./webpack-BSIWFzAA.js";
|
|
7
7
|
import "./webpack.js";
|
|
8
8
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
9
9
|
export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_generator = require("./generator-BXrWA7Sj.cjs");
|
|
3
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BEYGV4eB.cjs");
|
|
4
4
|
const require_defaults = require("./defaults.cjs");
|
|
5
5
|
const require_style_options = require("./style-options-Cta1OP3i.cjs");
|
|
6
6
|
let node_path = require("node:path");
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,8 +1,113 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BEYGV4eB.cjs");
|
|
4
|
+
const require_webpack = require("./webpack-DhwW2cva.cjs");
|
|
4
5
|
let node_path = require("node:path");
|
|
5
6
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
7
|
+
//#region src/bundlers/rspack/rule-match.ts
|
|
8
|
+
const STYLE_RULE_PROBES = [
|
|
9
|
+
"weapp-tailwindcss.css",
|
|
10
|
+
"weapp-tailwindcss.module.css",
|
|
11
|
+
"weapp-tailwindcss.wxss",
|
|
12
|
+
"weapp-tailwindcss.acss",
|
|
13
|
+
"weapp-tailwindcss.ttss",
|
|
14
|
+
"weapp-tailwindcss.qss",
|
|
15
|
+
"weapp-tailwindcss.jxss",
|
|
16
|
+
"weapp-tailwindcss.scss",
|
|
17
|
+
"weapp-tailwindcss.module.scss",
|
|
18
|
+
"weapp-tailwindcss.less",
|
|
19
|
+
"weapp-tailwindcss.styl",
|
|
20
|
+
"weapp-tailwindcss.pcss"
|
|
21
|
+
];
|
|
22
|
+
const SCRIPT_RULE_PROBES = [
|
|
23
|
+
"weapp-tailwindcss.js",
|
|
24
|
+
"weapp-tailwindcss.jsx",
|
|
25
|
+
"weapp-tailwindcss.mjs",
|
|
26
|
+
"weapp-tailwindcss.cjs",
|
|
27
|
+
"weapp-tailwindcss.ts",
|
|
28
|
+
"weapp-tailwindcss.tsx"
|
|
29
|
+
];
|
|
30
|
+
const STYLE_RESOURCE_QUERY_PROBES = [
|
|
31
|
+
"type=style",
|
|
32
|
+
"type=styles",
|
|
33
|
+
"vue&type=style&index=0&lang.css"
|
|
34
|
+
];
|
|
35
|
+
function isRegExpLike(value) {
|
|
36
|
+
return value instanceof RegExp;
|
|
37
|
+
}
|
|
38
|
+
function testRegexpMatcher(matcher, input) {
|
|
39
|
+
const lastIndex = matcher.lastIndex;
|
|
40
|
+
matcher.lastIndex = 0;
|
|
41
|
+
const result = matcher.test(input);
|
|
42
|
+
matcher.lastIndex = lastIndex;
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function matchesStringCondition(condition, input) {
|
|
46
|
+
if (typeof condition === "string") return input.includes(condition);
|
|
47
|
+
if (isRegExpLike(condition)) return testRegexpMatcher(condition, input);
|
|
48
|
+
}
|
|
49
|
+
function matchesCondition(condition, input) {
|
|
50
|
+
if (Array.isArray(condition)) {
|
|
51
|
+
let hasStaticMatcher = false;
|
|
52
|
+
for (const item of condition) {
|
|
53
|
+
const matched = matchesCondition(item, input);
|
|
54
|
+
if (matched === true) return true;
|
|
55
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
56
|
+
}
|
|
57
|
+
return hasStaticMatcher ? false : void 0;
|
|
58
|
+
}
|
|
59
|
+
if (typeof condition === "object" && condition !== null && !isRegExpLike(condition)) {
|
|
60
|
+
const group = condition;
|
|
61
|
+
if (Array.isArray(group.and)) {
|
|
62
|
+
let hasUnknown = false;
|
|
63
|
+
for (const item of group.and) {
|
|
64
|
+
const matched = matchesCondition(item, input);
|
|
65
|
+
if (matched === false) return false;
|
|
66
|
+
hasUnknown || (hasUnknown = matched === void 0);
|
|
67
|
+
}
|
|
68
|
+
return hasUnknown ? void 0 : true;
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(group.or)) return matchesCondition(group.or, input);
|
|
71
|
+
if (group.not !== void 0) {
|
|
72
|
+
const matched = matchesCondition(group.not, input);
|
|
73
|
+
return matched === void 0 ? void 0 : !matched;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
return matchesStringCondition(condition, input);
|
|
78
|
+
}
|
|
79
|
+
function matchesAnyStringCondition(condition, inputs) {
|
|
80
|
+
let hasStaticMatcher = false;
|
|
81
|
+
for (const input of inputs) {
|
|
82
|
+
const matched = matchesCondition(condition, input);
|
|
83
|
+
if (matched === true) return true;
|
|
84
|
+
hasStaticMatcher || (hasStaticMatcher = matched === false);
|
|
85
|
+
}
|
|
86
|
+
return hasStaticMatcher ? false : void 0;
|
|
87
|
+
}
|
|
88
|
+
function matchesStyleResourceCondition(condition) {
|
|
89
|
+
if (typeof condition === "function") return;
|
|
90
|
+
if (typeof condition === "string" && require_v4_generation_core.isSourceStyleRequest(condition)) return true;
|
|
91
|
+
const matched = matchesAnyStringCondition(condition, STYLE_RULE_PROBES);
|
|
92
|
+
return typeof condition === "string" && matched === false ? void 0 : matched;
|
|
93
|
+
}
|
|
94
|
+
function matchesResourceQueryCondition(condition) {
|
|
95
|
+
if (typeof condition === "function") return;
|
|
96
|
+
return matchesAnyStringCondition(condition, STYLE_RESOURCE_QUERY_PROBES);
|
|
97
|
+
}
|
|
98
|
+
function resolveRuleCssMatch(rule) {
|
|
99
|
+
if (matchesAnyStringCondition(rule.include, STYLE_RULE_PROBES) === true) return true;
|
|
100
|
+
if (matchesAnyStringCondition(rule.exclude, STYLE_RULE_PROBES) === true) return false;
|
|
101
|
+
if (matchesStyleResourceCondition(rule.resource) === true) return true;
|
|
102
|
+
if (matchesAnyStringCondition(rule.test, STYLE_RULE_PROBES) === true) return true;
|
|
103
|
+
if (matchesAnyStringCondition(rule.test, SCRIPT_RULE_PROBES) === true) return false;
|
|
104
|
+
if (matchesResourceQueryCondition(rule.resourceQuery) === true) return true;
|
|
105
|
+
if (typeof rule.type === "string") {
|
|
106
|
+
if (rule.type.includes("css") || rule.type.includes("style")) return true;
|
|
107
|
+
if (rule.type.includes("javascript")) return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
6
111
|
//#region src/bundlers/rspack/index.ts
|
|
7
112
|
const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
|
|
8
113
|
const LIGHTNING_CSS_LOADER_NAME = "builtin:lightningcss-loader";
|
|
@@ -11,10 +116,20 @@ const POSTCSS_LOADER_NAME = "postcss-loader";
|
|
|
11
116
|
function isRuleLike(value) {
|
|
12
117
|
return typeof value === "object" && value !== null;
|
|
13
118
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
119
|
+
function isRspackUseItem(value) {
|
|
120
|
+
return typeof value === "string" || typeof value === "object" && value !== null;
|
|
121
|
+
}
|
|
122
|
+
function normalizeRuleUse(use) {
|
|
123
|
+
if (Array.isArray(use)) return {
|
|
124
|
+
entries: use,
|
|
125
|
+
commit: (entries) => entries
|
|
126
|
+
};
|
|
16
127
|
if (use === void 0) return;
|
|
17
|
-
|
|
128
|
+
if (!isRspackUseItem(use)) return;
|
|
129
|
+
return {
|
|
130
|
+
entries: [use],
|
|
131
|
+
commit: (entries) => entries.length === 1 ? entries[0] : entries
|
|
132
|
+
};
|
|
18
133
|
}
|
|
19
134
|
function getLoaderName(item) {
|
|
20
135
|
if (typeof item === "string") return item;
|
|
@@ -35,8 +150,10 @@ function resolveCssImportRewriteOptions(options) {
|
|
|
35
150
|
return cssImportRewriteLoader === true ? {} : cssImportRewriteLoader;
|
|
36
151
|
}
|
|
37
152
|
function patchRuleUse(rule, options) {
|
|
38
|
-
|
|
39
|
-
|
|
153
|
+
if (resolveRuleCssMatch(rule) === false) return;
|
|
154
|
+
const normalizedUse = normalizeRuleUse(rule.use);
|
|
155
|
+
if (!normalizedUse) return;
|
|
156
|
+
let use = normalizedUse.entries;
|
|
40
157
|
if (options.removeLightningCssLoader) use = use.filter((item) => !includesLoaderName(item, LIGHTNING_CSS_LOADER_NAME));
|
|
41
158
|
const cssImportRewriteOptions = resolveCssImportRewriteOptions(options);
|
|
42
159
|
if (cssImportRewriteOptions) {
|
|
@@ -49,7 +166,7 @@ function patchRuleUse(rule, options) {
|
|
|
49
166
|
use.splice(fallbackAnchorIndex + 1, 0, loaderEntry);
|
|
50
167
|
}
|
|
51
168
|
}
|
|
52
|
-
rule.use = use;
|
|
169
|
+
rule.use = normalizedUse.commit(use);
|
|
53
170
|
}
|
|
54
171
|
function walkRspackRule(rule, options) {
|
|
55
172
|
if (!isRuleLike(rule)) return;
|