tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421

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 (137) hide show
  1. package/README.md +1 -2
  2. package/lib/cli/build/deps.js +62 -0
  3. package/lib/cli/build/index.js +12 -15
  4. package/lib/cli/build/plugin.js +107 -167
  5. package/lib/cli/build/utils.js +13 -13
  6. package/lib/cli/build/watching.js +10 -10
  7. package/lib/cli/help/index.js +11 -11
  8. package/lib/cli/index.js +60 -61
  9. package/lib/cli/init/index.js +16 -16
  10. package/lib/cli-peer-dependencies.js +36 -0
  11. package/lib/cli.js +1 -1
  12. package/lib/corePluginList.js +4 -1
  13. package/lib/corePlugins.js +2018 -1905
  14. package/lib/css/preflight.css +18 -12
  15. package/lib/featureFlags.js +17 -23
  16. package/lib/index.js +1 -1
  17. package/lib/lib/cacheInvalidation.js +3 -3
  18. package/lib/lib/collapseAdjacentRules.js +6 -6
  19. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  20. package/lib/lib/content.js +39 -32
  21. package/lib/lib/defaultExtractor.js +40 -17
  22. package/lib/lib/evaluateTailwindFunctions.js +23 -23
  23. package/lib/lib/expandApplyAtRules.js +37 -18
  24. package/lib/lib/expandTailwindAtRules.js +49 -85
  25. package/lib/lib/findAtConfigPath.js +5 -5
  26. package/lib/lib/generateRules.js +82 -55
  27. package/lib/lib/getModuleDependencies.js +23 -23
  28. package/lib/lib/load-config.js +21 -6
  29. package/lib/lib/normalizeTailwindDirectives.js +36 -21
  30. package/lib/lib/offsets.js +97 -48
  31. package/lib/lib/partitionApplyAtRules.js +2 -2
  32. package/lib/lib/regex.js +5 -5
  33. package/lib/lib/resolveDefaultsAtRules.js +27 -25
  34. package/lib/lib/setupContextUtils.js +195 -167
  35. package/lib/lib/setupTrackingContext.js +4 -5
  36. package/lib/lib/sharedState.js +10 -10
  37. package/lib/lib/substituteScreenAtRules.js +4 -4
  38. package/lib/plugin.js +8 -124
  39. package/lib/postcss-plugins/nesting/index.js +2 -2
  40. package/lib/postcss-plugins/nesting/plugin.js +11 -11
  41. package/lib/processTailwindFeatures.js +3 -5
  42. package/lib/public/colors.js +264 -264
  43. package/lib/util/applyImportantSelector.js +2 -2
  44. package/lib/util/buildMediaQuery.js +2 -2
  45. package/lib/util/cloneDeep.js +1 -1
  46. package/lib/util/cloneNodes.js +33 -13
  47. package/lib/util/color.js +19 -19
  48. package/lib/util/createUtilityPlugin.js +3 -3
  49. package/lib/util/dataTypes.js +170 -113
  50. package/lib/util/defaults.js +4 -4
  51. package/lib/util/escapeClassName.js +2 -2
  52. package/lib/util/escapeCommas.js +1 -1
  53. package/lib/util/flattenColorPalette.js +2 -2
  54. package/lib/util/formatVariantSelector.js +24 -19
  55. package/lib/util/getAllConfigs.js +4 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +2 -2
  58. package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
  59. package/lib/util/log.js +6 -23
  60. package/lib/util/nameClass.js +4 -4
  61. package/lib/util/negateValue.js +8 -8
  62. package/lib/util/normalizeConfig.js +63 -94
  63. package/lib/util/normalizeScreens.js +18 -18
  64. package/lib/util/parseAnimationValue.js +38 -38
  65. package/lib/util/parseBoxShadowValue.js +18 -18
  66. package/lib/util/parseDependency.js +4 -4
  67. package/lib/util/parseGlob.js +4 -4
  68. package/lib/util/parseObjectStyles.js +1 -1
  69. package/lib/util/pluginUtils.js +36 -21
  70. package/lib/util/prefixSelector.js +4 -4
  71. package/lib/util/pseudoElements.js +72 -69
  72. package/lib/util/removeAlphaVariables.js +1 -1
  73. package/lib/util/resolveConfig.js +11 -15
  74. package/lib/util/resolveConfigPath.js +6 -6
  75. package/lib/util/responsive.js +1 -1
  76. package/lib/util/splitAtTopLevelOnly.js +3 -3
  77. package/lib/util/toColorValue.js +1 -1
  78. package/lib/util/toPath.js +2 -2
  79. package/lib/util/transformThemeValue.js +24 -24
  80. package/lib/util/validateConfig.js +9 -20
  81. package/lib/util/validateFormalSyntax.js +5 -5
  82. package/lib/util/withAlphaVariable.js +5 -5
  83. package/lib/value-parser/index.js +5 -5
  84. package/lib/value-parser/parse.js +43 -43
  85. package/lib/value-parser/stringify.js +11 -11
  86. package/lib/value-parser/unit.js +5 -5
  87. package/lib/value-parser/walk.js +1 -1
  88. package/nesting/index.d.ts +4 -0
  89. package/package.json +41 -36
  90. package/peers/index.js +96503 -0
  91. package/resolveConfig.d.ts +22 -3
  92. package/scripts/generate-types.js +1 -2
  93. package/scripts/release-notes.js +1 -1
  94. package/src/cli/build/deps.js +56 -0
  95. package/src/cli/build/index.js +0 -4
  96. package/src/cli/build/plugin.js +53 -85
  97. package/src/cli/build/watching.js +1 -1
  98. package/src/cli/index.js +0 -1
  99. package/src/cli-peer-dependencies.js +15 -0
  100. package/src/corePluginList.js +1 -1
  101. package/src/corePlugins.js +118 -31
  102. package/src/css/preflight.css +18 -12
  103. package/src/featureFlags.js +3 -5
  104. package/src/lib/content.js +39 -30
  105. package/src/lib/defaultExtractor.js +29 -6
  106. package/src/lib/expandApplyAtRules.js +24 -0
  107. package/src/lib/expandTailwindAtRules.js +19 -56
  108. package/src/lib/generateRules.js +39 -8
  109. package/src/lib/load-config.ts +13 -0
  110. package/src/lib/normalizeTailwindDirectives.js +27 -0
  111. package/src/lib/offsets.js +62 -3
  112. package/src/lib/resolveDefaultsAtRules.js +5 -1
  113. package/src/lib/setupContextUtils.js +79 -39
  114. package/src/plugin.js +0 -86
  115. package/src/processTailwindFeatures.js +0 -3
  116. package/src/util/cloneNodes.js +35 -14
  117. package/src/util/dataTypes.js +72 -6
  118. package/src/util/formatVariantSelector.js +7 -0
  119. package/src/util/isPlainObject.js +1 -1
  120. package/src/util/log.js +0 -24
  121. package/src/util/normalizeConfig.js +11 -38
  122. package/src/util/pluginUtils.js +20 -0
  123. package/src/util/pseudoElements.js +4 -0
  124. package/src/util/validateConfig.js +0 -10
  125. package/stubs/config.full.js +68 -8
  126. package/stubs/config.simple.js +1 -1
  127. package/stubs/postcss.config.cjs +1 -0
  128. package/stubs/postcss.config.js +1 -0
  129. package/types/config.d.ts +12 -5
  130. package/types/generated/corePluginList.d.ts +1 -1
  131. package/types/generated/default-theme.d.ts +28 -9
  132. package/types/index.d.ts +7 -3
  133. package/index.css +0 -5
  134. package/lib/lib/detectNesting.js +0 -45
  135. package/lib/lib/handleImportAtRules.js +0 -50
  136. package/src/lib/detectNesting.js +0 -47
  137. package/src/lib/handleImportAtRules.js +0 -34
@@ -33,6 +33,7 @@ const _dataTypes = require("../util/dataTypes");
33
33
  const _setupContextUtils = require("./setupContextUtils");
34
34
  const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
35
35
  const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
36
+ const _featureFlags = require("../featureFlags");
36
37
  const _applyImportantSelector = require("../util/applyImportantSelector");
37
38
  function _interop_require_default(obj) {
38
39
  return obj && obj.__esModule ? obj : {
@@ -79,7 +80,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
79
80
  return newObj;
80
81
  }
81
82
  let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
82
- return selectors.first.filter(({ type })=>type === 'class').pop().value;
83
+ return selectors.first.filter(({ type })=>type === "class").pop().value;
83
84
  });
84
85
  function getClassNameFromSelector(selector) {
85
86
  return classNameParser.transformSync(selector);
@@ -96,23 +97,23 @@ function* candidatePermutations(candidate) {
96
97
  while(lastIndex >= 0){
97
98
  let dashIdx;
98
99
  let wasSlash = false;
99
- if (lastIndex === Infinity && candidate.endsWith(']')) {
100
- let bracketIdx = candidate.indexOf('[');
100
+ if (lastIndex === Infinity && candidate.endsWith("]")) {
101
+ let bracketIdx = candidate.indexOf("[");
101
102
  // If character before `[` isn't a dash or a slash, this isn't a dynamic class
102
- // e.g. string[]
103
- if (candidate[bracketIdx - 1] === '-') {
103
+ // eg. string[]
104
+ if (candidate[bracketIdx - 1] === "-") {
104
105
  dashIdx = bracketIdx - 1;
105
- } else if (candidate[bracketIdx - 1] === '/') {
106
+ } else if (candidate[bracketIdx - 1] === "/") {
106
107
  dashIdx = bracketIdx - 1;
107
108
  wasSlash = true;
108
109
  } else {
109
110
  dashIdx = -1;
110
111
  }
111
- } else if (lastIndex === Infinity && candidate.includes('/')) {
112
- dashIdx = candidate.lastIndexOf('/');
112
+ } else if (lastIndex === Infinity && candidate.includes("/")) {
113
+ dashIdx = candidate.lastIndexOf("/");
113
114
  wasSlash = true;
114
115
  } else {
115
- dashIdx = candidate.lastIndexOf('-', lastIndex);
116
+ dashIdx = candidate.lastIndexOf("-", lastIndex);
116
117
  }
117
118
  if (dashIdx < 0) {
118
119
  break;
@@ -121,7 +122,7 @@ function* candidatePermutations(candidate) {
121
122
  let modifier = candidate.slice(wasSlash ? dashIdx : dashIdx + 1);
122
123
  lastIndex = dashIdx - 1;
123
124
  // TODO: This feels a bit hacky
124
- if (prefix === '' || modifier === '/') {
125
+ if (prefix === "" || modifier === "/") {
125
126
  continue;
126
127
  }
127
128
  yield [
@@ -131,7 +132,7 @@ function* candidatePermutations(candidate) {
131
132
  }
132
133
  }
133
134
  function applyPrefix(matches, context) {
134
- if (matches.length === 0 || context.tailwindConfig.prefix === '') {
135
+ if (matches.length === 0 || context.tailwindConfig.prefix === "") {
135
136
  return matches;
136
137
  }
137
138
  for (let match of matches){
@@ -148,7 +149,7 @@ function applyPrefix(matches, context) {
148
149
  // have to ensure that the generated selector matches the candidate
149
150
  // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
150
151
  // The disconnect between candidate <-> class can cause @apply to hard crash.
151
- let shouldPrependNegative = classCandidate.startsWith('-');
152
+ let shouldPrependNegative = classCandidate.startsWith("-");
152
153
  r.selector = (0, _prefixSelector.default)(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
153
154
  });
154
155
  match[1] = container.nodes[0];
@@ -161,6 +162,9 @@ function applyImportant(matches, classCandidate) {
161
162
  return matches;
162
163
  }
163
164
  let result = [];
165
+ function isInKeyframes(rule) {
166
+ return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
167
+ }
164
168
  for (let [meta, rule] of matches){
165
169
  let container = _postcss.default.root({
166
170
  nodes: [
@@ -168,6 +172,11 @@ function applyImportant(matches, classCandidate) {
168
172
  ]
169
173
  });
170
174
  container.walkRules((r)=>{
175
+ // Declarations inside keyframes cannot be marked as important
176
+ // They will be ignored by the browser
177
+ if (isInKeyframes(r)) {
178
+ return;
179
+ }
171
180
  let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
172
181
  // Remove extraneous selectors that do not include the base candidate
173
182
  ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
@@ -204,20 +213,23 @@ function applyVariant(variant, matches, context) {
204
213
  };
205
214
  // Retrieve "modifier"
206
215
  {
207
- let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, '/');
216
+ let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
208
217
  // This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
209
218
  // In this case 1/10 is a value but /20 is a modifier
210
219
  if (modifiers.length > 1) {
211
- baseVariant = baseVariant + '/' + modifiers.slice(0, -1).join('/');
220
+ baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
212
221
  modifiers = modifiers.slice(-1);
213
222
  }
214
223
  if (modifiers.length && !context.variantMap.has(variant)) {
215
224
  variant = baseVariant;
216
225
  args.modifier = modifiers[0];
226
+ if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
227
+ return [];
228
+ }
217
229
  }
218
230
  }
219
231
  // Retrieve "arbitrary value"
220
- if (variant.endsWith(']') && !variant.startsWith('[')) {
232
+ if (variant.endsWith("]") && !variant.startsWith("[")) {
221
233
  // We either have:
222
234
  // @[200px]
223
235
  // group-[:hover]
@@ -229,10 +241,10 @@ function applyVariant(variant, matches, context) {
229
241
  if (match) {
230
242
  let [, char, separator, value] = match;
231
243
  // @-[200px] case
232
- if (char === '@' && separator === '-') return [];
244
+ if (char === "@" && separator === "-") return [];
233
245
  // group[:hover] case
234
- if (char !== '@' && separator === '') return [];
235
- variant = variant.replace(`${separator}[${value}]`, '');
246
+ if (char !== "@" && separator === "") return [];
247
+ variant = variant.replace(`${separator}[${value}]`, "");
236
248
  args.value = value;
237
249
  }
238
250
  }
@@ -240,7 +252,7 @@ function applyVariant(variant, matches, context) {
240
252
  if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
241
253
  let sort = context.offsets.recordVariant(variant);
242
254
  let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
243
- let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ',');
255
+ let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
244
256
  // We do not support multiple selectors for arbitrary variants
245
257
  if (selectors.length > 1) {
246
258
  return [];
@@ -268,7 +280,7 @@ function applyVariant(variant, matches, context) {
268
280
  })();
269
281
  for (let [meta, rule] of matches){
270
282
  // Don't generate variants for user css
271
- if (meta.layer === 'user') {
283
+ if (meta.layer === "user") {
272
284
  continue;
273
285
  }
274
286
  let container = _postcss.default.root({
@@ -290,7 +302,7 @@ function applyVariant(variant, matches, context) {
290
302
  function modifySelectors(modifierFunction) {
291
303
  prepareBackup();
292
304
  clone.each((rule)=>{
293
- if (rule.type !== 'rule') {
305
+ if (rule.type !== "rule") {
294
306
  return;
295
307
  }
296
308
  rule.selectors = rule.selectors.map((selector)=>{
@@ -345,7 +357,7 @@ function applyVariant(variant, matches, context) {
345
357
  }
346
358
  continue;
347
359
  }
348
- if (typeof ruleWithVariant === 'string') {
360
+ if (typeof ruleWithVariant === "string") {
349
361
  collectedFormats.push({
350
362
  format: ruleWithVariant,
351
363
  respectPrefix
@@ -386,7 +398,7 @@ function applyVariant(variant, matches, context) {
386
398
  // rebuiltBase (internal): .foo\\:markdown > p
387
399
  // format: .foo &
388
400
  collectedFormats.push({
389
- format: modified.replace(rebuiltBase, '&'),
401
+ format: modified.replace(rebuiltBase, "&"),
390
402
  respectPrefix
391
403
  });
392
404
  rule.selector = before;
@@ -449,12 +461,12 @@ function isValidPropName(name) {
449
461
  */ function looksLikeUri(declaration) {
450
462
  // Quick bailout for obvious non-urls
451
463
  // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
452
- if (!declaration.includes('://')) {
464
+ if (!declaration.includes("://")) {
453
465
  return false;
454
466
  }
455
467
  try {
456
468
  const url = new URL(declaration);
457
- return url.scheme !== '' && url.host !== '';
469
+ return url.scheme !== "" && url.host !== "";
458
470
  } catch (err) {
459
471
  // Definitely not a valid url
460
472
  return false;
@@ -471,9 +483,9 @@ function isParsableNode(node) {
471
483
  return isParsable;
472
484
  }
473
485
  function isParsableCssValue(property, value) {
474
- // We don't want to treat [https://example.com] as a custom property
486
+ // We don't want to to treat [https://example.com] as a custom property
475
487
  // Even though, according to the CSS grammar, it's a totally valid CSS declaration
476
- // So we short-circuit here by checking if the custom property looks like a URL
488
+ // So we short-circuit here by checking if the custom property looks like a url
477
489
  if (looksLikeUri(`${property}:${value}`)) {
478
490
  return false;
479
491
  }
@@ -496,16 +508,18 @@ function extractArbitraryProperty(classCandidate, context) {
496
508
  if (!(0, _isSyntacticallyValidPropertyValue.default)(value)) {
497
509
  return null;
498
510
  }
499
- let normalized = (0, _dataTypes.normalize)(value);
511
+ let normalized = (0, _dataTypes.normalize)(value, {
512
+ property
513
+ });
500
514
  if (!isParsableCssValue(property, normalized)) {
501
515
  return null;
502
516
  }
503
- let sort = context.offsets.arbitraryProperty();
517
+ let sort = context.offsets.arbitraryProperty(classCandidate);
504
518
  return [
505
519
  [
506
520
  {
507
521
  sort,
508
- layer: 'utilities'
522
+ layer: "utilities"
509
523
  },
510
524
  ()=>({
511
525
  [(0, _nameClass.asClass)(classCandidate)]: {
@@ -519,14 +533,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
519
533
  if (context.candidateRuleMap.has(classCandidate)) {
520
534
  yield [
521
535
  context.candidateRuleMap.get(classCandidate),
522
- 'DEFAULT'
536
+ "DEFAULT"
523
537
  ];
524
538
  }
525
539
  yield* function*(arbitraryPropertyRule) {
526
540
  if (arbitraryPropertyRule !== null) {
527
541
  yield [
528
542
  arbitraryPropertyRule,
529
- 'DEFAULT'
543
+ "DEFAULT"
530
544
  ];
531
545
  }
532
546
  }(extractArbitraryProperty(classCandidate, context));
@@ -535,14 +549,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
535
549
  const twConfigPrefix = context.tailwindConfig.prefix;
536
550
  const twConfigPrefixLen = twConfigPrefix.length;
537
551
  const hasMatchingPrefix = candidatePrefix.startsWith(twConfigPrefix) || candidatePrefix.startsWith(`-${twConfigPrefix}`);
538
- if (candidatePrefix[twConfigPrefixLen] === '-' && hasMatchingPrefix) {
552
+ if (candidatePrefix[twConfigPrefixLen] === "-" && hasMatchingPrefix) {
539
553
  negative = true;
540
554
  candidatePrefix = twConfigPrefix + candidatePrefix.slice(twConfigPrefixLen + 1);
541
555
  }
542
556
  if (negative && context.candidateRuleMap.has(candidatePrefix)) {
543
557
  yield [
544
558
  context.candidateRuleMap.get(candidatePrefix),
545
- '-DEFAULT'
559
+ "-DEFAULT"
546
560
  ];
547
561
  }
548
562
  for (let [prefix, modifier] of candidatePermutations(candidatePrefix)){
@@ -578,7 +592,7 @@ function* resolveMatches(candidate, context) {
578
592
  let separator = context.tailwindConfig.separator;
579
593
  let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
580
594
  let important = false;
581
- if (classCandidate.startsWith('!')) {
595
+ if (classCandidate.startsWith("!")) {
582
596
  important = true;
583
597
  classCandidate = classCandidate.slice(1);
584
598
  }
@@ -600,7 +614,7 @@ function* resolveMatches(candidate, context) {
600
614
  let isOnlyPlugin = plugins.length === 1;
601
615
  for (let [sort, plugin] of plugins){
602
616
  let matchesPerPlugin = [];
603
- if (typeof plugin === 'function') {
617
+ if (typeof plugin === "function") {
604
618
  for (let ruleSet of [].concat(plugin(modifier, {
605
619
  isOnlyPlugin
606
620
  }))){
@@ -618,7 +632,7 @@ function* resolveMatches(candidate, context) {
618
632
  ]);
619
633
  }
620
634
  }
621
- } else if (modifier === 'DEFAULT' || modifier === '-DEFAULT') {
635
+ } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
622
636
  let ruleSet = plugin;
623
637
  let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
624
638
  for (let rule of rules){
@@ -649,7 +663,7 @@ function* resolveMatches(candidate, context) {
649
663
  // Partition plugins in 2 categories so that we can start searching in the plugins that
650
664
  // don't have `any` as a type first.
651
665
  let [withAny, withoutAny] = matches.reduce((group, plugin)=>{
652
- let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === 'any'));
666
+ let hasAnyType = plugin.some(([{ options }])=>options.types.some(({ type })=>type === "any"));
653
667
  if (hasAnyType) {
654
668
  group[0].push(plugin);
655
669
  } else {
@@ -669,11 +683,11 @@ function* resolveMatches(candidate, context) {
669
683
  // also has the correct type which preferOnConflicts the plugin in case of clashes.
670
684
  return matches.find((rules)=>{
671
685
  let matchingTypes = typesByMatches.get(rules);
672
- return rules.some(([{ options }, rule])=>{
686
+ return rules.some(([{ options }, rule])=>{
673
687
  if (!isParsableNode(rule)) {
674
688
  return false;
675
689
  }
676
- return options.types.some(({ type, preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
690
+ return options.types.some(({ type , preferOnConflict })=>matchingTypes.includes(type) && preferOnConflict);
677
691
  });
678
692
  });
679
693
  }
@@ -707,17 +721,17 @@ function* resolveMatches(candidate, context) {
707
721
  let messages = [];
708
722
  for (let [idx, group] of typesPerPlugin.entries()){
709
723
  for (let type of group){
710
- let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split('\n').slice(1, -1) // Remove selector and closing '}'
724
+ let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
711
725
  .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
712
- .join('\n')).join('\n\n');
713
- messages.push(` Use \`${candidate.replace('[', `[${type}:`)}\` for \`${rules.trim()}\``);
726
+ .join("\n")).join("\n\n");
727
+ messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
714
728
  break;
715
729
  }
716
730
  }
717
731
  _log.default.warn([
718
732
  `The class \`${candidate}\` is ambiguous and matches multiple utilities.`,
719
733
  ...messages,
720
- `If this is content and not a class, replace it with \`${candidate.replace('[', '&lsqb;').replace(']', '&rsqb;')}\` to silence this warning.`
734
+ `If this is content and not a class, replace it with \`${candidate.replace("[", "&lsqb;").replace("]", "&rsqb;")}\` to silence this warning.`
721
735
  ]);
722
736
  continue;
723
737
  }
@@ -753,7 +767,7 @@ function* resolveMatches(candidate, context) {
753
767
  }
754
768
  }
755
769
  }
756
- function applyFinalFormat(match, { context, candidate }) {
770
+ function applyFinalFormat(match, { context , candidate }) {
757
771
  if (!match[0].collectedFormats) {
758
772
  return match;
759
773
  }
@@ -764,7 +778,7 @@ function applyFinalFormat(match, { context, candidate }) {
764
778
  context,
765
779
  candidate
766
780
  });
767
- } catch (e) {
781
+ } catch {
768
782
  // The format selector we produced is invalid
769
783
  // This could be because:
770
784
  // - A bug exists
@@ -786,11 +800,18 @@ function applyFinalFormat(match, { context, candidate }) {
786
800
  return;
787
801
  }
788
802
  try {
789
- rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
803
+ let selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
790
804
  candidate,
791
805
  context
792
806
  });
793
- } catch (e) {
807
+ // Finalize Selector determined that this candidate is irrelevant
808
+ // TODO: This elimination should happen earlier so this never happens
809
+ if (selector === null) {
810
+ rule.remove();
811
+ return;
812
+ }
813
+ rule.selector = selector;
814
+ } catch {
794
815
  // If this selector is invalid we also want to skip it
795
816
  // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
796
817
  isValid = false;
@@ -800,11 +821,15 @@ function applyFinalFormat(match, { context, candidate }) {
800
821
  if (!isValid) {
801
822
  return null;
802
823
  }
824
+ // If all rules have been eliminated we can skip this candidate entirely
825
+ if (container.nodes.length === 0) {
826
+ return null;
827
+ }
803
828
  match[1] = container.nodes[0];
804
829
  return match;
805
830
  }
806
831
  function inKeyframes(rule) {
807
- return rule.parent && rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
832
+ return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
808
833
  }
809
834
  function getImportantStrategy(important) {
810
835
  if (important === true) {
@@ -813,13 +838,13 @@ function getImportantStrategy(important) {
813
838
  return;
814
839
  }
815
840
  rule.walkDecls((d)=>{
816
- if (d.parent.type === 'rule' && !inKeyframes(d.parent)) {
841
+ if (d.parent.type === "rule" && !inKeyframes(d.parent)) {
817
842
  d.important = true;
818
843
  }
819
844
  });
820
845
  };
821
846
  }
822
- if (typeof important === 'string') {
847
+ if (typeof important === "string") {
823
848
  return (rule)=>{
824
849
  if (inKeyframes(rule)) {
825
850
  return;
@@ -830,7 +855,7 @@ function getImportantStrategy(important) {
830
855
  };
831
856
  }
832
857
  }
833
- function generateRules(candidates, context) {
858
+ function generateRules(candidates, context, isSorting = false) {
834
859
  let allRules = [];
835
860
  let strategy = getImportantStrategy(context.tailwindConfig.important);
836
861
  for (let candidate of candidates){
@@ -851,7 +876,7 @@ function generateRules(candidates, context) {
851
876
  let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
852
877
  context.candidateRuleCache.set(candidate, rules);
853
878
  for (const match of matches){
854
- let [{ sort, options }, rule] = match;
879
+ let [{ sort , options }, rule] = match;
855
880
  if (options.respectImportant && strategy) {
856
881
  let container = _postcss.default.root({
857
882
  nodes: [
@@ -861,9 +886,11 @@ function generateRules(candidates, context) {
861
886
  container.walkRules(strategy);
862
887
  rule = container.nodes[0];
863
888
  }
889
+ // Note: We have to clone rules during sorting
890
+ // so we eliminate some shared mutable state
864
891
  let newEntry = [
865
892
  sort,
866
- rule
893
+ isSorting ? rule.clone() : rule
867
894
  ];
868
895
  rules.add(newEntry);
869
896
  context.ruleCache.add(newEntry);
@@ -873,5 +900,5 @@ function generateRules(candidates, context) {
873
900
  return allRules;
874
901
  }
875
902
  function isArbitraryValue(input) {
876
- return input.startsWith('[') && input.endsWith(']');
903
+ return input.startsWith("[") && input.endsWith("]");
877
904
  }
@@ -16,9 +16,9 @@ function _interop_require_default(obj) {
16
16
  };
17
17
  }
18
18
  let jsExtensions = [
19
- '.js',
20
- '.cjs',
21
- '.mjs'
19
+ ".js",
20
+ ".cjs",
21
+ ".mjs"
22
22
  ];
23
23
  // Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
24
24
  // `b.ts` before `b.js`
@@ -31,26 +31,26 @@ let jsExtensions = [
31
31
  // a.js
32
32
  // b // .js or .ts
33
33
  let jsResolutionOrder = [
34
- '',
35
- '.js',
36
- '.cjs',
37
- '.mjs',
38
- '.ts',
39
- '.cts',
40
- '.mts',
41
- '.jsx',
42
- '.tsx'
34
+ "",
35
+ ".js",
36
+ ".cjs",
37
+ ".mjs",
38
+ ".ts",
39
+ ".cts",
40
+ ".mts",
41
+ ".jsx",
42
+ ".tsx"
43
43
  ];
44
44
  let tsResolutionOrder = [
45
- '',
46
- '.ts',
47
- '.cts',
48
- '.mts',
49
- '.tsx',
50
- '.js',
51
- '.cjs',
52
- '.mjs',
53
- '.jsx'
45
+ "",
46
+ ".ts",
47
+ ".cts",
48
+ ".mts",
49
+ ".tsx",
50
+ ".js",
51
+ ".cjs",
52
+ ".mjs",
53
+ ".jsx"
54
54
  ];
55
55
  function resolveWithExtension(file, extensions) {
56
56
  // Try to find `./a.ts`, `./a.ts`, ... from `./a`
@@ -81,7 +81,7 @@ function* _getModuleDependencies(filename, base, seen, ext = _path.default.extna
81
81
  // Resolve new base for new imports/requires
82
82
  base = _path.default.dirname(absoluteFile);
83
83
  ext = _path.default.extname(absoluteFile);
84
- let contents = _fs.default.readFileSync(absoluteFile, 'utf-8');
84
+ let contents = _fs.default.readFileSync(absoluteFile, "utf-8");
85
85
  // Find imports/requires
86
86
  for (let match of [
87
87
  ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
@@ -89,7 +89,7 @@ function* _getModuleDependencies(filename, base, seen, ext = _path.default.extna
89
89
  ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
90
90
  ]){
91
91
  // Bail out if it's not a relative file
92
- if (!match[1].startsWith('.')) continue;
92
+ if (!match[1].startsWith(".")) continue;
93
93
  yield* _getModuleDependencies(match[1], base, seen, ext);
94
94
  }
95
95
  }
@@ -2,9 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "loadConfig", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ useCustomJiti: function() {
13
+ return useCustomJiti;
14
+ },
15
+ loadConfig: function() {
8
16
  return loadConfig;
9
17
  }
10
18
  });
@@ -16,14 +24,21 @@ function _interop_require_default(obj) {
16
24
  };
17
25
  }
18
26
  let jiti = null;
27
+ function useCustomJiti(_jiti) {
28
+ jiti = _jiti();
29
+ }
19
30
  function lazyJiti() {
20
31
  return jiti !== null && jiti !== void 0 ? jiti : jiti = (0, _jiti.default)(__filename, {
21
32
  interopDefault: true,
22
33
  transform: (opts)=>{
34
+ // Sucrase can't transform import.meta so we have to use Babel
35
+ if (opts.source.includes("import.meta")) {
36
+ return require("jiti/dist/babel.js")(opts);
37
+ }
23
38
  return (0, _sucrase.transform)(opts.source, {
24
39
  transforms: [
25
- 'typescript',
26
- 'imports'
40
+ "typescript",
41
+ "imports"
27
42
  ]
28
43
  });
29
44
  }
@@ -33,7 +48,7 @@ function loadConfig(path) {
33
48
  let config = function() {
34
49
  try {
35
50
  return path ? require(path) : {};
36
- } catch (e) {
51
+ } catch {
37
52
  return lazyJiti()(path);
38
53
  }
39
54
  }();
@@ -19,50 +19,65 @@ function normalizeTailwindDirectives(root) {
19
19
  let layerDirectives = new Set();
20
20
  let applyDirectives = new Set();
21
21
  root.walkAtRules((atRule)=>{
22
- if (atRule.name === 'apply') {
22
+ if (atRule.name === "apply") {
23
23
  applyDirectives.add(atRule);
24
24
  }
25
- if (atRule.name === 'tailwind') {
26
- if (atRule.params === 'screens') {
27
- atRule.params = 'variants';
25
+ if (atRule.name === "import") {
26
+ if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
27
+ atRule.name = "tailwind";
28
+ atRule.params = "base";
29
+ } else if (atRule.params === '"tailwindcss/components"' || atRule.params === "'tailwindcss/components'") {
30
+ atRule.name = "tailwind";
31
+ atRule.params = "components";
32
+ } else if (atRule.params === '"tailwindcss/utilities"' || atRule.params === "'tailwindcss/utilities'") {
33
+ atRule.name = "tailwind";
34
+ atRule.params = "utilities";
35
+ } else if (atRule.params === '"tailwindcss/screens"' || atRule.params === "'tailwindcss/screens'" || atRule.params === '"tailwindcss/variants"' || atRule.params === "'tailwindcss/variants'") {
36
+ atRule.name = "tailwind";
37
+ atRule.params = "variants";
38
+ }
39
+ }
40
+ if (atRule.name === "tailwind") {
41
+ if (atRule.params === "screens") {
42
+ atRule.params = "variants";
28
43
  }
29
44
  tailwindDirectives.add(atRule.params);
30
45
  }
31
46
  if ([
32
- 'layer',
33
- 'responsive',
34
- 'variants'
47
+ "layer",
48
+ "responsive",
49
+ "variants"
35
50
  ].includes(atRule.name)) {
36
51
  if ([
37
- 'responsive',
38
- 'variants'
52
+ "responsive",
53
+ "variants"
39
54
  ].includes(atRule.name)) {
40
55
  _log.default.warn(`${atRule.name}-at-rule-deprecated`, [
41
56
  `The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
42
57
  `Use \`@layer utilities\` or \`@layer components\` instead.`,
43
- 'https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer'
58
+ "https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer"
44
59
  ]);
45
60
  }
46
61
  layerDirectives.add(atRule);
47
62
  }
48
63
  });
49
- if (!tailwindDirectives.has('base') || !tailwindDirectives.has('components') || !tailwindDirectives.has('utilities')) {
64
+ if (!tailwindDirectives.has("base") || !tailwindDirectives.has("components") || !tailwindDirectives.has("utilities")) {
50
65
  for (let rule of layerDirectives){
51
- if (rule.name === 'layer' && [
52
- 'base',
53
- 'components',
54
- 'utilities'
66
+ if (rule.name === "layer" && [
67
+ "base",
68
+ "components",
69
+ "utilities"
55
70
  ].includes(rule.params)) {
56
71
  if (!tailwindDirectives.has(rule.params)) {
57
72
  throw rule.error(`\`@layer ${rule.params}\` is used but no matching \`@tailwind ${rule.params}\` directive is present.`);
58
73
  }
59
- } else if (rule.name === 'responsive') {
60
- if (!tailwindDirectives.has('utilities')) {
61
- throw rule.error('`@responsive` is used but `@tailwind utilities` is missing.');
74
+ } else if (rule.name === "responsive") {
75
+ if (!tailwindDirectives.has("utilities")) {
76
+ throw rule.error("`@responsive` is used but `@tailwind utilities` is missing.");
62
77
  }
63
- } else if (rule.name === 'variants') {
64
- if (!tailwindDirectives.has('utilities')) {
65
- throw rule.error('`@variants` is used but `@tailwind utilities` is missing.');
78
+ } else if (rule.name === "variants") {
79
+ if (!tailwindDirectives.has("utilities")) {
80
+ throw rule.error("`@variants` is used but `@tailwind utilities` is missing.");
66
81
  }
67
82
  }
68
83
  }