diff --git a/lib/util/cssFiles.js b/lib/util/cssFiles.js index 324a42b..4c4fbb4 100644 --- a/lib/util/cssFiles.js +++ b/lib/util/cssFiles.js @@ -1,6 +1,6 @@ 'use strict'; -const fg = require('fast-glob'); +const { globSync } = require('tinyglobby'); const fs = require('fs'); const postcss = require('postcss'); const lastClassFromSelectorRegexp = /\.([^\.\,\s\n\:\(\)\[\]\'~\+\>\*\\]*)/gim; @@ -29,24 +29,24 @@ const generateClassnamesListSync = (patterns, refreshRate = 5_000) => { // Update classnames from CSS files lastUpdate = now; const filesToBeRemoved = new Set([...cssFilesInfos.keys()]); - const files = fg.sync(patterns, { suppressErrors: true, stats: true }); + const files = globSync(patterns, { expandDirectories: false }); for (const file of files) { let mtime = ''; - let canBeSkipped = cssFilesInfos.has(file.path); + let canBeSkipped = cssFilesInfos.has(file); if (canBeSkipped) { // This file is still used - filesToBeRemoved.delete(file.path); + filesToBeRemoved.delete(file); // Check modification date - const stats = fs.statSync(file.path); + const stats = fs.statSync(file); mtime = `${stats.mtime || ''}`; - canBeSkipped = cssFilesInfos.get(file.path).mtime === mtime; + canBeSkipped = cssFilesInfos.get(file).mtime === mtime; } if (canBeSkipped) { // File did not change since last run continue; } // Parse CSS file - const data = fs.readFileSync(file.path, 'utf-8'); + const data = fs.readFileSync(file, 'utf-8'); const root = postcss.parse(data); let detectedClassnames = new Set(); root.walkRules((rule) => { @@ -55,7 +55,7 @@ const generateClassnamesListSync = (patterns, refreshRate = 5_000) => { detectedClassnames = new Set([...detectedClassnames, ...classnames]); }); // Save the detected classnames - cssFilesInfos.set(file.path, { + cssFilesInfos.set(file, { mtime: mtime, classNames: [...detectedClassnames], }); diff --git a/package-lock.json b/package-lock.json index 203c3f2..b3b15a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,10 @@ "version": "4.0.0-beta.0", "license": "MIT", "dependencies": { - "fast-glob": "^3.2.5", "postcss": "^8.4.4", "synckit": "^0.11.4", - "tailwind-api-utils": "^1.0.3" + "tailwind-api-utils": "^1.0.3", + "tinyglobby": "^0.2.12" }, "devDependencies": { "@angular-eslint/template-parser": "^15.2.0", @@ -2710,6 +2710,51 @@ "node": ">=0.8" } }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -4858,6 +4903,28 @@ "thenify": ">= 3.1.0 < 4" } }, + "tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "requires": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "dependencies": { + "fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "requires": {} + }, + "picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==" + } + } + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index c7b132f..1e06055 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ "tailwindcss": "^3.4.0 || ^4.0.0" }, "dependencies": { - "fast-glob": "^3.2.5", "postcss": "^8.4.4", "synckit": "^0.11.4", - "tailwind-api-utils": "^1.0.3" + "tailwind-api-utils": "^1.0.3", + "tinyglobby": "^0.2.12" }, "devDependencies": { "@angular-eslint/template-parser": "^15.2.0",