tailwindcss 3.0.10 → 3.0.14
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 +43 -1
- package/lib/cli.js +8 -16
- package/lib/corePlugins.js +183 -280
- package/lib/css/preflight.css +1 -1
- package/lib/featureFlags.js +2 -5
- package/lib/lib/expandApplyAtRules.js +0 -40
- package/lib/lib/expandTailwindAtRules.js +32 -39
- package/lib/lib/generateRules.js +8 -2
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +4 -4
- package/lib/lib/setupContextUtils.js +48 -52
- package/lib/processTailwindFeatures.js +3 -1
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +4 -8
- package/lib/util/flattenColorPalette.js +1 -3
- package/lib/util/normalizeConfig.js +11 -12
- package/lib/util/normalizeScreens.js +2 -4
- package/lib/util/pluginUtils.js +6 -13
- package/lib/util/resolveConfig.js +9 -18
- package/lib/util/resolveConfigPath.js +1 -2
- package/lib/util/toColorValue.js +1 -2
- package/lib/util/transformThemeValue.js +4 -8
- package/nesting/plugin.js +4 -1
- package/package.json +10 -12
- package/peers/index.js +652 -651
- package/src/corePlugins.js +121 -155
- package/src/css/preflight.css +1 -1
- package/src/featureFlags.js +1 -5
- package/src/lib/expandApplyAtRules.js +0 -42
- package/src/lib/expandTailwindAtRules.js +34 -30
- package/src/lib/generateRules.js +6 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/resolveDefaultsAtRules.js +5 -5
- package/src/lib/setupContextUtils.js +37 -17
- package/src/processTailwindFeatures.js +4 -1
- package/src/util/normalizeConfig.js +6 -0
- package/src/util/pluginUtils.js +1 -1
package/lib/css/preflight.css
CHANGED
package/lib/featureFlags.js
CHANGED
|
@@ -13,9 +13,7 @@ function _interopRequireDefault(obj) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
let defaults = {
|
|
16
|
-
|
|
17
|
-
// the default.
|
|
18
|
-
optimizeUniversalDefaults: process.env.NODE_ENV === 'test' ? true : false
|
|
16
|
+
optimizeUniversalDefaults: false
|
|
19
17
|
};
|
|
20
18
|
let featureFlags = {
|
|
21
19
|
future: [],
|
|
@@ -41,8 +39,7 @@ function experimentalFlagsEnabled(config) {
|
|
|
41
39
|
return featureFlags.experimental;
|
|
42
40
|
}
|
|
43
41
|
var ref;
|
|
44
|
-
return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {
|
|
45
|
-
}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
|
|
42
|
+
return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]
|
|
46
43
|
);
|
|
47
44
|
}
|
|
48
45
|
function issueFlagNotices(config) {
|
|
@@ -75,45 +75,6 @@ function extractApplyCandidates(params) {
|
|
|
75
75
|
false
|
|
76
76
|
];
|
|
77
77
|
}
|
|
78
|
-
function partitionApplyParents(root) {
|
|
79
|
-
let applyParents = new Set();
|
|
80
|
-
root.walkAtRules('apply', (rule)=>{
|
|
81
|
-
applyParents.add(rule.parent);
|
|
82
|
-
});
|
|
83
|
-
for (let rule1 of applyParents){
|
|
84
|
-
let nodeGroups = [];
|
|
85
|
-
let lastGroup = [];
|
|
86
|
-
for (let node of rule1.nodes){
|
|
87
|
-
if (node.type === 'atrule' && node.name === 'apply') {
|
|
88
|
-
if (lastGroup.length > 0) {
|
|
89
|
-
nodeGroups.push(lastGroup);
|
|
90
|
-
lastGroup = [];
|
|
91
|
-
}
|
|
92
|
-
nodeGroups.push([
|
|
93
|
-
node
|
|
94
|
-
]);
|
|
95
|
-
} else {
|
|
96
|
-
lastGroup.push(node);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (lastGroup.length > 0) {
|
|
100
|
-
nodeGroups.push(lastGroup);
|
|
101
|
-
}
|
|
102
|
-
if (nodeGroups.length === 1) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
for (let group of [
|
|
106
|
-
...nodeGroups
|
|
107
|
-
].reverse()){
|
|
108
|
-
let newParent = rule1.clone({
|
|
109
|
-
nodes: []
|
|
110
|
-
});
|
|
111
|
-
newParent.append(group);
|
|
112
|
-
rule1.after(newParent);
|
|
113
|
-
}
|
|
114
|
-
rule1.remove();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
78
|
function processApply(root, context) {
|
|
118
79
|
let applyCandidates = new Set();
|
|
119
80
|
// Collect all @apply rules and candidates
|
|
@@ -311,7 +272,6 @@ function processApply(root, context) {
|
|
|
311
272
|
}
|
|
312
273
|
function expandApplyAtRules(context) {
|
|
313
274
|
return (root)=>{
|
|
314
|
-
partitionApplyParents(root);
|
|
315
275
|
processApply(root, context);
|
|
316
276
|
};
|
|
317
277
|
}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandTailwindAtRules;
|
|
6
|
-
exports.DEFAULTS_LAYER = void 0;
|
|
7
6
|
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
8
7
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
9
8
|
var _generateRules = require("./generateRules");
|
|
10
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
10
|
+
var _log = _interopRequireDefault(require("../util/log"));
|
|
11
11
|
var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
|
|
12
12
|
var _defaultExtractor = require("./defaultExtractor");
|
|
13
13
|
function _interopRequireDefault(obj) {
|
|
@@ -19,13 +19,11 @@ function _interopRequireWildcard(obj) {
|
|
|
19
19
|
if (obj && obj.__esModule) {
|
|
20
20
|
return obj;
|
|
21
21
|
} else {
|
|
22
|
-
var newObj = {
|
|
23
|
-
};
|
|
22
|
+
var newObj = {};
|
|
24
23
|
if (obj != null) {
|
|
25
24
|
for(var key in obj){
|
|
26
25
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
28
|
-
};
|
|
26
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
29
27
|
if (desc.get || desc.set) {
|
|
30
28
|
Object.defineProperty(newObj, key, desc);
|
|
31
29
|
} else {
|
|
@@ -133,8 +131,6 @@ function buildStylesheet(rules, context) {
|
|
|
133
131
|
}
|
|
134
132
|
return returnValue;
|
|
135
133
|
}
|
|
136
|
-
const DEFAULTS_LAYER = Symbol('defaults-layer');
|
|
137
|
-
exports.DEFAULTS_LAYER = DEFAULTS_LAYER;
|
|
138
134
|
function expandTailwindAtRules(context) {
|
|
139
135
|
return (root)=>{
|
|
140
136
|
let layerNodes = {
|
|
@@ -143,7 +139,6 @@ function expandTailwindAtRules(context) {
|
|
|
143
139
|
utilities: null,
|
|
144
140
|
variants: null
|
|
145
141
|
};
|
|
146
|
-
let hasApply = false;
|
|
147
142
|
root.walkAtRules((rule)=>{
|
|
148
143
|
// Make sure this file contains Tailwind directives. If not, we can save
|
|
149
144
|
// a lot of work and bail early. Also we don't have to register our touch
|
|
@@ -154,15 +149,9 @@ function expandTailwindAtRules(context) {
|
|
|
154
149
|
layerNodes[rule.params] = rule;
|
|
155
150
|
}
|
|
156
151
|
}
|
|
157
|
-
// We also want to check for @apply because the user can
|
|
158
|
-
// apply classes in an isolated environment like CSS
|
|
159
|
-
// modules and we still need to inject defaults
|
|
160
|
-
if (rule.name === 'apply') {
|
|
161
|
-
hasApply = true;
|
|
162
|
-
}
|
|
163
152
|
});
|
|
164
153
|
if (Object.values(layerNodes).every((n)=>n === null
|
|
165
|
-
)
|
|
154
|
+
)) {
|
|
166
155
|
return root;
|
|
167
156
|
}
|
|
168
157
|
// ---
|
|
@@ -177,6 +166,7 @@ function expandTailwindAtRules(context) {
|
|
|
177
166
|
let extractor = getExtractor(context.tailwindConfig, extension);
|
|
178
167
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
179
168
|
}
|
|
169
|
+
env.DEBUG && console.timeEnd('Reading changed files');
|
|
180
170
|
// ---
|
|
181
171
|
// Generate the actual CSS
|
|
182
172
|
let classCacheCount = context.classCache.size;
|
|
@@ -199,24 +189,9 @@ function expandTailwindAtRules(context) {
|
|
|
199
189
|
// Replace any Tailwind directives with generated CSS
|
|
200
190
|
if (layerNodes.base) {
|
|
201
191
|
layerNodes.base.before((0, _cloneNodes).default([
|
|
202
|
-
...baseNodes
|
|
192
|
+
...baseNodes,
|
|
193
|
+
...defaultNodes
|
|
203
194
|
], layerNodes.base.source));
|
|
204
|
-
}
|
|
205
|
-
// @defaults rules are unconditionally added first to ensure that
|
|
206
|
-
// using any utility that relies on defaults will work even when
|
|
207
|
-
// compiled in an isolated environment like CSS modules
|
|
208
|
-
if (context.tailwindConfig[DEFAULTS_LAYER] !== false) {
|
|
209
|
-
if (layerNodes.base) {
|
|
210
|
-
layerNodes.base.after((0, _cloneNodes).default([
|
|
211
|
-
...defaultNodes
|
|
212
|
-
], root.source));
|
|
213
|
-
} else {
|
|
214
|
-
root.prepend((0, _cloneNodes).default([
|
|
215
|
-
...defaultNodes
|
|
216
|
-
], root.source));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (layerNodes.base) {
|
|
220
195
|
layerNodes.base.remove();
|
|
221
196
|
}
|
|
222
197
|
if (layerNodes.components) {
|
|
@@ -231,15 +206,33 @@ function expandTailwindAtRules(context) {
|
|
|
231
206
|
], layerNodes.utilities.source));
|
|
232
207
|
layerNodes.utilities.remove();
|
|
233
208
|
}
|
|
209
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
210
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
211
|
+
var ref;
|
|
212
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
213
|
+
if (parentLayer === 'components') {
|
|
214
|
+
return layerNodes.components !== null;
|
|
215
|
+
}
|
|
216
|
+
if (parentLayer === 'utilities') {
|
|
217
|
+
return layerNodes.utilities !== null;
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
});
|
|
234
221
|
if (layerNodes.variants) {
|
|
235
|
-
layerNodes.variants.before((0, _cloneNodes).default(
|
|
236
|
-
...screenNodes
|
|
237
|
-
], layerNodes.variants.source));
|
|
222
|
+
layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source));
|
|
238
223
|
layerNodes.variants.remove();
|
|
239
|
-
} else {
|
|
240
|
-
root.append((0, _cloneNodes).default(
|
|
241
|
-
|
|
242
|
-
|
|
224
|
+
} else if (variantNodes.length > 0) {
|
|
225
|
+
root.append((0, _cloneNodes).default(variantNodes, root.source));
|
|
226
|
+
}
|
|
227
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
228
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
229
|
+
var ref;
|
|
230
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === 'utilities';
|
|
231
|
+
});
|
|
232
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
233
|
+
_log.default.warn('content-problems', [
|
|
234
|
+
'No utilities were generated there is likely a problem with the `content` key in the tailwind config. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
|
|
235
|
+
]);
|
|
243
236
|
}
|
|
244
237
|
// ---
|
|
245
238
|
if (env.DEBUG) {
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -217,6 +217,13 @@ function applyVariant(variant, matches, context) {
|
|
|
217
217
|
rule.selector = before;
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
+
// This tracks the originating layer for the variant
|
|
221
|
+
// For example:
|
|
222
|
+
// .sm:underline {} is a variant of something in the utilities layer
|
|
223
|
+
// .sm:container {} is a variant of the container component
|
|
224
|
+
clone.nodes[0].raws.tailwind = {
|
|
225
|
+
parentLayer: meta.layer
|
|
226
|
+
};
|
|
220
227
|
var _collectedFormats;
|
|
221
228
|
let withOffset = [
|
|
222
229
|
{
|
|
@@ -233,8 +240,7 @@ function applyVariant(variant, matches, context) {
|
|
|
233
240
|
}
|
|
234
241
|
return [];
|
|
235
242
|
}
|
|
236
|
-
function parseRules(rule, cache, options = {
|
|
237
|
-
}) {
|
|
243
|
+
function parseRules(rule, cache, options = {}) {
|
|
238
244
|
// PostCSS node
|
|
239
245
|
if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
|
|
240
246
|
return [
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = expandApplyAtRules;
|
|
6
|
+
function partitionRules(root) {
|
|
7
|
+
if (!root.walkAtRules) return;
|
|
8
|
+
let applyParents = new Set();
|
|
9
|
+
root.walkAtRules('apply', (rule)=>{
|
|
10
|
+
applyParents.add(rule.parent);
|
|
11
|
+
});
|
|
12
|
+
if (applyParents.size === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for (let rule1 of applyParents){
|
|
16
|
+
let nodeGroups = [];
|
|
17
|
+
let lastGroup = [];
|
|
18
|
+
for (let node of rule1.nodes){
|
|
19
|
+
if (node.type === 'atrule' && node.name === 'apply') {
|
|
20
|
+
if (lastGroup.length > 0) {
|
|
21
|
+
nodeGroups.push(lastGroup);
|
|
22
|
+
lastGroup = [];
|
|
23
|
+
}
|
|
24
|
+
nodeGroups.push([
|
|
25
|
+
node
|
|
26
|
+
]);
|
|
27
|
+
} else {
|
|
28
|
+
lastGroup.push(node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (lastGroup.length > 0) {
|
|
32
|
+
nodeGroups.push(lastGroup);
|
|
33
|
+
}
|
|
34
|
+
if (nodeGroups.length === 1) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (let group of [
|
|
38
|
+
...nodeGroups
|
|
39
|
+
].reverse()){
|
|
40
|
+
let clone = rule1.clone({
|
|
41
|
+
nodes: []
|
|
42
|
+
});
|
|
43
|
+
clone.append(group);
|
|
44
|
+
rule1.after(clone);
|
|
45
|
+
}
|
|
46
|
+
rule1.remove();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function expandApplyAtRules() {
|
|
50
|
+
return (root)=>{
|
|
51
|
+
partitionRules(root);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -109,11 +109,11 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
|
|
|
109
109
|
selectors.add(selector);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
if (selectorGroups.size === 0) {
|
|
113
|
-
universal.remove();
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
112
|
if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
|
|
113
|
+
if (selectorGroups.size === 0) {
|
|
114
|
+
universal.remove();
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
117
|
for (let [, selectors] of selectorGroups){
|
|
118
118
|
let universalRule = _postcss.default.rule();
|
|
119
119
|
universalRule.selectors = [
|
|
@@ -33,13 +33,11 @@ function _interopRequireWildcard(obj) {
|
|
|
33
33
|
if (obj && obj.__esModule) {
|
|
34
34
|
return obj;
|
|
35
35
|
} else {
|
|
36
|
-
var newObj = {
|
|
37
|
-
};
|
|
36
|
+
var newObj = {};
|
|
38
37
|
if (obj != null) {
|
|
39
38
|
for(var key in obj){
|
|
40
39
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
42
|
-
};
|
|
40
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
43
41
|
if (desc.get || desc.set) {
|
|
44
42
|
Object.defineProperty(newObj, key, desc);
|
|
45
43
|
} else {
|
|
@@ -76,8 +74,7 @@ function isBalanced(input) {
|
|
|
76
74
|
}
|
|
77
75
|
return count === 0;
|
|
78
76
|
}
|
|
79
|
-
function insertInto(list, value, { before =[] } = {
|
|
80
|
-
}) {
|
|
77
|
+
function insertInto(list, value, { before =[] } = {}) {
|
|
81
78
|
before = [].concat(before);
|
|
82
79
|
if (before.length <= 0) {
|
|
83
80
|
list.push(value);
|
|
@@ -112,44 +109,49 @@ function getClasses(selector) {
|
|
|
112
109
|
});
|
|
113
110
|
return parser.transformSync(selector);
|
|
114
111
|
}
|
|
115
|
-
function extractCandidates(node
|
|
112
|
+
function extractCandidates(node, state = {
|
|
113
|
+
containsNonOnDemandable: false
|
|
114
|
+
}, depth = 0) {
|
|
116
115
|
let classes = [];
|
|
116
|
+
// Handle normal rules
|
|
117
117
|
if (node.type === 'rule') {
|
|
118
118
|
for (let selector of node.selectors){
|
|
119
119
|
let classCandidates = getClasses(selector);
|
|
120
120
|
// At least one of the selectors contains non-"on-demandable" candidates.
|
|
121
|
-
if (classCandidates.length === 0)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
if (classCandidates.length === 0) {
|
|
122
|
+
state.containsNonOnDemandable = true;
|
|
123
|
+
}
|
|
124
|
+
for (let classCandidate of classCandidates){
|
|
125
|
+
classes.push(classCandidate);
|
|
126
|
+
}
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
if (node.type === 'atrule') {
|
|
128
|
+
} else if (node.type === 'atrule') {
|
|
130
129
|
node.walkRules((rule)=>{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
];
|
|
130
|
+
for (let classCandidate of rule.selectors.flatMap((selector)=>getClasses(selector, state, depth + 1)
|
|
131
|
+
)){
|
|
132
|
+
classes.push(classCandidate);
|
|
133
|
+
}
|
|
136
134
|
});
|
|
137
135
|
}
|
|
136
|
+
if (depth === 0) {
|
|
137
|
+
return [
|
|
138
|
+
state.containsNonOnDemandable || classes.length === 0,
|
|
139
|
+
classes
|
|
140
|
+
];
|
|
141
|
+
}
|
|
138
142
|
return classes;
|
|
139
143
|
}
|
|
140
144
|
function withIdentifiers(styles) {
|
|
141
145
|
return parseStyles(styles).flatMap((node)=>{
|
|
142
146
|
let nodeMap = new Map();
|
|
143
|
-
let candidates = extractCandidates(node);
|
|
144
|
-
// If this isn't "on-demandable", assign it a universal candidate.
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
[
|
|
148
|
-
'*',
|
|
149
|
-
node
|
|
150
|
-
]
|
|
151
|
-
];
|
|
147
|
+
let [containsNonOnDemandableSelectors, candidates] = extractCandidates(node);
|
|
148
|
+
// If this isn't "on-demandable", assign it a universal candidate to always include it.
|
|
149
|
+
if (containsNonOnDemandableSelectors) {
|
|
150
|
+
candidates.unshift('*');
|
|
152
151
|
}
|
|
152
|
+
// However, it could be that it also contains "on-demandable" candidates.
|
|
153
|
+
// E.g.: `span, .foo {}`, in that case it should still be possible to use
|
|
154
|
+
// `@apply foo` for example.
|
|
153
155
|
return candidates.map((c)=>{
|
|
154
156
|
if (!nodeMap.has(node)) {
|
|
155
157
|
nodeMap.set(node, node);
|
|
@@ -178,8 +180,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
178
180
|
return context.tailwindConfig.prefix + identifier;
|
|
179
181
|
}
|
|
180
182
|
return {
|
|
181
|
-
addVariant (variantName, variantFunctions, options = {
|
|
182
|
-
}) {
|
|
183
|
+
addVariant (variantName, variantFunctions, options = {}) {
|
|
183
184
|
variantFunctions = [].concat(variantFunctions).map((variantFunction)=>{
|
|
184
185
|
if (typeof variantFunction !== 'string') {
|
|
185
186
|
// Safelist public API functions
|
|
@@ -256,8 +257,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
256
257
|
},
|
|
257
258
|
addBase (base) {
|
|
258
259
|
for (let [identifier, rule] of withIdentifiers(base)){
|
|
259
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
260
|
-
});
|
|
260
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
261
261
|
let offset = offsets.base++;
|
|
262
262
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
263
263
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
@@ -279,15 +279,13 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
279
279
|
[`@defaults ${group}`]: declarations
|
|
280
280
|
};
|
|
281
281
|
for (let [identifier, rule] of withIdentifiers(groups)){
|
|
282
|
-
let prefixedIdentifier = prefixIdentifier(identifier, {
|
|
283
|
-
});
|
|
284
|
-
let offset = offsets.base++;
|
|
282
|
+
let prefixedIdentifier = prefixIdentifier(identifier, {});
|
|
285
283
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
286
284
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
287
285
|
}
|
|
288
286
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
289
287
|
{
|
|
290
|
-
sort:
|
|
288
|
+
sort: offsets.base++,
|
|
291
289
|
layer: 'defaults'
|
|
292
290
|
},
|
|
293
291
|
rule
|
|
@@ -299,19 +297,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
299
297
|
respectPrefix: true,
|
|
300
298
|
respectImportant: false
|
|
301
299
|
};
|
|
302
|
-
options = Object.assign({
|
|
303
|
-
}, defaultOptions, Array.isArray(options) ? {
|
|
304
|
-
} : options);
|
|
300
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
305
301
|
for (let [identifier, rule] of withIdentifiers(components)){
|
|
306
302
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
307
|
-
let offset = offsets.components++;
|
|
308
303
|
classList.add(prefixedIdentifier);
|
|
309
304
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
310
305
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
311
306
|
}
|
|
312
307
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
313
308
|
{
|
|
314
|
-
sort:
|
|
309
|
+
sort: offsets.components++,
|
|
315
310
|
layer: 'components',
|
|
316
311
|
options
|
|
317
312
|
},
|
|
@@ -324,19 +319,16 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
324
319
|
respectPrefix: true,
|
|
325
320
|
respectImportant: true
|
|
326
321
|
};
|
|
327
|
-
options = Object.assign({
|
|
328
|
-
}, defaultOptions, Array.isArray(options) ? {
|
|
329
|
-
} : options);
|
|
322
|
+
options = Object.assign({}, defaultOptions, Array.isArray(options) ? {} : options);
|
|
330
323
|
for (let [identifier, rule] of withIdentifiers(utilities)){
|
|
331
324
|
let prefixedIdentifier = prefixIdentifier(identifier, options);
|
|
332
|
-
let offset = offsets.utilities++;
|
|
333
325
|
classList.add(prefixedIdentifier);
|
|
334
326
|
if (!context.candidateRuleMap.has(prefixedIdentifier)) {
|
|
335
327
|
context.candidateRuleMap.set(prefixedIdentifier, []);
|
|
336
328
|
}
|
|
337
329
|
context.candidateRuleMap.get(prefixedIdentifier).push([
|
|
338
330
|
{
|
|
339
|
-
sort:
|
|
331
|
+
sort: offsets.utilities++,
|
|
340
332
|
layer: 'utilities',
|
|
341
333
|
options
|
|
342
334
|
},
|
|
@@ -463,11 +455,17 @@ function getFileModifiedMap(context) {
|
|
|
463
455
|
function trackModified(files, fileModifiedMap) {
|
|
464
456
|
let changed = false;
|
|
465
457
|
for (let file of files){
|
|
458
|
+
var ref;
|
|
466
459
|
if (!file) continue;
|
|
467
460
|
let parsed = _url.default.parse(file);
|
|
468
461
|
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href;
|
|
469
462
|
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname;
|
|
470
|
-
let newModified = _fs.default.statSync(decodeURIComponent(pathname)
|
|
463
|
+
let newModified = (ref = _fs.default.statSync(decodeURIComponent(pathname), {
|
|
464
|
+
throwIfNoEntry: false
|
|
465
|
+
})) === null || ref === void 0 ? void 0 : ref.mtimeMs;
|
|
466
|
+
if (!newModified) {
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
471
469
|
if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
|
|
472
470
|
changed = true;
|
|
473
471
|
}
|
|
@@ -678,8 +676,7 @@ function registerPlugins(plugins, context) {
|
|
|
678
676
|
let utils = Array.isArray(util) ? (()=>{
|
|
679
677
|
let [utilName, options] = util;
|
|
680
678
|
var ref;
|
|
681
|
-
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
682
|
-
}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
679
|
+
let classes = Object.keys((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {}).map((value)=>(0, _nameClass).formatClass(utilName, value)
|
|
683
680
|
);
|
|
684
681
|
if (options === null || options === void 0 ? void 0 : options.supportsNegativeValues) {
|
|
685
682
|
classes = [
|
|
@@ -733,8 +730,7 @@ function registerPlugins(plugins, context) {
|
|
|
733
730
|
let [utilName, options] = util;
|
|
734
731
|
let negativeClasses = [];
|
|
735
732
|
var ref;
|
|
736
|
-
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {
|
|
737
|
-
})){
|
|
733
|
+
for (let [key, value] of Object.entries((ref = options === null || options === void 0 ? void 0 : options.values) !== null && ref !== void 0 ? ref : {})){
|
|
738
734
|
output.push((0, _nameClass).formatClass(utilName, key));
|
|
739
735
|
if ((options === null || options === void 0 ? void 0 : options.supportsNegativeValues) && (0, _negateValue).default(value)) {
|
|
740
736
|
negativeClasses.push((0, _nameClass).formatClass(utilName, `-${key}`));
|
|
@@ -11,6 +11,7 @@ var _substituteScreenAtRules = _interopRequireDefault(require("./lib/substituteS
|
|
|
11
11
|
var _resolveDefaultsAtRules = _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
12
12
|
var _collapseAdjacentRules = _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
13
13
|
var _collapseDuplicateDeclarations = _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
14
|
+
var _partitionApplyAtRules = _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
14
15
|
var _detectNesting = _interopRequireDefault(require("./lib/detectNesting"));
|
|
15
16
|
var _setupContextUtils = require("./lib/setupContextUtils");
|
|
16
17
|
var _featureFlags = require("./featureFlags");
|
|
@@ -22,6 +23,8 @@ function _interopRequireDefault(obj) {
|
|
|
22
23
|
function processTailwindFeatures(setupContext) {
|
|
23
24
|
return function(root, result) {
|
|
24
25
|
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives).default(root);
|
|
26
|
+
(0, _detectNesting).default()(root, result);
|
|
27
|
+
(0, _partitionApplyAtRules).default()(root, result);
|
|
25
28
|
let context = setupContext({
|
|
26
29
|
tailwindDirectives,
|
|
27
30
|
applyDirectives,
|
|
@@ -40,7 +43,6 @@ function processTailwindFeatures(setupContext) {
|
|
|
40
43
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
41
44
|
}
|
|
42
45
|
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
43
|
-
(0, _detectNesting).default(context)(root, result);
|
|
44
46
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
45
47
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
46
48
|
(0, _evaluateTailwindFunctions).default(context)(root, result);
|
package/lib/util/createPlugin.js
CHANGED
|
@@ -9,8 +9,7 @@ function createPlugin(plugin, config) {
|
|
|
9
9
|
config
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({
|
|
13
|
-
})
|
|
12
|
+
createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
|
|
14
13
|
) {
|
|
15
14
|
const optionsFunction = function(options) {
|
|
16
15
|
return {
|
|
@@ -16,8 +16,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
16
16
|
themeKey
|
|
17
17
|
]
|
|
18
18
|
]
|
|
19
|
-
], { filterDefault =false , ...options } = {
|
|
20
|
-
}) {
|
|
19
|
+
], { filterDefault =false , ...options } = {}) {
|
|
21
20
|
let transformValue = (0, _transformThemeValue).default(themeKey);
|
|
22
21
|
return function({ matchUtilities , theme }) {
|
|
23
22
|
for (let utilityVariation of utilityVariations){
|
|
@@ -37,15 +36,12 @@ function createUtilityPlugin(themeKey, utilityVariations = [
|
|
|
37
36
|
return Object.assign(obj, {
|
|
38
37
|
[name]: transformValue(value)
|
|
39
38
|
});
|
|
40
|
-
}, {
|
|
41
|
-
});
|
|
39
|
+
}, {});
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
|
-
}, {
|
|
45
|
-
}), {
|
|
42
|
+
}, {}), {
|
|
46
43
|
...options,
|
|
47
|
-
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
|
|
48
|
-
}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
44
|
+
values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== 'DEFAULT'
|
|
49
45
|
)) : theme(themeKey)
|
|
50
46
|
});
|
|
51
47
|
}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = void 0;
|
|
6
|
-
const flattenColorPalette = (colors)=>Object.assign({
|
|
7
|
-
}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {
|
|
8
|
-
}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
6
|
+
const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
|
|
9
7
|
[color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
|
|
10
8
|
})
|
|
11
9
|
) : [
|
|
@@ -8,13 +8,11 @@ function _interopRequireWildcard(obj) {
|
|
|
8
8
|
if (obj && obj.__esModule) {
|
|
9
9
|
return obj;
|
|
10
10
|
} else {
|
|
11
|
-
var newObj = {
|
|
12
|
-
};
|
|
11
|
+
var newObj = {};
|
|
13
12
|
if (obj != null) {
|
|
14
13
|
for(var key in obj){
|
|
15
14
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
16
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
17
|
-
};
|
|
15
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
18
16
|
if (desc.get || desc.set) {
|
|
19
17
|
Object.defineProperty(newObj, key, desc);
|
|
20
18
|
} else {
|
|
@@ -169,11 +167,9 @@ function normalizeConfig(config) {
|
|
|
169
167
|
if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.extract) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.extract.DEFAULT;
|
|
170
168
|
if ((ref6 = config.purge) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.options) === null || ref7 === void 0 ? void 0 : ref7.extractors) return config.purge.options.extractors;
|
|
171
169
|
if ((ref8 = config.content) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.options) === null || ref9 === void 0 ? void 0 : ref9.extractors) return config.content.options.extractors;
|
|
172
|
-
return {
|
|
173
|
-
};
|
|
170
|
+
return {};
|
|
174
171
|
})();
|
|
175
|
-
let extractors = {
|
|
176
|
-
};
|
|
172
|
+
let extractors = {};
|
|
177
173
|
let defaultExtractor = (()=>{
|
|
178
174
|
var ref, ref10, ref11, ref12;
|
|
179
175
|
if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
|
|
@@ -208,11 +204,9 @@ function normalizeConfig(config) {
|
|
|
208
204
|
if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
|
|
209
205
|
if ((ref14 = config.purge) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.transform) === null || ref15 === void 0 ? void 0 : ref15.DEFAULT) return config.purge.transform.DEFAULT;
|
|
210
206
|
if ((ref16 = config.content) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.transform) === null || ref17 === void 0 ? void 0 : ref17.DEFAULT) return config.content.transform.DEFAULT;
|
|
211
|
-
return {
|
|
212
|
-
};
|
|
207
|
+
return {};
|
|
213
208
|
})();
|
|
214
|
-
let transformers = {
|
|
215
|
-
};
|
|
209
|
+
let transformers = {};
|
|
216
210
|
if (typeof transform === 'function') {
|
|
217
211
|
transformers.DEFAULT = transform;
|
|
218
212
|
}
|
|
@@ -233,5 +227,10 @@ function normalizeConfig(config) {
|
|
|
233
227
|
break;
|
|
234
228
|
}
|
|
235
229
|
}
|
|
230
|
+
if (config.content.files.length === 0) {
|
|
231
|
+
_log.default.warn('content-problems', [
|
|
232
|
+
'The `content` key is missing or empty. Please populate the content key as Tailwind generates utilities on-demand based on the files that use them. For more information see the documentation: https://tailwindcss.com/docs/content-configuration',
|
|
233
|
+
]);
|
|
234
|
+
}
|
|
236
235
|
return config;
|
|
237
236
|
}
|