tailwindcss 0.0.0-insiders.bd970d0 → 0.0.0-insiders.bda8421
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/README.md +1 -2
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +12 -15
- package/lib/cli/build/plugin.js +107 -167
- package/lib/cli/build/utils.js +13 -13
- package/lib/cli/build/watching.js +10 -10
- package/lib/cli/help/index.js +11 -11
- package/lib/cli/index.js +60 -61
- package/lib/cli/init/index.js +16 -16
- package/lib/cli-peer-dependencies.js +36 -0
- package/lib/cli.js +1 -1
- package/lib/corePluginList.js +4 -1
- package/lib/corePlugins.js +2018 -1905
- package/lib/css/preflight.css +18 -12
- package/lib/featureFlags.js +17 -23
- package/lib/index.js +1 -1
- package/lib/lib/cacheInvalidation.js +3 -3
- package/lib/lib/collapseAdjacentRules.js +6 -6
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/content.js +39 -32
- package/lib/lib/defaultExtractor.js +40 -17
- package/lib/lib/evaluateTailwindFunctions.js +23 -23
- package/lib/lib/expandApplyAtRules.js +37 -18
- package/lib/lib/expandTailwindAtRules.js +49 -85
- package/lib/lib/findAtConfigPath.js +5 -5
- package/lib/lib/generateRules.js +82 -55
- package/lib/lib/getModuleDependencies.js +23 -23
- package/lib/lib/load-config.js +21 -6
- package/lib/lib/normalizeTailwindDirectives.js +36 -21
- package/lib/lib/offsets.js +97 -48
- package/lib/lib/partitionApplyAtRules.js +2 -2
- package/lib/lib/regex.js +5 -5
- package/lib/lib/resolveDefaultsAtRules.js +27 -25
- package/lib/lib/setupContextUtils.js +195 -167
- package/lib/lib/setupTrackingContext.js +4 -5
- package/lib/lib/sharedState.js +10 -10
- package/lib/lib/substituteScreenAtRules.js +4 -4
- package/lib/plugin.js +8 -124
- package/lib/postcss-plugins/nesting/index.js +2 -2
- package/lib/postcss-plugins/nesting/plugin.js +11 -11
- package/lib/processTailwindFeatures.js +3 -5
- package/lib/public/colors.js +264 -264
- package/lib/util/applyImportantSelector.js +2 -2
- package/lib/util/buildMediaQuery.js +2 -2
- package/lib/util/cloneDeep.js +1 -1
- package/lib/util/cloneNodes.js +33 -13
- package/lib/util/color.js +19 -19
- package/lib/util/createUtilityPlugin.js +3 -3
- package/lib/util/dataTypes.js +170 -113
- package/lib/util/defaults.js +4 -4
- package/lib/util/escapeClassName.js +2 -2
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +2 -2
- package/lib/util/formatVariantSelector.js +24 -19
- package/lib/util/getAllConfigs.js +4 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +2 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +10 -10
- package/lib/util/log.js +6 -23
- package/lib/util/nameClass.js +4 -4
- package/lib/util/negateValue.js +8 -8
- package/lib/util/normalizeConfig.js +63 -94
- package/lib/util/normalizeScreens.js +18 -18
- package/lib/util/parseAnimationValue.js +38 -38
- package/lib/util/parseBoxShadowValue.js +18 -18
- package/lib/util/parseDependency.js +4 -4
- package/lib/util/parseGlob.js +4 -4
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +36 -21
- package/lib/util/prefixSelector.js +4 -4
- package/lib/util/pseudoElements.js +72 -69
- package/lib/util/removeAlphaVariables.js +1 -1
- package/lib/util/resolveConfig.js +11 -15
- package/lib/util/resolveConfigPath.js +6 -6
- package/lib/util/responsive.js +1 -1
- package/lib/util/splitAtTopLevelOnly.js +3 -3
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +24 -24
- package/lib/util/validateConfig.js +9 -20
- package/lib/util/validateFormalSyntax.js +5 -5
- package/lib/util/withAlphaVariable.js +5 -5
- package/lib/value-parser/index.js +5 -5
- package/lib/value-parser/parse.js +43 -43
- package/lib/value-parser/stringify.js +11 -11
- package/lib/value-parser/unit.js +5 -5
- package/lib/value-parser/walk.js +1 -1
- package/nesting/index.d.ts +4 -0
- package/package.json +41 -36
- package/peers/index.js +96503 -0
- package/resolveConfig.d.ts +22 -3
- package/scripts/generate-types.js +1 -2
- package/scripts/release-notes.js +1 -1
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +0 -4
- package/src/cli/build/plugin.js +53 -85
- package/src/cli/build/watching.js +1 -1
- package/src/cli/index.js +0 -1
- package/src/cli-peer-dependencies.js +15 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +118 -31
- package/src/css/preflight.css +18 -12
- package/src/featureFlags.js +3 -5
- package/src/lib/content.js +39 -30
- package/src/lib/defaultExtractor.js +29 -6
- package/src/lib/expandApplyAtRules.js +24 -0
- package/src/lib/expandTailwindAtRules.js +19 -56
- package/src/lib/generateRules.js +39 -8
- package/src/lib/load-config.ts +13 -0
- package/src/lib/normalizeTailwindDirectives.js +27 -0
- package/src/lib/offsets.js +62 -3
- package/src/lib/resolveDefaultsAtRules.js +5 -1
- package/src/lib/setupContextUtils.js +79 -39
- package/src/plugin.js +0 -86
- package/src/processTailwindFeatures.js +0 -3
- package/src/util/cloneNodes.js +35 -14
- package/src/util/dataTypes.js +72 -6
- package/src/util/formatVariantSelector.js +7 -0
- package/src/util/isPlainObject.js +1 -1
- package/src/util/log.js +0 -24
- package/src/util/normalizeConfig.js +11 -38
- package/src/util/pluginUtils.js +20 -0
- package/src/util/pseudoElements.js +4 -0
- package/src/util/validateConfig.js +0 -10
- package/stubs/config.full.js +68 -8
- package/stubs/config.simple.js +1 -1
- package/stubs/postcss.config.cjs +1 -0
- package/stubs/postcss.config.js +1 -0
- package/types/config.d.ts +12 -5
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +28 -9
- package/types/index.d.ts +7 -3
- package/index.css +0 -5
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/handleImportAtRules.js +0 -50
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/handleImportAtRules.js +0 -34
|
@@ -59,7 +59,7 @@ function extractBaseCandidates(candidates, separator) {
|
|
|
59
59
|
}
|
|
60
60
|
function prefix(context, selector) {
|
|
61
61
|
let prefix = context.tailwindConfig.prefix;
|
|
62
|
-
return typeof prefix ===
|
|
62
|
+
return typeof prefix === "function" ? prefix(selector) : prefix + selector;
|
|
63
63
|
}
|
|
64
64
|
function* pathToRoot(node) {
|
|
65
65
|
yield node;
|
|
@@ -125,7 +125,7 @@ function* pathToRoot(node) {
|
|
|
125
125
|
if (node === parent) {
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
|
-
if (parent.type ===
|
|
128
|
+
if (parent.type === "root") {
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
131
|
node = shallowClone(parent, {
|
|
@@ -150,13 +150,13 @@ function* pathToRoot(node) {
|
|
|
150
150
|
}
|
|
151
151
|
// Clone what's required to represent this singular rule in the tree
|
|
152
152
|
let container = nestedClone(rule);
|
|
153
|
-
let sort = context.offsets.create(
|
|
153
|
+
let sort = context.offsets.create("user");
|
|
154
154
|
for (let className of extractClasses(rule)){
|
|
155
155
|
let list = cache.get(className) || [];
|
|
156
156
|
cache.set(className, list);
|
|
157
157
|
list.push([
|
|
158
158
|
{
|
|
159
|
-
layer:
|
|
159
|
+
layer: "user",
|
|
160
160
|
sort,
|
|
161
161
|
important: false
|
|
162
162
|
},
|
|
@@ -221,7 +221,7 @@ function* pathToRoot(node) {
|
|
|
221
221
|
}
|
|
222
222
|
function extractApplyCandidates(params) {
|
|
223
223
|
let candidates = params.split(/[\s\t\n]+/g);
|
|
224
|
-
if (candidates[candidates.length - 1] ===
|
|
224
|
+
if (candidates[candidates.length - 1] === "!important") {
|
|
225
225
|
return [
|
|
226
226
|
candidates.slice(0, -1),
|
|
227
227
|
true
|
|
@@ -236,7 +236,7 @@ function processApply(root, context, localCache) {
|
|
|
236
236
|
let applyCandidates = new Set();
|
|
237
237
|
// Collect all @apply rules and candidates
|
|
238
238
|
let applies = [];
|
|
239
|
-
root.walkAtRules(
|
|
239
|
+
root.walkAtRules("apply", (rule)=>{
|
|
240
240
|
let [candidates] = extractApplyCandidates(rule.params);
|
|
241
241
|
for (let util of candidates){
|
|
242
242
|
applyCandidates.add(util);
|
|
@@ -318,7 +318,7 @@ function processApply(root, context, localCache) {
|
|
|
318
318
|
[]
|
|
319
319
|
];
|
|
320
320
|
for (let node of sel.nodes){
|
|
321
|
-
if (node.type ===
|
|
321
|
+
if (node.type === "combinator") {
|
|
322
322
|
groups.push(node);
|
|
323
323
|
groups.push([]);
|
|
324
324
|
} else {
|
|
@@ -330,13 +330,13 @@ function processApply(root, context, localCache) {
|
|
|
330
330
|
for (let group of groups){
|
|
331
331
|
if (Array.isArray(group)) {
|
|
332
332
|
group.sort((a, b)=>{
|
|
333
|
-
if (a.type ===
|
|
333
|
+
if (a.type === "tag" && b.type === "class") {
|
|
334
334
|
return -1;
|
|
335
|
-
} else if (a.type ===
|
|
335
|
+
} else if (a.type === "class" && b.type === "tag") {
|
|
336
336
|
return 1;
|
|
337
|
-
} else if (a.type ===
|
|
337
|
+
} else if (a.type === "class" && b.type === "pseudo" && b.value.startsWith("::")) {
|
|
338
338
|
return -1;
|
|
339
|
-
} else if (a.type ===
|
|
339
|
+
} else if (a.type === "pseudo" && a.value.startsWith("::") && b.type === "class") {
|
|
340
340
|
return 1;
|
|
341
341
|
}
|
|
342
342
|
return 0;
|
|
@@ -361,17 +361,17 @@ function processApply(root, context, localCache) {
|
|
|
361
361
|
apply.source
|
|
362
362
|
]);
|
|
363
363
|
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
364
|
-
if (apply.parent.type ===
|
|
365
|
-
if (apply.parent.name ===
|
|
364
|
+
if (apply.parent.type === "atrule") {
|
|
365
|
+
if (apply.parent.name === "screen") {
|
|
366
366
|
let screenType = apply.parent.params;
|
|
367
|
-
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map((c)=>`${screenType}:${c}`).join(
|
|
367
|
+
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${applyCandidates.map((c)=>`${screenType}:${c}`).join(" ")} instead.`);
|
|
368
368
|
}
|
|
369
369
|
throw apply.error(`@apply is not supported within nested at-rules like @${apply.parent.name}. You can fix this by un-nesting @${apply.parent.name}.`);
|
|
370
370
|
}
|
|
371
371
|
for (let applyCandidate of applyCandidates){
|
|
372
372
|
if ([
|
|
373
|
-
prefix(context,
|
|
374
|
-
prefix(context,
|
|
373
|
+
prefix(context, "group"),
|
|
374
|
+
prefix(context, "peer")
|
|
375
375
|
].includes(applyCandidate)) {
|
|
376
376
|
// TODO: Link to specific documentation page with error code.
|
|
377
377
|
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
|
|
@@ -380,6 +380,19 @@ function processApply(root, context, localCache) {
|
|
|
380
380
|
throw apply.error(`The \`${applyCandidate}\` class does not exist. If \`${applyCandidate}\` is a custom class, make sure it is defined within a \`@layer\` directive.`);
|
|
381
381
|
}
|
|
382
382
|
let rules = applyClassCache.get(applyCandidate);
|
|
383
|
+
// Verify that we can apply the class
|
|
384
|
+
for (let [, rule] of rules){
|
|
385
|
+
if (rule.type === "atrule") {
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
rule.walkRules(()=>{
|
|
389
|
+
throw apply.error([
|
|
390
|
+
`The \`${applyCandidate}\` class cannot be used with \`@apply\` because \`@apply\` does not currently support nested CSS.`,
|
|
391
|
+
"Rewrite the selector without nesting or configure the `tailwindcss/nesting` plugin:",
|
|
392
|
+
"https://tailwindcss.com/docs/using-with-preprocessors#nesting"
|
|
393
|
+
].join("\n"));
|
|
394
|
+
});
|
|
395
|
+
}
|
|
383
396
|
candidates.push([
|
|
384
397
|
applyCandidate,
|
|
385
398
|
important,
|
|
@@ -438,7 +451,7 @@ function processApply(root, context, localCache) {
|
|
|
438
451
|
root.walk((node)=>{
|
|
439
452
|
node.source = atApplySource;
|
|
440
453
|
});
|
|
441
|
-
let canRewriteSelector = node.type !==
|
|
454
|
+
let canRewriteSelector = node.type !== "atrule" || node.type === "atrule" && node.name !== "keyframes";
|
|
442
455
|
if (canRewriteSelector) {
|
|
443
456
|
root.walkRules((rule)=>{
|
|
444
457
|
// Let's imagine you have the following structure:
|
|
@@ -477,11 +490,17 @@ function processApply(root, context, localCache) {
|
|
|
477
490
|
return;
|
|
478
491
|
}
|
|
479
492
|
// Strip the important selector from the parent selector if at the beginning
|
|
480
|
-
let importantSelector = typeof context.tailwindConfig.important ===
|
|
493
|
+
let importantSelector = typeof context.tailwindConfig.important === "string" ? context.tailwindConfig.important : null;
|
|
481
494
|
// We only want to move the "important" selector if this is a Tailwind-generated utility
|
|
482
495
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
483
496
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
484
497
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
498
|
+
// If the selector becomes empty after replacing the important selector
|
|
499
|
+
// This means that it's the same as the parent selector and we don't want to replace it
|
|
500
|
+
// Otherwise we'll crash
|
|
501
|
+
if (parentSelector === "") {
|
|
502
|
+
parentSelector = parent.selector;
|
|
503
|
+
}
|
|
485
504
|
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
486
505
|
// And then re-add it if it was removed
|
|
487
506
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
@@ -10,13 +10,11 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
12
|
const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
|
|
13
|
-
const _oxide = require("@tailwindcss/oxide");
|
|
14
13
|
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
15
14
|
const _generateRules = require("./generateRules");
|
|
16
15
|
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
17
16
|
const _cloneNodes = /*#__PURE__*/ _interop_require_default(require("../util/cloneNodes"));
|
|
18
17
|
const _defaultExtractor = require("./defaultExtractor");
|
|
19
|
-
const _featureFlags = require("../featureFlags");
|
|
20
18
|
function _interop_require_default(obj) {
|
|
21
19
|
return obj && obj.__esModule ? obj : {
|
|
22
20
|
default: obj
|
|
@@ -67,16 +65,11 @@ const builtInExtractors = {
|
|
|
67
65
|
};
|
|
68
66
|
const builtInTransformers = {
|
|
69
67
|
DEFAULT: (content)=>content,
|
|
70
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g,
|
|
68
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
71
69
|
};
|
|
72
70
|
function getExtractor(context, fileExtension) {
|
|
73
71
|
let extractors = context.tailwindConfig.content.extract;
|
|
74
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] ||
|
|
75
|
-
// stable identity. Marking it with `DEFAULT_EXTRACTOR` allows us to check if it is the default
|
|
76
|
-
// extractor without relying on the function identity.
|
|
77
|
-
Object.assign(builtInExtractors.DEFAULT(context), {
|
|
78
|
-
DEFAULT_EXTRACTOR: true
|
|
79
|
-
});
|
|
72
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
80
73
|
}
|
|
81
74
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
82
75
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -92,7 +85,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
92
85
|
maxSize: 25000
|
|
93
86
|
}));
|
|
94
87
|
}
|
|
95
|
-
for (let line of content.split(
|
|
88
|
+
for (let line of content.split("\n")){
|
|
96
89
|
line = line.trim();
|
|
97
90
|
if (seen.has(line)) {
|
|
98
91
|
continue;
|
|
@@ -103,7 +96,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
103
96
|
candidates.add(match);
|
|
104
97
|
}
|
|
105
98
|
} else {
|
|
106
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
99
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
107
100
|
let lineMatchesSet = new Set(extractorMatches);
|
|
108
101
|
for (let match of lineMatchesSet){
|
|
109
102
|
candidates.add(match);
|
|
@@ -143,7 +136,7 @@ function expandTailwindAtRules(context) {
|
|
|
143
136
|
// a lot of work and bail early. Also we don't have to register our touch
|
|
144
137
|
// file as a dependency since the output of this CSS does not depend on
|
|
145
138
|
// the source of any templates. Think Vue <style> blocks for example.
|
|
146
|
-
if (rule.name ===
|
|
139
|
+
if (rule.name === "tailwind") {
|
|
147
140
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
148
141
|
layerNodes[rule.params] = rule;
|
|
149
142
|
}
|
|
@@ -160,54 +153,33 @@ function expandTailwindAtRules(context) {
|
|
|
160
153
|
_sharedState.NOT_ON_DEMAND
|
|
161
154
|
]);
|
|
162
155
|
let seen = new Set();
|
|
163
|
-
env.DEBUG && console.time(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
let
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
} else {
|
|
174
|
-
regexParserContent.push([
|
|
175
|
-
item,
|
|
176
|
-
{
|
|
177
|
-
transformer,
|
|
178
|
-
extractor
|
|
179
|
-
}
|
|
180
|
-
]);
|
|
156
|
+
env.DEBUG && console.time("Reading changed files");
|
|
157
|
+
/** @type {[item: {file?: string, content?: string}, meta: {transformer: any, extractor: any}][]} */ let regexParserContent = [];
|
|
158
|
+
for (let item of context.changedContent){
|
|
159
|
+
let transformer = getTransformer(context.tailwindConfig, item.extension);
|
|
160
|
+
let extractor = getExtractor(context, item.extension);
|
|
161
|
+
regexParserContent.push([
|
|
162
|
+
item,
|
|
163
|
+
{
|
|
164
|
+
transformer,
|
|
165
|
+
extractor
|
|
181
166
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
await Promise.all(regexParserContent.map(async ([{ file, content }, { transformer, extractor }])=>{
|
|
190
|
-
content = file ? await _fs.default.promises.readFile(file, 'utf8') : content;
|
|
191
|
-
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
await Promise.all(context.changedContent.map(async ({ file, content, extension })=>{
|
|
196
|
-
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
197
|
-
let extractor = getExtractor(context, extension);
|
|
198
|
-
content = file ? await _fs.default.promises.readFile(file, 'utf8') : content;
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
const BATCH_SIZE = 500;
|
|
170
|
+
for(let i = 0; i < regexParserContent.length; i += BATCH_SIZE){
|
|
171
|
+
let batch = regexParserContent.slice(i, i + BATCH_SIZE);
|
|
172
|
+
await Promise.all(batch.map(async ([{ file , content }, { transformer , extractor }])=>{
|
|
173
|
+
content = file ? await _fs.default.promises.readFile(file, "utf8") : content;
|
|
199
174
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
200
175
|
}));
|
|
201
176
|
}
|
|
202
|
-
env.DEBUG && console.timeEnd(
|
|
177
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
203
178
|
// ---
|
|
204
179
|
// Generate the actual CSS
|
|
205
180
|
let classCacheCount = context.classCache.size;
|
|
206
|
-
env.DEBUG && console.time(
|
|
207
|
-
env.DEBUG && console.time(
|
|
208
|
-
// TODO: only sort if we are not using the oxide parser (flagEnabled(context.tailwindConfig,
|
|
209
|
-
// 'oxideParser')) AND if we got all the candidates form the oxideParser alone. This will not
|
|
210
|
-
// be the case currently if you have custom transformers / extractors.
|
|
181
|
+
env.DEBUG && console.time("Generate rules");
|
|
182
|
+
env.DEBUG && console.time("Sorting candidates");
|
|
211
183
|
let sortedCandidates = new Set([
|
|
212
184
|
...candidates
|
|
213
185
|
].sort((a, z)=>{
|
|
@@ -215,18 +187,18 @@ function expandTailwindAtRules(context) {
|
|
|
215
187
|
if (a < z) return -1;
|
|
216
188
|
return 1;
|
|
217
189
|
}));
|
|
218
|
-
env.DEBUG && console.timeEnd(
|
|
190
|
+
env.DEBUG && console.timeEnd("Sorting candidates");
|
|
219
191
|
(0, _generateRules.generateRules)(sortedCandidates, context);
|
|
220
|
-
env.DEBUG && console.timeEnd(
|
|
192
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
221
193
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
222
|
-
env.DEBUG && console.time(
|
|
194
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
223
195
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
224
196
|
context.stylesheetCache = buildStylesheet([
|
|
225
197
|
...context.ruleCache
|
|
226
198
|
], context);
|
|
227
199
|
}
|
|
228
|
-
env.DEBUG && console.timeEnd(
|
|
229
|
-
let { defaults: defaultNodes, base: baseNodes, components: componentNodes, utilities: utilityNodes, variants: screenNodes
|
|
200
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
201
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes } = context.stylesheetCache;
|
|
230
202
|
// ---
|
|
231
203
|
// Replace any Tailwind directives with generated CSS
|
|
232
204
|
if (layerNodes.base) {
|
|
@@ -234,7 +206,7 @@ function expandTailwindAtRules(context) {
|
|
|
234
206
|
...baseNodes,
|
|
235
207
|
...defaultNodes
|
|
236
208
|
], layerNodes.base.source, {
|
|
237
|
-
layer:
|
|
209
|
+
layer: "base"
|
|
238
210
|
}));
|
|
239
211
|
layerNodes.base.remove();
|
|
240
212
|
}
|
|
@@ -242,7 +214,7 @@ function expandTailwindAtRules(context) {
|
|
|
242
214
|
layerNodes.components.before((0, _cloneNodes.default)([
|
|
243
215
|
...componentNodes
|
|
244
216
|
], layerNodes.components.source, {
|
|
245
|
-
layer:
|
|
217
|
+
layer: "components"
|
|
246
218
|
}));
|
|
247
219
|
layerNodes.components.remove();
|
|
248
220
|
}
|
|
@@ -250,7 +222,7 @@ function expandTailwindAtRules(context) {
|
|
|
250
222
|
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
251
223
|
...utilityNodes
|
|
252
224
|
], layerNodes.utilities.source, {
|
|
253
|
-
layer:
|
|
225
|
+
layer: "utilities"
|
|
254
226
|
}));
|
|
255
227
|
layerNodes.utilities.remove();
|
|
256
228
|
}
|
|
@@ -258,55 +230,47 @@ function expandTailwindAtRules(context) {
|
|
|
258
230
|
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
259
231
|
var _node_raws_tailwind;
|
|
260
232
|
const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
|
|
261
|
-
if (parentLayer ===
|
|
233
|
+
if (parentLayer === "components") {
|
|
262
234
|
return layerNodes.components !== null;
|
|
263
235
|
}
|
|
264
|
-
if (parentLayer ===
|
|
236
|
+
if (parentLayer === "utilities") {
|
|
265
237
|
return layerNodes.utilities !== null;
|
|
266
238
|
}
|
|
267
239
|
return true;
|
|
268
240
|
});
|
|
269
241
|
if (layerNodes.variants) {
|
|
270
242
|
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
271
|
-
layer:
|
|
243
|
+
layer: "variants"
|
|
272
244
|
}));
|
|
273
245
|
layerNodes.variants.remove();
|
|
274
246
|
} else if (variantNodes.length > 0) {
|
|
275
|
-
|
|
276
|
-
layer:
|
|
277
|
-
});
|
|
278
|
-
cloned.forEach((node)=>{
|
|
279
|
-
var _node_raws_tailwind;
|
|
280
|
-
var _node_raws_tailwind_parentLayer;
|
|
281
|
-
let parentLayer = (_node_raws_tailwind_parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) !== null && _node_raws_tailwind_parentLayer !== void 0 ? _node_raws_tailwind_parentLayer : null;
|
|
282
|
-
node.walk((n)=>{
|
|
283
|
-
if (!n.source) {
|
|
284
|
-
n.source = layerNodes[parentLayer].source;
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
root.append(cloned);
|
|
247
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
248
|
+
layer: "variants"
|
|
249
|
+
}));
|
|
289
250
|
}
|
|
251
|
+
var _root_source_end;
|
|
252
|
+
// TODO: Why is the root node having no source location for `end` possible?
|
|
253
|
+
root.source.end = (_root_source_end = root.source.end) !== null && _root_source_end !== void 0 ? _root_source_end : root.source.start;
|
|
290
254
|
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
291
255
|
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
292
256
|
var _node_raws_tailwind;
|
|
293
|
-
return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) ===
|
|
257
|
+
return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
|
|
294
258
|
});
|
|
295
259
|
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
296
|
-
_log.default.warn(
|
|
297
|
-
|
|
298
|
-
|
|
260
|
+
_log.default.warn("content-problems", [
|
|
261
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
262
|
+
"https://tailwindcss.com/docs/content-configuration"
|
|
299
263
|
]);
|
|
300
264
|
}
|
|
301
265
|
// ---
|
|
302
266
|
if (env.DEBUG) {
|
|
303
|
-
console.log(
|
|
304
|
-
console.log(
|
|
267
|
+
console.log("Potential classes: ", candidates.size);
|
|
268
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
305
269
|
}
|
|
306
270
|
// Clear the cache for the changed files
|
|
307
271
|
context.changedContent = [];
|
|
308
272
|
// Cleanup any leftover @layer atrules
|
|
309
|
-
root.walkAtRules(
|
|
273
|
+
root.walkAtRules("layer", (rule)=>{
|
|
310
274
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
311
275
|
rule.remove();
|
|
312
276
|
}
|
|
@@ -18,23 +18,23 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
function findAtConfigPath(root, result) {
|
|
19
19
|
let configPath = null;
|
|
20
20
|
let relativeTo = null;
|
|
21
|
-
root.walkAtRules(
|
|
21
|
+
root.walkAtRules("config", (rule)=>{
|
|
22
22
|
var _rule_source;
|
|
23
23
|
var _rule_source_input_file, _ref;
|
|
24
24
|
relativeTo = (_ref = (_rule_source_input_file = (_rule_source = rule.source) === null || _rule_source === void 0 ? void 0 : _rule_source.input.file) !== null && _rule_source_input_file !== void 0 ? _rule_source_input_file : result.opts.from) !== null && _ref !== void 0 ? _ref : null;
|
|
25
25
|
if (relativeTo === null) {
|
|
26
|
-
throw rule.error(
|
|
26
|
+
throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
|
|
27
27
|
}
|
|
28
28
|
if (configPath) {
|
|
29
|
-
throw rule.error(
|
|
29
|
+
throw rule.error("Only one `@config` directive is allowed per file.");
|
|
30
30
|
}
|
|
31
31
|
let matches = rule.params.match(/(['"])(.*?)\1/);
|
|
32
32
|
if (!matches) {
|
|
33
|
-
throw rule.error(
|
|
33
|
+
throw rule.error("A path is required when using the `@config` directive.");
|
|
34
34
|
}
|
|
35
35
|
let inputPath = matches[2];
|
|
36
36
|
if (_path.default.isAbsolute(inputPath)) {
|
|
37
|
-
throw rule.error(
|
|
37
|
+
throw rule.error("The `@config` directive cannot be used with an absolute path.");
|
|
38
38
|
}
|
|
39
39
|
configPath = _path.default.resolve(_path.default.dirname(relativeTo), inputPath);
|
|
40
40
|
if (!_fs.default.existsSync(configPath)) {
|