tailwindcss/packages/@tailwindcss-cli/src/utils
Robin Malfait b03e5e7731
Lazy load @parcel/watcher (#20325)
This PR ensure that we lazy load the `@parcel/watcher` in the
`@tailwindcss/cli`. This means that we don't have to load it at all when
using a normal build or when using `--watch --poll` combination.

The bigger reason is that on some platforms `@parcel/watcher` might not
work, and therefore the build will fail even if you don't use `--watch`
at all.

This PR fixes that by lazy loading it. Then, if we can't load it when
using `--watch`, a useful workaround is shown by using `--watch --poll`
instead.

This PR also improves showing errors such that the `error.cause`
property can be rendered as well.

Maybe in the future we can make use of deferred imports
(https://github.com/tc39/proposal-defer-import-eval)

Fixes: #20322

## Test plan

1. All tests still pass [ci-all]
2. Fabricated a fake error locally to prove that we can still use a
normal build and `--watch --poll` as a workaround

<img width="1122" height="1376"
alt="file-2f91d99cfb9eb0e24a196c2dd358c1f3"
src="https://github.com/user-attachments/assets/e37658ee-0827-422e-bd50-8ea5a85e1b7c"
/>
2026-07-13 15:53:42 +02:00
..
args.test.ts Add --poll option to @tailwindcss/cli (#20297) 2026-07-01 21:25:26 +02:00
args.ts Only use the last value when parsing duplicate cli arguments (#19416) 2025-12-07 12:26:22 -05:00
disposables.ts Fix macOS test flakiness (#14869) 2024-11-04 13:07:25 -05:00
format-ns.test.ts Move the CLI to its own package @tailwindcss/cli (#13095) 2024-03-06 05:41:12 -05:00
format-ns.ts Move the CLI to its own package @tailwindcss/cli (#13095) 2024-03-06 05:41:12 -05:00
renderer.test.ts Add tailwindcss canonicalize sub-command (#19783) 2026-03-11 20:30:21 +01:00
renderer.ts Lazy load @parcel/watcher (#20325) 2026-07-13 15:53:42 +02:00
resolve.ts Add standalone CLI (#14270) 2024-09-02 15:23:46 +02:00
test-helpers.ts Add tailwindcss canonicalize sub-command (#19783) 2026-03-11 20:30:21 +01:00