tailwindcss 0.0.0-insiders.b26ffa0 → 0.0.0-insiders.b2dd6ff

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 (57) hide show
  1. package/CHANGELOG.md +45 -3
  2. package/colors.d.ts +3 -0
  3. package/defaultConfig.d.ts +3 -0
  4. package/defaultTheme.d.ts +3 -0
  5. package/lib/cli.js +27 -7
  6. package/lib/corePluginList.js +1 -0
  7. package/lib/corePlugins.js +86 -10
  8. package/lib/featureFlags.js +2 -2
  9. package/lib/index.js +12 -1
  10. package/lib/lib/cacheInvalidation.js +69 -0
  11. package/lib/lib/collapseAdjacentRules.js +14 -1
  12. package/lib/lib/defaultExtractor.js +6 -4
  13. package/lib/lib/expandApplyAtRules.js +166 -13
  14. package/lib/lib/expandTailwindAtRules.js +16 -6
  15. package/lib/lib/generateRules.js +85 -40
  16. package/lib/lib/resolveDefaultsAtRules.js +6 -2
  17. package/lib/lib/setupContextUtils.js +25 -40
  18. package/lib/lib/setupTrackingContext.js +3 -3
  19. package/lib/lib/sharedState.js +5 -1
  20. package/lib/postcss-plugins/nesting/plugin.js +32 -0
  21. package/lib/util/cloneNodes.js +12 -1
  22. package/lib/util/color.js +6 -5
  23. package/lib/util/log.js +7 -7
  24. package/lib/util/parseBoxShadowValue.js +43 -3
  25. package/lib/util/resolveConfig.js +22 -0
  26. package/package.json +26 -22
  27. package/peers/index.js +3049 -3806
  28. package/plugin.d.ts +6 -0
  29. package/scripts/generate-types.js +52 -0
  30. package/src/cli.js +34 -11
  31. package/src/corePluginList.js +1 -1
  32. package/src/corePlugins.js +89 -10
  33. package/src/featureFlags.js +2 -2
  34. package/src/index.js +15 -1
  35. package/src/lib/cacheInvalidation.js +52 -0
  36. package/src/lib/collapseAdjacentRules.js +16 -1
  37. package/src/lib/defaultExtractor.js +6 -4
  38. package/src/lib/expandApplyAtRules.js +179 -6
  39. package/src/lib/expandTailwindAtRules.js +26 -6
  40. package/src/lib/generateRules.js +73 -46
  41. package/src/lib/resolveDefaultsAtRules.js +6 -2
  42. package/src/lib/setupContextUtils.js +39 -48
  43. package/src/lib/setupTrackingContext.js +3 -3
  44. package/src/lib/sharedState.js +2 -0
  45. package/src/postcss-plugins/nesting/plugin.js +36 -0
  46. package/src/util/cloneNodes.js +14 -1
  47. package/src/util/color.js +7 -5
  48. package/src/util/log.js +7 -7
  49. package/src/util/parseBoxShadowValue.js +50 -2
  50. package/src/util/resolveConfig.js +30 -0
  51. package/stubs/defaultConfig.stub.js +3 -0
  52. package/types/config.d.ts +323 -0
  53. package/types/generated/.gitkeep +0 -0
  54. package/types/generated/colors.d.ts +276 -0
  55. package/types/generated/corePluginList.d.ts +1 -0
  56. package/types/index.d.ts +1 -0
  57. package/types.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -7,13 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- - Nothing yet!
10
+ ### Fixed
11
+
12
+ - Prevent nesting plugin from breaking other plugins ([#7563](https://github.com/tailwindlabs/tailwindcss/pull/7563))
13
+ - Recursively collapse adjacent rules ([#7565](https://github.com/tailwindlabs/tailwindcss/pull/7565))
14
+ - Preserve source maps for generated CSS ([#7588](https://github.com/tailwindlabs/tailwindcss/pull/7588))
15
+ - Split box shadows on top-level commas only ([#7479](https://github.com/tailwindlabs/tailwindcss/pull/7479))
16
+ - Use local user CSS cache for `@apply` ([#7524](https://github.com/tailwindlabs/tailwindcss/pull/7524))
17
+ - Invalidate context when main CSS changes ([#7626](https://github.com/tailwindlabs/tailwindcss/pull/7626))
18
+ - Only add `!` to selector class matching template candidate when using important modifier with mutli-class selectors ([#7664](https://github.com/tailwindlabs/tailwindcss/pull/7664))
19
+ - Correctly parse and prefix animation names with dots ([#7163](https://github.com/tailwindlabs/tailwindcss/pull/7163))
20
+ - Fix extraction from template literal/function with array ([#7481](https://github.com/tailwindlabs/tailwindcss/pull/7481))
21
+ - Don't output unparsable arbitrary values ([#7789](https://github.com/tailwindlabs/tailwindcss/pull/7789))
22
+ - Fix generation of `div:not(.foo)` if `.foo` is never defined ([#7815](https://github.com/tailwindlabs/tailwindcss/pull/7815))
23
+ - Allow for custom properties in `rgb`, `rgba`, `hsl` and `hsla` colors ([#7933](https://github.com/tailwindlabs/tailwindcss/pull/7933))
24
+ - Remove autoprefixer as explicit peer-dependency to avoid invalid warnings in situations where it isn't actually needed ([#7949](https://github.com/tailwindlabs/tailwindcss/pull/7949))
25
+
26
+ ### Changed
27
+
28
+ - Replace `chalk` with `picocolors` ([#6039](https://github.com/tailwindlabs/tailwindcss/pull/6039))
29
+ - Replace `cosmiconfig` with `lilconfig` ([#6039](https://github.com/tailwindlabs/tailwindcss/pull/6038))
30
+ - Update `cssnano` to avoid removing empty variables when minifying ([#7818](https://github.com/tailwindlabs/tailwindcss/pull/7818))
31
+
32
+ ### Added
33
+
34
+ - Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
35
+ - Add `rgb` and `hsl` color helpers for CSS variables ([#7665](https://github.com/tailwindlabs/tailwindcss/pull/7665))
36
+ - Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
37
+ - Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656))
38
+ - Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800))
39
+ - Add `--poll` option to the CLI ([#7725](https://github.com/tailwindlabs/tailwindcss/pull/7725))
40
+ - Add new `border-spacing` utilities ([#7102](https://github.com/tailwindlabs/tailwindcss/pull/7102))
41
+ - Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
42
+ - Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
43
+
44
+ ## [3.0.23] - 2022-02-16
45
+
46
+ ### Fixed
47
+
48
+ - Remove opacity variables from `:visited` pseudo class ([#7458](https://github.com/tailwindlabs/tailwindcss/pull/7458))
49
+ - Support arbitrary values + calc + theme with quotes ([#7462](https://github.com/tailwindlabs/tailwindcss/pull/7462))
50
+ - Don't duplicate layer output when scanning content with variants + wildcards ([#7478](https://github.com/tailwindlabs/tailwindcss/pull/7478))
51
+ - Implement `getClassOrder` instead of `sortClassList` ([#7459](https://github.com/tailwindlabs/tailwindcss/pull/7459))
11
52
 
12
53
  ## [3.0.22] - 2022-02-11
13
54
 
14
55
  ### Fixed
15
56
 
16
- - Temporarily move postcss to dependencies ([#7424](https://github.com/tailwindlabs/tailwindcss/pull/7424))
57
+ - Temporarily move `postcss` to dependencies ([#7424](https://github.com/tailwindlabs/tailwindcss/pull/7424))
17
58
 
18
59
  ## [3.0.21] - 2022-02-10
19
60
 
@@ -1865,7 +1906,8 @@ No release notes
1865
1906
 
1866
1907
  - Everything!
1867
1908
 
1868
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...HEAD
1909
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...HEAD
1910
+ [3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
1869
1911
  [3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
1870
1912
  [3.0.21]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.20...v3.0.21
1871
1913
  [3.0.20]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.19...v3.0.20
package/colors.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { DefaultColors } from './types/generated/colors'
2
+ declare const colors: DefaultColors
3
+ export = colors
@@ -0,0 +1,3 @@
1
+ import type { Config } from './types/config'
2
+ declare const config: Config
3
+ export = config
@@ -0,0 +1,3 @@
1
+ import type { Config } from './types/config'
2
+ declare const theme: Config['theme']
3
+ export = theme
package/lib/cli.js CHANGED
@@ -6,7 +6,7 @@ var _path = _interopRequireDefault(require("path"));
6
6
  var _arg = _interopRequireDefault(require("arg"));
7
7
  var _fs = _interopRequireDefault(require("fs"));
8
8
  var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
9
- var _cosmiconfig = require("cosmiconfig");
9
+ var _lilconfig = require("lilconfig");
10
10
  var _plugins // Little bit scary, looking at private/internal API
11
11
  = _interopRequireDefault(require("postcss-load-config/src/plugins"));
12
12
  var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
@@ -140,6 +140,10 @@ let commands = {
140
140
  type: Boolean,
141
141
  description: 'Initialize a `postcss.config.js` file'
142
142
  },
143
+ '--types': {
144
+ type: Boolean,
145
+ description: 'Add TypeScript types for the `tailwind.config.js` file'
146
+ },
143
147
  '-f': '--full',
144
148
  '-p': '--postcss'
145
149
  }
@@ -159,6 +163,10 @@ let commands = {
159
163
  type: Boolean,
160
164
  description: 'Watch for changes and rebuild as needed'
161
165
  },
166
+ '--poll': {
167
+ type: Boolean,
168
+ description: 'Use polling instead of filesystem events when watching'
169
+ },
162
170
  '--content': {
163
171
  type: String,
164
172
  description: 'Content paths to use for removing unused classes'
@@ -187,7 +195,8 @@ let commands = {
187
195
  '-i': '--input',
188
196
  '-o': '--output',
189
197
  '-m': '--minify',
190
- '-w': '--watch'
198
+ '-w': '--watch',
199
+ '-p': '--poll'
191
200
  }
192
201
  }
193
202
  };
@@ -203,7 +212,7 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
203
212
  help({
204
213
  usage: [
205
214
  'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
206
- 'tailwindcss init [--full] [--postcss] [options...]',
215
+ 'tailwindcss init [--full] [--postcss] [--types] [options...]',
207
216
  ],
208
217
  commands: Object.keys(commands).filter((command2)=>command2 !== 'build'
209
218
  ).map((command3)=>`${command3} [options]`
@@ -322,6 +331,10 @@ function init() {
322
331
  messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
323
332
  } else {
324
333
  let stubFile = _fs.default.readFileSync(args['--full'] ? _path.default.resolve(__dirname, '../stubs/defaultConfig.stub.js') : _path.default.resolve(__dirname, '../stubs/simpleConfig.stub.js'), 'utf8');
334
+ if (args['--types']) {
335
+ let typesHeading = "/** @type {import('tailwindcss/types').Config} */";
336
+ stubFile = stubFile.replace(`module.exports = `, `${typesHeading}\nconst config = `) + '\nmodule.exports = config';
337
+ }
325
338
  // Change colors import
326
339
  stubFile = stubFile.replace('../colors', 'tailwindcss/colors');
327
340
  _fs.default.writeFileSync(tailwindConfigLocation, stubFile, 'utf8');
@@ -348,7 +361,12 @@ async function build() {
348
361
  let input = args['--input'];
349
362
  let output = args['--output'];
350
363
  let shouldWatch = args['--watch'];
364
+ let shouldPoll = args['--poll'];
365
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32';
351
366
  let includePostCss = args['--postcss'];
367
+ // Polling interval in milliseconds
368
+ // Used only when polling or coalescing add/change events on Windows
369
+ let pollInterval = 10;
352
370
  // TODO: Deprecate this in future versions
353
371
  if (!input && args['_'][1]) {
354
372
  console.error('[deprecation] Running tailwindcss without -i, please provide an input file.');
@@ -368,8 +386,8 @@ async function build() {
368
386
  let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined;
369
387
  let { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
370
388
  let file = _path.default.resolve(customPostCssPath);
371
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
372
- let { config ={} } = await (0, _cosmiconfig).cosmiconfig('postcss').load(file);
389
+ // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
390
+ let { config ={} } = await (0, _lilconfig).lilconfig('postcss').load(file);
373
391
  if (typeof config === 'function') {
374
392
  config = config();
375
393
  } else {
@@ -684,10 +702,12 @@ async function build() {
684
702
  ...contextDependencies,
685
703
  ...extractFileGlobs(config1)
686
704
  ], {
705
+ usePolling: shouldPoll,
706
+ interval: shouldPoll ? pollInterval : undefined,
687
707
  ignoreInitial: true,
688
- awaitWriteFinish: process.platform === 'win32' ? {
708
+ awaitWriteFinish: shouldCoalesceWriteEvents ? {
689
709
  stabilityThreshold: 50,
690
- pollInterval: 10
710
+ pollInterval: pollInterval
691
711
  } : false
692
712
  });
693
713
  let chain = Promise.resolve();
@@ -38,6 +38,7 @@ var _default = [
38
38
  "flexBasis",
39
39
  "tableLayout",
40
40
  "borderCollapse",
41
+ "borderSpacing",
41
42
  "transformOrigin",
42
43
  "translate",
43
44
  "rotate",
@@ -8,6 +8,7 @@ var path = _interopRequireWildcard(require("path"));
8
8
  var _postcss = _interopRequireDefault(require("postcss"));
9
9
  var _createUtilityPlugin = _interopRequireDefault(require("./util/createUtilityPlugin"));
10
10
  var _buildMediaQuery = _interopRequireDefault(require("./util/buildMediaQuery"));
11
+ var _escapeClassName = _interopRequireDefault(require("./util/escapeClassName"));
11
12
  var _parseAnimationValue = _interopRequireDefault(require("./util/parseAnimationValue"));
12
13
  var _flattenColorPalette = _interopRequireDefault(require("./util/flattenColorPalette"));
13
14
  var _withAlphaVariable = _interopRequireWildcard(require("./util/withAlphaVariable"));
@@ -116,7 +117,28 @@ let variantPlugins = {
116
117
  'last-of-type',
117
118
  'only-of-type',
118
119
  // State
119
- 'visited',
120
+ [
121
+ 'visited',
122
+ ({ container })=>{
123
+ let toRemove = [
124
+ '--tw-text-opacity',
125
+ '--tw-border-opacity',
126
+ '--tw-bg-opacity'
127
+ ];
128
+ container.walkDecls((decl)=>{
129
+ if (toRemove.includes(decl.prop)) {
130
+ decl.remove();
131
+ return;
132
+ }
133
+ for (const varName of toRemove){
134
+ if (decl.value.includes(`/ var(${varName})`)) {
135
+ decl.value = decl.value.replace(`/ var(${varName})`, '');
136
+ }
137
+ }
138
+ });
139
+ return ':visited';
140
+ },
141
+ ],
120
142
  'target',
121
143
  [
122
144
  'open',
@@ -142,6 +164,7 @@ let variantPlugins = {
142
164
  'focus',
143
165
  'focus-visible',
144
166
  'active',
167
+ 'enabled',
145
168
  'disabled',
146
169
  ].map((variant)=>Array.isArray(variant) ? variant : [
147
170
  variant,
@@ -149,13 +172,22 @@ let variantPlugins = {
149
172
  ]
150
173
  );
151
174
  for (let [variantName, state] of pseudoVariants){
152
- addVariant(variantName, `&${state}`);
175
+ addVariant(variantName, (ctx)=>{
176
+ let result = typeof state === 'function' ? state(ctx) : state;
177
+ return `&${result}`;
178
+ });
153
179
  }
154
180
  for (let [variantName1, state1] of pseudoVariants){
155
- addVariant(`group-${variantName1}`, `:merge(.group)${state1} &`);
181
+ addVariant(`group-${variantName1}`, (ctx)=>{
182
+ let result = typeof state1 === 'function' ? state1(ctx) : state1;
183
+ return `:merge(.group)${result} &`;
184
+ });
156
185
  }
157
186
  for (let [variantName2, state2] of pseudoVariants){
158
- addVariant(`peer-${variantName2}`, `:merge(.peer)${state2} ~ &`);
187
+ addVariant(`peer-${variantName2}`, (ctx)=>{
188
+ let result = typeof state2 === 'function' ? state2(ctx) : state2;
189
+ return `:merge(.peer)${result} ~ &`;
190
+ });
159
191
  }
160
192
  },
161
193
  directionVariants: ({ addVariant })=>{
@@ -179,7 +211,7 @@ let variantPlugins = {
179
211
  addVariant('motion-reduce', '@media (prefers-reduced-motion: reduce)');
180
212
  },
181
213
  darkVariants: ({ config , addVariant })=>{
182
- let mode = config('darkMode', 'media');
214
+ let [mode, className = '.dark'] = [].concat(config('darkMode', 'media'));
183
215
  if (mode === false) {
184
216
  mode = 'media';
185
217
  _log.default.warn('darkmode-false', [
@@ -189,7 +221,7 @@ let variantPlugins = {
189
221
  ]);
190
222
  }
191
223
  if (mode === 'class') {
192
- addVariant('dark', '.dark &');
224
+ addVariant('dark', `${className} &`);
193
225
  } else if (mode === 'media') {
194
226
  addVariant('dark', '@media (prefers-color-scheme: dark)');
195
227
  }
@@ -790,6 +822,38 @@ let corePlugins = {
790
822
  }
791
823
  });
792
824
  },
825
+ borderSpacing: ({ addDefaults , matchUtilities , theme })=>{
826
+ addDefaults('border-spacing', {
827
+ '--tw-border-spacing-x': 0,
828
+ '--tw-border-spacing-y': 0
829
+ });
830
+ matchUtilities({
831
+ 'border-spacing': (value)=>{
832
+ return {
833
+ '--tw-border-spacing-x': value,
834
+ '--tw-border-spacing-y': value,
835
+ '@defaults border-spacing': {},
836
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)'
837
+ };
838
+ },
839
+ 'border-spacing-x': (value)=>{
840
+ return {
841
+ '--tw-border-spacing-x': value,
842
+ '@defaults border-spacing': {},
843
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)'
844
+ };
845
+ },
846
+ 'border-spacing-y': (value)=>{
847
+ return {
848
+ '--tw-border-spacing-y': value,
849
+ '@defaults border-spacing': {},
850
+ 'border-spacing': 'var(--tw-border-spacing-x) var(--tw-border-spacing-y)'
851
+ };
852
+ }
853
+ }, {
854
+ values: theme('borderSpacing')
855
+ });
856
+ },
793
857
  transformOrigin: (0, _createUtilityPlugin).default('transformOrigin', [
794
858
  [
795
859
  'origin',
@@ -959,8 +1023,8 @@ let corePlugins = {
959
1023
  }
960
1024
  });
961
1025
  },
962
- animation: ({ matchUtilities , theme , prefix })=>{
963
- let prefixName = (name)=>prefix(`.${name}`).slice(1)
1026
+ animation: ({ matchUtilities , theme , config })=>{
1027
+ let prefixName = (name)=>`${config('prefix')}${(0, _escapeClassName).default(name)}`
964
1028
  ;
965
1029
  var ref;
966
1030
  let keyframes = Object.fromEntries(Object.entries((ref = theme('keyframes')) !== null && ref !== void 0 ? ref : {}).map(([key, value])=>{
@@ -2501,6 +2565,12 @@ let corePlugins = {
2501
2565
  },
2502
2566
  '.text-justify': {
2503
2567
  'text-align': 'justify'
2568
+ },
2569
+ '.text-start': {
2570
+ 'text-align': 'start'
2571
+ },
2572
+ '.text-end': {
2573
+ 'text-align': 'end'
2504
2574
  }
2505
2575
  });
2506
2576
  },
@@ -3118,8 +3188,9 @@ let corePlugins = {
3118
3188
  });
3119
3189
  },
3120
3190
  ringWidth: ({ matchUtilities , addDefaults , addUtilities , theme })=>{
3191
+ var ref;
3121
3192
  let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5');
3122
- let ringColorDefault = (0, _withAlphaVariable).withAlphaValue(theme('ringColor.DEFAULT'), ringOpacityDefault, `rgb(147 197 253 / ${ringOpacityDefault})`);
3193
+ let ringColorDefault = (0, _withAlphaVariable).withAlphaValue((ref = theme('ringColor')) === null || ref === void 0 ? void 0 : ref.DEFAULT, ringOpacityDefault, `rgb(147 197 253 / ${ringOpacityDefault})`);
3123
3194
  addDefaults('ring-width', {
3124
3195
  '--tw-ring-inset': ' ',
3125
3196
  '--tw-ring-offset-width': theme('ringOffsetWidth.DEFAULT', '0px'),
@@ -3154,9 +3225,14 @@ let corePlugins = {
3154
3225
  }
3155
3226
  });
3156
3227
  },
3157
- ringColor: ({ matchUtilities , theme })=>{
3228
+ ringColor: ({ matchUtilities , theme , corePlugins: corePlugins6 })=>{
3158
3229
  matchUtilities({
3159
3230
  ring: (value)=>{
3231
+ if (!corePlugins6('ringOpacity')) {
3232
+ return {
3233
+ '--tw-ring-color': (0, _toColorValue).default(value)
3234
+ };
3235
+ }
3160
3236
  return (0, _withAlphaVariable).default({
3161
3237
  color: value,
3162
3238
  property: '--tw-ring-color',
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.flagEnabled = flagEnabled;
6
6
  exports.issueFlagNotices = issueFlagNotices;
7
7
  exports.default = void 0;
8
- var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _picocolors = _interopRequireDefault(require("picocolors"));
9
9
  var _log = _interopRequireDefault(require("./util/log"));
10
10
  function _interopRequireDefault(obj) {
11
11
  return obj && obj.__esModule ? obj : {
@@ -47,7 +47,7 @@ function issueFlagNotices(config) {
47
47
  return;
48
48
  }
49
49
  if (experimentalFlagsEnabled(config).length > 0) {
50
- let changes = experimentalFlagsEnabled(config).map((s)=>_chalk.default.yellow(s)
50
+ let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)
51
51
  ).join(', ');
52
52
  _log.default.warn('experimental-flags-enabled', [
53
53
  `You have enabled experimental features: ${changes}`,
package/lib/index.js CHANGED
@@ -17,7 +17,18 @@ module.exports = function tailwindcss(configOrPath) {
17
17
  return root;
18
18
  },
19
19
  function(root, result) {
20
- (0, _processTailwindFeatures).default((0, _setupTrackingContext).default(configOrPath))(root, result);
20
+ let context = (0, _setupTrackingContext).default(configOrPath);
21
+ if (root.type === 'document') {
22
+ let roots = root.nodes.filter((node)=>node.type === 'root'
23
+ );
24
+ for (const root1 of roots){
25
+ if (root1.type === 'root') {
26
+ (0, _processTailwindFeatures).default(context)(root1, result);
27
+ }
28
+ }
29
+ return;
30
+ }
31
+ (0, _processTailwindFeatures).default(context)(root, result);
21
32
  },
22
33
  _sharedState.env.DEBUG && function(root) {
23
34
  console.timeEnd('JIT TOTAL');
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.hasContentChanged = hasContentChanged;
6
+ var _crypto = _interopRequireDefault(require("crypto"));
7
+ var sharedState = _interopRequireWildcard(require("./sharedState"));
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ function _interopRequireWildcard(obj) {
14
+ if (obj && obj.__esModule) {
15
+ return obj;
16
+ } else {
17
+ var newObj = {};
18
+ if (obj != null) {
19
+ for(var key in obj){
20
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
21
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
22
+ if (desc.get || desc.set) {
23
+ Object.defineProperty(newObj, key, desc);
24
+ } else {
25
+ newObj[key] = obj[key];
26
+ }
27
+ }
28
+ }
29
+ }
30
+ newObj.default = obj;
31
+ return newObj;
32
+ }
33
+ }
34
+ /**
35
+ * Calculate the hash of a string.
36
+ *
37
+ * This doesn't need to be cryptographically secure or
38
+ * anything like that since it's used only to detect
39
+ * when the CSS changes to invalidate the context.
40
+ *
41
+ * This is wrapped in a try/catch because it's really dependent
42
+ * on how Node itself is build and the environment and OpenSSL
43
+ * version / build that is installed on the user's machine.
44
+ *
45
+ * Based on the environment this can just outright fail.
46
+ *
47
+ * See https://github.com/nodejs/node/issues/40455
48
+ *
49
+ * @param {string} str
50
+ */ function getHash(str) {
51
+ try {
52
+ return _crypto.default.createHash('md5').update(str, 'utf-8').digest('binary');
53
+ } catch (err) {
54
+ return '';
55
+ }
56
+ }
57
+ function hasContentChanged(sourcePath, root) {
58
+ let css = root.toString();
59
+ // We only care about files with @tailwind directives
60
+ // Other files use an existing context
61
+ if (!css.includes('@tailwind')) {
62
+ return false;
63
+ }
64
+ let existingHash = sharedState.sourceHashMap.get(sourcePath);
65
+ let rootHash = getHash(css);
66
+ let didChange = existingHash !== rootHash;
67
+ sharedState.sourceHashMap.set(sourcePath, rootHash);
68
+ return didChange;
69
+ }
@@ -14,7 +14,7 @@ let comparisonMap = {
14
14
  };
15
15
  let types = new Set(Object.keys(comparisonMap));
16
16
  function collapseAdjacentRules() {
17
- return (root)=>{
17
+ function collapseRulesIn(root) {
18
18
  let currentRule = null;
19
19
  root.each((node)=>{
20
20
  if (!types.has(node.type)) {
@@ -37,5 +37,18 @@ function collapseAdjacentRules() {
37
37
  currentRule = node;
38
38
  }
39
39
  });
40
+ // After we've collapsed adjacent rules & at-rules, we need to collapse
41
+ // adjacent rules & at-rules that are children of at-rules.
42
+ // We do not care about nesting rules because Tailwind CSS
43
+ // explicitly does not handle rule nesting on its own as
44
+ // the user is expected to use a nesting plugin
45
+ root.each((node)=>{
46
+ if (node.type === 'atrule') {
47
+ collapseRulesIn(node);
48
+ }
49
+ });
50
+ }
51
+ return (root)=>{
52
+ collapseRulesIn(root);
40
53
  };
41
54
  }
@@ -7,14 +7,16 @@ const PATTERNS = [
7
7
  /(?:\['([^'\s]+[^<>"'`\s:\\])')/.source,
8
8
  /(?:\["([^"\s]+[^<>"'`\s:\\])")/.source,
9
9
  /(?:\[`([^`\s]+[^<>"'`\s:\\])`)/.source,
10
- /([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
11
- /([^<>"'`\s]*\[\w*"[^'`\s]*"?\])/.source,
10
+ /([^${(<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
11
+ /([^${(<>"'`\s]*\[\w*"[^'`\s]*"?\])/.source,
12
12
  /([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
13
13
  /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
14
14
  /([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
15
15
  /([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
16
- /([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
17
- /([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
16
+ /([^<>"'`\s]*\[[^<>"'`\s]*\('[^"`\s]*'\)+\])/.source,
17
+ /([^<>"'`\s]*\[[^<>"'`\s]*\("[^'`\s]*"\)+\])/.source,
18
+ /([^${(<>"'`\s]*\['[^"'`\s]*'\])/.source,
19
+ /([^${(<>"'`\s]*\["[^"'`\s]*"\])/.source,
18
20
  /([^<>"'`\s]*\[[^<>"'`\s]*:[^\]\s]*\])/.source,
19
21
  /([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
20
22
  /([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,