tailwindcss/src/util
Robin Malfait 7e9a53f6cb
Enable ESM and TS based config files (#10785)
* add `jiti` and `detective-typescript` dependencies

* use `jiti` and `detective-typescript`

Instead of `detective`, this way we will be able to support
`tailwind.config.ts` files and `ESM` files.

* use `@swc/core` instead of the built-in `babel` form `jiti`

* update changelog

* add `jiti` and `detective-typescript` dependencies to `stable`

* use `sucrase` to transform the configs

* add `sucrase` dependency to `stable` engine

* make loading the config easier

* use abstracted loading config utils

* WIP: make `load` related files public API

* use new config loader in PostCSS plugin

* add list of default config files to look for

* cleanup unused arguments

* find default config path when using CLI

* improve `init` command

* make eslint happy

* keep all files in `stubs` folder

* add `tailwind.config.js` stub file

* Initialize PostCSS config using the same format as Tailwind config

* Rename config content stubs to config.*.js

* Improve option descriptions for init options

* Remove unused code, remove `constants` file

* Fix TS warning

* apply CLI changes to the Oxide version

* update `--help` output in CLI tests

* WIP: make tests work on CI

TODO: Test all combinations of `--full`, `--ts`, `--postcss`, and `--esm`.

* wip

* remove unused `fs`

* Fix init tests

Did you know you could pass an empty args to a command? No? Me neither. ¯\_(ツ)_/¯

* bump `napi-derive`

* list extensions we are interested in

* no-op the `removeFile` if file doesn't exist

* ensure all `init` flags work

* ensure we cleanup the new files

* test ESM/CJS generation based on package.json

* remove unnecessary test

We are not displaying output in the `--help` anymore based on whether
`type: module` is present or not.
Therefore this test is unneeded.

* only look for `TypeScript` files when the entryFile is `TypeScript` as well

* refactor `load` to be `loadConfig`

This will allow you to use:

```js
import loadConfig from 'tailwindcss/loadConfig'

let config = loadConfig("/Users/xyz/projects/my-app/tailwind.config.ts")
```

The `loadConfig` function will return the configuration object based on
the given absolute path of a tailwind configuration file.

The given path can be a CJS, an ESM or a TS file.

* use the `config.full.js` stub instead of the `defaultConfig.stub.js` file

The root `defaultConfig` is still there for backwards compatibilty
reasons. But the `module.exports = requrie('./config.full.js')` was
causing some problems when actually using tailwindcss.

So dropped it instead.

* apply `load` -> `loadConfig` changes to `Oxide` engine CLI

* ensure we write the config file in the Oxide engine

* improve type in Oxide engine CLI

* catch errors instead of checking if the file exists

A little smaller but just for tests so doesn't matter too much here 👍

* ensure we publish the correct stub files

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Nate Moore <nate@natemoo.re>
Co-authored-by: Enzo Innocenzi <enzo@innocenzi.dev>
2023-03-15 17:04:18 -04:00
..
bigSign.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
buildMediaQuery.js Add new min and max variants (#9558) 2022-10-14 14:25:25 -04:00
cloneDeep.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
cloneNodes.js Don't rewrite source maps for @layer rules (#8971) 2022-07-27 12:19:08 -04:00
color.js Parse alpha value from rgba/hsla colors when using variables (#10429) 2023-01-31 14:36:38 -05:00
configurePlugins.js Make it possible to enable caretColor and content core plugins in AOT mode (#4548) 2021-06-03 15:27:22 +02:00
createPlugin.js ensure options for plugins are not stale between builds (#2695) 2020-10-28 13:46:12 -04:00
createUtilityPlugin.js Make negative values a first-class feature, rather than theme-driven (#5709) 2021-10-06 13:42:05 -04:00
dataTypes.js Revert "Prepare for the v3.2.6" 2023-02-08 17:39:43 +01:00
defaults.js Move defaults to their own always-on layer (#6500) 2021-12-14 12:21:38 -05:00
escapeClassName.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
escapeCommas.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
flattenColorPalette.js Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
formatVariantSelector.js Fix use of :where(.btn) when matching !btn (#10601) 2023-02-16 10:13:42 -05:00
getAllConfigs.js Enable ESM and TS based config files (#10785) 2023-03-15 17:04:18 -04:00
hashConfig.js Ignore unknown types when hashing config 2021-05-06 13:16:32 -04:00
isKeyframeRule.js Fix malformed keyframes when using class variants (#5223) 2021-08-16 12:25:30 -04:00
isPlainObject.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
isSyntacticallyValidPropertyValue.js Rename isValidArbitraryValue 2022-11-17 15:19:31 -05:00
log.js Remove process dependency from log functions (#8530) 2022-06-07 11:23:32 +02:00
nameClass.js Add generalized modifier support to matchUtilities (#9541) 2022-10-13 14:01:17 -04:00
negateValue.js Oxide (#10252) 2023-01-13 12:22:00 +01:00
normalizeConfig.js Enable relative content paths for the oxide engine (#10621) 2023-02-17 21:42:10 +01:00
normalizeScreens.js Add new min and max variants (#9558) 2022-10-14 14:25:25 -04:00
parseAnimationValue.js ensure we don't override the name (#5602) 2021-09-26 07:44:41 -04:00
parseBoxShadowValue.js Improve data type analyses for arbitrary values (#9320) 2022-09-14 14:08:56 +02:00
parseDependency.js Allow resolving content paths relative to the config file (#9396) 2022-09-23 08:09:02 -04:00
parseGlob.js Allow resolving content paths relative to the config file (#9396) 2022-09-23 08:09:02 -04:00
parseObjectStyles.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
pluginUtils.js Fix use of :where(.btn) when matching !btn (#10601) 2023-02-16 10:13:42 -05:00
prefixSelector.js Don't prefix classes in arbitrary variants (#10214) 2023-01-03 09:40:47 -05:00
removeAlphaVariables.js Remove text opacity CSS variables from ::marker (#8622) 2022-06-14 10:09:09 -04:00
resolveConfig.js Cleanup unused variantOrder (#9829) 2022-11-14 12:18:44 +01:00
resolveConfigPath.js Enable ESM and TS based config files (#10785) 2023-03-15 17:04:18 -04:00
responsive.js Replaces use of Lodash isArray with built-in Array.isArray 2019-07-13 16:52:07 +02:00
splitAtTopLevelOnly.js Disallow multi-selector arbitrary variants (#10655) 2023-02-22 14:44:54 -05:00
tap.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
toColorValue.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
toPath.js Support alpha values for theme() function (#8416) 2022-05-25 13:54:30 -04:00
transformThemeValue.js Fix theme(fontFamily.*) when family contains fontFeatureSettings config (#9217) 2022-08-30 17:18:41 +01:00
validateConfig.js Move some config error checking out of resolveConfig (#8362) 2022-05-16 10:10:40 -04:00
validateFormalSyntax.js Improve type checking for formal syntax (#9448) 2022-09-29 18:24:51 +02:00
withAlphaVariable.js Replace rgb and hsl helpers with <alpha-value> placeholder for colors with custom properties (#8501) 2022-06-02 10:21:20 -04:00