tailwindcss 0.0.0-insiders.4e21639 → 0.0.0-insiders.4e62334
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 +435 -3
- 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-peer-dependencies.js +20 -7
- package/lib/cli.js +460 -259
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +9 -3
- package/lib/corePlugins.js +1840 -1753
- package/lib/css/preflight.css +8 -9
- package/lib/featureFlags.js +29 -20
- package/lib/index.js +22 -11
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +58 -4
- package/lib/lib/defaultExtractor.js +231 -0
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +119 -52
- package/lib/lib/expandApplyAtRules.js +440 -161
- package/lib/lib/expandTailwindAtRules.js +130 -128
- package/lib/lib/generateRules.js +410 -171
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +43 -32
- package/lib/lib/offsets.js +199 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +91 -55
- package/lib/lib/setupContextUtils.js +453 -347
- package/lib/lib/setupTrackingContext.js +52 -44
- package/lib/lib/sharedState.js +48 -9
- 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 -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 +16 -25
- 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 +4 -1
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -102
- 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 +223 -40
- 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 +22 -12
- package/lib/util/nameClass.js +17 -8
- package/lib/util/negateValue.js +22 -7
- package/lib/util/normalizeConfig.js +99 -54
- package/lib/util/normalizeScreens.js +73 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +51 -42
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +91 -66
- 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 +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +43 -43
- package/peers/index.js +11543 -8114
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +293 -36
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +428 -285
- package/src/css/preflight.css +8 -9
- package/src/featureFlags.js +9 -5
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/defaultExtractor.js +208 -0
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +82 -80
- package/src/lib/generateRules.js +352 -120
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +239 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +59 -17
- package/src/lib/setupContextUtils.js +337 -174
- package/src/lib/setupTrackingContext.js +13 -8
- package/src/lib/sharedState.js +42 -4
- 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 +12 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/dataTypes.js +28 -19
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +237 -23
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +1 -1
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +16 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/pluginUtils.js +14 -2
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +71 -17
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +24 -3
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +334 -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 +331 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -288
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -311
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
6
|
+
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
7
|
+
// source path), or set up a new one (including setting up watchers and registering
|
|
8
|
+
// plugins) then return it
|
|
9
|
+
"default", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: ()=>setupTrackingContext
|
|
12
|
+
});
|
|
13
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
14
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
15
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
16
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
17
|
+
const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
18
|
+
const _hashConfig = /*#__PURE__*/ _interopRequireDefault(require("../util/hashConfig"));
|
|
19
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("../lib/getModuleDependencies"));
|
|
20
|
+
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../public/resolve-config"));
|
|
21
|
+
const _resolveConfigPath = /*#__PURE__*/ _interopRequireDefault(require("../util/resolveConfigPath"));
|
|
22
|
+
const _sharedState = require("./sharedState");
|
|
23
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
24
|
+
const _parseDependency = /*#__PURE__*/ _interopRequireDefault(require("../util/parseDependency"));
|
|
25
|
+
const _validateConfigJs = require("../util/validateConfig.js");
|
|
18
26
|
function _interopRequireDefault(obj) {
|
|
19
27
|
return obj && obj.__esModule ? obj : {
|
|
20
28
|
default: obj
|
|
@@ -28,18 +36,15 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
28
36
|
if (candidateFilesCache.has(context)) {
|
|
29
37
|
return candidateFilesCache.get(context);
|
|
30
38
|
}
|
|
31
|
-
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item ===
|
|
32
|
-
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
33
|
-
);
|
|
39
|
+
let candidateFiles = tailwindConfig.content.files.filter((item)=>typeof item === "string").map((contentPath)=>(0, _normalizePath.default)(contentPath));
|
|
34
40
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
35
41
|
}
|
|
36
42
|
// Get the config object based on a path
|
|
37
43
|
function getTailwindConfig(configOrPath) {
|
|
38
|
-
let userConfigPath = (0, _resolveConfigPath
|
|
44
|
+
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
39
45
|
if (userConfigPath !== null) {
|
|
40
46
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
41
|
-
let newDeps = (0, _getModuleDependencies
|
|
42
|
-
);
|
|
47
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath).map((dep)=>dep.file);
|
|
43
48
|
let modified = false;
|
|
44
49
|
let newModified = new Map();
|
|
45
50
|
for (let file of newDeps){
|
|
@@ -62,8 +67,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
62
67
|
for (let file1 of newDeps){
|
|
63
68
|
delete require.cache[file1];
|
|
64
69
|
}
|
|
65
|
-
let newConfig = (0, _resolveConfig
|
|
66
|
-
|
|
70
|
+
let newConfig = (0, _resolveConfig.default)(require(userConfigPath));
|
|
71
|
+
newConfig = (0, _validateConfigJs.validateConfig)(newConfig);
|
|
72
|
+
let newHash = (0, _hashConfig.default)(newConfig);
|
|
67
73
|
configPathCache.set(userConfigPath, [
|
|
68
74
|
newConfig,
|
|
69
75
|
newHash,
|
|
@@ -78,23 +84,22 @@ function getTailwindConfig(configOrPath) {
|
|
|
78
84
|
];
|
|
79
85
|
}
|
|
80
86
|
// It's a plain object, not a path
|
|
81
|
-
let
|
|
87
|
+
let newConfig1 = (0, _resolveConfig.default)(configOrPath.config === undefined ? configOrPath : configOrPath.config);
|
|
88
|
+
newConfig1 = (0, _validateConfigJs.validateConfig)(newConfig1);
|
|
82
89
|
return [
|
|
83
|
-
|
|
90
|
+
newConfig1,
|
|
84
91
|
null,
|
|
85
|
-
(0, _hashConfig
|
|
92
|
+
(0, _hashConfig.default)(newConfig1),
|
|
86
93
|
[]
|
|
87
94
|
];
|
|
88
95
|
}
|
|
89
96
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
90
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw ===
|
|
91
|
-
).map(({ raw , extension ='html' })=>({
|
|
97
|
+
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
|
|
92
98
|
content: raw,
|
|
93
99
|
extension
|
|
94
|
-
})
|
|
95
|
-
);
|
|
100
|
+
}));
|
|
96
101
|
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
|
|
97
|
-
let content = _fs.default.readFileSync(changedFile,
|
|
102
|
+
let content = _fs.default.readFileSync(changedFile, "utf8");
|
|
98
103
|
let extension = _path.default.extname(changedFile).slice(1);
|
|
99
104
|
changedContent.push({
|
|
100
105
|
content,
|
|
@@ -105,8 +110,10 @@ function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
|
105
110
|
}
|
|
106
111
|
function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
107
112
|
let changedFiles = new Set();
|
|
108
|
-
_sharedState.env.DEBUG && console.time(
|
|
109
|
-
let files = _fastGlob.default.sync(candidateFiles
|
|
113
|
+
_sharedState.env.DEBUG && console.time("Finding changed files");
|
|
114
|
+
let files = _fastGlob.default.sync(candidateFiles, {
|
|
115
|
+
absolute: true
|
|
116
|
+
});
|
|
110
117
|
for (let file of files){
|
|
111
118
|
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
|
|
112
119
|
let modified = _fs.default.statSync(file).mtimeMs;
|
|
@@ -115,7 +122,7 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
115
122
|
fileModifiedMap.set(file, modified);
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
|
-
_sharedState.env.DEBUG && console.timeEnd(
|
|
125
|
+
_sharedState.env.DEBUG && console.timeEnd("Finding changed files");
|
|
119
126
|
return changedFiles;
|
|
120
127
|
}
|
|
121
128
|
function setupTrackingContext(configOrPath) {
|
|
@@ -123,33 +130,34 @@ function setupTrackingContext(configOrPath) {
|
|
|
123
130
|
return (root, result)=>{
|
|
124
131
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] = getTailwindConfig(configOrPath);
|
|
125
132
|
let contextDependencies = new Set(configDependencies);
|
|
126
|
-
// If there are no @tailwind rules, we don't consider this CSS
|
|
127
|
-
// to be dependencies of the context. Can reuse
|
|
128
|
-
// We may want to think about `@layer`
|
|
129
|
-
//
|
|
130
|
-
// in
|
|
133
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
134
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
135
|
+
// the context even if they change. We may want to think about `@layer`
|
|
136
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
137
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
138
|
+
// another file since independent sources are effectively isolated.
|
|
131
139
|
if (tailwindDirectives.size > 0) {
|
|
132
140
|
// Add current css file as a context dependencies.
|
|
133
141
|
contextDependencies.add(result.opts.from);
|
|
134
142
|
// Add all css @import dependencies as context dependencies.
|
|
135
143
|
for (let message of result.messages){
|
|
136
|
-
if (message.type ===
|
|
144
|
+
if (message.type === "dependency") {
|
|
137
145
|
contextDependencies.add(message.file);
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
|
-
let [context] = (0, _setupContextUtils
|
|
149
|
+
let [context] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
142
150
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
143
|
-
// If there are no @tailwind rules, we don't consider this CSS file or it's
|
|
144
|
-
// to be dependencies of the context. Can reuse the context even if they change.
|
|
151
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
152
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
145
153
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
146
154
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
147
155
|
// in another file since independent sources are effectively isolated.
|
|
148
156
|
if (tailwindDirectives.size > 0) {
|
|
149
|
-
let fileModifiedMap = (0, _setupContextUtils
|
|
157
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
150
158
|
// Add template paths as postcss dependencies.
|
|
151
159
|
for (let fileOrGlob of candidateFiles){
|
|
152
|
-
let dependency = (0, _parseDependency
|
|
160
|
+
let dependency = (0, _parseDependency.default)(fileOrGlob);
|
|
153
161
|
if (dependency) {
|
|
154
162
|
registerDependency(dependency);
|
|
155
163
|
}
|
|
@@ -160,7 +168,7 @@ function setupTrackingContext(configOrPath) {
|
|
|
160
168
|
}
|
|
161
169
|
for (let file of configDependencies){
|
|
162
170
|
registerDependency({
|
|
163
|
-
type:
|
|
171
|
+
type: "dependency",
|
|
164
172
|
file
|
|
165
173
|
});
|
|
166
174
|
}
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,18 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
env: ()=>env,
|
|
13
|
+
contextMap: ()=>contextMap,
|
|
14
|
+
configContextMap: ()=>configContextMap,
|
|
15
|
+
contextSourcesMap: ()=>contextSourcesMap,
|
|
16
|
+
sourceHashMap: ()=>sourceHashMap,
|
|
17
|
+
NOT_ON_DEMAND: ()=>NOT_ON_DEMAND,
|
|
18
|
+
resolveDebug: ()=>resolveDebug
|
|
19
|
+
});
|
|
6
20
|
const env = {
|
|
7
|
-
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
8
21
|
NODE_ENV: process.env.NODE_ENV,
|
|
9
|
-
DEBUG: process.env.DEBUG
|
|
10
|
-
TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
|
|
11
|
-
TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR
|
|
22
|
+
DEBUG: resolveDebug(process.env.DEBUG)
|
|
12
23
|
};
|
|
13
|
-
exports.env = env;
|
|
14
24
|
const contextMap = new Map();
|
|
15
|
-
exports.contextMap = contextMap;
|
|
16
25
|
const configContextMap = new Map();
|
|
17
|
-
exports.configContextMap = configContextMap;
|
|
18
26
|
const contextSourcesMap = new Map();
|
|
19
|
-
|
|
27
|
+
const sourceHashMap = new Map();
|
|
28
|
+
const NOT_ON_DEMAND = new String("*");
|
|
29
|
+
function resolveDebug(debug) {
|
|
30
|
+
if (debug === undefined) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// Environment variables are strings, so convert to boolean
|
|
34
|
+
if (debug === "true" || debug === "1") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (debug === "false" || debug === "0") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// Keep the debug convention into account:
|
|
41
|
+
// DEBUG=* -> This enables all debug modes
|
|
42
|
+
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
43
|
+
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
44
|
+
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
45
|
+
if (debug === "*") {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
|
|
49
|
+
// Ignoring tailwindcss
|
|
50
|
+
if (debuggers.includes("-tailwindcss")) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
// Including tailwindcss
|
|
54
|
+
if (debuggers.includes("tailwindcss")) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _normalizeScreens = require("../util/normalizeScreens");
|
|
10
|
+
const _buildMediaQuery = /*#__PURE__*/ _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
7
11
|
function _interopRequireDefault(obj) {
|
|
8
12
|
return obj && obj.__esModule ? obj : {
|
|
9
13
|
default: obj
|
|
@@ -11,14 +15,15 @@ function _interopRequireDefault(obj) {
|
|
|
11
15
|
}
|
|
12
16
|
function _default({ tailwindConfig: { theme } }) {
|
|
13
17
|
return function(css) {
|
|
14
|
-
css.walkAtRules(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
css.walkAtRules("screen", (atRule)=>{
|
|
19
|
+
let screen = atRule.params;
|
|
20
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
|
|
21
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
22
|
+
if (!screenDefinition) {
|
|
18
23
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
19
24
|
}
|
|
20
|
-
atRule.name =
|
|
21
|
-
atRule.params = (0, _buildMediaQuery
|
|
25
|
+
atRule.name = "media";
|
|
26
|
+
atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
|
|
22
27
|
});
|
|
23
28
|
};
|
|
24
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tailwindcss/nesting
|
|
2
2
|
|
|
3
|
-
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/
|
|
3
|
+
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
|
|
4
4
|
|
|
5
5
|
Add it to your PostCSS configuration, somewhere before Tailwind itself:
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
|
|
20
20
|
|
|
21
|
-
If you'd rather use [postcss-nesting](https://github.com/
|
|
21
|
+
If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
npm install postcss-nesting
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _plugin = require("./plugin");
|
|
10
|
+
const _default = Object.assign(function(opts) {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: "tailwindcss/nesting",
|
|
13
|
+
Once (root, { result }) {
|
|
14
|
+
return (0, _plugin.nesting)(opts)(root, result);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
postcss: true
|
|
19
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "nesting", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>nesting
|
|
8
|
+
});
|
|
9
|
+
const _postcss = /*#__PURE__*/ _interopRequireDefault(require("postcss"));
|
|
10
|
+
const _postcssNested = /*#__PURE__*/ _interopRequireDefault(require("postcss-nested"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function nesting(opts = _postcssNested.default) {
|
|
17
|
+
return (root, result)=>{
|
|
18
|
+
root.walkAtRules("screen", (rule)=>{
|
|
19
|
+
rule.name = "media";
|
|
20
|
+
rule.params = `screen(${rule.params})`;
|
|
21
|
+
});
|
|
22
|
+
root.walkAtRules("apply", (rule)=>{
|
|
23
|
+
rule.before(_postcss.default.decl({
|
|
24
|
+
prop: "__apply",
|
|
25
|
+
value: rule.params,
|
|
26
|
+
source: rule.source
|
|
27
|
+
}));
|
|
28
|
+
rule.remove();
|
|
29
|
+
});
|
|
30
|
+
let plugin = (()=>{
|
|
31
|
+
var ref;
|
|
32
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (ref = opts.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(opts, "postcssPlugin"))) {
|
|
33
|
+
return opts;
|
|
34
|
+
}
|
|
35
|
+
if (typeof opts === "string") {
|
|
36
|
+
return require(opts);
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(opts).length <= 0) {
|
|
39
|
+
return _postcssNested.default;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
|
|
42
|
+
})();
|
|
43
|
+
(0, _postcss.default)([
|
|
44
|
+
plugin
|
|
45
|
+
]).process(root, result.opts).sync();
|
|
46
|
+
root.walkDecls("__apply", (decl)=>{
|
|
47
|
+
decl.before(_postcss.default.atRule({
|
|
48
|
+
name: "apply",
|
|
49
|
+
params: decl.value,
|
|
50
|
+
source: decl.source
|
|
51
|
+
}));
|
|
52
|
+
decl.remove();
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
56
|
+
* This is done because running process() on the AST will set the "clean"
|
|
57
|
+
* flag on all nodes, which we don't want.
|
|
58
|
+
*
|
|
59
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
60
|
+
*
|
|
61
|
+
* This is guarded because the PostCSS API is not public
|
|
62
|
+
* and may change in future versions of PostCSS.
|
|
63
|
+
*
|
|
64
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
65
|
+
*
|
|
66
|
+
* @param {import('postcss').Node} node
|
|
67
|
+
*/ function markDirty(node) {
|
|
68
|
+
if (!("markDirty" in node)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Traverse the tree down to the leaf nodes
|
|
72
|
+
if (node.nodes) {
|
|
73
|
+
node.nodes.forEach((n)=>markDirty(n));
|
|
74
|
+
}
|
|
75
|
+
// If it's a leaf node mark it as dirty
|
|
76
|
+
// We do this here because marking a node as dirty
|
|
77
|
+
// will walk up the tree and mark all parents as dirty
|
|
78
|
+
// resulting in a lot of unnecessary work if we did this
|
|
79
|
+
// for every single node
|
|
80
|
+
if (!node.nodes) {
|
|
81
|
+
node.markDirty();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
markDirty(root);
|
|
85
|
+
return root;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>processTailwindFeatures
|
|
8
|
+
});
|
|
9
|
+
const _normalizeTailwindDirectives = /*#__PURE__*/ _interopRequireDefault(require("./lib/normalizeTailwindDirectives"));
|
|
10
|
+
const _expandTailwindAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/expandTailwindAtRules"));
|
|
11
|
+
const _expandApplyAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/expandApplyAtRules"));
|
|
12
|
+
const _evaluateTailwindFunctions = /*#__PURE__*/ _interopRequireDefault(require("./lib/evaluateTailwindFunctions"));
|
|
13
|
+
const _substituteScreenAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/substituteScreenAtRules"));
|
|
14
|
+
const _resolveDefaultsAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/resolveDefaultsAtRules"));
|
|
15
|
+
const _collapseAdjacentRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/collapseAdjacentRules"));
|
|
16
|
+
const _collapseDuplicateDeclarations = /*#__PURE__*/ _interopRequireDefault(require("./lib/collapseDuplicateDeclarations"));
|
|
17
|
+
const _partitionApplyAtRules = /*#__PURE__*/ _interopRequireDefault(require("./lib/partitionApplyAtRules"));
|
|
18
|
+
const _detectNesting = /*#__PURE__*/ _interopRequireDefault(require("./lib/detectNesting"));
|
|
19
|
+
const _setupContextUtils = require("./lib/setupContextUtils");
|
|
20
|
+
const _featureFlags = require("./featureFlags");
|
|
17
21
|
function _interopRequireDefault(obj) {
|
|
18
22
|
return obj && obj.__esModule ? obj : {
|
|
19
23
|
default: obj
|
|
@@ -21,31 +25,38 @@ function _interopRequireDefault(obj) {
|
|
|
21
25
|
}
|
|
22
26
|
function processTailwindFeatures(setupContext) {
|
|
23
27
|
return function(root, result) {
|
|
24
|
-
let tailwindDirectives = (0, _normalizeTailwindDirectives
|
|
28
|
+
let { tailwindDirectives , applyDirectives } = (0, _normalizeTailwindDirectives.default)(root);
|
|
29
|
+
(0, _detectNesting.default)()(root, result);
|
|
30
|
+
// Partition apply rules that are found in the css
|
|
31
|
+
// itself.
|
|
32
|
+
(0, _partitionApplyAtRules.default)()(root, result);
|
|
25
33
|
let context = setupContext({
|
|
26
34
|
tailwindDirectives,
|
|
35
|
+
applyDirectives,
|
|
27
36
|
registerDependency (dependency) {
|
|
28
37
|
result.messages.push({
|
|
29
|
-
plugin:
|
|
38
|
+
plugin: "tailwindcss",
|
|
30
39
|
parent: result.opts.from,
|
|
31
40
|
...dependency
|
|
32
41
|
});
|
|
33
42
|
},
|
|
34
43
|
createContext (tailwindConfig, changedContent) {
|
|
35
|
-
return (0, _setupContextUtils
|
|
44
|
+
return (0, _setupContextUtils.createContext)(tailwindConfig, changedContent, root);
|
|
36
45
|
}
|
|
37
46
|
})(root, result);
|
|
38
|
-
if (context.tailwindConfig.separator ===
|
|
47
|
+
if (context.tailwindConfig.separator === "-") {
|
|
39
48
|
throw new Error("The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead.");
|
|
40
49
|
}
|
|
41
|
-
(0, _featureFlags
|
|
42
|
-
(0,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(0,
|
|
46
|
-
(0,
|
|
47
|
-
(0,
|
|
48
|
-
(0,
|
|
49
|
-
(0,
|
|
50
|
+
(0, _featureFlags.issueFlagNotices)(context.tailwindConfig);
|
|
51
|
+
(0, _expandTailwindAtRules.default)(context)(root, result);
|
|
52
|
+
// Partition apply rules that are generated by
|
|
53
|
+
// addComponents, addUtilities and so on.
|
|
54
|
+
(0, _partitionApplyAtRules.default)()(root, result);
|
|
55
|
+
(0, _expandApplyAtRules.default)(context)(root, result);
|
|
56
|
+
(0, _evaluateTailwindFunctions.default)(context)(root, result);
|
|
57
|
+
(0, _substituteScreenAtRules.default)(context)(root, result);
|
|
58
|
+
(0, _resolveDefaultsAtRules.default)(context)(root, result);
|
|
59
|
+
(0, _collapseAdjacentRules.default)(context)(root, result);
|
|
60
|
+
(0, _collapseDuplicateDeclarations.default)(context)(root, result);
|
|
50
61
|
};
|
|
51
62
|
}
|