tailwindcss 0.0.0-insiders.c834da4 → 0.0.0-insiders.c8bf2d4

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 (81) hide show
  1. package/README.md +1 -1
  2. package/lib/cli/build/plugin.js +30 -25
  3. package/lib/cli/index.js +231 -10
  4. package/lib/cli.js +4 -236
  5. package/lib/corePluginList.js +2 -0
  6. package/lib/corePlugins.js +216 -4
  7. package/lib/css/preflight.css +2 -0
  8. package/lib/featureFlags.js +5 -1
  9. package/lib/index.js +4 -46
  10. package/lib/lib/content.js +16 -16
  11. package/lib/lib/defaultExtractor.js +7 -2
  12. package/lib/lib/detectNesting.js +7 -1
  13. package/lib/lib/expandTailwindAtRules.js +30 -5
  14. package/lib/lib/generateRules.js +92 -56
  15. package/lib/lib/offsets.js +19 -0
  16. package/lib/lib/setupContextUtils.js +84 -37
  17. package/lib/lib/setupTrackingContext.js +25 -4
  18. package/lib/lib/sharedState.js +19 -1
  19. package/lib/oxide/cli/build/deps.js +81 -0
  20. package/lib/oxide/cli/build/index.js +47 -0
  21. package/lib/oxide/cli/build/plugin.js +364 -0
  22. package/lib/oxide/cli/build/utils.js +77 -0
  23. package/lib/oxide/cli/build/watching.js +177 -0
  24. package/lib/oxide/cli/help/index.js +70 -0
  25. package/lib/oxide/cli/index.js +220 -0
  26. package/lib/oxide/cli/init/index.js +35 -0
  27. package/lib/oxide/cli.js +5 -0
  28. package/lib/oxide/postcss-plugin.js +2 -0
  29. package/lib/plugin.js +98 -0
  30. package/lib/util/color.js +16 -2
  31. package/lib/util/dataTypes.js +19 -1
  32. package/lib/util/formatVariantSelector.js +151 -103
  33. package/lib/util/negateValue.js +2 -2
  34. package/lib/util/pluginUtils.js +5 -24
  35. package/lib/util/prefixSelector.js +22 -8
  36. package/package.json +26 -15
  37. package/peers/index.js +108 -173
  38. package/scripts/swap-engines.js +40 -0
  39. package/src/cli/build/plugin.js +12 -7
  40. package/src/cli/index.js +234 -3
  41. package/src/cli.js +4 -231
  42. package/src/corePluginList.js +1 -1
  43. package/src/corePlugins.js +117 -4
  44. package/src/css/preflight.css +2 -0
  45. package/src/featureFlags.js +4 -0
  46. package/src/index.js +4 -46
  47. package/src/lib/content.js +12 -17
  48. package/src/lib/defaultExtractor.js +8 -2
  49. package/src/lib/detectNesting.js +9 -1
  50. package/src/lib/expandTailwindAtRules.js +35 -6
  51. package/src/lib/generateRules.js +106 -56
  52. package/src/lib/offsets.js +22 -0
  53. package/src/lib/setupContextUtils.js +90 -41
  54. package/src/lib/setupTrackingContext.js +31 -6
  55. package/src/lib/sharedState.js +17 -0
  56. package/src/oxide/cli/build/deps.ts +91 -0
  57. package/src/oxide/cli/build/index.ts +47 -0
  58. package/src/oxide/cli/build/plugin.ts +436 -0
  59. package/src/oxide/cli/build/utils.ts +74 -0
  60. package/src/oxide/cli/build/watching.ts +225 -0
  61. package/src/oxide/cli/help/index.ts +69 -0
  62. package/src/oxide/cli/index.ts +212 -0
  63. package/src/oxide/cli/init/index.ts +32 -0
  64. package/src/oxide/cli.ts +1 -0
  65. package/src/oxide/postcss-plugin.ts +1 -0
  66. package/src/plugin.js +107 -0
  67. package/src/util/color.js +17 -2
  68. package/src/util/dataTypes.js +18 -0
  69. package/src/util/formatVariantSelector.js +204 -122
  70. package/src/util/negateValue.js +1 -1
  71. package/src/util/pluginUtils.js +10 -29
  72. package/src/util/prefixSelector.js +28 -10
  73. package/stubs/defaultConfig.stub.js +3 -0
  74. package/types/config.d.ts +11 -1
  75. package/types/generated/corePluginList.d.ts +1 -1
  76. package/types/generated/default-theme.d.ts +5 -2
  77. package/CHANGELOG.md +0 -2352
  78. package/lib/cli/shared.js +0 -12
  79. package/scripts/install-integrations.js +0 -27
  80. package/scripts/rebuildFixtures.js +0 -68
  81. package/src/cli/shared.js +0 -5
package/peers/index.js CHANGED
@@ -3248,7 +3248,7 @@ var require_input = __commonJS({
3248
3248
  if (line && typeof line === "object") {
3249
3249
  let start = line;
3250
3250
  let end = column;
3251
- if (typeof line.offset === "number") {
3251
+ if (typeof start.offset === "number") {
3252
3252
  let pos = this.fromOffset(start.offset);
3253
3253
  line = pos.line;
3254
3254
  column = pos.col;
@@ -3636,7 +3636,8 @@ var require_map_generator = __commonJS({
3636
3636
  }
3637
3637
  if (node && type !== "start") {
3638
3638
  let p = node.parent || { raws: {} };
3639
- if (node.type !== "decl" || node !== p.last || p.raws.semicolon) {
3639
+ let childless = node.type === "decl" || node.type === "atrule" && !node.nodes;
3640
+ if (!childless || node !== p.last || p.raws.semicolon) {
3640
3641
  if (node.source && node.source.end) {
3641
3642
  mapping.source = this.sourcePath(node);
3642
3643
  mapping.original.line = node.source.end.line;
@@ -5576,7 +5577,7 @@ var require_processor = __commonJS({
5576
5577
  var Root = require_root();
5577
5578
  var Processor = class {
5578
5579
  constructor(plugins = []) {
5579
- this.version = "8.4.19";
5580
+ this.version = "8.4.21";
5580
5581
  this.plugins = this.normalize(plugins);
5581
5582
  }
5582
5583
  use(plugin) {
@@ -56608,49 +56609,44 @@ var require_walker = __commonJS({
56608
56609
  var require_package = __commonJS({
56609
56610
  "node_modules/css-tree/package.json"(exports2, module2) {
56610
56611
  module2.exports = {
56611
- _args: [
56612
- [
56613
- "css-tree@1.1.3",
56614
- "/home/runner/work/tailwindcss/tailwindcss"
56615
- ]
56616
- ],
56617
- _development: true,
56618
- _from: "css-tree@1.1.3",
56619
- _id: "css-tree@1.1.3",
56620
- _inBundle: false,
56621
- _integrity: "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==",
56622
- _location: "/css-tree",
56623
- _phantomChildren: {},
56624
- _requested: {
56625
- type: "version",
56626
- registry: true,
56627
- raw: "css-tree@1.1.3",
56628
- name: "css-tree",
56629
- escapedName: "css-tree",
56630
- rawSpec: "1.1.3",
56631
- saveSpec: null,
56632
- fetchSpec: "1.1.3"
56633
- },
56634
- _requiredBy: [
56635
- "/csso",
56636
- "/svgo"
56612
+ name: "css-tree",
56613
+ version: "1.1.3",
56614
+ description: "A tool set for CSS: fast detailed parser (CSS \u2192 AST), walker (AST traversal), generator (AST \u2192 CSS) and lexer (validation and matching) based on specs and browser implementations",
56615
+ author: "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
56616
+ license: "MIT",
56617
+ repository: "csstree/csstree",
56618
+ keywords: [
56619
+ "css",
56620
+ "ast",
56621
+ "tokenizer",
56622
+ "parser",
56623
+ "walker",
56624
+ "lexer",
56625
+ "generator",
56626
+ "utils",
56627
+ "syntax",
56628
+ "validation"
56637
56629
  ],
56638
- _resolved: "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz",
56639
- _spec: "1.1.3",
56640
- _where: "/home/runner/work/tailwindcss/tailwindcss",
56641
- author: {
56642
- name: "Roman Dvornov",
56643
- email: "rdvornov@gmail.com",
56644
- url: "https://github.com/lahmatiy"
56645
- },
56646
- bugs: {
56647
- url: "https://github.com/csstree/csstree/issues"
56630
+ main: "lib/index.js",
56631
+ unpkg: "dist/csstree.min.js",
56632
+ jsdelivr: "dist/csstree.min.js",
56633
+ scripts: {
56634
+ build: "rollup --config",
56635
+ lint: "eslint data lib scripts test && node scripts/review-syntax-patch --lint && node scripts/update-docs --lint",
56636
+ "lint-and-test": "npm run lint && npm test",
56637
+ "update:docs": "node scripts/update-docs",
56638
+ "review:syntax-patch": "node scripts/review-syntax-patch",
56639
+ test: "mocha --reporter progress",
56640
+ coverage: "nyc npm test",
56641
+ travis: "nyc npm run lint-and-test && npm run coveralls",
56642
+ coveralls: "nyc report --reporter=text-lcov | coveralls",
56643
+ prepublishOnly: "npm run build",
56644
+ hydrogen: "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --trace_hydrogen_file=code.cfg --print-opt-code bin/parse --stat -o /dev/null"
56648
56645
  },
56649
56646
  dependencies: {
56650
56647
  "mdn-data": "2.0.14",
56651
56648
  "source-map": "^0.6.1"
56652
56649
  },
56653
- description: "A tool set for CSS: fast detailed parser (CSS \u2192 AST), walker (AST traversal), generator (AST \u2192 CSS) and lexer (validation and matching) based on specs and browser implementations",
56654
56650
  devDependencies: {
56655
56651
  "@rollup/plugin-commonjs": "^11.0.2",
56656
56652
  "@rollup/plugin-json": "^4.0.2",
@@ -56670,43 +56666,7 @@ var require_package = __commonJS({
56670
56666
  "data",
56671
56667
  "dist",
56672
56668
  "lib"
56673
- ],
56674
- homepage: "https://github.com/csstree/csstree#readme",
56675
- jsdelivr: "dist/csstree.min.js",
56676
- keywords: [
56677
- "css",
56678
- "ast",
56679
- "tokenizer",
56680
- "parser",
56681
- "walker",
56682
- "lexer",
56683
- "generator",
56684
- "utils",
56685
- "syntax",
56686
- "validation"
56687
- ],
56688
- license: "MIT",
56689
- main: "lib/index.js",
56690
- name: "css-tree",
56691
- repository: {
56692
- type: "git",
56693
- url: "git+https://github.com/csstree/csstree.git"
56694
- },
56695
- scripts: {
56696
- build: "rollup --config",
56697
- coverage: "nyc npm test",
56698
- coveralls: "nyc report --reporter=text-lcov | coveralls",
56699
- hydrogen: "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --trace_hydrogen_file=code.cfg --print-opt-code bin/parse --stat -o /dev/null",
56700
- lint: "eslint data lib scripts test && node scripts/review-syntax-patch --lint && node scripts/update-docs --lint",
56701
- "lint-and-test": "npm run lint && npm test",
56702
- prepublishOnly: "npm run build",
56703
- "review:syntax-patch": "node scripts/review-syntax-patch",
56704
- test: "mocha --reporter progress",
56705
- travis: "nyc npm run lint-and-test && npm run coveralls",
56706
- "update:docs": "node scripts/update-docs"
56707
- },
56708
- unpkg: "dist/csstree.min.js",
56709
- version: "1.1.3"
56669
+ ]
56710
56670
  };
56711
56671
  }
56712
56672
  });
@@ -60328,50 +60288,50 @@ var require_compress = __commonJS({
60328
60288
  var require_package2 = __commonJS({
60329
60289
  "node_modules/csso/package.json"(exports2, module2) {
60330
60290
  module2.exports = {
60331
- _args: [
60332
- [
60333
- "csso@4.2.0",
60334
- "/home/runner/work/tailwindcss/tailwindcss"
60335
- ]
60336
- ],
60337
- _development: true,
60338
- _from: "csso@4.2.0",
60339
- _id: "csso@4.2.0",
60340
- _inBundle: false,
60341
- _integrity: "sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==",
60342
- _location: "/csso",
60343
- _phantomChildren: {},
60344
- _requested: {
60345
- type: "version",
60346
- registry: true,
60347
- raw: "csso@4.2.0",
60348
- name: "csso",
60349
- escapedName: "csso",
60350
- rawSpec: "4.2.0",
60351
- saveSpec: null,
60352
- fetchSpec: "4.2.0"
60353
- },
60354
- _requiredBy: [
60355
- "/svgo"
60291
+ name: "csso",
60292
+ version: "4.2.0",
60293
+ description: "CSS minifier with structural optimisations",
60294
+ homepage: "https://github.com/css/csso",
60295
+ author: "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (https://github.com/afelix)",
60296
+ maintainers: [
60297
+ {
60298
+ name: "Roman Dvornov",
60299
+ email: "rdvornov@gmail.com",
60300
+ "github-username": "lahmatiy"
60301
+ }
60356
60302
  ],
60357
- _resolved: "https://registry.npmjs.org/csso/-/csso-4.2.0.tgz",
60358
- _spec: "4.2.0",
60359
- _where: "/home/runner/work/tailwindcss/tailwindcss",
60360
- author: {
60361
- name: "Sergey Kryzhanovsky",
60362
- email: "skryzhanovsky@ya.ru",
60363
- url: "https://github.com/afelix"
60364
- },
60365
- browser: {
60366
- "css-tree": "css-tree/dist/csstree.min.js"
60367
- },
60303
+ license: "MIT",
60304
+ repository: "css/csso",
60368
60305
  bugs: {
60369
60306
  url: "https://github.com/css/csso/issues"
60370
60307
  },
60308
+ keywords: [
60309
+ "css",
60310
+ "compress",
60311
+ "minifier",
60312
+ "minify",
60313
+ "optimise",
60314
+ "optimisation",
60315
+ "csstree"
60316
+ ],
60317
+ main: "./lib/index",
60318
+ scripts: {
60319
+ test: "mocha --reporter dot",
60320
+ lint: "eslint lib test",
60321
+ "lint-and-test": "npm run lint && npm test",
60322
+ build: "rollup --config && terser dist/csso.js --compress --mangle -o dist/csso.min.js",
60323
+ coverage: "nyc npm test",
60324
+ coveralls: "nyc report --reporter=text-lcov | coveralls",
60325
+ travis: "nyc npm run lint-and-test && npm run coveralls",
60326
+ hydrogen: "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --trace_hydrogen_file=code.cfg --print-opt-code bin/csso --stat -o /dev/null",
60327
+ prepublishOnly: "npm run build"
60328
+ },
60371
60329
  dependencies: {
60372
60330
  "css-tree": "^1.1.2"
60373
60331
  },
60374
- description: "CSS minifier with structural optimisations",
60332
+ browser: {
60333
+ "css-tree": "css-tree/dist/csstree.min.js"
60334
+ },
60375
60335
  devDependencies: {
60376
60336
  "@rollup/plugin-commonjs": "^11.0.1",
60377
60337
  "@rollup/plugin-json": "^4.0.1",
@@ -60390,42 +60350,7 @@ var require_package2 = __commonJS({
60390
60350
  files: [
60391
60351
  "dist",
60392
60352
  "lib"
60393
- ],
60394
- homepage: "https://github.com/css/csso",
60395
- keywords: [
60396
- "css",
60397
- "compress",
60398
- "minifier",
60399
- "minify",
60400
- "optimise",
60401
- "optimisation",
60402
- "csstree"
60403
- ],
60404
- license: "MIT",
60405
- main: "./lib/index",
60406
- maintainers: [
60407
- {
60408
- name: "Roman Dvornov",
60409
- email: "rdvornov@gmail.com"
60410
- }
60411
- ],
60412
- name: "csso",
60413
- repository: {
60414
- type: "git",
60415
- url: "git+https://github.com/css/csso.git"
60416
- },
60417
- scripts: {
60418
- build: "rollup --config && terser dist/csso.js --compress --mangle -o dist/csso.min.js",
60419
- coverage: "nyc npm test",
60420
- coveralls: "nyc report --reporter=text-lcov | coveralls",
60421
- hydrogen: "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --trace_hydrogen_file=code.cfg --print-opt-code bin/csso --stat -o /dev/null",
60422
- lint: "eslint lib test",
60423
- "lint-and-test": "npm run lint && npm test",
60424
- prepublishOnly: "npm run build",
60425
- test: "mocha --reporter dot",
60426
- travis: "nyc npm run lint-and-test && npm run coveralls"
60427
- },
60428
- version: "4.2.0"
60353
+ ]
60429
60354
  };
60430
60355
  }
60431
60356
  });
@@ -79501,26 +79426,36 @@ function lazyAutoprefixer() {
79501
79426
  function lazyCssnano() {
79502
79427
  return require_src32();
79503
79428
  }
79504
- /*! https://mths.be/cssesc v3.0.0 by @mathias */
79505
- /**
79506
- * @author Ben Briggs
79507
- * @license MIT
79508
- * @module cssnano:preset:default
79509
- * @overview
79510
- *
79511
- * This default preset for cssnano only includes transforms that make no
79512
- * assumptions about your CSS other than what is passed in. In previous
79513
- * iterations of cssnano, assumptions were made about your CSS which caused
79514
- * output to look different in certain use cases, but not others. These
79515
- * transforms have been moved from the defaults to other presets, to make
79516
- * this preset require only minimal configuration.
79517
- */
79518
- /**
79519
- * @license Fraction.js v4.2.0 05/03/2022
79520
- * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
79521
- *
79522
- * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
79523
- * Dual licensed under the MIT or GPL Version 2 licenses.
79524
- **/
79525
- //! stable.js 0.1.8, https://github.com/Two-Screen/stable
79526
- //! © 2018 Angry Bytes and contributors. MIT licensed.
79429
+ /*! Bundled license information:
79430
+
79431
+ fraction.js/fraction.js:
79432
+ (**
79433
+ * @license Fraction.js v4.2.0 05/03/2022
79434
+ * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
79435
+ *
79436
+ * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
79437
+ * Dual licensed under the MIT or GPL Version 2 licenses.
79438
+ **)
79439
+
79440
+ stable/stable.js:
79441
+ (*! stable.js 0.1.8, https://github.com/Two-Screen/stable *)
79442
+ (*! © 2018 Angry Bytes and contributors. MIT licensed. *)
79443
+
79444
+ cssesc/cssesc.js:
79445
+ (*! https://mths.be/cssesc v3.0.0 by @mathias *)
79446
+
79447
+ cssnano-preset-default/src/index.js:
79448
+ (**
79449
+ * @author Ben Briggs
79450
+ * @license MIT
79451
+ * @module cssnano:preset:default
79452
+ * @overview
79453
+ *
79454
+ * This default preset for cssnano only includes transforms that make no
79455
+ * assumptions about your CSS other than what is passed in. In previous
79456
+ * iterations of cssnano, assumptions were made about your CSS which caused
79457
+ * output to look different in certain use cases, but not others. These
79458
+ * transforms have been moved from the defaults to other presets, to make
79459
+ * this preset require only minimal configuration.
79460
+ *)
79461
+ */
@@ -0,0 +1,40 @@
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
+ )
@@ -10,7 +10,7 @@ import loadOptions from 'postcss-load-config/src/options' // Little bit scary, l
10
10
  import tailwind from '../../processTailwindFeatures'
11
11
  import { loadAutoprefixer, loadCssNano, loadPostcss, loadPostcssImport } from './deps'
12
12
  import { formatNodes, drainStdin, outputFile } from './utils'
13
- import { env } from '../shared'
13
+ import { env } from '../../lib/sharedState'
14
14
  import resolveConfig from '../../../resolveConfig.js'
15
15
  import getModuleDependencies from '../../lib/getModuleDependencies.js'
16
16
  import { parseCandidateFiles } from '../../lib/content.js'
@@ -184,10 +184,17 @@ let state = {
184
184
  let files = fastGlob.sync(this.contentPatterns.all)
185
185
 
186
186
  for (let file of files) {
187
- content.push({
188
- content: fs.readFileSync(path.resolve(file), 'utf8'),
189
- extension: path.extname(file).slice(1),
190
- })
187
+ if (env.OXIDE) {
188
+ content.push({
189
+ file,
190
+ extension: path.extname(file).slice(1),
191
+ })
192
+ } else {
193
+ content.push({
194
+ content: fs.readFileSync(path.resolve(file), 'utf8'),
195
+ extension: path.extname(file).slice(1),
196
+ })
197
+ }
191
198
  }
192
199
 
193
200
  // Resolve raw content in the tailwind config
@@ -234,11 +241,9 @@ let state = {
234
241
  env.DEBUG && console.timeEnd('Watch new files')
235
242
  }
236
243
 
237
- env.DEBUG && console.time('Reading content files')
238
244
  for (let file of this.readContentPaths()) {
239
245
  this.context.changedContent.push(file)
240
246
  }
241
- env.DEBUG && console.timeEnd('Reading content files')
242
247
 
243
248
  return this.context
244
249
  },
package/src/cli/index.js CHANGED
@@ -1,3 +1,234 @@
1
- export * from './build'
2
- export * from './config'
3
- export * from './content'
1
+ #!/usr/bin/env node
2
+
3
+ import path from 'path'
4
+ import arg from 'arg'
5
+ import fs from 'fs'
6
+
7
+ import { build } from './build'
8
+ import { help } from './help'
9
+ import { init } from './init'
10
+
11
+ function isESM() {
12
+ const pkgPath = path.resolve('./package.json')
13
+
14
+ try {
15
+ let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
16
+ return pkg.type && pkg.type === 'module'
17
+ } catch (err) {
18
+ return false
19
+ }
20
+ }
21
+
22
+ let configs = isESM()
23
+ ? {
24
+ tailwind: 'tailwind.config.cjs',
25
+ postcss: 'postcss.config.cjs',
26
+ }
27
+ : {
28
+ tailwind: 'tailwind.config.js',
29
+ postcss: 'postcss.config.js',
30
+ }
31
+
32
+ // ---
33
+
34
+ function oneOf(...options) {
35
+ return Object.assign(
36
+ (value = true) => {
37
+ for (let option of options) {
38
+ let parsed = option(value)
39
+ if (parsed === value) {
40
+ return parsed
41
+ }
42
+ }
43
+
44
+ throw new Error('...')
45
+ },
46
+ { manualParsing: true }
47
+ )
48
+ }
49
+
50
+ let commands = {
51
+ init: {
52
+ run: init,
53
+ args: {
54
+ '--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
55
+ '--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
56
+ '-f': '--full',
57
+ '-p': '--postcss',
58
+ },
59
+ },
60
+ build: {
61
+ run: build,
62
+ args: {
63
+ '--input': { type: String, description: 'Input file' },
64
+ '--output': { type: String, description: 'Output file' },
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': { type: Boolean, description: 'Minify the output' },
86
+ '--config': {
87
+ type: String,
88
+ description: 'Path to a custom config file',
89
+ },
90
+ '--no-autoprefixer': {
91
+ type: Boolean,
92
+ description: 'Disable autoprefixer',
93
+ },
94
+ '-c': '--config',
95
+ '-i': '--input',
96
+ '-o': '--output',
97
+ '-m': '--minify',
98
+ '-w': '--watch',
99
+ '-p': '--poll',
100
+ },
101
+ },
102
+ }
103
+
104
+ let sharedFlags = {
105
+ '--help': { type: Boolean, description: 'Display usage information' },
106
+ '-h': '--help',
107
+ }
108
+
109
+ if (
110
+ process.stdout.isTTY /* Detect redirecting output to a file */ &&
111
+ (process.argv[2] === undefined ||
112
+ process.argv.slice(2).every((flag) => sharedFlags[flag] !== undefined))
113
+ ) {
114
+ help({
115
+ usage: [
116
+ 'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
117
+ 'tailwindcss init [--full] [--postcss] [options...]',
118
+ ],
119
+ commands: Object.keys(commands)
120
+ .filter((command) => command !== 'build')
121
+ .map((command) => `${command} [options]`),
122
+ options: { ...commands.build.args, ...sharedFlags },
123
+ })
124
+ process.exit(0)
125
+ }
126
+
127
+ let command = ((arg = '') => (arg.startsWith('-') ? undefined : arg))(process.argv[2]) || 'build'
128
+
129
+ if (commands[command] === undefined) {
130
+ if (fs.existsSync(path.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
+ help({
136
+ message: `Invalid command: ${command}`,
137
+ usage: ['tailwindcss <command> [options]'],
138
+ commands: Object.keys(commands)
139
+ .filter((command) => command !== 'build')
140
+ .map((command) => `${command} [options]`),
141
+ options: sharedFlags,
142
+ })
143
+ process.exit(1)
144
+ }
145
+ }
146
+
147
+ // Execute command
148
+ let { args: flags, run } = commands[command]
149
+ let args = (() => {
150
+ try {
151
+ let result = arg(
152
+ Object.fromEntries(
153
+ Object.entries({ ...flags, ...sharedFlags })
154
+ .filter(([_key, value]) => !value?.type?.manualParsing)
155
+ .map(([key, value]) => [key, typeof value === 'object' ? value.type : value])
156
+ ),
157
+ { permissive: true }
158
+ )
159
+
160
+ // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
161
+ for (let i = result['_'].length - 1; i >= 0; --i) {
162
+ let flag = result['_'][i]
163
+ if (!flag.startsWith('-')) continue
164
+
165
+ let [flagName, flagValue] = flag.split('=')
166
+ let handler = flags[flagName]
167
+
168
+ // Resolve flagName & handler
169
+ while (typeof handler === 'string') {
170
+ flagName = handler
171
+ handler = flags[handler]
172
+ }
173
+
174
+ if (!handler) continue
175
+
176
+ let args = []
177
+ let offset = i + 1
178
+
179
+ // --flag value syntax was used so we need to pull `value` from `args`
180
+ if (flagValue === undefined) {
181
+ // Parse args for current flag
182
+ while (result['_'][offset] && !result['_'][offset].startsWith('-')) {
183
+ args.push(result['_'][offset++])
184
+ }
185
+
186
+ // Cleanup manually parsed flags + args
187
+ result['_'].splice(i, 1 + args.length)
188
+
189
+ // No args were provided, use default value defined in handler
190
+ // One arg was provided, use that directly
191
+ // Multiple args were provided so pass them all in an array
192
+ flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args
193
+ } else {
194
+ // Remove the whole flag from the args array
195
+ result['_'].splice(i, 1)
196
+ }
197
+
198
+ // Set the resolved value in the `result` object
199
+ result[flagName] = handler.type(flagValue, flagName)
200
+ }
201
+
202
+ // Ensure that the `command` is always the first argument in the `args`.
203
+ // This is important so that we don't have to check if a default command
204
+ // (build) was used or not from within each plugin.
205
+ //
206
+ // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
207
+ // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
208
+ if (result['_'][0] !== command) {
209
+ result['_'].unshift(command)
210
+ }
211
+
212
+ return result
213
+ } catch (err) {
214
+ if (err.code === 'ARG_UNKNOWN_OPTION') {
215
+ help({
216
+ message: err.message,
217
+ usage: ['tailwindcss <command> [options]'],
218
+ options: sharedFlags,
219
+ })
220
+ process.exit(1)
221
+ }
222
+ throw err
223
+ }
224
+ })()
225
+
226
+ if (args['--help']) {
227
+ help({
228
+ options: { ...flags, ...sharedFlags },
229
+ usage: [`tailwindcss ${command} [options]`],
230
+ })
231
+ process.exit(0)
232
+ }
233
+
234
+ run(args, configs)