From 5121c6563ef78b9b3bad606324ffde89292a5d84 Mon Sep 17 00:00:00 2001 From: Dragon <52599892+DragonnZhang@users.noreply.github.com> Date: Fri, 12 Jun 2026 16:52:37 +0800 Subject: [PATCH] perf(desktop): add --cli-only flag to skip non-CLI packages during vendor build (#5025) The desktop vendor step only needs the CLI bundle, but was building all 14 workspaces including webui, sdk, web-shell, and vscode-ide-companion. This wasted ~30-40% of build time and triggered TS type errors in vscode-ide-companion on newer Node.js versions. Add a --cli-only flag to scripts/build.js that truncates the build order after the CLI package. vendor-qwen-code.ts now passes this flag when building from a local source checkout, so both local brand builds and CI desktop-release (source_branch mode) benefit automatically. --- packages/desktop/scripts/vendor-qwen-code.ts | 2 +- scripts/build.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/desktop/scripts/vendor-qwen-code.ts b/packages/desktop/scripts/vendor-qwen-code.ts index 0207392900..02d0f3184d 100644 --- a/packages/desktop/scripts/vendor-qwen-code.ts +++ b/packages/desktop/scripts/vendor-qwen-code.ts @@ -102,7 +102,7 @@ async function vendorLocalCheckout(repoRoot: string): Promise { console.log(`Building Qwen Code CLI from ${repoRoot}...`); const npm = npmCommand(); - await run([npm, 'run', 'build'], repoRoot); + await run([npm, 'run', 'build', '--', '--cli-only'], repoRoot); await run([npm, 'run', 'bundle'], repoRoot); await run([npm, 'run', 'prepare:package'], repoRoot); diff --git a/scripts/build.js b/scripts/build.js index e3ab8c2314..81141ec19f 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -33,6 +33,10 @@ if (!existsSync(join(root, 'node_modules'))) { // build all workspaces/packages in dependency order execSync('npm run generate', { stdio: 'inherit', cwd: root }); +// --cli-only: skip packages not needed by the CLI bundle +// (webui, sdk, web-shell, vscode-ide-companion are for IDE/web use only) +const cliOnly = process.argv.includes('--cli-only'); + // Build in dependency order: // 1. core (foundation package, includes test-utils) // 2. web-templates (embeddable web templates - used by cli) @@ -55,10 +59,14 @@ const buildOrder = [ 'packages/channels/plugin-example', 'packages/acp-bridge', 'packages/cli', - 'packages/webui', - 'packages/sdk-typescript', - 'packages/web-shell', - 'packages/vscode-ide-companion', + ...(cliOnly + ? [] + : [ + 'packages/webui', + 'packages/sdk-typescript', + 'packages/web-shell', + 'packages/vscode-ide-companion', + ]), ]; for (const workspace of buildOrder) {