Skip to content

Commit 8123fa5

Browse files
authored
Vite plugin: stop checking CSS files that no longer exist (tailwindlabs#13197)
* Vite plugin: stop checking CSS files that no longer exist Fix a potential memory leak in the Vite plugin. If CSS files are created that include `@tailwind` and later deleted, remove them from the list of files checked. Thanks to @timneutkens for highlighting this issue. * Vite plugin: don't log when files are removed
1 parent 5c5037d commit 8123fa5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/@tailwindcss-vite/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export default function tailwindcss(): Plugin[] {
2121
if (!server) return
2222

2323
let updates: Update[] = []
24-
for (let id of cssModules) {
24+
for (let id of cssModules.values()) {
2525
let cssModule = server.moduleGraph.getModuleById(id)
2626
if (!cssModule) {
27-
console.log('Could not find css module', id)
27+
// It is safe to remove the item here since we're iterating on a copy of
28+
// the values.
29+
cssModules.delete(id)
2830
continue
2931
}
3032

0 commit comments

Comments
 (0)