From 119dff3b7331429dfc55df45ad570b266e998110 Mon Sep 17 00:00:00 2001 From: Sehoon Shon Date: Tue, 31 Mar 2026 13:46:36 -0400 Subject: [PATCH] perf(build): optimize build scripts for parallel execution and remove redundant checks (#24307) --- packages/vscode-ide-companion/package.json | 2 +- scripts/build.js | 27 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/vscode-ide-companion/package.json b/packages/vscode-ide-companion/package.json index ac47bbf0be..b2a2912c7e 100644 --- a/packages/vscode-ide-companion/package.json +++ b/packages/vscode-ide-companion/package.json @@ -108,7 +108,7 @@ "scripts": { "prepackage": "npm run generate:notices && npm run check-types && npm run lint && npm run build:prod", "build": "npm run build:dev", - "build:dev": "npm run check-types && npm run lint && node esbuild.js", + "build:dev": "node esbuild.js", "build:prod": "node esbuild.js --production", "generate:notices": "node ./scripts/generate-notices.js", "prepare": "npm run generate:notices", diff --git a/scripts/build.js b/scripts/build.js index 8a525e98e3..e6aa14faa9 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -32,7 +32,32 @@ if (!existsSync(join(root, 'node_modules'))) { // build all workspaces/packages execSync('npm run generate', { stdio: 'inherit', cwd: root }); -execSync('npm run build --workspaces', { stdio: 'inherit', cwd: root }); + +if (process.env.CI) { + console.log('CI environment detected. Building workspaces sequentially...'); + execSync('npm run build --workspaces', { stdio: 'inherit', cwd: root }); +} else { + // Build core first because everyone depends on it + console.log('Building @google/gemini-cli-core...'); + execSync('npm run build -w @google/gemini-cli-core', { + stdio: 'inherit', + cwd: root, + }); + + // Build the rest in parallel + console.log('Building other workspaces in parallel...'); + const workspaceInfo = JSON.parse( + execSync('npm query .workspace --json', { cwd: root, encoding: 'utf-8' }), + ); + const parallelWorkspaces = workspaceInfo + .map((w) => w.name) + .filter((name) => name !== '@google/gemini-cli-core'); + + execSync( + `npx npm-run-all --parallel ${parallelWorkspaces.map((w) => `"build -w ${w}"`).join(' ')}`, + { stdio: 'inherit', cwd: root }, + ); +} // also build container image if sandboxing is enabled // skip (-s) npm install + build since we did that above