tailwindcss 0.0.0-oxide-insiders.dddaded → 0.0.0-oxide-insiders.b2e3cf2

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