Allow --splitting and --compile together (#23017)

### What does this PR do?

### How did you verify your code works?
This commit is contained in:
Jarred Sumner
2025-10-04 06:52:20 -07:00
committed by GitHub
parent 624911180f
commit f0eb0472e6
8 changed files with 92 additions and 19 deletions

View File

@@ -0,0 +1,40 @@
import { describe } from "bun:test";
import { itBundled } from "./expectBundled";
describe("bundler", () => {
describe("compile with splitting", () => {
itBundled("compile/splitting/RelativePathsAcrossChunks", {
compile: true,
splitting: true,
backend: "cli",
files: {
"/src/app/entry.ts": /* js */ `
console.log('app entry');
import('../components/header').then(m => m.render());
`,
"/src/components/header.ts": /* js */ `
export async function render() {
console.log('header rendering');
const nav = await import('./nav/menu');
nav.show();
}
`,
"/src/components/nav/menu.ts": /* js */ `
export async function show() {
console.log('menu showing');
const items = await import('./items');
console.log('items:', items.list);
}
`,
"/src/components/nav/items.ts": /* js */ `
export const list = ['home', 'about', 'contact'].join(',');
`,
},
entryPoints: ["/src/app/entry.ts"],
outdir: "/build",
run: {
stdout: "app entry\nheader rendering\nmenu showing\nitems: home,about,contact",
},
});
});
});

View File

@@ -524,7 +524,15 @@ function expectBundled(
if (metafile === true) metafile = "/metafile.json";
if (bundleErrors === true) bundleErrors = {};
if (bundleWarnings === true) bundleWarnings = {};
const useOutFile = generateOutput == false ? false : outfile ? true : outdir ? false : entryPoints.length === 1;
const useOutFile = compile
? true
: generateOutput == false
? false
: outfile
? true
: outdir
? false
: entryPoints.length === 1;
if (bundling === false && entryPoints.length > 1) {
throw new Error("bundling:false only supports a single entry point");
@@ -1087,14 +1095,16 @@ function expectBundled(
define: define ?? {},
throw: _throw ?? false,
compile,
jsx: jsx ? {
runtime: jsx.runtime,
importSource: jsx.importSource,
factory: jsx.factory,
fragment: jsx.fragment,
sideEffects: jsx.sideEffects,
development: jsx.development,
} : undefined,
jsx: jsx
? {
runtime: jsx.runtime,
importSource: jsx.importSource,
factory: jsx.factory,
fragment: jsx.fragment,
sideEffects: jsx.sideEffects,
development: jsx.development,
}
: undefined,
} as BuildConfig;
if (dotenv) {