tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.d07553b
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 +110 -1
- package/colors.js +2 -1
- package/defaultConfig.js +2 -1
- package/defaultTheme.js +2 -1
- package/lib/cli.js +47 -48
- package/lib/constants.js +1 -1
- package/lib/corePluginList.js +10 -1
- package/lib/corePlugins.js +425 -285
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +14 -9
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +9 -5
- package/lib/lib/expandApplyAtRules.js +26 -9
- package/lib/lib/expandTailwindAtRules.js +16 -26
- package/lib/lib/generateRules.js +206 -27
- package/lib/lib/normalizeTailwindDirectives.js +3 -2
- package/lib/lib/resolveDefaultsAtRules.js +67 -56
- package/lib/lib/setupContextUtils.js +198 -186
- package/lib/lib/setupTrackingContext.js +3 -3
- package/lib/lib/setupWatchingContext.js +8 -4
- package/lib/lib/sharedState.js +2 -12
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/processTailwindFeatures.js +4 -0
- package/lib/public/colors.js +4 -8
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/createUtilityPlugin.js +5 -5
- package/lib/util/dataTypes.js +38 -7
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +30 -18
- package/lib/util/nameClass.js +2 -1
- package/lib/util/negateValue.js +3 -1
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +61 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +62 -158
- package/lib/util/prefixSelector.js +1 -3
- package/lib/util/resolveConfig.js +22 -81
- package/lib/util/transformThemeValue.js +23 -13
- package/package.json +15 -15
- package/peers/index.js +4495 -5499
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +19 -13
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +413 -422
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +16 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandApplyAtRules.js +29 -2
- package/src/lib/expandTailwindAtRules.js +17 -29
- package/src/lib/generateRules.js +228 -19
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +67 -50
- package/src/lib/setupContextUtils.js +189 -163
- package/src/lib/setupTrackingContext.js +3 -5
- package/src/lib/setupWatchingContext.js +10 -5
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +5 -0
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +43 -11
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +2 -2
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +50 -146
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +11 -64
- package/src/util/transformThemeValue.js +22 -7
- package/stubs/defaultConfig.stub.js +151 -91
- package/stubs/simpleConfig.stub.js +0 -1
package/lib/css/preflight.css
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
border-color: currentColor; /* 2 */
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
::before,
|
|
16
|
+
::after {
|
|
17
|
+
--tw-content: '';
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
/*
|
|
16
21
|
1. Use a consistent sensible line-height in all browsers.
|
|
17
22
|
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
@@ -283,7 +288,8 @@ legend {
|
|
|
283
288
|
}
|
|
284
289
|
|
|
285
290
|
ol,
|
|
286
|
-
ul
|
|
291
|
+
ul,
|
|
292
|
+
menu {
|
|
287
293
|
list-style: none;
|
|
288
294
|
margin: 0;
|
|
289
295
|
padding: 0;
|
|
@@ -317,6 +323,13 @@ button,
|
|
|
317
323
|
cursor: pointer;
|
|
318
324
|
}
|
|
319
325
|
|
|
326
|
+
/*
|
|
327
|
+
Make sure disabled buttons don't get the pointer cursor.
|
|
328
|
+
*/
|
|
329
|
+
:disabled {
|
|
330
|
+
cursor: default;
|
|
331
|
+
}
|
|
332
|
+
|
|
320
333
|
/*
|
|
321
334
|
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
322
335
|
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
package/lib/featureFlags.js
CHANGED
|
@@ -12,7 +12,12 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
default: obj
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
let defaults = {
|
|
16
|
+
// TODO: Drop this once we can safely rely on optimizeUniversalDefaults being
|
|
17
|
+
// the default.
|
|
18
|
+
optimizeUniversalDefaults: process.env.NODE_ENV === 'test' ? true : false
|
|
19
|
+
};
|
|
20
|
+
let featureFlags = {
|
|
16
21
|
future: [],
|
|
17
22
|
experimental: [
|
|
18
23
|
'optimizeUniversalDefaults'
|
|
@@ -21,13 +26,13 @@ const featureFlags = {
|
|
|
21
26
|
function flagEnabled(config, flag) {
|
|
22
27
|
if (featureFlags.future.includes(flag)) {
|
|
23
28
|
var ref;
|
|
24
|
-
var ref1;
|
|
25
|
-
return config.future === 'all' || ((ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : false);
|
|
29
|
+
var ref1, ref2;
|
|
30
|
+
return config.future === 'all' || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
|
|
26
31
|
}
|
|
27
32
|
if (featureFlags.experimental.includes(flag)) {
|
|
28
|
-
var
|
|
29
|
-
var ref5;
|
|
30
|
-
return config.experimental === 'all' || ((ref5 = config === null || config === void 0 ? void 0 : (
|
|
33
|
+
var ref3;
|
|
34
|
+
var ref4, ref5;
|
|
35
|
+
return config.experimental === 'all' || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
|
|
31
36
|
}
|
|
32
37
|
return false;
|
|
33
38
|
}
|
|
@@ -45,11 +50,11 @@ function issueFlagNotices(config) {
|
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
47
52
|
if (experimentalFlagsEnabled(config).length > 0) {
|
|
48
|
-
|
|
53
|
+
let changes = experimentalFlagsEnabled(config).map((s)=>_chalk.default.yellow(s)
|
|
49
54
|
).join(', ');
|
|
50
|
-
_log.default.warn([
|
|
55
|
+
_log.default.warn('experimental-flags-enabled', [
|
|
51
56
|
`You have enabled experimental features: ${changes}`,
|
|
52
|
-
'Experimental features are not covered by semver, may introduce breaking changes, and can change at any time.',
|
|
57
|
+
'Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.',
|
|
53
58
|
]);
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = collapseDuplicateDeclarations;
|
|
6
|
+
function collapseDuplicateDeclarations() {
|
|
7
|
+
return (root)=>{
|
|
8
|
+
root.walkRules((node)=>{
|
|
9
|
+
let seen = new Map();
|
|
10
|
+
let droppable = new Set([]);
|
|
11
|
+
node.walkDecls((decl)=>{
|
|
12
|
+
// This could happen if we have nested selectors. In that case the
|
|
13
|
+
// parent will loop over all its declarations but also the declarations
|
|
14
|
+
// of nested rules. With this we ensure that we are shallowly checking
|
|
15
|
+
// declarations.
|
|
16
|
+
if (decl.parent !== node) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (seen.has(decl.prop)) {
|
|
20
|
+
droppable.add(seen.get(decl.prop));
|
|
21
|
+
}
|
|
22
|
+
seen.set(decl.prop, decl);
|
|
23
|
+
});
|
|
24
|
+
for (let decl1 of droppable){
|
|
25
|
+
decl1.remove();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
package/lib/lib/detectNesting.js
CHANGED
|
@@ -6,12 +6,27 @@ exports.default = _default;
|
|
|
6
6
|
function _default(_context) {
|
|
7
7
|
return (root, result)=>{
|
|
8
8
|
let found = false;
|
|
9
|
+
root.walkAtRules('tailwind', (node)=>{
|
|
10
|
+
if (found) return false;
|
|
11
|
+
if (node.parent && node.parent.type !== 'root') {
|
|
12
|
+
found = true;
|
|
13
|
+
node.warn(result, [
|
|
14
|
+
'Nested @tailwind rules were detected, but are not supported.',
|
|
15
|
+
"Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
|
|
16
|
+
'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
|
|
17
|
+
].join('\n'));
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
9
21
|
root.walkRules((rule)=>{
|
|
10
22
|
if (found) return false;
|
|
11
23
|
rule.walkRules((nestedRule)=>{
|
|
12
24
|
found = true;
|
|
13
|
-
nestedRule.warn(result,
|
|
14
|
-
|
|
25
|
+
nestedRule.warn(result, [
|
|
26
|
+
'Nested CSS was detected, but CSS nesting has not been configured correctly.',
|
|
27
|
+
'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
|
|
28
|
+
'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
|
|
29
|
+
].join('\n'));
|
|
15
30
|
return false;
|
|
16
31
|
});
|
|
17
32
|
});
|
|
@@ -7,6 +7,7 @@ var _dlv = _interopRequireDefault(require("dlv"));
|
|
|
7
7
|
var _didyoumean = _interopRequireDefault(require("didyoumean"));
|
|
8
8
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
9
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
10
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
10
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
11
12
|
var _toPath = require("../util/toPath");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
@@ -112,11 +113,11 @@ function extractArgs(node, vNodes, functions) {
|
|
|
112
113
|
let args = [
|
|
113
114
|
''
|
|
114
115
|
];
|
|
115
|
-
for (let
|
|
116
|
-
if (
|
|
116
|
+
for (let vNode1 of vNodes){
|
|
117
|
+
if (vNode1.type === 'div' && vNode1.value === ',') {
|
|
117
118
|
args.push('');
|
|
118
119
|
} else {
|
|
119
|
-
args[args.length - 1] += _postcssValueParser.default.stringify(
|
|
120
|
+
args[args.length - 1] += _postcssValueParser.default.stringify(vNode1);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
return args;
|
|
@@ -149,10 +150,13 @@ function _default({ tailwindConfig: config }) {
|
|
|
149
150
|
},
|
|
150
151
|
screen: (node, screen)=>{
|
|
151
152
|
screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
|
|
152
|
-
|
|
153
|
+
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
+
);
|
|
156
|
+
if (!screenDefinition) {
|
|
153
157
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
154
158
|
}
|
|
155
|
-
return (0, _buildMediaQuery).default(
|
|
159
|
+
return (0, _buildMediaQuery).default(screenDefinition);
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
return (root)=>{
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandApplyAtRules;
|
|
6
6
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
7
|
+
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
7
8
|
var _generateRules = require("./generateRules");
|
|
8
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
9
10
|
var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
|
|
@@ -12,9 +13,21 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
default: obj
|
|
13
14
|
};
|
|
14
15
|
}
|
|
16
|
+
function containsBase(selector, classCandidateBase, separator) {
|
|
17
|
+
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
18
|
+
let contains = false;
|
|
19
|
+
selectors.walkClasses((classSelector)=>{
|
|
20
|
+
if (classSelector.value.split(separator).pop() === classCandidateBase) {
|
|
21
|
+
contains = true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return contains;
|
|
26
|
+
}).transformSync(selector);
|
|
27
|
+
}
|
|
15
28
|
function prefix(context, selector) {
|
|
16
|
-
let
|
|
17
|
-
return typeof
|
|
29
|
+
let prefix1 = context.tailwindConfig.prefix;
|
|
30
|
+
return typeof prefix1 === 'function' ? prefix1(selector) : prefix1 + selector;
|
|
18
31
|
}
|
|
19
32
|
function buildApplyCache(applyCandidates, context) {
|
|
20
33
|
for (let candidate of applyCandidates){
|
|
@@ -56,10 +69,10 @@ function partitionApplyParents(root) {
|
|
|
56
69
|
root.walkAtRules('apply', (rule)=>{
|
|
57
70
|
applyParents.add(rule.parent);
|
|
58
71
|
});
|
|
59
|
-
for (let
|
|
72
|
+
for (let rule1 of applyParents){
|
|
60
73
|
let nodeGroups = [];
|
|
61
74
|
let lastGroup = [];
|
|
62
|
-
for (let node of
|
|
75
|
+
for (let node of rule1.nodes){
|
|
63
76
|
if (node.type === 'atrule' && node.name === 'apply') {
|
|
64
77
|
if (lastGroup.length > 0) {
|
|
65
78
|
nodeGroups.push(lastGroup);
|
|
@@ -81,13 +94,13 @@ function partitionApplyParents(root) {
|
|
|
81
94
|
for (let group of [
|
|
82
95
|
...nodeGroups
|
|
83
96
|
].reverse()){
|
|
84
|
-
let newParent =
|
|
97
|
+
let newParent = rule1.clone({
|
|
85
98
|
nodes: []
|
|
86
99
|
});
|
|
87
100
|
newParent.append(group);
|
|
88
|
-
|
|
101
|
+
rule1.after(newParent);
|
|
89
102
|
}
|
|
90
|
-
|
|
103
|
+
rule1.remove();
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
function processApply(root, context) {
|
|
@@ -127,8 +140,8 @@ function processApply(root, context) {
|
|
|
127
140
|
*/ // TODO: Should we use postcss-selector-parser for this instead?
|
|
128
141
|
function replaceSelector(selector, utilitySelectors, candidate) {
|
|
129
142
|
let needle = `.${(0, _escapeClassName).default(candidate)}`;
|
|
130
|
-
let utilitySelectorsList = utilitySelectors.split(/\s
|
|
131
|
-
return selector.split(/\s
|
|
143
|
+
let utilitySelectorsList = utilitySelectors.split(/\s*\,(?![^(]*\))\s*/g);
|
|
144
|
+
return selector.split(/\s*\,(?![^(]*\))\s*/g).map((s)=>{
|
|
132
145
|
let replaced = [];
|
|
133
146
|
for (let utilitySelector of utilitySelectorsList){
|
|
134
147
|
let replacedSelector = utilitySelector.replace(needle, s);
|
|
@@ -173,7 +186,11 @@ function processApply(root, context) {
|
|
|
173
186
|
for (const [parent, candidates] of perParentApplies){
|
|
174
187
|
let siblings = [];
|
|
175
188
|
for (let [applyCandidate, important, rules] of candidates){
|
|
189
|
+
let base = applyCandidate.split(context.tailwindConfig.separator).pop();
|
|
176
190
|
for (let [meta, node] of rules){
|
|
191
|
+
if (containsBase(parent.selector, base, context.tailwindConfig.separator) && containsBase(node.selector, base, context.tailwindConfig.separator)) {
|
|
192
|
+
throw node.error(`Circular dependency detected when using: \`@apply ${applyCandidate}\``);
|
|
193
|
+
}
|
|
177
194
|
let root = _postcss.default.root({
|
|
178
195
|
nodes: [
|
|
179
196
|
node.clone()
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = expandTailwindAtRules;
|
|
6
|
+
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
6
7
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
7
8
|
var _generateRules = require("./generateRules");
|
|
8
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
@@ -36,14 +37,17 @@ function _interopRequireWildcard(obj) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
let env = sharedState.env;
|
|
39
|
-
let contentMatchCache = sharedState.contentMatchCache;
|
|
40
40
|
const PATTERNS = [
|
|
41
41
|
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
42
42
|
/([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
|
|
43
43
|
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
44
44
|
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
45
|
+
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
46
|
+
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
45
47
|
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
46
48
|
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
49
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
50
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
47
51
|
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
48
52
|
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
49
53
|
].join('|');
|
|
@@ -66,43 +70,30 @@ const builtInTransformers = {
|
|
|
66
70
|
};
|
|
67
71
|
function getExtractor(tailwindConfig, fileExtension) {
|
|
68
72
|
let extractors = tailwindConfig.content.extract;
|
|
69
|
-
let contentOptions = tailwindConfig.content.options;
|
|
70
|
-
if (typeof extractors === 'function') {
|
|
71
|
-
extractors = {
|
|
72
|
-
DEFAULT: extractors
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (contentOptions.defaultExtractor) {
|
|
76
|
-
extractors.DEFAULT = contentOptions.defaultExtractor;
|
|
77
|
-
}
|
|
78
|
-
for (let { extensions , extractor } of contentOptions.extractors || []){
|
|
79
|
-
for (let extension of extensions){
|
|
80
|
-
extractors[extension] = extractor;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
73
|
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
84
74
|
}
|
|
85
75
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
86
76
|
let transformers = tailwindConfig.content.transform;
|
|
87
|
-
if (typeof transformers === 'function') {
|
|
88
|
-
transformers = {
|
|
89
|
-
DEFAULT: transformers
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
77
|
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
93
78
|
}
|
|
79
|
+
let extractorCache = new WeakMap();
|
|
94
80
|
// Scans template contents for possible classes. This is a hot path on initial build but
|
|
95
81
|
// not too important for subsequent builds. The faster the better though — if we can speed
|
|
96
82
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
97
|
-
function getClassCandidates(content, extractor,
|
|
83
|
+
function getClassCandidates(content, extractor, candidates, seen) {
|
|
84
|
+
if (!extractorCache.has(extractor)) {
|
|
85
|
+
extractorCache.set(extractor, new _quickLru.default({
|
|
86
|
+
maxSize: 25000
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
98
89
|
for (let line of content.split('\n')){
|
|
99
90
|
line = line.trim();
|
|
100
91
|
if (seen.has(line)) {
|
|
101
92
|
continue;
|
|
102
93
|
}
|
|
103
94
|
seen.add(line);
|
|
104
|
-
if (
|
|
105
|
-
for (let match of
|
|
95
|
+
if (extractorCache.get(extractor).has(line)) {
|
|
96
|
+
for (let match of extractorCache.get(extractor).get(line)){
|
|
106
97
|
candidates.add(match);
|
|
107
98
|
}
|
|
108
99
|
} else {
|
|
@@ -112,7 +103,7 @@ function getClassCandidates(content, extractor, contentMatchCache, candidates, s
|
|
|
112
103
|
for (let match of lineMatchesSet){
|
|
113
104
|
candidates.add(match);
|
|
114
105
|
}
|
|
115
|
-
|
|
106
|
+
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
116
107
|
}
|
|
117
108
|
}
|
|
118
109
|
}
|
|
@@ -189,7 +180,7 @@ function expandTailwindAtRules(context) {
|
|
|
189
180
|
for (let { content , extension } of context.changedContent){
|
|
190
181
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
191
182
|
let extractor = getExtractor(context.tailwindConfig, extension);
|
|
192
|
-
getClassCandidates(transformer(content), extractor,
|
|
183
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
193
184
|
}
|
|
194
185
|
// ---
|
|
195
186
|
// Generate the actual CSS
|
|
@@ -243,7 +234,6 @@ function expandTailwindAtRules(context) {
|
|
|
243
234
|
if (env.DEBUG) {
|
|
244
235
|
console.log('Potential classes: ', candidates.size);
|
|
245
236
|
console.log('Active contexts: ', sharedState.contextSourcesMap.size);
|
|
246
|
-
console.log('Content match entries', contentMatchCache.size);
|
|
247
237
|
}
|
|
248
238
|
// Clear the cache for the changed files
|
|
249
239
|
context.changedContent = [];
|