tailwindcss 0.0.0-insiders.ea10bb9 → 0.0.0-insiders.ea3d9cd
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 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +23 -10
- package/lib/cli/build/plugin.js +136 -117
- package/lib/cli/build/utils.js +18 -8
- package/lib/cli/build/watching.js +16 -12
- package/lib/cli/help/index.js +6 -4
- package/lib/cli/index.js +223 -10
- package/lib/cli/init/index.js +29 -12
- package/lib/cli.js +1 -227
- package/lib/corePluginList.js +8 -1
- package/lib/corePlugins.js +374 -77
- package/lib/css/preflight.css +9 -1
- package/lib/featureFlags.js +30 -17
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +7 -5
- package/lib/lib/collapseAdjacentRules.js +5 -3
- package/lib/lib/collapseDuplicateDeclarations.js +12 -10
- package/lib/lib/content.js +61 -31
- package/lib/lib/defaultExtractor.js +15 -8
- package/lib/lib/detectNesting.js +10 -2
- package/lib/lib/evaluateTailwindFunctions.js +24 -20
- package/lib/lib/expandApplyAtRules.js +43 -35
- package/lib/lib/expandTailwindAtRules.js +89 -22
- package/lib/lib/findAtConfigPath.js +9 -7
- package/lib/lib/generateRules.js +160 -98
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +5 -18
- package/lib/lib/offsets.js +93 -4
- package/lib/lib/partitionApplyAtRules.js +3 -1
- package/lib/lib/regex.js +21 -7
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +28 -24
- package/lib/lib/setupContextUtils.js +191 -142
- package/lib/lib/setupTrackingContext.js +50 -26
- package/lib/lib/sharedState.js +28 -9
- package/lib/lib/substituteScreenAtRules.js +5 -3
- package/lib/plugin.js +116 -0
- package/lib/postcss-plugins/nesting/index.js +3 -1
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +14 -12
- package/lib/public/colors.js +49 -25
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +3 -1
- package/lib/util/cloneDeep.js +3 -1
- package/lib/util/cloneNodes.js +5 -3
- package/lib/util/color.js +30 -12
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +7 -5
- package/lib/util/dataTypes.js +88 -23
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +10 -8
- package/lib/util/escapeCommas.js +3 -1
- package/lib/util/flattenColorPalette.js +3 -1
- package/lib/util/formatVariantSelector.js +138 -160
- package/lib/util/getAllConfigs.js +8 -6
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +3 -1
- package/lib/util/isPlainObject.js +3 -1
- package/lib/util/isSyntacticallyValidPropertyValue.js +3 -1
- package/lib/util/log.js +25 -4
- package/lib/util/nameClass.js +12 -6
- package/lib/util/negateValue.js +4 -2
- package/lib/util/normalizeConfig.js +63 -36
- package/lib/util/normalizeScreens.js +12 -4
- package/lib/util/parseAnimationValue.js +3 -1
- package/lib/util/parseBoxShadowValue.js +6 -2
- package/lib/util/parseDependency.js +3 -1
- package/lib/util/parseGlob.js +6 -4
- package/lib/util/parseObjectStyles.js +9 -7
- package/lib/util/pluginUtils.js +53 -55
- package/lib/util/prefixSelector.js +27 -11
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +3 -1
- package/lib/util/resolveConfig.js +17 -15
- package/lib/util/resolveConfigPath.js +26 -10
- package/lib/util/responsive.js +6 -4
- package/lib/util/splitAtTopLevelOnly.js +10 -2
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +3 -1
- package/lib/util/toPath.js +3 -1
- package/lib/util/transformThemeValue.js +6 -4
- package/lib/util/validateConfig.js +27 -3
- package/lib/util/validateFormalSyntax.js +3 -1
- package/lib/util/withAlphaVariable.js +6 -2
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +46 -45
- package/resolveConfig.d.ts +11 -2
- package/src/cli/build/index.js +17 -9
- package/src/cli/build/plugin.js +96 -73
- package/src/cli/build/watching.js +4 -2
- package/src/cli/index.js +217 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +1 -221
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +237 -34
- package/src/css/preflight.css +9 -1
- package/src/featureFlags.js +7 -3
- package/src/index.js +1 -47
- package/src/lib/content.js +45 -18
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +8 -1
- package/src/lib/expandTailwindAtRules.js +73 -12
- package/src/lib/generateRules.js +127 -49
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/handleImportAtRules.js +34 -0
- package/src/lib/load-config.ts +31 -0
- package/src/lib/normalizeTailwindDirectives.js +0 -27
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +109 -69
- package/src/lib/setupTrackingContext.js +37 -14
- package/src/lib/sharedState.js +11 -4
- package/src/plugin.js +124 -0
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +18 -3
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +49 -9
- package/src/util/formatVariantSelector.js +160 -163
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/log.js +24 -0
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +39 -11
- package/src/util/pluginUtils.js +16 -35
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +23 -0
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +197 -147
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
- package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -1
- package/stubs/postcss.config.js +5 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +17 -10
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +110 -80
- package/CHANGELOG.md +0 -2336
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/shared.js +0 -12
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/constants.js +0 -44
- package/peers/index.js +0 -79512
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/build/deps.js +0 -56
- package/src/cli/shared.js +0 -5
- package/src/cli-peer-dependencies.js +0 -15
- package/src/constants.js +0 -17
|
@@ -4,13 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandApplyAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _postcss = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
12
|
+
const _postcssselectorparser = /*#__PURE__*/ _interop_require_default(require("postcss-selector-parser"));
|
|
11
13
|
const _generateRules = require("./generateRules");
|
|
12
|
-
const _escapeClassName = /*#__PURE__*/
|
|
13
|
-
|
|
14
|
+
const _escapeClassName = /*#__PURE__*/ _interop_require_default(require("../util/escapeClassName"));
|
|
15
|
+
const _applyImportantSelector = require("../util/applyImportantSelector");
|
|
16
|
+
const _pseudoElements = require("../util/pseudoElements");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
14
18
|
return obj && obj.__esModule ? obj : {
|
|
15
19
|
default: obj
|
|
16
20
|
};
|
|
@@ -23,7 +27,7 @@ function _interopRequireDefault(obj) {
|
|
|
23
27
|
]
|
|
24
28
|
});
|
|
25
29
|
container.walkRules((rule)=>{
|
|
26
|
-
(0,
|
|
30
|
+
(0, _postcssselectorparser.default)((selectors)=>{
|
|
27
31
|
selectors.walkClasses((classSelector)=>{
|
|
28
32
|
let parentSelector = classSelector.parent.toString();
|
|
29
33
|
let classes = groups.get(parentSelector);
|
|
@@ -40,7 +44,7 @@ function _interopRequireDefault(obj) {
|
|
|
40
44
|
groups: normalizedGroups
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
|
-
let selectorExtractor = (0,
|
|
47
|
+
let selectorExtractor = (0, _postcssselectorparser.default)();
|
|
44
48
|
/**
|
|
45
49
|
* @param {string} ruleSelectors
|
|
46
50
|
*/ function extractSelectors(ruleSelectors) {
|
|
@@ -139,8 +143,8 @@ function* pathToRoot(node) {
|
|
|
139
143
|
root.walkRules((rule)=>{
|
|
140
144
|
// Ignore rules generated by Tailwind
|
|
141
145
|
for (let node of pathToRoot(rule)){
|
|
142
|
-
var
|
|
143
|
-
if (((
|
|
146
|
+
var _node_raws_tailwind;
|
|
147
|
+
if (((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.layer) !== undefined) {
|
|
144
148
|
return;
|
|
145
149
|
}
|
|
146
150
|
}
|
|
@@ -309,11 +313,11 @@ function processApply(root, context, localCache) {
|
|
|
309
313
|
// Sort tag names before class names (but only sort each group (separated by a combinator)
|
|
310
314
|
// separately and not in total)
|
|
311
315
|
// This happens when replacing `.bar` in `.foo.bar` with a tag like `section`
|
|
312
|
-
for (let
|
|
316
|
+
for (let sel of replaced){
|
|
313
317
|
let groups = [
|
|
314
318
|
[]
|
|
315
319
|
];
|
|
316
|
-
for (let node of
|
|
320
|
+
for (let node of sel.nodes){
|
|
317
321
|
if (node.type === "combinator") {
|
|
318
322
|
groups.push(node);
|
|
319
323
|
groups.push([]);
|
|
@@ -322,7 +326,7 @@ function processApply(root, context, localCache) {
|
|
|
322
326
|
last.push(node);
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
|
-
|
|
329
|
+
sel.nodes = [];
|
|
326
330
|
for (let group of groups){
|
|
327
331
|
if (Array.isArray(group)) {
|
|
328
332
|
group.sort((a, b)=>{
|
|
@@ -338,7 +342,7 @@ function processApply(root, context, localCache) {
|
|
|
338
342
|
return 0;
|
|
339
343
|
});
|
|
340
344
|
}
|
|
341
|
-
|
|
345
|
+
sel.nodes = sel.nodes.concat(group);
|
|
342
346
|
}
|
|
343
347
|
}
|
|
344
348
|
sel.replaceWith(...replaced);
|
|
@@ -356,15 +360,15 @@ function processApply(root, context, localCache) {
|
|
|
356
360
|
candidates,
|
|
357
361
|
apply.source
|
|
358
362
|
]);
|
|
359
|
-
let [
|
|
363
|
+
let [applyCandidates, important] = extractApplyCandidates(apply.params);
|
|
360
364
|
if (apply.parent.type === "atrule") {
|
|
361
365
|
if (apply.parent.name === "screen") {
|
|
362
366
|
let screenType = apply.parent.params;
|
|
363
|
-
throw apply.error(`@apply is not supported within nested at-rules like @screen. We suggest you write this as @apply ${
|
|
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.`);
|
|
364
368
|
}
|
|
365
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}.`);
|
|
366
370
|
}
|
|
367
|
-
for (let applyCandidate of
|
|
371
|
+
for (let applyCandidate of applyCandidates){
|
|
368
372
|
if ([
|
|
369
373
|
prefix(context, "group"),
|
|
370
374
|
prefix(context, "peer")
|
|
@@ -383,16 +387,16 @@ function processApply(root, context, localCache) {
|
|
|
383
387
|
]);
|
|
384
388
|
}
|
|
385
389
|
}
|
|
386
|
-
for (let [parent, [
|
|
390
|
+
for (let [parent, [candidates, atApplySource]] of perParentApplies){
|
|
387
391
|
let siblings = [];
|
|
388
|
-
for (let [
|
|
392
|
+
for (let [applyCandidate, important, rules] of candidates){
|
|
389
393
|
let potentialApplyCandidates = [
|
|
390
|
-
|
|
394
|
+
applyCandidate,
|
|
391
395
|
...extractBaseCandidates([
|
|
392
|
-
|
|
396
|
+
applyCandidate
|
|
393
397
|
], context.tailwindConfig.separator)
|
|
394
398
|
];
|
|
395
|
-
for (let [meta, node] of
|
|
399
|
+
for (let [meta, node] of rules){
|
|
396
400
|
let parentClasses = extractClasses(parent);
|
|
397
401
|
let nodeClasses = extractClasses(node);
|
|
398
402
|
// When we encounter a rule like `.dark .a, .b { … }` we only want to be left with `[.dark, .a]` if the base applyCandidate is `.a` or with `[.b]` if the base applyCandidate is `.b`
|
|
@@ -423,20 +427,20 @@ function processApply(root, context, localCache) {
|
|
|
423
427
|
nodeClasses = nodeClasses.concat(extractBaseCandidates(nodeClasses, context.tailwindConfig.separator));
|
|
424
428
|
let intersects = parentClasses.some((selector)=>nodeClasses.includes(selector));
|
|
425
429
|
if (intersects) {
|
|
426
|
-
throw node.error(`You cannot \`@apply\` the \`${
|
|
430
|
+
throw node.error(`You cannot \`@apply\` the \`${applyCandidate}\` utility here because it creates a circular dependency.`);
|
|
427
431
|
}
|
|
428
|
-
let
|
|
432
|
+
let root = _postcss.default.root({
|
|
429
433
|
nodes: [
|
|
430
434
|
node.clone()
|
|
431
435
|
]
|
|
432
436
|
});
|
|
433
437
|
// Make sure every node in the entire tree points back at the @apply rule that generated it
|
|
434
|
-
|
|
438
|
+
root.walk((node)=>{
|
|
435
439
|
node.source = atApplySource;
|
|
436
440
|
});
|
|
437
441
|
let canRewriteSelector = node.type !== "atrule" || node.type === "atrule" && node.name !== "keyframes";
|
|
438
442
|
if (canRewriteSelector) {
|
|
439
|
-
|
|
443
|
+
root.walkRules((rule)=>{
|
|
440
444
|
// Let's imagine you have the following structure:
|
|
441
445
|
//
|
|
442
446
|
// .foo {
|
|
@@ -468,7 +472,7 @@ function processApply(root, context, localCache) {
|
|
|
468
472
|
// would have replaced this with something that didn't exist and
|
|
469
473
|
// therefore it removed the selector altogether. In this specific
|
|
470
474
|
// case it would result in `{}` instead of `.something-unrelated {}`
|
|
471
|
-
if (!extractClasses(rule).some((candidate)=>candidate ===
|
|
475
|
+
if (!extractClasses(rule).some((candidate)=>candidate === applyCandidate)) {
|
|
472
476
|
rule.remove();
|
|
473
477
|
return;
|
|
474
478
|
}
|
|
@@ -478,25 +482,29 @@ function processApply(root, context, localCache) {
|
|
|
478
482
|
// We do *not* want to do this for user CSS that happens to be structured the same
|
|
479
483
|
let isGenerated = parent.raws.tailwind !== undefined;
|
|
480
484
|
let parentSelector = isGenerated && importantSelector && parent.selector.indexOf(importantSelector) === 0 ? parent.selector.slice(importantSelector.length) : parent.selector;
|
|
481
|
-
rule.selector = replaceSelector(parentSelector, rule.selector,
|
|
485
|
+
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate);
|
|
482
486
|
// And then re-add it if it was removed
|
|
483
487
|
if (importantSelector && parentSelector !== parent.selector) {
|
|
484
|
-
rule.selector =
|
|
488
|
+
rule.selector = (0, _applyImportantSelector.applyImportantSelector)(rule.selector, importantSelector);
|
|
485
489
|
}
|
|
486
490
|
rule.walkDecls((d)=>{
|
|
487
|
-
d.important = meta.important ||
|
|
491
|
+
d.important = meta.important || important;
|
|
488
492
|
});
|
|
493
|
+
// Move pseudo elements to the end of the selector (if necessary)
|
|
494
|
+
let selector = (0, _postcssselectorparser.default)().astSync(rule.selector);
|
|
495
|
+
selector.each((sel)=>(0, _pseudoElements.movePseudos)(sel));
|
|
496
|
+
rule.selector = selector.toString();
|
|
489
497
|
});
|
|
490
498
|
}
|
|
491
499
|
// It could be that the node we were inserted was removed because the class didn't match
|
|
492
500
|
// If that was the *only* rule in the parent, then we have nothing add so we skip it
|
|
493
|
-
if (!
|
|
501
|
+
if (!root.nodes[0]) {
|
|
494
502
|
continue;
|
|
495
503
|
}
|
|
496
504
|
// Insert it
|
|
497
505
|
siblings.push([
|
|
498
506
|
meta.sort,
|
|
499
|
-
|
|
507
|
+
root.nodes[0]
|
|
500
508
|
]);
|
|
501
509
|
}
|
|
502
510
|
}
|
|
@@ -505,13 +513,13 @@ function processApply(root, context, localCache) {
|
|
|
505
513
|
// `parent` refers to the node at `.abc` in: .abc { @apply mt-2 }
|
|
506
514
|
parent.after(nodes);
|
|
507
515
|
}
|
|
508
|
-
for (let
|
|
516
|
+
for (let apply of applies){
|
|
509
517
|
// If there are left-over declarations, just remove the @apply
|
|
510
|
-
if (
|
|
511
|
-
|
|
518
|
+
if (apply.parent.nodes.length > 1) {
|
|
519
|
+
apply.remove();
|
|
512
520
|
} else {
|
|
513
521
|
// The node is empty, drop the full node
|
|
514
|
-
|
|
522
|
+
apply.parent.remove();
|
|
515
523
|
}
|
|
516
524
|
}
|
|
517
525
|
// Do it again, in case we have other `@apply` rules
|
|
@@ -4,15 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return expandTailwindAtRules;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
|
|
13
|
+
const _oxide = require("@tailwindcss/oxide");
|
|
14
|
+
const _sharedState = /*#__PURE__*/ _interop_require_wildcard(require("./sharedState"));
|
|
11
15
|
const _generateRules = require("./generateRules");
|
|
12
|
-
const _log = /*#__PURE__*/
|
|
13
|
-
const _cloneNodes = /*#__PURE__*/
|
|
16
|
+
const _log = /*#__PURE__*/ _interop_require_default(require("../util/log"));
|
|
17
|
+
const _cloneNodes = /*#__PURE__*/ _interop_require_default(require("../util/cloneNodes"));
|
|
14
18
|
const _defaultExtractor = require("./defaultExtractor");
|
|
15
|
-
|
|
19
|
+
const _featureFlags = require("../featureFlags");
|
|
20
|
+
function _interop_require_default(obj) {
|
|
16
21
|
return obj && obj.__esModule ? obj : {
|
|
17
22
|
default: obj
|
|
18
23
|
};
|
|
@@ -25,7 +30,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
25
30
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
31
|
})(nodeInterop);
|
|
27
32
|
}
|
|
28
|
-
function
|
|
33
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
34
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
35
|
return obj;
|
|
31
36
|
}
|
|
@@ -66,7 +71,12 @@ const builtInTransformers = {
|
|
|
66
71
|
};
|
|
67
72
|
function getExtractor(context, fileExtension) {
|
|
68
73
|
let extractors = context.tailwindConfig.content.extract;
|
|
69
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] ||
|
|
74
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || // Because we call `DEFAULT(context)`, the returning function is always a new function without a
|
|
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
|
+
});
|
|
70
80
|
}
|
|
71
81
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
72
82
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -78,7 +88,7 @@ let extractorCache = new WeakMap();
|
|
|
78
88
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
79
89
|
function getClassCandidates(content, extractor, candidates, seen) {
|
|
80
90
|
if (!extractorCache.has(extractor)) {
|
|
81
|
-
extractorCache.set(extractor, new
|
|
91
|
+
extractorCache.set(extractor, new _quicklru.default({
|
|
82
92
|
maxSize: 25000
|
|
83
93
|
}));
|
|
84
94
|
}
|
|
@@ -95,8 +105,8 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
95
105
|
} else {
|
|
96
106
|
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
97
107
|
let lineMatchesSet = new Set(extractorMatches);
|
|
98
|
-
for (let
|
|
99
|
-
candidates.add(
|
|
108
|
+
for (let match of lineMatchesSet){
|
|
109
|
+
candidates.add(match);
|
|
100
110
|
}
|
|
101
111
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
102
112
|
}
|
|
@@ -142,24 +152,70 @@ function expandTailwindAtRules(context) {
|
|
|
142
152
|
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
143
153
|
return root;
|
|
144
154
|
}
|
|
155
|
+
var _context_candidates;
|
|
145
156
|
// ---
|
|
146
157
|
// Find potential rules in changed files
|
|
147
158
|
let candidates = new Set([
|
|
159
|
+
...(_context_candidates = context.candidates) !== null && _context_candidates !== void 0 ? _context_candidates : [],
|
|
148
160
|
_sharedState.NOT_ON_DEMAND
|
|
149
161
|
]);
|
|
150
162
|
let seen = new Set();
|
|
151
163
|
env.DEBUG && console.time("Reading changed files");
|
|
152
|
-
|
|
153
|
-
let
|
|
154
|
-
let
|
|
155
|
-
|
|
164
|
+
if ((0, _featureFlags.flagEnabled)(context.tailwindConfig, "oxideParser")) {
|
|
165
|
+
let rustParserContent = [];
|
|
166
|
+
let regexParserContent = [];
|
|
167
|
+
for (let item of context.changedContent){
|
|
168
|
+
let transformer = getTransformer(context.tailwindConfig, item.extension);
|
|
169
|
+
let extractor = getExtractor(context, item.extension);
|
|
170
|
+
if (transformer === builtInTransformers.DEFAULT && (extractor === null || extractor === void 0 ? void 0 : extractor.DEFAULT_EXTRACTOR) === true) {
|
|
171
|
+
rustParserContent.push(item);
|
|
172
|
+
} else {
|
|
173
|
+
regexParserContent.push([
|
|
174
|
+
item,
|
|
175
|
+
{
|
|
176
|
+
transformer,
|
|
177
|
+
extractor
|
|
178
|
+
}
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (rustParserContent.length > 0) {
|
|
183
|
+
for (let candidate of (0, _oxide.parseCandidateStrings)(rustParserContent, _oxide.IO.Parallel | _oxide.Parsing.Parallel)){
|
|
184
|
+
candidates.add(candidate);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (regexParserContent.length > 0) {
|
|
188
|
+
for (let [{ file , content }, { transformer , extractor }] of regexParserContent){
|
|
189
|
+
content = file ? _fs.default.readFileSync(file, "utf8") : content;
|
|
190
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
for (let { file , content , extension } of context.changedContent){
|
|
195
|
+
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
196
|
+
let extractor = getExtractor(context, extension);
|
|
197
|
+
content = file ? _fs.default.readFileSync(file, "utf8") : content;
|
|
198
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
199
|
+
}
|
|
156
200
|
}
|
|
157
201
|
env.DEBUG && console.timeEnd("Reading changed files");
|
|
158
202
|
// ---
|
|
159
203
|
// Generate the actual CSS
|
|
160
204
|
let classCacheCount = context.classCache.size;
|
|
161
205
|
env.DEBUG && console.time("Generate rules");
|
|
162
|
-
|
|
206
|
+
env.DEBUG && console.time("Sorting candidates");
|
|
207
|
+
// TODO: only sort if we are not using the oxide parser (flagEnabled(context.tailwindConfig,
|
|
208
|
+
// 'oxideParser')) AND if we got all the candidates form the oxideParser alone. This will not
|
|
209
|
+
// be the case currently if you have custom transformers / extractors.
|
|
210
|
+
let sortedCandidates = new Set([
|
|
211
|
+
...candidates
|
|
212
|
+
].sort((a, z)=>{
|
|
213
|
+
if (a === z) return 0;
|
|
214
|
+
if (a < z) return -1;
|
|
215
|
+
return 1;
|
|
216
|
+
}));
|
|
217
|
+
env.DEBUG && console.timeEnd("Sorting candidates");
|
|
218
|
+
(0, _generateRules.generateRules)(sortedCandidates, context);
|
|
163
219
|
env.DEBUG && console.timeEnd("Generate rules");
|
|
164
220
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
165
221
|
env.DEBUG && console.time("Build stylesheet");
|
|
@@ -199,8 +255,8 @@ function expandTailwindAtRules(context) {
|
|
|
199
255
|
}
|
|
200
256
|
// We do post-filtering to not alter the emitted order of the variants
|
|
201
257
|
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
202
|
-
var
|
|
203
|
-
const parentLayer = (
|
|
258
|
+
var _node_raws_tailwind;
|
|
259
|
+
const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
|
|
204
260
|
if (parentLayer === "components") {
|
|
205
261
|
return layerNodes.components !== null;
|
|
206
262
|
}
|
|
@@ -215,14 +271,25 @@ function expandTailwindAtRules(context) {
|
|
|
215
271
|
}));
|
|
216
272
|
layerNodes.variants.remove();
|
|
217
273
|
} else if (variantNodes.length > 0) {
|
|
218
|
-
|
|
274
|
+
let cloned = (0, _cloneNodes.default)(variantNodes, undefined, {
|
|
219
275
|
layer: "variants"
|
|
220
|
-
})
|
|
276
|
+
});
|
|
277
|
+
cloned.forEach((node)=>{
|
|
278
|
+
var _node_raws_tailwind;
|
|
279
|
+
var _node_raws_tailwind_parentLayer;
|
|
280
|
+
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;
|
|
281
|
+
node.walk((n)=>{
|
|
282
|
+
if (!n.source) {
|
|
283
|
+
n.source = layerNodes[parentLayer].source;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
root.append(cloned);
|
|
221
288
|
}
|
|
222
289
|
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
223
290
|
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
224
|
-
var
|
|
225
|
-
return ((
|
|
291
|
+
var _node_raws_tailwind;
|
|
292
|
+
return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
|
|
226
293
|
});
|
|
227
294
|
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
228
295
|
_log.default.warn("content-problems", [
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "findAtConfigPath", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return findAtConfigPath;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _fs = /*#__PURE__*/
|
|
10
|
-
const _path = /*#__PURE__*/
|
|
11
|
-
function
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
@@ -17,9 +19,9 @@ function findAtConfigPath(root, result) {
|
|
|
17
19
|
let configPath = null;
|
|
18
20
|
let relativeTo = null;
|
|
19
21
|
root.walkAtRules("config", (rule)=>{
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
relativeTo = (
|
|
22
|
+
var _rule_source;
|
|
23
|
+
var _rule_source_input_file, _ref;
|
|
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;
|
|
23
25
|
if (relativeTo === null) {
|
|
24
26
|
throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
|
|
25
27
|
}
|