From 7e2a19bfa1549e61a1b2480ba9f46f6fbf40f416 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Thu, 7 Sep 2023 17:24:26 -0400 Subject: [PATCH] chore(core): remove fast-glob from core nx (#18975) --- packages/nx/package.json | 1 - .../nx/src/daemon/server/outputs-tracking.ts | 30 ++++--------------- packages/nx/src/utils/ignore.ts | 1 - 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/packages/nx/package.json b/packages/nx/package.json index df38a9d3d9862..243f1a569223d 100644 --- a/packages/nx/package.json +++ b/packages/nx/package.json @@ -44,7 +44,6 @@ "dotenv": "~16.3.1", "dotenv-expand": "~10.0.0", "enquirer": "~2.3.6", - "fast-glob": "3.2.7", "figures": "3.2.0", "flat": "^5.0.2", "fs-extra": "^11.1.0", diff --git a/packages/nx/src/daemon/server/outputs-tracking.ts b/packages/nx/src/daemon/server/outputs-tracking.ts index 2129b15dbc1dd..448ab5fabd5a2 100644 --- a/packages/nx/src/daemon/server/outputs-tracking.ts +++ b/packages/nx/src/daemon/server/outputs-tracking.ts @@ -1,9 +1,9 @@ import { lstat } from 'fs-extra'; import { dirname, join } from 'path'; -import * as fastGlob from 'fast-glob'; import { workspaceRoot } from '../../utils/workspace-root'; import { collapseExpandedOutputs } from '../../utils/collapse-expanded-outputs'; import type { Event } from '@parcel/watcher'; +import { getFilesForOutputs } from '../../native'; let disabled = false; @@ -59,30 +59,10 @@ export async function outputsHashesMatch(_outputs: string[], hash: string) { } async function normalizeOutputs(outputs: string[]) { - return ( - await Promise.all(outputs.map((o) => normalizeOutput(o, true))) - ).flat(); -} - -async function normalizeOutput( - output: string, - expand: boolean -): Promise { - try { - await lstat(join(workspaceRoot, output)); - return [output]; - } catch (e) { - if (expand) { - const expanded = collapseExpandedOutputs( - await fastGlob(output, { cwd: workspaceRoot, dot: true }) - ); - return ( - await Promise.all(expanded.map((e) => normalizeOutput(e, false))) - ).flat(); - } else { - return []; - } - } + let expandedOutputs = collapseExpandedOutputs( + getFilesForOutputs(workspaceRoot, outputs) + ); + return expandedOutputs; } export function processFileChangesInOutputs( diff --git a/packages/nx/src/utils/ignore.ts b/packages/nx/src/utils/ignore.ts index a61bd99fd57e4..05440219163d5 100644 --- a/packages/nx/src/utils/ignore.ts +++ b/packages/nx/src/utils/ignore.ts @@ -6,7 +6,6 @@ import { workspaceRoot } from './workspace-root'; /** * An array of glob patterns that should always be ignored. - * Uses path/posix, since fast-glob requires unix paths. */ export const ALWAYS_IGNORE = getAlwaysIgnore();