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.
Files changed (89) hide show
  1. package/CHANGELOG.md +45 -2
  2. package/lib/cli-peer-dependencies.js +3 -3
  3. package/lib/cli.js +183 -161
  4. package/lib/constants.js +8 -8
  5. package/lib/corePlugins.js +1597 -1518
  6. package/lib/featureFlags.js +9 -9
  7. package/lib/index.js +19 -6
  8. package/lib/lib/cacheInvalidation.js +69 -0
  9. package/lib/lib/collapseAdjacentRules.js +26 -13
  10. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  11. package/lib/lib/defaultExtractor.js +8 -6
  12. package/lib/lib/detectNesting.js +9 -9
  13. package/lib/lib/evaluateTailwindFunctions.js +16 -16
  14. package/lib/lib/expandApplyAtRules.js +180 -27
  15. package/lib/lib/expandTailwindAtRules.js +132 -122
  16. package/lib/lib/generateRules.js +117 -72
  17. package/lib/lib/getModuleDependencies.js +14 -14
  18. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  19. package/lib/lib/partitionApplyAtRules.js +7 -7
  20. package/lib/lib/resolveDefaultsAtRules.js +81 -77
  21. package/lib/lib/setupContextUtils.js +83 -98
  22. package/lib/lib/setupTrackingContext.js +57 -57
  23. package/lib/lib/sharedState.js +11 -7
  24. package/lib/lib/substituteScreenAtRules.js +2 -2
  25. package/lib/postcss-plugins/nesting/README.md +2 -2
  26. package/lib/postcss-plugins/nesting/index.js +1 -1
  27. package/lib/postcss-plugins/nesting/plugin.js +41 -9
  28. package/lib/processTailwindFeatures.js +7 -7
  29. package/lib/public/colors.js +241 -241
  30. package/lib/public/resolve-config.js +5 -5
  31. package/lib/util/buildMediaQuery.js +2 -2
  32. package/lib/util/cloneDeep.js +1 -1
  33. package/lib/util/cloneNodes.js +12 -1
  34. package/lib/util/color.js +21 -20
  35. package/lib/util/createUtilityPlugin.js +6 -6
  36. package/lib/util/dataTypes.js +77 -75
  37. package/lib/util/escapeClassName.js +5 -5
  38. package/lib/util/escapeCommas.js +1 -1
  39. package/lib/util/flattenColorPalette.js +2 -2
  40. package/lib/util/formatVariantSelector.js +19 -19
  41. package/lib/util/getAllConfigs.js +5 -5
  42. package/lib/util/hashConfig.js +5 -5
  43. package/lib/util/isKeyframeRule.js +1 -1
  44. package/lib/util/isPlainObject.js +1 -1
  45. package/lib/util/isValidArbitraryValue.js +27 -27
  46. package/lib/util/log.js +8 -8
  47. package/lib/util/nameClass.js +7 -7
  48. package/lib/util/negateValue.js +4 -4
  49. package/lib/util/normalizeConfig.js +39 -39
  50. package/lib/util/normalizeScreens.js +4 -4
  51. package/lib/util/parseAnimationValue.js +56 -56
  52. package/lib/util/parseBoxShadowValue.js +60 -20
  53. package/lib/util/parseDependency.js +32 -32
  54. package/lib/util/parseObjectStyles.js +6 -6
  55. package/lib/util/pluginUtils.js +9 -9
  56. package/lib/util/prefixSelector.js +1 -1
  57. package/lib/util/resolveConfig.js +28 -28
  58. package/lib/util/resolveConfigPath.js +16 -16
  59. package/lib/util/responsive.js +6 -6
  60. package/lib/util/toColorValue.js +1 -1
  61. package/lib/util/toPath.js +2 -2
  62. package/lib/util/transformThemeValue.js +27 -27
  63. package/lib/util/withAlphaVariable.js +19 -19
  64. package/package.json +26 -25
  65. package/peers/index.js +4803 -4857
  66. package/scripts/generate-types.js +52 -0
  67. package/src/cli.js +41 -11
  68. package/src/corePlugins.js +104 -9
  69. package/src/featureFlags.js +2 -2
  70. package/src/index.js +17 -1
  71. package/src/lib/cacheInvalidation.js +52 -0
  72. package/src/lib/collapseAdjacentRules.js +16 -1
  73. package/src/lib/defaultExtractor.js +6 -4
  74. package/src/lib/expandApplyAtRules.js +179 -6
  75. package/src/lib/expandTailwindAtRules.js +26 -6
  76. package/src/lib/generateRules.js +73 -46
  77. package/src/lib/resolveDefaultsAtRules.js +6 -2
  78. package/src/lib/setupContextUtils.js +39 -48
  79. package/src/lib/setupTrackingContext.js +3 -3
  80. package/src/lib/sharedState.js +2 -0
  81. package/src/postcss-plugins/nesting/README.md +2 -2
  82. package/src/postcss-plugins/nesting/plugin.js +36 -0
  83. package/src/util/cloneNodes.js +14 -1
  84. package/src/util/color.js +7 -5
  85. package/src/util/dataTypes.js +3 -1
  86. package/src/util/log.js +7 -7
  87. package/src/util/parseBoxShadowValue.js +50 -2
  88. package/src/util/resolveConfig.js +32 -0
  89. package/stubs/defaultConfig.stub.js +5 -0
@@ -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 === 'class'
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('-', lastIndex);
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
- return `!${className}`;
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 === 'user') {
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 !== 'rule') {
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 === 'string') {
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 !== '' && url.host !== '';
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: 'utilities'
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
- 'DEFAULT'
378
+ "DEFAULT"
344
379
  ];
345
380
  }
346
- yield* (function*(arbitraryPropertyRule) {
381
+ yield* function*(arbitraryPropertyRule) {
347
382
  if (arbitraryPropertyRule !== null) {
348
383
  yield [
349
384
  arbitraryPropertyRule,
350
- 'DEFAULT'
385
+ "DEFAULT"
351
386
  ];
352
387
  }
353
- })(extractArbitraryProperty(classCandidate, context));
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
- '-DEFAULT'
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
- return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
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 === 'function') {
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 === 'DEFAULT' || modifier === '-DEFAULT') {
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
- // Only keep the result of the very first plugin if we are dealing with
456
- // arbitrary values, to protect against ambiguity.
457
- if (isArbitraryValue(modifier) && matches.length > 1) {
458
- var ref1;
459
- let typesPerPlugin = matches.map((match)=>new Set([
460
- ...(ref1 = typesByMatches.get(match)) !== null && ref1 !== void 0 ? ref1 : []
461
- ])
462
- );
463
- // Remove duplicates, so that we can detect proper unique types for each plugin.
464
- for (let pluginTypes of typesPerPlugin){
465
- for (let type of pluginTypes){
466
- let removeFromOwnGroup = false;
467
- for (let otherGroup of typesPerPlugin){
468
- if (pluginTypes === otherGroup) continue;
469
- if (otherGroup.has(type)) {
470
- otherGroup.delete(type);
471
- removeFromOwnGroup = true;
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
- let messages = [];
478
- for (let [idx, group] of typesPerPlugin.entries()){
479
- for (let type of group){
480
- let rules = matches[idx].map(([, rule])=>rule
481
- ).flat().map((rule)=>rule.toString().split('\n').slice(1, -1) // Remove selector and closing '}'
482
- .map((line)=>line.trim()
483
- ).map((x)=>` ${x}`
484
- ) // Re-indent
485
- .join('\n')
486
- ).join('\n\n');
487
- messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``);
488
- break;
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("[", "&lsqb;").replace("]", "&rsqb;")}\` to silence this warning.`,
536
+ ]);
537
+ continue;
490
538
  }
491
- _log.default.warn([
492
- `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
493
- ...messages,
494
- `If this is content and not a class, replace it with \`${candidate.replace('[', '&lsqb;').replace(']', '&rsqb;')}\` 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, context);
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('&', ...match1[0].collectedFormats);
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 === 'atrule' && rule.parent.name === 'keyframes';
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 === 'rule' && !inKeyframes(d.parent)) {
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 === 'string') {
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('[') && input.endsWith(']');
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('./') || 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 === 'apply') {
12
+ if (atRule.name === "apply") {
18
13
  applyDirectives.add(atRule);
19
14
  }
20
- if (atRule.name === 'import') {
15
+ if (atRule.name === "import") {
21
16
  if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
22
- atRule.name = 'tailwind';
23
- atRule.params = 'base';
17
+ atRule.name = "tailwind";
18
+ atRule.params = "base";
24
19
  } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
25
- atRule.name = 'tailwind';
26
- atRule.params = 'components';
20
+ atRule.name = "tailwind";
21
+ atRule.params = "components";
27
22
  } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
28
- atRule.name = 'tailwind';
29
- atRule.params = 'utilities';
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 = 'tailwind';
32
- atRule.params = 'variants';
26
+ atRule.name = "tailwind";
27
+ atRule.params = "variants";
33
28
  }
34
29
  }
35
- if (atRule.name === 'tailwind') {
36
- if (atRule.params === 'screens') {
37
- atRule.params = 'variants';
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
- 'layer',
43
- 'responsive',
44
- 'variants'
37
+ "layer",
38
+ "responsive",
39
+ "variants"
45
40
  ].includes(atRule.name)) {
46
41
  if ([
47
- 'responsive',
48
- 'variants'
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
- 'https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer',
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('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
54
+ if (!tailwindDirectives.has("base") || !tailwindDirectives.has("components") || !tailwindDirectives.has("utilities")) {
60
55
  for (let rule of layerDirectives){
61
- if (rule.name === 'layer' && [
62
- 'base',
63
- 'components',
64
- 'utilities'
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 === 'responsive') {
70
- if (!tailwindDirectives.has('utilities')) {
71
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
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 === 'variants') {
74
- if (!tailwindDirectives.has('utilities')) {
75
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
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('apply', (rule)=>{
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 === 'atrule' && node.name === 'apply') {
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
- }