tailwindcss 3.2.3 → 3.2.4

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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  - Nothing yet!
11
11
 
12
+ ## [3.2.4] - 2022-11-11
13
+
14
+ ### Added
15
+
16
+ - Add `blocklist` option to prevent generating unwanted CSS ([#9812](https://github.com/tailwindlabs/tailwindcss/pull/9812))
17
+
18
+ ### Fixed
19
+
20
+ - Fix watching of files on Linux when renames are involved ([#9796](https://github.com/tailwindlabs/tailwindcss/pull/9796))
21
+ - Make sure errors are always displayed when watching for changes ([#9810](https://github.com/tailwindlabs/tailwindcss/pull/9810))
22
+
12
23
  ## [3.2.3] - 2022-11-09
13
24
 
14
25
  ### Fixed
@@ -2110,7 +2121,8 @@ No release notes
2110
2121
 
2111
2122
  - Everything!
2112
2123
 
2113
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.3...HEAD
2124
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.4...HEAD
2125
+ [3.2.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.3...v3.2.4
2114
2126
  [3.2.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.2...v3.2.3
2115
2127
  [3.2.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.1...v3.2.2
2116
2128
  [3.2.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.0...v3.2.1
@@ -311,6 +311,17 @@ async function createProcessor(args, cliConfigPath) {
311
311
  let end = process.hrtime.bigint();
312
312
  console.error();
313
313
  console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
314
+ }).then(()=>{}, (err)=>{
315
+ // TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
316
+ // that were collected before the error occurred
317
+ // The result is not stored on the error so we have to store it externally
318
+ // and pull the messages off of it here somehow
319
+ // This results in a less than ideal DX because the watcher will not pick up
320
+ // changes to imported CSS if one of them caused an error during the initial build
321
+ // If you fix it and then save the main CSS file so there's no error
322
+ // The watcher will start watching the imported CSS files and will be
323
+ // resilient to future errors.
324
+ console.error(err);
314
325
  });
315
326
  }
316
327
  /**
@@ -70,12 +70,13 @@ function createWatcher(args, { state , rebuild }) {
70
70
  *
71
71
  * @param {*} file
72
72
  * @param {(() => Promise<string>) | null} content
73
+ * @param {boolean} skipPendingCheck
73
74
  * @returns {Promise<void>}
74
- */ function recordChangedFile(file, content = null) {
75
+ */ function recordChangedFile(file, content = null, skipPendingCheck = false) {
75
76
  file = _path.default.resolve(file);
76
77
  // Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
77
78
  // In that case rebuild has already been queued by rename, so can be skipped in change
78
- if (pendingRebuilds.has(file)) {
79
+ if (pendingRebuilds.has(file) && !skipPendingCheck) {
79
80
  return Promise.resolve();
80
81
  }
81
82
  // Mark that a rebuild of this file is going to happen
@@ -152,8 +153,10 @@ function createWatcher(args, { state , rebuild }) {
152
153
  return;
153
154
  }
154
155
  // This will push the rebuild onto the chain
156
+ // We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
157
+ // This is because the order of events and timing is different on Linux
155
158
  // @ts-ignore: TypeScript isn't picking up that content is a string here
156
- await recordChangedFile(filePath, ()=>content);
159
+ await recordChangedFile(filePath, ()=>content, true);
157
160
  } catch {
158
161
  // If reading the file fails, it's was probably a deleted temporary file
159
162
  // So we can ignore it and no rebuild is needed
@@ -1098,13 +1098,15 @@ function registerPlugins(plugins, context) {
1098
1098
  markInvalidUtilityCandidate(context, candidate);
1099
1099
  }
1100
1100
  function createContext(tailwindConfig, changedContent = [], root = _postcss.default.root()) {
1101
+ var _blocklist;
1101
1102
  let context = {
1102
1103
  disposables: [],
1103
1104
  ruleCache: new Set(),
1104
1105
  candidateRuleCache: new Map(),
1105
1106
  classCache: new Map(),
1106
1107
  applyClassCache: new Map(),
1107
- notClassCache: new Set(),
1108
+ // Seed the not class cache with the blocklist (which is only strings)
1109
+ notClassCache: new Set((_blocklist = tailwindConfig.blocklist) !== null && _blocklist !== void 0 ? _blocklist : []),
1108
1110
  postCssNodeCache: new Map(),
1109
1111
  candidateRuleMap: new Map(),
1110
1112
  tailwindConfig,
@@ -162,6 +162,20 @@ function normalizeConfig(config) {
162
162
  if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
163
163
  return [];
164
164
  })();
165
+ // Normalize the `blocklist`
166
+ config.blocklist = (()=>{
167
+ let { blocklist } = config;
168
+ if (Array.isArray(blocklist)) {
169
+ if (blocklist.every((item)=>typeof item === "string")) {
170
+ return blocklist;
171
+ }
172
+ _log.default.warn("blocklist-invalid", [
173
+ "The `blocklist` option must be an array of strings.",
174
+ "https://tailwindcss.com/docs/content-configuration#discarding-classes"
175
+ ]);
176
+ }
177
+ return [];
178
+ })();
165
179
  // Normalize prefix option
166
180
  if (typeof config.prefix === "function") {
167
181
  _log.default.warn("prefix-function", [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -364,6 +364,23 @@ export async function createProcessor(args, cliConfigPath) {
364
364
  console.error()
365
365
  console.error('Done in', (end - start) / BigInt(1e6) + 'ms.')
366
366
  })
367
+ .then(
368
+ () => {},
369
+ (err) => {
370
+ // TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
371
+ // that were collected before the error occurred
372
+ // The result is not stored on the error so we have to store it externally
373
+ // and pull the messages off of it here somehow
374
+
375
+ // This results in a less than ideal DX because the watcher will not pick up
376
+ // changes to imported CSS if one of them caused an error during the initial build
377
+ // If you fix it and then save the main CSS file so there's no error
378
+ // The watcher will start watching the imported CSS files and will be
379
+ // resilient to future errors.
380
+
381
+ console.error(err)
382
+ }
383
+ )
367
384
  }
368
385
 
369
386
  /**
@@ -97,14 +97,15 @@ export function createWatcher(args, { state, rebuild }) {
97
97
  *
98
98
  * @param {*} file
99
99
  * @param {(() => Promise<string>) | null} content
100
+ * @param {boolean} skipPendingCheck
100
101
  * @returns {Promise<void>}
101
102
  */
102
- function recordChangedFile(file, content = null) {
103
+ function recordChangedFile(file, content = null, skipPendingCheck = false) {
103
104
  file = path.resolve(file)
104
105
 
105
106
  // Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
106
107
  // In that case rebuild has already been queued by rename, so can be skipped in change
107
- if (pendingRebuilds.has(file)) {
108
+ if (pendingRebuilds.has(file) && !skipPendingCheck) {
108
109
  return Promise.resolve()
109
110
  }
110
111
 
@@ -198,8 +199,10 @@ export function createWatcher(args, { state, rebuild }) {
198
199
  }
199
200
 
200
201
  // This will push the rebuild onto the chain
202
+ // We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
203
+ // This is because the order of events and timing is different on Linux
201
204
  // @ts-ignore: TypeScript isn't picking up that content is a string here
202
- await recordChangedFile(filePath, () => content)
205
+ await recordChangedFile(filePath, () => content, true)
203
206
  } catch {
204
207
  // If reading the file fails, it's was probably a deleted temporary file
205
208
  // So we can ignore it and no rebuild is needed
@@ -1165,7 +1165,8 @@ export function createContext(tailwindConfig, changedContent = [], root = postcs
1165
1165
  candidateRuleCache: new Map(),
1166
1166
  classCache: new Map(),
1167
1167
  applyClassCache: new Map(),
1168
- notClassCache: new Set(),
1168
+ // Seed the not class cache with the blocklist (which is only strings)
1169
+ notClassCache: new Set(tailwindConfig.blocklist ?? []),
1169
1170
  postCssNodeCache: new Map(),
1170
1171
  candidateRuleMap: new Map(),
1171
1172
  tailwindConfig,
@@ -150,6 +150,24 @@ export function normalizeConfig(config) {
150
150
  return []
151
151
  })()
152
152
 
153
+ // Normalize the `blocklist`
154
+ config.blocklist = (() => {
155
+ let { blocklist } = config
156
+
157
+ if (Array.isArray(blocklist)) {
158
+ if (blocklist.every((item) => typeof item === 'string')) {
159
+ return blocklist
160
+ }
161
+
162
+ log.warn('blocklist-invalid', [
163
+ 'The `blocklist` option must be an array of strings.',
164
+ 'https://tailwindcss.com/docs/content-configuration#discarding-classes',
165
+ ])
166
+ }
167
+
168
+ return []
169
+ })()
170
+
153
171
  // Normalize prefix option
154
172
  if (typeof config.prefix === 'function') {
155
173
  log.warn('prefix-function', [