fix(js): update tinyglobby to speed up shallow file matching (#30415)

`tinyglobby` at `0.2.10` (what we use now) is slow on shallow files, but
the latest version `0.2.12` is fast due to this PR
https://github.com/SuperchupuDev/tinyglobby/pull/69/files.

This PR updates both the js and esbuild plugins to use the newest
versions, but also adds `tinyglobby@^0.2.12` to our root `package.json`
so we get the speed increase right away. I removed `fast-glob` in our
repo scripts and replaced it with `tinyglobby`.

## Current Behavior
Asset handling is slow for shallow files like `LICENSE` but is fine for
scoped patterns like `src/**/*.ts`.

## Expected Behavior
Asset handling should be fast for shallow files.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jack Hsu 2025-03-19 09:20:18 -04:00 committed by GitHub
parent 851138cabd
commit e0cae539d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 233 additions and 236 deletions

View File

@ -355,7 +355,6 @@
"cliui": "^8.0.1", "cliui": "^8.0.1",
"core-js": "3.36.1", "core-js": "3.36.1",
"enquirer": "~2.3.6", "enquirer": "~2.3.6",
"fast-glob": "3.2.7",
"framer-motion": "^11.3.0", "framer-motion": "^11.3.0",
"front-matter": "^4.0.2", "front-matter": "^4.0.2",
"glob": "7.1.4", "glob": "7.1.4",
@ -378,6 +377,7 @@
"tailwind-merge": "^2.4.0", "tailwind-merge": "^2.4.0",
"tailwindcss": "3.4.4", "tailwindcss": "3.4.4",
"three": "^0.166.1", "three": "^0.166.1",
"tinyglobby": "^0.2.12",
"tslib": "^2.3.0", "tslib": "^2.3.0",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
}, },

View File

@ -33,7 +33,7 @@
"dependencies": { "dependencies": {
"@nx/devkit": "file:../devkit", "@nx/devkit": "file:../devkit",
"@nx/js": "file:../js", "@nx/js": "file:../js",
"tinyglobby": "^0.2.10", "tinyglobby": "^0.2.12",
"picocolors": "^1.1.0", "picocolors": "^1.1.0",
"tsconfig-paths": "^4.1.2", "tsconfig-paths": "^4.1.2",
"tslib": "^2.3.0" "tslib": "^2.3.0"

View File

@ -59,7 +59,7 @@
"picomatch": "4.0.2", "picomatch": "4.0.2",
"semver": "^7.5.3", "semver": "^7.5.3",
"source-map-support": "0.5.19", "source-map-support": "0.5.19",
"tinyglobby": "^0.2.10", "tinyglobby": "^0.2.12",
"ts-node": "10.9.1", "ts-node": "10.9.1",
"tsconfig-paths": "^4.1.2", "tsconfig-paths": "^4.1.2",
"tslib": "^2.3.0" "tslib": "^2.3.0"

451
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import * as fg from 'fast-glob'; import * as globby from 'tinyglobby';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as octokit from 'octokit'; import * as octokit from 'octokit';
@ -35,7 +35,7 @@ async function main() {
for (const pattern of patternsToCheck) { for (const pattern of patternsToCheck) {
foundMatchingFiles ||= foundMatchingFiles ||=
fg.sync(pattern, { globby.globSync(pattern, {
ignore: ['node_modules', 'dist', 'build', '.git'], ignore: ['node_modules', 'dist', 'build', '.git'],
cwd: path.join(__dirname, '..'), cwd: path.join(__dirname, '..'),
onlyFiles: false, onlyFiles: false,

View File

@ -1,10 +1,10 @@
//@ts-check //@ts-check
const fs = require('fs'); const fs = require('fs');
const glob = require('fast-glob'); const glob = require('tinyglobby');
const p = process.argv[2]; const p = process.argv[2];
const nativeFiles = glob.sync(`packages/${p}/**/*.{node,wasm,js,mjs,cjs}`); const nativeFiles = glob.globSync(`packages/${p}/**/*.{node,wasm,js,mjs,cjs}`);
console.log({ nativeFiles }); console.log({ nativeFiles });

View File

@ -1,6 +1,6 @@
//@ts-check //@ts-check
const { mkdirSync, copySync } = require('fs-extra'); const { mkdirSync, copySync } = require('fs-extra');
const glob = require('fast-glob'); const glob = require('tinyglobby');
const { join, basename } = require('path'); const { join, basename } = require('path');
const p = process.argv[2]; const p = process.argv[2];
@ -15,7 +15,7 @@ try {
}); });
} catch {} } catch {}
for (const f of from) { for (const f of from) {
const matchingFiles = glob.sync(f, { const matchingFiles = glob.globSync(f, {
cwd: process.cwd(), cwd: process.cwd(),
onlyDirectories: true, onlyDirectories: true,
}); });