tailwindcss 3.0.23 → 3.0.24
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/CHANGELOG.md +29 -3
- package/lib/cli-peer-dependencies.js +3 -3
- package/lib/cli.js +183 -161
- package/lib/constants.js +8 -8
- package/lib/corePlugins.js +1572 -1523
- package/lib/featureFlags.js +9 -9
- package/lib/index.js +19 -6
- package/lib/lib/cacheInvalidation.js +69 -0
- package/lib/lib/collapseAdjacentRules.js +26 -13
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +6 -6
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +16 -16
- package/lib/lib/expandApplyAtRules.js +180 -27
- package/lib/lib/expandTailwindAtRules.js +132 -122
- package/lib/lib/generateRules.js +90 -72
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/resolveDefaultsAtRules.js +81 -77
- package/lib/lib/setupContextUtils.js +78 -87
- package/lib/lib/setupTrackingContext.js +57 -57
- package/lib/lib/sharedState.js +10 -8
- package/lib/lib/substituteScreenAtRules.js +2 -2
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +41 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +21 -20
- package/lib/util/createUtilityPlugin.js +6 -6
- package/lib/util/dataTypes.js +77 -75
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +19 -19
- package/lib/util/getAllConfigs.js +5 -5
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +27 -27
- package/lib/util/log.js +8 -8
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +39 -39
- package/lib/util/normalizeScreens.js +4 -4
- package/lib/util/parseAnimationValue.js +56 -56
- package/lib/util/parseBoxShadowValue.js +60 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +9 -9
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +28 -28
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +27 -27
- package/lib/util/withAlphaVariable.js +19 -19
- package/package.json +24 -23
- package/peers/index.js +4777 -4831
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +41 -11
- package/src/corePlugins.js +67 -5
- package/src/featureFlags.js +2 -2
- package/src/index.js +17 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +16 -1
- package/src/lib/defaultExtractor.js +4 -4
- package/src/lib/expandApplyAtRules.js +179 -6
- package/src/lib/expandTailwindAtRules.js +25 -5
- package/src/lib/generateRules.js +68 -46
- package/src/lib/resolveDefaultsAtRules.js +6 -2
- package/src/lib/setupContextUtils.js +25 -26
- package/src/lib/setupTrackingContext.js +3 -3
- package/src/lib/sharedState.js +1 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +7 -5
- package/src/util/dataTypes.js +3 -1
- package/src/util/log.js +7 -7
- package/src/util/parseBoxShadowValue.js +50 -2
- package/src/util/resolveConfig.js +32 -0
- package/stubs/defaultConfig.stub.js +5 -0
package/lib/lib/generateRules.js
CHANGED
|
@@ -42,7 +42,7 @@ function _interopRequireWildcard(obj) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
45
|
-
return selectors.first.filter(({ type })=>type ===
|
|
45
|
+
return selectors.first.filter(({ type })=>type === "class"
|
|
46
46
|
).pop().value;
|
|
47
47
|
});
|
|
48
48
|
function getClassNameFromSelector(selector) {
|
|
@@ -59,16 +59,16 @@ function* candidatePermutations(candidate) {
|
|
|
59
59
|
let lastIndex = Infinity;
|
|
60
60
|
while(lastIndex >= 0){
|
|
61
61
|
let dashIdx;
|
|
62
|
-
if (lastIndex === Infinity && candidate.endsWith(
|
|
63
|
-
let bracketIdx = candidate.indexOf(
|
|
62
|
+
if (lastIndex === Infinity && candidate.endsWith("]")) {
|
|
63
|
+
let bracketIdx = candidate.indexOf("[");
|
|
64
64
|
// If character before `[` isn't a dash or a slash, this isn't a dynamic class
|
|
65
65
|
// eg. string[]
|
|
66
66
|
dashIdx = [
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
"-",
|
|
68
|
+
"/"
|
|
69
69
|
].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
|
|
70
70
|
} else {
|
|
71
|
-
dashIdx = candidate.lastIndexOf(
|
|
71
|
+
dashIdx = candidate.lastIndexOf("-", lastIndex);
|
|
72
72
|
}
|
|
73
73
|
if (dashIdx < 0) {
|
|
74
74
|
break;
|
|
@@ -83,7 +83,7 @@ function* candidatePermutations(candidate) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
function applyPrefix(matches, context) {
|
|
86
|
-
if (matches.length === 0 || context.tailwindConfig.prefix ===
|
|
86
|
+
if (matches.length === 0 || context.tailwindConfig.prefix === "") {
|
|
87
87
|
return matches;
|
|
88
88
|
}
|
|
89
89
|
for (let match of matches){
|
|
@@ -100,7 +100,7 @@ function applyPrefix(matches, context) {
|
|
|
100
100
|
// have to ensure that the generated selector matches the candidate
|
|
101
101
|
// Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
|
|
102
102
|
// The disconnect between candidate <-> class can cause @apply to hard crash.
|
|
103
|
-
let shouldPrependNegative = classCandidate.startsWith(
|
|
103
|
+
let shouldPrependNegative = classCandidate.startsWith("-");
|
|
104
104
|
r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
|
|
105
105
|
});
|
|
106
106
|
match[1] = container.nodes[0];
|
|
@@ -108,7 +108,7 @@ function applyPrefix(matches, context) {
|
|
|
108
108
|
}
|
|
109
109
|
return matches;
|
|
110
110
|
}
|
|
111
|
-
function applyImportant(matches) {
|
|
111
|
+
function applyImportant(matches, classCandidate) {
|
|
112
112
|
if (matches.length === 0) {
|
|
113
113
|
return matches;
|
|
114
114
|
}
|
|
@@ -121,7 +121,10 @@ function applyImportant(matches) {
|
|
|
121
121
|
});
|
|
122
122
|
container.walkRules((r)=>{
|
|
123
123
|
r.selector = (0, _pluginUtils).updateAllClasses(r.selector, (className)=>{
|
|
124
|
-
|
|
124
|
+
if (className === classCandidate) {
|
|
125
|
+
return `!${className}`;
|
|
126
|
+
}
|
|
127
|
+
return className;
|
|
125
128
|
});
|
|
126
129
|
r.walkDecls((d)=>d.important = true
|
|
127
130
|
);
|
|
@@ -153,7 +156,7 @@ function applyVariant(variant, matches, context) {
|
|
|
153
156
|
let result = [];
|
|
154
157
|
for (let [meta, rule1] of matches){
|
|
155
158
|
// Don't generate variants for user css
|
|
156
|
-
if (meta.layer ===
|
|
159
|
+
if (meta.layer === "user") {
|
|
157
160
|
continue;
|
|
158
161
|
}
|
|
159
162
|
let container = _postcss.default.root({
|
|
@@ -173,7 +176,7 @@ function applyVariant(variant, matches, context) {
|
|
|
173
176
|
function modifySelectors(modifierFunction) {
|
|
174
177
|
prepareBackup();
|
|
175
178
|
clone.each((rule)=>{
|
|
176
|
-
if (rule.type !==
|
|
179
|
+
if (rule.type !== "rule") {
|
|
177
180
|
return;
|
|
178
181
|
}
|
|
179
182
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
@@ -206,7 +209,7 @@ function applyVariant(variant, matches, context) {
|
|
|
206
209
|
collectedFormats.push(selectorFormat);
|
|
207
210
|
}
|
|
208
211
|
});
|
|
209
|
-
if (typeof ruleWithVariant ===
|
|
212
|
+
if (typeof ruleWithVariant === "string") {
|
|
210
213
|
collectedFormats.push(ruleWithVariant);
|
|
211
214
|
}
|
|
212
215
|
if (ruleWithVariant === null) {
|
|
@@ -241,7 +244,7 @@ function applyVariant(variant, matches, context) {
|
|
|
241
244
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
242
245
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
243
246
|
// format: .foo &
|
|
244
|
-
collectedFormats.push(modified.replace(rebuiltBase,
|
|
247
|
+
collectedFormats.push(modified.replace(rebuiltBase, "&"));
|
|
245
248
|
rule.selector = before;
|
|
246
249
|
});
|
|
247
250
|
}
|
|
@@ -302,17 +305,27 @@ function isValidPropName(name) {
|
|
|
302
305
|
*/ function looksLikeUri(declaration) {
|
|
303
306
|
// Quick bailout for obvious non-urls
|
|
304
307
|
// This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
|
|
305
|
-
if (!declaration.includes(
|
|
308
|
+
if (!declaration.includes("://")) {
|
|
306
309
|
return false;
|
|
307
310
|
}
|
|
308
311
|
try {
|
|
309
312
|
const url = new URL(declaration);
|
|
310
|
-
return url.scheme !==
|
|
313
|
+
return url.scheme !== "" && url.host !== "";
|
|
311
314
|
} catch (err) {
|
|
312
315
|
// Definitely not a valid url
|
|
313
316
|
return false;
|
|
314
317
|
}
|
|
315
318
|
}
|
|
319
|
+
function isParsableNode(node) {
|
|
320
|
+
let isParsable = true;
|
|
321
|
+
node.walkDecls((decl)=>{
|
|
322
|
+
if (!isParsableCssValue(decl.name, decl.value)) {
|
|
323
|
+
isParsable = false;
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
return isParsable;
|
|
328
|
+
}
|
|
316
329
|
function isParsableCssValue(property, value) {
|
|
317
330
|
// We don't want to to treat [https://example.com] as a custom property
|
|
318
331
|
// Even though, according to the CSS grammar, it's a totally valid CSS declaration
|
|
@@ -347,7 +360,7 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
347
360
|
[
|
|
348
361
|
{
|
|
349
362
|
sort: context.arbitraryPropertiesSort,
|
|
350
|
-
layer:
|
|
363
|
+
layer: "utilities"
|
|
351
364
|
},
|
|
352
365
|
()=>({
|
|
353
366
|
[(0, _nameClass).asClass(classCandidate)]: {
|
|
@@ -362,29 +375,29 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
362
375
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
363
376
|
yield [
|
|
364
377
|
context.candidateRuleMap.get(classCandidate),
|
|
365
|
-
|
|
378
|
+
"DEFAULT"
|
|
366
379
|
];
|
|
367
380
|
}
|
|
368
|
-
yield*
|
|
381
|
+
yield* function*(arbitraryPropertyRule) {
|
|
369
382
|
if (arbitraryPropertyRule !== null) {
|
|
370
383
|
yield [
|
|
371
384
|
arbitraryPropertyRule,
|
|
372
|
-
|
|
385
|
+
"DEFAULT"
|
|
373
386
|
];
|
|
374
387
|
}
|
|
375
|
-
}
|
|
388
|
+
}(extractArbitraryProperty(classCandidate, context));
|
|
376
389
|
let candidatePrefix = classCandidate;
|
|
377
390
|
let negative = false;
|
|
378
391
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
379
392
|
const twConfigPrefixLen = twConfigPrefix.length;
|
|
380
|
-
if (candidatePrefix[twConfigPrefixLen] ===
|
|
393
|
+
if (candidatePrefix[twConfigPrefixLen] === "-") {
|
|
381
394
|
negative = true;
|
|
382
395
|
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
|
|
383
396
|
}
|
|
384
397
|
if (negative && context.candidateRuleMap.has(candidatePrefix)) {
|
|
385
398
|
yield [
|
|
386
399
|
context.candidateRuleMap.get(candidatePrefix),
|
|
387
|
-
|
|
400
|
+
"-DEFAULT"
|
|
388
401
|
];
|
|
389
402
|
}
|
|
390
403
|
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
|
|
@@ -402,7 +415,7 @@ function splitWithSeparator(input, separator) {
|
|
|
402
415
|
sharedState.NOT_ON_DEMAND
|
|
403
416
|
];
|
|
404
417
|
}
|
|
405
|
-
return input.split(new RegExp(`\\${separator}(?![^[]*\\])`,
|
|
418
|
+
return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, "g"));
|
|
406
419
|
}
|
|
407
420
|
function* recordCandidates(matches, classCandidate) {
|
|
408
421
|
for (const match of matches){
|
|
@@ -417,7 +430,7 @@ function* resolveMatches(candidate, context) {
|
|
|
417
430
|
let separator = context.tailwindConfig.separator;
|
|
418
431
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
419
432
|
let important = false;
|
|
420
|
-
if (classCandidate.startsWith(
|
|
433
|
+
if (classCandidate.startsWith("!")) {
|
|
421
434
|
important = true;
|
|
422
435
|
classCandidate = classCandidate.slice(1);
|
|
423
436
|
}
|
|
@@ -439,7 +452,7 @@ function* resolveMatches(candidate, context) {
|
|
|
439
452
|
let isOnlyPlugin = plugins.length === 1;
|
|
440
453
|
for (let [sort, plugin] of plugins){
|
|
441
454
|
let matchesPerPlugin = [];
|
|
442
|
-
if (typeof plugin ===
|
|
455
|
+
if (typeof plugin === "function") {
|
|
443
456
|
for (let ruleSet of [].concat(plugin(modifier, {
|
|
444
457
|
isOnlyPlugin
|
|
445
458
|
}))){
|
|
@@ -457,7 +470,7 @@ function* resolveMatches(candidate, context) {
|
|
|
457
470
|
]);
|
|
458
471
|
}
|
|
459
472
|
}
|
|
460
|
-
} else if (modifier ===
|
|
473
|
+
} else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
|
|
461
474
|
let ruleSet = plugin;
|
|
462
475
|
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
|
|
463
476
|
for (let rule of rules){
|
|
@@ -479,54 +492,59 @@ function* resolveMatches(candidate, context) {
|
|
|
479
492
|
matches.push(matchesPerPlugin);
|
|
480
493
|
}
|
|
481
494
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
for (let
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
otherGroup.
|
|
498
|
-
|
|
495
|
+
if (isArbitraryValue(modifier)) {
|
|
496
|
+
// When generated arbitrary values are ambiguous, we can't know
|
|
497
|
+
// which to pick so don't generate any utilities for them
|
|
498
|
+
if (matches.length > 1) {
|
|
499
|
+
var ref1;
|
|
500
|
+
let typesPerPlugin = matches.map((match)=>new Set([
|
|
501
|
+
...(ref1 = typesByMatches.get(match)) !== null && ref1 !== void 0 ? ref1 : []
|
|
502
|
+
])
|
|
503
|
+
);
|
|
504
|
+
// Remove duplicates, so that we can detect proper unique types for each plugin.
|
|
505
|
+
for (let pluginTypes of typesPerPlugin){
|
|
506
|
+
for (let type of pluginTypes){
|
|
507
|
+
let removeFromOwnGroup = false;
|
|
508
|
+
for (let otherGroup of typesPerPlugin){
|
|
509
|
+
if (pluginTypes === otherGroup) continue;
|
|
510
|
+
if (otherGroup.has(type)) {
|
|
511
|
+
otherGroup.delete(type);
|
|
512
|
+
removeFromOwnGroup = true;
|
|
513
|
+
}
|
|
499
514
|
}
|
|
515
|
+
if (removeFromOwnGroup) pluginTypes.delete(type);
|
|
500
516
|
}
|
|
501
|
-
if (removeFromOwnGroup) pluginTypes.delete(type);
|
|
502
517
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
.join(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
518
|
+
let messages = [];
|
|
519
|
+
for (let [idx, group] of typesPerPlugin.entries()){
|
|
520
|
+
for (let type of group){
|
|
521
|
+
let rules = matches[idx].map(([, rule])=>rule
|
|
522
|
+
).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
|
|
523
|
+
.map((line)=>line.trim()
|
|
524
|
+
).map((x)=>` ${x}`
|
|
525
|
+
) // Re-indent
|
|
526
|
+
.join("\n")
|
|
527
|
+
).join("\n\n");
|
|
528
|
+
messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
516
531
|
}
|
|
532
|
+
_log.default.warn([
|
|
533
|
+
`The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
|
|
534
|
+
...messages,
|
|
535
|
+
`If this is content and not a class, replace it with \`${candidate.replace("[", "[").replace("]", "]")}\` to silence this warning.`,
|
|
536
|
+
]);
|
|
537
|
+
continue;
|
|
517
538
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
`If this is content and not a class, replace it with \`${candidate.replace('[', '[').replace(']', ']')}\` to silence this warning.`,
|
|
522
|
-
]);
|
|
523
|
-
continue;
|
|
539
|
+
matches = matches.map((list)=>list.filter((match)=>isParsableNode(match[1])
|
|
540
|
+
)
|
|
541
|
+
);
|
|
524
542
|
}
|
|
525
543
|
matches = matches.flat();
|
|
526
544
|
matches = Array.from(recordCandidates(matches, classCandidate));
|
|
527
545
|
matches = applyPrefix(matches, context);
|
|
528
546
|
if (important) {
|
|
529
|
-
matches = applyImportant(matches,
|
|
547
|
+
matches = applyImportant(matches, classCandidate);
|
|
530
548
|
}
|
|
531
549
|
for (let variant of variants){
|
|
532
550
|
matches = applyVariant(variant, matches, context);
|
|
@@ -538,7 +556,7 @@ function* resolveMatches(candidate, context) {
|
|
|
538
556
|
};
|
|
539
557
|
// Apply final format selector
|
|
540
558
|
if (match1[0].collectedFormats) {
|
|
541
|
-
let finalFormat = (0, _formatVariantSelector).formatVariantSelector(
|
|
559
|
+
let finalFormat = (0, _formatVariantSelector).formatVariantSelector("&", ...match1[0].collectedFormats);
|
|
542
560
|
let container = _postcss.default.root({
|
|
543
561
|
nodes: [
|
|
544
562
|
match1[1].clone()
|
|
@@ -558,8 +576,9 @@ function* resolveMatches(candidate, context) {
|
|
|
558
576
|
}
|
|
559
577
|
}
|
|
560
578
|
}
|
|
579
|
+
exports.resolveMatches = resolveMatches;
|
|
561
580
|
function inKeyframes(rule) {
|
|
562
|
-
return rule.parent && rule.parent.type ===
|
|
581
|
+
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
563
582
|
}
|
|
564
583
|
function generateRules(candidates, context) {
|
|
565
584
|
let allRules = [];
|
|
@@ -584,13 +603,13 @@ function generateRules(candidates, context) {
|
|
|
584
603
|
if (important === true) {
|
|
585
604
|
return (rule)=>{
|
|
586
605
|
rule.walkDecls((d)=>{
|
|
587
|
-
if (d.parent.type ===
|
|
606
|
+
if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
|
|
588
607
|
d.important = true;
|
|
589
608
|
}
|
|
590
609
|
});
|
|
591
610
|
};
|
|
592
611
|
}
|
|
593
|
-
if (typeof important ===
|
|
612
|
+
if (typeof important === "string") {
|
|
594
613
|
return (rule)=>{
|
|
595
614
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
596
615
|
return `${important} ${selector}`;
|
|
@@ -621,8 +640,7 @@ function generateRules(candidates, context) {
|
|
|
621
640
|
];
|
|
622
641
|
});
|
|
623
642
|
}
|
|
643
|
+
exports.generateRules = generateRules;
|
|
624
644
|
function isArbitraryValue(input) {
|
|
625
|
-
return input.startsWith(
|
|
645
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
626
646
|
}
|
|
627
|
-
exports.resolveMatches = resolveMatches;
|
|
628
|
-
exports.generateRules = generateRules;
|
|
@@ -7,19 +7,6 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
8
|
var _resolve = _interopRequireDefault(require("resolve"));
|
|
9
9
|
var _detective = _interopRequireDefault(require("detective"));
|
|
10
|
-
function _interopRequireDefault(obj) {
|
|
11
|
-
return obj && obj.__esModule ? obj : {
|
|
12
|
-
default: obj
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function createModule(file) {
|
|
16
|
-
const source = _fs.default.readFileSync(file, 'utf-8');
|
|
17
|
-
const requires = (0, _detective).default(source);
|
|
18
|
-
return {
|
|
19
|
-
file,
|
|
20
|
-
requires
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
10
|
function getModuleDependencies(entryFile) {
|
|
24
11
|
const rootModule = createModule(entryFile);
|
|
25
12
|
const modules = [
|
|
@@ -30,7 +17,7 @@ function getModuleDependencies(entryFile) {
|
|
|
30
17
|
for (const mdl of modules){
|
|
31
18
|
mdl.requires.filter((dep)=>{
|
|
32
19
|
// Only track local modules, not node_modules
|
|
33
|
-
return dep.startsWith(
|
|
20
|
+
return dep.startsWith("./") || dep.startsWith("../");
|
|
34
21
|
}).forEach((dep)=>{
|
|
35
22
|
try {
|
|
36
23
|
const basedir = _path.default.dirname(mdl.file);
|
|
@@ -46,3 +33,16 @@ function getModuleDependencies(entryFile) {
|
|
|
46
33
|
}
|
|
47
34
|
return modules;
|
|
48
35
|
}
|
|
36
|
+
function _interopRequireDefault(obj) {
|
|
37
|
+
return obj && obj.__esModule ? obj : {
|
|
38
|
+
default: obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function createModule(file) {
|
|
42
|
+
const source = _fs.default.readFileSync(file, "utf-8");
|
|
43
|
+
const requires = (0, _detective).default(source);
|
|
44
|
+
return {
|
|
45
|
+
file,
|
|
46
|
+
requires
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -4,75 +4,70 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = normalizeTailwindDirectives;
|
|
6
6
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
7
|
-
function _interopRequireDefault(obj) {
|
|
8
|
-
return obj && obj.__esModule ? obj : {
|
|
9
|
-
default: obj
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
7
|
function normalizeTailwindDirectives(root) {
|
|
13
8
|
let tailwindDirectives = new Set();
|
|
14
9
|
let layerDirectives = new Set();
|
|
15
10
|
let applyDirectives = new Set();
|
|
16
11
|
root.walkAtRules((atRule)=>{
|
|
17
|
-
if (atRule.name ===
|
|
12
|
+
if (atRule.name === "apply") {
|
|
18
13
|
applyDirectives.add(atRule);
|
|
19
14
|
}
|
|
20
|
-
if (atRule.name ===
|
|
15
|
+
if (atRule.name === "import") {
|
|
21
16
|
if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
|
|
22
|
-
atRule.name =
|
|
23
|
-
atRule.params =
|
|
17
|
+
atRule.name = "tailwind";
|
|
18
|
+
atRule.params = "base";
|
|
24
19
|
} else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
|
|
25
|
-
atRule.name =
|
|
26
|
-
atRule.params =
|
|
20
|
+
atRule.name = "tailwind";
|
|
21
|
+
atRule.params = "components";
|
|
27
22
|
} else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
|
|
28
|
-
atRule.name =
|
|
29
|
-
atRule.params =
|
|
23
|
+
atRule.name = "tailwind";
|
|
24
|
+
atRule.params = "utilities";
|
|
30
25
|
} else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
|
|
31
|
-
atRule.name =
|
|
32
|
-
atRule.params =
|
|
26
|
+
atRule.name = "tailwind";
|
|
27
|
+
atRule.params = "variants";
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
|
-
if (atRule.name ===
|
|
36
|
-
if (atRule.params ===
|
|
37
|
-
atRule.params =
|
|
30
|
+
if (atRule.name === "tailwind") {
|
|
31
|
+
if (atRule.params === "screens") {
|
|
32
|
+
atRule.params = "variants";
|
|
38
33
|
}
|
|
39
34
|
tailwindDirectives.add(atRule.params);
|
|
40
35
|
}
|
|
41
36
|
if ([
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
"layer",
|
|
38
|
+
"responsive",
|
|
39
|
+
"variants"
|
|
45
40
|
].includes(atRule.name)) {
|
|
46
41
|
if ([
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
"responsive",
|
|
43
|
+
"variants"
|
|
49
44
|
].includes(atRule.name)) {
|
|
50
45
|
_log.default.warn(`${atRule.name}-at-rule-deprecated`, [
|
|
51
46
|
`The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
|
|
52
47
|
`Use \`@layer utilities\` or \`@layer components\` instead.`,
|
|
53
|
-
|
|
48
|
+
"https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer",
|
|
54
49
|
]);
|
|
55
50
|
}
|
|
56
51
|
layerDirectives.add(atRule);
|
|
57
52
|
}
|
|
58
53
|
});
|
|
59
|
-
if (!tailwindDirectives.has(
|
|
54
|
+
if (!tailwindDirectives.has("base") || !tailwindDirectives.has("components") || !tailwindDirectives.has("utilities")) {
|
|
60
55
|
for (let rule of layerDirectives){
|
|
61
|
-
if (rule.name ===
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
if (rule.name === "layer" && [
|
|
57
|
+
"base",
|
|
58
|
+
"components",
|
|
59
|
+
"utilities"
|
|
65
60
|
].includes(rule.params)) {
|
|
66
61
|
if (!tailwindDirectives.has(rule.params)) {
|
|
67
62
|
throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
|
|
68
63
|
}
|
|
69
|
-
} else if (rule.name ===
|
|
70
|
-
if (!tailwindDirectives.has(
|
|
71
|
-
throw rule.error(
|
|
64
|
+
} else if (rule.name === "responsive") {
|
|
65
|
+
if (!tailwindDirectives.has("utilities")) {
|
|
66
|
+
throw rule.error("`@responsive` is used but `@tailwind utilities` is missing.");
|
|
72
67
|
}
|
|
73
|
-
} else if (rule.name ===
|
|
74
|
-
if (!tailwindDirectives.has(
|
|
75
|
-
throw rule.error(
|
|
68
|
+
} else if (rule.name === "variants") {
|
|
69
|
+
if (!tailwindDirectives.has("utilities")) {
|
|
70
|
+
throw rule.error("`@variants` is used but `@tailwind utilities` is missing.");
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
}
|
|
@@ -82,3 +77,8 @@ function normalizeTailwindDirectives(root) {
|
|
|
82
77
|
applyDirectives
|
|
83
78
|
};
|
|
84
79
|
}
|
|
80
|
+
function _interopRequireDefault(obj) {
|
|
81
|
+
return obj && obj.__esModule ? obj : {
|
|
82
|
+
default: obj
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -3,10 +3,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandApplyAtRules;
|
|
6
|
+
function expandApplyAtRules() {
|
|
7
|
+
return (root)=>{
|
|
8
|
+
partitionRules(root);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
6
11
|
function partitionRules(root) {
|
|
7
12
|
if (!root.walkAtRules) return;
|
|
8
13
|
let applyParents = new Set();
|
|
9
|
-
root.walkAtRules(
|
|
14
|
+
root.walkAtRules("apply", (rule)=>{
|
|
10
15
|
applyParents.add(rule.parent);
|
|
11
16
|
});
|
|
12
17
|
if (applyParents.size === 0) {
|
|
@@ -16,7 +21,7 @@ function partitionRules(root) {
|
|
|
16
21
|
let nodeGroups = [];
|
|
17
22
|
let lastGroup = [];
|
|
18
23
|
for (let node of rule1.nodes){
|
|
19
|
-
if (node.type ===
|
|
24
|
+
if (node.type === "atrule" && node.name === "apply") {
|
|
20
25
|
if (lastGroup.length > 0) {
|
|
21
26
|
nodeGroups.push(lastGroup);
|
|
22
27
|
lastGroup = [];
|
|
@@ -46,8 +51,3 @@ function partitionRules(root) {
|
|
|
46
51
|
rule1.remove();
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
function expandApplyAtRules() {
|
|
50
|
-
return (root)=>{
|
|
51
|
-
partitionRules(root);
|
|
52
|
-
};
|
|
53
|
-
}
|