tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.6d7c311
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 +384 -3
- package/LICENSE +1 -2
- package/README.md +12 -8
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +239 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +4 -740
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +2064 -1811
- package/lib/css/preflight.css +5 -5
- package/lib/featureFlags.js +31 -22
- package/lib/index.js +4 -28
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +225 -31
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +118 -55
- package/lib/lib/expandApplyAtRules.js +439 -190
- package/lib/lib/expandTailwindAtRules.js +151 -134
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +454 -187
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +36 -32
- 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 +89 -67
- package/lib/lib/setupContextUtils.js +667 -376
- package/lib/lib/setupTrackingContext.js +38 -67
- package/lib/lib/sharedState.js +27 -14
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/lib/oxide/cli.d.js +1 -0
- package/lib/oxide/cli.js +2 -0
- package/lib/oxide/postcss-plugin.d.js +1 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +48 -0
- 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 +35 -25
- package/lib/public/colors.js +247 -245
- 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 +11 -6
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -110
- package/lib/util/defaults.js +4 -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 +184 -85
- 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 → isSyntacticallyValidPropertyValue.js} +23 -15
- package/lib/util/log.js +20 -14
- package/lib/util/nameClass.js +20 -9
- package/lib/util/negateValue.js +23 -8
- package/lib/util/normalizeConfig.js +116 -72
- package/lib/util/normalizeScreens.js +120 -11
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- 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 +147 -50
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -85
- 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 +20 -4
- package/lib/util/transformThemeValue.js +37 -29
- 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 +52 -46
- package/peers/index.js +11381 -7950
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- 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 +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +234 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +4 -810
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +532 -217
- package/src/css/preflight.css +5 -5
- package/src/featureFlags.js +15 -9
- package/src/index.js +4 -27
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +196 -33
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +482 -183
- package/src/lib/expandTailwindAtRules.js +106 -85
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +418 -129
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- 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 +51 -30
- package/src/lib/setupContextUtils.js +556 -208
- package/src/lib/setupTrackingContext.js +11 -48
- package/src/lib/sharedState.js +5 -0
- package/src/oxide/cli.d.ts +0 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.d.ts +0 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +47 -0
- 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 +8 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +29 -21
- package/src/util/formatVariantSelector.js +184 -61
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +44 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- 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 +167 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +362 -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/nesting/plugin.js +0 -41
|
@@ -2,54 +2,73 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>expandTailwindAtRules
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
11
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
12
|
+
const _generateRules = require("./generateRules");
|
|
13
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
14
|
+
const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
|
|
15
|
+
const _defaultExtractor = require("./defaultExtractor");
|
|
16
|
+
const _oxide = /*#__PURE__*/ _interopRequireDefault(require("@tailwindcss/oxide"));
|
|
13
17
|
function _interopRequireDefault(obj) {
|
|
14
18
|
return obj && obj.__esModule ? obj : {
|
|
15
19
|
default: obj
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
23
|
+
if (typeof WeakMap !== "function") return null;
|
|
24
|
+
var cacheBabelInterop = new WeakMap();
|
|
25
|
+
var cacheNodeInterop = new WeakMap();
|
|
26
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
27
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
28
|
+
})(nodeInterop);
|
|
29
|
+
}
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
31
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
20
32
|
return obj;
|
|
21
|
-
}
|
|
22
|
-
|
|
33
|
+
}
|
|
34
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
35
|
+
return {
|
|
36
|
+
default: obj
|
|
23
37
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
}
|
|
39
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
40
|
+
if (cache && cache.has(obj)) {
|
|
41
|
+
return cache.get(obj);
|
|
42
|
+
}
|
|
43
|
+
var newObj = {};
|
|
44
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
|
+
for(var key in obj){
|
|
46
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
47
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
48
|
+
if (desc && (desc.get || desc.set)) {
|
|
49
|
+
Object.defineProperty(newObj, key, desc);
|
|
50
|
+
} else {
|
|
51
|
+
newObj[key] = obj[key];
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
|
-
newObj.default = obj;
|
|
38
|
-
return newObj;
|
|
39
54
|
}
|
|
55
|
+
newObj.default = obj;
|
|
56
|
+
if (cache) {
|
|
57
|
+
cache.set(obj, newObj);
|
|
58
|
+
}
|
|
59
|
+
return newObj;
|
|
40
60
|
}
|
|
41
|
-
let env =
|
|
61
|
+
let env = _sharedState.env;
|
|
42
62
|
const builtInExtractors = {
|
|
43
63
|
DEFAULT: _defaultExtractor.defaultExtractor
|
|
44
64
|
};
|
|
45
65
|
const builtInTransformers = {
|
|
46
|
-
DEFAULT: (content)=>content
|
|
47
|
-
,
|
|
48
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
66
|
+
DEFAULT: (content)=>content,
|
|
67
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
49
68
|
};
|
|
50
|
-
function getExtractor(
|
|
51
|
-
let extractors = tailwindConfig.content.extract;
|
|
52
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
69
|
+
function getExtractor(context, fileExtension) {
|
|
70
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
71
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
53
72
|
}
|
|
54
73
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
55
74
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -65,7 +84,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
65
84
|
maxSize: 25000
|
|
66
85
|
}));
|
|
67
86
|
}
|
|
68
|
-
for (let line of content.split(
|
|
87
|
+
for (let line of content.split("\n")){
|
|
69
88
|
line = line.trim();
|
|
70
89
|
if (seen.has(line)) {
|
|
71
90
|
continue;
|
|
@@ -76,65 +95,33 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
76
95
|
candidates.add(match);
|
|
77
96
|
}
|
|
78
97
|
} else {
|
|
79
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
80
|
-
);
|
|
98
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
81
99
|
let lineMatchesSet = new Set(extractorMatches);
|
|
82
|
-
for (let
|
|
83
|
-
candidates.add(
|
|
100
|
+
for (let match1 of lineMatchesSet){
|
|
101
|
+
candidates.add(match1);
|
|
84
102
|
}
|
|
85
103
|
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param {[import('./offsets.js').RuleOffset, import('postcss').Node][]} rules
|
|
110
|
+
* @param {*} context
|
|
111
|
+
*/ function buildStylesheet(rules, context) {
|
|
112
|
+
let sortedRules = context.offsets.sort(rules);
|
|
92
113
|
let returnValue = {
|
|
93
114
|
base: new Set(),
|
|
94
115
|
defaults: new Set(),
|
|
95
116
|
components: new Set(),
|
|
96
117
|
utilities: new Set(),
|
|
97
|
-
variants: new Set()
|
|
98
|
-
// All the CSS that is not Tailwind related can be put in this bucket. This
|
|
99
|
-
// will make it easier to later use this information when we want to
|
|
100
|
-
// `@apply` for example. The main reason we do this here is because we
|
|
101
|
-
// still need to make sure the order is correct. Last but not least, we
|
|
102
|
-
// will make sure to always re-inject this section into the css, even if
|
|
103
|
-
// certain rules were not used. This means that it will look like a no-op
|
|
104
|
-
// from the user's perspective, but we gathered all the useful information
|
|
105
|
-
// we need.
|
|
106
|
-
user: new Set()
|
|
118
|
+
variants: new Set()
|
|
107
119
|
};
|
|
108
120
|
for (let [sort, rule] of sortedRules){
|
|
109
|
-
|
|
110
|
-
returnValue.variants.add(rule);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (sort & context.layerOrder.base) {
|
|
114
|
-
returnValue.base.add(rule);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
if (sort & context.layerOrder.defaults) {
|
|
118
|
-
returnValue.defaults.add(rule);
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (sort & context.layerOrder.components) {
|
|
122
|
-
returnValue.components.add(rule);
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
if (sort & context.layerOrder.utilities) {
|
|
126
|
-
returnValue.utilities.add(rule);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
if (sort & context.layerOrder.user) {
|
|
130
|
-
returnValue.user.add(rule);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
121
|
+
returnValue[sort.layer].add(rule);
|
|
133
122
|
}
|
|
134
123
|
return returnValue;
|
|
135
124
|
}
|
|
136
|
-
const DEFAULTS_LAYER = Symbol('defaults-layer');
|
|
137
|
-
exports.DEFAULTS_LAYER = DEFAULTS_LAYER;
|
|
138
125
|
function expandTailwindAtRules(context) {
|
|
139
126
|
return (root)=>{
|
|
140
127
|
let layerNodes = {
|
|
@@ -143,113 +130,143 @@ function expandTailwindAtRules(context) {
|
|
|
143
130
|
utilities: null,
|
|
144
131
|
variants: null
|
|
145
132
|
};
|
|
146
|
-
// let hasApply = false
|
|
147
133
|
root.walkAtRules((rule)=>{
|
|
148
134
|
// Make sure this file contains Tailwind directives. If not, we can save
|
|
149
135
|
// a lot of work and bail early. Also we don't have to register our touch
|
|
150
136
|
// file as a dependency since the output of this CSS does not depend on
|
|
151
137
|
// the source of any templates. Think Vue <style> blocks for example.
|
|
152
|
-
if (rule.name ===
|
|
138
|
+
if (rule.name === "tailwind") {
|
|
153
139
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
154
140
|
layerNodes[rule.params] = rule;
|
|
155
141
|
}
|
|
156
142
|
}
|
|
157
|
-
// We also want to check for @apply because the user can
|
|
158
|
-
// apply classes in an isolated environment like CSS
|
|
159
|
-
// modules and we still need to inject defaults
|
|
160
|
-
// if (rule.name === 'apply') {
|
|
161
|
-
// hasApply = true
|
|
162
|
-
// }
|
|
163
143
|
});
|
|
164
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
165
|
-
)) {
|
|
144
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
166
145
|
return root;
|
|
167
146
|
}
|
|
147
|
+
var _candidates;
|
|
168
148
|
// ---
|
|
169
149
|
// Find potential rules in changed files
|
|
170
150
|
let candidates = new Set([
|
|
171
|
-
|
|
151
|
+
...(_candidates = context.candidates) !== null && _candidates !== void 0 ? _candidates : [],
|
|
152
|
+
_sharedState.NOT_ON_DEMAND
|
|
172
153
|
]);
|
|
173
154
|
let seen = new Set();
|
|
174
|
-
env.DEBUG && console.time(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
let
|
|
178
|
-
|
|
155
|
+
env.DEBUG && console.time("Reading changed files");
|
|
156
|
+
if (env.OXIDE) {
|
|
157
|
+
// TODO: Pass through or implement `extractor`
|
|
158
|
+
for (let candidate of _oxide.default.parseCandidateStringsFromFiles(context.changedContent)){
|
|
159
|
+
candidates.add(candidate);
|
|
160
|
+
}
|
|
161
|
+
// for (let { file, content, extension } of context.changedContent) {
|
|
162
|
+
// let transformer = getTransformer(context.tailwindConfig, extension)
|
|
163
|
+
// let extractor = getExtractor(context, extension)
|
|
164
|
+
// getClassCandidatesOxide(file, transformer(content), extractor, candidates, seen)
|
|
165
|
+
// }
|
|
166
|
+
} else {
|
|
167
|
+
for (let { file , content , extension } of context.changedContent){
|
|
168
|
+
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
169
|
+
let extractor = getExtractor(context, extension);
|
|
170
|
+
content = file ? _fs.default.readFileSync(file, "utf8") : content;
|
|
171
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
172
|
+
}
|
|
179
173
|
}
|
|
174
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
180
175
|
// ---
|
|
181
176
|
// Generate the actual CSS
|
|
182
177
|
let classCacheCount = context.classCache.size;
|
|
183
|
-
env.DEBUG && console.time(
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
env.DEBUG && console.time("Generate rules");
|
|
179
|
+
// TODO: Sorting is _probably_ slow, but right now it can guarantee the same order. Eventually
|
|
180
|
+
// we will be able to get rid of this.
|
|
181
|
+
env.DEBUG && console.time("Sorting candidates");
|
|
182
|
+
let sortedCandidates = typeof process !== "undefined" && process.env.JEST_WORKER_ID ? new Set([
|
|
183
|
+
...candidates
|
|
184
|
+
].sort((a, z)=>{
|
|
185
|
+
if (a === z) return 0;
|
|
186
|
+
if (a < z) return -1;
|
|
187
|
+
return 1;
|
|
188
|
+
})) : candidates;
|
|
189
|
+
env.DEBUG && console.timeEnd("Sorting candidates");
|
|
190
|
+
(0, _generateRules.generateRules)(sortedCandidates, context);
|
|
191
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
186
192
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
187
|
-
env.DEBUG && console.time(
|
|
193
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
188
194
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
189
|
-
for (let rule of rules){
|
|
190
|
-
context.ruleCache.add(rule);
|
|
191
|
-
}
|
|
192
195
|
context.stylesheetCache = buildStylesheet([
|
|
193
196
|
...context.ruleCache
|
|
194
197
|
], context);
|
|
195
198
|
}
|
|
196
|
-
env.DEBUG && console.timeEnd(
|
|
197
|
-
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes
|
|
199
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
200
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes } = context.stylesheetCache;
|
|
198
201
|
// ---
|
|
199
202
|
// Replace any Tailwind directives with generated CSS
|
|
200
203
|
if (layerNodes.base) {
|
|
201
|
-
layerNodes.base.before((0, _cloneNodes
|
|
202
|
-
...baseNodes
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// compiled in an isolated environment like CSS modules
|
|
208
|
-
if (context.tailwindConfig[DEFAULTS_LAYER] !== false) {
|
|
209
|
-
if (layerNodes.base) {
|
|
210
|
-
layerNodes.base.after((0, _cloneNodes).default([
|
|
211
|
-
...defaultNodes
|
|
212
|
-
], root.source));
|
|
213
|
-
} else {
|
|
214
|
-
root.prepend((0, _cloneNodes).default([
|
|
215
|
-
...defaultNodes
|
|
216
|
-
], root.source));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (layerNodes.base) {
|
|
204
|
+
layerNodes.base.before((0, _cloneNodes.default)([
|
|
205
|
+
...baseNodes,
|
|
206
|
+
...defaultNodes
|
|
207
|
+
], layerNodes.base.source, {
|
|
208
|
+
layer: "base"
|
|
209
|
+
}));
|
|
220
210
|
layerNodes.base.remove();
|
|
221
211
|
}
|
|
222
212
|
if (layerNodes.components) {
|
|
223
|
-
layerNodes.components.before((0, _cloneNodes
|
|
213
|
+
layerNodes.components.before((0, _cloneNodes.default)([
|
|
224
214
|
...componentNodes
|
|
225
|
-
], layerNodes.components.source
|
|
215
|
+
], layerNodes.components.source, {
|
|
216
|
+
layer: "components"
|
|
217
|
+
}));
|
|
226
218
|
layerNodes.components.remove();
|
|
227
219
|
}
|
|
228
220
|
if (layerNodes.utilities) {
|
|
229
|
-
layerNodes.utilities.before((0, _cloneNodes
|
|
221
|
+
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
230
222
|
...utilityNodes
|
|
231
|
-
], layerNodes.utilities.source
|
|
223
|
+
], layerNodes.utilities.source, {
|
|
224
|
+
layer: "utilities"
|
|
225
|
+
}));
|
|
232
226
|
layerNodes.utilities.remove();
|
|
233
227
|
}
|
|
228
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
229
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
230
|
+
var ref;
|
|
231
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
232
|
+
if (parentLayer === "components") {
|
|
233
|
+
return layerNodes.components !== null;
|
|
234
|
+
}
|
|
235
|
+
if (parentLayer === "utilities") {
|
|
236
|
+
return layerNodes.utilities !== null;
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
234
240
|
if (layerNodes.variants) {
|
|
235
|
-
layerNodes.variants.before((0, _cloneNodes
|
|
236
|
-
|
|
237
|
-
|
|
241
|
+
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
242
|
+
layer: "variants"
|
|
243
|
+
}));
|
|
238
244
|
layerNodes.variants.remove();
|
|
239
|
-
} else {
|
|
240
|
-
root.append((0, _cloneNodes
|
|
241
|
-
|
|
242
|
-
|
|
245
|
+
} else if (variantNodes.length > 0) {
|
|
246
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
247
|
+
layer: "variants"
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
251
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
252
|
+
var ref;
|
|
253
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
|
|
254
|
+
});
|
|
255
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
256
|
+
_log.default.warn("content-problems", [
|
|
257
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
258
|
+
"https://tailwindcss.com/docs/content-configuration"
|
|
259
|
+
]);
|
|
243
260
|
}
|
|
244
261
|
// ---
|
|
245
262
|
if (env.DEBUG) {
|
|
246
|
-
console.log(
|
|
247
|
-
console.log(
|
|
263
|
+
console.log("Potential classes: ", candidates.size);
|
|
264
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
248
265
|
}
|
|
249
266
|
// Clear the cache for the changed files
|
|
250
267
|
context.changedContent = [];
|
|
251
268
|
// Cleanup any leftover @layer atrules
|
|
252
|
-
root.walkAtRules(
|
|
269
|
+
root.walkAtRules("layer", (rule)=>{
|
|
253
270
|
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
254
271
|
rule.remove();
|
|
255
272
|
}
|
|
@@ -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` directive cannot be used without setting `from` in your PostCSS config.");
|
|
25
|
+
}
|
|
26
|
+
if (configPath) {
|
|
27
|
+
throw rule.error("Only one `@config` directive is allowed per file.");
|
|
28
|
+
}
|
|
29
|
+
let matches = rule.params.match(/(['"])(.*?)\1/);
|
|
30
|
+
if (!matches) {
|
|
31
|
+
throw rule.error("A path is required when using the `@config` directive.");
|
|
32
|
+
}
|
|
33
|
+
let inputPath = matches[2];
|
|
34
|
+
if (_path.default.isAbsolute(inputPath)) {
|
|
35
|
+
throw rule.error("The `@config` directive 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
|
+
}
|