mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Allow --splitting and --compile together (#23017)
### What does this PR do? ### How did you verify your code works?
This commit is contained in:
40
test/bundler/bundler_compile_splitting.test.ts
Normal file
40
test/bundler/bundler_compile_splitting.test.ts
Normal 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",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user