Commit graph

205 commits

Author SHA1 Message Date
Philipp Spiess
7f4b079632 Move Root class to the module scope 2024-09-02 15:27:27 +02:00
Philipp Spiess
4b92050c17 Use DefaultMap instead of plain-old Map 2024-09-02 15:27:27 +02:00
Philipp Spiess
76872c094e Remove todos 2024-09-02 15:27:27 +02:00
Philipp Spiess
5040fb1dcd Cleanups 2024-09-02 15:26:51 +02:00
Philipp Spiess
9ccdf87576 Adding watch files in renderStart doesn't make sense 2024-09-02 15:26:51 +02:00
Philipp Spiess
822f17381d Whoopsie 2024-09-02 15:26:51 +02:00
Philipp Spiess
8395e3f036 Add a test case for moving a file from being a Tailwind root back to a normal CSS file and back 2024-09-02 15:26:51 +02:00
Philipp Spiess
e452c721ee Use a seperate global scanner for module graph candidates 2024-09-02 15:26:51 +02:00
Philipp Spiess
f642a41b1c WIP 2024-09-02 15:26:51 +02:00
Philipp Spiess
19c3ef65a2 Remove debug steps 2024-09-02 15:26:51 +02:00
Philipp Spiess
d7393f95bc Support vite build --watch mode 2024-09-02 15:26:51 +02:00
Philipp Spiess
f0f7418785 Simplify Vite plugin and handle all CSS transforms in pre-transform hook 2024-09-02 15:26:49 +02:00
Philipp Spiess
5789eb789d Do not register ESM hook in Bun 2024-09-02 15:26:31 +02:00
Philipp Spiess
c42664cc6f Add change log and improve error messages 2024-09-02 15:26:31 +02:00
Philipp Spiess
dcb452a0a8 Rename resolveInternal to extractConfigs 2024-09-02 15:26:31 +02:00
Philipp Spiess
9939d344e4 Rename to applyConfigToTheme 2024-09-02 15:26:31 +02:00
Philipp Spiess
8c43650798 Don't block on module dependency resolution 2024-09-02 15:26:31 +02:00
Jordan Pittman
85d6da4884 Make the ESM cache hook ESM-only 2024-09-02 15:26:30 +02:00
Jordan Pittman
1b848f38b0 Make getModuleDependencies async 2024-09-02 15:26:30 +02:00
Philipp Spiess
3666a98a6a Only reset the require cache for build dependencies 2024-09-02 15:26:30 +02:00
Philipp Spiess
266d0184b7 Fix esm cache hook for esm usage with vitest 2024-09-02 15:26:30 +02:00
Philipp Spiess
f37565de7a Fix js config file and plugin dependnecy rebuilds for vite 2024-09-02 15:26:30 +02:00
Philipp Spiess
a72ca61f26 WIP 2024-09-02 15:26:30 +02:00
Philipp Spiess
a5c379386b Add the @tailwindcss/node module to handle shared node specific dependencies between our clients 2024-09-02 15:26:28 +02:00
Philipp Spiess
d607f0a40e Detect changes to the config file and plugins for the CLI 2024-09-02 15:26:04 +02:00
Jordan Pittman
3a7feb7930 wip 2024-09-02 15:26:04 +02:00
Jordan Pittman
7e9db364c9 update test 2024-09-02 15:26:04 +02:00
Jordan Pittman
faf98b364a Upgrade merged theme keys from colors.* to color-* 2024-09-02 15:26:04 +02:00
Jordan Pittman
c13d221d58 Update tests 2024-09-02 15:26:04 +02:00
Jordan Pittman
ea54594515 Handle inline theme keys in resolveWith 2024-09-02 15:26:04 +02:00
Jordan Pittman
5078ccdc9f wip 2024-09-02 15:26:04 +02:00
Jordan Pittman
b44c4f90dc prettier 2024-09-02 15:26:04 +02:00
Jordan Pittman
8ffe833f40 Format code 2024-09-02 15:26:04 +02:00
Jordan Pittman
73b5dfa9e7 Ensure CSS variants and utilities always take precedence 2024-09-02 15:26:04 +02:00
Jordan Pittman
bb89c7c6df Work on theme value merging 2024-09-02 15:26:04 +02:00
Jordan Pittman
f2b7fbae6b Add config test 2024-09-02 15:26:04 +02:00
Jordan Pittman
67efbfe628 Allow configuring dark mode from configs 2024-09-02 15:26:04 +02:00
Jordan Pittman
cc353d310b Merge sources from config files 2024-09-02 15:26:04 +02:00
Jordan Pittman
73ab0a61d7 Load config files via @config directive 2024-09-02 15:26:04 +02:00
Jordan Pittman
f878a90893 Add config helper 2024-09-02 15:26:04 +02:00
Jordan Pittman
20f001cb3c Allow resolve config to take in optional paths alongside configs 2024-09-02 15:26:04 +02:00
Jordan Pittman
f876304557 Add support for presets 2024-09-02 15:26:04 +02:00
Jordan Pittman
3553b5912e Use resolveConfig to normalize plugins 2024-09-02 15:26:04 +02:00
Philipp Spiess
d9e3fd613b
Add standalone CLI (#14270)
This PR adds a new standalone client: A single-binary file that you can
use to run Tailwind v4 without having a node setup. To make this work we
use Bun's single-binary build which can properly package up native
modules and the bun runtime for us so we do not have to rely on any
expand-into-tmp-folder-at-runtime workarounds.

When running locally, `pnpm build` will now standalone artifacts inside
`packages/@tailwindcss-standalone/dist`. Note that since we do not build
Oxide for other environments in the local setup, you won't be able to
use the standalone artifacts for other platforms in local dev mode.

Unfortunately Bun does not have support for Windows ARM builds yet but
we found that using the `bun-baseline` runtime for Windows x64 would
make the builds work fine in ARM emulation mode:

![Screenshot
windows](https://github.com/user-attachments/assets/5b39387f-ec50-4757-9469-19b98e43162d)


Some Bun related issues we faced and worked around:

- We found that the regular Windows x64 build of `bun` does not run on
Windows ARM via emulation. Instead, we have to use the `bun-baseline`
builds which emulate correctly.

- When we tried to bundle artifacts with [embed
directories](https://bun.sh/docs/bundler/executables#embed-directories),
node binary dependencies were no longer resolved correctly even though
they would still be bundled and accessible within the [`embeddedFiles`
list](https://bun.sh/docs/bundler/executables#listing-embedded-files).
We worked around this by using the `import * as from ... with { type:
"file" };` and patching the resolver we use in our CLI.
  
  
- If you have an import to a module that is used as a regular import
_and_ a `with { type: "file" }`, it will either return the module in
both cases _or_ the file path when we would expect only the `with {
type: "file" }` import to return the path. We do read the Tailwind CSS
version via the file system and `require.resolve()` in the CLI and via
`import * from './package.json'` in core and had to work around this by
patching the version resolution in our CLI.
 
  ```ts
  import packageJson from "./package.json"
  import packageJsonPath from "./package.json" with {type: "file"}
  
  // We do not expect these to be equal
  packageJson === packageJsonPath 
  ```
- We can not customize the app icon used for Windows `.exe` builds
without decompiling the binary. For now we will leave the default but
one workaround is to [use tools like
ResourceHacker](698d9c4bd1)
to decompile the binary first.

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2024-09-02 15:23:46 +02:00
Philipp Spiess
ac6d4a6e8e
Spreading tailwindcss/defaultTheme exports keeps bare values (#14257)
In #14221 we added a new export to the `tailwindcss` package:
`tailwindcss/defaultTheme`. This is build on top of the full config from
V3 and will allow plugins to keep being compatible.

However, spreading in from this package has overwritten the bare value
callback handler. This PR fixes it by sharing the bare value callbacks
with the compat config.
2024-08-29 14:05:41 +02:00
Jordan Pittman
fa8253e42a
Fix support for declaration fallbacks in plugins (#14265)
This PR fixes support for "fallback" values for declarations in plugins.

A plugin using `addUtilities`, `matchUtilities`, `addComponents`, etc…
should be able to specify "fallback" values for declarations by passing
an array as the value of a declaration however this does not currently
work in v4 (but it does in v3):

```js
export default {
  plugins: [
    function ({ addUtilities }) {
      addUtilities({
        '.outlined': {
          outline: ['1px solid ButtonText', '1px auto -webkit-focus-ring-color'],
        },
      })
    },
  ],
};
```

After this PR the candidate `outlined` will now produce the following
CSS — like it does in v3:

```css
.outlined {
  outline: 1px solid ButtonText;
  outline: 1px auto -webkit-focus-ring-color;
}
```
2024-08-27 12:18:53 +02:00
Philipp Spiess
f5499aac95
Fix issues with the CSS theme() function (#14262)
While working on #14257, we noticed two issues with the CSS `theme()`
function:

1. In V3 it's possible to set arrays inside the theme object. An example
for this is the default font families as defined here:
https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L303-L311.
We now properly join these arrays that are not tuples.
2. We noticed that in the case where there are no modifiers, the
fallback values for the CSS `theme()` function had the first word
removed. A regression test for this was added.
2024-08-26 18:55:27 +02:00
Philipp Spiess
0796653527
Correctly merge tuple values when using the plugin API (#14260)
We noticed that when the `defaultTheme` (change for this is coming in
#14257) defines a tuple that is also defined in the CSS theme, the
values are incorrectly merged as objects instead of overwritten.
However, CSS theme values should take precedence, even when they use
tuple syntax.

Proper coverage of this will come once `#14257` is merged when calling
`theme(fontSize.xs[1].lineHeight)` will also have a default value passed
in from the `defaultTheme`.
2024-08-26 16:23:52 +02:00
Philipp Spiess
ab8972749c
Postcss: Bring back proper type exports (#14256)
Closes #14253

Since we changed the export strategy for the postcss client in #14132,
we accidentally no longer generated type exports for this package.

This PR adds a type export back. We now use a similar pattern to the
`./colors` and `./defaultTheme` exports in the tailwindcss package where
we have a separate cjs entrypoint.

The changes were validated manually in a playground project that were
installing the updated dependencies from tarballs.

Here is one example of it working as expected:
 
<img width="750" alt="Screenshot 2024-08-26 at 14 10 07"
src="https://github.com/user-attachments/assets/83de15f2-1543-4805-9231-9b8df1636c5e">
2024-08-26 15:54:07 +02:00
Philipp Spiess
d5f563b746
Prepare v4.0.0-alpha.20 (#14244)
Prepare next `4.0.0-alpha.20` release
2024-08-23 15:51:53 +02:00