tailwindcss 0.0.0-insiders.ea80db2 → 0.0.0-insiders.eae2b7a
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 +13 -9
- package/defaultTheme.d.ts +2 -1
- package/index.css +5 -0
- package/lib/cli/build/index.js +57 -0
- package/lib/cli/build/plugin.js +427 -0
- package/lib/cli/build/utils.js +88 -0
- package/lib/cli/build/watching.js +182 -0
- package/lib/cli/help/index.js +73 -0
- package/lib/cli/index.js +231 -0
- package/lib/cli/init/index.js +63 -0
- package/lib/cli.js +1 -759
- package/lib/corePluginList.js +12 -3
- package/lib/corePlugins.js +2308 -1739
- package/lib/css/preflight.css +13 -5
- package/lib/featureFlags.js +50 -25
- package/lib/index.js +1 -40
- package/lib/lib/cacheInvalidation.js +48 -25
- package/lib/lib/collapseAdjacentRules.js +17 -10
- package/lib/lib/collapseDuplicateDeclarations.js +13 -8
- package/lib/lib/content.js +207 -0
- package/lib/lib/defaultExtractor.js +232 -33
- package/lib/lib/detectNesting.js +21 -10
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +316 -215
- package/lib/lib/expandTailwindAtRules.js +167 -115
- package/lib/lib/findAtConfigPath.js +46 -0
- package/lib/lib/generateRules.js +444 -211
- package/lib/lib/getModuleDependencies.js +88 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +29 -39
- package/lib/lib/offsets.js +306 -0
- package/lib/lib/partitionApplyAtRules.js +13 -8
- package/lib/lib/regex.js +74 -0
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +96 -74
- package/lib/lib/setupContextUtils.js +672 -300
- package/lib/lib/setupTrackingContext.js +63 -68
- package/lib/lib/sharedState.js +44 -17
- package/lib/lib/substituteScreenAtRules.js +14 -10
- package/lib/plugin.js +160 -0
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +10 -6
- package/lib/postcss-plugins/nesting/plugin.js +24 -20
- package/lib/processTailwindFeatures.js +34 -29
- package/lib/public/colors.js +272 -246
- package/lib/public/create-plugin.js +9 -5
- package/lib/public/default-config.js +10 -6
- package/lib/public/default-theme.js +10 -6
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +11 -6
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +6 -1
- package/lib/util/buildMediaQuery.js +13 -6
- package/lib/util/cloneDeep.js +9 -6
- package/lib/util/cloneNodes.js +12 -3
- package/lib/util/color.js +66 -50
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +7 -2
- package/lib/util/createPlugin.js +8 -5
- package/lib/util/createUtilityPlugin.js +13 -9
- package/lib/util/dataTypes.js +182 -111
- package/lib/util/defaults.js +12 -7
- package/lib/util/escapeClassName.js +13 -8
- package/lib/util/escapeCommas.js +7 -2
- package/lib/util/flattenColorPalette.js +11 -10
- package/lib/util/formatVariantSelector.js +228 -151
- package/lib/util/getAllConfigs.js +33 -12
- package/lib/util/hashConfig.js +9 -4
- package/lib/util/isKeyframeRule.js +7 -2
- package/lib/util/isPlainObject.js +7 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
- package/lib/util/log.js +40 -13
- package/lib/util/nameClass.js +27 -10
- package/lib/util/negateValue.js +25 -8
- package/lib/util/normalizeConfig.js +155 -87
- package/lib/util/normalizeScreens.js +127 -8
- package/lib/util/parseAnimationValue.js +44 -40
- package/lib/util/parseBoxShadowValue.js +33 -62
- package/lib/util/parseDependency.js +39 -55
- package/lib/util/parseGlob.js +36 -0
- package/lib/util/parseObjectStyles.js +15 -10
- package/lib/util/pluginUtils.js +154 -59
- package/lib/util/prefixSelector.js +29 -10
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +31 -0
- package/lib/util/resolveConfig.js +96 -95
- package/lib/util/resolveConfigPath.js +29 -10
- package/lib/util/responsive.js +11 -6
- package/lib/util/splitAtTopLevelOnly.js +51 -0
- package/lib/util/tap.js +6 -1
- package/lib/util/toColorValue.js +7 -2
- package/lib/util/toPath.js +22 -4
- package/lib/util/transformThemeValue.js +40 -26
- package/lib/util/validateConfig.js +48 -0
- package/lib/util/validateFormalSyntax.js +26 -0
- package/lib/util/withAlphaVariable.js +27 -15
- 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 +54 -52
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +53 -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/index.js +53 -0
- package/src/cli/build/plugin.js +465 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +229 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +217 -0
- package/src/cli/init/index.js +79 -0
- package/src/cli.js +1 -836
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +576 -106
- package/src/css/preflight.css +13 -5
- package/src/featureFlags.js +17 -3
- package/src/index.js +1 -42
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/content.js +240 -0
- package/src/lib/defaultExtractor.js +202 -35
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +82 -8
- package/src/lib/expandApplyAtRules.js +322 -189
- package/src/lib/expandTailwindAtRules.js +82 -59
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +413 -132
- 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 +373 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +570 -151
- package/src/lib/setupTrackingContext.js +44 -58
- package/src/lib/sharedState.js +13 -4
- package/src/plugin.js +128 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- 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/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +5 -1
- package/src/util/color.js +34 -17
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +67 -23
- package/src/util/formatVariantSelector.js +264 -144
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +25 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +78 -20
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +118 -23
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -62
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +36 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- 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} +215 -165
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -1
- 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 +102 -56
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +372 -0
- package/types/index.d.ts +7 -1
- package/CHANGELOG.md +0 -2099
- package/lib/cli-peer-dependencies.js +0 -15
- package/lib/constants.js +0 -37
- package/peers/index.js +0 -75156
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli-peer-dependencies.js +0 -9
- package/src/constants.js +0 -17
- package/types.d.ts +0 -1
|
@@ -1,26 +1,35 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
4
|
value: true
|
|
4
5
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
Object.defineProperty(exports, // DISABLE_TOUCH = TRUE
|
|
7
|
+
// Retrieve an existing context from cache if possible (since contexts are unique per
|
|
8
|
+
// source path), or set up a new one (including setting up watchers and registering
|
|
9
|
+
// plugins) then return it
|
|
10
|
+
"default", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return setupTrackingContext;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
17
|
+
const _quicklru = /*#__PURE__*/ _interop_require_default(require("@alloc/quick-lru"));
|
|
18
|
+
const _hashConfig = /*#__PURE__*/ _interop_require_default(require("../util/hashConfig"));
|
|
19
|
+
const _resolveconfig = /*#__PURE__*/ _interop_require_default(require("../public/resolve-config"));
|
|
20
|
+
const _resolveConfigPath = /*#__PURE__*/ _interop_require_default(require("../util/resolveConfigPath"));
|
|
21
|
+
const _setupContextUtils = require("./setupContextUtils");
|
|
22
|
+
const _parseDependency = /*#__PURE__*/ _interop_require_default(require("../util/parseDependency"));
|
|
23
|
+
const _validateConfig = require("../util/validateConfig.js");
|
|
24
|
+
const _content = require("./content.js");
|
|
25
|
+
const _loadconfig = require("../lib/load-config");
|
|
26
|
+
const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("./getModuleDependencies"));
|
|
27
|
+
function _interop_require_default(obj) {
|
|
19
28
|
return obj && obj.__esModule ? obj : {
|
|
20
29
|
default: obj
|
|
21
30
|
};
|
|
22
31
|
}
|
|
23
|
-
let configPathCache = new
|
|
32
|
+
let configPathCache = new _quicklru.default({
|
|
24
33
|
maxSize: 100
|
|
25
34
|
});
|
|
26
35
|
let candidateFilesCache = new WeakMap();
|
|
@@ -28,18 +37,15 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
28
37
|
if (candidateFilesCache.has(context)) {
|
|
29
38
|
return candidateFilesCache.get(context);
|
|
30
39
|
}
|
|
31
|
-
let candidateFiles =
|
|
32
|
-
).map((contentPath)=>(0, _normalizePath).default(contentPath)
|
|
33
|
-
);
|
|
40
|
+
let candidateFiles = (0, _content.parseCandidateFiles)(context, tailwindConfig);
|
|
34
41
|
return candidateFilesCache.set(context, candidateFiles).get(context);
|
|
35
42
|
}
|
|
36
43
|
// Get the config object based on a path
|
|
37
44
|
function getTailwindConfig(configOrPath) {
|
|
38
|
-
let userConfigPath = (0, _resolveConfigPath
|
|
45
|
+
let userConfigPath = (0, _resolveConfigPath.default)(configOrPath);
|
|
39
46
|
if (userConfigPath !== null) {
|
|
40
47
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] = configPathCache.get(userConfigPath) || [];
|
|
41
|
-
let newDeps = (0, _getModuleDependencies
|
|
42
|
-
);
|
|
48
|
+
let newDeps = (0, _getModuleDependencies.default)(userConfigPath);
|
|
43
49
|
let modified = false;
|
|
44
50
|
let newModified = new Map();
|
|
45
51
|
for (let file of newDeps){
|
|
@@ -59,11 +65,11 @@ function getTailwindConfig(configOrPath) {
|
|
|
59
65
|
];
|
|
60
66
|
}
|
|
61
67
|
// It has changed (based on timestamps), or first run
|
|
62
|
-
for (let
|
|
63
|
-
delete require.cache[
|
|
68
|
+
for (let file of newDeps){
|
|
69
|
+
delete require.cache[file];
|
|
64
70
|
}
|
|
65
|
-
let newConfig = (0,
|
|
66
|
-
let newHash = (0, _hashConfig
|
|
71
|
+
let newConfig = (0, _validateConfig.validateConfig)((0, _resolveconfig.default)((0, _loadconfig.loadConfig)(userConfigPath)));
|
|
72
|
+
let newHash = (0, _hashConfig.default)(newConfig);
|
|
67
73
|
configPathCache.set(userConfigPath, [
|
|
68
74
|
newConfig,
|
|
69
75
|
newHash,
|
|
@@ -77,47 +83,17 @@ function getTailwindConfig(configOrPath) {
|
|
|
77
83
|
newDeps
|
|
78
84
|
];
|
|
79
85
|
}
|
|
86
|
+
var _configOrPath_config, _ref;
|
|
80
87
|
// It's a plain object, not a path
|
|
81
|
-
let newConfig = (0,
|
|
88
|
+
let newConfig = (0, _resolveconfig.default)((_ref = (_configOrPath_config = configOrPath === null || configOrPath === void 0 ? void 0 : configOrPath.config) !== null && _configOrPath_config !== void 0 ? _configOrPath_config : configOrPath) !== null && _ref !== void 0 ? _ref : {});
|
|
89
|
+
newConfig = (0, _validateConfig.validateConfig)(newConfig);
|
|
82
90
|
return [
|
|
83
91
|
newConfig,
|
|
84
92
|
null,
|
|
85
|
-
(0, _hashConfig
|
|
93
|
+
(0, _hashConfig.default)(newConfig),
|
|
86
94
|
[]
|
|
87
95
|
];
|
|
88
96
|
}
|
|
89
|
-
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
90
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === 'string'
|
|
91
|
-
).map(({ raw , extension ='html' })=>({
|
|
92
|
-
content: raw,
|
|
93
|
-
extension
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)){
|
|
97
|
-
let content = _fs.default.readFileSync(changedFile, 'utf8');
|
|
98
|
-
let extension = _path.default.extname(changedFile).slice(1);
|
|
99
|
-
changedContent.push({
|
|
100
|
-
content,
|
|
101
|
-
extension
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return changedContent;
|
|
105
|
-
}
|
|
106
|
-
function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
107
|
-
let changedFiles = new Set();
|
|
108
|
-
_sharedState.env.DEBUG && console.time('Finding changed files');
|
|
109
|
-
let files = _fastGlob.default.sync(candidateFiles);
|
|
110
|
-
for (let file of files){
|
|
111
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;
|
|
112
|
-
let modified = _fs.default.statSync(file).mtimeMs;
|
|
113
|
-
if (modified > prevModified) {
|
|
114
|
-
changedFiles.add(file);
|
|
115
|
-
fileModifiedMap.set(file, modified);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
_sharedState.env.DEBUG && console.timeEnd('Finding changed files');
|
|
119
|
-
return changedFiles;
|
|
120
|
-
}
|
|
121
97
|
function setupTrackingContext(configOrPath) {
|
|
122
98
|
return ({ tailwindDirectives , registerDependency })=>{
|
|
123
99
|
return (root, result)=>{
|
|
@@ -134,12 +110,13 @@ function setupTrackingContext(configOrPath) {
|
|
|
134
110
|
contextDependencies.add(result.opts.from);
|
|
135
111
|
// Add all css @import dependencies as context dependencies.
|
|
136
112
|
for (let message of result.messages){
|
|
137
|
-
if (message.type ===
|
|
113
|
+
if (message.type === "dependency") {
|
|
138
114
|
contextDependencies.add(message.file);
|
|
139
115
|
}
|
|
140
116
|
}
|
|
141
117
|
}
|
|
142
|
-
let [context] = (0, _setupContextUtils
|
|
118
|
+
let [context, , mTimesToCommit] = (0, _setupContextUtils.getContext)(root, result, tailwindConfig, userConfigPath, tailwindConfigHash, contextDependencies);
|
|
119
|
+
let fileModifiedMap = (0, _setupContextUtils.getFileModifiedMap)(context);
|
|
143
120
|
let candidateFiles = getCandidateFiles(context, tailwindConfig);
|
|
144
121
|
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
145
122
|
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
@@ -147,24 +124,42 @@ function setupTrackingContext(configOrPath) {
|
|
|
147
124
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
148
125
|
// in another file since independent sources are effectively isolated.
|
|
149
126
|
if (tailwindDirectives.size > 0) {
|
|
150
|
-
let fileModifiedMap = (0, _setupContextUtils).getFileModifiedMap(context);
|
|
151
127
|
// Add template paths as postcss dependencies.
|
|
152
|
-
for (let
|
|
153
|
-
let dependency
|
|
154
|
-
if (dependency) {
|
|
128
|
+
for (let contentPath of candidateFiles){
|
|
129
|
+
for (let dependency of (0, _parseDependency.default)(contentPath)){
|
|
155
130
|
registerDependency(dependency);
|
|
156
131
|
}
|
|
157
132
|
}
|
|
158
|
-
|
|
159
|
-
|
|
133
|
+
let [changedContent, contentMTimesToCommit] = (0, _content.resolvedChangedContent)(context, candidateFiles, fileModifiedMap);
|
|
134
|
+
for (let content of changedContent){
|
|
135
|
+
context.changedContent.push(content);
|
|
136
|
+
}
|
|
137
|
+
// Add the mtimes of the content files to the commit list
|
|
138
|
+
// We can overwrite the existing values because unconditionally
|
|
139
|
+
// This is because:
|
|
140
|
+
// 1. Most of the files here won't be in the map yet
|
|
141
|
+
// 2. If they are that means it's a context dependency
|
|
142
|
+
// and we're reading this after the context. This means
|
|
143
|
+
// that the mtime we just read is strictly >= the context
|
|
144
|
+
// mtime. Unless the user / os is doing something weird
|
|
145
|
+
// in which the mtime would be going backwards. If that
|
|
146
|
+
// happens there's already going to be problems.
|
|
147
|
+
for (let [path, mtime] of contentMTimesToCommit.entries()){
|
|
148
|
+
mTimesToCommit.set(path, mtime);
|
|
160
149
|
}
|
|
161
150
|
}
|
|
162
151
|
for (let file of configDependencies){
|
|
163
152
|
registerDependency({
|
|
164
|
-
type:
|
|
153
|
+
type: "dependency",
|
|
165
154
|
file
|
|
166
155
|
});
|
|
167
156
|
}
|
|
157
|
+
// "commit" the new modified time for all context deps
|
|
158
|
+
// We do this here because we want content tracking to
|
|
159
|
+
// read the "old" mtime even when it's a context dependency.
|
|
160
|
+
for (let [path, mtime] of mTimesToCommit.entries()){
|
|
161
|
+
fileModifiedMap.set(path, mtime);
|
|
162
|
+
}
|
|
168
163
|
return context;
|
|
169
164
|
};
|
|
170
165
|
};
|
package/lib/lib/sharedState.js
CHANGED
|
@@ -2,32 +2,60 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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: function() {
|
|
13
|
+
return env;
|
|
14
|
+
},
|
|
15
|
+
contextMap: function() {
|
|
16
|
+
return contextMap;
|
|
17
|
+
},
|
|
18
|
+
configContextMap: function() {
|
|
19
|
+
return configContextMap;
|
|
20
|
+
},
|
|
21
|
+
contextSourcesMap: function() {
|
|
22
|
+
return contextSourcesMap;
|
|
23
|
+
},
|
|
24
|
+
sourceHashMap: function() {
|
|
25
|
+
return sourceHashMap;
|
|
26
|
+
},
|
|
27
|
+
NOT_ON_DEMAND: function() {
|
|
28
|
+
return NOT_ON_DEMAND;
|
|
29
|
+
},
|
|
30
|
+
NONE: function() {
|
|
31
|
+
return NONE;
|
|
32
|
+
},
|
|
33
|
+
resolveDebug: function() {
|
|
34
|
+
return resolveDebug;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const env = typeof process !== "undefined" ? {
|
|
8
38
|
NODE_ENV: process.env.NODE_ENV,
|
|
9
39
|
DEBUG: resolveDebug(process.env.DEBUG)
|
|
40
|
+
} : {
|
|
41
|
+
NODE_ENV: "production",
|
|
42
|
+
DEBUG: false
|
|
10
43
|
};
|
|
11
|
-
exports.env = env;
|
|
12
44
|
const contextMap = new Map();
|
|
13
|
-
exports.contextMap = contextMap;
|
|
14
45
|
const configContextMap = new Map();
|
|
15
|
-
exports.configContextMap = configContextMap;
|
|
16
46
|
const contextSourcesMap = new Map();
|
|
17
|
-
exports.contextSourcesMap = contextSourcesMap;
|
|
18
47
|
const sourceHashMap = new Map();
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
exports.NOT_ON_DEMAND = NOT_ON_DEMAND;
|
|
48
|
+
const NOT_ON_DEMAND = new String("*");
|
|
49
|
+
const NONE = Symbol("__NONE__");
|
|
22
50
|
function resolveDebug(debug) {
|
|
23
51
|
if (debug === undefined) {
|
|
24
52
|
return false;
|
|
25
53
|
}
|
|
26
54
|
// Environment variables are strings, so convert to boolean
|
|
27
|
-
if (debug ===
|
|
55
|
+
if (debug === "true" || debug === "1") {
|
|
28
56
|
return true;
|
|
29
57
|
}
|
|
30
|
-
if (debug ===
|
|
58
|
+
if (debug === "false" || debug === "0") {
|
|
31
59
|
return false;
|
|
32
60
|
}
|
|
33
61
|
// Keep the debug convention into account:
|
|
@@ -35,17 +63,16 @@ function resolveDebug(debug) {
|
|
|
35
63
|
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
36
64
|
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
37
65
|
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
38
|
-
if (debug ===
|
|
66
|
+
if (debug === "*") {
|
|
39
67
|
return true;
|
|
40
68
|
}
|
|
41
|
-
let debuggers = debug.split(
|
|
42
|
-
);
|
|
69
|
+
let debuggers = debug.split(",").map((d)=>d.split(":")[0]);
|
|
43
70
|
// Ignoring tailwindcss
|
|
44
|
-
if (debuggers.includes(
|
|
71
|
+
if (debuggers.includes("-tailwindcss")) {
|
|
45
72
|
return false;
|
|
46
73
|
}
|
|
47
74
|
// Including tailwindcss
|
|
48
|
-
if (debuggers.includes(
|
|
75
|
+
if (debuggers.includes("tailwindcss")) {
|
|
49
76
|
return true;
|
|
50
77
|
}
|
|
51
78
|
return false;
|
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _normalizeScreens = require("../util/normalizeScreens");
|
|
12
|
+
const _buildMediaQuery = /*#__PURE__*/ _interop_require_default(require("../util/buildMediaQuery"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
9
14
|
return obj && obj.__esModule ? obj : {
|
|
10
15
|
default: obj
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
18
|
function _default({ tailwindConfig: { theme } }) {
|
|
14
19
|
return function(css) {
|
|
15
|
-
css.walkAtRules(
|
|
20
|
+
css.walkAtRules("screen", (atRule)=>{
|
|
16
21
|
let screen = atRule.params;
|
|
17
|
-
let screens = (0, _normalizeScreens
|
|
18
|
-
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
-
);
|
|
22
|
+
let screens = (0, _normalizeScreens.normalizeScreens)(theme.screens);
|
|
23
|
+
let screenDefinition = screens.find(({ name })=>name === screen);
|
|
20
24
|
if (!screenDefinition) {
|
|
21
25
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
22
26
|
}
|
|
23
|
-
atRule.name =
|
|
24
|
-
atRule.params = (0, _buildMediaQuery
|
|
27
|
+
atRule.name = "media";
|
|
28
|
+
atRule.params = (0, _buildMediaQuery.default)(screenDefinition);
|
|
25
29
|
});
|
|
26
30
|
};
|
|
27
31
|
}
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
6
|
+
const _lightningcss = /*#__PURE__*/ _interop_require_wildcard(require("lightningcss"));
|
|
7
|
+
const _browserslist = /*#__PURE__*/ _interop_require_default(require("browserslist"));
|
|
8
|
+
const _setupTrackingContext = /*#__PURE__*/ _interop_require_default(require("./lib/setupTrackingContext"));
|
|
9
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interop_require_default(require("./processTailwindFeatures"));
|
|
10
|
+
const _sharedState = require("./lib/sharedState");
|
|
11
|
+
const _findAtConfigPath = require("./lib/findAtConfigPath");
|
|
12
|
+
const _handleImportAtRules = require("./lib/handleImportAtRules");
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
19
|
+
if (typeof WeakMap !== "function") return null;
|
|
20
|
+
var cacheBabelInterop = new WeakMap();
|
|
21
|
+
var cacheNodeInterop = new WeakMap();
|
|
22
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
23
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
24
|
+
})(nodeInterop);
|
|
25
|
+
}
|
|
26
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
27
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
31
|
+
return {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
36
|
+
if (cache && cache.has(obj)) {
|
|
37
|
+
return cache.get(obj);
|
|
38
|
+
}
|
|
39
|
+
var newObj = {};
|
|
40
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
+
for(var key in obj){
|
|
42
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
+
if (desc && (desc.get || desc.set)) {
|
|
45
|
+
Object.defineProperty(newObj, key, desc);
|
|
46
|
+
} else {
|
|
47
|
+
newObj[key] = obj[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
if (cache) {
|
|
53
|
+
cache.set(obj, newObj);
|
|
54
|
+
}
|
|
55
|
+
return newObj;
|
|
56
|
+
}
|
|
57
|
+
module.exports = function tailwindcss(configOrPath) {
|
|
58
|
+
return {
|
|
59
|
+
postcssPlugin: "tailwindcss",
|
|
60
|
+
plugins: [
|
|
61
|
+
_sharedState.env.DEBUG && function(root) {
|
|
62
|
+
console.log("\n");
|
|
63
|
+
console.time("JIT TOTAL");
|
|
64
|
+
return root;
|
|
65
|
+
},
|
|
66
|
+
...(0, _handleImportAtRules.handleImportAtRules)(),
|
|
67
|
+
function(root, result) {
|
|
68
|
+
var _findAtConfigPath1;
|
|
69
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
70
|
+
// path for the file being processed
|
|
71
|
+
configOrPath = (_findAtConfigPath1 = (0, _findAtConfigPath.findAtConfigPath)(root, result)) !== null && _findAtConfigPath1 !== void 0 ? _findAtConfigPath1 : configOrPath;
|
|
72
|
+
let context = (0, _setupTrackingContext.default)(configOrPath);
|
|
73
|
+
if (root.type === "document") {
|
|
74
|
+
let roots = root.nodes.filter((node)=>node.type === "root");
|
|
75
|
+
for (const root of roots){
|
|
76
|
+
if (root.type === "root") {
|
|
77
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
(0, _processTailwindFeatures.default)(context)(root, result);
|
|
83
|
+
},
|
|
84
|
+
function lightningCssPlugin(_root, result) {
|
|
85
|
+
var _intermediateResult_map, _intermediateResult_map_toJSON;
|
|
86
|
+
var _result_map;
|
|
87
|
+
let map = (_result_map = result.map) !== null && _result_map !== void 0 ? _result_map : result.opts.map;
|
|
88
|
+
let intermediateResult = result.root.toResult({
|
|
89
|
+
map: map ? {
|
|
90
|
+
inline: true
|
|
91
|
+
} : false
|
|
92
|
+
});
|
|
93
|
+
var _intermediateResult_map_toJSON1;
|
|
94
|
+
let intermediateMap = (_intermediateResult_map_toJSON1 = (_intermediateResult_map = intermediateResult.map) === null || _intermediateResult_map === void 0 ? void 0 : (_intermediateResult_map_toJSON = _intermediateResult_map.toJSON) === null || _intermediateResult_map_toJSON === void 0 ? void 0 : _intermediateResult_map_toJSON.call(_intermediateResult_map)) !== null && _intermediateResult_map_toJSON1 !== void 0 ? _intermediateResult_map_toJSON1 : map;
|
|
95
|
+
try {
|
|
96
|
+
var _browserslist_findConfig;
|
|
97
|
+
var _result_opts_from;
|
|
98
|
+
let resolvedBrowsersListConfig = (_browserslist_findConfig = _browserslist.default.findConfig((_result_opts_from = result.opts.from) !== null && _result_opts_from !== void 0 ? _result_opts_from : process.cwd())) === null || _browserslist_findConfig === void 0 ? void 0 : _browserslist_findConfig.defaults;
|
|
99
|
+
let defaultBrowsersListConfig = require("../package.json").browserslist;
|
|
100
|
+
let browsersListConfig = resolvedBrowsersListConfig !== null && resolvedBrowsersListConfig !== void 0 ? resolvedBrowsersListConfig : defaultBrowsersListConfig;
|
|
101
|
+
let transformed = _lightningcss.default.transform({
|
|
102
|
+
filename: result.opts.from,
|
|
103
|
+
code: Buffer.from(intermediateResult.css),
|
|
104
|
+
minify: false,
|
|
105
|
+
sourceMap: !!intermediateMap,
|
|
106
|
+
targets: _lightningcss.default.browserslistToTargets((0, _browserslist.default)(browsersListConfig)),
|
|
107
|
+
drafts: {
|
|
108
|
+
nesting: true,
|
|
109
|
+
customMedia: true
|
|
110
|
+
},
|
|
111
|
+
nonStandard: {
|
|
112
|
+
deepSelectorCombinator: true
|
|
113
|
+
},
|
|
114
|
+
include: _lightningcss.Features.Nesting,
|
|
115
|
+
exclude: _lightningcss.Features.LogicalProperties
|
|
116
|
+
});
|
|
117
|
+
let code = transformed.code.toString();
|
|
118
|
+
// https://postcss.org/api/#sourcemapoptions
|
|
119
|
+
if (intermediateMap && transformed.map != null) {
|
|
120
|
+
let prev = transformed.map.toString();
|
|
121
|
+
if (typeof intermediateMap === "object") {
|
|
122
|
+
intermediateMap.prev = prev;
|
|
123
|
+
} else {
|
|
124
|
+
code = `${code}\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(prev).toString("base64")} */`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
result.root = _postcss.default.parse(code, {
|
|
128
|
+
...result.opts,
|
|
129
|
+
map: intermediateMap
|
|
130
|
+
});
|
|
131
|
+
} catch (err) {
|
|
132
|
+
if (err.source && typeof process !== "undefined" && process.env.JEST_WORKER_ID) {
|
|
133
|
+
let lines = err.source.split("\n");
|
|
134
|
+
err = new Error([
|
|
135
|
+
"Error formatting using Lightning CSS:",
|
|
136
|
+
"",
|
|
137
|
+
...[
|
|
138
|
+
"```css",
|
|
139
|
+
...lines.slice(Math.max(err.loc.line - 3, 0), err.loc.line),
|
|
140
|
+
" ".repeat(err.loc.column - 1) + "^-- " + err.toString(),
|
|
141
|
+
...lines.slice(err.loc.line, err.loc.line + 2),
|
|
142
|
+
"```"
|
|
143
|
+
]
|
|
144
|
+
].join("\n"));
|
|
145
|
+
}
|
|
146
|
+
if (Error.captureStackTrace) {
|
|
147
|
+
Error.captureStackTrace(err, lightningCssPlugin);
|
|
148
|
+
}
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
_sharedState.env.DEBUG && function(root) {
|
|
153
|
+
console.timeEnd("JIT TOTAL");
|
|
154
|
+
console.log("\n");
|
|
155
|
+
return root;
|
|
156
|
+
}
|
|
157
|
+
].filter(Boolean)
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
module.exports.postcss = true;
|
|
@@ -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
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _plugin = require("./plugin");
|
|
12
|
+
const _default = Object.assign(function(opts) {
|
|
8
13
|
return {
|
|
9
|
-
postcssPlugin:
|
|
14
|
+
postcssPlugin: "tailwindcss/nesting",
|
|
10
15
|
Once (root, { result }) {
|
|
11
|
-
return (0, _plugin
|
|
16
|
+
return (0, _plugin.nesting)(opts)(root, result);
|
|
12
17
|
}
|
|
13
18
|
};
|
|
14
19
|
}, {
|
|
15
20
|
postcss: true
|
|
16
21
|
});
|
|
17
|
-
exports.default = _default;
|
|
@@ -2,47 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "nesting", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return nesting;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
|
12
|
+
const _postcssnested = /*#__PURE__*/ _interop_require_default(require("postcss-nested"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
9
14
|
return obj && obj.__esModule ? obj : {
|
|
10
15
|
default: obj
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
|
-
function nesting(opts =
|
|
18
|
+
function nesting(opts = _postcssnested.default) {
|
|
14
19
|
return (root, result)=>{
|
|
15
|
-
root.walkAtRules(
|
|
16
|
-
rule.name =
|
|
20
|
+
root.walkAtRules("screen", (rule)=>{
|
|
21
|
+
rule.name = "media";
|
|
17
22
|
rule.params = `screen(${rule.params})`;
|
|
18
23
|
});
|
|
19
|
-
root.walkAtRules(
|
|
24
|
+
root.walkAtRules("apply", (rule)=>{
|
|
20
25
|
rule.before(_postcss.default.decl({
|
|
21
|
-
prop:
|
|
26
|
+
prop: "__apply",
|
|
22
27
|
value: rule.params,
|
|
23
28
|
source: rule.source
|
|
24
29
|
}));
|
|
25
30
|
rule.remove();
|
|
26
31
|
});
|
|
27
32
|
let plugin = (()=>{
|
|
28
|
-
var
|
|
29
|
-
if (typeof opts ===
|
|
33
|
+
var _opts_hasOwnProperty;
|
|
34
|
+
if (typeof opts === "function" || typeof opts === "object" && (opts === null || opts === void 0 ? void 0 : (_opts_hasOwnProperty = opts.hasOwnProperty) === null || _opts_hasOwnProperty === void 0 ? void 0 : _opts_hasOwnProperty.call(opts, "postcssPlugin"))) {
|
|
30
35
|
return opts;
|
|
31
36
|
}
|
|
32
|
-
if (typeof opts ===
|
|
37
|
+
if (typeof opts === "string") {
|
|
33
38
|
return require(opts);
|
|
34
39
|
}
|
|
35
40
|
if (Object.keys(opts).length <= 0) {
|
|
36
|
-
return
|
|
41
|
+
return _postcssnested.default;
|
|
37
42
|
}
|
|
38
|
-
throw new Error(
|
|
43
|
+
throw new Error("tailwindcss/nesting should be loaded with a nesting plugin.");
|
|
39
44
|
})();
|
|
40
|
-
(0, _postcss
|
|
45
|
+
(0, _postcss.default)([
|
|
41
46
|
plugin
|
|
42
47
|
]).process(root, result.opts).sync();
|
|
43
|
-
root.walkDecls(
|
|
48
|
+
root.walkDecls("__apply", (decl)=>{
|
|
44
49
|
decl.before(_postcss.default.atRule({
|
|
45
|
-
name:
|
|
50
|
+
name: "apply",
|
|
46
51
|
params: decl.value,
|
|
47
52
|
source: decl.source
|
|
48
53
|
}));
|
|
@@ -62,13 +67,12 @@ function nesting(opts = _postcssNested.default) {
|
|
|
62
67
|
*
|
|
63
68
|
* @param {import('postcss').Node} node
|
|
64
69
|
*/ function markDirty(node) {
|
|
65
|
-
if (!(
|
|
70
|
+
if (!("markDirty" in node)) {
|
|
66
71
|
return;
|
|
67
72
|
}
|
|
68
73
|
// Traverse the tree down to the leaf nodes
|
|
69
74
|
if (node.nodes) {
|
|
70
|
-
node.nodes.forEach((n)=>markDirty(n)
|
|
71
|
-
);
|
|
75
|
+
node.nodes.forEach((n)=>markDirty(n));
|
|
72
76
|
}
|
|
73
77
|
// If it's a leaf node mark it as dirty
|
|
74
78
|
// We do this here because marking a node as dirty
|