tailwindcss 0.0.0-insiders.4e21639 → 0.0.0-insiders.4e62334
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +435 -3
- package/LICENSE +1 -2
- package/README.md +13 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +460 -259
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +9 -3
- package/lib/corePlugins.js +1840 -1753
- package/lib/css/preflight.css +8 -9
- package/lib/featureFlags.js +29 -20
- package/lib/index.js +22 -11
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +58 -4
- package/lib/lib/defaultExtractor.js +231 -0
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +119 -52
- package/lib/lib/expandApplyAtRules.js +440 -161
- package/lib/lib/expandTailwindAtRules.js +130 -128
- package/lib/lib/generateRules.js +410 -171
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +43 -32
- package/lib/lib/offsets.js +199 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +91 -55
- package/lib/lib/setupContextUtils.js +453 -347
- package/lib/lib/setupTrackingContext.js +52 -44
- package/lib/lib/sharedState.js +48 -9
- package/lib/lib/substituteScreenAtRules.js +13 -8
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +36 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +16 -25
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -102
- package/lib/util/defaults.js +10 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +223 -40
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +72 -0
- package/lib/util/log.js +22 -12
- package/lib/util/nameClass.js +17 -8
- package/lib/util/negateValue.js +22 -7
- package/lib/util/normalizeConfig.js +99 -54
- package/lib/util/normalizeScreens.js +73 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +51 -42
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +91 -66
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +43 -43
- package/peers/index.js +11543 -8114
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +293 -36
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +428 -285
- package/src/css/preflight.css +8 -9
- package/src/featureFlags.js +9 -5
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/defaultExtractor.js +208 -0
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +82 -80
- package/src/lib/generateRules.js +352 -120
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +239 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +59 -17
- package/src/lib/setupContextUtils.js +337 -174
- package/src/lib/setupTrackingContext.js +13 -8
- package/src/lib/sharedState.js +42 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +12 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/dataTypes.js +28 -19
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +237 -23
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +1 -1
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +16 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/pluginUtils.js +14 -2
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +71 -17
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +24 -3
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +334 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -288
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -311
|
@@ -2,73 +2,71 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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");
|
|
11
15
|
function _interopRequireDefault(obj) {
|
|
12
16
|
return obj && obj.__esModule ? obj : {
|
|
13
17
|
default: obj
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
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) {
|
|
18
30
|
return obj;
|
|
19
|
-
}
|
|
20
|
-
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
21
35
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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];
|
|
33
50
|
}
|
|
34
51
|
}
|
|
35
|
-
newObj.default = obj;
|
|
36
|
-
return newObj;
|
|
37
52
|
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
38
58
|
}
|
|
39
|
-
let env =
|
|
40
|
-
const PATTERNS = [
|
|
41
|
-
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
42
|
-
/([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
|
|
43
|
-
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
44
|
-
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
45
|
-
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
46
|
-
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
47
|
-
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
48
|
-
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
49
|
-
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
50
|
-
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
51
|
-
].join('|');
|
|
52
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
53
|
-
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
|
|
59
|
+
let env = _sharedState.env;
|
|
54
60
|
const builtInExtractors = {
|
|
55
|
-
DEFAULT:
|
|
56
|
-
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
|
|
57
|
-
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
|
|
58
|
-
return [
|
|
59
|
-
...broadMatches,
|
|
60
|
-
...innerMatches
|
|
61
|
-
];
|
|
62
|
-
}
|
|
61
|
+
DEFAULT: _defaultExtractor.defaultExtractor
|
|
63
62
|
};
|
|
64
63
|
const builtInTransformers = {
|
|
65
|
-
DEFAULT: (content)=>content
|
|
66
|
-
,
|
|
67
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
64
|
+
DEFAULT: (content)=>content,
|
|
65
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
68
66
|
};
|
|
69
|
-
function getExtractor(
|
|
70
|
-
let extractors = tailwindConfig.content.extract;
|
|
71
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
67
|
+
function getExtractor(context, fileExtension) {
|
|
68
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
69
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
72
70
|
}
|
|
73
71
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
74
72
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -84,7 +82,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
84
82
|
maxSize: 25000
|
|
85
83
|
}));
|
|
86
84
|
}
|
|
87
|
-
for (let line of content.split(
|
|
85
|
+
for (let line of content.split("\n")){
|
|
88
86
|
line = line.trim();
|
|
89
87
|
if (seen.has(line)) {
|
|
90
88
|
continue;
|
|
@@ -95,55 +93,30 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
95
93
|
candidates.add(match);
|
|
96
94
|
}
|
|
97
95
|
} else {
|
|
98
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
99
|
-
);
|
|
96
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
100
97
|
let lineMatchesSet = new Set(extractorMatches);
|
|
101
|
-
for (let
|
|
102
|
-
candidates.add(
|
|
98
|
+
for (let match1 of lineMatchesSet){
|
|
99
|
+
candidates.add(match1);
|
|
103
100
|
}
|
|
104
101
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
111
|
let returnValue = {
|
|
112
112
|
base: new Set(),
|
|
113
|
+
defaults: new Set(),
|
|
113
114
|
components: new Set(),
|
|
114
115
|
utilities: new Set(),
|
|
115
|
-
variants: new Set()
|
|
116
|
-
// All the CSS that is not Tailwind related can be put in this bucket. This
|
|
117
|
-
// will make it easier to later use this information when we want to
|
|
118
|
-
// `@apply` for example. The main reason we do this here is because we
|
|
119
|
-
// still need to make sure the order is correct. Last but not least, we
|
|
120
|
-
// will make sure to always re-inject this section into the css, even if
|
|
121
|
-
// certain rules were not used. This means that it will look like a no-op
|
|
122
|
-
// from the user's perspective, but we gathered all the useful information
|
|
123
|
-
// we need.
|
|
124
|
-
user: new Set()
|
|
116
|
+
variants: new Set()
|
|
125
117
|
};
|
|
126
118
|
for (let [sort, rule] of sortedRules){
|
|
127
|
-
|
|
128
|
-
returnValue.variants.add(rule);
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (sort & context.layerOrder.base) {
|
|
132
|
-
returnValue.base.add(rule);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (sort & context.layerOrder.components) {
|
|
136
|
-
returnValue.components.add(rule);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (sort & context.layerOrder.utilities) {
|
|
140
|
-
returnValue.utilities.add(rule);
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (sort & context.layerOrder.user) {
|
|
144
|
-
returnValue.user.add(rule);
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
119
|
+
returnValue[sort.layer].add(rule);
|
|
147
120
|
}
|
|
148
121
|
return returnValue;
|
|
149
122
|
}
|
|
@@ -155,88 +128,117 @@ function expandTailwindAtRules(context) {
|
|
|
155
128
|
utilities: null,
|
|
156
129
|
variants: null
|
|
157
130
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
layerNodes
|
|
131
|
+
root.walkAtRules((rule)=>{
|
|
132
|
+
// Make sure this file contains Tailwind directives. If not, we can save
|
|
133
|
+
// a lot of work and bail early. Also we don't have to register our touch
|
|
134
|
+
// file as a dependency since the output of this CSS does not depend on
|
|
135
|
+
// the source of any templates. Think Vue <style> blocks for example.
|
|
136
|
+
if (rule.name === "tailwind") {
|
|
137
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
138
|
+
layerNodes[rule.params] = rule;
|
|
139
|
+
}
|
|
165
140
|
}
|
|
166
141
|
});
|
|
167
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
168
|
-
)) {
|
|
142
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
169
143
|
return root;
|
|
170
144
|
}
|
|
171
145
|
// ---
|
|
172
146
|
// Find potential rules in changed files
|
|
173
147
|
let candidates = new Set([
|
|
174
|
-
|
|
148
|
+
_sharedState.NOT_ON_DEMAND
|
|
175
149
|
]);
|
|
176
150
|
let seen = new Set();
|
|
177
|
-
env.DEBUG && console.time(
|
|
151
|
+
env.DEBUG && console.time("Reading changed files");
|
|
178
152
|
for (let { content , extension } of context.changedContent){
|
|
179
153
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
180
|
-
let extractor = getExtractor(context
|
|
154
|
+
let extractor = getExtractor(context, extension);
|
|
181
155
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
182
156
|
}
|
|
157
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
183
158
|
// ---
|
|
184
159
|
// Generate the actual CSS
|
|
185
160
|
let classCacheCount = context.classCache.size;
|
|
186
|
-
env.DEBUG && console.time(
|
|
187
|
-
|
|
188
|
-
env.DEBUG && console.timeEnd(
|
|
161
|
+
env.DEBUG && console.time("Generate rules");
|
|
162
|
+
(0, _generateRules.generateRules)(candidates, context);
|
|
163
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
189
164
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
190
|
-
env.DEBUG && console.time(
|
|
165
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
191
166
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
192
|
-
for (let rule of rules){
|
|
193
|
-
context.ruleCache.add(rule);
|
|
194
|
-
}
|
|
195
167
|
context.stylesheetCache = buildStylesheet([
|
|
196
168
|
...context.ruleCache
|
|
197
169
|
], context);
|
|
198
170
|
}
|
|
199
|
-
env.DEBUG && console.timeEnd(
|
|
200
|
-
let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
171
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
172
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
201
173
|
// ---
|
|
202
174
|
// Replace any Tailwind directives with generated CSS
|
|
203
175
|
if (layerNodes.base) {
|
|
204
|
-
layerNodes.base.before((0, _cloneNodes
|
|
205
|
-
...baseNodes
|
|
206
|
-
|
|
176
|
+
layerNodes.base.before((0, _cloneNodes.default)([
|
|
177
|
+
...baseNodes,
|
|
178
|
+
...defaultNodes
|
|
179
|
+
], layerNodes.base.source, {
|
|
180
|
+
layer: "base"
|
|
181
|
+
}));
|
|
207
182
|
layerNodes.base.remove();
|
|
208
183
|
}
|
|
209
184
|
if (layerNodes.components) {
|
|
210
|
-
layerNodes.components.before((0, _cloneNodes
|
|
185
|
+
layerNodes.components.before((0, _cloneNodes.default)([
|
|
211
186
|
...componentNodes
|
|
212
|
-
], layerNodes.components.source
|
|
187
|
+
], layerNodes.components.source, {
|
|
188
|
+
layer: "components"
|
|
189
|
+
}));
|
|
213
190
|
layerNodes.components.remove();
|
|
214
191
|
}
|
|
215
192
|
if (layerNodes.utilities) {
|
|
216
|
-
layerNodes.utilities.before((0, _cloneNodes
|
|
193
|
+
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
217
194
|
...utilityNodes
|
|
218
|
-
], layerNodes.utilities.source
|
|
195
|
+
], layerNodes.utilities.source, {
|
|
196
|
+
layer: "utilities"
|
|
197
|
+
}));
|
|
219
198
|
layerNodes.utilities.remove();
|
|
220
199
|
}
|
|
200
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
201
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
202
|
+
var ref;
|
|
203
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
204
|
+
if (parentLayer === "components") {
|
|
205
|
+
return layerNodes.components !== null;
|
|
206
|
+
}
|
|
207
|
+
if (parentLayer === "utilities") {
|
|
208
|
+
return layerNodes.utilities !== null;
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
});
|
|
221
212
|
if (layerNodes.variants) {
|
|
222
|
-
layerNodes.variants.before((0, _cloneNodes
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
214
|
+
layer: "variants"
|
|
215
|
+
}));
|
|
225
216
|
layerNodes.variants.remove();
|
|
226
|
-
} else {
|
|
227
|
-
root.append((0, _cloneNodes
|
|
228
|
-
|
|
229
|
-
|
|
217
|
+
} else if (variantNodes.length > 0) {
|
|
218
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
219
|
+
layer: "variants"
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
223
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
224
|
+
var ref;
|
|
225
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
|
|
226
|
+
});
|
|
227
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
228
|
+
_log.default.warn("content-problems", [
|
|
229
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
230
|
+
"https://tailwindcss.com/docs/content-configuration",
|
|
231
|
+
]);
|
|
230
232
|
}
|
|
231
233
|
// ---
|
|
232
234
|
if (env.DEBUG) {
|
|
233
|
-
console.log(
|
|
234
|
-
console.log(
|
|
235
|
+
console.log("Potential classes: ", candidates.size);
|
|
236
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
235
237
|
}
|
|
236
238
|
// Clear the cache for the changed files
|
|
237
239
|
context.changedContent = [];
|
|
238
240
|
// Cleanup any leftover @layer atrules
|
|
239
|
-
root.walkAtRules(
|
|
241
|
+
root.walkAtRules("layer", (rule)=>{
|
|
240
242
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
241
243
|
rule.remove();
|
|
242
244
|
}
|