tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -1,331 +1,288 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = setupWatchingContext;
7
-
8
6
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
7
  var _path = _interopRequireDefault(require("path"));
11
-
12
8
  var _tmp = _interopRequireDefault(require("tmp"));
13
-
14
9
  var _chokidar = _interopRequireDefault(require("chokidar"));
15
-
16
10
  var _fastGlob = _interopRequireDefault(require("fast-glob"));
17
-
18
11
  var _quickLru = _interopRequireDefault(require("quick-lru"));
19
-
20
12
  var _normalizePath = _interopRequireDefault(require("normalize-path"));
21
-
22
13
  var _hashConfig = _interopRequireDefault(require("../util/hashConfig"));
23
-
24
14
  var _log = _interopRequireDefault(require("../util/log"));
25
-
26
15
  var _getModuleDependencies = _interopRequireDefault(require("../lib/getModuleDependencies"));
27
-
28
- var _resolveConfig = _interopRequireDefault(require("../../resolveConfig"));
29
-
16
+ var _resolveConfig = _interopRequireDefault(require("../public/resolve-config"));
30
17
  var _resolveConfigPath = _interopRequireDefault(require("../util/resolveConfigPath"));
31
-
32
18
  var _setupContextUtils = require("./setupContextUtils");
33
-
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
-
19
+ function _interopRequireDefault(obj) {
20
+ return obj && obj.__esModule ? obj : {
21
+ default: obj
22
+ };
23
+ }
36
24
  // This is used to trigger rebuilds. Just updating the timestamp
37
25
  // is significantly faster than actually writing to the file (10x).
38
26
  function touch(filename) {
39
- let time = new Date();
40
-
41
- try {
42
- _fs.default.utimesSync(filename, time, time);
43
- } catch (err) {
44
- _fs.default.closeSync(_fs.default.openSync(filename, 'w'));
45
- }
27
+ let time = new Date();
28
+ try {
29
+ _fs.default.utimesSync(filename, time, time);
30
+ } catch (err) {
31
+ _fs.default.closeSync(_fs.default.openSync(filename, 'w'));
32
+ }
46
33
  }
47
-
48
34
  let watchers = new WeakMap();
49
-
50
35
  function getWatcher(context) {
51
- if (watchers.has(context)) {
52
- return watchers.get(context);
53
- }
54
-
55
- return null;
36
+ if (watchers.has(context)) {
37
+ return watchers.get(context);
38
+ }
39
+ return null;
56
40
  }
57
-
58
41
  function setWatcher(context, watcher) {
59
- return watchers.set(context, watcher);
42
+ return watchers.set(context, watcher);
60
43
  }
61
-
62
44
  let touchFiles = new WeakMap();
63
-
64
45
  function getTouchFile(context) {
65
- if (touchFiles.has(context)) {
66
- return touchFiles.get(context);
67
- }
68
-
69
- return null;
46
+ if (touchFiles.has(context)) {
47
+ return touchFiles.get(context);
48
+ }
49
+ return null;
70
50
  }
71
-
72
51
  function setTouchFile(context, touchFile) {
73
- return touchFiles.set(context, touchFile);
52
+ return touchFiles.set(context, touchFile);
74
53
  }
75
-
76
54
  let configPaths = new WeakMap();
77
-
78
55
  function getConfigPath(context, configOrPath) {
79
- if (!configPaths.has(context)) {
80
- configPaths.set(context, (0, _resolveConfigPath.default)(configOrPath));
81
- }
82
-
83
- return configPaths.get(context);
56
+ if (!configPaths.has(context)) {
57
+ configPaths.set(context, (0, _resolveConfigPath).default(configOrPath));
58
+ }
59
+ return configPaths.get(context);
84
60
  }
85
-
86
61
  function rebootWatcher(context, configPath, configDependencies, candidateFiles) {
87
- let touchFile = getTouchFile(context);
88
-
89
- if (touchFile === null) {
90
- touchFile = _tmp.default.fileSync().name;
91
- setTouchFile(context, touchFile);
92
- touch(touchFile);
93
- }
94
-
95
- let watcher = getWatcher(context);
96
- Promise.resolve(watcher ? watcher.close() : null).then(() => {
97
- _log.default.info(['Tailwind CSS is watching for changes...', 'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds']);
98
-
99
- watcher = _chokidar.default.watch([...candidateFiles, ...configDependencies], {
100
- ignoreInitial: true
101
- });
102
- setWatcher(context, watcher);
103
- watcher.on('add', file => {
104
- let changedFile = _path.default.resolve('.', file);
105
-
106
- let content = _fs.default.readFileSync(changedFile, 'utf8');
107
-
108
- let extension = _path.default.extname(changedFile).slice(1);
109
-
110
- context.changedContent.push({
111
- content,
112
- extension
113
- });
114
- touch(touchFile);
115
- });
116
- watcher.on('change', file => {
117
- // If it was a config dependency, touch the config file to trigger a new context.
118
- // This is not really that clean of a solution but it's the fastest, because we
119
- // can do a very quick check on each build to see if the config has changed instead
120
- // of having to get all of the module dependencies and check every timestamp each
121
- // time.
122
- if (configDependencies.has(file)) {
123
- for (let dependency of configDependencies) {
124
- delete require.cache[require.resolve(dependency)];
125
- }
126
-
127
- touch(configPath);
128
- } else {
129
- let changedFile = _path.default.resolve('.', file);
130
-
131
- let content = _fs.default.readFileSync(changedFile, 'utf8');
132
-
133
- let extension = _path.default.extname(changedFile).slice(1);
134
-
135
- context.changedContent.push({
136
- content,
137
- extension
138
- });
62
+ let touchFile = getTouchFile(context);
63
+ if (touchFile === null) {
64
+ touchFile = _tmp.default.fileSync().name;
65
+ setTouchFile(context, touchFile);
139
66
  touch(touchFile);
140
- }
141
- });
142
- watcher.on('unlink', file => {
143
- // Touch the config file if any of the dependencies are deleted.
144
- if (configDependencies.has(file)) {
145
- for (let dependency of configDependencies) {
146
- delete require.cache[require.resolve(dependency)];
147
- }
148
-
149
- touch(configPath);
150
- }
67
+ }
68
+ let watcher = getWatcher(context);
69
+ Promise.resolve(watcher ? watcher.close() : null).then(()=>{
70
+ _log.default.info([
71
+ 'Tailwind CSS is watching for changes...',
72
+ 'https://tailwindcss.com/docs/just-in-time-mode#watch-mode-and-one-off-builds',
73
+ ]);
74
+ watcher = _chokidar.default.watch([
75
+ ...candidateFiles,
76
+ ...configDependencies
77
+ ], {
78
+ ignoreInitial: true,
79
+ awaitWriteFinish: process.platform === 'win32' ? {
80
+ stabilityThreshold: 50,
81
+ pollInterval: 10
82
+ } : false
83
+ });
84
+ setWatcher(context, watcher);
85
+ watcher.on('add', (file)=>{
86
+ let changedFile = _path.default.resolve('.', file);
87
+ let content = _fs.default.readFileSync(changedFile, 'utf8');
88
+ let extension = _path.default.extname(changedFile).slice(1);
89
+ context.changedContent.push({
90
+ content,
91
+ extension
92
+ });
93
+ touch(touchFile);
94
+ });
95
+ watcher.on('change', (file)=>{
96
+ // If it was a config dependency, touch the config file to trigger a new context.
97
+ // This is not really that clean of a solution but it's the fastest, because we
98
+ // can do a very quick check on each build to see if the config has changed instead
99
+ // of having to get all of the module dependencies and check every timestamp each
100
+ // time.
101
+ if (configDependencies.has(file)) {
102
+ for (let dependency of configDependencies){
103
+ delete require.cache[require.resolve(dependency)];
104
+ }
105
+ touch(configPath);
106
+ } else {
107
+ let changedFile = _path.default.resolve('.', file);
108
+ let content = _fs.default.readFileSync(changedFile, 'utf8');
109
+ let extension = _path.default.extname(changedFile).slice(1);
110
+ context.changedContent.push({
111
+ content,
112
+ extension
113
+ });
114
+ touch(touchFile);
115
+ }
116
+ });
117
+ watcher.on('unlink', (file)=>{
118
+ // Touch the config file if any of the dependencies are deleted.
119
+ if (configDependencies.has(file)) {
120
+ for (let dependency of configDependencies){
121
+ delete require.cache[require.resolve(dependency)];
122
+ }
123
+ touch(configPath);
124
+ }
125
+ });
151
126
  });
152
- });
153
127
  }
154
-
155
128
  let configPathCache = new _quickLru.default({
156
- maxSize: 100
129
+ maxSize: 100
157
130
  });
158
131
  let configDependenciesCache = new WeakMap();
159
-
160
132
  function getConfigDependencies(context) {
161
- if (!configDependenciesCache.has(context)) {
162
- configDependenciesCache.set(context, new Set());
163
- }
164
-
165
- return configDependenciesCache.get(context);
133
+ if (!configDependenciesCache.has(context)) {
134
+ configDependenciesCache.set(context, new Set());
135
+ }
136
+ return configDependenciesCache.get(context);
166
137
  }
167
-
168
138
  let candidateFilesCache = new WeakMap();
169
-
170
139
  function getCandidateFiles(context, tailwindConfig) {
171
- if (candidateFilesCache.has(context)) {
172
- return candidateFilesCache.get(context);
173
- }
174
-
175
- let candidateFiles = tailwindConfig.content.content.filter(item => typeof item === 'string').map(contentPath => (0, _normalizePath.default)(_path.default.resolve(contentPath)));
176
- return candidateFilesCache.set(context, candidateFiles).get(context);
177
- } // Get the config object based on a path
178
-
179
-
140
+ if (candidateFilesCache.has(context)) {
141
+ return candidateFilesCache.get(context);
142
+ }
143
+ let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === 'string'
144
+ ).map((contentPath)=>(0, _normalizePath).default(contentPath)
145
+ );
146
+ return candidateFilesCache.set(context, candidateFiles).get(context);
147
+ }
148
+ // Get the config object based on a path
180
149
  function getTailwindConfig(configOrPath) {
181
- let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
182
-
183
- if (userConfigPath !== null) {
184
- let [prevConfig, prevModified = -Infinity, prevConfigHash] = configPathCache.get(userConfigPath) || [];
185
-
186
- let modified = _fs.default.statSync(userConfigPath).mtimeMs; // It hasn't changed (based on timestamp)
187
-
188
-
189
- if (modified <= prevModified) {
190
- return [prevConfig, userConfigPath, prevConfigHash, [userConfigPath]];
191
- } // It has changed (based on timestamp), or first run
192
-
193
-
194
- delete require.cache[userConfigPath];
195
- let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
196
- let newHash = (0, _hashConfig.default)(newConfig);
197
- configPathCache.set(userConfigPath, [newConfig, modified, newHash]);
198
- return [newConfig, userConfigPath, newHash, [userConfigPath]];
199
- } // It's a plain object, not a path
200
-
201
-
202
- let newConfig = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
203
- return [newConfig, null, (0, _hashConfig.default)(newConfig), []];
150
+ let userConfigPath = (0, _resolveConfigPath).default(configOrPath);
151
+ if (userConfigPath !== null) {
152
+ let [prevConfig, prevModified = -Infinity, prevConfigHash] = configPathCache.get(userConfigPath) || [];
153
+ let modified = _fs.default.statSync(userConfigPath).mtimeMs;
154
+ // It hasn't changed (based on timestamp)
155
+ if (modified <= prevModified) {
156
+ return [
157
+ prevConfig,
158
+ userConfigPath,
159
+ prevConfigHash,
160
+ [
161
+ userConfigPath
162
+ ]
163
+ ];
164
+ }
165
+ // It has changed (based on timestamp), or first run
166
+ delete require.cache[userConfigPath];
167
+ let newConfig = (0, _resolveConfig).default(require(userConfigPath));
168
+ let newHash = (0, _hashConfig).default(newConfig);
169
+ configPathCache.set(userConfigPath, [
170
+ newConfig,
171
+ modified,
172
+ newHash
173
+ ]);
174
+ return [
175
+ newConfig,
176
+ userConfigPath,
177
+ newHash,
178
+ [
179
+ userConfigPath
180
+ ]
181
+ ];
182
+ }
183
+ // It's a plain object, not a path
184
+ let newConfig = (0, _resolveConfig).default(configOrPath.config === undefined ? configOrPath : configOrPath.config);
185
+ return [
186
+ newConfig,
187
+ null,
188
+ (0, _hashConfig).default(newConfig),
189
+ []
190
+ ];
204
191
  }
205
-
206
192
  function resolvedChangedContent(context, candidateFiles) {
207
- let changedContent = context.tailwindConfig.content.content.filter(item => typeof item.raw === 'string').concat(context.tailwindConfig.content.safelist).map(({
208
- raw,
209
- extension
210
- }) => ({
211
- content: raw,
212
- extension
213
- }));
214
-
215
- for (let changedFile of resolveChangedFiles(context, candidateFiles)) {
216
- let content = _fs.default.readFileSync(changedFile, 'utf8');
217
-
218
- let extension = _path.default.extname(changedFile).slice(1);
219
-
220
- changedContent.push({
221
- content,
222
- extension
223
- });
224
- }
225
-
226
- return changedContent;
193
+ let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
194
+ ).map(({ raw , extension ='html' })=>({
195
+ content: raw,
196
+ extension
197
+ })
198
+ );
199
+ for (let changedFile of resolveChangedFiles(context, candidateFiles)){
200
+ let content = _fs.default.readFileSync(changedFile, 'utf8');
201
+ let extension = _path.default.extname(changedFile).slice(1);
202
+ changedContent.push({
203
+ content,
204
+ extension
205
+ });
206
+ }
207
+ return changedContent;
227
208
  }
228
-
229
209
  let scannedContentCache = new WeakMap();
230
-
231
210
  function resolveChangedFiles(context, candidateFiles) {
232
- let changedFiles = new Set(); // If we're not set up and watching files ourselves, we need to do
233
- // the work of grabbing all of the template files for candidate
234
- // detection.
235
-
236
- if (!scannedContentCache.has(context)) {
237
- let files = _fastGlob.default.sync(candidateFiles);
238
-
239
- for (let file of files) {
240
- changedFiles.add(file);
211
+ let changedFiles = new Set();
212
+ // If we're not set up and watching files ourselves, we need to do
213
+ // the work of grabbing all of the template files for candidate
214
+ // detection.
215
+ if (!scannedContentCache.has(context)) {
216
+ let files = _fastGlob.default.sync(candidateFiles);
217
+ for (let file of files){
218
+ changedFiles.add(file);
219
+ }
220
+ scannedContentCache.set(context, true);
241
221
  }
242
-
243
- scannedContentCache.set(context, true);
244
- }
245
-
246
- return changedFiles;
247
- } // DISABLE_TOUCH = FALSE
248
- // Retrieve an existing context from cache if possible (since contexts are unique per
249
- // source path), or set up a new one (including setting up watchers and registering
250
- // plugins) then return it
251
-
252
-
222
+ return changedFiles;
223
+ }
253
224
  function setupWatchingContext(configOrPath) {
254
- return ({
255
- tailwindDirectives,
256
- registerDependency
257
- }) => {
258
- return (root, result) => {
259
- let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
260
- let contextDependencies = new Set(configDependencies); // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
261
- // to be dependencies of the context. Can reuse the context even if they change.
262
- // We may want to think about `@layer` being part of this trigger too, but it's tough
263
- // because it's impossible for a layer in one file to end up in the actual @tailwind rule
264
- // in another file since independent sources are effectively isolated.
265
-
266
- if (tailwindDirectives.size > 0) {
267
- // Add current css file as a context dependencies.
268
- contextDependencies.add(result.opts.from); // Add all css @import dependencies as context dependencies.
269
-
270
- for (let message of result.messages) {
271
- if (message.type === 'dependency') {
272
- contextDependencies.add(message.file);
273
- }
274
- }
275
- }
276
-
277
- let [context, isNewContext] = (0, _setupContextUtils.getContext)(tailwindDirectives, root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
278
- let candidateFiles = getCandidateFiles(context, tailwindConfig);
279
- let contextConfigDependencies = getConfigDependencies(context);
280
-
281
- for (let file of configDependencies) {
282
- registerDependency({
283
- type: 'dependency',
284
- file
285
- });
286
- }
287
-
288
- context.disposables.push(oldContext => {
289
- let watcher = getWatcher(oldContext);
290
-
291
- if (watcher !== null) {
292
- watcher.close();
293
- }
294
- });
295
- let configPath = getConfigPath(context, configOrPath);
296
-
297
- if (configPath !== null) {
298
- for (let dependency of (0, _getModuleDependencies.default)(configPath)) {
299
- if (dependency.file === configPath) {
300
- continue;
301
- }
302
-
303
- contextConfigDependencies.add(dependency.file);
304
- }
305
- }
306
-
307
- if (isNewContext) {
308
- rebootWatcher(context, configPath, contextConfigDependencies, candidateFiles);
309
- } // Register our temp file as a dependency — we write to this file
310
- // to trigger rebuilds.
311
-
312
-
313
- let touchFile = getTouchFile(context);
314
-
315
- if (touchFile) {
316
- registerDependency({
317
- type: 'dependency',
318
- file: touchFile
319
- });
320
- }
321
-
322
- if (tailwindDirectives.size > 0) {
323
- for (let changedContent of resolvedChangedContent(context, candidateFiles)) {
324
- context.changedContent.push(changedContent);
325
- }
326
- }
327
-
328
- return context;
225
+ return ({ tailwindDirectives , registerDependency })=>{
226
+ return (root, result)=>{
227
+ let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
228
+ let contextDependencies = new Set(configDependencies);
229
+ // If there are no @tailwind rules, we don't consider this CSS file or it's dependencies
230
+ // to be dependencies of the context. Can reuse the context even if they change.
231
+ // We may want to think about `@layer` being part of this trigger too, but it's tough
232
+ // because it's impossible for a layer in one file to end up in the actual @tailwind rule
233
+ // in another file since independent sources are effectively isolated.
234
+ if (tailwindDirectives.size > 0) {
235
+ // Add current css file as a context dependencies.
236
+ contextDependencies.add(result.opts.from);
237
+ // Add all css @import dependencies as context dependencies.
238
+ for (let message of result.messages){
239
+ if (message.type === 'dependency') {
240
+ contextDependencies.add(message.file);
241
+ }
242
+ }
243
+ }
244
+ let [context, isNewContext] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
245
+ let candidateFiles = getCandidateFiles(context, tailwindConfig);
246
+ let contextConfigDependencies = getConfigDependencies(context);
247
+ for (let file of configDependencies){
248
+ registerDependency({
249
+ type: 'dependency',
250
+ file
251
+ });
252
+ }
253
+ context.disposables.push((oldContext)=>{
254
+ let watcher = getWatcher(oldContext);
255
+ if (watcher !== null) {
256
+ watcher.close();
257
+ }
258
+ });
259
+ let configPath = getConfigPath(context, configOrPath);
260
+ if (configPath !== null) {
261
+ for (let dependency of (0, _getModuleDependencies).default(configPath)){
262
+ if (dependency.file === configPath) {
263
+ continue;
264
+ }
265
+ contextConfigDependencies.add(dependency.file);
266
+ }
267
+ }
268
+ if (isNewContext) {
269
+ rebootWatcher(context, configPath, contextConfigDependencies, candidateFiles);
270
+ }
271
+ // Register our temp file as a dependency — we write to this file
272
+ // to trigger rebuilds.
273
+ let touchFile = getTouchFile(context);
274
+ if (touchFile) {
275
+ registerDependency({
276
+ type: 'dependency',
277
+ file: touchFile
278
+ });
279
+ }
280
+ if (tailwindDirectives.size > 0) {
281
+ for (let changedContent of resolvedChangedContent(context, candidateFiles)){
282
+ context.changedContent.push(changedContent);
283
+ }
284
+ }
285
+ return context;
286
+ };
329
287
  };
330
- };
331
- }
288
+ }
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.contentMatchCache = exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
7
-
8
- var _quickLru = _interopRequireDefault(require("quick-lru"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
5
+ exports.contextSourcesMap = exports.configContextMap = exports.contextMap = exports.env = void 0;
12
6
  const env = {
13
- TAILWIND_MODE: process.env.TAILWIND_MODE,
14
- NODE_ENV: process.env.NODE_ENV,
15
- DEBUG: process.env.DEBUG !== undefined,
16
- TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
17
- TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
7
+ TAILWIND_MODE: process.env.TAILWIND_MODE,
8
+ NODE_ENV: process.env.NODE_ENV,
9
+ DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
10
+ TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
11
+ TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
18
12
  };
19
13
  exports.env = env;
20
14
  const contextMap = new Map();
@@ -23,7 +17,3 @@ const configContextMap = new Map();
23
17
  exports.configContextMap = configContextMap;
24
18
  const contextSourcesMap = new Map();
25
19
  exports.contextSourcesMap = contextSourcesMap;
26
- const contentMatchCache = new _quickLru.default({
27
- maxSize: 25000
28
- });
29
- exports.contentMatchCache = contentMatchCache;
@@ -1,31 +1,27 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
5
  exports.default = _default;
7
-
6
+ var _normalizeScreens = require("../util/normalizeScreens");
8
7
  var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function _default({
13
- tailwindConfig: {
14
- theme
15
- }
16
- }) {
17
- return function (css) {
18
- css.walkAtRules('screen', atRule => {
19
- var _theme$screens, _theme$screens$hasOwn;
20
-
21
- const screen = atRule.params;
22
-
23
- if (!((_theme$screens = theme.screens) !== null && _theme$screens !== void 0 && (_theme$screens$hasOwn = _theme$screens.hasOwnProperty) !== null && _theme$screens$hasOwn !== void 0 && _theme$screens$hasOwn.call(_theme$screens, screen))) {
24
- throw atRule.error(`No \`${screen}\` screen found.`);
25
- }
26
-
27
- atRule.name = 'media';
28
- atRule.params = (0, _buildMediaQuery.default)(theme.screens[screen]);
29
- });
30
- };
31
- }
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ function _default({ tailwindConfig: { theme } }) {
14
+ return function(css) {
15
+ css.walkAtRules('screen', (atRule)=>{
16
+ let screen = atRule.params;
17
+ let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
18
+ let screenDefinition = screens.find(({ name })=>name === screen
19
+ );
20
+ if (!screenDefinition) {
21
+ throw atRule.error(`No \`${screen}\` screen found.`);
22
+ }
23
+ atRule.name = 'media';
24
+ atRule.params = (0, _buildMediaQuery).default(screenDefinition);
25
+ });
26
+ };
27
+ }