tailwindcss 2.0.1-compat → 2.0.4
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 +47 -1
- package/dist/base.css +3 -0
- package/dist/base.min.css +1 -1
- package/dist/tailwind-dark.css +7587 -0
- package/dist/tailwind-dark.min.css +1 -1
- package/dist/tailwind-experimental.css +27 -0
- package/dist/tailwind-experimental.min.css +1 -1
- package/dist/tailwind.css +27 -0
- package/dist/tailwind.min.css +1 -1
- package/dist/utilities.css +24 -0
- package/dist/utilities.min.css +1 -1
- package/lib/cli/commands/init.js +6 -4
- package/lib/cli/utils.js +22 -2
- package/lib/constants.js +9 -1
- package/lib/index.js +15 -12
- package/lib/index.postcss7.js +8 -6
- package/lib/lib/evaluateTailwindFunctions.js +1 -1
- package/lib/lib/substituteClassApplyAtRules.js +71 -32
- package/lib/lib/substituteTailwindAtRules.js +1 -1
- package/lib/plugins/css/preflight.css +1 -0
- package/lib/plugins/preflight.js +5 -1
- package/lib/plugins/ringOffsetColor.js +1 -1
- package/lib/plugins/ringOffsetWidth.js +1 -1
- package/lib/plugins/ringWidth.js +2 -2
- package/lib/processTailwindFeatures.js +4 -0
- package/lib/util/disposables.js +30 -0
- package/lib/util/transformThemeValue.js +4 -0
- package/lib/util/useMemo.js +14 -3
- package/lib/util/withAlphaVariable.js +2 -1
- package/package.json +25 -23
- package/scripts/compat.js +8 -2
- package/stubs/defaultConfig.stub.js +21 -20
- package/lib/index.postcss8.js +0 -92
- package/tailwind.config.js +0 -9
package/lib/cli/commands/init.js
CHANGED
|
@@ -27,7 +27,7 @@ const options = [{
|
|
|
27
27
|
description: 'Generate complete configuration file.'
|
|
28
28
|
}, {
|
|
29
29
|
usage: '-p',
|
|
30
|
-
description: 'Generate
|
|
30
|
+
description: 'Generate PostCSS config file.'
|
|
31
31
|
}];
|
|
32
32
|
exports.options = options;
|
|
33
33
|
const optionMap = {
|
|
@@ -47,8 +47,9 @@ exports.optionMap = optionMap;
|
|
|
47
47
|
function run(cliParams, cliOptions) {
|
|
48
48
|
return new Promise(resolve => {
|
|
49
49
|
utils.header();
|
|
50
|
+
const isModule = utils.isModule();
|
|
50
51
|
const full = cliOptions.full;
|
|
51
|
-
const file = cliParams[0] || constants.defaultConfigFile;
|
|
52
|
+
const file = cliParams[0] || (isModule ? constants.cjsConfigFile : constants.defaultConfigFile);
|
|
52
53
|
const simplePath = utils.getSimplePath(file);
|
|
53
54
|
utils.exists(file) && utils.die(colors.file(simplePath), 'already exists.');
|
|
54
55
|
const stubFile = full ? constants.defaultConfigStubFile : constants.simpleConfigStubFile;
|
|
@@ -58,9 +59,10 @@ function run(cliParams, cliOptions) {
|
|
|
58
59
|
utils.log(emoji.yes, 'Created Tailwind config file:', colors.file(simplePath));
|
|
59
60
|
|
|
60
61
|
if (cliOptions.postcss) {
|
|
61
|
-
const
|
|
62
|
+
const postCssConfigFile = isModule ? constants.cjsPostCssConfigFile : constants.defaultPostCssConfigFile;
|
|
63
|
+
const path = utils.getSimplePath(postCssConfigFile);
|
|
62
64
|
utils.exists(constants.defaultPostCssConfigFile) && utils.die(colors.file(path), 'already exists.');
|
|
63
|
-
utils.copyFile(constants.defaultPostCssConfigStubFile,
|
|
65
|
+
utils.copyFile(constants.defaultPostCssConfigStubFile, postCssConfigFile);
|
|
64
66
|
utils.log(emoji.yes, 'Created PostCSS config file:', colors.file(path));
|
|
65
67
|
}
|
|
66
68
|
|
package/lib/cli/utils.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.die = die;
|
|
|
13
13
|
exports.exists = exists;
|
|
14
14
|
exports.copyFile = copyFile;
|
|
15
15
|
exports.readFile = readFile;
|
|
16
|
+
exports.isModule = isModule;
|
|
16
17
|
exports.writeFile = writeFile;
|
|
17
18
|
exports.getSimplePath = getSimplePath;
|
|
18
19
|
|
|
@@ -20,18 +21,20 @@ var _fsExtra = require("fs-extra");
|
|
|
20
21
|
|
|
21
22
|
var _lodash = require("lodash");
|
|
22
23
|
|
|
24
|
+
var _path = _interopRequireDefault(require("path"));
|
|
25
|
+
|
|
23
26
|
var colors = _interopRequireWildcard(require("./colors"));
|
|
24
27
|
|
|
25
28
|
var emoji = _interopRequireWildcard(require("./emoji"));
|
|
26
29
|
|
|
27
30
|
var _package = _interopRequireDefault(require("../../package.json"));
|
|
28
31
|
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
31
32
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
32
33
|
|
|
33
34
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
35
|
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
35
38
|
/**
|
|
36
39
|
* Gets CLI parameters.
|
|
37
40
|
*
|
|
@@ -153,6 +156,23 @@ function copyFile(source, destination) {
|
|
|
153
156
|
function readFile(path) {
|
|
154
157
|
return (0, _fsExtra.readFileSync)(path, 'utf-8');
|
|
155
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Checks if current package.json uses type "module"
|
|
161
|
+
*
|
|
162
|
+
* @return {boolean}
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
function isModule() {
|
|
167
|
+
const pkgPath = _path.default.resolve('./package.json');
|
|
168
|
+
|
|
169
|
+
if (exists(pkgPath)) {
|
|
170
|
+
const pkg = JSON.parse(readFile(pkgPath));
|
|
171
|
+
return pkg.type && pkg.type === 'module';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
156
176
|
/**
|
|
157
177
|
* Writes content to file.
|
|
158
178
|
*
|
package/lib/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.defaultPostCssConfigStubFile = exports.simpleConfigStubFile = exports.defaultConfigStubFile = exports.defaultPostCssConfigFile = exports.defaultConfigFile = exports.cli = void 0;
|
|
6
|
+
exports.defaultPostCssConfigStubFile = exports.simpleConfigStubFile = exports.defaultConfigStubFile = exports.supportedPostCssConfigFile = exports.supportedConfigFiles = exports.cjsPostCssConfigFile = exports.cjsConfigFile = exports.defaultPostCssConfigFile = exports.defaultConfigFile = exports.cli = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
@@ -15,6 +15,14 @@ const defaultConfigFile = './tailwind.config.js';
|
|
|
15
15
|
exports.defaultConfigFile = defaultConfigFile;
|
|
16
16
|
const defaultPostCssConfigFile = './postcss.config.js';
|
|
17
17
|
exports.defaultPostCssConfigFile = defaultPostCssConfigFile;
|
|
18
|
+
const cjsConfigFile = './tailwind.config.cjs';
|
|
19
|
+
exports.cjsConfigFile = cjsConfigFile;
|
|
20
|
+
const cjsPostCssConfigFile = './postcss.config.cjs';
|
|
21
|
+
exports.cjsPostCssConfigFile = cjsPostCssConfigFile;
|
|
22
|
+
const supportedConfigFiles = [cjsConfigFile, defaultConfigFile];
|
|
23
|
+
exports.supportedConfigFiles = supportedConfigFiles;
|
|
24
|
+
const supportedPostCssConfigFile = [cjsPostCssConfigFile, defaultPostCssConfigFile];
|
|
25
|
+
exports.supportedPostCssConfigFile = supportedPostCssConfigFile;
|
|
18
26
|
|
|
19
27
|
const defaultConfigStubFile = _path.default.resolve(__dirname, '../stubs/defaultConfig.stub.js');
|
|
20
28
|
|
package/lib/index.js
CHANGED
|
@@ -6,8 +6,6 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
6
6
|
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
8
|
|
|
9
|
-
var _postcss = _interopRequireDefault(require("postcss"));
|
|
10
|
-
|
|
11
9
|
var _getModuleDependencies = _interopRequireDefault(require("./lib/getModuleDependencies"));
|
|
12
10
|
|
|
13
11
|
var _registerConfigAsDependency = _interopRequireDefault(require("./lib/registerConfigAsDependency"));
|
|
@@ -48,15 +46,17 @@ function resolveConfigPath(filePath) {
|
|
|
48
46
|
} // require('tailwindcss')
|
|
49
47
|
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
for (const configFile of _constants.supportedConfigFiles) {
|
|
50
|
+
try {
|
|
51
|
+
const configPath = _path.default.resolve(configFile);
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
_fs.default.accessSync(configPath);
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
55
|
+
return configPath;
|
|
56
|
+
} catch (err) {}
|
|
59
57
|
}
|
|
58
|
+
|
|
59
|
+
return undefined;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const getConfigFunction = config => () => {
|
|
@@ -77,7 +77,7 @@ const getConfigFunction = config => () => {
|
|
|
77
77
|
return (0, _resolveConfig.default)([...(0, _getAllConfigs.default)(configObject)]);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
module.exports = function (config) {
|
|
81
81
|
const plugins = [];
|
|
82
82
|
const resolvedConfigPath = resolveConfigPath(config);
|
|
83
83
|
|
|
@@ -85,7 +85,10 @@ const plugin = _postcss.default.plugin('tailwindcss', config => {
|
|
|
85
85
|
plugins.push((0, _registerConfigAsDependency.default)(resolvedConfigPath));
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
return
|
|
89
|
-
|
|
88
|
+
return {
|
|
89
|
+
postcssPlugin: 'tailwindcss',
|
|
90
|
+
plugins: [...plugins, (0, _processTailwindFeatures.default)(getConfigFunction(resolvedConfigPath || config)), _formatCSS.default]
|
|
91
|
+
};
|
|
92
|
+
};
|
|
90
93
|
|
|
91
|
-
module.exports =
|
|
94
|
+
module.exports.postcss = true;
|
package/lib/index.postcss7.js
CHANGED
|
@@ -48,15 +48,17 @@ function resolveConfigPath(filePath) {
|
|
|
48
48
|
} // require('tailwindcss')
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
for (const configFile of _constants.supportedConfigFiles) {
|
|
52
|
+
try {
|
|
53
|
+
const configPath = _path.default.resolve(configFile);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
_fs.default.accessSync(configPath);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
57
|
+
return configPath;
|
|
58
|
+
} catch (err) {}
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
return undefined;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const getConfigFunction = config => () => {
|
|
@@ -85,7 +85,7 @@ function validatePath(config, path, defaultValue) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
if (!(typeof value === 'string' || typeof value === 'number' || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
88
|
+
if (!(typeof value === 'string' || typeof value === 'number' || typeof value === 'function' || value instanceof String || value instanceof Number || Array.isArray(value))) {
|
|
89
89
|
let error = `'${pathString}' was found but does not resolve to a string.`;
|
|
90
90
|
|
|
91
91
|
if (_lodash.default.isObject(value)) {
|
|
@@ -31,13 +31,18 @@ var _useMemo = require("../util/useMemo");
|
|
|
31
31
|
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
33
|
|
|
34
|
-
function hasAtRule(css, atRule) {
|
|
35
|
-
let
|
|
36
|
-
css.walkAtRules(atRule, () => {
|
|
37
|
-
|
|
34
|
+
function hasAtRule(css, atRule, condition) {
|
|
35
|
+
let found = false;
|
|
36
|
+
css.walkAtRules(atRule, condition === undefined ? () => {
|
|
37
|
+
found = true;
|
|
38
38
|
return false;
|
|
39
|
+
} : node => {
|
|
40
|
+
if (condition(node)) {
|
|
41
|
+
found = true;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
39
44
|
});
|
|
40
|
-
return
|
|
45
|
+
return found;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
function cloneWithoutChildren(node) {
|
|
@@ -115,7 +120,7 @@ function buildUtilityMap(css, lookupTree) {
|
|
|
115
120
|
let index = 0;
|
|
116
121
|
const utilityMap = {};
|
|
117
122
|
|
|
118
|
-
function handle(rule) {
|
|
123
|
+
function handle(getRule, rule) {
|
|
119
124
|
const utilityNames = extractUtilityNames(rule.selector);
|
|
120
125
|
utilityNames.forEach((utilityName, i) => {
|
|
121
126
|
if (utilityMap[utilityName] === undefined) {
|
|
@@ -126,18 +131,29 @@ function buildUtilityMap(css, lookupTree) {
|
|
|
126
131
|
index,
|
|
127
132
|
utilityName,
|
|
128
133
|
classPosition: i,
|
|
129
|
-
|
|
130
|
-
get rule() {
|
|
131
|
-
return cloneRuleWithParent(rule);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
+
...getRule(rule)
|
|
134
135
|
});
|
|
135
136
|
index++;
|
|
136
137
|
});
|
|
137
|
-
}
|
|
138
|
+
} // Lookup tree is the big lookup tree, making the rule lazy allows us to save
|
|
139
|
+
// some memory because we don't need everything.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
lookupTree.walkRules(handle.bind(null, rule => ({
|
|
143
|
+
get rule() {
|
|
144
|
+
return cloneRuleWithParent(rule);
|
|
145
|
+
}
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
}))); // This is the end user's css. This might contain rules that we want to
|
|
148
|
+
// apply. We want immediate copies of everything in case that we have user
|
|
149
|
+
// defined classes that are recursively applied. Down below we are modifying
|
|
150
|
+
// the rules directly. We could do a better solution where we keep track of a
|
|
151
|
+
// dependency tree, but that is a bit more complex. Might revisit later,
|
|
152
|
+
// we'll see how this turns out!
|
|
153
|
+
|
|
154
|
+
css.walkRules(handle.bind(null, rule => ({
|
|
155
|
+
rule: cloneRuleWithParent(rule)
|
|
156
|
+
})));
|
|
141
157
|
return utilityMap;
|
|
142
158
|
}
|
|
143
159
|
|
|
@@ -231,14 +247,29 @@ function processApplyAtRules(css, lookupTree, config) {
|
|
|
231
247
|
|
|
232
248
|
const rulesToInsert = [];
|
|
233
249
|
applys.forEach(nearestParentRule === parent ? util => rulesToInsert.push(generateRulesFromApply(util, parent.selectors)) : util => util.rule.nodes.forEach(n => afterRule.append(n.clone())));
|
|
250
|
+
rulesToInsert.forEach(rule => {
|
|
251
|
+
if (rule.type === 'atrule') {
|
|
252
|
+
rule.walkRules(rule => {
|
|
253
|
+
rule.__tailwind = { ...rule.__tailwind,
|
|
254
|
+
important
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
rule.__tailwind = { ...rule.__tailwind,
|
|
259
|
+
important
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
});
|
|
234
263
|
|
|
235
264
|
const {
|
|
236
265
|
nodes
|
|
237
266
|
} = _lodash.default.tap(_postcss.default.root({
|
|
238
267
|
nodes: rulesToInsert
|
|
239
|
-
}), root =>
|
|
240
|
-
d
|
|
241
|
-
|
|
268
|
+
}), root => {
|
|
269
|
+
root.walkDecls(d => {
|
|
270
|
+
d.important = important;
|
|
271
|
+
});
|
|
272
|
+
});
|
|
242
273
|
|
|
243
274
|
const mergedRules = mergeAdjacentRules(nearestParentRule, [...nodes, afterRule]);
|
|
244
275
|
applyRule.remove();
|
|
@@ -263,34 +294,42 @@ function processApplyAtRules(css, lookupTree, config) {
|
|
|
263
294
|
return css;
|
|
264
295
|
}
|
|
265
296
|
|
|
266
|
-
let defaultTailwindTree =
|
|
297
|
+
let defaultTailwindTree = new Map();
|
|
267
298
|
|
|
268
299
|
function substituteClassApplyAtRules(config, getProcessedPlugins, configChanged) {
|
|
269
300
|
return function (css) {
|
|
270
301
|
// We can stop already when we don't have any @apply rules. Vue users: you're welcome!
|
|
271
302
|
if (!hasAtRule(css, 'apply')) {
|
|
272
303
|
return css;
|
|
273
|
-
}
|
|
304
|
+
}
|
|
274
305
|
|
|
306
|
+
let requiredTailwindAtRules = ['base', 'components', 'utilities'];
|
|
275
307
|
|
|
276
|
-
if (hasAtRule(css, 'tailwind'
|
|
308
|
+
if (hasAtRule(css, 'tailwind', node => {
|
|
309
|
+
let idx = requiredTailwindAtRules.indexOf(node.params);
|
|
310
|
+
if (idx !== -1) requiredTailwindAtRules.splice(idx, 1);
|
|
311
|
+
if (requiredTailwindAtRules.length <= 0) return true;
|
|
312
|
+
return false;
|
|
313
|
+
})) {
|
|
314
|
+
// Tree already contains all the at rules (requiredTailwindAtRules)
|
|
277
315
|
return processApplyAtRules(css, _postcss.default.root(), config);
|
|
278
|
-
}
|
|
279
|
-
// prepend them to the user's CSS. Important for <style> blocks in Vue components.
|
|
316
|
+
}
|
|
280
317
|
|
|
318
|
+
let lookupKey = requiredTailwindAtRules.join(','); // We mutated the `requiredTailwindAtRules`, but when we hit this point in
|
|
319
|
+
// time, it means that we don't have all the atrules. The missing atrules
|
|
320
|
+
// are listed inside the requiredTailwindAtRules, which we can use to fill
|
|
321
|
+
// in the missing pieces.
|
|
322
|
+
//
|
|
323
|
+
// Important for <style> blocks in Vue components.
|
|
281
324
|
|
|
282
|
-
const generateLookupTree = configChanged || defaultTailwindTree
|
|
283
|
-
return (0, _postcss.default)([(0, _substituteTailwindAtRules.default)(config, getProcessedPlugins()), (0, _evaluateTailwindFunctions.default)(config), (0, _substituteVariantsAtRules.default)(config, getProcessedPlugins()), (0, _substituteResponsiveAtRules.default)(config), (0, _convertLayerAtRulesToControlComments.default)(config), (0, _substituteScreenAtRules.default)(config)]).process(
|
|
284
|
-
|
|
285
|
-
@tailwind components;
|
|
286
|
-
@tailwind utilities;
|
|
287
|
-
`, {
|
|
288
|
-
from: undefined
|
|
325
|
+
const generateLookupTree = configChanged || !defaultTailwindTree.has(lookupKey) ? () => {
|
|
326
|
+
return (0, _postcss.default)([(0, _substituteTailwindAtRules.default)(config, getProcessedPlugins()), (0, _evaluateTailwindFunctions.default)(config), (0, _substituteVariantsAtRules.default)(config, getProcessedPlugins()), (0, _substituteResponsiveAtRules.default)(config), (0, _convertLayerAtRulesToControlComments.default)(config), (0, _substituteScreenAtRules.default)(config)]).process(requiredTailwindAtRules.map(rule => `@tailwind ${rule};`).join('\n'), {
|
|
327
|
+
from: __filename
|
|
289
328
|
}).then(result => {
|
|
290
|
-
defaultTailwindTree
|
|
291
|
-
return
|
|
329
|
+
defaultTailwindTree.set(lookupKey, result);
|
|
330
|
+
return result;
|
|
292
331
|
});
|
|
293
|
-
} : () => Promise.resolve(defaultTailwindTree);
|
|
332
|
+
} : () => Promise.resolve(defaultTailwindTree.get(lookupKey));
|
|
294
333
|
return generateLookupTree().then(result => {
|
|
295
334
|
return processApplyAtRules(css, result.root, config);
|
|
296
335
|
});
|
|
@@ -62,7 +62,7 @@ function _default(_config, {
|
|
|
62
62
|
css.walkAtRules('tailwind', atRule => {
|
|
63
63
|
if (atRule.params === 'preflight') {
|
|
64
64
|
// prettier-ignore
|
|
65
|
-
throw atRule.error("`@tailwind preflight` is not a valid at-rule in Tailwind
|
|
65
|
+
throw atRule.error("`@tailwind preflight` is not a valid at-rule in Tailwind v2.0, use `@tailwind base` instead.", {
|
|
66
66
|
word: 'preflight'
|
|
67
67
|
});
|
|
68
68
|
}
|
package/lib/plugins/preflight.js
CHANGED
|
@@ -9,6 +9,8 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
9
9
|
|
|
10
10
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
11
11
|
|
|
12
|
+
var _package = _interopRequireDefault(require("../../package.json"));
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
function _default() {
|
|
@@ -19,6 +21,8 @@ function _default() {
|
|
|
19
21
|
|
|
20
22
|
const preflightStyles = _postcss.default.parse(_fs.default.readFileSync(`${__dirname}/css/preflight.css`, 'utf8'));
|
|
21
23
|
|
|
22
|
-
addBase([
|
|
24
|
+
addBase([_postcss.default.comment({
|
|
25
|
+
text: `! tailwindcss v${_package.default.version} | MIT License | https://tailwindcss.com`
|
|
26
|
+
}), ...normalizeStyles.nodes, ...preflightStyles.nodes]);
|
|
23
27
|
};
|
|
24
28
|
}
|
|
@@ -23,7 +23,7 @@ function _default() {
|
|
|
23
23
|
}) {
|
|
24
24
|
const colors = (0, _flattenColorPalette.default)(theme('ringOffsetColor'));
|
|
25
25
|
|
|
26
|
-
const utilities = _lodash.default.fromPairs(_lodash.default.map(colors, (value, modifier) => {
|
|
26
|
+
const utilities = _lodash.default.fromPairs(_lodash.default.map(_lodash.default.omit(colors, 'DEFAULT'), (value, modifier) => {
|
|
27
27
|
return [(0, _nameClass.default)('ring-offset', modifier), {
|
|
28
28
|
'--tw-ring-offset-color': (0, _toColorValue.default)(value)
|
|
29
29
|
}];
|
|
@@ -17,7 +17,7 @@ function _default() {
|
|
|
17
17
|
theme,
|
|
18
18
|
variants
|
|
19
19
|
}) {
|
|
20
|
-
const utilities = _lodash.default.fromPairs(_lodash.default.map(theme('ringOffsetWidth'), (value, modifier) => {
|
|
20
|
+
const utilities = _lodash.default.fromPairs(_lodash.default.map(_lodash.default.omit(theme('ringOffsetWidth'), 'DEFAULT'), (value, modifier) => {
|
|
21
21
|
return [(0, _nameClass.default)('ring-offset', modifier), {
|
|
22
22
|
'--tw-ring-offset-width': value
|
|
23
23
|
}];
|
package/lib/plugins/ringWidth.js
CHANGED
|
@@ -34,8 +34,8 @@ function _default() {
|
|
|
34
34
|
addUtilities({
|
|
35
35
|
'*': {
|
|
36
36
|
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
37
|
-
'--tw-ring-offset-width': '0px',
|
|
38
|
-
'--tw-ring-offset-color': '#fff',
|
|
37
|
+
'--tw-ring-offset-width': theme('ringOffsetWidth.DEFAULT', '0px'),
|
|
38
|
+
'--tw-ring-offset-color': theme('ringOffsetColor.DEFAULT', '#fff'),
|
|
39
39
|
'--tw-ring-color': ringColorDefault,
|
|
40
40
|
'--tw-ring-offset-shadow': '0 0 #0000',
|
|
41
41
|
'--tw-ring-shadow': '0 0 #0000'
|
|
@@ -39,6 +39,8 @@ var _objectHash = _interopRequireDefault(require("object-hash"));
|
|
|
39
39
|
|
|
40
40
|
var _log = _interopRequireDefault(require("./util/log"));
|
|
41
41
|
|
|
42
|
+
var _disposables = require("./util/disposables");
|
|
43
|
+
|
|
42
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
45
|
|
|
44
46
|
let previousConfig = null;
|
|
@@ -52,6 +54,8 @@ function _default(getConfig) {
|
|
|
52
54
|
previousConfig = config;
|
|
53
55
|
|
|
54
56
|
if (configChanged) {
|
|
57
|
+
_disposables.shared.dispose();
|
|
58
|
+
|
|
55
59
|
if (config.target) {
|
|
56
60
|
_log.default.warn(['The `target` feature has been removed in Tailwind CSS v2.0.', 'Please remove this option from your config file to silence this warning.']);
|
|
57
61
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.disposables = disposables;
|
|
7
|
+
exports.shared = void 0;
|
|
8
|
+
|
|
9
|
+
function disposables() {
|
|
10
|
+
let disposables = [];
|
|
11
|
+
let api = {
|
|
12
|
+
add(cb) {
|
|
13
|
+
disposables.push(cb);
|
|
14
|
+
return () => {
|
|
15
|
+
let idx = disposables.indexOf(cb);
|
|
16
|
+
if (idx !== -1) disposables.splice(idx, 1);
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
dispose() {
|
|
21
|
+
disposables.splice(0).forEach(dispose => dispose());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
return api;
|
|
26
|
+
} // A shared disposables collection
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
let shared = disposables();
|
|
30
|
+
exports.shared = shared;
|
|
@@ -14,5 +14,9 @@ function transformThemeValue(themeSection) {
|
|
|
14
14
|
return value => Array.isArray(value) ? value.join(', ') : value;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
if (themeSection === 'colors') {
|
|
18
|
+
return value => typeof value === 'function' ? value({}) : value;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
return value => value;
|
|
18
22
|
}
|
package/lib/util/useMemo.js
CHANGED
|
@@ -5,16 +5,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useMemo = useMemo;
|
|
7
7
|
|
|
8
|
+
var _disposables = require("./disposables");
|
|
9
|
+
|
|
8
10
|
function useMemo(cb, keyResolver) {
|
|
9
|
-
|
|
11
|
+
let cache = new Map();
|
|
12
|
+
|
|
13
|
+
function clearCache() {
|
|
14
|
+
cache.clear();
|
|
15
|
+
|
|
16
|
+
_disposables.shared.add(clearCache);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_disposables.shared.add(clearCache);
|
|
20
|
+
|
|
10
21
|
return (...args) => {
|
|
11
|
-
|
|
22
|
+
let key = keyResolver(...args);
|
|
12
23
|
|
|
13
24
|
if (cache.has(key)) {
|
|
14
25
|
return cache.get(key);
|
|
15
26
|
}
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
let result = cb(...args);
|
|
18
29
|
cache.set(key, result);
|
|
19
30
|
return result;
|
|
20
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"rebuild-fixtures": "npm run babelify && babel-node scripts/rebuildFixtures.js",
|
|
24
24
|
"prepublishOnly": "npm run babelify && babel-node scripts/build.js",
|
|
25
25
|
"style": "eslint .",
|
|
26
|
-
"test": "jest
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"posttest": "npm run style",
|
|
27
28
|
"compat": "node scripts/compat.js --prepare",
|
|
28
29
|
"compat:restore": "node scripts/compat.js --restore"
|
|
29
30
|
},
|
|
@@ -36,44 +37,46 @@
|
|
|
36
37
|
"*.js"
|
|
37
38
|
],
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@babel/cli": "^7.
|
|
40
|
-
"@babel/core": "^7.
|
|
41
|
-
"@babel/node": "^7.
|
|
42
|
-
"@babel/preset-env": "^7.
|
|
43
|
-
"autoprefixer": "^10.
|
|
40
|
+
"@babel/cli": "^7.12.13",
|
|
41
|
+
"@babel/core": "^7.13.8",
|
|
42
|
+
"@babel/node": "^7.12.13",
|
|
43
|
+
"@babel/preset-env": "^7.13.8",
|
|
44
|
+
"autoprefixer": "^10.2.4",
|
|
44
45
|
"babel-jest": "^26.6.3",
|
|
45
46
|
"clean-css": "^4.1.9",
|
|
46
|
-
"eslint": "^7.
|
|
47
|
-
"eslint-config-prettier": "^
|
|
48
|
-
"eslint-plugin-prettier": "^3.1
|
|
47
|
+
"eslint": "^7.20.0",
|
|
48
|
+
"eslint-config-prettier": "^7.2.0",
|
|
49
|
+
"eslint-plugin-prettier": "^3.3.1",
|
|
49
50
|
"jest": "^26.6.3",
|
|
50
|
-
"postcss": "^8.
|
|
51
|
-
"prettier": "^2.1
|
|
51
|
+
"postcss": "^8.2.6",
|
|
52
|
+
"prettier": "^2.2.1",
|
|
52
53
|
"rimraf": "^3.0.0"
|
|
53
54
|
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"autoprefixer": "^10.0.2",
|
|
57
|
+
"postcss": "^8.0.9"
|
|
58
|
+
},
|
|
54
59
|
"dependencies": {
|
|
55
|
-
"@fullhuman/postcss-purgecss": "^3.
|
|
60
|
+
"@fullhuman/postcss-purgecss": "^3.1.3",
|
|
56
61
|
"bytes": "^3.0.0",
|
|
57
62
|
"chalk": "^4.1.0",
|
|
58
63
|
"color": "^3.1.3",
|
|
59
64
|
"detective": "^5.2.0",
|
|
60
65
|
"didyoumean": "^1.2.1",
|
|
61
|
-
"fs-extra": "^9.0
|
|
66
|
+
"fs-extra": "^9.1.0",
|
|
62
67
|
"html-tags": "^3.1.0",
|
|
63
|
-
"lodash": "^4.17.
|
|
68
|
+
"lodash": "^4.17.21",
|
|
64
69
|
"modern-normalize": "^1.0.0",
|
|
65
70
|
"node-emoji": "^1.8.1",
|
|
66
|
-
"object-hash": "^2.
|
|
71
|
+
"object-hash": "^2.1.1",
|
|
67
72
|
"postcss-functions": "^3",
|
|
68
|
-
"postcss-js": "^
|
|
69
|
-
"postcss-nested": "^
|
|
73
|
+
"postcss-js": "^3.0.3",
|
|
74
|
+
"postcss-nested": "^5.0.5",
|
|
70
75
|
"postcss-selector-parser": "^6.0.4",
|
|
71
76
|
"postcss-value-parser": "^4.1.0",
|
|
72
77
|
"pretty-hrtime": "^1.0.3",
|
|
73
|
-
"reduce-css-calc": "^2.1.
|
|
74
|
-
"resolve": "^1.
|
|
75
|
-
"autoprefixer": "^9",
|
|
76
|
-
"postcss": "^7"
|
|
78
|
+
"reduce-css-calc": "^2.1.8",
|
|
79
|
+
"resolve": "^1.20.0"
|
|
77
80
|
},
|
|
78
81
|
"browserslist": [
|
|
79
82
|
"> 1%",
|
|
@@ -94,7 +97,6 @@
|
|
|
94
97
|
]
|
|
95
98
|
},
|
|
96
99
|
"jest": {
|
|
97
|
-
"collectCoverage": true,
|
|
98
100
|
"testTimeout": 30000,
|
|
99
101
|
"setupFilesAfterEnv": [
|
|
100
102
|
"<rootDir>/jest/customMatchers.js"
|
package/scripts/compat.js
CHANGED
|
@@ -37,10 +37,16 @@ if (process.argv.includes('--prepare')) {
|
|
|
37
37
|
// 5. Remove peerDependencies
|
|
38
38
|
delete packageJson.peerDependencies
|
|
39
39
|
|
|
40
|
-
// 6.
|
|
40
|
+
// 6. Use new name
|
|
41
|
+
packageJson.name = '@tailwindcss/postcss7-compat'
|
|
42
|
+
|
|
43
|
+
// 7. Make sure you can publish
|
|
44
|
+
packageJson.publishConfig = { access: 'public' }
|
|
45
|
+
|
|
46
|
+
// 8. Write package.json with the new contents
|
|
41
47
|
fs.writeFileSync(fromRootPath('package.json'), JSON.stringify(packageJson, null, 2), 'utf8')
|
|
42
48
|
|
|
43
|
-
//
|
|
49
|
+
// 9. Print some useful information to make publishing easy
|
|
44
50
|
console.log()
|
|
45
51
|
console.log('You can safely publish `tailwindcss` in PostCSS 7 compatibility mode:\n')
|
|
46
52
|
console.log(
|