perf(build): optimize build scripts for parallel execution and remove redundant checks (#24307)

This commit is contained in:
Sehoon Shon
2026-03-31 13:46:36 -04:00
committed by GitHub
parent 7c4b497a84
commit 119dff3b73
2 changed files with 27 additions and 2 deletions

View File

@@ -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",

View File

@@ -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