Skip to content

Commit 77ed962

Browse files
authored
perf(deps): replace fast-glob with tinyglobby (#307)
1 parent d362cdb commit 77ed962

File tree

11 files changed

+58
-32
lines changed

11 files changed

+58
-32
lines changed

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
},
3939
"dependencies": {
4040
"@rsbuild/core": "~1.0.14",
41-
"rsbuild-plugin-dts": "workspace:*"
41+
"rsbuild-plugin-dts": "workspace:*",
42+
"tinyglobby": "^0.2.9"
4243
},
4344
"devDependencies": {
4445
"@rslib/tsconfig": "workspace:*",
4546
"@rspack/core": "1.0.8",
4647
"@types/fs-extra": "^11.0.4",
4748
"commander": "^12.1.0",
48-
"fast-glob": "^3.3.2",
4949
"fs-extra": "^11.2.0",
5050
"memfs": "^4.14.0",
5151
"picocolors": "1.1.0",

packages/core/prebundle.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default {
1313
},
1414
dependencies: [
1515
'commander',
16-
'fast-glob',
1716
{
1817
name: 'rslog',
1918
afterBundle(task) {

packages/core/rslib.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default defineConfig({
2424
target: 'node',
2525
externals: {
2626
picocolors: '../compiled/picocolors/index.js',
27-
'fast-glob': '../compiled/fast-glob/index.js',
2827
commander: '../compiled/commander/index.js',
2928
rslog: '../compiled/rslog/index.js',
3029
},

packages/core/src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
mergeRsbuildConfig,
1010
rspack,
1111
} from '@rsbuild/core';
12-
import glob from 'fast-glob';
12+
import { glob } from 'tinyglobby';
1313
import {
1414
DEFAULT_CONFIG_EXTENSIONS,
1515
DEFAULT_CONFIG_NAME,
@@ -777,6 +777,7 @@ const composeEntryConfig = async (
777777
// Turn entries in array into each separate entry.
778778
const globEntryFiles = await glob(entryFiles, {
779779
cwd: root,
780+
absolute: true,
780781
});
781782

782783
// Filter the glob resolved entry files based on the allowed extensions

packages/core/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"paths": {
1414
"commander": ["./compiled/commander"],
1515
"picocolors": ["./compiled/picocolors"],
16-
"fast-glob": ["./compiled/fast-glob"],
1716
"rslog": ["./compiled/rslog"]
1817
}
1918
},

packages/plugin-dts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"dev": "rslib build --watch"
3030
},
3131
"dependencies": {
32-
"fast-glob": "^3.3.2",
3332
"magic-string": "^0.30.12",
34-
"picocolors": "1.1.0"
33+
"picocolors": "1.1.0",
34+
"tinyglobby": "^0.2.9"
3535
},
3636
"devDependencies": {
3737
"@microsoft/api-extractor": "^7.47.9",

packages/plugin-dts/src/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import fsP from 'node:fs/promises';
33
import { platform } from 'node:os';
44
import path, { join } from 'node:path';
55
import { type RsbuildConfig, logger } from '@rsbuild/core';
6-
import fg from 'fast-glob';
76
import MagicString from 'magic-string';
87
import color from 'picocolors';
8+
import { convertPathToPattern, glob } from 'tinyglobby';
99
import ts from 'typescript';
1010
import type { DtsEntry } from './index';
1111

12-
const { convertPathToPattern } = fg;
13-
1412
export function loadTsconfig(tsconfigPath: string): ts.ParsedCommandLine {
1513
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
1614
const configFileContent = ts.parseJsonConfigFileContent(
@@ -68,8 +66,8 @@ export const prettyTime = (seconds: number): string => {
6866
return `${format(minutes.toFixed(2))} m`;
6967
};
7068

71-
// fast-glob only accepts posix path
72-
// https://github.com/mrmlnc/fast-glob#convertpathtopatternpath
69+
// tinyglobby only accepts posix path
70+
// https://github.com/SuperchupuDev/tinyglobby?tab=readme-ov-file#api
7371
const convertPath = (path: string) => {
7472
if (platform() === 'win32') {
7573
return convertPathToPattern(path);
@@ -111,7 +109,9 @@ export async function processDtsFiles(
111109
return;
112110
}
113111

114-
const dtsFiles = await fg(convertPath(join(dir, '/**/*.d.ts')));
112+
const dtsFiles = await glob(convertPath(join(dir, '/**/*.d.ts')), {
113+
absolute: true,
114+
});
115115

116116
for (const file of dtsFiles) {
117117
try {

pnpm-lock.yaml

Lines changed: 36 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ systemjs
119119
tailwindcss
120120
taze
121121
templating
122+
tinyglobby
122123
transpiling
123124
treeshaking
124125
tsbuildinfo

tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"@types/node": "~18.19.39",
2424
"@types/react": "^18.3.11",
2525
"@types/react-dom": "^18.3.1",
26-
"fast-glob": "^3.3.2",
2726
"fs-extra": "^11.2.0",
2827
"path-serializer": "0.1.3",
2928
"strip-ansi": "^7.1.0",
30-
"test-helper": "workspace:*"
29+
"test-helper": "workspace:*",
30+
"tinyglobby": "^0.2.9"
3131
}
3232
}

tests/scripts/helper.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { platform } from 'node:os';
22
import { join } from 'node:path';
3-
import fg, {
4-
type Options as GlobOptions,
5-
convertPathToPattern,
6-
} from 'fast-glob';
73
import fse from 'fs-extra';
4+
import { type GlobOptions, convertPathToPattern, glob } from 'tinyglobby';
85

9-
// fast-glob only accepts posix path
10-
// https://github.com/mrmlnc/fast-glob#convertpathtopatternpath
6+
// tinyglobby only accepts posix path
7+
// https://github.com/SuperchupuDev/tinyglobby?tab=readme-ov-file#api
118
const convertPath = (path: string) => {
129
if (platform() === 'win32') {
1310
return convertPathToPattern(path);
@@ -19,7 +16,10 @@ export const globContentJSON = async (
1916
path: string,
2017
options?: GlobOptions,
2118
): Promise<Record<string, string>> => {
22-
const files = await fg(convertPath(join(path, '**/*')), options);
19+
const files = await glob(convertPath(join(path, '**/*')), {
20+
absolute: true,
21+
...options,
22+
});
2323
const ret: Record<string, string> = {};
2424

2525
await Promise.all(

0 commit comments

Comments
 (0)