tailwindcss 0.0.0-insiders.a2bca63 → 0.0.0-insiders.a2fa693
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 +7 -6
- package/index.css +5 -0
- package/lib/cli/build/index.js +32 -19
- package/lib/cli/build/plugin.js +248 -134
- package/lib/cli/build/utils.js +31 -21
- package/lib/cli/build/watching.js +99 -30
- package/lib/cli/help/index.js +17 -15
- package/lib/cli/index.js +223 -10
- package/lib/cli/init/index.js +31 -14
- package/lib/cli.js +1 -227
- package/lib/corePluginList.js +8 -1
- package/lib/corePlugins.js +2129 -1819
- package/lib/css/preflight.css +17 -3
- package/lib/featureFlags.js +39 -25
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +10 -8
- package/lib/lib/collapseAdjacentRules.js +10 -8
- package/lib/lib/collapseDuplicateDeclarations.js +13 -11
- package/lib/lib/content.js +72 -27
- package/lib/lib/defaultExtractor.js +24 -17
- package/lib/lib/detectNesting.js +18 -10
- package/lib/lib/evaluateTailwindFunctions.js +45 -41
- package/lib/lib/expandApplyAtRules.js +84 -57
- package/lib/lib/expandTailwindAtRules.js +115 -47
- package/lib/lib/findAtConfigPath.js +14 -12
- package/lib/lib/generateRules.js +221 -138
- package/lib/lib/getModuleDependencies.js +85 -37
- package/lib/lib/handleImportAtRules.js +50 -0
- package/lib/lib/load-config.js +42 -0
- package/lib/lib/normalizeTailwindDirectives.js +26 -39
- package/lib/lib/offsets.js +136 -47
- package/lib/lib/partitionApplyAtRules.js +5 -3
- package/lib/lib/regex.js +26 -12
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +53 -49
- package/lib/lib/setupContextUtils.js +455 -229
- package/lib/lib/setupTrackingContext.js +54 -29
- package/lib/lib/sharedState.js +36 -15
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/plugin.js +164 -0
- package/lib/postcss-plugins/nesting/index.js +5 -3
- package/lib/postcss-plugins/nesting/plugin.js +19 -17
- package/lib/processTailwindFeatures.js +19 -17
- package/lib/public/colors.js +269 -245
- package/lib/public/create-plugin.js +5 -3
- package/lib/public/default-config.js +6 -4
- package/lib/public/default-theme.js +6 -4
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +6 -4
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +3 -1
- package/lib/util/buildMediaQuery.js +5 -3
- package/lib/util/cloneDeep.js +4 -2
- package/lib/util/cloneNodes.js +6 -4
- package/lib/util/color.js +45 -27
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +3 -1
- package/lib/util/createPlugin.js +3 -1
- package/lib/util/createUtilityPlugin.js +9 -7
- package/lib/util/dataTypes.js +215 -96
- package/lib/util/defaults.js +9 -7
- package/lib/util/escapeClassName.js +10 -8
- package/lib/util/escapeCommas.js +4 -2
- package/lib/util/flattenColorPalette.js +5 -3
- package/lib/util/formatVariantSelector.js +149 -169
- package/lib/util/getAllConfigs.js +12 -9
- package/lib/util/hashConfig.js +6 -4
- package/lib/util/isKeyframeRule.js +4 -2
- package/lib/util/isPlainObject.js +4 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +14 -12
- package/lib/util/log.js +31 -10
- package/lib/util/nameClass.js +16 -10
- package/lib/util/negateValue.js +12 -10
- package/lib/util/normalizeConfig.js +123 -77
- package/lib/util/normalizeScreens.js +30 -22
- package/lib/util/parseAnimationValue.js +41 -39
- package/lib/util/parseBoxShadowValue.js +24 -20
- package/lib/util/parseDependency.js +7 -5
- package/lib/util/parseGlob.js +10 -8
- package/lib/util/parseObjectStyles.js +10 -8
- package/lib/util/pluginUtils.js +97 -87
- package/lib/util/prefixSelector.js +27 -11
- package/lib/util/pseudoElements.js +209 -0
- package/lib/util/removeAlphaVariables.js +4 -2
- package/lib/util/resolveConfig.js +31 -30
- package/lib/util/resolveConfigPath.js +28 -12
- package/lib/util/responsive.js +7 -5
- package/lib/util/splitAtTopLevelOnly.js +12 -4
- package/lib/util/tap.js +3 -1
- package/lib/util/toColorValue.js +4 -2
- package/lib/util/toPath.js +5 -3
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +31 -7
- package/lib/util/validateFormalSyntax.js +8 -6
- package/lib/util/withAlphaVariable.js +11 -7
- 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 +50 -50
- package/resolveConfig.d.ts +11 -2
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/src/cli/build/index.js +17 -9
- package/src/cli/build/plugin.js +177 -80
- package/src/cli/build/watching.js +108 -13
- package/src/cli/index.js +217 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +1 -221
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +287 -62
- package/src/css/preflight.css +17 -3
- package/src/featureFlags.js +7 -3
- package/src/index.js +1 -47
- package/src/lib/content.js +54 -13
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/lib/expandApplyAtRules.js +43 -16
- package/src/lib/expandTailwindAtRules.js +78 -13
- package/src/lib/findAtConfigPath.js +4 -6
- package/src/lib/generateRules.js +154 -53
- 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 +105 -2
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +305 -88
- package/src/lib/setupTrackingContext.js +37 -14
- package/src/lib/sharedState.js +13 -4
- package/src/plugin.js +133 -0
- package/src/processTailwindFeatures.js +3 -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/color.js +18 -3
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +97 -9
- package/src/util/formatVariantSelector.js +163 -165
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +24 -0
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +57 -11
- package/src/util/pluginUtils.js +49 -42
- package/src/util/prefixSelector.js +29 -10
- package/src/util/pseudoElements.js +167 -0
- package/src/util/resolveConfig.js +3 -9
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +23 -0
- 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} +205 -173
- package/stubs/{simpleConfig.stub.js → config.simple.js} +1 -2
- 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 +21 -13
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +116 -80
- package/CHANGELOG.md +0 -2276
- package/lib/cli/build/deps.js +0 -54
- package/lib/cli/shared.js +0 -12
- package/lib/cli-peer-dependencies.js +0 -28
- package/lib/constants.js +0 -44
- package/peers/index.js +0 -79455
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/build/deps.js +0 -56
- package/src/cli/shared.js +0 -5
- package/src/cli-peer-dependencies.js +0 -15
- package/src/constants.js +0 -17
package/lib/cli/build/utils.js
CHANGED
|
@@ -10,41 +10,51 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
indentRecursive: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
indentRecursive: function() {
|
|
14
|
+
return indentRecursive;
|
|
15
|
+
},
|
|
16
|
+
formatNodes: function() {
|
|
17
|
+
return formatNodes;
|
|
18
|
+
},
|
|
19
|
+
readFileWithRetries: function() {
|
|
20
|
+
return readFileWithRetries;
|
|
21
|
+
},
|
|
22
|
+
drainStdin: function() {
|
|
23
|
+
return drainStdin;
|
|
24
|
+
},
|
|
25
|
+
outputFile: function() {
|
|
26
|
+
return outputFile;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
|
-
const _fs = /*#__PURE__*/
|
|
20
|
-
const _path = /*#__PURE__*/
|
|
21
|
-
function
|
|
29
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
30
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
31
|
+
function _interop_require_default(obj) {
|
|
22
32
|
return obj && obj.__esModule ? obj : {
|
|
23
33
|
default: obj
|
|
24
34
|
};
|
|
25
35
|
}
|
|
26
36
|
function indentRecursive(node, indent = 0) {
|
|
27
37
|
node.each && node.each((child, i)=>{
|
|
28
|
-
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes(
|
|
29
|
-
child.raws.before = `\n${node.type !==
|
|
38
|
+
if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
|
|
39
|
+
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
|
|
30
40
|
}
|
|
31
|
-
child.raws.after = `\n${
|
|
41
|
+
child.raws.after = `\n${' '.repeat(indent)}`;
|
|
32
42
|
indentRecursive(child, indent + 1);
|
|
33
43
|
});
|
|
34
44
|
}
|
|
35
45
|
function formatNodes(root) {
|
|
36
46
|
indentRecursive(root);
|
|
37
47
|
if (root.first) {
|
|
38
|
-
root.first.raws.before =
|
|
48
|
+
root.first.raws.before = '';
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
async function readFileWithRetries(path, tries = 5) {
|
|
42
52
|
for(let n = 0; n <= tries; n++){
|
|
43
53
|
try {
|
|
44
|
-
return await _fs.default.promises.readFile(path,
|
|
54
|
+
return await _fs.default.promises.readFile(path, 'utf8');
|
|
45
55
|
} catch (err) {
|
|
46
56
|
if (n !== tries) {
|
|
47
|
-
if (err.code ===
|
|
57
|
+
if (err.code === 'ENOENT' || err.code === 'EBUSY') {
|
|
48
58
|
await new Promise((resolve)=>setTimeout(resolve, 10));
|
|
49
59
|
continue;
|
|
50
60
|
}
|
|
@@ -55,24 +65,24 @@ async function readFileWithRetries(path, tries = 5) {
|
|
|
55
65
|
}
|
|
56
66
|
function drainStdin() {
|
|
57
67
|
return new Promise((resolve, reject)=>{
|
|
58
|
-
let result =
|
|
59
|
-
process.stdin.on(
|
|
68
|
+
let result = '';
|
|
69
|
+
process.stdin.on('data', (chunk)=>{
|
|
60
70
|
result += chunk;
|
|
61
71
|
});
|
|
62
|
-
process.stdin.on(
|
|
63
|
-
process.stdin.on(
|
|
72
|
+
process.stdin.on('end', ()=>resolve(result));
|
|
73
|
+
process.stdin.on('error', (err)=>reject(err));
|
|
64
74
|
});
|
|
65
75
|
}
|
|
66
76
|
async function outputFile(file, newContents) {
|
|
67
77
|
try {
|
|
68
|
-
let currentContents = await _fs.default.promises.readFile(file,
|
|
78
|
+
let currentContents = await _fs.default.promises.readFile(file, 'utf8');
|
|
69
79
|
if (currentContents === newContents) {
|
|
70
80
|
return; // Skip writing the file
|
|
71
81
|
}
|
|
72
|
-
} catch
|
|
82
|
+
} catch (e) {}
|
|
73
83
|
// Write the file
|
|
74
84
|
await _fs.default.promises.mkdir(_path.default.dirname(file), {
|
|
75
85
|
recursive: true
|
|
76
86
|
});
|
|
77
|
-
await _fs.default.promises.writeFile(file, newContents,
|
|
87
|
+
await _fs.default.promises.writeFile(file, newContents, 'utf8');
|
|
78
88
|
}
|
|
@@ -5,22 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "createWatcher", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return createWatcher;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const _chokidar = /*#__PURE__*/
|
|
11
|
-
const _fs = /*#__PURE__*/
|
|
12
|
-
const _micromatch = /*#__PURE__*/
|
|
13
|
-
const
|
|
14
|
-
const _path = /*#__PURE__*/
|
|
15
|
-
const
|
|
16
|
-
function
|
|
12
|
+
const _chokidar = /*#__PURE__*/ _interop_require_default(require("chokidar"));
|
|
13
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
14
|
+
const _micromatch = /*#__PURE__*/ _interop_require_default(require("micromatch"));
|
|
15
|
+
const _normalizepath = /*#__PURE__*/ _interop_require_default(require("normalize-path"));
|
|
16
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
17
|
+
const _utils = require("./utils.js");
|
|
18
|
+
function _interop_require_default(obj) {
|
|
17
19
|
return obj && obj.__esModule ? obj : {
|
|
18
20
|
default: obj
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
|
-
function createWatcher(args, { state
|
|
22
|
-
let shouldPoll = args[
|
|
23
|
-
let shouldCoalesceWriteEvents = shouldPoll || process.platform ===
|
|
23
|
+
function createWatcher(args, { state, rebuild }) {
|
|
24
|
+
let shouldPoll = args['--poll'];
|
|
25
|
+
let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32';
|
|
24
26
|
// Polling interval in milliseconds
|
|
25
27
|
// Used only when polling or coalescing add/change events on Windows
|
|
26
28
|
let pollInterval = 10;
|
|
@@ -37,31 +39,81 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
37
39
|
pollInterval: pollInterval
|
|
38
40
|
} : false
|
|
39
41
|
});
|
|
42
|
+
// A queue of rebuilds, file reads, etc… to run
|
|
40
43
|
let chain = Promise.resolve();
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* A list of files that have been changed since the last rebuild
|
|
46
|
+
*
|
|
47
|
+
* @type {{file: string, content: () => Promise<string>, extension: string}[]}
|
|
48
|
+
*/ let changedContent = [];
|
|
49
|
+
/**
|
|
50
|
+
* A list of files for which a rebuild has already been queued.
|
|
51
|
+
* This is used to prevent duplicate rebuilds when multiple events are fired for the same file.
|
|
52
|
+
* The rebuilt file is cleared from this list when it's associated rebuild has _started_
|
|
53
|
+
* This is because if the file is changed during a rebuild it won't trigger a new rebuild which it should
|
|
54
|
+
**/ let pendingRebuilds = new Set();
|
|
55
|
+
let _timer;
|
|
56
|
+
let _reject;
|
|
57
|
+
/**
|
|
58
|
+
* Rebuilds the changed files and resolves when the rebuild is
|
|
59
|
+
* complete regardless of whether it was successful or not
|
|
60
|
+
*/ async function rebuildAndContinue() {
|
|
61
|
+
let changes = changedContent.splice(0);
|
|
62
|
+
// There are no changes to rebuild so we can just do nothing
|
|
63
|
+
if (changes.length === 0) {
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}
|
|
66
|
+
// Clear all pending rebuilds for the about-to-be-built files
|
|
67
|
+
changes.forEach((change)=>pendingRebuilds.delete(change.file));
|
|
68
|
+
// Resolve the promise even when the rebuild fails
|
|
69
|
+
return rebuild(changes).then(()=>{}, (e)=>{
|
|
70
|
+
console.error(e.toString());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
43
73
|
/**
|
|
44
74
|
*
|
|
45
75
|
* @param {*} file
|
|
46
76
|
* @param {(() => Promise<string>) | null} content
|
|
47
|
-
|
|
77
|
+
* @param {boolean} skipPendingCheck
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/ function recordChangedFile(file, content = null, skipPendingCheck = false) {
|
|
48
80
|
file = _path.default.resolve(file);
|
|
49
|
-
|
|
81
|
+
// Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
|
|
82
|
+
// In that case rebuild has already been queued by rename, so can be skipped in change
|
|
83
|
+
if (pendingRebuilds.has(file) && !skipPendingCheck) {
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
}
|
|
86
|
+
// Mark that a rebuild of this file is going to happen
|
|
87
|
+
// It MUST happen synchronously before the rebuild is queued for this to be effective
|
|
88
|
+
pendingRebuilds.add(file);
|
|
50
89
|
changedContent.push({
|
|
51
90
|
file,
|
|
52
|
-
content,
|
|
91
|
+
content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, 'utf8'),
|
|
53
92
|
extension: _path.default.extname(file).slice(1)
|
|
54
93
|
});
|
|
55
|
-
|
|
94
|
+
if (_timer) {
|
|
95
|
+
clearTimeout(_timer);
|
|
96
|
+
_reject();
|
|
97
|
+
}
|
|
98
|
+
// If a rebuild is already in progress we don't want to start another one until the 10ms timer has expired
|
|
99
|
+
chain = chain.then(()=>new Promise((resolve, reject)=>{
|
|
100
|
+
_timer = setTimeout(resolve, 10);
|
|
101
|
+
_reject = reject;
|
|
102
|
+
}));
|
|
103
|
+
// Resolves once this file has been rebuilt (or the rebuild for this file has failed)
|
|
104
|
+
// This queues as many rebuilds as there are changed files
|
|
105
|
+
// But those rebuilds happen after some delay
|
|
106
|
+
// And will immediately resolve if there are no changes
|
|
107
|
+
chain = chain.then(rebuildAndContinue, rebuildAndContinue);
|
|
56
108
|
return chain;
|
|
57
109
|
}
|
|
58
|
-
watcher.on(
|
|
59
|
-
watcher.on(
|
|
110
|
+
watcher.on('change', (file)=>recordChangedFile(file));
|
|
111
|
+
watcher.on('add', (file)=>recordChangedFile(file));
|
|
60
112
|
// Restore watching any files that are "removed"
|
|
61
113
|
// This can happen when a file is pseudo-atomically replaced (a copy is created, overwritten, the old one is unlinked, and the new one is renamed)
|
|
62
114
|
// TODO: An an optimization we should allow removal when the config changes
|
|
63
|
-
watcher.on(
|
|
64
|
-
file = (0,
|
|
115
|
+
watcher.on('unlink', (file)=>{
|
|
116
|
+
file = (0, _normalizepath.default)(file);
|
|
65
117
|
// Only re-add the file if it's not covered by a dynamic pattern
|
|
66
118
|
if (!_micromatch.default.some([
|
|
67
119
|
file
|
|
@@ -73,8 +125,8 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
73
125
|
// will only fire a rename event for atomic writes and not a change event
|
|
74
126
|
// This is very likely a chokidar bug but it's one we need to work around
|
|
75
127
|
// We treat this as a change event and rebuild the CSS
|
|
76
|
-
watcher.on(
|
|
77
|
-
if (evt !==
|
|
128
|
+
watcher.on('raw', (evt, filePath, meta)=>{
|
|
129
|
+
if (evt !== 'rename') {
|
|
78
130
|
return;
|
|
79
131
|
}
|
|
80
132
|
let watchedPath = meta.watchedPath;
|
|
@@ -91,22 +143,39 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
91
143
|
if (pendingRebuilds.has(filePath)) {
|
|
92
144
|
return;
|
|
93
145
|
}
|
|
146
|
+
// We'll go ahead and add the file to the pending rebuilds list here
|
|
147
|
+
// It'll be removed when the rebuild starts unless the read fails
|
|
148
|
+
// which will be taken care of as well
|
|
94
149
|
pendingRebuilds.add(filePath);
|
|
95
|
-
|
|
96
|
-
let content;
|
|
150
|
+
async function enqueue() {
|
|
97
151
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
152
|
+
// We need to read the file as early as possible outside of the chain
|
|
153
|
+
// because it may be gone by the time we get to it. doing the read
|
|
154
|
+
// immediately increases the chance that the file is still there
|
|
155
|
+
let content = await (0, _utils.readFileWithRetries)(_path.default.resolve(filePath));
|
|
156
|
+
if (content === undefined) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// This will push the rebuild onto the chain
|
|
160
|
+
// We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
|
|
161
|
+
// This is because the order of events and timing is different on Linux
|
|
162
|
+
// @ts-ignore: TypeScript isn't picking up that content is a string here
|
|
163
|
+
await recordChangedFile(filePath, ()=>content, true);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
// If reading the file fails, it's was probably a deleted temporary file
|
|
166
|
+
// So we can ignore it and no rebuild is needed
|
|
101
167
|
}
|
|
102
|
-
|
|
168
|
+
}
|
|
169
|
+
enqueue().then(()=>{
|
|
170
|
+
// If the file read fails we still need to make sure the file isn't stuck in the pending rebuilds list
|
|
171
|
+
pendingRebuilds.delete(filePath);
|
|
103
172
|
});
|
|
104
173
|
});
|
|
105
174
|
return {
|
|
106
175
|
fswatcher: watcher,
|
|
107
176
|
refreshWatchedFiles () {
|
|
108
177
|
watcher.add(Array.from(state.contextDependencies));
|
|
109
|
-
watcher.add(Array.from(state.
|
|
178
|
+
watcher.add(Array.from(state.configBag.dependencies));
|
|
110
179
|
watcher.add(state.contentPatterns.all);
|
|
111
180
|
}
|
|
112
181
|
};
|
package/lib/cli/help/index.js
CHANGED
|
@@ -5,47 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "help", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: ()
|
|
8
|
+
get: function() {
|
|
9
|
+
return help;
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
+
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../package.json"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
12
14
|
return obj && obj.__esModule ? obj : {
|
|
13
15
|
default: obj
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
|
-
function help({ message
|
|
18
|
+
function help({ message, usage, commands, options }) {
|
|
17
19
|
let indent = 2;
|
|
18
20
|
// Render header
|
|
19
21
|
console.log();
|
|
20
|
-
console.log(`${
|
|
22
|
+
console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
|
|
21
23
|
// Render message
|
|
22
24
|
if (message) {
|
|
23
25
|
console.log();
|
|
24
|
-
for (let msg of message.split(
|
|
26
|
+
for (let msg of message.split('\n')){
|
|
25
27
|
console.log(msg);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
// Render usage
|
|
29
31
|
if (usage && usage.length > 0) {
|
|
30
32
|
console.log();
|
|
31
|
-
console.log(
|
|
33
|
+
console.log('Usage:');
|
|
32
34
|
for (let example of usage){
|
|
33
|
-
console.log(
|
|
35
|
+
console.log(' '.repeat(indent), example);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
// Render commands
|
|
37
39
|
if (commands && commands.length > 0) {
|
|
38
40
|
console.log();
|
|
39
|
-
console.log(
|
|
41
|
+
console.log('Commands:');
|
|
40
42
|
for (let command of commands){
|
|
41
|
-
console.log(
|
|
43
|
+
console.log(' '.repeat(indent), command);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
// Render options
|
|
45
47
|
if (options) {
|
|
46
48
|
let groupedOptions = {};
|
|
47
49
|
for (let [key, value] of Object.entries(options)){
|
|
48
|
-
if (typeof value ===
|
|
50
|
+
if (typeof value === 'object') {
|
|
49
51
|
groupedOptions[key] = {
|
|
50
52
|
...value,
|
|
51
53
|
flags: [
|
|
@@ -57,13 +59,13 @@ function help({ message , usage , commands , options }) {
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
console.log();
|
|
60
|
-
console.log(
|
|
61
|
-
for (let { flags
|
|
62
|
+
console.log('Options:');
|
|
63
|
+
for (let { flags, description, deprecated } of Object.values(groupedOptions)){
|
|
62
64
|
if (deprecated) continue;
|
|
63
65
|
if (flags.length === 1) {
|
|
64
|
-
console.log(
|
|
66
|
+
console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(', ').padEnd(20, ' '), description);
|
|
65
67
|
} else {
|
|
66
|
-
console.log(
|
|
68
|
+
console.log(' '.repeat(indent), flags.slice().reverse().join(', ').padEnd(24, ' '), description);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
package/lib/cli/index.js
CHANGED
|
@@ -1,18 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
4
|
value: true
|
|
4
5
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
7
|
+
const _arg = /*#__PURE__*/ _interop_require_default(require("arg"));
|
|
8
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
9
|
+
const _build = require("./build");
|
|
10
|
+
const _help = require("./help");
|
|
11
|
+
const _init = require("./init");
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function oneOf(...options) {
|
|
18
|
+
return Object.assign((value = true)=>{
|
|
19
|
+
for (let option of options){
|
|
20
|
+
let parsed = option(value);
|
|
21
|
+
if (parsed === value) {
|
|
22
|
+
return parsed;
|
|
14
23
|
}
|
|
24
|
+
}
|
|
25
|
+
throw new Error('...');
|
|
26
|
+
}, {
|
|
27
|
+
manualParsing: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
let commands = {
|
|
31
|
+
init: {
|
|
32
|
+
run: _init.init,
|
|
33
|
+
args: {
|
|
34
|
+
'--esm': {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
description: `Initialize configuration file as ESM`
|
|
37
|
+
},
|
|
38
|
+
'--ts': {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
description: `Initialize configuration file as TypeScript`
|
|
41
|
+
},
|
|
42
|
+
'--postcss': {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
description: `Initialize a \`postcss.config.js\` file`
|
|
45
|
+
},
|
|
46
|
+
'--full': {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
description: `Include the default values for all options in the generated configuration file`
|
|
49
|
+
},
|
|
50
|
+
'-f': '--full',
|
|
51
|
+
'-p': '--postcss'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
build: {
|
|
55
|
+
run: _build.build,
|
|
56
|
+
args: {
|
|
57
|
+
'--input': {
|
|
58
|
+
type: String,
|
|
59
|
+
description: 'Input file'
|
|
60
|
+
},
|
|
61
|
+
'--output': {
|
|
62
|
+
type: String,
|
|
63
|
+
description: 'Output file'
|
|
64
|
+
},
|
|
65
|
+
'--watch': {
|
|
66
|
+
type: oneOf(String, Boolean),
|
|
67
|
+
description: 'Watch for changes and rebuild as needed'
|
|
68
|
+
},
|
|
69
|
+
'--poll': {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
description: 'Use polling instead of filesystem events when watching'
|
|
72
|
+
},
|
|
73
|
+
'--content': {
|
|
74
|
+
type: String,
|
|
75
|
+
description: 'Content paths to use for removing unused classes'
|
|
76
|
+
},
|
|
77
|
+
'--purge': {
|
|
78
|
+
type: String,
|
|
79
|
+
deprecated: true
|
|
80
|
+
},
|
|
81
|
+
'--postcss': {
|
|
82
|
+
type: oneOf(String, Boolean),
|
|
83
|
+
description: 'Load custom PostCSS configuration'
|
|
84
|
+
},
|
|
85
|
+
'--minify': {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
description: 'Minify the output'
|
|
88
|
+
},
|
|
89
|
+
'--config': {
|
|
90
|
+
type: String,
|
|
91
|
+
description: 'Path to a custom config file'
|
|
92
|
+
},
|
|
93
|
+
'--no-autoprefixer': {
|
|
94
|
+
deprecated: true,
|
|
95
|
+
type: Boolean,
|
|
96
|
+
description: 'Disable autoprefixer'
|
|
97
|
+
},
|
|
98
|
+
'-c': '--config',
|
|
99
|
+
'-i': '--input',
|
|
100
|
+
'-o': '--output',
|
|
101
|
+
'-m': '--minify',
|
|
102
|
+
'-w': '--watch',
|
|
103
|
+
'-p': '--poll'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
let sharedFlags = {
|
|
108
|
+
'--help': {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
description: 'Display usage information'
|
|
111
|
+
},
|
|
112
|
+
'-h': '--help'
|
|
113
|
+
};
|
|
114
|
+
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
115
|
+
(0, _help.help)({
|
|
116
|
+
usage: [
|
|
117
|
+
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
|
118
|
+
'tailwindcss init [--full] [--postcss] [options...]'
|
|
119
|
+
],
|
|
120
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
121
|
+
options: {
|
|
122
|
+
...commands.build.args,
|
|
123
|
+
...sharedFlags
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
process.exit(0);
|
|
127
|
+
}
|
|
128
|
+
let command = ((arg = '')=>arg.startsWith('-') ? undefined : arg)(process.argv[2]) || 'build';
|
|
129
|
+
if (commands[command] === undefined) {
|
|
130
|
+
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
131
|
+
// TODO: Deprecate this in future versions
|
|
132
|
+
// Check if non-existing command, might be a file.
|
|
133
|
+
command = 'build';
|
|
134
|
+
} else {
|
|
135
|
+
(0, _help.help)({
|
|
136
|
+
message: `Invalid command: ${command}`,
|
|
137
|
+
usage: [
|
|
138
|
+
'tailwindcss <command> [options]'
|
|
139
|
+
],
|
|
140
|
+
commands: Object.keys(commands).filter((command)=>command !== 'build').map((command)=>`${command} [options]`),
|
|
141
|
+
options: sharedFlags
|
|
15
142
|
});
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Execute command
|
|
147
|
+
let { args: flags, run } = commands[command];
|
|
148
|
+
let args = (()=>{
|
|
149
|
+
try {
|
|
150
|
+
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
151
|
+
...flags,
|
|
152
|
+
...sharedFlags
|
|
153
|
+
}).filter(([_key, value])=>{
|
|
154
|
+
var _value_type, _value;
|
|
155
|
+
return !((_value = value) === null || _value === void 0 ? void 0 : (_value_type = _value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
|
156
|
+
}).map(([key, value])=>[
|
|
157
|
+
key,
|
|
158
|
+
typeof value === 'object' ? value.type : value
|
|
159
|
+
])), {
|
|
160
|
+
permissive: true
|
|
161
|
+
});
|
|
162
|
+
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
163
|
+
for(let i = result['_'].length - 1; i >= 0; --i){
|
|
164
|
+
let flag = result['_'][i];
|
|
165
|
+
if (!flag.startsWith('-')) continue;
|
|
166
|
+
let [flagName, flagValue] = flag.split('=');
|
|
167
|
+
let handler = flags[flagName];
|
|
168
|
+
// Resolve flagName & handler
|
|
169
|
+
while(typeof handler === 'string'){
|
|
170
|
+
flagName = handler;
|
|
171
|
+
handler = flags[handler];
|
|
172
|
+
}
|
|
173
|
+
if (!handler) continue;
|
|
174
|
+
let args = [];
|
|
175
|
+
let offset = i + 1;
|
|
176
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
177
|
+
if (flagValue === undefined) {
|
|
178
|
+
// Parse args for current flag
|
|
179
|
+
while(result['_'][offset] && !result['_'][offset].startsWith('-')){
|
|
180
|
+
args.push(result['_'][offset++]);
|
|
181
|
+
}
|
|
182
|
+
// Cleanup manually parsed flags + args
|
|
183
|
+
result['_'].splice(i, 1 + args.length);
|
|
184
|
+
// No args were provided, use default value defined in handler
|
|
185
|
+
// One arg was provided, use that directly
|
|
186
|
+
// Multiple args were provided so pass them all in an array
|
|
187
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
188
|
+
} else {
|
|
189
|
+
// Remove the whole flag from the args array
|
|
190
|
+
result['_'].splice(i, 1);
|
|
191
|
+
}
|
|
192
|
+
// Set the resolved value in the `result` object
|
|
193
|
+
result[flagName] = handler.type(flagValue, flagName);
|
|
194
|
+
}
|
|
195
|
+
// Ensure that the `command` is always the first argument in the `args`.
|
|
196
|
+
// This is important so that we don't have to check if a default command
|
|
197
|
+
// (build) was used or not from within each plugin.
|
|
198
|
+
//
|
|
199
|
+
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
200
|
+
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
201
|
+
if (result['_'][0] !== command) {
|
|
202
|
+
result['_'].unshift(command);
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
} catch (err) {
|
|
206
|
+
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
|
207
|
+
(0, _help.help)({
|
|
208
|
+
message: err.message,
|
|
209
|
+
usage: [
|
|
210
|
+
'tailwindcss <command> [options]'
|
|
211
|
+
],
|
|
212
|
+
options: sharedFlags
|
|
213
|
+
});
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
}
|
|
218
|
+
})();
|
|
219
|
+
if (args['--help']) {
|
|
220
|
+
(0, _help.help)({
|
|
221
|
+
options: {
|
|
222
|
+
...flags,
|
|
223
|
+
...sharedFlags
|
|
224
|
+
},
|
|
225
|
+
usage: [
|
|
226
|
+
`tailwindcss ${command} [options]`
|
|
227
|
+
]
|
|
16
228
|
});
|
|
17
|
-
|
|
229
|
+
process.exit(0);
|
|
18
230
|
}
|
|
231
|
+
run(args);
|