From 61451a100b6610a74a7c2489ffcea5ce5db6bacc Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Thu, 20 Apr 2023 17:17:46 -0400 Subject: [PATCH] fix(core): optional dependencies should be tracked by project graph (#16383) --- .../explicit-package-json-dependencies.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.ts b/packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.ts index 4485305db2bfd..1f1f55a5397e2 100644 --- a/packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.ts +++ b/packages/nx/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.ts @@ -10,6 +10,7 @@ import { getImportPath, joinPathFragments } from '../../../../utils/path'; import { ProjectsConfigurations } from '../../../../config/workspace-json-project-json'; import { NxJsonConfiguration } from '../../../../config/nx-json'; import { ExplicitDependency } from './explicit-project-dependencies'; +import { PackageJson } from '../../../../utils/package-json'; class ProjectGraphNodeRecords {} @@ -110,10 +111,11 @@ function processPackageJson( } } -function readDeps(packageJsonDeps: any) { +function readDeps(packageJson: PackageJson) { return [ - ...Object.keys(packageJsonDeps?.dependencies ?? {}), - ...Object.keys(packageJsonDeps?.devDependencies ?? {}), - ...Object.keys(packageJsonDeps?.peerDependencies ?? {}), + ...Object.keys(packageJson?.dependencies ?? {}), + ...Object.keys(packageJson?.devDependencies ?? {}), + ...Object.keys(packageJson?.peerDependencies ?? {}), + ...Object.keys(packageJson?.optionalDependencies ?? {}), ]; }