tailwindcss 3.0.9 → 3.0.13
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 +57 -28
- 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 +14 -29
- package/lib/lib/generateRules.js +1 -2
- package/lib/lib/normalizeTailwindDirectives.js +8 -1
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +4 -4
- package/lib/lib/setupContextUtils.js +48 -52
- package/lib/lib/setupTrackingContext.js +11 -10
- package/lib/processTailwindFeatures.js +5 -2
- 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 +6 -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/package.json +8 -10
- package/peers/index.js +652 -651
- package/src/cli.js +57 -12
- 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 +12 -21
- package/src/lib/normalizeTailwindDirectives.js +6 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/resolveDefaultsAtRules.js +5 -5
- package/src/lib/setupContextUtils.js +37 -17
- package/src/lib/setupTrackingContext.js +11 -10
- package/src/processTailwindFeatures.js +6 -2
- 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,7 +3,6 @@ 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");
|
|
@@ -19,13 +18,11 @@ function _interopRequireWildcard(obj) {
|
|
|
19
18
|
if (obj && obj.__esModule) {
|
|
20
19
|
return obj;
|
|
21
20
|
} else {
|
|
22
|
-
var newObj = {
|
|
23
|
-
};
|
|
21
|
+
var newObj = {};
|
|
24
22
|
if (obj != null) {
|
|
25
23
|
for(var key in obj){
|
|
26
24
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
28
|
-
};
|
|
25
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
29
26
|
if (desc.get || desc.set) {
|
|
30
27
|
Object.defineProperty(newObj, key, desc);
|
|
31
28
|
} else {
|
|
@@ -133,8 +130,6 @@ function buildStylesheet(rules, context) {
|
|
|
133
130
|
}
|
|
134
131
|
return returnValue;
|
|
135
132
|
}
|
|
136
|
-
const DEFAULTS_LAYER = Symbol('defaults-layer');
|
|
137
|
-
exports.DEFAULTS_LAYER = DEFAULTS_LAYER;
|
|
138
133
|
function expandTailwindAtRules(context) {
|
|
139
134
|
return (root)=>{
|
|
140
135
|
let layerNodes = {
|
|
@@ -143,13 +138,15 @@ function expandTailwindAtRules(context) {
|
|
|
143
138
|
utilities: null,
|
|
144
139
|
variants: null
|
|
145
140
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
layerNodes
|
|
141
|
+
root.walkAtRules((rule)=>{
|
|
142
|
+
// Make sure this file contains Tailwind directives. If not, we can save
|
|
143
|
+
// a lot of work and bail early. Also we don't have to register our touch
|
|
144
|
+
// file as a dependency since the output of this CSS does not depend on
|
|
145
|
+
// the source of any templates. Think Vue <style> blocks for example.
|
|
146
|
+
if (rule.name === 'tailwind') {
|
|
147
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
148
|
+
layerNodes[rule.params] = rule;
|
|
149
|
+
}
|
|
153
150
|
}
|
|
154
151
|
});
|
|
155
152
|
if (Object.values(layerNodes).every((n)=>n === null
|
|
@@ -168,6 +165,7 @@ function expandTailwindAtRules(context) {
|
|
|
168
165
|
let extractor = getExtractor(context.tailwindConfig, extension);
|
|
169
166
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
170
167
|
}
|
|
168
|
+
env.DEBUG && console.timeEnd('Reading changed files');
|
|
171
169
|
// ---
|
|
172
170
|
// Generate the actual CSS
|
|
173
171
|
let classCacheCount = context.classCache.size;
|
|
@@ -190,23 +188,10 @@ function expandTailwindAtRules(context) {
|
|
|
190
188
|
// Replace any Tailwind directives with generated CSS
|
|
191
189
|
if (layerNodes.base) {
|
|
192
190
|
layerNodes.base.before((0, _cloneNodes).default([
|
|
193
|
-
...baseNodes
|
|
191
|
+
...baseNodes,
|
|
192
|
+
...defaultNodes
|
|
194
193
|
], layerNodes.base.source));
|
|
195
194
|
}
|
|
196
|
-
// @defaults rules are unconditionally added first to ensure that
|
|
197
|
-
// using any utility that relies on defaults will work even when
|
|
198
|
-
// compiled in an isolated environment like CSS modules
|
|
199
|
-
if (context.tailwindConfig[DEFAULTS_LAYER] !== false) {
|
|
200
|
-
if (layerNodes.base) {
|
|
201
|
-
layerNodes.base.after((0, _cloneNodes).default([
|
|
202
|
-
...defaultNodes
|
|
203
|
-
], root.source));
|
|
204
|
-
} else {
|
|
205
|
-
root.prepend((0, _cloneNodes).default([
|
|
206
|
-
...defaultNodes
|
|
207
|
-
], root.source));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
195
|
if (layerNodes.base) {
|
|
211
196
|
layerNodes.base.remove();
|
|
212
197
|
}
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -233,8 +233,7 @@ function applyVariant(variant, matches, context) {
|
|
|
233
233
|
}
|
|
234
234
|
return [];
|
|
235
235
|
}
|
|
236
|
-
function parseRules(rule, cache, options = {
|
|
237
|
-
}) {
|
|
236
|
+
function parseRules(rule, cache, options = {}) {
|
|
238
237
|
// PostCSS node
|
|
239
238
|
if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
|
|
240
239
|
return [
|
|
@@ -12,7 +12,11 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
function normalizeTailwindDirectives(root) {
|
|
13
13
|
let tailwindDirectives = new Set();
|
|
14
14
|
let layerDirectives = new Set();
|
|
15
|
+
let applyDirectives = new Set();
|
|
15
16
|
root.walkAtRules((atRule)=>{
|
|
17
|
+
if (atRule.name === 'apply') {
|
|
18
|
+
applyDirectives.add(atRule);
|
|
19
|
+
}
|
|
16
20
|
if (atRule.name === 'import') {
|
|
17
21
|
if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
|
|
18
22
|
atRule.name = 'tailwind';
|
|
@@ -72,5 +76,8 @@ function normalizeTailwindDirectives(root) {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
tailwindDirectives,
|
|
81
|
+
applyDirectives
|
|
82
|
+
};
|
|
76
83
|
}
|
|
@@ -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}`));
|
|
@@ -119,16 +119,17 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
119
119
|
return changedFiles;
|
|
120
120
|
}
|
|
121
121
|
function setupTrackingContext(configOrPath) {
|
|
122
|
-
return ({ tailwindDirectives , registerDependency })=>{
|
|
122
|
+
return ({ tailwindDirectives , registerDependency , applyDirectives })=>{
|
|
123
123
|
return (root, result)=>{
|
|
124
124
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
125
125
|
let contextDependencies = new Set(configDependencies);
|
|
126
|
-
// If there are no @tailwind rules, we don't consider this CSS
|
|
127
|
-
// to be dependencies of the context. Can reuse
|
|
128
|
-
// We may want to think about `@layer`
|
|
129
|
-
//
|
|
130
|
-
// in
|
|
131
|
-
|
|
126
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
127
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
128
|
+
// the context even if they change. We may want to think about `@layer`
|
|
129
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
130
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
131
|
+
// another file since independent sources are effectively isolated.
|
|
132
|
+
if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
|
|
132
133
|
// Add current css file as a context dependencies.
|
|
133
134
|
contextDependencies.add(result.opts.from);
|
|
134
135
|
// Add all css @import dependencies as context dependencies.
|
|
@@ -140,12 +141,12 @@ function setupTrackingContext(configOrPath) {
|
|
|
140
141
|
}
|
|
141
142
|
let [context] = (0, _setupContextUtils).getContext(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
142
143
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
143
|
-
// If there are no @tailwind rules, we don't consider this CSS file or it's
|
|
144
|
-
// to be dependencies of the context. Can reuse the context even if they change.
|
|
144
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
145
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
145
146
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
146
147
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
147
148
|
// in another file since independent sources are effectively isolated.
|
|
148
|
-
if (tailwindDirectives.size > 0) {
|
|
149
|
+
if (tailwindDirectives.size > 0 || applyDirectives.size > 0) {
|
|
149
150
|
let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
|
|
150
151
|
// Add template paths as postcss dependencies.
|
|
151
152
|
for (let fileOrGlob of candidateFiles){
|
|
@@ -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");
|
|
@@ -21,9 +22,12 @@ function _interopRequireDefault(obj) {
|
|
|
21
22
|
}
|
|
22
23
|
function processTailwindFeatures(setupContext) {
|
|
23
24
|
return function(root, result) {
|
|
24
|
-
let tailwindDirectives = (0, _normalizeTailwindDirectives).default(root);
|
|
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,
|
|
30
|
+
applyDirectives,
|
|
27
31
|
registerDependency (dependency) {
|
|
28
32
|
result.messages.push({
|
|
29
33
|
plugin: 'tailwindcss',
|
|
@@ -39,7 +43,6 @@ function processTailwindFeatures(setupContext) {
|
|
|
39
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.");
|
|
40
44
|
}
|
|
41
45
|
(0, _featureFlags).issueFlagNotices(context.tailwindConfig);
|
|
42
|
-
(0, _detectNesting).default(context)(root, result);
|
|
43
46
|
(0, _expandTailwindAtRules).default(context)(root, result);
|
|
44
47
|
(0, _expandApplyAtRules).default(context)(root, result);
|
|
45
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
|
) : [
|