tailwindcss 0.0.0-insiders.c5e7857 → 0.0.0-insiders.c601fea

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 (101) hide show
  1. package/CHANGELOG.md +68 -2
  2. package/README.md +6 -3
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli-peer-dependencies.js +12 -4
  5. package/lib/cli.js +144 -75
  6. package/lib/constants.js +19 -12
  7. package/lib/corePluginList.js +5 -3
  8. package/lib/corePlugins.js +220 -203
  9. package/lib/css/preflight.css +5 -0
  10. package/lib/featureFlags.js +16 -8
  11. package/lib/index.js +9 -6
  12. package/lib/lib/cacheInvalidation.js +18 -15
  13. package/lib/lib/collapseAdjacentRules.js +14 -11
  14. package/lib/lib/collapseDuplicateDeclarations.js +11 -8
  15. package/lib/lib/defaultExtractor.js +41 -33
  16. package/lib/lib/detectNesting.js +4 -1
  17. package/lib/lib/evaluateTailwindFunctions.js +75 -44
  18. package/lib/lib/expandApplyAtRules.js +104 -62
  19. package/lib/lib/expandTailwindAtRules.js +150 -150
  20. package/lib/lib/generateRules.js +125 -107
  21. package/lib/lib/getModuleDependencies.js +21 -18
  22. package/lib/lib/normalizeTailwindDirectives.js +10 -7
  23. package/lib/lib/partitionApplyAtRules.js +14 -11
  24. package/lib/lib/regex.js +15 -7
  25. package/lib/lib/resolveDefaultsAtRules.js +92 -85
  26. package/lib/lib/setupContextUtils.js +116 -97
  27. package/lib/lib/setupTrackingContext.js +85 -76
  28. package/lib/lib/sharedState.js +15 -8
  29. package/lib/lib/substituteScreenAtRules.js +8 -5
  30. package/lib/postcss-plugins/nesting/index.js +7 -5
  31. package/lib/postcss-plugins/nesting/plugin.js +7 -4
  32. package/lib/processTailwindFeatures.js +34 -31
  33. package/lib/public/colors.js +6 -4
  34. package/lib/public/create-plugin.js +6 -4
  35. package/lib/public/default-config.js +7 -5
  36. package/lib/public/default-theme.js +7 -5
  37. package/lib/public/resolve-config.js +13 -10
  38. package/lib/util/bigSign.js +4 -1
  39. package/lib/util/buildMediaQuery.js +5 -2
  40. package/lib/util/cloneDeep.js +4 -1
  41. package/lib/util/cloneNodes.js +9 -2
  42. package/lib/util/color.js +11 -3
  43. package/lib/util/configurePlugins.js +4 -1
  44. package/lib/util/createPlugin.js +5 -3
  45. package/lib/util/createUtilityPlugin.js +13 -10
  46. package/lib/util/dataTypes.js +28 -22
  47. package/lib/util/defaults.js +4 -1
  48. package/lib/util/escapeClassName.js +12 -9
  49. package/lib/util/escapeCommas.js +4 -1
  50. package/lib/util/flattenColorPalette.js +5 -3
  51. package/lib/util/formatVariantSelector.js +23 -15
  52. package/lib/util/getAllConfigs.js +26 -12
  53. package/lib/util/hashConfig.js +10 -7
  54. package/lib/util/isKeyframeRule.js +4 -1
  55. package/lib/util/isPlainObject.js +4 -1
  56. package/lib/util/isValidArbitraryValue.js +33 -24
  57. package/lib/util/log.js +12 -5
  58. package/lib/util/nameClass.js +16 -8
  59. package/lib/util/negateValue.js +4 -1
  60. package/lib/util/normalizeConfig.js +26 -23
  61. package/lib/util/normalizeScreens.js +17 -2
  62. package/lib/util/parseAnimationValue.js +42 -39
  63. package/lib/util/parseBoxShadowValue.js +12 -4
  64. package/lib/util/parseDependency.js +35 -32
  65. package/lib/util/parseObjectStyles.js +14 -11
  66. package/lib/util/pluginUtils.js +28 -20
  67. package/lib/util/prefixSelector.js +6 -3
  68. package/lib/util/removeAlphaVariables.js +13 -2
  69. package/lib/util/resolveConfig.js +56 -53
  70. package/lib/util/resolveConfigPath.js +20 -17
  71. package/lib/util/responsive.js +12 -9
  72. package/lib/util/splitAtTopLevelOnly.js +16 -13
  73. package/lib/util/tap.js +4 -1
  74. package/lib/util/toColorValue.js +4 -1
  75. package/lib/util/toPath.js +18 -2
  76. package/lib/util/transformThemeValue.js +10 -7
  77. package/lib/util/validateConfig.js +5 -2
  78. package/lib/util/withAlphaVariable.js +30 -22
  79. package/package.json +15 -15
  80. package/peers/index.js +3530 -2037
  81. package/resolveConfig.d.ts +3 -0
  82. package/scripts/generate-types.js +53 -0
  83. package/scripts/type-utils.js +27 -0
  84. package/src/cli.js +81 -0
  85. package/src/corePlugins.js +25 -5
  86. package/src/css/preflight.css +5 -0
  87. package/src/featureFlags.js +5 -1
  88. package/src/lib/defaultExtractor.js +7 -1
  89. package/src/lib/evaluateTailwindFunctions.js +41 -15
  90. package/src/lib/expandApplyAtRules.js +71 -18
  91. package/src/lib/expandTailwindAtRules.js +1 -5
  92. package/src/lib/generateRules.js +51 -36
  93. package/src/lib/setupContextUtils.js +16 -2
  94. package/src/lib/setupTrackingContext.js +1 -1
  95. package/src/util/cloneNodes.js +5 -1
  96. package/src/util/dataTypes.js +1 -3
  97. package/src/util/formatVariantSelector.js +3 -1
  98. package/src/util/getAllConfigs.js +14 -2
  99. package/src/util/resolveConfig.js +1 -1
  100. package/types/config.d.ts +8 -6
  101. package/types/generated/default-theme.d.ts +331 -0
package/CHANGELOG.md CHANGED
@@ -7,10 +7,71 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add support for configuring default `font-feature-settings` for a font family ([#9039](https://github.com/tailwindlabs/tailwindcss/pull/9039))
13
+ - Add a standalone CLI build for 32-bit Linux on ARM (`node16-linux-armv7`) ([#9084](https://github.com/tailwindlabs/tailwindcss/pull/9084))
14
+ - Add future flag to disable color opacity utility plugins ([#9088](https://github.com/tailwindlabs/tailwindcss/pull/9088))
15
+ - Add negative value support for `outline-offset` ([#9136](https://github.com/tailwindlabs/tailwindcss/pull/9136))
16
+
17
+ ### Fixed
18
+
19
+ - Use absolute paths when resolving changed files for resilience against working directory changes ([#9032](https://github.com/tailwindlabs/tailwindcss/pull/9032))
20
+ - Fix ring color utility generation when using `respectDefaultRingColorOpacity` ([#9070](https://github.com/tailwindlabs/tailwindcss/pull/9070))
21
+ - Sort tags before classes when `@applying` a selector with joined classes ([#9107](https://github.com/tailwindlabs/tailwindcss/pull/9107))
22
+ - Remove invalid `outline-hidden` utility ([#9147](https://github.com/tailwindlabs/tailwindcss/pull/9147))
23
+ - Honor the `hidden` attribute on elements in preflight ([#9174](https://github.com/tailwindlabs/tailwindcss/pull/9174))
24
+ - Don't stop watching atomically renamed files ([#9173](https://github.com/tailwindlabs/tailwindcss/pull/9173))
25
+ - Re-use existing entries in the rule cache ([#9208](https://github.com/tailwindlabs/tailwindcss/pull/9208))
26
+ - Don't output duplicate utilities ([#9208](https://github.com/tailwindlabs/tailwindcss/pull/9208))
27
+
28
+ ## [3.1.8] - 2022-08-05
29
+
30
+ ### Fixed
31
+
32
+ - Don’t prefix classes within reused arbitrary variants ([#8992](https://github.com/tailwindlabs/tailwindcss/pull/8992))
33
+ - Fix usage of alpha values inside single-named colors that are functions ([#9008](https://github.com/tailwindlabs/tailwindcss/pull/9008))
34
+ - Fix `@apply` of user utilities when negative and non-negative versions both exist ([#9027](https://github.com/tailwindlabs/tailwindcss/pull/9027))
35
+
36
+ ## [3.1.7] - 2022-07-29
37
+
38
+ ### Fixed
39
+
40
+ - Don't rewrite source maps for `@layer` rules ([#8971](https://github.com/tailwindlabs/tailwindcss/pull/8971))
41
+
42
+ ### Added
43
+
44
+ - Added types for `resolveConfig` ([#8924](https://github.com/tailwindlabs/tailwindcss/pull/8924))
45
+
46
+ ## [3.1.6] - 2022-07-11
47
+
48
+ ### Fixed
49
+
50
+ - Fix usage on Node 12.x ([b4e637e](https://github.com/tailwindlabs/tailwindcss/commit/b4e637e2e096a9d6f2210efba9541f6fd4f28e56))
51
+ - Handle theme keys with slashes when using `theme()` in CSS ([#8831](https://github.com/tailwindlabs/tailwindcss/pull/8831))
52
+
53
+ ## [3.1.5] - 2022-07-07
54
+
55
+ ### Added
56
+
57
+ - Support configuring a default `font-weight` for each font size utility ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
58
+ - Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
59
+
60
+ ### Fixed
61
+
62
+ - Improve types to support fallback values in the CSS-in-JS syntax used in plugin APIs ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
63
+ - Support including `tailwindcss` and `autoprefixer` in `postcss.config.js` in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
64
+ - Fix using special-characters as prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
65
+ - Don’t prefix classes used within arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
66
+ - Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
67
+
68
+ ## [3.1.4] - 2022-06-21
69
+
10
70
  ### Fixed
11
71
 
12
72
  - Provide default to `<alpha-value>` when using `theme()` ([#8652](https://github.com/tailwindlabs/tailwindcss/pull/8652))
13
73
  - Detect arbitrary variants with quotes ([#8687](https://github.com/tailwindlabs/tailwindcss/pull/8687))
74
+ - Don’t add spaces around raw `/` that are preceded by numbers ([#8688](https://github.com/tailwindlabs/tailwindcss/pull/8688))
14
75
 
15
76
  ## [3.1.3] - 2022-06-14
16
77
 
@@ -1618,7 +1679,7 @@ No release notes
1618
1679
 
1619
1680
  - Make it possible to disable all core plugins using `corePlugins: false`
1620
1681
  - Make it possible to configure a single list of variants that applies to all utility plugins
1621
- - Make it possible to whitelist which core plugins should be enabled
1682
+ - Make it possible to safelist which core plugins should be enabled
1622
1683
 
1623
1684
  ### Fixed
1624
1685
 
@@ -1984,7 +2045,12 @@ No release notes
1984
2045
 
1985
2046
  - Everything!
1986
2047
 
1987
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...HEAD
2048
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.8...HEAD
2049
+ [3.1.8]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.7...v3.1.8
2050
+ [3.1.7]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.6...v3.1.7
2051
+ [3.1.6]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...v3.1.6
2052
+ [3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
2053
+ [3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
1988
2054
  [3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
1989
2055
  [3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
1990
2056
  [3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <p>
1
+ <p align="center">
2
2
  <a href="https://tailwindcss.com/#gh-light-mode-only" target="_blank">
3
3
  <img src="./.github/logo-light.svg" alt="Tailwind CSS" width="350" height="70">
4
4
  </a>
@@ -7,9 +7,12 @@
7
7
  </a>
8
8
  </p>
9
9
 
10
- A utility-first CSS framework for rapidly building custom user interfaces.
10
+ <p align="center">
11
+ A utility-first CSS framework for rapidly building custom user interfaces.
12
+ </p>
13
+
11
14
 
12
- <p>
15
+ <p align="center">
13
16
  <a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/workflow/status/tailwindlabs/tailwindcss/Node.js%20CI" alt="Build Status"></a>
14
17
  <a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
15
18
  <a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
package/defaultTheme.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Config } from './types/config'
2
- declare const theme: Config['theme']
2
+ import { DefaultTheme } from './types/generated/default-theme'
3
+ declare const theme: Config['theme'] & DefaultTheme
3
4
  export = theme
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.lazyPostcss = lazyPostcss;
6
- exports.lazyPostcssImport = lazyPostcssImport;
7
- exports.lazyAutoprefixer = lazyAutoprefixer;
8
- exports.lazyCssnano = lazyCssnano;
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
+ lazyPostcss: ()=>lazyPostcss,
13
+ lazyPostcssImport: ()=>lazyPostcssImport,
14
+ lazyAutoprefixer: ()=>lazyAutoprefixer,
15
+ lazyCssnano: ()=>lazyCssnano
16
+ });
9
17
  function lazyPostcss() {
10
18
  return require("postcss");
11
19
  }
package/lib/cli.js CHANGED
@@ -1,24 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var _indexJs = require("../peers/index.js");
4
- var _chokidar = _interopRequireDefault(require("chokidar"));
5
- var _path = _interopRequireDefault(require("path"));
6
- var _arg = _interopRequireDefault(require("arg"));
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
9
- var _lilconfig = require("lilconfig");
10
- var _plugins // Little bit scary, looking at private/internal API
11
- = _interopRequireDefault(require("postcss-load-config/src/plugins"));
12
- var _options // Little bit scary, looking at private/internal API
13
- = _interopRequireDefault(require("postcss-load-config/src/options"));
14
- var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
15
- var _resolveConfig = _interopRequireDefault(require("../resolveConfig"));
16
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
17
- var _getModuleDependencies = _interopRequireDefault(require("./lib/getModuleDependencies"));
18
- var _log = _interopRequireDefault(require("./util/log"));
19
- var _packageJson = _interopRequireDefault(require("../package.json"));
20
- var _normalizePath = _interopRequireDefault(require("normalize-path"));
21
- var _validateConfigJs = require("./util/validateConfig.js");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ const _indexJs = require("../peers/index.js");
7
+ const _chokidar = /*#__PURE__*/ _interopRequireDefault(require("chokidar"));
8
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
9
+ const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
10
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
11
+ const _postcssLoadConfig = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config"));
12
+ const _lilconfig = require("lilconfig");
13
+ const _plugins = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
14
+ ));
15
+ const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
16
+ ));
17
+ const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
18
+ const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../resolveConfig"));
19
+ const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
20
+ const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("./lib/getModuleDependencies"));
21
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
22
+ const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../package.json"));
23
+ const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
24
+ const _validateConfigJs = require("./util/validateConfig.js");
22
25
  function _interopRequireDefault(obj) {
23
26
  return obj && obj.__esModule ? obj : {
24
27
  default: obj
@@ -76,7 +79,7 @@ function drainStdin() {
76
79
  process.stdin.on("error", (err)=>reject(err));
77
80
  });
78
81
  }
79
- function help({ message , usage , commands: commands1 , options }) {
82
+ function help({ message , usage , commands , options }) {
80
83
  let indent = 2;
81
84
  // Render header
82
85
  console.log();
@@ -97,11 +100,11 @@ function help({ message , usage , commands: commands1 , options }) {
97
100
  }
98
101
  }
99
102
  // Render commands
100
- if (commands1 && commands1.length > 0) {
103
+ if (commands && commands.length > 0) {
101
104
  console.log();
102
105
  console.log("Commands:");
103
- for (let command1 of commands1){
104
- console.log(" ".repeat(indent), command1);
106
+ for (let command of commands){
107
+ console.log(" ".repeat(indent), command);
105
108
  }
106
109
  }
107
110
  // Render options
@@ -121,12 +124,12 @@ function help({ message , usage , commands: commands1 , options }) {
121
124
  }
122
125
  console.log();
123
126
  console.log("Options:");
124
- for (let { flags: flags1 , description , deprecated } of Object.values(groupedOptions)){
127
+ for (let { flags , description , deprecated } of Object.values(groupedOptions)){
125
128
  if (deprecated) continue;
126
- if (flags1.length === 1) {
127
- console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags1.slice().reverse().join(", ").padEnd(20, " "), description);
129
+ if (flags.length === 1) {
130
+ console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
128
131
  } else {
129
- console.log(" ".repeat(indent), flags1.slice().reverse().join(", ").padEnd(24, " "), description);
132
+ console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
130
133
  }
131
134
  }
132
135
  }
@@ -150,7 +153,7 @@ function loadPostcss() {
150
153
  try {
151
154
  return require("postcss");
152
155
  } catch {}
153
- return (0, _indexJs).lazyPostcss();
156
+ return (0, _indexJs.lazyPostcss)();
154
157
  }
155
158
  let commands = {
156
159
  init: {
@@ -233,7 +236,7 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
233
236
  "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
234
237
  "tailwindcss init [--full] [--postcss] [options...]",
235
238
  ],
236
- commands: Object.keys(commands).filter((command2)=>command2 !== "build").map((command3)=>`${command3} [options]`),
239
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
237
240
  options: {
238
241
  ...commands.build.args,
239
242
  ...sharedFlags
@@ -253,7 +256,7 @@ if (commands[command] === undefined) {
253
256
  usage: [
254
257
  "tailwindcss <command> [options]"
255
258
  ],
256
- commands: Object.keys(commands).filter((command4)=>command4 !== "build").map((command5)=>`${command5} [options]`),
259
+ commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
257
260
  options: sharedFlags
258
261
  });
259
262
  process.exit(1);
@@ -263,7 +266,7 @@ if (commands[command] === undefined) {
263
266
  let { args: flags , run } = commands[command];
264
267
  let args = (()=>{
265
268
  try {
266
- let result = (0, _arg).default(Object.fromEntries(Object.entries({
269
+ let result = (0, _arg.default)(Object.fromEntries(Object.entries({
267
270
  ...flags,
268
271
  ...sharedFlags
269
272
  }).filter(([_key, value])=>{
@@ -287,16 +290,16 @@ let args = (()=>{
287
290
  handler = flags[handler];
288
291
  }
289
292
  if (!handler) continue;
290
- let args1 = [];
293
+ let args = [];
291
294
  let offset = i + 1;
292
295
  // Parse args for current flag
293
296
  while(result["_"][offset] && !result["_"][offset].startsWith("-")){
294
- args1.push(result["_"][offset++]);
297
+ args.push(result["_"][offset++]);
295
298
  }
296
299
  // Cleanup manually parsed flags + args
297
- result["_"].splice(i, 1 + args1.length);
300
+ result["_"].splice(i, 1 + args.length);
298
301
  // Set the resolved value in the `result` object
299
- result[flagName] = handler.type(args1.length === 0 ? undefined : args1.length === 1 ? args1[0] : args1, flagName);
302
+ result[flagName] = handler.type(args.length === 0 ? undefined : args.length === 1 ? args[0] : args, flagName);
300
303
  }
301
304
  // Ensure that the `command` is always the first argument in the `args`.
302
305
  // This is important so that we don't have to check if a default command
@@ -354,8 +357,8 @@ function init() {
354
357
  if (_fs.default.existsSync(postcssConfigLocation)) {
355
358
  messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
356
359
  } else {
357
- let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, "../stubs/defaultPostCssConfig.stub.js"), "utf8");
358
- _fs.default.writeFileSync(postcssConfigLocation, stubFile, "utf8");
360
+ let stubFile1 = _fs.default.readFileSync(_path.default.resolve(__dirname, "../stubs/defaultPostCssConfig.stub.js"), "utf8");
361
+ _fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8");
359
362
  messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
360
363
  }
361
364
  }
@@ -392,10 +395,10 @@ async function build() {
392
395
  let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
393
396
  async function loadPostCssPlugins() {
394
397
  let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
395
- let config1 = customPostCssPath ? await (async ()=>{
398
+ let config = customPostCssPath ? await (async ()=>{
396
399
  let file = _path.default.resolve(customPostCssPath);
397
400
  // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
398
- let { config ={} } = await (0, _lilconfig).lilconfig("postcss").load(file);
401
+ let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
399
402
  if (typeof config === "function") {
400
403
  config = config();
401
404
  } else {
@@ -406,11 +409,11 @@ async function build() {
406
409
  }
407
410
  return {
408
411
  file,
409
- plugins: (0, _plugins).default(config, file),
410
- options: (0, _options).default(config, file)
412
+ plugins: (0, _plugins.default)(config, file),
413
+ options: (0, _options.default)(config, file)
411
414
  };
412
- })() : await (0, _postcssLoadConfig).default();
413
- let configPlugins = config1.plugins;
415
+ })() : await (0, _postcssLoadConfig.default)();
416
+ let configPlugins = config.plugins;
414
417
  let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
415
418
  if (typeof plugin === "function" && plugin.name === "tailwindcss") {
416
419
  return true;
@@ -425,7 +428,7 @@ async function build() {
425
428
  return [
426
429
  beforePlugins,
427
430
  afterPlugins,
428
- config1.options
431
+ config.options
429
432
  ];
430
433
  }
431
434
  function loadBuiltinPostcssPlugins() {
@@ -447,7 +450,7 @@ async function build() {
447
450
  try {
448
451
  return require("postcss-import");
449
452
  } catch {}
450
- return (0, _indexJs).lazyPostcssImport();
453
+ return (0, _indexJs.lazyPostcssImport)();
451
454
  })(),
452
455
  (root)=>{
453
456
  root.walkComments((rule)=>{
@@ -478,18 +481,18 @@ async function build() {
478
481
  }
479
482
  if (args["--content"]) {
480
483
  let files = args["--content"].split(/(?<!{[^}]+),/);
481
- let resolvedConfig = (0, _resolveConfig).default(config, {
484
+ let resolvedConfig = (0, _resolveConfig.default)(config, {
482
485
  content: {
483
486
  files
484
487
  }
485
488
  });
486
489
  resolvedConfig.content.files = files;
487
- resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
490
+ resolvedConfig = (0, _validateConfigJs.validateConfig)(resolvedConfig);
488
491
  return resolvedConfig;
489
492
  }
490
- let resolvedConfig = (0, _resolveConfig).default(config);
491
- resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
492
- return resolvedConfig;
493
+ let resolvedConfig1 = (0, _resolveConfig.default)(config);
494
+ resolvedConfig1 = (0, _validateConfigJs.validateConfig)(resolvedConfig1);
495
+ return resolvedConfig1;
493
496
  }
494
497
  function extractFileGlobs(config) {
495
498
  return config.content.files.filter((file)=>{
@@ -497,7 +500,7 @@ async function build() {
497
500
  // like an object it's probably a raw content object. But this object
498
501
  // is not watchable, so let's remove it.
499
502
  return typeof file === "string";
500
- }).map((glob)=>(0, _normalizePath).default(glob));
503
+ }).map((glob)=>(0, _normalizePath.default)(glob));
501
504
  }
502
505
  function extractRawContent(config) {
503
506
  return config.content.files.filter((file)=>{
@@ -531,7 +534,7 @@ async function build() {
531
534
  return {
532
535
  postcssPlugin: "tailwindcss",
533
536
  Once (root, { result }) {
534
- (0, _processTailwindFeatures).default(({ createContext })=>{
537
+ (0, _processTailwindFeatures.default)(({ createContext })=>{
535
538
  return ()=>{
536
539
  return createContext(config, changedContent);
537
540
  };
@@ -551,7 +554,7 @@ async function build() {
551
554
  try {
552
555
  return require("autoprefixer");
553
556
  } catch {}
554
- return (0, _indexJs).lazyAutoprefixer();
557
+ return (0, _indexJs.lazyAutoprefixer)();
555
558
  })(),
556
559
  args["--minify"] && (()=>{
557
560
  let options = {
@@ -566,7 +569,7 @@ async function build() {
566
569
  try {
567
570
  return require("cssnano");
568
571
  } catch {}
569
- return (0, _indexJs).lazyCssnano()(options);
572
+ return (0, _indexJs.lazyCssnano)()(options);
570
573
  })(),
571
574
  ].filter(Boolean);
572
575
  let postcss = loadPostcss();
@@ -593,7 +596,7 @@ async function build() {
593
596
  console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
594
597
  });
595
598
  }
596
- let css1 = await (()=>{
599
+ let css = await (()=>{
597
600
  // Piping in data, let's drain the stdin
598
601
  if (input === "-") {
599
602
  return drainStdin();
@@ -605,7 +608,7 @@ async function build() {
605
608
  // No input file provided, fallback to default atrules
606
609
  return "@tailwind base; @tailwind components; @tailwind utilities";
607
610
  })();
608
- return processCSS(css1);
611
+ return processCSS(css);
609
612
  }
610
613
  let context = null;
611
614
  async function startWatcher() {
@@ -615,11 +618,11 @@ async function build() {
615
618
  let watcher = null;
616
619
  function refreshConfig() {
617
620
  env.DEBUG && console.time("Module dependencies");
618
- for (let file1 of configDependencies){
619
- delete require.cache[require.resolve(file1)];
621
+ for (let file of configDependencies){
622
+ delete require.cache[require.resolve(file)];
620
623
  }
621
624
  if (configPath) {
622
- configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file);
625
+ configDependencies = (0, _getModuleDependencies.default)(configPath).map(({ file })=>file);
623
626
  for (let dependency of configDependencies){
624
627
  contextDependencies.add(dependency);
625
628
  }
@@ -638,7 +641,7 @@ async function build() {
638
641
  try {
639
642
  return require("autoprefixer");
640
643
  } catch {}
641
- return (0, _indexJs).lazyAutoprefixer();
644
+ return (0, _indexJs.lazyAutoprefixer)();
642
645
  })(),
643
646
  args["--minify"] && (()=>{
644
647
  let options = {
@@ -653,7 +656,7 @@ async function build() {
653
656
  try {
654
657
  return require("cssnano");
655
658
  } catch {}
656
- return (0, _indexJs).lazyCssnano()(options);
659
+ return (0, _indexJs.lazyCssnano)()(options);
657
660
  })(),
658
661
  ].filter(Boolean);
659
662
  async function rebuild(config) {
@@ -663,7 +666,7 @@ async function build() {
663
666
  postcssPlugin: "tailwindcss",
664
667
  Once (root, { result }) {
665
668
  env.DEBUG && console.time("Compiling CSS");
666
- (0, _processTailwindFeatures).default(({ createContext })=>{
669
+ (0, _processTailwindFeatures.default)(({ createContext })=>{
667
670
  console.error();
668
671
  console.error("Rebuilding...");
669
672
  return ()=>{
@@ -721,7 +724,7 @@ async function build() {
721
724
  }
722
725
  });
723
726
  }
724
- let css2 = await (()=>{
727
+ let css = await (()=>{
725
728
  // Piping in data, let's drain the stdin
726
729
  if (input === "-") {
727
730
  return drainStdin();
@@ -733,18 +736,22 @@ async function build() {
733
736
  // No input file provided, fallback to default atrules
734
737
  return "@tailwind base; @tailwind components; @tailwind utilities";
735
738
  })();
736
- let result1 = await processCSS(css2);
739
+ let result = await processCSS(css);
737
740
  env.DEBUG && console.timeEnd("Finished in");
738
- return result1;
741
+ return result;
739
742
  }
740
- let config2 = refreshConfig(configPath);
743
+ let config = refreshConfig(configPath);
741
744
  if (input) {
742
745
  contextDependencies.add(_path.default.resolve(input));
743
746
  }
744
747
  watcher = _chokidar.default.watch([
745
748
  ...contextDependencies,
746
- ...extractFileGlobs(config2)
749
+ ...extractFileGlobs(config)
747
750
  ], {
751
+ // Force checking for atomic writes in all situations
752
+ // This causes chokidar to wait up to 100ms for a file to re-added after it's been unlinked
753
+ // This only works when watching directories though
754
+ atomic: true,
748
755
  usePolling: shouldPoll,
749
756
  interval: shouldPoll ? pollInterval : undefined,
750
757
  ignoreInitial: true,
@@ -754,20 +761,21 @@ async function build() {
754
761
  } : false
755
762
  });
756
763
  let chain = Promise.resolve();
764
+ let pendingRebuilds = new Set();
757
765
  watcher.on("change", async (file)=>{
758
766
  if (contextDependencies.has(file)) {
759
767
  env.DEBUG && console.time("Resolve config");
760
768
  context = null;
761
- config2 = refreshConfig(configPath);
769
+ config = refreshConfig(configPath);
762
770
  env.DEBUG && console.timeEnd("Resolve config");
763
771
  env.DEBUG && console.time("Watch new files");
764
- let globs = extractFileGlobs(config2);
772
+ let globs = extractFileGlobs(config);
765
773
  watcher.add(configDependencies);
766
774
  watcher.add(globs);
767
775
  env.DEBUG && console.timeEnd("Watch new files");
768
776
  chain = chain.then(async ()=>{
769
- changedContent.push(...getChangedContent(config2));
770
- await rebuild(config2);
777
+ changedContent.push(...getChangedContent(config));
778
+ await rebuild(config);
771
779
  });
772
780
  } else {
773
781
  chain = chain.then(async ()=>{
@@ -775,22 +783,83 @@ async function build() {
775
783
  content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
776
784
  extension: _path.default.extname(file).slice(1)
777
785
  });
778
- await rebuild(config2);
786
+ await rebuild(config);
779
787
  });
780
788
  }
781
789
  });
790
+ /**
791
+ * When rapidly saving files atomically a couple of situations can happen:
792
+ * - The file is missing since the external program has deleted it by the time we've gotten around to reading it from the earlier save.
793
+ * - The file is being written to by the external program by the time we're going to read it and is thus treated as busy because a lock is held.
794
+ *
795
+ * To work around this we retry reading the file a handful of times with a delay between each attempt
796
+ *
797
+ * @param {string} path
798
+ * @param {number} tries
799
+ * @returns {string}
800
+ * @throws {Error} If the file is still missing or busy after the specified number of tries
801
+ */ async function readFileWithRetries(path, tries = 5) {
802
+ for(let n = 0; n <= tries; n++){
803
+ try {
804
+ return await _fs.default.promises.readFile(path, "utf8");
805
+ } catch (err) {
806
+ if (n !== tries) {
807
+ if (err.code === "ENOENT" || err.code === "EBUSY") {
808
+ await new Promise((resolve)=>setTimeout(resolve, 10));
809
+ continue;
810
+ }
811
+ }
812
+ throw err;
813
+ }
814
+ }
815
+ }
816
+ // Restore watching any files that are "removed"
817
+ // This can happen when a file is pseudo-atomically replaced (a copy is created, overwritten, the old one is unlinked, and the new one is renamed)
818
+ // TODO: An an optimization we should allow removal when the config changes
819
+ watcher.on("unlink", (file)=>watcher.add(file));
820
+ // Some applications such as Visual Studio (but not VS Code)
821
+ // will only fire a rename event for atomic writes and not a change event
822
+ // This is very likely a chokidar bug but it's one we need to work around
823
+ // We treat this as a change event and rebuild the CSS
824
+ watcher.on("raw", (evt, filePath, meta)=>{
825
+ if (evt !== "rename") {
826
+ return;
827
+ }
828
+ let watchedPath = _path.default.resolve(meta.watchedPath);
829
+ // Watched path might be the file itself
830
+ // Or the directory it is in
831
+ filePath = watchedPath.endsWith(filePath) ? watchedPath : _path.default.resolve(watchedPath, filePath);
832
+ // Skip since we've already queued a rebuild for this file that hasn't happened yet
833
+ if (pendingRebuilds.has(filePath)) {
834
+ return;
835
+ }
836
+ pendingRebuilds.add(filePath);
837
+ chain = chain.then(async ()=>{
838
+ let content;
839
+ try {
840
+ content = await readFileWithRetries(_path.default.resolve(filePath));
841
+ } finally{
842
+ pendingRebuilds.delete(filePath);
843
+ }
844
+ changedContent.push({
845
+ content,
846
+ extension: _path.default.extname(filePath).slice(1)
847
+ });
848
+ await rebuild(config);
849
+ });
850
+ });
782
851
  watcher.on("add", async (file)=>{
783
852
  chain = chain.then(async ()=>{
784
853
  changedContent.push({
785
854
  content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
786
855
  extension: _path.default.extname(file).slice(1)
787
856
  });
788
- await rebuild(config2);
857
+ await rebuild(config);
789
858
  });
790
859
  });
791
860
  chain = chain.then(()=>{
792
- changedContent.push(...getChangedContent(config2));
793
- return rebuild(config2);
861
+ changedContent.push(...getChangedContent(config));
862
+ return rebuild(config);
794
863
  });
795
864
  }
796
865
  if (shouldWatch) {