tailwindcss 0.0.0-insiders.ea10bb9 → 0.0.0-insiders.ea3d9cd

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 (187) hide show
  1. package/README.md +1 -1
  2. package/index.css +5 -0
  3. package/lib/cli/build/index.js +23 -10
  4. package/lib/cli/build/plugin.js +136 -117
  5. package/lib/cli/build/utils.js +18 -8
  6. package/lib/cli/build/watching.js +16 -12
  7. package/lib/cli/help/index.js +6 -4
  8. package/lib/cli/index.js +223 -10
  9. package/lib/cli/init/index.js +29 -12
  10. package/lib/cli.js +1 -227
  11. package/lib/corePluginList.js +8 -1
  12. package/lib/corePlugins.js +374 -77
  13. package/lib/css/preflight.css +9 -1
  14. package/lib/featureFlags.js +30 -17
  15. package/lib/index.js +1 -47
  16. package/lib/lib/cacheInvalidation.js +7 -5
  17. package/lib/lib/collapseAdjacentRules.js +5 -3
  18. package/lib/lib/collapseDuplicateDeclarations.js +12 -10
  19. package/lib/lib/content.js +61 -31
  20. package/lib/lib/defaultExtractor.js +15 -8
  21. package/lib/lib/detectNesting.js +10 -2
  22. package/lib/lib/evaluateTailwindFunctions.js +24 -20
  23. package/lib/lib/expandApplyAtRules.js +43 -35
  24. package/lib/lib/expandTailwindAtRules.js +89 -22
  25. package/lib/lib/findAtConfigPath.js +9 -7
  26. package/lib/lib/generateRules.js +160 -98
  27. package/lib/lib/getModuleDependencies.js +85 -37
  28. package/lib/lib/handleImportAtRules.js +50 -0
  29. package/lib/lib/load-config.js +42 -0
  30. package/lib/lib/normalizeTailwindDirectives.js +5 -18
  31. package/lib/lib/offsets.js +93 -4
  32. package/lib/lib/partitionApplyAtRules.js +3 -1
  33. package/lib/lib/regex.js +21 -7
  34. package/lib/lib/remap-bitfield.js +89 -0
  35. package/lib/lib/resolveDefaultsAtRules.js +28 -24
  36. package/lib/lib/setupContextUtils.js +191 -142
  37. package/lib/lib/setupTrackingContext.js +50 -26
  38. package/lib/lib/sharedState.js +28 -9
  39. package/lib/lib/substituteScreenAtRules.js +5 -3
  40. package/lib/plugin.js +116 -0
  41. package/lib/postcss-plugins/nesting/index.js +3 -1
  42. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  43. package/lib/processTailwindFeatures.js +14 -12
  44. package/lib/public/colors.js +49 -25
  45. package/lib/public/create-plugin.js +5 -3
  46. package/lib/public/default-config.js +6 -4
  47. package/lib/public/default-theme.js +6 -4
  48. package/lib/public/load-config.js +12 -0
  49. package/lib/public/resolve-config.js +6 -4
  50. package/lib/util/applyImportantSelector.js +36 -0
  51. package/lib/util/bigSign.js +3 -1
  52. package/lib/util/buildMediaQuery.js +3 -1
  53. package/lib/util/cloneDeep.js +3 -1
  54. package/lib/util/cloneNodes.js +5 -3
  55. package/lib/util/color.js +30 -12
  56. package/lib/util/colorNames.js +752 -0
  57. package/lib/util/configurePlugins.js +3 -1
  58. package/lib/util/createPlugin.js +3 -1
  59. package/lib/util/createUtilityPlugin.js +7 -5
  60. package/lib/util/dataTypes.js +88 -23
  61. package/lib/util/defaults.js +9 -7
  62. package/lib/util/escapeClassName.js +10 -8
  63. package/lib/util/escapeCommas.js +3 -1
  64. package/lib/util/flattenColorPalette.js +3 -1
  65. package/lib/util/formatVariantSelector.js +138 -160
  66. package/lib/util/getAllConfigs.js +8 -6
  67. package/lib/util/hashConfig.js +6 -4
  68. package/lib/util/isKeyframeRule.js +3 -1
  69. package/lib/util/isPlainObject.js +3 -1
  70. package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
  71. package/lib/util/log.js +25 -4
  72. package/lib/util/nameClass.js +12 -6
  73. package/lib/util/negateValue.js +4 -2
  74. package/lib/util/normalizeConfig.js +63 -36
  75. package/lib/util/normalizeScreens.js +12 -4
  76. package/lib/util/parseAnimationValue.js +3 -1
  77. package/lib/util/parseBoxShadowValue.js +6 -2
  78. package/lib/util/parseDependency.js +3 -1
  79. package/lib/util/parseGlob.js +6 -4
  80. package/lib/util/parseObjectStyles.js +9 -7
  81. package/lib/util/pluginUtils.js +53 -55
  82. package/lib/util/prefixSelector.js +27 -11
  83. package/lib/util/pseudoElements.js +209 -0
  84. package/lib/util/removeAlphaVariables.js +3 -1
  85. package/lib/util/resolveConfig.js +17 -15
  86. package/lib/util/resolveConfigPath.js +26 -10
  87. package/lib/util/responsive.js +6 -4
  88. package/lib/util/splitAtTopLevelOnly.js +10 -2
  89. package/lib/util/tap.js +3 -1
  90. package/lib/util/toColorValue.js +3 -1
  91. package/lib/util/toPath.js +3 -1
  92. package/lib/util/transformThemeValue.js +6 -4
  93. package/lib/util/validateConfig.js +27 -3
  94. package/lib/util/validateFormalSyntax.js +3 -1
  95. package/lib/util/withAlphaVariable.js +6 -2
  96. package/lib/value-parser/LICENSE +22 -0
  97. package/lib/value-parser/README.md +3 -0
  98. package/lib/value-parser/index.d.js +2 -0
  99. package/lib/value-parser/index.js +22 -0
  100. package/lib/value-parser/parse.js +259 -0
  101. package/lib/value-parser/stringify.js +38 -0
  102. package/lib/value-parser/unit.js +86 -0
  103. package/lib/value-parser/walk.js +16 -0
  104. package/loadConfig.d.ts +4 -0
  105. package/loadConfig.js +2 -0
  106. package/package.json +46 -45
  107. package/resolveConfig.d.ts +11 -2
  108. package/src/cli/build/index.js +17 -9
  109. package/src/cli/build/plugin.js +96 -73
  110. package/src/cli/build/watching.js +4 -2
  111. package/src/cli/index.js +217 -3
  112. package/src/cli/init/index.js +37 -8
  113. package/src/cli.js +1 -221
  114. package/src/corePluginList.js +1 -1
  115. package/src/corePlugins.js +237 -34
  116. package/src/css/preflight.css +9 -1
  117. package/src/featureFlags.js +7 -3
  118. package/src/index.js +1 -47
  119. package/src/lib/content.js +45 -18
  120. package/src/lib/defaultExtractor.js +9 -3
  121. package/src/lib/detectNesting.js +9 -1
  122. package/src/lib/evaluateTailwindFunctions.js +4 -1
  123. package/src/lib/expandApplyAtRules.js +8 -1
  124. package/src/lib/expandTailwindAtRules.js +73 -12
  125. package/src/lib/generateRules.js +127 -49
  126. package/src/lib/getModuleDependencies.js +70 -30
  127. package/src/lib/handleImportAtRules.js +34 -0
  128. package/src/lib/load-config.ts +31 -0
  129. package/src/lib/normalizeTailwindDirectives.js +0 -27
  130. package/src/lib/offsets.js +104 -1
  131. package/src/lib/remap-bitfield.js +82 -0
  132. package/src/lib/setupContextUtils.js +109 -69
  133. package/src/lib/setupTrackingContext.js +37 -14
  134. package/src/lib/sharedState.js +11 -4
  135. package/src/plugin.js +124 -0
  136. package/src/public/colors.js +22 -0
  137. package/src/public/default-config.js +1 -1
  138. package/src/public/default-theme.js +2 -2
  139. package/src/public/load-config.js +2 -0
  140. package/src/util/applyImportantSelector.js +27 -0
  141. package/src/util/color.js +18 -3
  142. package/src/util/colorNames.js +150 -0
  143. package/src/util/dataTypes.js +49 -9
  144. package/src/util/formatVariantSelector.js +160 -163
  145. package/src/util/getAllConfigs.js +2 -2
  146. package/src/util/log.js +24 -0
  147. package/src/util/negateValue.js +1 -1
  148. package/src/util/normalizeConfig.js +39 -11
  149. package/src/util/pluginUtils.js +16 -35
  150. package/src/util/prefixSelector.js +28 -10
  151. package/src/util/pseudoElements.js +167 -0
  152. package/src/util/resolveConfigPath.js +12 -1
  153. package/src/util/splitAtTopLevelOnly.js +8 -1
  154. package/src/util/validateConfig.js +23 -0
  155. package/src/value-parser/LICENSE +22 -0
  156. package/src/value-parser/README.md +3 -0
  157. package/src/value-parser/index.d.ts +177 -0
  158. package/src/value-parser/index.js +28 -0
  159. package/src/value-parser/parse.js +303 -0
  160. package/src/value-parser/stringify.js +41 -0
  161. package/src/value-parser/unit.js +118 -0
  162. package/src/value-parser/walk.js +18 -0
  163. package/stubs/.gitignore +1 -0
  164. package/stubs/.prettierrc.json +6 -0
  165. package/stubs/{defaultConfig.stub.js → config.full.js} +197 -147
  166. package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
  167. package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
  168. package/stubs/postcss.config.js +5 -0
  169. package/stubs/tailwind.config.cjs +2 -0
  170. package/stubs/tailwind.config.js +2 -0
  171. package/stubs/tailwind.config.ts +3 -0
  172. package/types/config.d.ts +17 -10
  173. package/types/generated/colors.d.ts +22 -0
  174. package/types/generated/corePluginList.d.ts +1 -1
  175. package/types/generated/default-theme.d.ts +110 -80
  176. package/CHANGELOG.md +0 -2336
  177. package/lib/cli/build/deps.js +0 -54
  178. package/lib/cli/shared.js +0 -12
  179. package/lib/cli-peer-dependencies.js +0 -28
  180. package/lib/constants.js +0 -44
  181. package/peers/index.js +0 -79512
  182. package/scripts/install-integrations.js +0 -27
  183. package/scripts/rebuildFixtures.js +0 -68
  184. package/src/cli/build/deps.js +0 -56
  185. package/src/cli/shared.js +0 -5
  186. package/src/cli-peer-dependencies.js +0 -15
  187. package/src/constants.js +0 -17
@@ -9,26 +9,33 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getClassNameFromSelector: ()=>getClassNameFromSelector,
13
- resolveMatches: ()=>resolveMatches,
14
- generateRules: ()=>generateRules
12
+ getClassNameFromSelector: function() {
13
+ return getClassNameFromSelector;
14
+ },
15
+ resolveMatches: function() {
16
+ return resolveMatches;
17
+ },
18
+ generateRules: function() {
19
+ return generateRules;
20
+ }
15
21
  });
16
- const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
17
- const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
18
- const _parseObjectStyles = /*#__PURE__*/ _interopRequireDefault(require("../util/parseObjectStyles"));
19
- const _isPlainObject = /*#__PURE__*/ _interopRequireDefault(require("../util/isPlainObject"));
20
- const _prefixSelector = /*#__PURE__*/ _interopRequireDefault(require("../util/prefixSelector"));
22
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
23
+ const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
24
+ const _parseObjectStyles = /*#__PURE__*/ _interop_require_default(require("../util/parseObjectStyles"));
25
+ const _isPlainObject = /*#__PURE__*/ _interop_require_default(require("../util/isPlainObject"));
26
+ const _prefixSelector = /*#__PURE__*/ _interop_require_default(require("../util/prefixSelector"));
21
27
  const _pluginUtils = require("../util/pluginUtils");
22
- const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
23
- const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
28
+ const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
29
+ const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
24
30
  const _formatVariantSelector = require("../util/formatVariantSelector");
25
31
  const _nameClass = require("../util/nameClass");
26
32
  const _dataTypes = require("../util/dataTypes");
27
33
  const _setupContextUtils = require("./setupContextUtils");
28
- const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interopRequireDefault(require("../util/isSyntacticallyValidPropertyValue"));
29
- const _splitAtTopLevelOnlyJs = require("../util/splitAtTopLevelOnly.js");
34
+ const _isSyntacticallyValidPropertyValue = /*#__PURE__*/ _interop_require_default(require("../util/isSyntacticallyValidPropertyValue"));
35
+ const _splitAtTopLevelOnly = require("../util/splitAtTopLevelOnly.js");
30
36
  const _featureFlags = require("../featureFlags");
31
- function _interopRequireDefault(obj) {
37
+ const _applyImportantSelector = require("../util/applyImportantSelector");
38
+ function _interop_require_default(obj) {
32
39
  return obj && obj.__esModule ? obj : {
33
40
  default: obj
34
41
  };
@@ -41,7 +48,7 @@ function _getRequireWildcardCache(nodeInterop) {
41
48
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
49
  })(nodeInterop);
43
50
  }
44
- function _interopRequireWildcard(obj, nodeInterop) {
51
+ function _interop_require_wildcard(obj, nodeInterop) {
45
52
  if (!nodeInterop && obj && obj.__esModule) {
46
53
  return obj;
47
54
  }
@@ -72,7 +79,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
72
79
  }
73
80
  return newObj;
74
81
  }
75
- let classNameParser = (0, _postcssSelectorParser.default)((selectors)=>{
82
+ let classNameParser = (0, _postcssselectorparser.default)((selectors)=>{
76
83
  return selectors.first.filter(({ type })=>type === "class").pop().value;
77
84
  });
78
85
  function getClassNameFromSelector(selector) {
@@ -162,12 +169,12 @@ function applyImportant(matches, classCandidate) {
162
169
  ]
163
170
  });
164
171
  container.walkRules((r)=>{
165
- r.selector = (0, _pluginUtils.updateAllClasses)((0, _pluginUtils.filterSelectorsForClass)(r.selector, classCandidate), (className)=>{
166
- if (className === classCandidate) {
167
- return `!${className}`;
168
- }
169
- return className;
170
- });
172
+ let ast = (0, _postcssselectorparser.default)().astSync(r.selector);
173
+ // Remove extraneous selectors that do not include the base candidate
174
+ ast.each((sel)=>(0, _formatVariantSelector.eliminateIrrelevantSelectors)(sel, classCandidate));
175
+ // Update all instances of the base candidate to include the important marker
176
+ (0, _pluginUtils.updateAllClasses)(ast, (className)=>className === classCandidate ? `!${className}` : className);
177
+ r.selector = ast.toString();
171
178
  r.walkDecls((d)=>d.important = true);
172
179
  });
173
180
  result.push([
@@ -198,13 +205,16 @@ function applyVariant(variant, matches, context) {
198
205
  };
199
206
  // Retrieve "modifier"
200
207
  {
201
- let match = /(.*)\/(.*)$/g.exec(variant);
202
- if (match) {
203
- variant = match[1];
204
- args.modifier = match[2];
205
- if (!(0, _featureFlags.flagEnabled)(context.tailwindConfig, "generalizedModifiers")) {
206
- return [];
207
- }
208
+ let [baseVariant, ...modifiers] = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(variant, "/");
209
+ // This is a hack to support variants with `/` in them, like `ar-1/10/20:text-red-500`
210
+ // In this case 1/10 is a value but /20 is a modifier
211
+ if (modifiers.length > 1) {
212
+ baseVariant = baseVariant + "/" + modifiers.slice(0, -1).join("/");
213
+ modifiers = modifiers.slice(-1);
214
+ }
215
+ if (modifiers.length && !context.variantMap.has(variant)) {
216
+ variant = baseVariant;
217
+ args.modifier = modifiers[0];
208
218
  }
209
219
  }
210
220
  // Retrieve "arbitrary value"
@@ -216,33 +226,37 @@ function applyVariant(variant, matches, context) {
216
226
  // But we don't want:
217
227
  // @-[200px] (`-` is incorrect)
218
228
  // group[:hover] (`-` is missing)
219
- let match1 = /(.)(-?)\[(.*)\]/g.exec(variant);
220
- if (match1) {
221
- let [, char, seperator, value] = match1;
229
+ let match = /(.)(-?)\[(.*)\]/g.exec(variant);
230
+ if (match) {
231
+ let [, char, separator, value] = match;
222
232
  // @-[200px] case
223
- if (char === "@" && seperator === "-") return [];
233
+ if (char === "@" && separator === "-") return [];
224
234
  // group[:hover] case
225
- if (char !== "@" && seperator === "") return [];
226
- variant = variant.replace(`${seperator}[${value}]`, "");
235
+ if (char !== "@" && separator === "") return [];
236
+ variant = variant.replace(`${separator}[${value}]`, "");
227
237
  args.value = value;
228
238
  }
229
239
  }
230
240
  // Register arbitrary variants
231
241
  if (isArbitraryValue(variant) && !context.variantMap.has(variant)) {
242
+ let sort = context.offsets.recordVariant(variant);
232
243
  let selector = (0, _dataTypes.normalize)(variant.slice(1, -1));
233
- if (!(0, _setupContextUtils.isValidVariantFormatString)(selector)) {
244
+ let selectors = (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(selector, ",");
245
+ // We do not support multiple selectors for arbitrary variants
246
+ if (selectors.length > 1) {
234
247
  return [];
235
248
  }
236
- let fn = (0, _setupContextUtils.parseVariant)(selector);
237
- let sort = context.offsets.recordVariant(variant);
238
- context.variantMap.set(variant, [
239
- [
240
- sort,
241
- fn
242
- ]
243
- ]);
249
+ if (!selectors.every(_setupContextUtils.isValidVariantFormatString)) {
250
+ return [];
251
+ }
252
+ let records = selectors.map((sel, idx)=>[
253
+ context.offsets.applyParallelOffset(sort, idx),
254
+ (0, _setupContextUtils.parseVariant)(sel.trim())
255
+ ]);
256
+ context.variantMap.set(variant, records);
244
257
  }
245
258
  if (context.variantMap.has(variant)) {
259
+ let isArbitraryVariant = isArbitraryValue(variant);
246
260
  let variantFunctionTuples = context.variantMap.get(variant).slice();
247
261
  let result = [];
248
262
  for (let [meta, rule] of matches){
@@ -299,21 +313,24 @@ function applyVariant(variant, matches, context) {
299
313
  clone.append(wrapper);
300
314
  },
301
315
  format (selectorFormat) {
302
- collectedFormats.push(selectorFormat);
316
+ collectedFormats.push({
317
+ format: selectorFormat,
318
+ isArbitraryVariant
319
+ });
303
320
  },
304
321
  args
305
322
  });
306
323
  // It can happen that a list of format strings is returned from within the function. In that
307
324
  // case, we have to process them as well. We can use the existing `variantSort`.
308
325
  if (Array.isArray(ruleWithVariant)) {
309
- for (let [idx, variantFunction1] of ruleWithVariant.entries()){
326
+ for (let [idx, variantFunction] of ruleWithVariant.entries()){
310
327
  // This is a little bit scary since we are pushing to an array of items that we are
311
328
  // currently looping over. However, you can also think of it like a processing queue
312
329
  // where you keep handling jobs until everything is done and each job can queue more
313
330
  // jobs if needed.
314
331
  variantFunctionTuples.push([
315
332
  context.offsets.applyParallelOffset(variantSort, idx),
316
- variantFunction1,
333
+ variantFunction,
317
334
  // If the clone has been modified we have to pass that back
318
335
  // though so each rule can use the modified container
319
336
  clone.clone()
@@ -322,7 +339,10 @@ function applyVariant(variant, matches, context) {
322
339
  continue;
323
340
  }
324
341
  if (typeof ruleWithVariant === "string") {
325
- collectedFormats.push(ruleWithVariant);
342
+ collectedFormats.push({
343
+ format: ruleWithVariant,
344
+ isArbitraryVariant
345
+ });
326
346
  }
327
347
  if (ruleWithVariant === null) {
328
348
  continue;
@@ -342,7 +362,7 @@ function applyVariant(variant, matches, context) {
342
362
  // as well. E.g.: `${variant}${separator}${className}`.
343
363
  // However, plugin authors probably also prepend or append certain
344
364
  // classes, pseudos, ids, ...
345
- let rebuiltBase = (0, _postcssSelectorParser.default)((selectors)=>{
365
+ let rebuiltBase = (0, _postcssselectorparser.default)((selectors)=>{
346
366
  selectors.walkClasses((classNode)=>{
347
367
  classNode.value = `${variant}${context.tailwindConfig.separator}${classNode.value}`;
348
368
  });
@@ -358,7 +378,10 @@ function applyVariant(variant, matches, context) {
358
378
  // modified (by plugin): .foo .foo\\:markdown > p
359
379
  // rebuiltBase (internal): .foo\\:markdown > p
360
380
  // format: .foo &
361
- collectedFormats.push(modified.replace(rebuiltBase, "&"));
381
+ collectedFormats.push({
382
+ format: modified.replace(rebuiltBase, "&"),
383
+ isArbitraryVariant
384
+ });
362
385
  rule.selector = before;
363
386
  });
364
387
  }
@@ -370,13 +393,12 @@ function applyVariant(variant, matches, context) {
370
393
  ...clone.nodes[0].raws.tailwind,
371
394
  parentLayer: meta.layer
372
395
  };
373
- var _collectedFormats;
396
+ var _meta_collectedFormats;
374
397
  let withOffset = [
375
398
  {
376
399
  ...meta,
377
400
  sort: context.offsets.applyVariantOffset(meta.sort, variantSort, Object.assign(args, context.variantOptions.get(variant))),
378
- collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
379
- isArbitraryVariant: isArbitraryValue(variant)
401
+ collectedFormats: ((_meta_collectedFormats = meta.collectedFormats) !== null && _meta_collectedFormats !== void 0 ? _meta_collectedFormats : []).concat(collectedFormats)
380
402
  },
381
403
  clone.nodes[0]
382
404
  ];
@@ -434,7 +456,7 @@ function isValidPropName(name) {
434
456
  function isParsableNode(node) {
435
457
  let isParsable = true;
436
458
  node.walkDecls((decl)=>{
437
- if (!isParsableCssValue(decl.name, decl.value)) {
459
+ if (!isParsableCssValue(decl.prop, decl.value)) {
438
460
  isParsable = false;
439
461
  return false;
440
462
  }
@@ -456,8 +478,8 @@ function isParsableCssValue(property, value) {
456
478
  }
457
479
  }
458
480
  function extractArbitraryProperty(classCandidate, context) {
459
- var ref;
460
- let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
481
+ var _classCandidate_match;
482
+ let [, property, value] = (_classCandidate_match = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && _classCandidate_match !== void 0 ? _classCandidate_match : [];
461
483
  if (value === undefined) {
462
484
  return null;
463
485
  }
@@ -531,16 +553,16 @@ function splitWithSeparator(input, separator) {
531
553
  _sharedState.NOT_ON_DEMAND
532
554
  ];
533
555
  }
534
- return (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(input, separator);
556
+ return (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(input, separator);
535
557
  }
536
558
  function* recordCandidates(matches, classCandidate) {
537
559
  for (const match of matches){
538
- var ref;
539
- var ref1;
560
+ var _match__options;
561
+ var _match__options_preserveSource;
540
562
  match[1].raws.tailwind = {
541
563
  ...match[1].raws.tailwind,
542
564
  classCandidate,
543
- preserveSource: (ref1 = (ref = match[0].options) === null || ref === void 0 ? void 0 : ref.preserveSource) !== null && ref1 !== void 0 ? ref1 : false
565
+ preserveSource: (_match__options_preserveSource = (_match__options = match[0].options) === null || _match__options === void 0 ? void 0 : _match__options.preserveSource) !== null && _match__options_preserveSource !== void 0 ? _match__options_preserveSource : false
544
566
  };
545
567
  yield match;
546
568
  }
@@ -556,7 +578,7 @@ function* resolveMatches(candidate, context, original = candidate) {
556
578
  if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "variantGrouping")) {
557
579
  if (classCandidate.startsWith("(") && classCandidate.endsWith(")")) {
558
580
  let base = variants.slice().reverse().join(separator);
559
- for (let part of (0, _splitAtTopLevelOnlyJs.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
581
+ for (let part of (0, _splitAtTopLevelOnly.splitAtTopLevelOnly)(classCandidate.slice(1, -1), ",")){
560
582
  yield* resolveMatches(base + separator + part, context, original);
561
583
  }
562
584
  }
@@ -598,25 +620,25 @@ function* resolveMatches(candidate, context, original = candidate) {
598
620
  }
599
621
  }
600
622
  } else if (modifier === "DEFAULT" || modifier === "-DEFAULT") {
601
- let ruleSet1 = plugin;
602
- let [rules1, options1] = parseRules(ruleSet1, context.postCssNodeCache);
603
- for (let rule1 of rules1){
623
+ let ruleSet = plugin;
624
+ let [rules, options] = parseRules(ruleSet, context.postCssNodeCache);
625
+ for (let rule of rules){
604
626
  matchesPerPlugin.push([
605
627
  {
606
628
  ...sort,
607
629
  options: {
608
630
  ...sort.options,
609
- ...options1
631
+ ...options
610
632
  }
611
633
  },
612
- rule1
634
+ rule
613
635
  ]);
614
636
  }
615
637
  }
616
638
  if (matchesPerPlugin.length > 0) {
617
- var ref;
618
- var ref1, _options;
619
- let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((ref1 = (ref = sort.options) === null || ref === void 0 ? void 0 : ref.types) !== null && ref1 !== void 0 ? ref1 : [], modifier, (_options = sort.options) !== null && _options !== void 0 ? _options : {}, context.tailwindConfig)).map(([_, type])=>type);
639
+ var _sort_options;
640
+ var _sort_options_types, _sort_options1;
641
+ let matchingTypes = Array.from((0, _pluginUtils.getMatchingTypes)((_sort_options_types = (_sort_options = sort.options) === null || _sort_options === void 0 ? void 0 : _sort_options.types) !== null && _sort_options_types !== void 0 ? _sort_options_types : [], modifier, (_sort_options1 = sort.options) !== null && _sort_options1 !== void 0 ? _sort_options1 : {}, context.tailwindConfig)).map(([_, type])=>type);
620
642
  if (matchingTypes.length > 0) {
621
643
  typesByMatches.set(matchesPerPlugin, matchingTypes);
622
644
  }
@@ -656,18 +678,18 @@ function* resolveMatches(candidate, context, original = candidate) {
656
678
  });
657
679
  });
658
680
  }
659
- var ref2;
681
+ var _findFallback;
660
682
  // Try to find a fallback plugin, because we already know that multiple plugins matched for
661
683
  // the given arbitrary value.
662
- let fallback = (ref2 = findFallback(withoutAny)) !== null && ref2 !== void 0 ? ref2 : findFallback(withAny);
684
+ let fallback = (_findFallback = findFallback(withoutAny)) !== null && _findFallback !== void 0 ? _findFallback : findFallback(withAny);
663
685
  if (fallback) {
664
686
  matches = [
665
687
  fallback
666
688
  ];
667
689
  } else {
668
- var ref3;
690
+ var _typesByMatches_get;
669
691
  let typesPerPlugin = matches.map((match)=>new Set([
670
- ...(ref3 = typesByMatches.get(match)) !== null && ref3 !== void 0 ? ref3 : []
692
+ ...(_typesByMatches_get = typesByMatches.get(match)) !== null && _typesByMatches_get !== void 0 ? _typesByMatches_get : []
671
693
  ]));
672
694
  // Remove duplicates, so that we can detect proper unique types for each plugin.
673
695
  for (let pluginTypes of typesPerPlugin){
@@ -685,11 +707,11 @@ function* resolveMatches(candidate, context, original = candidate) {
685
707
  }
686
708
  let messages = [];
687
709
  for (let [idx, group] of typesPerPlugin.entries()){
688
- for (let type1 of group){
689
- let rules2 = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
710
+ for (let type of group){
711
+ let rules = matches[idx].map(([, rule])=>rule).flat().map((rule)=>rule.toString().split("\n").slice(1, -1) // Remove selector and closing '}'
690
712
  .map((line)=>line.trim()).map((x)=>` ${x}`) // Re-indent
691
713
  .join("\n")).join("\n\n");
692
- messages.push(` Use \`${candidate.replace("[", `[${type1}:`)}\` for \`${rules2.trim()}\``);
714
+ messages.push(` Use \`${candidate.replace("[", `[${type}:`)}\` for \`${rules.trim()}\``);
693
715
  break;
694
716
  }
695
717
  }
@@ -718,31 +740,71 @@ function* resolveMatches(candidate, context, original = candidate) {
718
740
  candidate
719
741
  };
720
742
  // Apply final format selector
721
- if (match[0].collectedFormats) {
722
- let finalFormat = (0, _formatVariantSelector.formatVariantSelector)("&", ...match[0].collectedFormats);
723
- let container = _postcss.default.root({
724
- nodes: [
725
- match[1].clone()
726
- ]
727
- });
728
- container.walkRules((rule)=>{
729
- var ref;
730
- if (inKeyframes(rule)) return;
731
- var ref1;
732
- rule.selector = (0, _formatVariantSelector.finalizeSelector)(finalFormat, {
733
- selector: rule.selector,
734
- candidate: original,
735
- base: candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop(),
736
- isArbitraryVariant: match[0].isArbitraryVariant,
737
- context
738
- });
739
- });
740
- match[1] = container.nodes[0];
743
+ match = applyFinalFormat(match, {
744
+ context,
745
+ candidate,
746
+ original
747
+ });
748
+ // Skip rules with invalid selectors
749
+ // This will cause the candidate to be added to the "not class"
750
+ // cache skipping it entirely for future builds
751
+ if (match === null) {
752
+ continue;
741
753
  }
742
754
  yield match;
743
755
  }
744
756
  }
745
757
  }
758
+ function applyFinalFormat(match, { context , candidate , original }) {
759
+ if (!match[0].collectedFormats) {
760
+ return match;
761
+ }
762
+ let isValid = true;
763
+ let finalFormat;
764
+ try {
765
+ finalFormat = (0, _formatVariantSelector.formatVariantSelector)(match[0].collectedFormats, {
766
+ context,
767
+ candidate
768
+ });
769
+ } catch {
770
+ // The format selector we produced is invalid
771
+ // This could be because:
772
+ // - A bug exists
773
+ // - A plugin introduced an invalid variant selector (ex: `addVariant('foo', '&;foo')`)
774
+ // - The user used an invalid arbitrary variant (ex: `[&;foo]:underline`)
775
+ // Either way the build will fail because of this
776
+ // We would rather that the build pass "silently" given that this could
777
+ // happen because of picking up invalid things when scanning content
778
+ // So we'll throw out the candidate instead
779
+ return null;
780
+ }
781
+ let container = _postcss.default.root({
782
+ nodes: [
783
+ match[1].clone()
784
+ ]
785
+ });
786
+ container.walkRules((rule)=>{
787
+ if (inKeyframes(rule)) {
788
+ return;
789
+ }
790
+ try {
791
+ rule.selector = (0, _formatVariantSelector.finalizeSelector)(rule.selector, finalFormat, {
792
+ candidate: original,
793
+ context
794
+ });
795
+ } catch {
796
+ // If this selector is invalid we also want to skip it
797
+ // But it's likely that being invalid here means there's a bug in a plugin rather than too loosely matching content
798
+ isValid = false;
799
+ return false;
800
+ }
801
+ });
802
+ if (!isValid) {
803
+ return null;
804
+ }
805
+ match[1] = container.nodes[0];
806
+ return match;
807
+ }
746
808
  function inKeyframes(rule) {
747
809
  return rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes";
748
810
  }
@@ -765,7 +827,7 @@ function getImportantStrategy(important) {
765
827
  return;
766
828
  }
767
829
  rule.selectors = rule.selectors.map((selector)=>{
768
- return `${important} ${selector}`;
830
+ return (0, _applyImportantSelector.applyImportantSelector)(selector, important);
769
831
  });
770
832
  };
771
833
  }
@@ -787,8 +849,8 @@ function generateRules(candidates, context) {
787
849
  continue;
788
850
  }
789
851
  context.classCache.set(candidate, matches);
790
- var ref;
791
- let rules = (ref = context.candidateRuleCache.get(candidate)) !== null && ref !== void 0 ? ref : new Set();
852
+ var _context_candidateRuleCache_get;
853
+ let rules = (_context_candidateRuleCache_get = context.candidateRuleCache.get(candidate)) !== null && _context_candidateRuleCache_get !== void 0 ? _context_candidateRuleCache_get : new Set();
792
854
  context.candidateRuleCache.set(candidate, rules);
793
855
  for (const match of matches){
794
856
  let [{ sort , options }, rule] = match;
@@ -4,48 +4,96 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>getModuleDependencies
7
+ get: function() {
8
+ return getModuleDependencies;
9
+ }
8
10
  });
9
- const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
- const _resolve = /*#__PURE__*/ _interopRequireDefault(require("resolve"));
12
- const _detective = /*#__PURE__*/ _interopRequireDefault(require("detective"));
13
- function _interopRequireDefault(obj) {
11
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ function _interop_require_default(obj) {
14
14
  return obj && obj.__esModule ? obj : {
15
15
  default: obj
16
16
  };
17
17
  }
18
- function createModule(file) {
19
- const source = _fs.default.readFileSync(file, "utf-8");
20
- const requires = (0, _detective.default)(source);
21
- return {
22
- file,
23
- requires
24
- };
18
+ let jsExtensions = [
19
+ ".js",
20
+ ".cjs",
21
+ ".mjs"
22
+ ];
23
+ // Given the current file `a.ts`, we want to make sure that when importing `b` that we resolve
24
+ // `b.ts` before `b.js`
25
+ //
26
+ // E.g.:
27
+ //
28
+ // a.ts
29
+ // b // .ts
30
+ // c // .ts
31
+ // a.js
32
+ // b // .js or .ts
33
+ let jsResolutionOrder = [
34
+ "",
35
+ ".js",
36
+ ".cjs",
37
+ ".mjs",
38
+ ".ts",
39
+ ".cts",
40
+ ".mts",
41
+ ".jsx",
42
+ ".tsx"
43
+ ];
44
+ let tsResolutionOrder = [
45
+ "",
46
+ ".ts",
47
+ ".cts",
48
+ ".mts",
49
+ ".tsx",
50
+ ".js",
51
+ ".cjs",
52
+ ".mjs",
53
+ ".jsx"
54
+ ];
55
+ function resolveWithExtension(file, extensions) {
56
+ // Try to find `./a.ts`, `./a.ts`, ... from `./a`
57
+ for (let ext of extensions){
58
+ let full = `${file}${ext}`;
59
+ if (_fs.default.existsSync(full) && _fs.default.statSync(full).isFile()) {
60
+ return full;
61
+ }
62
+ }
63
+ // Try to find `./a/index.js` from `./a`
64
+ for (let ext of extensions){
65
+ let full = `${file}/index${ext}`;
66
+ if (_fs.default.existsSync(full)) {
67
+ return full;
68
+ }
69
+ }
70
+ return null;
25
71
  }
26
- function getModuleDependencies(entryFile) {
27
- const rootModule = createModule(entryFile);
28
- const modules = [
29
- rootModule
30
- ];
31
- // Iterate over the modules, even when new
32
- // ones are being added
33
- for (const mdl of modules){
34
- mdl.requires.filter((dep)=>{
35
- // Only track local modules, not node_modules
36
- return dep.startsWith("./") || dep.startsWith("../");
37
- }).forEach((dep)=>{
38
- try {
39
- const basedir = _path.default.dirname(mdl.file);
40
- const depPath = _resolve.default.sync(dep, {
41
- basedir
42
- });
43
- const depModule = createModule(depPath);
44
- modules.push(depModule);
45
- } catch (_err) {
46
- // eslint-disable-next-line no-empty
47
- }
48
- });
72
+ function* _getModuleDependencies(filename, base, seen, ext = _path.default.extname(filename)) {
73
+ // Try to find the file
74
+ let absoluteFile = resolveWithExtension(_path.default.resolve(base, filename), jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder);
75
+ if (absoluteFile === null) return; // File doesn't exist
76
+ // Prevent infinite loops when there are circular dependencies
77
+ if (seen.has(absoluteFile)) return; // Already seen
78
+ seen.add(absoluteFile);
79
+ // Mark the file as a dependency
80
+ yield absoluteFile;
81
+ // Resolve new base for new imports/requires
82
+ base = _path.default.dirname(absoluteFile);
83
+ ext = _path.default.extname(absoluteFile);
84
+ let contents = _fs.default.readFileSync(absoluteFile, "utf-8");
85
+ // Find imports/requires
86
+ for (let match of [
87
+ ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
88
+ ...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
89
+ ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
90
+ ]){
91
+ // Bail out if it's not a relative file
92
+ if (!match[1].startsWith(".")) continue;
93
+ yield* _getModuleDependencies(match[1], base, seen, ext);
49
94
  }
50
- return modules;
95
+ }
96
+ function getModuleDependencies(absoluteFilePath) {
97
+ if (absoluteFilePath === null) return new Set();
98
+ return new Set(_getModuleDependencies(absoluteFilePath, _path.default.dirname(absoluteFilePath), new Set()));
51
99
  }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "handleImportAtRules", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return handleImportAtRules;
9
+ }
10
+ });
11
+ const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
12
+ const _postcssimport = /*#__PURE__*/ _interop_require_default(require("postcss-import"));
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ const TAILWIND = Symbol();
19
+ function handleImportAtRules() {
20
+ let RESTORE_ATRULE_COMMENT = "__TAILWIND_RESTORE__";
21
+ let atRulesToRestore = [
22
+ "tailwind",
23
+ "config"
24
+ ];
25
+ return [
26
+ (root)=>{
27
+ root.walkAtRules((rule)=>{
28
+ if (!atRulesToRestore.includes(rule.name)) return rule;
29
+ rule.after(_postcss.default.comment({
30
+ text: RESTORE_ATRULE_COMMENT,
31
+ raws: {
32
+ [TAILWIND]: {
33
+ rule
34
+ }
35
+ }
36
+ }));
37
+ rule.remove();
38
+ });
39
+ },
40
+ (0, _postcssimport.default)(),
41
+ (root)=>{
42
+ root.walkComments((rule)=>{
43
+ if (rule.text === RESTORE_ATRULE_COMMENT) {
44
+ rule.after(rule.raws[TAILWIND].rule);
45
+ rule.remove();
46
+ }
47
+ });
48
+ }
49
+ ];
50
+ }