tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cb6e45a
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 +526 -2
- package/LICENSE +1 -2
- package/README.md +13 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +44 -0
- package/lib/cli/build/plugin.js +335 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +113 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +91 -569
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +16 -4
- package/lib/corePlugins.js +2247 -1873
- package/lib/css/preflight.css +20 -9
- package/lib/featureFlags.js +37 -23
- package/lib/index.js +28 -12
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +167 -0
- package/lib/lib/defaultExtractor.js +236 -0
- package/lib/lib/detectNesting.js +21 -3
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +439 -160
- package/lib/lib/expandTailwindAtRules.js +141 -151
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +572 -105
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +45 -33
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +114 -81
- package/lib/lib/setupContextUtils.js +777 -385
- package/lib/lib/setupTrackingContext.js +43 -71
- package/lib/lib/sharedState.js +49 -18
- package/lib/lib/substituteScreenAtRules.js +13 -8
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +36 -21
- package/lib/public/colors.js +250 -252
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +18 -24
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +11 -13
- package/lib/util/dataTypes.js +137 -100
- package/lib/util/defaults.js +10 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +285 -0
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +72 -0
- package/lib/util/log.js +44 -22
- package/lib/util/nameClass.js +20 -8
- package/lib/util/negateValue.js +23 -6
- package/lib/util/normalizeConfig.js +267 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +171 -189
- package/lib/util/prefixSelector.js +10 -10
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +92 -126
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +49 -31
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +48 -46
- package/peers/index.js +14817 -12471
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +45 -0
- package/src/cli/build/plugin.js +397 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +134 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +26 -565
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +905 -615
- package/src/css/preflight.css +20 -9
- package/src/featureFlags.js +26 -10
- package/src/index.js +19 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/content.js +205 -0
- package/src/lib/defaultExtractor.js +211 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +94 -106
- package/src/lib/findAtConfigPath.js +50 -0
- package/src/lib/generateRules.js +589 -67
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +98 -60
- package/src/lib/setupContextUtils.js +737 -246
- package/src/lib/setupTrackingContext.js +16 -54
- package/src/lib/sharedState.js +44 -7
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +17 -2
- package/src/public/colors.js +4 -9
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +57 -21
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +319 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +14 -4
- package/src/util/normalizeConfig.js +282 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +144 -152
- package/src/util/prefixSelector.js +7 -8
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +82 -81
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +33 -8
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +173 -93
- package/stubs/simpleConfig.stub.js +1 -1
- package/types/config.d.ts +361 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -306
|
@@ -2,159 +2,121 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>expandTailwindAtRules
|
|
8
|
+
});
|
|
9
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
10
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
|
+
const _generateRules = require("./generateRules");
|
|
12
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
13
|
+
const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
|
|
14
|
+
const _defaultExtractor = require("./defaultExtractor");
|
|
10
15
|
function _interopRequireDefault(obj) {
|
|
11
16
|
return obj && obj.__esModule ? obj : {
|
|
12
17
|
default: obj
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
17
30
|
return obj;
|
|
18
|
-
}
|
|
19
|
-
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
20
35
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
|
-
newObj.default = obj;
|
|
35
|
-
return newObj;
|
|
36
52
|
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
37
58
|
}
|
|
38
|
-
let env =
|
|
39
|
-
let contentMatchCache = sharedState.contentMatchCache;
|
|
40
|
-
const PATTERNS = [
|
|
41
|
-
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
42
|
-
/([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
|
|
43
|
-
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
44
|
-
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
45
|
-
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
46
|
-
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
47
|
-
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
48
|
-
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
49
|
-
].join('|');
|
|
50
|
-
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
51
|
-
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
|
|
59
|
+
let env = _sharedState.env;
|
|
52
60
|
const builtInExtractors = {
|
|
53
|
-
DEFAULT:
|
|
54
|
-
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
|
|
55
|
-
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
|
|
56
|
-
return [
|
|
57
|
-
...broadMatches,
|
|
58
|
-
...innerMatches
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
+
DEFAULT: _defaultExtractor.defaultExtractor
|
|
61
62
|
};
|
|
62
63
|
const builtInTransformers = {
|
|
63
|
-
DEFAULT: (content)=>content
|
|
64
|
-
,
|
|
65
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
64
|
+
DEFAULT: (content)=>content,
|
|
65
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
66
66
|
};
|
|
67
|
-
function getExtractor(
|
|
68
|
-
let extractors = tailwindConfig.content.extract;
|
|
69
|
-
|
|
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
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
67
|
+
function getExtractor(context, fileExtension) {
|
|
68
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
69
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
84
70
|
}
|
|
85
71
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
86
72
|
let transformers = tailwindConfig.content.transform;
|
|
87
|
-
if (typeof transformers === 'function') {
|
|
88
|
-
transformers = {
|
|
89
|
-
DEFAULT: transformers
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
73
|
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
93
74
|
}
|
|
75
|
+
let extractorCache = new WeakMap();
|
|
94
76
|
// Scans template contents for possible classes. This is a hot path on initial build but
|
|
95
77
|
// not too important for subsequent builds. The faster the better though — if we can speed
|
|
96
78
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
97
|
-
function getClassCandidates(content, extractor,
|
|
98
|
-
|
|
79
|
+
function getClassCandidates(content, extractor, candidates, seen) {
|
|
80
|
+
if (!extractorCache.has(extractor)) {
|
|
81
|
+
extractorCache.set(extractor, new _quickLru.default({
|
|
82
|
+
maxSize: 25000
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
for (let line of content.split("\n")){
|
|
99
86
|
line = line.trim();
|
|
100
87
|
if (seen.has(line)) {
|
|
101
88
|
continue;
|
|
102
89
|
}
|
|
103
90
|
seen.add(line);
|
|
104
|
-
if (
|
|
105
|
-
for (let match of
|
|
91
|
+
if (extractorCache.get(extractor).has(line)) {
|
|
92
|
+
for (let match of extractorCache.get(extractor).get(line)){
|
|
106
93
|
candidates.add(match);
|
|
107
94
|
}
|
|
108
95
|
} else {
|
|
109
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
110
|
-
);
|
|
96
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
111
97
|
let lineMatchesSet = new Set(extractorMatches);
|
|
112
|
-
for (let
|
|
113
|
-
candidates.add(
|
|
98
|
+
for (let match1 of lineMatchesSet){
|
|
99
|
+
candidates.add(match1);
|
|
114
100
|
}
|
|
115
|
-
|
|
101
|
+
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
104
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {[import('./offsets.js').RuleOffset, import('postcss').Node][]} rules
|
|
108
|
+
* @param {*} context
|
|
109
|
+
*/ function buildStylesheet(rules, context) {
|
|
110
|
+
let sortedRules = context.offsets.sort(rules);
|
|
122
111
|
let returnValue = {
|
|
123
112
|
base: new Set(),
|
|
113
|
+
defaults: new Set(),
|
|
124
114
|
components: new Set(),
|
|
125
115
|
utilities: new Set(),
|
|
126
|
-
variants: new Set()
|
|
127
|
-
// All the CSS that is not Tailwind related can be put in this bucket. This
|
|
128
|
-
// will make it easier to later use this information when we want to
|
|
129
|
-
// `@apply` for example. The main reason we do this here is because we
|
|
130
|
-
// still need to make sure the order is correct. Last but not least, we
|
|
131
|
-
// will make sure to always re-inject this section into the css, even if
|
|
132
|
-
// certain rules were not used. This means that it will look like a no-op
|
|
133
|
-
// from the user's perspective, but we gathered all the useful information
|
|
134
|
-
// we need.
|
|
135
|
-
user: new Set()
|
|
116
|
+
variants: new Set()
|
|
136
117
|
};
|
|
137
118
|
for (let [sort, rule] of sortedRules){
|
|
138
|
-
|
|
139
|
-
returnValue.variants.add(rule);
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (sort & context.layerOrder.base) {
|
|
143
|
-
returnValue.base.add(rule);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (sort & context.layerOrder.components) {
|
|
147
|
-
returnValue.components.add(rule);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (sort & context.layerOrder.utilities) {
|
|
151
|
-
returnValue.utilities.add(rule);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (sort & context.layerOrder.user) {
|
|
155
|
-
returnValue.user.add(rule);
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
119
|
+
returnValue[sort.layer].add(rule);
|
|
158
120
|
}
|
|
159
121
|
return returnValue;
|
|
160
122
|
}
|
|
@@ -166,89 +128,117 @@ function expandTailwindAtRules(context) {
|
|
|
166
128
|
utilities: null,
|
|
167
129
|
variants: null
|
|
168
130
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
layerNodes
|
|
131
|
+
root.walkAtRules((rule)=>{
|
|
132
|
+
// Make sure this file contains Tailwind directives. If not, we can save
|
|
133
|
+
// a lot of work and bail early. Also we don't have to register our touch
|
|
134
|
+
// file as a dependency since the output of this CSS does not depend on
|
|
135
|
+
// the source of any templates. Think Vue <style> blocks for example.
|
|
136
|
+
if (rule.name === "tailwind") {
|
|
137
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
138
|
+
layerNodes[rule.params] = rule;
|
|
139
|
+
}
|
|
176
140
|
}
|
|
177
141
|
});
|
|
178
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
179
|
-
)) {
|
|
142
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
180
143
|
return root;
|
|
181
144
|
}
|
|
182
145
|
// ---
|
|
183
146
|
// Find potential rules in changed files
|
|
184
147
|
let candidates = new Set([
|
|
185
|
-
|
|
148
|
+
_sharedState.NOT_ON_DEMAND
|
|
186
149
|
]);
|
|
187
150
|
let seen = new Set();
|
|
188
|
-
env.DEBUG && console.time(
|
|
151
|
+
env.DEBUG && console.time("Reading changed files");
|
|
189
152
|
for (let { content , extension } of context.changedContent){
|
|
190
153
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
191
|
-
let extractor = getExtractor(context
|
|
192
|
-
getClassCandidates(transformer(content), extractor,
|
|
154
|
+
let extractor = getExtractor(context, extension);
|
|
155
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
193
156
|
}
|
|
157
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
194
158
|
// ---
|
|
195
159
|
// Generate the actual CSS
|
|
196
160
|
let classCacheCount = context.classCache.size;
|
|
197
|
-
env.DEBUG && console.time(
|
|
198
|
-
|
|
199
|
-
env.DEBUG && console.timeEnd(
|
|
161
|
+
env.DEBUG && console.time("Generate rules");
|
|
162
|
+
(0, _generateRules.generateRules)(candidates, context);
|
|
163
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
200
164
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
201
|
-
env.DEBUG && console.time(
|
|
165
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
202
166
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
203
|
-
for (let rule of rules){
|
|
204
|
-
context.ruleCache.add(rule);
|
|
205
|
-
}
|
|
206
167
|
context.stylesheetCache = buildStylesheet([
|
|
207
168
|
...context.ruleCache
|
|
208
169
|
], context);
|
|
209
170
|
}
|
|
210
|
-
env.DEBUG && console.timeEnd(
|
|
211
|
-
let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
171
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
172
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
212
173
|
// ---
|
|
213
174
|
// Replace any Tailwind directives with generated CSS
|
|
214
175
|
if (layerNodes.base) {
|
|
215
|
-
layerNodes.base.before((0, _cloneNodes
|
|
216
|
-
...baseNodes
|
|
217
|
-
|
|
176
|
+
layerNodes.base.before((0, _cloneNodes.default)([
|
|
177
|
+
...baseNodes,
|
|
178
|
+
...defaultNodes
|
|
179
|
+
], layerNodes.base.source, {
|
|
180
|
+
layer: "base"
|
|
181
|
+
}));
|
|
218
182
|
layerNodes.base.remove();
|
|
219
183
|
}
|
|
220
184
|
if (layerNodes.components) {
|
|
221
|
-
layerNodes.components.before((0, _cloneNodes
|
|
185
|
+
layerNodes.components.before((0, _cloneNodes.default)([
|
|
222
186
|
...componentNodes
|
|
223
|
-
], layerNodes.components.source
|
|
187
|
+
], layerNodes.components.source, {
|
|
188
|
+
layer: "components"
|
|
189
|
+
}));
|
|
224
190
|
layerNodes.components.remove();
|
|
225
191
|
}
|
|
226
192
|
if (layerNodes.utilities) {
|
|
227
|
-
layerNodes.utilities.before((0, _cloneNodes
|
|
193
|
+
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
228
194
|
...utilityNodes
|
|
229
|
-
], layerNodes.utilities.source
|
|
195
|
+
], layerNodes.utilities.source, {
|
|
196
|
+
layer: "utilities"
|
|
197
|
+
}));
|
|
230
198
|
layerNodes.utilities.remove();
|
|
231
199
|
}
|
|
200
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
201
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
202
|
+
var ref;
|
|
203
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
204
|
+
if (parentLayer === "components") {
|
|
205
|
+
return layerNodes.components !== null;
|
|
206
|
+
}
|
|
207
|
+
if (parentLayer === "utilities") {
|
|
208
|
+
return layerNodes.utilities !== null;
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
});
|
|
232
212
|
if (layerNodes.variants) {
|
|
233
|
-
layerNodes.variants.before((0, _cloneNodes
|
|
234
|
-
|
|
235
|
-
|
|
213
|
+
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
214
|
+
layer: "variants"
|
|
215
|
+
}));
|
|
236
216
|
layerNodes.variants.remove();
|
|
237
|
-
} else {
|
|
238
|
-
root.append((0, _cloneNodes
|
|
239
|
-
|
|
240
|
-
|
|
217
|
+
} else if (variantNodes.length > 0) {
|
|
218
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
219
|
+
layer: "variants"
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
223
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
224
|
+
var ref;
|
|
225
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
|
|
226
|
+
});
|
|
227
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
228
|
+
_log.default.warn("content-problems", [
|
|
229
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
230
|
+
"https://tailwindcss.com/docs/content-configuration"
|
|
231
|
+
]);
|
|
241
232
|
}
|
|
242
233
|
// ---
|
|
243
234
|
if (env.DEBUG) {
|
|
244
|
-
console.log(
|
|
245
|
-
console.log(
|
|
246
|
-
console.log('Content match entries', contentMatchCache.size);
|
|
235
|
+
console.log("Potential classes: ", candidates.size);
|
|
236
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
247
237
|
}
|
|
248
238
|
// Clear the cache for the changed files
|
|
249
239
|
context.changedContent = [];
|
|
250
240
|
// Cleanup any leftover @layer atrules
|
|
251
|
-
root.walkAtRules(
|
|
241
|
+
root.walkAtRules("layer", (rule)=>{
|
|
252
242
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
253
243
|
rule.remove();
|
|
254
244
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "findAtConfigPath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>findAtConfigPath
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function findAtConfigPath(root, result) {
|
|
17
|
+
let configPath = null;
|
|
18
|
+
let relativeTo = null;
|
|
19
|
+
root.walkAtRules("config", (rule)=>{
|
|
20
|
+
var ref;
|
|
21
|
+
var _file, ref1;
|
|
22
|
+
relativeTo = (ref1 = (_file = (ref = rule.source) === null || ref === void 0 ? void 0 : ref.input.file) !== null && _file !== void 0 ? _file : result.opts.from) !== null && ref1 !== void 0 ? ref1 : null;
|
|
23
|
+
if (relativeTo === null) {
|
|
24
|
+
throw rule.error("The `@config` at-rule cannot be used without a `from` option being set on the PostCSS config.");
|
|
25
|
+
}
|
|
26
|
+
if (configPath) {
|
|
27
|
+
throw rule.error("Only `@config` at-rule is allowed per file.");
|
|
28
|
+
}
|
|
29
|
+
let matches = rule.params.match(/(['"])(.*?)\1/);
|
|
30
|
+
if (!matches) {
|
|
31
|
+
throw rule.error("The `@config` at-rule must be followed by a string containing the path to the config file.");
|
|
32
|
+
}
|
|
33
|
+
let inputPath = matches[2];
|
|
34
|
+
if (_path.default.isAbsolute(inputPath)) {
|
|
35
|
+
throw rule.error("The `@config` at-rule cannot be used with an absolute path.");
|
|
36
|
+
}
|
|
37
|
+
configPath = _path.default.resolve(_path.default.dirname(relativeTo), inputPath);
|
|
38
|
+
if (!_fs.default.existsSync(configPath)) {
|
|
39
|
+
throw rule.error(`The config file at "${inputPath}" does not exist. Make sure the path is correct and the file exists.`);
|
|
40
|
+
}
|
|
41
|
+
rule.remove();
|
|
42
|
+
});
|
|
43
|
+
return configPath ? configPath : null;
|
|
44
|
+
}
|