tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21

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 (161) hide show
  1. package/CHANGELOG.md +246 -6
  2. package/README.md +13 -9
  3. package/defaultTheme.d.ts +2 -1
  4. package/lib/cli/build/deps.js +54 -0
  5. package/lib/cli/build/index.js +48 -0
  6. package/lib/cli/build/plugin.js +362 -0
  7. package/lib/cli/build/utils.js +78 -0
  8. package/lib/cli/build/watching.js +178 -0
  9. package/lib/cli/help/index.js +71 -0
  10. package/lib/cli/index.js +18 -0
  11. package/lib/cli/init/index.js +46 -0
  12. package/lib/cli/shared.js +12 -0
  13. package/lib/cli-peer-dependencies.js +18 -5
  14. package/lib/cli.js +62 -592
  15. package/lib/constants.js +19 -12
  16. package/lib/corePluginList.js +5 -3
  17. package/lib/corePlugins.js +619 -347
  18. package/lib/css/preflight.css +7 -0
  19. package/lib/featureFlags.js +34 -22
  20. package/lib/index.js +16 -9
  21. package/lib/lib/cacheInvalidation.js +42 -21
  22. package/lib/lib/collapseAdjacentRules.js +16 -14
  23. package/lib/lib/collapseDuplicateDeclarations.js +13 -10
  24. package/lib/lib/content.js +177 -0
  25. package/lib/lib/defaultExtractor.js +230 -33
  26. package/lib/lib/detectNesting.js +13 -4
  27. package/lib/lib/evaluateTailwindFunctions.js +105 -42
  28. package/lib/lib/expandApplyAtRules.js +151 -92
  29. package/lib/lib/expandTailwindAtRules.js +134 -149
  30. package/lib/lib/findAtConfigPath.js +44 -0
  31. package/lib/lib/generateRules.js +404 -185
  32. package/lib/lib/getModuleDependencies.js +21 -18
  33. package/lib/lib/normalizeTailwindDirectives.js +11 -8
  34. package/lib/lib/offsets.js +285 -0
  35. package/lib/lib/partitionApplyAtRules.js +14 -11
  36. package/lib/lib/regex.js +60 -0
  37. package/lib/lib/remap-bitfield.js +87 -0
  38. package/lib/lib/resolveDefaultsAtRules.js +97 -79
  39. package/lib/lib/setupContextUtils.js +567 -242
  40. package/lib/lib/setupTrackingContext.js +77 -106
  41. package/lib/lib/sharedState.js +18 -10
  42. package/lib/lib/substituteScreenAtRules.js +9 -7
  43. package/lib/postcss-plugins/nesting/index.js +7 -5
  44. package/lib/postcss-plugins/nesting/plugin.js +10 -8
  45. package/lib/processTailwindFeatures.js +34 -31
  46. package/lib/public/colors.js +7 -5
  47. package/lib/public/create-plugin.js +6 -4
  48. package/lib/public/default-config.js +7 -5
  49. package/lib/public/default-theme.js +7 -5
  50. package/lib/public/resolve-config.js +13 -10
  51. package/lib/util/bigSign.js +4 -1
  52. package/lib/util/buildMediaQuery.js +10 -5
  53. package/lib/util/cloneDeep.js +6 -5
  54. package/lib/util/cloneNodes.js +9 -2
  55. package/lib/util/color.js +20 -17
  56. package/lib/util/configurePlugins.js +5 -2
  57. package/lib/util/createPlugin.js +6 -5
  58. package/lib/util/createUtilityPlugin.js +15 -13
  59. package/lib/util/dataTypes.js +75 -51
  60. package/lib/util/defaults.js +8 -5
  61. package/lib/util/escapeClassName.js +13 -10
  62. package/lib/util/escapeCommas.js +4 -1
  63. package/lib/util/flattenColorPalette.js +7 -8
  64. package/lib/util/formatVariantSelector.js +270 -103
  65. package/lib/util/getAllConfigs.js +34 -15
  66. package/lib/util/hashConfig.js +10 -7
  67. package/lib/util/isKeyframeRule.js +4 -1
  68. package/lib/util/isPlainObject.js +4 -1
  69. package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
  70. package/lib/util/log.js +14 -8
  71. package/lib/util/nameClass.js +19 -8
  72. package/lib/util/negateValue.js +20 -5
  73. package/lib/util/normalizeConfig.js +94 -53
  74. package/lib/util/normalizeScreens.js +115 -4
  75. package/lib/util/parseAnimationValue.js +43 -41
  76. package/lib/util/parseBoxShadowValue.js +12 -45
  77. package/lib/util/parseDependency.js +37 -55
  78. package/lib/util/parseGlob.js +34 -0
  79. package/lib/util/parseObjectStyles.js +15 -12
  80. package/lib/util/pluginUtils.js +146 -42
  81. package/lib/util/prefixSelector.js +26 -9
  82. package/lib/util/removeAlphaVariables.js +29 -0
  83. package/lib/util/resolveConfig.js +104 -105
  84. package/lib/util/resolveConfigPath.js +20 -17
  85. package/lib/util/responsive.js +12 -9
  86. package/lib/util/splitAtTopLevelOnly.js +43 -0
  87. package/lib/util/tap.js +4 -1
  88. package/lib/util/toColorValue.js +4 -1
  89. package/lib/util/toPath.js +18 -2
  90. package/lib/util/transformThemeValue.js +23 -11
  91. package/lib/util/validateConfig.js +24 -0
  92. package/lib/util/validateFormalSyntax.js +24 -0
  93. package/lib/util/withAlphaVariable.js +32 -24
  94. package/package.json +32 -29
  95. package/peers/index.js +6693 -3036
  96. package/plugin.d.ts +10 -5
  97. package/resolveConfig.d.ts +12 -0
  98. package/scripts/generate-types.js +53 -0
  99. package/scripts/release-channel.js +18 -0
  100. package/scripts/release-notes.js +21 -0
  101. package/scripts/type-utils.js +27 -0
  102. package/src/cli/build/deps.js +56 -0
  103. package/src/cli/build/index.js +49 -0
  104. package/src/cli/build/plugin.js +434 -0
  105. package/src/cli/build/utils.js +76 -0
  106. package/src/cli/build/watching.js +227 -0
  107. package/src/cli/help/index.js +70 -0
  108. package/src/cli/index.js +3 -0
  109. package/src/cli/init/index.js +50 -0
  110. package/src/cli/shared.js +5 -0
  111. package/src/cli-peer-dependencies.js +7 -1
  112. package/src/cli.js +46 -659
  113. package/src/corePlugins.js +346 -79
  114. package/src/css/preflight.css +7 -0
  115. package/src/featureFlags.js +12 -2
  116. package/src/index.js +5 -0
  117. package/src/lib/content.js +213 -0
  118. package/src/lib/defaultExtractor.js +202 -35
  119. package/src/lib/detectNesting.js +9 -1
  120. package/src/lib/evaluateTailwindFunctions.js +78 -7
  121. package/src/lib/expandApplyAtRules.js +129 -34
  122. package/src/lib/expandTailwindAtRules.js +12 -50
  123. package/src/lib/findAtConfigPath.js +48 -0
  124. package/src/lib/generateRules.js +379 -126
  125. package/src/lib/offsets.js +351 -0
  126. package/src/lib/regex.js +74 -0
  127. package/src/lib/remap-bitfield.js +82 -0
  128. package/src/lib/resolveDefaultsAtRules.js +53 -36
  129. package/src/lib/setupContextUtils.js +510 -120
  130. package/src/lib/setupTrackingContext.js +8 -45
  131. package/src/lib/sharedState.js +2 -0
  132. package/src/util/buildMediaQuery.js +5 -3
  133. package/src/util/cloneNodes.js +5 -1
  134. package/src/util/dataTypes.js +51 -26
  135. package/src/util/formatVariantSelector.js +317 -101
  136. package/src/util/getAllConfigs.js +19 -0
  137. package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
  138. package/src/util/log.js +1 -1
  139. package/src/util/nameClass.js +4 -0
  140. package/src/util/negateValue.js +10 -2
  141. package/src/util/normalizeConfig.js +40 -10
  142. package/src/util/normalizeScreens.js +99 -4
  143. package/src/util/parseBoxShadowValue.js +3 -50
  144. package/src/util/parseDependency.js +37 -42
  145. package/src/util/parseGlob.js +24 -0
  146. package/src/util/pluginUtils.js +132 -10
  147. package/src/util/prefixSelector.js +28 -10
  148. package/src/util/removeAlphaVariables.js +24 -0
  149. package/src/util/resolveConfig.js +70 -62
  150. package/src/util/splitAtTopLevelOnly.js +45 -0
  151. package/src/util/toPath.js +1 -1
  152. package/src/util/transformThemeValue.js +13 -3
  153. package/src/util/validateConfig.js +13 -0
  154. package/src/util/validateFormalSyntax.js +34 -0
  155. package/src/util/withAlphaVariable.js +1 -1
  156. package/stubs/defaultConfig.stub.js +165 -164
  157. package/stubs/simpleConfig.stub.js +1 -0
  158. package/types/config.d.ts +77 -37
  159. package/types/generated/default-theme.d.ts +342 -0
  160. package/types/index.d.ts +7 -1
  161. package/types.d.ts +0 -1
@@ -2,14 +2,124 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.default = expandTailwindAtRules;
6
- var _quickLru = _interopRequireDefault(require("quick-lru"));
7
- var sharedState = _interopRequireWildcard(require("./sharedState"));
8
- var _generateRules = require("./generateRules");
9
- var _bigSign = _interopRequireDefault(require("../util/bigSign"));
10
- var _log = _interopRequireDefault(require("../util/log"));
11
- var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
12
- var _defaultExtractor = require("./defaultExtractor");
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: ()=>expandTailwindAtRules
8
+ });
9
+ const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
10
+ const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
11
+ const _generateRules = require("./generateRules");
12
+ const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
13
+ const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
14
+ const _defaultExtractor = require("./defaultExtractor");
15
+ function _interopRequireDefault(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ function _getRequireWildcardCache(nodeInterop) {
21
+ if (typeof WeakMap !== "function") return null;
22
+ var cacheBabelInterop = new WeakMap();
23
+ var cacheNodeInterop = new WeakMap();
24
+ return (_getRequireWildcardCache = function(nodeInterop) {
25
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
26
+ })(nodeInterop);
27
+ }
28
+ function _interopRequireWildcard(obj, nodeInterop) {
29
+ if (!nodeInterop && obj && obj.__esModule) {
30
+ return obj;
31
+ }
32
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
+ return {
34
+ default: obj
35
+ };
36
+ }
37
+ var cache = _getRequireWildcardCache(nodeInterop);
38
+ if (cache && cache.has(obj)) {
39
+ return cache.get(obj);
40
+ }
41
+ var newObj = {};
42
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
+ for(var key in obj){
44
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
+ if (desc && (desc.get || desc.set)) {
47
+ Object.defineProperty(newObj, key, desc);
48
+ } else {
49
+ newObj[key] = obj[key];
50
+ }
51
+ }
52
+ }
53
+ newObj.default = obj;
54
+ if (cache) {
55
+ cache.set(obj, newObj);
56
+ }
57
+ return newObj;
58
+ }
59
+ let env = _sharedState.env;
60
+ const builtInExtractors = {
61
+ DEFAULT: _defaultExtractor.defaultExtractor
62
+ };
63
+ const builtInTransformers = {
64
+ DEFAULT: (content)=>content,
65
+ svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
66
+ };
67
+ function getExtractor(context, fileExtension) {
68
+ let extractors = context.tailwindConfig.content.extract;
69
+ return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
70
+ }
71
+ function getTransformer(tailwindConfig, fileExtension) {
72
+ let transformers = tailwindConfig.content.transform;
73
+ return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
74
+ }
75
+ let extractorCache = new WeakMap();
76
+ // Scans template contents for possible classes. This is a hot path on initial build but
77
+ // not too important for subsequent builds. The faster the better though — if we can speed
78
+ // up these regexes by 50% that could cut initial build time by like 20%.
79
+ function getClassCandidates(content, extractor, candidates, seen) {
80
+ if (!extractorCache.has(extractor)) {
81
+ extractorCache.set(extractor, new _quickLru.default({
82
+ maxSize: 25000
83
+ }));
84
+ }
85
+ for (let line of content.split("\n")){
86
+ line = line.trim();
87
+ if (seen.has(line)) {
88
+ continue;
89
+ }
90
+ seen.add(line);
91
+ if (extractorCache.get(extractor).has(line)) {
92
+ for (let match of extractorCache.get(extractor).get(line)){
93
+ candidates.add(match);
94
+ }
95
+ } else {
96
+ let extractorMatches = extractor(line).filter((s)=>s !== "!*");
97
+ let lineMatchesSet = new Set(extractorMatches);
98
+ for (let match1 of lineMatchesSet){
99
+ candidates.add(match1);
100
+ }
101
+ extractorCache.get(extractor).set(line, lineMatchesSet);
102
+ }
103
+ }
104
+ }
105
+ /**
106
+ *
107
+ * @param {[import('./offsets.js').RuleOffset, import('postcss').Node][]} rules
108
+ * @param {*} context
109
+ */ function buildStylesheet(rules, context) {
110
+ let sortedRules = context.offsets.sort(rules);
111
+ let returnValue = {
112
+ base: new Set(),
113
+ defaults: new Set(),
114
+ components: new Set(),
115
+ utilities: new Set(),
116
+ variants: new Set()
117
+ };
118
+ for (let [sort, rule] of sortedRules){
119
+ returnValue[sort.layer].add(rule);
120
+ }
121
+ return returnValue;
122
+ }
13
123
  function expandTailwindAtRules(context) {
14
124
  return (root)=>{
15
125
  let layerNodes = {
@@ -29,20 +139,19 @@ function expandTailwindAtRules(context) {
29
139
  }
30
140
  }
31
141
  });
32
- if (Object.values(layerNodes).every((n)=>n === null
33
- )) {
142
+ if (Object.values(layerNodes).every((n)=>n === null)) {
34
143
  return root;
35
144
  }
36
145
  // ---
37
146
  // Find potential rules in changed files
38
147
  let candidates = new Set([
39
- sharedState.NOT_ON_DEMAND
148
+ _sharedState.NOT_ON_DEMAND
40
149
  ]);
41
150
  let seen = new Set();
42
151
  env.DEBUG && console.time("Reading changed files");
43
152
  for (let { content , extension } of context.changedContent){
44
153
  let transformer = getTransformer(context.tailwindConfig, extension);
45
- let extractor = getExtractor(context.tailwindConfig, extension);
154
+ let extractor = getExtractor(context, extension);
46
155
  getClassCandidates(transformer(content), extractor, candidates, seen);
47
156
  }
48
157
  env.DEBUG && console.timeEnd("Reading changed files");
@@ -50,24 +159,21 @@ function expandTailwindAtRules(context) {
50
159
  // Generate the actual CSS
51
160
  let classCacheCount = context.classCache.size;
52
161
  env.DEBUG && console.time("Generate rules");
53
- let rules = (0, _generateRules).generateRules(candidates, context);
162
+ (0, _generateRules.generateRules)(candidates, context);
54
163
  env.DEBUG && console.timeEnd("Generate rules");
55
164
  // We only ever add to the classCache, so if it didn't grow, there is nothing new.
56
165
  env.DEBUG && console.time("Build stylesheet");
57
166
  if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
58
- for (let rule of rules){
59
- context.ruleCache.add(rule);
60
- }
61
167
  context.stylesheetCache = buildStylesheet([
62
168
  ...context.ruleCache
63
169
  ], context);
64
170
  }
65
171
  env.DEBUG && console.timeEnd("Build stylesheet");
66
- let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
172
+ let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes } = context.stylesheetCache;
67
173
  // ---
68
174
  // Replace any Tailwind directives with generated CSS
69
175
  if (layerNodes.base) {
70
- layerNodes.base.before((0, _cloneNodes).default([
176
+ layerNodes.base.before((0, _cloneNodes.default)([
71
177
  ...baseNodes,
72
178
  ...defaultNodes
73
179
  ], layerNodes.base.source, {
@@ -76,7 +182,7 @@ function expandTailwindAtRules(context) {
76
182
  layerNodes.base.remove();
77
183
  }
78
184
  if (layerNodes.components) {
79
- layerNodes.components.before((0, _cloneNodes).default([
185
+ layerNodes.components.before((0, _cloneNodes.default)([
80
186
  ...componentNodes
81
187
  ], layerNodes.components.source, {
82
188
  layer: "components"
@@ -84,7 +190,7 @@ function expandTailwindAtRules(context) {
84
190
  layerNodes.components.remove();
85
191
  }
86
192
  if (layerNodes.utilities) {
87
- layerNodes.utilities.before((0, _cloneNodes).default([
193
+ layerNodes.utilities.before((0, _cloneNodes.default)([
88
194
  ...utilityNodes
89
195
  ], layerNodes.utilities.source, {
90
196
  layer: "utilities"
@@ -93,8 +199,8 @@ function expandTailwindAtRules(context) {
93
199
  }
94
200
  // We do post-filtering to not alter the emitted order of the variants
95
201
  const variantNodes = Array.from(screenNodes).filter((node)=>{
96
- var ref;
97
- const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
202
+ var _node_raws_tailwind;
203
+ const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
98
204
  if (parentLayer === "components") {
99
205
  return layerNodes.components !== null;
100
206
  }
@@ -104,30 +210,30 @@ function expandTailwindAtRules(context) {
104
210
  return true;
105
211
  });
106
212
  if (layerNodes.variants) {
107
- layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source, {
213
+ layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
108
214
  layer: "variants"
109
215
  }));
110
216
  layerNodes.variants.remove();
111
217
  } else if (variantNodes.length > 0) {
112
- root.append((0, _cloneNodes).default(variantNodes, root.source, {
218
+ root.append((0, _cloneNodes.default)(variantNodes, root.source, {
113
219
  layer: "variants"
114
220
  }));
115
221
  }
116
222
  // If we've got a utility layer and no utilities are generated there's likely something wrong
117
223
  const hasUtilityVariants = variantNodes.some((node)=>{
118
- var ref;
119
- return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
224
+ var _node_raws_tailwind;
225
+ return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
120
226
  });
121
227
  if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
122
228
  _log.default.warn("content-problems", [
123
229
  "No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
124
- "https://tailwindcss.com/docs/content-configuration",
230
+ "https://tailwindcss.com/docs/content-configuration"
125
231
  ]);
126
232
  }
127
233
  // ---
128
234
  if (env.DEBUG) {
129
235
  console.log("Potential classes: ", candidates.size);
130
- console.log("Active contexts: ", sharedState.contextSourcesMap.size);
236
+ console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
131
237
  }
132
238
  // Clear the cache for the changed files
133
239
  context.changedContent = [];
@@ -139,124 +245,3 @@ function expandTailwindAtRules(context) {
139
245
  });
140
246
  };
141
247
  }
142
- function _interopRequireDefault(obj) {
143
- return obj && obj.__esModule ? obj : {
144
- default: obj
145
- };
146
- }
147
- function _interopRequireWildcard(obj) {
148
- if (obj && obj.__esModule) {
149
- return obj;
150
- } else {
151
- var newObj = {};
152
- if (obj != null) {
153
- for(var key in obj){
154
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
155
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
156
- if (desc.get || desc.set) {
157
- Object.defineProperty(newObj, key, desc);
158
- } else {
159
- newObj[key] = obj[key];
160
- }
161
- }
162
- }
163
- }
164
- newObj.default = obj;
165
- return newObj;
166
- }
167
- }
168
- let env = sharedState.env;
169
- const builtInExtractors = {
170
- DEFAULT: _defaultExtractor.defaultExtractor
171
- };
172
- const builtInTransformers = {
173
- DEFAULT: (content)=>content
174
- ,
175
- svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
176
- };
177
- function getExtractor(tailwindConfig, fileExtension) {
178
- let extractors = tailwindConfig.content.extract;
179
- return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
180
- }
181
- function getTransformer(tailwindConfig, fileExtension) {
182
- let transformers = tailwindConfig.content.transform;
183
- return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
184
- }
185
- let extractorCache = new WeakMap();
186
- // Scans template contents for possible classes. This is a hot path on initial build but
187
- // not too important for subsequent builds. The faster the better though — if we can speed
188
- // up these regexes by 50% that could cut initial build time by like 20%.
189
- function getClassCandidates(content, extractor, candidates, seen) {
190
- if (!extractorCache.has(extractor)) {
191
- extractorCache.set(extractor, new _quickLru.default({
192
- maxSize: 25000
193
- }));
194
- }
195
- for (let line of content.split("\n")){
196
- line = line.trim();
197
- if (seen.has(line)) {
198
- continue;
199
- }
200
- seen.add(line);
201
- if (extractorCache.get(extractor).has(line)) {
202
- for (let match of extractorCache.get(extractor).get(line)){
203
- candidates.add(match);
204
- }
205
- } else {
206
- let extractorMatches = extractor(line).filter((s)=>s !== "!*"
207
- );
208
- let lineMatchesSet = new Set(extractorMatches);
209
- for (let match of lineMatchesSet){
210
- candidates.add(match);
211
- }
212
- extractorCache.get(extractor).set(line, lineMatchesSet);
213
- }
214
- }
215
- }
216
- function buildStylesheet(rules, context) {
217
- let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
218
- );
219
- let returnValue = {
220
- base: new Set(),
221
- defaults: new Set(),
222
- components: new Set(),
223
- utilities: new Set(),
224
- variants: new Set(),
225
- // All the CSS that is not Tailwind related can be put in this bucket. This
226
- // will make it easier to later use this information when we want to
227
- // `@apply` for example. The main reason we do this here is because we
228
- // still need to make sure the order is correct. Last but not least, we
229
- // will make sure to always re-inject this section into the css, even if
230
- // certain rules were not used. This means that it will look like a no-op
231
- // from the user's perspective, but we gathered all the useful information
232
- // we need.
233
- user: new Set()
234
- };
235
- for (let [sort, rule] of sortedRules){
236
- if (sort >= context.minimumScreen) {
237
- returnValue.variants.add(rule);
238
- continue;
239
- }
240
- if (sort & context.layerOrder.base) {
241
- returnValue.base.add(rule);
242
- continue;
243
- }
244
- if (sort & context.layerOrder.defaults) {
245
- returnValue.defaults.add(rule);
246
- continue;
247
- }
248
- if (sort & context.layerOrder.components) {
249
- returnValue.components.add(rule);
250
- continue;
251
- }
252
- if (sort & context.layerOrder.utilities) {
253
- returnValue.utilities.add(rule);
254
- continue;
255
- }
256
- if (sort & context.layerOrder.user) {
257
- returnValue.user.add(rule);
258
- continue;
259
- }
260
- }
261
- return returnValue;
262
- }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "findAtConfigPath", {
6
+ enumerable: true,
7
+ get: ()=>findAtConfigPath
8
+ });
9
+ const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
10
+ const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function findAtConfigPath(root, result) {
17
+ let configPath = null;
18
+ let relativeTo = null;
19
+ root.walkAtRules("config", (rule)=>{
20
+ var _rule_source;
21
+ var _rule_source_input_file, _ref;
22
+ relativeTo = (_ref = (_rule_source_input_file = (_rule_source = rule.source) === null || _rule_source === void 0 ? void 0 : _rule_source.input.file) !== null && _rule_source_input_file !== void 0 ? _rule_source_input_file : result.opts.from) !== null && _ref !== void 0 ? _ref : null;
23
+ if (relativeTo === null) {
24
+ throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
25
+ }
26
+ if (configPath) {
27
+ throw rule.error("Only one `@config` directive is allowed per file.");
28
+ }
29
+ let matches = rule.params.match(/(['"])(.*?)\1/);
30
+ if (!matches) {
31
+ throw rule.error("A path is required when using the `@config` directive.");
32
+ }
33
+ let inputPath = matches[2];
34
+ if (_path.default.isAbsolute(inputPath)) {
35
+ throw rule.error("The `@config` directive cannot be used with an absolute path.");
36
+ }
37
+ configPath = _path.default.resolve(_path.default.dirname(relativeTo), inputPath);
38
+ if (!_fs.default.existsSync(configPath)) {
39
+ throw rule.error(`The config file at "${inputPath}" does not exist. Make sure the path is correct and the file exists.`);
40
+ }
41
+ rule.remove();
42
+ });
43
+ return configPath ? configPath : null;
44
+ }