From afb37c8691159081ff919a9d593dd11848859847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Jona=C5=A1?= Date: Tue, 11 Apr 2023 17:40:07 +0200 Subject: [PATCH] fix(core): respect analyzePackageJson for processProjectGraph (#16220) --- packages/js/src/utils/inline.ts | 2 +- packages/nx/src/plugins/js/index.ts | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/js/src/utils/inline.ts b/packages/js/src/utils/inline.ts index f6d0ba34881f3..7cc06a48fe1a5 100644 --- a/packages/js/src/utils/inline.ts +++ b/packages/js/src/utils/inline.ts @@ -36,7 +36,7 @@ export function handleInliningBuild( ): InlineProjectGraph { const tsConfigJson = readJsonFile(tsConfigPath); const pathAliases = - tsConfigJson['compilerOptions']['paths'] || readBasePathAliases(context); + tsConfigJson['compilerOptions']?.['paths'] || readBasePathAliases(context); const inlineGraph = createInlineGraph(context, options, pathAliases); if (isInlineGraphEmpty(inlineGraph)) { diff --git a/packages/nx/src/plugins/js/index.ts b/packages/nx/src/plugins/js/index.ts index 56dbfe4eefd3d..deb4a55aeab02 100644 --- a/packages/nx/src/plugins/js/index.ts +++ b/packages/nx/src/plugins/js/index.ts @@ -23,24 +23,23 @@ export const processProjectGraph: ProjectGraphProcessor = async ( context ) => { const builder = new ProjectGraphBuilder(graph); + const pluginConfig = jsPluginConfig(readNxJson()); - // during the create-nx-workspace lock file might not exists yet - if (lockFileExists()) { - const lockHash = lockFileHash() ?? 'n/a'; - if (lockFileNeedsReprocessing(lockHash)) { - removeNpmNodes(graph, builder); - parseLockFile(builder); + if (pluginConfig.analyzePackageJson) { + // during the create-nx-workspace lock file might not exists yet + if (lockFileExists()) { + const lockHash = lockFileHash() ?? 'n/a'; + if (lockFileNeedsReprocessing(lockHash)) { + removeNpmNodes(graph, builder); + parseLockFile(builder); + } + writeLastProcessedLockfileHash(lockHash); } - writeLastProcessedLockfileHash(lockHash); - } - buildNpmPackageNodes(builder); + buildNpmPackageNodes(builder); + } - await buildExplicitDependencies( - jsPluginConfig(readNxJson()), - context, - builder - ); + await buildExplicitDependencies(pluginConfig, context, builder); return builder.getUpdatedProjectGraph(); };