tailwindcss/src/lib
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
..
cacheInvalidation.js Invalidate context when main css changes (#7626) 2022-02-25 13:12:45 -05:00
collapseAdjacentRules.js Handle duplicate atrules without children (#8122) 2022-04-15 12:24:27 -04:00
collapseDuplicateDeclarations.js Improve collapsing of duplicate declarations (#6856) 2022-01-03 15:41:49 +01:00
content.js Oxide (#10252) 2023-01-13 12:22:00 +01:00
defaultExtractor.js Match arbitrary properties even when followed by square bracketed text (#10212) 2023-01-02 09:43:07 -05:00
detectNesting.js Allow direct nesting in root or @layer nodes (#10229) 2023-01-03 12:38:30 +01:00
evaluateTailwindFunctions.js Don't emit utilities containing invalid theme fn keys (#9319) 2022-09-14 13:27:01 -04:00
expandApplyAtRules.js Only sort pseudo elements after classes when using @apply and variants (#9765) 2022-11-09 16:41:16 -05:00
expandTailwindAtRules.js drop oxide api shim 2023-02-08 17:34:33 +01:00
findAtConfigPath.js Improve warning messages (#9608) 2022-10-19 18:35:42 +02:00
generateRules.js Disallow multi-selector arbitrary variants (#10655) 2023-02-22 14:44:54 -05:00
getModuleDependencies.js Enable ESM and TS based config files (#10785) 2023-03-15 17:04:18 -04:00
load-config.ts Enable ESM and TS based config files (#10785) 2023-03-15 17:04:18 -04:00
normalizeTailwindDirectives.js Improve various warnings (#7118) 2022-01-19 15:09:13 -05:00
offsets.js Sort by layer inside variants layer (#10505) 2023-02-06 16:27:01 +01:00
partitionApplyAtRules.js Fix consecutive builds with at apply producing different CSS (#6999) 2022-01-10 12:36:14 -05:00
regex.js Rewrite default class extractor (#8204) 2022-05-04 16:08:25 -04:00
remap-bitfield.js Sort arbitrary variants deterministically regardless of content order (#10016) 2022-12-08 09:05:46 -05:00
resolveDefaultsAtRules.js Split ::backdrop into separate defaults group (#8567) 2022-06-09 16:26:18 -04:00
setupContextUtils.js Sort class lists deterministically for Prettier plugin (#10672) 2023-02-23 13:32:24 -05:00
setupTrackingContext.js Enable ESM and TS based config files (#10785) 2023-03-15 17:04:18 -04:00
sharedState.js Separate stable and oxide engines (#10359) 2023-01-19 11:58:25 -05:00
substituteScreenAtRules.js Add tuple syntax to guarantee screens order (#6104) 2021-11-16 18:01:06 +01:00