Skip to content

Commit 7610965

Browse files
committed
chore(deps): switch to tinyglobby
1 parent 447406f commit 7610965

File tree

12 files changed

+121
-41
lines changed

12 files changed

+121
-41
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"eslint-plugin-import": "2.32.0",
7474
"eslint-plugin-n": "17.21.3",
7575
"eslint-plugin-promise": "7.2.1",
76-
"globby": "11.1.0",
76+
"eslint-plugin-standard": "5.0.0",
7777
"graphql": "16.11.0",
7878
"graphql-yoga": "5.15.2",
7979
"husky": "9.1.7",
@@ -83,6 +83,7 @@
8383
"prettier": "3.6.2",
8484
"prettier-plugin-tailwindcss": "0.6.14",
8585
"rimraf": "6.0.1",
86+
"tinyglobby": "0.2.15",
8687
"ts-jest": "29.4.1",
8788
"tsx": "4.20.5",
8889
"typedoc": "0.25.13",

packages/load-files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
5252
},
5353
"dependencies": {
54-
"globby": "11.1.0",
54+
"tinyglobby": "^0.2.13",
5555
"tslib": "^2.4.0",
5656
"unixify": "^1.0.0"
5757
},

packages/load-files/src/index.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { promises as fsPromises, readFileSync, statSync } from 'fs';
22
import { createRequire } from 'module';
33
import { extname, join } from 'path';
44
import { cwd } from 'process';
5-
import globby, { GlobbyOptions, sync as globbySync } from 'globby';
5+
import { fileURLToPath } from 'url';
66
import { DocumentNode, parse } from 'graphql';
7+
import { GlobOptions, globSync, glob as tinyglobby } from 'tinyglobby';
78
import unixify from 'unixify';
89

910
const { readFile, stat } = fsPromises;
@@ -63,8 +64,8 @@ async function isDirectory(path: string) {
6364
}
6465
}
6566

66-
function scanForFilesSync(globStr: string | string[], globOptions: GlobbyOptions = {}): string[] {
67-
return globbySync(globStr, { absolute: true, ...globOptions });
67+
function scanForFilesSync(globStr: string | string[], globOptions: GlobOptions = {}): string[] {
68+
return globSync(globStr, { absolute: true, ...globOptions });
6869
}
6970

7071
function formatExtension(extension: string): string {
@@ -98,8 +99,8 @@ export interface LoadFilesOptions {
9899
useRequire?: boolean;
99100
// An alternative to `require` to use if `require` would be used to load a file
100101
requireMethod?: any;
101-
// Additional options to pass to globby
102-
globOptions?: GlobbyOptions;
102+
// Additional options to pass to tinyglobby
103+
globOptions?: GlobOptions;
103104
// Named exports to extract from each file. Defaults to ['typeDefs', 'schema']
104105
exportNames?: string[];
105106
// Load files from nested directories. Set to `false` to only search the top-level directory.
@@ -148,10 +149,12 @@ export function loadFilesSync<T = any>(
148149
options.globOptions,
149150
);
150151

152+
const cwd = options?.globOptions?.cwd;
153+
const normalizedCwd = cwd instanceof URL ? fileURLToPath(cwd) : cwd;
151154
const extractExports =
152155
execOptions.extractExports || DEFAULT_EXTRACT_EXPORTS_FACTORY(execOptions.exportNames ?? []);
153156
const requireMethod =
154-
execOptions.requireMethod || createRequire(join(options?.globOptions?.cwd || cwd(), 'noop.js'));
157+
execOptions.requireMethod || createRequire(join(normalizedCwd || cwd(), 'noop.js'));
155158

156159
return relevantPaths
157160
.map(path => {
@@ -183,9 +186,9 @@ export function loadFilesSync<T = any>(
183186

184187
async function scanForFiles(
185188
globStr: string | string[],
186-
globOptions: GlobbyOptions = {},
189+
globOptions: GlobOptions = {},
187190
): Promise<string[]> {
188-
return globby(globStr, { absolute: true, ...globOptions });
191+
return tinyglobby(globStr, { absolute: true, ...globOptions });
189192
}
190193

191194
const checkExtension = (
@@ -248,12 +251,14 @@ export async function loadFiles(
248251
options.globOptions,
249252
);
250253

254+
const cwd = options?.globOptions?.cwd;
255+
const normalizedCwd = cwd instanceof URL ? fileURLToPath(cwd) : cwd;
251256
const extractExports =
252257
execOptions.extractExports || DEFAULT_EXTRACT_EXPORTS_FACTORY(execOptions.exportNames ?? []);
253258
const defaultRequireMethod = (path: string) =>
254259
import(path)
255260
.catch(importError => {
256-
const cwdRequire = createRequire(join(options?.globOptions?.cwd || cwd(), 'noop.js'));
261+
const cwdRequire = createRequire(join(normalizedCwd || cwd(), 'noop.js'));
257262
try {
258263
return cwdRequire(path);
259264
} catch (e) {

packages/load/tests/loaders/documents/documents-from-glob.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { loadDocuments, loadDocumentsSync, NoTypeDefinitionsFound } from '@graph
66
import { runTests } from '../../../../testing/utils.js';
77
import '../../../../testing/to-be-similar-string';
88
import { readFileSync } from 'fs';
9-
import globby from 'globby';
9+
import { globSync } from 'tinyglobby';
1010
import { removeLoc } from '@graphql-tools/optimize';
1111

1212
describe('documentsFromGlob', () => {
@@ -20,7 +20,7 @@ describe('documentsFromGlob', () => {
2020
loaders: [new GraphQLFileLoader()],
2121
});
2222
expect(result).toHaveLength(1);
23-
const expectedFiles = globby.sync(glob);
23+
const expectedFiles = globSync(glob);
2424
for (const expectedFileName of expectedFiles) {
2525
const fileNameResult = result?.find(({ location }) => location === expectedFileName);
2626
if (fileNameResult) {
@@ -38,7 +38,7 @@ describe('documentsFromGlob', () => {
3838
loaders: [new GraphQLFileLoader()],
3939
});
4040
expect(result).toHaveLength(2);
41-
const expectedFiles = globby.sync(glob);
41+
const expectedFiles = globSync(glob);
4242
for (const expectedFileName of expectedFiles) {
4343
const fileNameResult = result?.find(({ location }) => location === expectedFileName);
4444
if (fileNameResult) {

packages/loaders/code-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"dependencies": {
5454
"@graphql-tools/graphql-tag-pluck": "8.3.21",
5555
"@graphql-tools/utils": "^10.9.1",
56-
"globby": "^11.0.3",
56+
"tinyglobby": "^0.2.15",
5757
"tslib": "^2.4.0",
5858
"unixify": "^1.0.0"
5959
},

packages/loaders/code-file/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { existsSync, promises as fsPromises, readFileSync } from 'fs';
22
import { createRequire } from 'module';
33
import { isAbsolute, resolve } from 'path';
44
import { cwd, env } from 'process';
5-
import type { GlobbyOptions } from 'globby';
6-
import globby from 'globby';
75
import { DocumentNode, GraphQLSchema, isSchema, parse } from 'graphql';
6+
import type { GlobOptions } from 'tinyglobby';
7+
import { globSync, glob as tinyglobby } from 'tinyglobby';
88
import unixify from 'unixify';
99
import {
1010
gqlPluckFromCodeString,
@@ -59,7 +59,7 @@ const FILE_EXTENSIONS = [
5959
'.gjs',
6060
];
6161

62-
function createGlobbyOptions(options: CodeFileLoaderOptions): GlobbyOptions {
62+
function createGlobbyOptions(options: CodeFileLoaderOptions): GlobOptions {
6363
return { absolute: true, ...options, ignore: [] };
6464
}
6565

@@ -138,13 +138,13 @@ export class CodeFileLoader implements Loader<CodeFileLoaderOptions> {
138138
async resolveGlobs(glob: string, options: CodeFileLoaderOptions) {
139139
options = this.getMergedOptions(options);
140140
const globs = this._buildGlobs(glob, options);
141-
return globby(globs, createGlobbyOptions(options));
141+
return tinyglobby(globs, createGlobbyOptions(options));
142142
}
143143

144144
resolveGlobsSync(glob: string, options: CodeFileLoaderOptions) {
145145
options = this.getMergedOptions(options);
146146
const globs = this._buildGlobs(glob, options);
147-
return globby.sync(globs, createGlobbyOptions(options));
147+
return globSync(globs, createGlobbyOptions(options));
148148
}
149149

150150
async load(pointer: string, options: CodeFileLoaderOptions): Promise<Source[]> {

packages/loaders/graphql-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"dependencies": {
5454
"@graphql-tools/import": "7.1.1",
5555
"@graphql-tools/utils": "^10.9.1",
56-
"globby": "^11.0.3",
56+
"tinyglobby": "^0.2.15",
5757
"tslib": "^2.4.0",
5858
"unixify": "^1.0.0"
5959
},

packages/loaders/graphql-file/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { existsSync, promises as fsPromises, readFileSync } from 'fs';
22
import { isAbsolute, resolve } from 'path';
33
import { env, cwd as processCwd } from 'process';
4-
import type { GlobbyOptions } from 'globby';
5-
import globby from 'globby';
4+
import type { GlobOptions } from 'tinyglobby';
5+
import { globSync, glob as tinyglobby } from 'tinyglobby';
66
import unixify from 'unixify';
77
import { PathAliases, processImport } from '@graphql-tools/import';
88
import {
@@ -46,7 +46,7 @@ function isGraphQLImportFile(rawSDL: string) {
4646
return trimmedRawSDL.startsWith('# import') || trimmedRawSDL.startsWith('#import');
4747
}
4848

49-
function createGlobbyOptions(options: GraphQLFileLoaderOptions): GlobbyOptions {
49+
function createGlobbyOptions(options: GraphQLFileLoaderOptions): GlobOptions {
5050
return { absolute: true, ...options, ignore: [] };
5151
}
5252

@@ -124,7 +124,7 @@ export class GraphQLFileLoader implements Loader<GraphQLFileLoaderOptions> {
124124
)
125125
return [glob]; // bypass globby when no glob character, can be loaded, no ignores and source not requested. Fixes problem with pkg and passes ci tests
126126
const globs = this._buildGlobs(glob, options);
127-
const result = await globby(globs, createGlobbyOptions(options));
127+
const result = await tinyglobby(globs, createGlobbyOptions(options));
128128
return result;
129129
}
130130

@@ -137,7 +137,7 @@ export class GraphQLFileLoader implements Loader<GraphQLFileLoaderOptions> {
137137
)
138138
return [glob]; // bypass globby when no glob character, can be loaded, no ignores and source not requested. Fixes problem with pkg and passes ci tests
139139
const globs = this._buildGlobs(glob, options);
140-
const result = globby.sync(globs, createGlobbyOptions(options));
140+
const result = globSync(globs, createGlobbyOptions(options));
141141
return result;
142142
}
143143

0 commit comments

Comments
 (0)