Skip to content

Commit

Permalink
Replace fast-glob with a lighter tinyglobby (#165)
Browse files Browse the repository at this point in the history
* Replace `fast-glob` with `tinyglobby`

`tinyglobby` uses `picomatch` under the hood which default to
case-sensitive matching. Not sure what are the performance
implications of performing such matching on Unix systems, but in case
we want to preserve the distinction, an update in `tinyglobby` would be
needed to expose the underlying `picomatch` options or add a new
top-level one that'd control the `nocase` flag.

* Update the README after changing the glob provider

* Remove `packageManager` from `package.json`

* Reorder the import

* Bump `tinyglobby`

* Fix test failures in CI and on Windows

* Always match case-insensitively

* Remove `packageManager` again (sorry)
  • Loading branch information
ziebam authored Sep 8, 2024
1 parent 71b3a20 commit dd13095
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ module.exports = {
Type: `string|string[]`

Similar to [`mixinsDir`](#mixinsdir); except, you can provide
[fast-glob](https://github.com/mrmlnc/fast-glob) syntax to target or not target
[tinyglobby](https://github.com/SuperchupuDev/tinyglobby) syntax to target or not target
specific files.

```js
Expand Down
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
let glob = require('fast-glob')
let { readFileSync } = require('node:fs')
let { platform } = require('node:os')
let { basename, extname, join, relative } = require('node:path')
let { parse } = require('postcss-js')
let vars = require('postcss-simple-vars')
let sugarss = require('sugarss')
let { globSync } = require('tinyglobby')

let MIXINS_GLOB = '*.{js,cjs,mjs,json,css,sss,pcss}'
let IS_WIN = platform().includes('win32')

function addMixin(helpers, mixins, rule, file) {
let name = rule.params.split(/\s/, 1)[0]
Expand Down Expand Up @@ -48,7 +46,7 @@ function processModulesForHotReloadRecursively(module, helpers) {

function loadGlobalMixin(helpers, globs) {
let cwd = process.cwd()
let files = glob.sync(globs, { caseSensitiveMatch: IS_WIN })
let files = globSync(globs, { caseSensitiveMatch: false })
let mixins = {}
files.forEach(i => {
let ext = extname(i).toLowerCase()
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"postcss": "^8.2.14"
},
"dependencies": {
"fast-glob": "^3.3.2",
"postcss-js": "^4.0.1",
"postcss-simple-vars": "^7.0.1",
"sugarss": "^4.0.1"
"sugarss": "^4.0.1",
"tinyglobby": "^0.2.6"
},
"devDependencies": {
"@logux/eslint-config": "^53.4.0",
Expand Down
33 changes: 30 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd13095

Please sign in to comment.