tailwindcss 0.0.0-insiders.e2d5f21 → 0.0.0-insiders.e302ef1

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 (91) hide show
  1. package/CHANGELOG.md +244 -3
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.js +2 -1
  5. package/defaultConfig.js +2 -1
  6. package/defaultTheme.js +2 -1
  7. package/lib/cli.js +123 -88
  8. package/lib/corePlugins.js +288 -360
  9. package/lib/css/preflight.css +4 -4
  10. package/lib/featureFlags.js +4 -5
  11. package/lib/index.js +12 -3
  12. package/lib/lib/cacheInvalidation.js +69 -0
  13. package/lib/lib/collapseAdjacentRules.js +14 -1
  14. package/lib/lib/collapseDuplicateDeclarations.js +52 -1
  15. package/lib/lib/defaultExtractor.js +44 -0
  16. package/lib/lib/evaluateTailwindFunctions.js +1 -1
  17. package/lib/lib/expandApplyAtRules.js +265 -60
  18. package/lib/lib/expandTailwindAtRules.js +63 -48
  19. package/lib/lib/generateRules.js +136 -34
  20. package/lib/lib/normalizeTailwindDirectives.js +10 -2
  21. package/lib/lib/partitionApplyAtRules.js +53 -0
  22. package/lib/lib/resolveDefaultsAtRules.js +30 -12
  23. package/lib/lib/setupContextUtils.js +137 -81
  24. package/lib/lib/setupTrackingContext.js +8 -7
  25. package/lib/lib/sharedState.js +38 -5
  26. package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
  27. package/lib/postcss-plugins/nesting/index.js +17 -0
  28. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  29. package/lib/processTailwindFeatures.js +10 -2
  30. package/lib/util/cloneNodes.js +12 -1
  31. package/lib/util/color.js +23 -8
  32. package/lib/util/createPlugin.js +1 -2
  33. package/lib/util/createUtilityPlugin.js +4 -8
  34. package/lib/util/dataTypes.js +4 -2
  35. package/lib/util/defaults.js +6 -0
  36. package/lib/util/flattenColorPalette.js +1 -3
  37. package/lib/util/log.js +10 -6
  38. package/lib/util/normalizeConfig.js +47 -15
  39. package/lib/util/normalizeScreens.js +6 -5
  40. package/lib/util/parseBoxShadowValue.js +44 -4
  41. package/lib/util/pluginUtils.js +6 -13
  42. package/lib/util/prefixSelector.js +4 -5
  43. package/lib/util/resolveConfig.js +48 -27
  44. package/lib/util/resolveConfigPath.js +1 -2
  45. package/lib/util/toColorValue.js +1 -2
  46. package/lib/util/toPath.js +6 -1
  47. package/lib/util/transformThemeValue.js +4 -8
  48. package/nesting/index.js +2 -12
  49. package/package.json +28 -33
  50. package/peers/index.js +3209 -4239
  51. package/plugin.js +2 -1
  52. package/resolveConfig.js +2 -1
  53. package/src/cli.js +62 -15
  54. package/src/corePlugins.js +212 -217
  55. package/src/css/preflight.css +4 -4
  56. package/src/featureFlags.js +3 -3
  57. package/src/index.js +14 -6
  58. package/src/lib/cacheInvalidation.js +52 -0
  59. package/src/lib/collapseAdjacentRules.js +16 -1
  60. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  61. package/src/lib/defaultExtractor.js +50 -0
  62. package/src/lib/evaluateTailwindFunctions.js +1 -1
  63. package/src/lib/expandApplyAtRules.js +285 -56
  64. package/src/lib/expandTailwindAtRules.js +75 -37
  65. package/src/lib/generateRules.js +121 -27
  66. package/src/lib/normalizeTailwindDirectives.js +7 -1
  67. package/src/lib/partitionApplyAtRules.js +52 -0
  68. package/src/lib/resolveDefaultsAtRules.js +35 -10
  69. package/src/lib/setupContextUtils.js +127 -45
  70. package/src/lib/setupTrackingContext.js +8 -7
  71. package/src/lib/sharedState.js +42 -4
  72. package/src/postcss-plugins/nesting/README.md +42 -0
  73. package/src/postcss-plugins/nesting/index.js +13 -0
  74. package/src/postcss-plugins/nesting/plugin.js +80 -0
  75. package/src/processTailwindFeatures.js +12 -2
  76. package/src/util/cloneNodes.js +14 -1
  77. package/src/util/color.js +20 -7
  78. package/src/util/dataTypes.js +7 -5
  79. package/src/util/defaults.js +6 -0
  80. package/src/util/log.js +10 -6
  81. package/src/util/normalizeConfig.js +24 -3
  82. package/src/util/normalizeScreens.js +6 -3
  83. package/src/util/parseBoxShadowValue.js +51 -3
  84. package/src/util/pluginUtils.js +1 -1
  85. package/src/util/prefixSelector.js +7 -5
  86. package/src/util/resolveConfig.js +41 -1
  87. package/src/util/toPath.js +23 -1
  88. package/stubs/defaultConfig.stub.js +2 -2
  89. package/lib/lib/setupWatchingContext.js +0 -288
  90. package/nesting/plugin.js +0 -41
  91. package/src/lib/setupWatchingContext.js +0 -311
package/plugin.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/create-plugin').default
1
+ let createPlugin = require('./lib/public/create-plugin')
2
+ module.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default
package/resolveConfig.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/resolve-config').default
1
+ let resolveConfig = require('./lib/public/resolve-config')
2
+ module.exports = (resolveConfig.__esModule ? resolveConfig : { default: resolveConfig }).default
package/src/cli.js CHANGED
@@ -41,6 +41,26 @@ function formatNodes(root) {
41
41
  }
42
42
  }
43
43
 
44
+ async function outputFile(file, contents) {
45
+ if (fs.existsSync(file) && (await fs.promises.readFile(file, 'utf8')) === contents) {
46
+ return // Skip writing the file
47
+ }
48
+
49
+ // Write the file
50
+ await fs.promises.writeFile(file, contents, 'utf8')
51
+ }
52
+
53
+ function drainStdin() {
54
+ return new Promise((resolve, reject) => {
55
+ let result = ''
56
+ process.stdin.on('data', (chunk) => {
57
+ result += chunk
58
+ })
59
+ process.stdin.on('end', () => resolve(result))
60
+ process.stdin.on('error', (err) => reject(err))
61
+ })
62
+ }
63
+
44
64
  function help({ message, usage, commands, options }) {
45
65
  let indent = 2
46
66
 
@@ -355,7 +375,7 @@ async function build() {
355
375
  input = args['--input'] = args['_'][1]
356
376
  }
357
377
 
358
- if (input && !fs.existsSync((input = path.resolve(input)))) {
378
+ if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
359
379
  console.error(`Specified input file ${args['--input']} does not exist.`)
360
380
  process.exit(9)
361
381
  }
@@ -417,7 +437,6 @@ async function build() {
417
437
 
418
438
  function resolveConfig() {
419
439
  let config = configPath ? require(configPath) : {}
420
- let resolvedConfig = resolveConfigInternal(config)
421
440
 
422
441
  if (args['--purge']) {
423
442
  log.warn('purge-flag-deprecated', [
@@ -430,10 +449,13 @@ async function build() {
430
449
  }
431
450
 
432
451
  if (args['--content']) {
433
- resolvedConfig.content.files = args['--content'].split(/(?<!{[^}]+),/)
452
+ let files = args['--content'].split(/(?<!{[^}]+),/)
453
+ let resolvedConfig = resolveConfigInternal(config, { content: { files } })
454
+ resolvedConfig.content.files = files
455
+ return resolvedConfig
434
456
  }
435
457
 
436
- return resolvedConfig
458
+ return resolveConfigInternal(config)
437
459
  }
438
460
 
439
461
  function extractFileGlobs(config) {
@@ -534,10 +556,11 @@ async function build() {
534
556
  if (!output) {
535
557
  return process.stdout.write(result.css)
536
558
  }
559
+
537
560
  return Promise.all(
538
561
  [
539
- fs.promises.writeFile(output, result.css, () => true),
540
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
562
+ outputFile(output, result.css),
563
+ result.map && outputFile(output + '.map', result.map.toString()),
541
564
  ].filter(Boolean)
542
565
  )
543
566
  })
@@ -548,9 +571,21 @@ async function build() {
548
571
  })
549
572
  }
550
573
 
551
- let css = input
552
- ? fs.readFileSync(path.resolve(input), 'utf8')
553
- : '@tailwind base; @tailwind components; @tailwind utilities'
574
+ let css = await (() => {
575
+ // Piping in data, let's drain the stdin
576
+ if (input === '-') {
577
+ return drainStdin()
578
+ }
579
+
580
+ // Input file has been provided
581
+ if (input) {
582
+ return fs.readFileSync(path.resolve(input), 'utf8')
583
+ }
584
+
585
+ // No input file provided, fallback to default atrules
586
+ return '@tailwind base; @tailwind components; @tailwind utilities'
587
+ })()
588
+
554
589
  return processCSS(css)
555
590
  }
556
591
 
@@ -664,10 +699,10 @@ async function build() {
664
699
  return process.stdout.write(result.css)
665
700
  }
666
701
 
667
- await Promise.all(
702
+ return Promise.all(
668
703
  [
669
- fs.promises.writeFile(output, result.css, () => true),
670
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
704
+ outputFile(output, result.css),
705
+ result.map && outputFile(output + '.map', result.map.toString()),
671
706
  ].filter(Boolean)
672
707
  )
673
708
  })
@@ -684,9 +719,21 @@ async function build() {
684
719
  })
685
720
  }
686
721
 
687
- let css = input
688
- ? fs.readFileSync(path.resolve(input), 'utf8')
689
- : '@tailwind base; @tailwind components; @tailwind utilities'
722
+ let css = await (() => {
723
+ // Piping in data, let's drain the stdin
724
+ if (input === '-') {
725
+ return drainStdin()
726
+ }
727
+
728
+ // Input file has been provided
729
+ if (input) {
730
+ return fs.readFileSync(path.resolve(input), 'utf8')
731
+ }
732
+
733
+ // No input file provided, fallback to default atrules
734
+ return '@tailwind base; @tailwind components; @tailwind utilities'
735
+ })()
736
+
690
737
  let result = await processCSS(css)
691
738
  env.DEBUG && console.timeEnd('Finished in')
692
739
  return result