From 1bded85718909368ea466fdf8bf821fd3d768108 Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Sat, 7 Feb 2026 13:39:18 -0800 Subject: [PATCH] types: Enable --splitting with compile (#26796) ### What does this PR do? Enables --splitting with compile ### How did you verify your code works? Bun types integration test fixture updates --- packages/bun-types/bun.d.ts | 85 ++++++++------------- test/integration/bun-types/fixture/build.ts | 1 - 2 files changed, 33 insertions(+), 53 deletions(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 5b34265536..7b38d27a7b 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -2445,7 +2445,12 @@ declare module "bun" { /** * @see [Bun.build API docs](https://bun.com/docs/bundler#api) */ - interface BuildConfigBase { + interface BuildConfig { + /** + * Enable code splitting + */ + splitting?: boolean; + /** * List of entrypoints, usually file paths */ @@ -2774,6 +2779,33 @@ declare module "bun" { metafile?: boolean; outdir?: string; + + /** + * Create a standalone executable + * + * When `true`, creates an executable for the current platform. + * When a target string, creates an executable for that platform. + * + * @example + * ```ts + * // Create executable for current platform + * await Bun.build({ + * entrypoints: ['./app.js'], + * compile: { + * target: 'linux-x64', + * }, + * outfile: './my-app' + * }); + * + * // Cross-compile for Linux x64 + * await Bun.build({ + * entrypoints: ['./app.js'], + * compile: 'linux-x64', + * outfile: './my-app' + * }); + * ``` + */ + compile?: boolean | Bun.Build.CompileTarget | CompileBuildOptions; } interface CompileBuildOptions { @@ -2832,57 +2864,6 @@ declare module "bun" { }; } - // Compile build config - uses outfile for executable output - interface CompileBuildConfig extends BuildConfigBase { - /** - * Create a standalone executable - * - * When `true`, creates an executable for the current platform. - * When a target string, creates an executable for that platform. - * - * @example - * ```ts - * // Create executable for current platform - * await Bun.build({ - * entrypoints: ['./app.js'], - * compile: { - * target: 'linux-x64', - * }, - * outfile: './my-app' - * }); - * - * // Cross-compile for Linux x64 - * await Bun.build({ - * entrypoints: ['./app.js'], - * compile: 'linux-x64', - * outfile: './my-app' - * }); - * ``` - */ - compile: boolean | Bun.Build.CompileTarget | CompileBuildOptions; - - /** - * Splitting is not currently supported with `.compile` - */ - splitting?: never; - } - - interface NormalBuildConfig extends BuildConfigBase { - /** - * Enable code splitting - * - * This does not currently work with {@link CompileBuildConfig.compile `compile`} - * - * @default true - */ - splitting?: boolean; - } - - /** - * @see [Bun.build API docs](https://bun.com/docs/bundler#api) - */ - type BuildConfig = CompileBuildConfig | NormalBuildConfig; - /** * Hash and verify passwords using argon2 or bcrypt * diff --git a/test/integration/bun-types/fixture/build.ts b/test/integration/bun-types/fixture/build.ts index fd8969a5a1..c87e2459ca 100644 --- a/test/integration/bun-types/fixture/build.ts +++ b/test/integration/bun-types/fixture/build.ts @@ -19,7 +19,6 @@ expectAssignable("bun-windows-x64-modern"); Bun.build({ entrypoints: ["hey"], splitting: false, - // @ts-expect-error Currently not supported compile: {}, });