diff --git a/packages/nx/bin/post-install.ts b/packages/nx/bin/post-install.ts index eb1d0200f9ceb..06dbac66591b0 100644 --- a/packages/nx/bin/post-install.ts +++ b/packages/nx/bin/post-install.ts @@ -11,10 +11,10 @@ import { readNxJson } from '../src/config/nx-json'; import { setupWorkspaceContext } from '../src/utils/workspace-context'; (async () => { + const start = new Date(); try { setupWorkspaceContext(workspaceRoot); if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) { - const b = new Date(); assertSupportedPlatform(); try { @@ -35,15 +35,18 @@ import { setupWorkspaceContext } from '../src/utils/workspace-context'; }); }) ); - if (process.env.NX_VERBOSE_LOGGING === 'true') { - const a = new Date(); - console.log(`Nx postinstall steps took ${a.getTime() - b.getTime()}ms`); - } } } catch (e) { if (process.env.NX_VERBOSE_LOGGING === 'true') { console.log(e); } + } finally { + if (process.env.NX_VERBOSE_LOGGING === 'true') { + const end = new Date(); + console.log( + `Nx postinstall steps took ${end.getTime() - start.getTime()}ms` + ); + } } })(); diff --git a/packages/nx/src/project-graph/project-graph.ts b/packages/nx/src/project-graph/project-graph.ts index 812c58cdb4553..0ff72b3c3a659 100644 --- a/packages/nx/src/project-graph/project-graph.ts +++ b/packages/nx/src/project-graph/project-graph.ts @@ -82,35 +82,37 @@ export async function buildProjectGraphAndSourceMapsWithoutDaemon() { const nxJson = readNxJson(); const [plugins, cleanup] = await loadNxPluginsInIsolation(nxJson.plugins); - - performance.mark('retrieve-project-configurations:start'); - const { projects, externalNodes, sourceMaps, projectRootMap } = - await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson); - performance.mark('retrieve-project-configurations:end'); - - performance.mark('retrieve-workspace-files:start'); - const { allWorkspaceFiles, fileMap, rustReferences } = - await retrieveWorkspaceFiles(workspaceRoot, projectRootMap); - performance.mark('retrieve-workspace-files:end'); - - const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false'; - performance.mark('build-project-graph-using-project-file-map:start'); - const projectGraph = ( - await buildProjectGraphUsingProjectFileMap( - projects, - externalNodes, - fileMap, - allWorkspaceFiles, - rustReferences, - cacheEnabled ? readFileMapCache() : null, - cacheEnabled, - plugins - ) - ).projectGraph; - performance.mark('build-project-graph-using-project-file-map:end'); - delete global.NX_GRAPH_CREATION; - cleanup(); - return { projectGraph, sourceMaps }; + try { + performance.mark('retrieve-project-configurations:start'); + const { projects, externalNodes, sourceMaps, projectRootMap } = + await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson); + performance.mark('retrieve-project-configurations:end'); + + performance.mark('retrieve-workspace-files:start'); + const { allWorkspaceFiles, fileMap, rustReferences } = + await retrieveWorkspaceFiles(workspaceRoot, projectRootMap); + performance.mark('retrieve-workspace-files:end'); + + const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false'; + performance.mark('build-project-graph-using-project-file-map:start'); + const projectGraph = ( + await buildProjectGraphUsingProjectFileMap( + projects, + externalNodes, + fileMap, + allWorkspaceFiles, + rustReferences, + cacheEnabled ? readFileMapCache() : null, + cacheEnabled, + plugins + ) + ).projectGraph; + performance.mark('build-project-graph-using-project-file-map:end'); + delete global.NX_GRAPH_CREATION; + return { projectGraph, sourceMaps }; + } finally { + cleanup(); + } } function handleProjectGraphError(opts: { exitOnError: boolean }, e) {