4437 Commits

Author SHA1 Message Date
depfu[bot]
ee35abd97e Update esbuild to version 0.14.10 2022-01-07 16:58:20 +00:00
Robin Malfait
8e0ccda1a1
3.0.12 v3.0.12 2022-01-07 17:42:18 +01:00
Robin Malfait
3dc93c06a3
update changelog 2022-01-07 17:42:11 +01:00
Jordan Pittman
f2d73b8c3d
Change how we handle defaults (optimized or not) (#6926)
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2022-01-07 11:39:45 -05:00
Jesper
4bc9ca7d8b
End 'Reading changed files' timer in debug mode (#6954) 2022-01-07 17:08:15 +01:00
Robin Malfait
fe08e919dc
Ensure @apply works consistently with or without @layer (#6938)
* partition nodes as soon as possible

Time to write another story on `@apply`...

When we write code like this:

```css
.a {
  @apply b;
}

.b {
  @apply uppercase;
  color: red;
}
```

Then we create 2 Nodes in our context to keep track of. One has
identifier `a`, the other has identifier `b`. However, when we have an
`@apply` and it contains multiple declarations/atrules, then we have to
split up the (aka partition) node into multiple nodes so that we can
guarantee the correct expected sort order.

This means that the above example technically looks like this:

```css
.a {
  @apply b;
}

.b {
  @apply uppercase;
}

.b {
  color: red;
}
```

If this was your input, then we would still have 1 node for identifier
'a', but we would have 2 nodes for identifier 'b'.

As mentioned earlier, this is important to guarantee the correct order,
here is an example:

```css
.b {
  @apply md:font-bold xl:font-normal; /* Here we can sort by our
  internal rules. This means that the `md` comes before `xl`. */
}
```

... however

```css
.b {
  @apply xl:font-normal; /* This now exists _before_ the example below */
}

.b {
  @apply md:font-bold; /* Because we respect the order of the user's css */
}
```

So to guarantee the order when doing this:
```css
.b {
  @apply xl:font-normal;
  @apply lg:font-normal;
}
```

We also split this up into 2 nodes like this:
```css
.b {
  @apply xl:font-normal;
}
.b {
  @apply lg:font-normal;
}
```

The tricky part is that now only 1 empty `.b` node exists in our context
because we partitioned the orginal node into multiple nodes and moved
the children to the new nodes and because they are new nodes it means
that they have a different identity.

This partitioning used to happen in the expandApplyAtRules code, but
this is a bit too late because the context has already been filled at
this time. Instead, we move the code more to the front, as if you wrote
those separated blocks yourself. Now the code to inject those nodes into
the context happens in a single spot instead of multiple places.

Another good part about this is that we have better consistency between
each layer because it turns out that these two examples generated
different results...

```css
.a {
  @apply b;
}
.b {
  @apply uppercase;
  color: red;
}
```

... is different compared to:

```css
@tailwind components;
@layer components {
  .a {
    @apply b;
  }
  .b {
    @apply uppercase;
    color: red;
  }
}
```

Even if both `a` and `b` are being used in one of your content paths...
Yeah.. *sigh*

* add more `@apply` related tests

* update changelog

* remove support for basic nesting (leftover)

* remove leftover todo

This has been fixed already
2022-01-07 16:41:01 +01:00
Jonathan Reinink
9c72add3b7
Update changelog 2022-01-06 08:20:58 -05:00
Robin Malfait
4562b7cd59
update changelog 2022-01-06 14:17:55 +01:00
Max Veytsman
93e5717f73
Switch to using linuxstatic build target (#6914) 2022-01-06 08:13:44 -05:00
depfu[bot]
ece160cfe9 Update postcss-selector-parser to version 6.0.8 2022-01-06 12:43:34 +00:00
Robin Malfait
21fe083db0
Ensure we can apply classes defined with non-"on-demandable" selectors (#6922)
* improve extractCandidates

When we have a css rule that is defined as `.foo, .bar {}`, then we will
crawl each selector and link it to the same node. This is useful because
now our Map looks something like this:

```js
Map(2) { 'foo' => Node {}, 'bar' => Node {} }
```

This allows us to later on `@apply foo` or `@apply bar` and we can do a
direct lookup for this "candidate".

When we have css defined as `span {}`, then we consider this
"non-ondemandable". This means that we will _always_ inject these rules
into the `*` section and call it a day.

However, it could happen that you have something like this: `span, .foo
{}` up until now this was totally fine. It contains a non-ondemandable
selector (`span`) and therefore we injected this into that `*` section.

However, the issue occurs if you now try to `@apply foo`. Since we had
an early return for this use case it didn't endup in our Map from above
and now you get an error like:

```
The `foo` class does not exist. If `foo` is a custom class, make sure it
is defined within a `@layer` directive."
```

So instead what we will do is keep track whether or not a css rule
contains any on-demandable classes. If this is the case then we still
generate it always by putting it in that `*` section. However, we will
still register all on-demandable classes in our Map (in this case `.foo`).

This allows us to `@apply foo` again!

* update changelog
2022-01-06 13:27:14 +01:00
Jordan Pittman
82f163d425
Fix use of falsy values in theme config (#6917) 2022-01-05 16:37:07 -05:00
depfu[bot]
fc6c27d95b Update autoprefixer to version 10.4.1 2022-01-05 16:43:58 +00:00
Jonathan Reinink
bd4dddd71a
Update CHANGELOG.md 2022-01-05 09:34:36 -05:00
Robin Malfait
a00b9fb692
3.0.11 v3.0.11 2022-01-05 14:39:14 +01:00
Robin Malfait
24c1f8df83
update changelog 2022-01-05 14:39:06 +01:00
Robin Malfait
e3612d3d13
update changelog 2022-01-05 14:38:18 +01:00
Jordan Pittman
9fdc391d4f Revert apply defaults in isolation 2022-01-05 08:36:30 -05:00
Robin Malfait
5f49e53aba
Ignore content files that don't exist (#6901)
* ignore content files that don't exist

PostCSS CLI will give you a fake file path that ends in /stdin if you
are reading from stdin.

* update changelog
2022-01-05 14:18:41 +01:00
Jordan Pittman
78fb761d75
Preserve case of css variables added by plugins (#6888) 2022-01-04 23:03:41 -05:00
Robin Malfait
30ea5b14a6
3.0.10 v3.0.10 2022-01-04 19:02:12 +01:00
Robin Malfait
83852dc3de
update changelog 2022-01-04 19:02:06 +01:00
Robin Malfait
657bf5f8c9
Allow piping data into the CLI (#6876)
* use outputFile instead of direct writeFile

This is an improvement we introduced earlier but forgot this part.

* allow to pipe in data to the CLI

* add integration tests to validate piping to the CLI

* update changelog
2022-01-04 18:58:55 +01:00
Jordan Pittman
058a9256ae
Emit defaults from apply in css modules (#6875)
* Emit defaults from apply in css modules

* Update changelog
2022-01-04 11:29:33 -05:00
Robin Malfait
41e32bd9a7
update changelog 2022-01-04 16:30:00 +01:00
Geoffrey
0bcd628ec3
Avoid writing to output files when no changes (#6550)
* fix(cli): avoid write same output when no changes

* generalize outputFile

This function will check a cache, it will only write the file if:
- The modified timestamps changed since last time we wrote something.
  This is useful to know if something changed by another tool or
  manually without diffing the full file.
- The contents changed.

* further simplify checks

Turns out that reading files and comparing them is fairly fast and there
is no huge benefit over only using the Stats of the file and keeping
track of that information.

Thanks @kentcdodds!

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-01-04 16:29:16 +01:00
Gary Mathews
722232cb2e
Allow all classes for @apply (#6580)
* Always include css with apply in context

* Use let

We use it more consistently

* Remove early return

To match the style of the surrounding code

* Don't return layer directives

They do not need to be returned here. If it's needed in the future its easy enough to add it back.

* Use let

* Update changelog

* fix typo

And re-format comments

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-01-04 14:23:10 +01:00
Robin Malfait
51b3c0a458
3.0.9 v3.0.9 2022-01-03 18:42:31 +01:00
Robin Malfait
1b691fa48f
update changelog 2022-01-03 18:42:06 +01:00
Robin Malfait
87b5d2d3da
update changelog
Improve wording a bit.
2022-01-03 17:47:42 +01:00
Robin Malfait
1cbb29faeb
Remove the watching context (#6858)
* remove watching context

* update changelog
2022-01-03 17:45:31 +01:00
Robin Malfait
b9af5a916b
Improve collapsing of duplicate declarations (#6856)
* improve collapsing of duplicate properties

In theory, we don't have to do anything because the browser is smart
enough to figure everything out. However, leaving in duplicate
properties is not that ideal for file size.

Our previous method was pretty simple: if you see a declaration you
already saw in this rule, delete the previous one and keep the current
one.

This works pretty well, but this gets rid of **all** the declarations
with the same property. This is not great for overrides for older
browsers.

In a perfect world, we can handle this based on your target browser but
this is a lot of unnecessary complexity and will slow things down
performance wise.

Alternative, we improved the solution by being a bit smarter:
1. Delete duplicate declarations that have the same property and value
   (this will get rid of **exact** duplications).
2. Delete declarations with the same property and the same **unit**.

This means that we will reduce this:
```css
.example {
  height: 50%;
  height: 100px;
  height: 20vh;
  height: 30%;
  height: 50px;
  height: 30vh;
  transform: var(--value);
  transform: var(--value);
}
```

To:
```diff-css
  .example {
-   height: 50%;    /* Another height exists later with a `%` unit */
-   height: 100px;  /* Another height exists later with a `px` unit */
-   height: 20vh;   /* Another height exists later with a `vh` unit */
    height: 30%;
    height: 50px;
    height: 30vh;
-   transform: var(--value); /* Value is too complex, but is **exactly** the same as the one below */
    transform: var(--value);
  }
```

This will reduce the values that we are 100% sure that can be safely
removed. This will still result in some overrides but the browser can
handle those for you.

Fixes: #6844

* update changelog
2022-01-03 15:41:49 +01:00
Robin Malfait
3149738035
Properly detect theme() value usage in arbitrary properties (#6854)
* properly detect theme value in arbitrary properties

* update changelog
2022-01-03 13:12:43 +01:00
Robin Malfait
c912434e0b
Validate theme() works in arbitray values (#6852)
* add tests to ensure theme value inside arbitrary values work

* update changelog
2022-01-03 11:29:18 +01:00
Robin Malfait
b341813d3f
Ensure we can use < and > characters in modifiers (#6851)
* ensure we can use "special" characters in modifiers

Fixes: #6778

* update changelog
2022-01-03 11:17:58 +01:00
Robin Malfait
875c850b37
Improve DEBUG parsing: only take care of tailwindcss and not tailwind (#6804)
* only take care of `tailwindcss` and not `tailwind`

* update changelog
2021-12-30 16:41:23 +01:00
Robin Malfait
10710b08b9
Improve DEBUG flag (#6797)
* improve DEBUG flag

* update changelog
2021-12-29 23:51:30 +01:00
depfu[bot]
07c3e95322 Update jest to version 27.4.5 2021-12-29 14:15:05 +00:00
Adam Wathan
a1c7868340 Update changelog 2021-12-28 16:17:29 -05:00
Adam Wathan
49f76ed23a 3.0.8 v3.0.8 2021-12-28 16:10:13 -05:00
Adam Wathan
bc82352b95 Update changelog 2021-12-28 16:09:58 -05:00
Philipp Schmid
2317533a57
Add standalone-cli node16-linux-arm64 build (#6693) 2021-12-28 16:06:49 -05:00
depfu[bot]
5b72a064c5 Update cssnano to version 5.0.14 2021-12-27 13:03:18 +00:00
depfu[bot]
2de4308b59 Update @swc/jest to version 0.2.15 2021-12-27 11:00:03 +00:00
depfu[bot]
8776db71da Update postcss to version 8.4.5 2021-12-25 15:13:37 +00:00
Adam Wathan
c40b0552df Update changelog 2021-12-24 13:21:18 -05:00
Adam Wathan
1d5aa27e79
Support HSL with hue units in arbitrary values (#6726) 2021-12-24 13:20:35 -05:00
Adam Wathan
da7396cf77 Sketching out more specific tests for our default extractor 2021-12-24 12:56:53 -05:00
depfu[bot]
7114fa96d9 Update prettier to version 2.5.1 2021-12-23 14:14:50 +00:00
depfu[bot]
66412062b8 Update @swc/cli to version 0.1.55 2021-12-22 04:29:00 +00:00