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.
This commit is contained in:
Dragon 2026-06-12 16:52:37 +08:00 committed by GitHub
parent 3c55295f63
commit 5121c6563e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View file

@ -102,7 +102,7 @@ async function vendorLocalCheckout(repoRoot: string): Promise<void> {
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);

View file

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