tailwindcss 3.0.13 → 3.0.14

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.0.14] - 2022-01-14
13
+
14
+ ### Added
15
+
16
+ - Show warnings for invalid content config ([#7065](https://github.com/tailwindlabs/tailwindcss/pull/7065))
17
+
18
+ ### Fixed
19
+
20
+ - Only emit utility/component variants when those layers exist ([#7066](https://github.com/tailwindlabs/tailwindcss/pull/7066))
21
+ - Ensure nesting plugins can receive options ([#7016](https://github.com/tailwindlabs/tailwindcss/pull/7016))
22
+
12
23
  ## [3.0.13] - 2022-01-11
13
24
 
14
25
  ### Fixed
@@ -1798,7 +1809,8 @@ No release notes
1798
1809
 
1799
1810
  - Everything!
1800
1811
 
1801
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.13...HEAD
1812
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.14...HEAD
1813
+ [3.0.14]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.13...v3.0.14
1802
1814
  [3.0.13]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.12...v3.0.13
1803
1815
  [3.0.12]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.11...v3.0.12
1804
1816
  [3.0.11]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.10...v3.0.11
@@ -7,6 +7,7 @@ var _quickLru = _interopRequireDefault(require("quick-lru"));
7
7
  var sharedState = _interopRequireWildcard(require("./sharedState"));
8
8
  var _generateRules = require("./generateRules");
9
9
  var _bigSign = _interopRequireDefault(require("../util/bigSign"));
10
+ var _log = _interopRequireDefault(require("../util/log"));
10
11
  var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
11
12
  var _defaultExtractor = require("./defaultExtractor");
12
13
  function _interopRequireDefault(obj) {
@@ -191,8 +192,6 @@ function expandTailwindAtRules(context) {
191
192
  ...baseNodes,
192
193
  ...defaultNodes
193
194
  ], layerNodes.base.source));
194
- }
195
- if (layerNodes.base) {
196
195
  layerNodes.base.remove();
197
196
  }
198
197
  if (layerNodes.components) {
@@ -207,15 +206,33 @@ function expandTailwindAtRules(context) {
207
206
  ], layerNodes.utilities.source));
208
207
  layerNodes.utilities.remove();
209
208
  }
209
+ // We do post-filtering to not alter the emitted order of the variants
210
+ const variantNodes = Array.from(screenNodes).filter((node)=>{
211
+ var ref;
212
+ const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
213
+ if (parentLayer === 'components') {
214
+ return layerNodes.components !== null;
215
+ }
216
+ if (parentLayer === 'utilities') {
217
+ return layerNodes.utilities !== null;
218
+ }
219
+ return true;
220
+ });
210
221
  if (layerNodes.variants) {
211
- layerNodes.variants.before((0, _cloneNodes).default([
212
- ...screenNodes
213
- ], layerNodes.variants.source));
222
+ layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source));
214
223
  layerNodes.variants.remove();
215
- } else {
216
- root.append((0, _cloneNodes).default([
217
- ...screenNodes
218
- ], root.source));
224
+ } else if (variantNodes.length > 0) {
225
+ root.append((0, _cloneNodes).default(variantNodes, root.source));
226
+ }
227
+ // If we've got a utility layer and no utilities are generated there's likely something wrong
228
+ const hasUtilityVariants = variantNodes.some((node)=>{
229
+ var ref;
230
+ return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === 'utilities';
231
+ });
232
+ if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
233
+ _log.default.warn('content-problems', [
234
+ 'No utilities were generated there is likely a problem with the `content` key in the tailwind config. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
235
+ ]);
219
236
  }
220
237
  // ---
221
238
  if (env.DEBUG) {
@@ -217,6 +217,13 @@ function applyVariant(variant, matches, context) {
217
217
  rule.selector = before;
218
218
  });
219
219
  }
220
+ // This tracks the originating layer for the variant
221
+ // For example:
222
+ // .sm:underline {} is a variant of something in the utilities layer
223
+ // .sm:container {} is a variant of the container component
224
+ clone.nodes[0].raws.tailwind = {
225
+ parentLayer: meta.layer
226
+ };
220
227
  var _collectedFormats;
221
228
  let withOffset = [
222
229
  {
@@ -227,5 +227,10 @@ function normalizeConfig(config) {
227
227
  break;
228
228
  }
229
229
  }
230
+ if (config.content.files.length === 0) {
231
+ _log.default.warn('content-problems', [
232
+ 'The `content` key is missing or empty. Please populate the content key as Tailwind generates utilities on-demand based on the files that use them. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
233
+ ]);
234
+ }
230
235
  return config;
231
236
  }
package/nesting/plugin.js CHANGED
@@ -14,7 +14,10 @@ module.exports = function nesting(opts = postcssNested) {
14
14
  })
15
15
 
16
16
  let plugin = (() => {
17
- if (typeof opts === 'function') {
17
+ if (
18
+ typeof opts === 'function' ||
19
+ (typeof opts === 'object' && opts?.hasOwnProperty('postcssPlugin'))
20
+ ) {
18
21
  return opts
19
22
  }
20
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.0.13",
3
+ "version": "3.0.14",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -53,8 +53,8 @@
53
53
  "eslint": "^8.6.0",
54
54
  "eslint-config-prettier": "^8.3.0",
55
55
  "eslint-plugin-prettier": "^4.0.0",
56
- "jest": "^27.4.5",
57
- "jest-diff": "^27.4.2",
56
+ "jest": "^27.4.7",
57
+ "jest-diff": "^27.4.6",
58
58
  "postcss": "^8.4.5",
59
59
  "prettier": "^2.5.1",
60
60
  "rimraf": "^3.0.0"
@@ -2,6 +2,7 @@ import LRU from 'quick-lru'
2
2
  import * as sharedState from './sharedState'
3
3
  import { generateRules } from './generateRules'
4
4
  import bigSign from '../util/bigSign'
5
+ import log from '../util/log'
5
6
  import cloneNodes from '../util/cloneNodes'
6
7
  import { defaultExtractor } from './defaultExtractor'
7
8
 
@@ -204,9 +205,6 @@ export default function expandTailwindAtRules(context) {
204
205
 
205
206
  if (layerNodes.base) {
206
207
  layerNodes.base.before(cloneNodes([...baseNodes, ...defaultNodes], layerNodes.base.source))
207
- }
208
-
209
- if (layerNodes.base) {
210
208
  layerNodes.base.remove()
211
209
  }
212
210
 
@@ -220,11 +218,37 @@ export default function expandTailwindAtRules(context) {
220
218
  layerNodes.utilities.remove()
221
219
  }
222
220
 
221
+ // We do post-filtering to not alter the emitted order of the variants
222
+ const variantNodes = Array.from(screenNodes).filter((node) => {
223
+ const parentLayer = node.raws.tailwind?.parentLayer
224
+
225
+ if (parentLayer === 'components') {
226
+ return layerNodes.components !== null
227
+ }
228
+
229
+ if (parentLayer === 'utilities') {
230
+ return layerNodes.utilities !== null
231
+ }
232
+
233
+ return true
234
+ })
235
+
223
236
  if (layerNodes.variants) {
224
- layerNodes.variants.before(cloneNodes([...screenNodes], layerNodes.variants.source))
237
+ layerNodes.variants.before(cloneNodes(variantNodes, layerNodes.variants.source))
225
238
  layerNodes.variants.remove()
226
- } else {
227
- root.append(cloneNodes([...screenNodes], root.source))
239
+ } else if (variantNodes.length > 0) {
240
+ root.append(cloneNodes(variantNodes, root.source))
241
+ }
242
+
243
+ // If we've got a utility layer and no utilities are generated there's likely something wrong
244
+ const hasUtilityVariants = variantNodes.some(
245
+ (node) => node.raws.tailwind?.parentLayer === 'utilities'
246
+ )
247
+
248
+ if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
249
+ log.warn('content-problems', [
250
+ 'No utilities were generated there is likely a problem with the `content` key in the tailwind config. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
251
+ ])
228
252
  }
229
253
 
230
254
  // ---
@@ -216,6 +216,12 @@ function applyVariant(variant, matches, context) {
216
216
  })
217
217
  }
218
218
 
219
+ // This tracks the originating layer for the variant
220
+ // For example:
221
+ // .sm:underline {} is a variant of something in the utilities layer
222
+ // .sm:container {} is a variant of the container component
223
+ clone.nodes[0].raws.tailwind = { parentLayer: meta.layer }
224
+
219
225
  let withOffset = [
220
226
  {
221
227
  ...meta,
@@ -258,5 +258,11 @@ export function normalizeConfig(config) {
258
258
  }
259
259
  }
260
260
 
261
+ if (config.content.files.length === 0) {
262
+ log.warn('content-problems', [
263
+ 'The `content` key is missing or empty. Please populate the content key as Tailwind generates utilities on-demand based on the files that use them. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
264
+ ])
265
+ }
266
+
261
267
  return config
262
268
  }