Skip to content

Commit af774e8

Browse files
Improve the CLI output when nothing changed (#14351)
When we observe that no new candidates were found, then we can return early because nothing really changed. There is also no need to re-optimize (use Lightning CSS) in this case. But this had a side effect that when no new candidates were detected, that you didn't see any output either. This feels like nothing is working from a DX perspective. Typically you are changing things, so it's not really a problem. But the moment you use a class that already existed (e.g.: in another file) you also don't get any output because we have a shared cache. This PR solves that by always showing the output. But it still doesn't write to disk if nothing changed. --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent c37473e commit af774e8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Ensure there is always CLI feedback on save even when no new classes were found ([#14351](https://github.com/tailwindlabs/tailwindcss/pull/14351))
1113

1214
## [4.0.0-alpha.23] - 2024-09-05
1315

packages/@tailwindcss-cli/src/commands/build/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,13 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
236236
else if (rebuildStrategy === 'incremental') {
237237
let newCandidates = scanner.scanFiles(changedFiles)
238238

239-
// No candidates found which means we don't need to rebuild. This can
240-
// happen if a file is detected but doesn't match any of the globs.
241-
if (newCandidates.length <= 0) return
239+
// No new candidates found which means we don't need to write to
240+
// disk, and can return early.
241+
if (newCandidates.length <= 0) {
242+
let end = process.hrtime.bigint()
243+
eprintln(`Done in ${formatDuration(end - start)}`)
244+
return
245+
}
242246

243247
compiledCss = compiler.build(newCandidates)
244248
}

0 commit comments

Comments
 (0)