tailwindcss 3.0.21 → 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 +45 -2
- package/lib/cli-peer-dependencies.js +3 -3
- package/lib/cli.js +183 -161
- package/lib/constants.js +8 -8
- package/lib/corePlugins.js +1597 -1518
- 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 +8 -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 +117 -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 +83 -98
- package/lib/lib/setupTrackingContext.js +57 -57
- package/lib/lib/sharedState.js +11 -7
- 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 +26 -25
- package/peers/index.js +4803 -4857
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +41 -11
- package/src/corePlugins.js +104 -9
- 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 +6 -4
- package/src/lib/expandApplyAtRules.js +179 -6
- package/src/lib/expandTailwindAtRules.js +26 -6
- package/src/lib/generateRules.js +73 -46
- package/src/lib/resolveDefaultsAtRules.js +6 -2
- package/src/lib/setupContextUtils.js +39 -48
- package/src/lib/setupTrackingContext.js +3 -3
- package/src/lib/sharedState.js +2 -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
|
@@ -10,6 +10,7 @@ var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
|
|
|
10
10
|
var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
11
11
|
var _pluginUtils = require("../util/pluginUtils");
|
|
12
12
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
13
|
+
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
13
14
|
var _formatVariantSelector = require("../util/formatVariantSelector");
|
|
14
15
|
var _nameClass = require("../util/nameClass");
|
|
15
16
|
var _dataTypes = require("../util/dataTypes");
|
|
@@ -19,8 +20,29 @@ function _interopRequireDefault(obj) {
|
|
|
19
20
|
default: obj
|
|
20
21
|
};
|
|
21
22
|
}
|
|
23
|
+
function _interopRequireWildcard(obj) {
|
|
24
|
+
if (obj && obj.__esModule) {
|
|
25
|
+
return obj;
|
|
26
|
+
} else {
|
|
27
|
+
var newObj = {};
|
|
28
|
+
if (obj != null) {
|
|
29
|
+
for(var key in obj){
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
31
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
32
|
+
if (desc.get || desc.set) {
|
|
33
|
+
Object.defineProperty(newObj, key, desc);
|
|
34
|
+
} else {
|
|
35
|
+
newObj[key] = obj[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
newObj.default = obj;
|
|
41
|
+
return newObj;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
22
44
|
let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
|
|
23
|
-
return selectors.first.filter(({ type })=>type ===
|
|
45
|
+
return selectors.first.filter(({ type })=>type === "class"
|
|
24
46
|
).pop().value;
|
|
25
47
|
});
|
|
26
48
|
function getClassNameFromSelector(selector) {
|
|
@@ -37,16 +59,16 @@ function* candidatePermutations(candidate) {
|
|
|
37
59
|
let lastIndex = Infinity;
|
|
38
60
|
while(lastIndex >= 0){
|
|
39
61
|
let dashIdx;
|
|
40
|
-
if (lastIndex === Infinity && candidate.endsWith(
|
|
41
|
-
let bracketIdx = candidate.indexOf(
|
|
62
|
+
if (lastIndex === Infinity && candidate.endsWith("]")) {
|
|
63
|
+
let bracketIdx = candidate.indexOf("[");
|
|
42
64
|
// If character before `[` isn't a dash or a slash, this isn't a dynamic class
|
|
43
65
|
// eg. string[]
|
|
44
66
|
dashIdx = [
|
|
45
|
-
|
|
46
|
-
|
|
67
|
+
"-",
|
|
68
|
+
"/"
|
|
47
69
|
].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
|
|
48
70
|
} else {
|
|
49
|
-
dashIdx = candidate.lastIndexOf(
|
|
71
|
+
dashIdx = candidate.lastIndexOf("-", lastIndex);
|
|
50
72
|
}
|
|
51
73
|
if (dashIdx < 0) {
|
|
52
74
|
break;
|
|
@@ -61,7 +83,7 @@ function* candidatePermutations(candidate) {
|
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
function applyPrefix(matches, context) {
|
|
64
|
-
if (matches.length === 0 || context.tailwindConfig.prefix ===
|
|
86
|
+
if (matches.length === 0 || context.tailwindConfig.prefix === "") {
|
|
65
87
|
return matches;
|
|
66
88
|
}
|
|
67
89
|
for (let match of matches){
|
|
@@ -78,7 +100,7 @@ function applyPrefix(matches, context) {
|
|
|
78
100
|
// have to ensure that the generated selector matches the candidate
|
|
79
101
|
// Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
|
|
80
102
|
// The disconnect between candidate <-> class can cause @apply to hard crash.
|
|
81
|
-
let shouldPrependNegative = classCandidate.startsWith(
|
|
103
|
+
let shouldPrependNegative = classCandidate.startsWith("-");
|
|
82
104
|
r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
|
|
83
105
|
});
|
|
84
106
|
match[1] = container.nodes[0];
|
|
@@ -86,7 +108,7 @@ function applyPrefix(matches, context) {
|
|
|
86
108
|
}
|
|
87
109
|
return matches;
|
|
88
110
|
}
|
|
89
|
-
function applyImportant(matches) {
|
|
111
|
+
function applyImportant(matches, classCandidate) {
|
|
90
112
|
if (matches.length === 0) {
|
|
91
113
|
return matches;
|
|
92
114
|
}
|
|
@@ -99,7 +121,10 @@ function applyImportant(matches) {
|
|
|
99
121
|
});
|
|
100
122
|
container.walkRules((r)=>{
|
|
101
123
|
r.selector = (0, _pluginUtils).updateAllClasses(r.selector, (className)=>{
|
|
102
|
-
|
|
124
|
+
if (className === classCandidate) {
|
|
125
|
+
return `!${className}`;
|
|
126
|
+
}
|
|
127
|
+
return className;
|
|
103
128
|
});
|
|
104
129
|
r.walkDecls((d)=>d.important = true
|
|
105
130
|
);
|
|
@@ -131,7 +156,7 @@ function applyVariant(variant, matches, context) {
|
|
|
131
156
|
let result = [];
|
|
132
157
|
for (let [meta, rule1] of matches){
|
|
133
158
|
// Don't generate variants for user css
|
|
134
|
-
if (meta.layer ===
|
|
159
|
+
if (meta.layer === "user") {
|
|
135
160
|
continue;
|
|
136
161
|
}
|
|
137
162
|
let container = _postcss.default.root({
|
|
@@ -151,7 +176,7 @@ function applyVariant(variant, matches, context) {
|
|
|
151
176
|
function modifySelectors(modifierFunction) {
|
|
152
177
|
prepareBackup();
|
|
153
178
|
clone.each((rule)=>{
|
|
154
|
-
if (rule.type !==
|
|
179
|
+
if (rule.type !== "rule") {
|
|
155
180
|
return;
|
|
156
181
|
}
|
|
157
182
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
@@ -184,7 +209,7 @@ function applyVariant(variant, matches, context) {
|
|
|
184
209
|
collectedFormats.push(selectorFormat);
|
|
185
210
|
}
|
|
186
211
|
});
|
|
187
|
-
if (typeof ruleWithVariant ===
|
|
212
|
+
if (typeof ruleWithVariant === "string") {
|
|
188
213
|
collectedFormats.push(ruleWithVariant);
|
|
189
214
|
}
|
|
190
215
|
if (ruleWithVariant === null) {
|
|
@@ -219,7 +244,7 @@ function applyVariant(variant, matches, context) {
|
|
|
219
244
|
// modified (by plugin): .foo .foo\\:markdown > p
|
|
220
245
|
// rebuiltBase (internal): .foo\\:markdown > p
|
|
221
246
|
// format: .foo &
|
|
222
|
-
collectedFormats.push(modified.replace(rebuiltBase,
|
|
247
|
+
collectedFormats.push(modified.replace(rebuiltBase, "&"));
|
|
223
248
|
rule.selector = before;
|
|
224
249
|
});
|
|
225
250
|
}
|
|
@@ -280,17 +305,27 @@ function isValidPropName(name) {
|
|
|
280
305
|
*/ function looksLikeUri(declaration) {
|
|
281
306
|
// Quick bailout for obvious non-urls
|
|
282
307
|
// This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
|
|
283
|
-
if (!declaration.includes(
|
|
308
|
+
if (!declaration.includes("://")) {
|
|
284
309
|
return false;
|
|
285
310
|
}
|
|
286
311
|
try {
|
|
287
312
|
const url = new URL(declaration);
|
|
288
|
-
return url.scheme !==
|
|
313
|
+
return url.scheme !== "" && url.host !== "";
|
|
289
314
|
} catch (err) {
|
|
290
315
|
// Definitely not a valid url
|
|
291
316
|
return false;
|
|
292
317
|
}
|
|
293
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
|
+
}
|
|
294
329
|
function isParsableCssValue(property, value) {
|
|
295
330
|
// We don't want to to treat [https://example.com] as a custom property
|
|
296
331
|
// Even though, according to the CSS grammar, it's a totally valid CSS declaration
|
|
@@ -325,7 +360,7 @@ function extractArbitraryProperty(classCandidate, context) {
|
|
|
325
360
|
[
|
|
326
361
|
{
|
|
327
362
|
sort: context.arbitraryPropertiesSort,
|
|
328
|
-
layer:
|
|
363
|
+
layer: "utilities"
|
|
329
364
|
},
|
|
330
365
|
()=>({
|
|
331
366
|
[(0, _nameClass).asClass(classCandidate)]: {
|
|
@@ -340,29 +375,29 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
340
375
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
341
376
|
yield [
|
|
342
377
|
context.candidateRuleMap.get(classCandidate),
|
|
343
|
-
|
|
378
|
+
"DEFAULT"
|
|
344
379
|
];
|
|
345
380
|
}
|
|
346
|
-
yield*
|
|
381
|
+
yield* function*(arbitraryPropertyRule) {
|
|
347
382
|
if (arbitraryPropertyRule !== null) {
|
|
348
383
|
yield [
|
|
349
384
|
arbitraryPropertyRule,
|
|
350
|
-
|
|
385
|
+
"DEFAULT"
|
|
351
386
|
];
|
|
352
387
|
}
|
|
353
|
-
}
|
|
388
|
+
}(extractArbitraryProperty(classCandidate, context));
|
|
354
389
|
let candidatePrefix = classCandidate;
|
|
355
390
|
let negative = false;
|
|
356
391
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
357
392
|
const twConfigPrefixLen = twConfigPrefix.length;
|
|
358
|
-
if (candidatePrefix[twConfigPrefixLen] ===
|
|
393
|
+
if (candidatePrefix[twConfigPrefixLen] === "-") {
|
|
359
394
|
negative = true;
|
|
360
395
|
candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
|
|
361
396
|
}
|
|
362
397
|
if (negative && context.candidateRuleMap.has(candidatePrefix)) {
|
|
363
398
|
yield [
|
|
364
399
|
context.candidateRuleMap.get(candidatePrefix),
|
|
365
|
-
|
|
400
|
+
"-DEFAULT"
|
|
366
401
|
];
|
|
367
402
|
}
|
|
368
403
|
for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
|
|
@@ -375,7 +410,12 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
375
410
|
}
|
|
376
411
|
}
|
|
377
412
|
function splitWithSeparator(input, separator) {
|
|
378
|
-
|
|
413
|
+
if (input === sharedState.NOT_ON_DEMAND) {
|
|
414
|
+
return [
|
|
415
|
+
sharedState.NOT_ON_DEMAND
|
|
416
|
+
];
|
|
417
|
+
}
|
|
418
|
+
return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, "g"));
|
|
379
419
|
}
|
|
380
420
|
function* recordCandidates(matches, classCandidate) {
|
|
381
421
|
for (const match of matches){
|
|
@@ -390,7 +430,7 @@ function* resolveMatches(candidate, context) {
|
|
|
390
430
|
let separator = context.tailwindConfig.separator;
|
|
391
431
|
let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
|
|
392
432
|
let important = false;
|
|
393
|
-
if (classCandidate.startsWith(
|
|
433
|
+
if (classCandidate.startsWith("!")) {
|
|
394
434
|
important = true;
|
|
395
435
|
classCandidate = classCandidate.slice(1);
|
|
396
436
|
}
|
|
@@ -412,7 +452,7 @@ function* resolveMatches(candidate, context) {
|
|
|
412
452
|
let isOnlyPlugin = plugins.length === 1;
|
|
413
453
|
for (let [sort, plugin] of plugins){
|
|
414
454
|
let matchesPerPlugin = [];
|
|
415
|
-
if (typeof plugin ===
|
|
455
|
+
if (typeof plugin === "function") {
|
|
416
456
|
for (let ruleSet of [].concat(plugin(modifier, {
|
|
417
457
|
isOnlyPlugin
|
|
418
458
|
}))){
|
|
@@ -430,7 +470,7 @@ function* resolveMatches(candidate, context) {
|
|
|
430
470
|
]);
|
|
431
471
|
}
|
|
432
472
|
}
|
|
433
|
-
} else if (modifier ===
|
|
473
|
+
} else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
|
|
434
474
|
let ruleSet = plugin;
|
|
435
475
|
let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
|
|
436
476
|
for (let rule of rules){
|
|
@@ -452,54 +492,59 @@ function* resolveMatches(candidate, context) {
|
|
|
452
492
|
matches.push(matchesPerPlugin);
|
|
453
493
|
}
|
|
454
494
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
for (let
|
|
466
|
-
let
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
otherGroup.
|
|
471
|
-
|
|
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
|
+
}
|
|
472
514
|
}
|
|
515
|
+
if (removeFromOwnGroup) pluginTypes.delete(type);
|
|
473
516
|
}
|
|
474
|
-
if (removeFromOwnGroup) pluginTypes.delete(type);
|
|
475
517
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
.join(
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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
|
+
}
|
|
489
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;
|
|
490
538
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
`If this is content and not a class, replace it with \`${candidate.replace('[', '[').replace(']', ']')}\` to silence this warning.`,
|
|
495
|
-
]);
|
|
496
|
-
continue;
|
|
539
|
+
matches = matches.map((list)=>list.filter((match)=>isParsableNode(match[1])
|
|
540
|
+
)
|
|
541
|
+
);
|
|
497
542
|
}
|
|
498
543
|
matches = matches.flat();
|
|
499
544
|
matches = Array.from(recordCandidates(matches, classCandidate));
|
|
500
545
|
matches = applyPrefix(matches, context);
|
|
501
546
|
if (important) {
|
|
502
|
-
matches = applyImportant(matches,
|
|
547
|
+
matches = applyImportant(matches, classCandidate);
|
|
503
548
|
}
|
|
504
549
|
for (let variant of variants){
|
|
505
550
|
matches = applyVariant(variant, matches, context);
|
|
@@ -511,7 +556,7 @@ function* resolveMatches(candidate, context) {
|
|
|
511
556
|
};
|
|
512
557
|
// Apply final format selector
|
|
513
558
|
if (match1[0].collectedFormats) {
|
|
514
|
-
let finalFormat = (0, _formatVariantSelector).formatVariantSelector(
|
|
559
|
+
let finalFormat = (0, _formatVariantSelector).formatVariantSelector("&", ...match1[0].collectedFormats);
|
|
515
560
|
let container = _postcss.default.root({
|
|
516
561
|
nodes: [
|
|
517
562
|
match1[1].clone()
|
|
@@ -531,8 +576,9 @@ function* resolveMatches(candidate, context) {
|
|
|
531
576
|
}
|
|
532
577
|
}
|
|
533
578
|
}
|
|
579
|
+
exports.resolveMatches = resolveMatches;
|
|
534
580
|
function inKeyframes(rule) {
|
|
535
|
-
return rule.parent && rule.parent.type ===
|
|
581
|
+
return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
|
|
536
582
|
}
|
|
537
583
|
function generateRules(candidates, context) {
|
|
538
584
|
let allRules = [];
|
|
@@ -557,13 +603,13 @@ function generateRules(candidates, context) {
|
|
|
557
603
|
if (important === true) {
|
|
558
604
|
return (rule)=>{
|
|
559
605
|
rule.walkDecls((d)=>{
|
|
560
|
-
if (d.parent.type ===
|
|
606
|
+
if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
|
|
561
607
|
d.important = true;
|
|
562
608
|
}
|
|
563
609
|
});
|
|
564
610
|
};
|
|
565
611
|
}
|
|
566
|
-
if (typeof important ===
|
|
612
|
+
if (typeof important === "string") {
|
|
567
613
|
return (rule)=>{
|
|
568
614
|
rule.selectors = rule.selectors.map((selector)=>{
|
|
569
615
|
return `${important} ${selector}`;
|
|
@@ -594,8 +640,7 @@ function generateRules(candidates, context) {
|
|
|
594
640
|
];
|
|
595
641
|
});
|
|
596
642
|
}
|
|
643
|
+
exports.generateRules = generateRules;
|
|
597
644
|
function isArbitraryValue(input) {
|
|
598
|
-
return input.startsWith(
|
|
645
|
+
return input.startsWith("[") && input.endsWith("]");
|
|
599
646
|
}
|
|
600
|
-
exports.resolveMatches = resolveMatches;
|
|
601
|
-
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
|
-
}
|