Commit graph

4999 commits

Author SHA1 Message Date
Robin Malfait
a1246de6a5
WIP: New @apply logic
use `lightningcss` and `prettier` for `toMatchFormattedCss`

Lightning CSS applies some optimizations and prettier ensures that the
output is always formatted in the same way.

In a future version, we will be using Lightning CSS to apply
optimizations like handling the nesting, optimizing selectors, sorting
declarations, simplifying colors and so on.

To guarantee that we have the same output in both the normal version and
OXIDE version, we can apply lightningcss in our tests so that it always
produces correct results in both version with the same optimizations
applied.

This also aliases `toMatchCss` to `toMatchFormattedCss` so that we can
guarantee the same output. This has a small caveat where `lightningcss`
is pretty strict. It will complain about `@media screen(md) {}` for
example. This is correct because it is not valid CSS, but we eventually
take care of it.
In this case, we will catch the error and use prettier instead (since
this should only happen in tests that doesn't use end-to-end tests, but
uses a more specialized test instead). If prettier still finds an error,
we will ensure to throw the original error.

Eventually, all the "lower" level tests, should probably become higher
level end-to-end tests. But let's do everything step by step!
2023-01-05 16:20:24 +01:00
Adam Wathan
d378bc3b5c
Remove autoprefixer and cssnano from oxide CLI 2023-01-05 16:03:27 +01:00
Robin Malfait
28e7f92a44
setup lightningcss 2023-01-05 16:03:26 +01:00
Robin Malfait
ef3369c5b8
drop --postcss flag 2023-01-05 16:01:58 +01:00
Robin Malfait
b1dae3bb5e
make CLI files TypeScript files 2023-01-05 16:01:58 +01:00
Robin Malfait
fcb96f6847
copy cli to oxide/cli 2023-01-05 16:01:58 +01:00
Adam Wathan
a92f798117
Clean up tests for TS 2023-01-05 16:01:58 +01:00
Adam Wathan
7da6d23c4d
Update scripts 2023-01-05 16:01:58 +01:00
Adam Wathan
e3d27e89b9
Move TS to ./src/oxide 2023-01-05 16:01:58 +01:00
Jordan Pittman
9fa15877bd
Include new compiled typescript stuff when publishing 2023-01-05 16:01:58 +01:00
Jordan Pittman
9b6a2c7c5e
Defer to existing CLI for Oxide 2023-01-05 16:01:58 +01:00
Robin Malfait
8b7cf61cf3
WIP 2023-01-05 16:01:58 +01:00
Robin Malfait
2c73675c7f
drop prepublishOnly
I don't think we actually need this anymore (or even want because this
is trying to do things in CI that we don't want to happen. Aka, build
the Oxide Rust code, it is already a dependency).
2023-01-05 16:01:58 +01:00
Robin Malfait
9838839e47
publish tailwindcss@oxide 2023-01-05 16:01:58 +01:00
Robin Malfait
60b8fa3881
use @tailwindcss/oxide dependency 2023-01-05 16:01:56 +01:00
Robin Malfait
487bf93233
re-enable workflows 2023-01-05 16:01:46 +01:00
Robin Malfait
b00b5635f0
skip tests in oxide mode regarding custom separators in arbitrary variants 2023-01-05 16:01:46 +01:00
Jordan Pittman
0a6e97c122
Don’t match empty arbitrary values 2023-01-05 16:01:45 +01:00
Jordan Pittman
19b1e54ab5
Fix failing tests 2023-01-05 16:01:45 +01:00
Jordan Pittman
ee5da2e271
Include only unique values for tests
Really, what we care about most is that the list contains every expected candidate. Not necessarily how many times it shows up because while many candidates will show up A LOT in a source text we’ll unique them before passing them back to anything that needs them
2023-01-05 16:01:45 +01:00
Robin Malfait
b643c9e669
fix range to include \n 2023-01-05 16:01:45 +01:00
Robin Malfait
cceb585777
add failing tests
I noticed that some of the tests were failing, and while looking at
them, it happened because the tests were structured like this:

```html
    <div
      class="
        backdrop-filter
        backdrop-filter-none
        backdrop-blur-lg
        backdrop-brightness-50
        backdrop-contrast-0
        backdrop-grayscale
        backdrop-hue-rotate-90
        backdrop-invert
        backdrop-opacity-75
        backdrop-saturate-150
        backdrop-sepia
      "
    ></div>
```

This means that the class names themselves eventually end up like this: `backdrop-filter-none\n`
-> (Notice the `\n`)

/cc @thecrypticace
2023-01-05 16:01:45 +01:00
Robin Malfait
0c211a8bd0
sort test output
This happened because the sorting happens in this branch, but changes
happened on the `master` branch.
2023-01-05 16:01:45 +01:00
Robin Malfait
efb6015641
improve CI for the Oxide build 2023-01-05 16:01:43 +01:00
Robin Malfait
531125def7
enable tracing based on DEBUG env 2023-01-05 16:01:13 +01:00
Jordan Pittman
30b7d3fcc2
wip 2023-01-05 16:01:13 +01:00
Robin Malfait
52edffba86
cargo fmt 2023-01-05 16:01:13 +01:00
Robin Malfait
208eeb99f5
remove into_par_iter where it doesn't make sense 2023-01-05 16:01:13 +01:00
Robin Malfait
b643d399db
use oxide
- Setup the codebase to be able to use the Rust parts based on an
  environment variable: `OXIDE=1`.
- Setup some tests that run both the non-Rust and Rust version in the
  same test.
- Sort the candidates in a consistent way, to guarantee the order for
  now (especially in tests).
- Reflect sorting related changes in tests.
- Ensure tests run in both the Rust and non-Rust version. (Some tests
  are explicitly skipped when using the Rust version since we haven't
  implemented those features yet. These include: custom prefix,
  transformers and extractors).
  - `jest`
  -`OXIDE=1 jest`
2023-01-05 16:01:11 +01:00
Robin Malfait
cc92ef53a6
add oxide
Our Rust related parts
2023-01-05 15:57:17 +01:00
Robin Malfait
e7135052ac
temporarily disable workflows 2023-01-05 15:57:16 +01:00
Justin Wong
7b3de616e9
Fix missing blocklist type (#10239)
* Fix missing `blocklist` type

* Update changelog
2023-01-04 11:53:07 +01:00
Jordan Pittman
5d828248bc Update changelog 2023-01-03 15:46:56 -05:00
Jordan Pittman
ec5136c19a
Fix perf regression when checking for changed content (#10234)
* Commit changes to mod time cache all at once

This allows us to track changes in files that are both a context and content dependency in a way that preserves file mod checking optimizations

* fixup
2023-01-03 15:45:51 -05:00
Jordan Pittman
7d8eb21de6
Don't prefix classes in arbitrary variants (#10214)
* Add tests

* Refactor

refactor

* Allow `prefixSelector` to take an AST

* Consider multiple formats in `finalizeSelector`

The functions `finalizeSelector` and `formatVariantSelector` together were using a mix for AST and string-based parsing. This now does the full transformation using the selector AST. This also parses the format strings AST as early as possible and is set up to parse them only once for a given set of rules.

All of this will allow considering metadata per format string. For instance, we now know if the format string `.foo &` was produced by a normal variant or by an arbitrary variant. We use this information to control the prefixing behavior for individual format strings.

* Update changelog

* Cleanup code a bit
2023-01-03 09:40:47 -05:00
Robin Malfait
2b885ef252
Allow direct nesting in root or @layer nodes (#10229)
* hide nesting warnings in `root` or `@layer` nodes

* update changelog
2023-01-03 12:38:30 +01:00
Jordan Pittman
3a8e95d848
Match arbitrary properties even when followed by square bracketed text (#10212)
* Match arbitrary properties even when followed by square bracketed text

* Update changelog
2023-01-02 09:43:07 -05:00
depfu[bot]
5594c3bec9 Update @swc/cli to version 0.1.59 2023-01-01 05:27:44 +00:00
depfu[bot]
8b13ecfe16 Update eslint to version 8.30.0 2022-12-30 22:14:46 +00:00
depfu[bot]
dc26c5e3f8 Update @swc/core to version 1.3.24 2022-12-28 12:13:11 +00:00
Adam Wathan
941ef21774
Update CHANGELOG.md 2022-12-27 10:21:31 -05:00
depfu[bot]
a795e4554f
Update esbuild to version 0.16.10 (#10178)
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2022-12-27 10:20:36 -05:00
depfu[bot]
8462d6708b Update prettier to version 2.8.1 2022-12-22 06:55:34 +00:00
Nikolai Grushkovsky
41e655dd0b
Fix GitHub workflow badge (#10120)
See badges/shields#8671
2022-12-19 10:44:47 +01:00
depfu[bot]
6998ca418a Update postcss to version 8.4.20 2022-12-18 17:58:58 +00:00
depfu[bot]
03d2a04b3e Update @swc/jest to version 0.2.24 2022-12-17 00:28:32 +00:00
Jordan Pittman
51b6224e6a
Update list of length units (#10100)
* Update length units

* Update changelog
2022-12-16 10:16:12 -05:00
Nikolai Grushkovsky
c834da4e80
Fix missing string[] in the dropShadow type (#10072)
* Fix missing `string[]` in the `dropShadow` type

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-12-14 09:48:49 -05:00
sibbng
ce7ac96e88
Properly handle subtraction followed by a variable in arbitrary values (#10074)
* fix normalizing subtraction followed by a variable

* Add test

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-12-14 09:27:34 -05:00
Jordan Pittman
25d17db78c
Prevent invalid arbitrary variant selectors from failing the build (#10059)
* Refactor

* Prevent invalid arbitrary variant selectors from failing the build

* Update changelog

* Fix CS
2022-12-12 11:03:53 -05:00