typed-css-modules
typed-css-modules copied to clipboard
Only handle '.css' files in writeFile
Description
Chokidar can trigger writeFile for files that glob() does not (see example of issue in screenshot).
In our case, starting watch on pattern packages/**/*.module.css in a monorepo has chokidar trigger for files like:
packages/apps/WebApp/node_modules/.bin/lint-stagedpackages/apps/WebApp/node_modules/.bin/prettier
It seems that the issue is caused by chokidar using glob-parent that handles recursive patterns in a different way than glob.
Solution
Adding an extra precaution that checks .css extension before writing file to skip avoidable error logs.
Not perfect but feels ok to require .css-extension in this module.
Error screenshot