tailwindcss 3.4.0 → 3.4.2

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +40 -1
  2. package/README.md +2 -3
  3. package/lib/cli/build/plugin.js +4 -11
  4. package/lib/cli.js +1 -5
  5. package/lib/corePluginList.js +1 -0
  6. package/lib/corePlugins.js +92 -25
  7. package/lib/css/preflight.css +4 -3
  8. package/lib/featureFlags.js +2 -6
  9. package/lib/lib/content.js +36 -3
  10. package/lib/lib/defaultExtractor.js +2 -2
  11. package/lib/lib/expandApplyAtRules.js +13 -0
  12. package/lib/lib/expandTailwindAtRules.js +20 -32
  13. package/lib/lib/generateRules.js +13 -2
  14. package/lib/lib/load-config.js +4 -0
  15. package/lib/lib/offsets.js +51 -2
  16. package/lib/lib/resolveDefaultsAtRules.js +3 -1
  17. package/lib/lib/setupContextUtils.js +23 -3
  18. package/lib/lib/sharedState.js +2 -10
  19. package/lib/plugin.js +0 -50
  20. package/lib/processTailwindFeatures.js +0 -2
  21. package/lib/util/dataTypes.js +12 -2
  22. package/lib/util/pseudoElements.js +3 -0
  23. package/package.json +5 -8
  24. package/peers/index.js +61 -61
  25. package/src/cli/build/plugin.js +4 -11
  26. package/src/cli.js +1 -5
  27. package/src/corePluginList.js +1 -1
  28. package/src/corePlugins.js +88 -27
  29. package/src/css/preflight.css +4 -3
  30. package/src/featureFlags.js +2 -6
  31. package/src/lib/content.js +42 -1
  32. package/src/lib/defaultExtractor.js +2 -2
  33. package/src/lib/expandApplyAtRules.js +17 -0
  34. package/src/lib/expandTailwindAtRules.js +23 -41
  35. package/src/lib/generateRules.js +12 -2
  36. package/src/lib/load-config.ts +5 -0
  37. package/src/lib/offsets.js +61 -2
  38. package/src/lib/resolveDefaultsAtRules.js +5 -1
  39. package/src/lib/setupContextUtils.js +28 -2
  40. package/src/lib/sharedState.js +0 -4
  41. package/src/plugin.js +0 -60
  42. package/src/processTailwindFeatures.js +0 -3
  43. package/src/util/dataTypes.js +13 -1
  44. package/src/util/pseudoElements.js +4 -0
  45. package/types/config.d.ts +7 -0
  46. package/types/generated/corePluginList.d.ts +1 -1
  47. package/lib/lib/detectNesting.js +0 -45
  48. package/lib/oxide/cli/build/deps.js +0 -89
  49. package/lib/oxide/cli/build/index.js +0 -53
  50. package/lib/oxide/cli/build/plugin.js +0 -375
  51. package/lib/oxide/cli/build/utils.js +0 -87
  52. package/lib/oxide/cli/build/watching.js +0 -179
  53. package/lib/oxide/cli/help/index.js +0 -72
  54. package/lib/oxide/cli/index.js +0 -214
  55. package/lib/oxide/cli/init/index.js +0 -52
  56. package/lib/oxide/cli.js +0 -5
  57. package/lib/oxide/postcss-plugin.js +0 -2
  58. package/scripts/swap-engines.js +0 -40
  59. package/src/lib/detectNesting.js +0 -47
  60. package/src/oxide/cli/build/deps.ts +0 -91
  61. package/src/oxide/cli/build/index.ts +0 -47
  62. package/src/oxide/cli/build/plugin.ts +0 -442
  63. package/src/oxide/cli/build/utils.ts +0 -74
  64. package/src/oxide/cli/build/watching.ts +0 -225
  65. package/src/oxide/cli/help/index.ts +0 -69
  66. package/src/oxide/cli/index.ts +0 -204
  67. package/src/oxide/cli/init/index.ts +0 -59
  68. package/src/oxide/cli.ts +0 -1
  69. package/src/oxide/postcss-plugin.ts +0 -1
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "help", {
6
- enumerable: true,
7
- get: function() {
8
- return help;
9
- }
10
- });
11
- const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../../../package.json"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- function help({ message , usage , commands , options }) {
18
- let indent = 2;
19
- // Render header
20
- console.log();
21
- console.log(`${_packagejson.default.name} v${_packagejson.default.version}`);
22
- // Render message
23
- if (message) {
24
- console.log();
25
- for (let msg of message.split("\n")){
26
- console.log(msg);
27
- }
28
- }
29
- // Render usage
30
- if (usage && usage.length > 0) {
31
- console.log();
32
- console.log("Usage:");
33
- for (let example of usage){
34
- console.log(" ".repeat(indent), example);
35
- }
36
- }
37
- // Render commands
38
- if (commands && commands.length > 0) {
39
- console.log();
40
- console.log("Commands:");
41
- for (let command of commands){
42
- console.log(" ".repeat(indent), command);
43
- }
44
- }
45
- // Render options
46
- if (options) {
47
- let groupedOptions = {};
48
- for (let [key, value] of Object.entries(options)){
49
- if (typeof value === "object") {
50
- groupedOptions[key] = {
51
- ...value,
52
- flags: [
53
- key
54
- ]
55
- };
56
- } else {
57
- groupedOptions[value].flags.push(key);
58
- }
59
- }
60
- console.log();
61
- console.log("Options:");
62
- for (let { flags , description , deprecated } of Object.values(groupedOptions)){
63
- if (deprecated) continue;
64
- if (flags.length === 1) {
65
- console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
66
- } else {
67
- console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
68
- }
69
- }
70
- }
71
- console.log();
72
- }
@@ -1,214 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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
- // ---
18
- function oneOf(...options) {
19
- return Object.assign((value = true)=>{
20
- for (let option of options){
21
- let parsed = option(value);
22
- if (parsed === value) {
23
- return parsed;
24
- }
25
- }
26
- throw new Error("...");
27
- }, {
28
- manualParsing: true
29
- });
30
- }
31
- let commands = {
32
- init: {
33
- run: _init.init,
34
- args: {
35
- "--esm": {
36
- type: Boolean,
37
- description: `Initialize configuration file as ESM`
38
- },
39
- "--ts": {
40
- type: Boolean,
41
- description: `Initialize configuration file as TypeScript`
42
- },
43
- "--full": {
44
- type: Boolean,
45
- description: `Include the default values for all options in the generated configuration file`
46
- },
47
- "-f": "--full"
48
- }
49
- },
50
- build: {
51
- run: _build.build,
52
- args: {
53
- "--input": {
54
- type: String,
55
- description: "Input file"
56
- },
57
- "--output": {
58
- type: String,
59
- description: "Output file"
60
- },
61
- "--watch": {
62
- type: oneOf(String, Boolean),
63
- description: "Watch for changes and rebuild as needed"
64
- },
65
- "--poll": {
66
- type: Boolean,
67
- description: "Use polling instead of filesystem events when watching"
68
- },
69
- "--content": {
70
- type: String,
71
- description: "Content paths to use for removing unused classes"
72
- },
73
- "--minify": {
74
- type: Boolean,
75
- description: "Minify the output"
76
- },
77
- "--config": {
78
- type: String,
79
- description: "Path to a custom config file"
80
- },
81
- "-c": "--config",
82
- "-i": "--input",
83
- "-o": "--output",
84
- "-m": "--minify",
85
- "-w": "--watch",
86
- "-p": "--poll"
87
- }
88
- }
89
- };
90
- let sharedFlags = {
91
- "--help": {
92
- type: Boolean,
93
- description: "Display usage information"
94
- },
95
- "-h": "--help"
96
- };
97
- if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
98
- (0, _help.help)({
99
- usage: [
100
- "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
101
- "tailwindcss init [--full] [options...]"
102
- ],
103
- commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
104
- options: {
105
- ...commands.build.args,
106
- ...sharedFlags
107
- }
108
- });
109
- process.exit(0);
110
- }
111
- let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
112
- if (commands[command] === undefined) {
113
- if (_fs.default.existsSync(_path.default.resolve(command))) {
114
- // TODO: Deprecate this in future versions
115
- // Check if non-existing command, might be a file.
116
- command = "build";
117
- } else {
118
- (0, _help.help)({
119
- message: `Invalid command: ${command}`,
120
- usage: [
121
- "tailwindcss <command> [options]"
122
- ],
123
- commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
124
- options: sharedFlags
125
- });
126
- process.exit(1);
127
- }
128
- }
129
- // Execute command
130
- let { args: flags , run } = commands[command];
131
- let args = (()=>{
132
- try {
133
- let result = (0, _arg.default)(Object.fromEntries(Object.entries({
134
- ...flags,
135
- ...sharedFlags
136
- }).filter(([_key, value])=>{
137
- var _value_type;
138
- return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
139
- }).map(([key, value])=>[
140
- key,
141
- typeof value === "object" ? value.type : value
142
- ])), {
143
- permissive: true
144
- });
145
- // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
146
- for(let i = result["_"].length - 1; i >= 0; --i){
147
- let flag = result["_"][i];
148
- if (!flag.startsWith("-")) continue;
149
- let [flagName, flagValue] = flag.split("=");
150
- let handler = flags[flagName];
151
- // Resolve flagName & handler
152
- while(typeof handler === "string"){
153
- flagName = handler;
154
- handler = flags[handler];
155
- }
156
- if (!handler) continue;
157
- let args = [];
158
- let offset = i + 1;
159
- // --flag value syntax was used so we need to pull `value` from `args`
160
- if (flagValue === undefined) {
161
- // Parse args for current flag
162
- while(result["_"][offset] && !result["_"][offset].startsWith("-")){
163
- args.push(result["_"][offset++]);
164
- }
165
- // Cleanup manually parsed flags + args
166
- result["_"].splice(i, 1 + args.length);
167
- // No args were provided, use default value defined in handler
168
- // One arg was provided, use that directly
169
- // Multiple args were provided so pass them all in an array
170
- flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
171
- } else {
172
- // Remove the whole flag from the args array
173
- result["_"].splice(i, 1);
174
- }
175
- // Set the resolved value in the `result` object
176
- result[flagName] = handler.type(flagValue, flagName);
177
- }
178
- // Ensure that the `command` is always the first argument in the `args`.
179
- // This is important so that we don't have to check if a default command
180
- // (build) was used or not from within each plugin.
181
- //
182
- // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
183
- // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
184
- if (result["_"][0] !== command) {
185
- result["_"].unshift(command);
186
- }
187
- return result;
188
- } catch (err) {
189
- if (err.code === "ARG_UNKNOWN_OPTION") {
190
- (0, _help.help)({
191
- message: err.message,
192
- usage: [
193
- "tailwindcss <command> [options]"
194
- ],
195
- options: sharedFlags
196
- });
197
- process.exit(1);
198
- }
199
- throw err;
200
- }
201
- })();
202
- if (args["--help"]) {
203
- (0, _help.help)({
204
- options: {
205
- ...flags,
206
- ...sharedFlags
207
- },
208
- usage: [
209
- `tailwindcss ${command} [options]`
210
- ]
211
- });
212
- process.exit(0);
213
- }
214
- run(args);
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "init", {
6
- enumerable: true,
7
- get: function() {
8
- return init;
9
- }
10
- });
11
- const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- function isESM() {
19
- const pkgPath = _path.default.resolve("./package.json");
20
- try {
21
- let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
22
- return pkg.type && pkg.type === "module";
23
- } catch (err) {
24
- return false;
25
- }
26
- }
27
- function init(args) {
28
- let messages = [];
29
- let isProjectESM = args["--ts"] || args["--esm"] || isESM();
30
- let syntax = args["--ts"] ? "ts" : isProjectESM ? "js" : "cjs";
31
- let extension = args["--ts"] ? "ts" : "js";
32
- var _args___;
33
- let tailwindConfigLocation = _path.default.resolve((_args___ = args["_"][1]) !== null && _args___ !== void 0 ? _args___ : `./tailwind.config.${extension}`);
34
- if (_fs.default.existsSync(tailwindConfigLocation)) {
35
- messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
36
- } else {
37
- let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../../stubs/config.simple.js"), "utf8");
38
- let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../../stubs/tailwind.config.${syntax}`), "utf8");
39
- // Change colors import
40
- stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
41
- // Replace contents of {ts,js,cjs} file with the stub {simple,full}.
42
- stubFile = stubFile.replace("__CONFIG__", stubContentsFile.replace("module.exports =", "").trim()).trim() + "\n\n";
43
- _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
44
- messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
45
- }
46
- if (messages.length > 0) {
47
- console.log();
48
- for (let message of messages){
49
- console.log(message);
50
- }
51
- }
52
- }
package/lib/oxide/cli.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- require("./cli/index");
@@ -1,2 +0,0 @@
1
- "use strict";
2
- module.exports = require("../plugin.js");
@@ -1,40 +0,0 @@
1
- let fs = require('fs')
2
- let path = require('path')
3
-
4
- let engines = {
5
- stable: {
6
- files: [
7
- path.resolve(__dirname, '..', 'package.stable.json'),
8
- path.resolve(__dirname, '..', 'package-lock.stable.json'),
9
- ],
10
- },
11
- oxide: {
12
- files: [
13
- path.resolve(__dirname, '..', 'package.oxide.json'),
14
- path.resolve(__dirname, '..', 'package-lock.oxide.json'),
15
- ],
16
- },
17
- }
18
-
19
- // Find out what the current engine is that we are using:
20
- let [otherEngine, info] = Object.entries(engines).find(([, info]) =>
21
- info.files.every((file) => fs.existsSync(file))
22
- )
23
- let currentEngine = otherEngine === 'oxide' ? 'stable' : 'oxide'
24
-
25
- console.log(`Current engine: \`${currentEngine}\`, swapping to \`${otherEngine}\``)
26
-
27
- // Swap the engines
28
- for (let file of info.files) {
29
- fs.renameSync(
30
- file.replace(`.${otherEngine}`, ''),
31
- file.replace(`.${otherEngine}`, `.${currentEngine}`)
32
- )
33
- }
34
- for (let file of engines[otherEngine].files) {
35
- fs.renameSync(file, file.replace(`.${otherEngine}`, ''))
36
- }
37
-
38
- console.log(
39
- 'Engines have been swapped. Make sure to run `npm install` to update your dependencies.'
40
- )
@@ -1,47 +0,0 @@
1
- function isRoot(node) {
2
- return node.type === 'root'
3
- }
4
-
5
- function isAtLayer(node) {
6
- return node.type === 'atrule' && node.name === 'layer'
7
- }
8
-
9
- export default function (_context) {
10
- return (root, result) => {
11
- let found = false
12
-
13
- root.walkAtRules('tailwind', (node) => {
14
- if (found) return false
15
-
16
- if (node.parent && !(isRoot(node.parent) || isAtLayer(node.parent))) {
17
- found = true
18
- node.warn(
19
- result,
20
- [
21
- 'Nested @tailwind rules were detected, but are not supported.',
22
- "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
23
- 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
24
- ].join('\n')
25
- )
26
- return false
27
- }
28
- })
29
-
30
- root.walkRules((rule) => {
31
- if (found) return false
32
-
33
- rule.walkRules((nestedRule) => {
34
- found = true
35
- nestedRule.warn(
36
- result,
37
- [
38
- 'Nested CSS was detected, but CSS nesting has not been configured correctly.',
39
- 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
40
- 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
41
- ].join('\n')
42
- )
43
- return false
44
- })
45
- })
46
- }
47
- }
@@ -1,91 +0,0 @@
1
- import packageJson from '../../../../package.json'
2
- import browserslist from 'browserslist'
3
- import { Result } from 'postcss'
4
-
5
- import {
6
- // @ts-ignore
7
- lazyPostcss,
8
-
9
- // @ts-ignore
10
- lazyPostcssImport,
11
-
12
- // @ts-ignore
13
- lazyCssnano,
14
-
15
- // @ts-ignore
16
- } from '../../../../peers/index'
17
-
18
- export function lazyLightningCss() {
19
- // TODO: Make this lazy/bundled
20
- return require('lightningcss')
21
- }
22
-
23
- let lightningCss
24
-
25
- function loadLightningCss() {
26
- if (lightningCss) {
27
- return lightningCss
28
- }
29
-
30
- // Try to load a local version first
31
- try {
32
- return (lightningCss = require('lightningcss'))
33
- } catch {}
34
-
35
- return (lightningCss = lazyLightningCss())
36
- }
37
-
38
- export async function lightningcss(shouldMinify: boolean, result: Result) {
39
- let css = loadLightningCss()
40
-
41
- try {
42
- let transformed = css.transform({
43
- filename: result.opts.from || 'input.css',
44
- code: Buffer.from(result.css, 'utf-8'),
45
- minify: shouldMinify,
46
- sourceMap: !!result.map,
47
- inputSourceMap: result.map ? result.map.toString() : undefined,
48
- targets: css.browserslistToTargets(browserslist(packageJson.browserslist)),
49
- drafts: {
50
- nesting: true,
51
- },
52
- })
53
-
54
- return Object.assign(result, {
55
- css: transformed.code.toString('utf8'),
56
- map: result.map
57
- ? Object.assign(result.map, {
58
- toString() {
59
- return transformed.map.toString()
60
- },
61
- })
62
- : result.map,
63
- })
64
- } catch (err) {
65
- console.error('Unable to use Lightning CSS. Using raw version instead.')
66
- console.error(err)
67
-
68
- return result
69
- }
70
- }
71
-
72
- /**
73
- * @returns {import('postcss')}
74
- */
75
- export function loadPostcss() {
76
- // Try to load a local `postcss` version first
77
- try {
78
- return require('postcss')
79
- } catch {}
80
-
81
- return lazyPostcss()
82
- }
83
-
84
- export function loadPostcssImport() {
85
- // Try to load a local `postcss-import` version first
86
- try {
87
- return require('postcss-import')
88
- } catch {}
89
-
90
- return lazyPostcssImport()
91
- }
@@ -1,47 +0,0 @@
1
- import fs from 'fs'
2
- import path from 'path'
3
- import { resolveDefaultConfigPath } from '../../../util/resolveConfigPath'
4
- import { createProcessor } from './plugin'
5
-
6
- export async function build(args) {
7
- let input = args['--input']
8
- let shouldWatch = args['--watch']
9
-
10
- // TODO: Deprecate this in future versions
11
- if (!input && args['_'][1]) {
12
- console.error('[deprecation] Running tailwindcss without -i, please provide an input file.')
13
- input = args['--input'] = args['_'][1]
14
- }
15
-
16
- if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
17
- console.error(`Specified input file ${args['--input']} does not exist.`)
18
- process.exit(9)
19
- }
20
-
21
- if (args['--config'] && !fs.existsSync((args['--config'] = path.resolve(args['--config'])))) {
22
- console.error(`Specified config file ${args['--config']} does not exist.`)
23
- process.exit(9)
24
- }
25
-
26
- // TODO: Reference the @config path here if exists
27
- let configPath = args['--config'] ? args['--config'] : resolveDefaultConfigPath()
28
-
29
- let processor = await createProcessor(args, configPath)
30
-
31
- if (shouldWatch) {
32
- // Abort the watcher if stdin is closed to avoid zombie processes
33
- // You can disable this behavior with --watch=always
34
- if (args['--watch'] !== 'always') {
35
- process.stdin.on('end', () => process.exit(0))
36
- }
37
-
38
- process.stdin.resume()
39
-
40
- await processor.watch()
41
- } else {
42
- await processor.build().catch((e) => {
43
- console.error(e)
44
- process.exit(1)
45
- })
46
- }
47
- }