From 21be15ef980fb5dc046b8c91e8fd4d1d7b027c61 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Sat, 21 Dec 2024 11:36:24 +0000 Subject: [PATCH 1/2] cleanup(core): move esbuild to use tinyglobby An alternative to #28037, switches the esbuild package to use `tinyglobby` instead of `fast-glob`. This improves performance a fair chunk and reduces install complexity/size. --- packages/esbuild/package.json | 2 +- packages/esbuild/src/utils/get-entry-points.ts | 13 ++++++------- packages/esbuild/tsconfig.lib.json | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/esbuild/package.json b/packages/esbuild/package.json index cbd8422b90922..0a5bd11689a0a 100644 --- a/packages/esbuild/package.json +++ b/packages/esbuild/package.json @@ -33,7 +33,7 @@ "dependencies": { "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", - "fast-glob": "3.2.7", + "tinyglobby": "^0.2.10", "picocolors": "^1.1.0", "tsconfig-paths": "^4.1.2", "tslib": "^2.3.0" diff --git a/packages/esbuild/src/utils/get-entry-points.ts b/packages/esbuild/src/utils/get-entry-points.ts index c165fdd69166d..982eb59b1800b 100644 --- a/packages/esbuild/src/utils/get-entry-points.ts +++ b/packages/esbuild/src/utils/get-entry-points.ts @@ -1,7 +1,7 @@ import { ExecutorContext, readJsonFile } from '@nx/devkit'; import * as fs from 'fs'; import * as path from 'path'; -import * as glob from 'fast-glob'; +import { globSync } from 'tinyglobby'; export interface GetEntryPointsOptions { recursive?: boolean; @@ -50,12 +50,11 @@ export function getEntryPoints( const tsconfig = readJsonFile( path.join(project.data.root, foundTsConfig) ); - const projectFiles = glob - .sync(tsconfig.include ?? [], { - cwd: project.data.root, - ignore: tsconfig.exclude ?? [], - }) - .map((f) => path.join(project.data.root, f)); + const projectFiles = globSync(tsconfig.include ?? [], { + cwd: project.data.root, + ignore: tsconfig.exclude ?? [], + expandDirectories: false, + }).map((f) => path.join(project.data.root, f)); projectFiles.forEach((f) => entryPoints.add(f)); options?.onProjectFilesMatched?.(projectName, projectFiles); diff --git a/packages/esbuild/tsconfig.lib.json b/packages/esbuild/tsconfig.lib.json index e85ef50f65c2d..7bfc80f73e6fa 100644 --- a/packages/esbuild/tsconfig.lib.json +++ b/packages/esbuild/tsconfig.lib.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "declaration": true, - "types": [] + "types": ["node"] }, "include": ["**/*.ts"], "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] From 97a5868597369d843feb7c418102c1fe018ae66d Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Mon, 30 Dec 2024 16:35:45 +0000 Subject: [PATCH 2/2] cleanup(core): add lint rule for fast-glob warning --- packages/esbuild/.eslintrc.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/esbuild/.eslintrc.json b/packages/esbuild/.eslintrc.json index cfc1f671011b6..a8397114217c3 100644 --- a/packages/esbuild/.eslintrc.json +++ b/packages/esbuild/.eslintrc.json @@ -14,6 +14,10 @@ { "name": "fs-extra", "message": "Please use equivalent utilities from `node:fs` instead." + }, + { + "name": "fast-glob", + "message": "Please use `tinyglobby` in place of `fast-glob` for executing glob traversals" } ] }