From bda2a75b0f46337c1c6ee0c858115662bcf64fb8 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Wed, 14 Dec 2022 13:48:10 -0500 Subject: [PATCH] fix(core): ignore angular.json projects if @nrwl/angular is not installed --- packages/nx/src/config/workspaces.ts | 12 +++++++++++- scripts/depcheck/missing.ts | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/config/workspaces.ts b/packages/nx/src/config/workspaces.ts index 541905d88d35e..713d21ad60a15 100644 --- a/packages/nx/src/config/workspaces.ts +++ b/packages/nx/src/config/workspaces.ts @@ -33,7 +33,8 @@ import { joinPathFragments } from '../utils/path'; export function workspaceConfigName( root: string ): 'angular.json' | 'workspace.json' | null { - if (existsSync(path.join(root, 'angular.json'))) { + // If a workspace doesn't have `@nrwl/angular` it's likely they do not want projects from `angular.json` to be considered by Nx. + if (existsSync(path.join(root, 'angular.json')) && isNrwlAngularInstalled()) { return 'angular.json'; } else if (existsSync(path.join(root, 'workspace.json'))) { return 'workspace.json'; @@ -431,6 +432,15 @@ function assertValidWorkspaceConfiguration( } } +function isNrwlAngularInstalled() { + try { + require.resolve('@nrwl/angular'); + return true; + } catch { + return false; + } +} + function findFullGeneratorName( name: string, generators: { diff --git a/scripts/depcheck/missing.ts b/scripts/depcheck/missing.ts index 24a19b46ec7b3..9db6da11adcae 100644 --- a/scripts/depcheck/missing.ts +++ b/scripts/depcheck/missing.ts @@ -124,6 +124,7 @@ const IGNORE_MATCHES_IN_PACKAGE = { '@angular-devkit/core', '@angular-devkit/architect', '@angular/cli', + '@nrwl/angular', 'ts-node', // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep ], web: [