mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
### What does this PR do? ### How did you verify your code works? --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
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",
|
|
},
|
|
});
|
|
|
|
for (const minify of [false, true]) {
|
|
itBundled(`compile/splitting/ImportMetaInSplitChunk${minify ? "+minify" : ""}`, {
|
|
compile: true,
|
|
splitting: true,
|
|
bytecode: true,
|
|
format: "esm",
|
|
...(minify ? { minifySyntax: true, minifyIdentifiers: true, minifyWhitespace: true } : {}),
|
|
files: {
|
|
"/entry.ts": /* js */ `
|
|
const mod = await import("./worker.ts");
|
|
mod.run();
|
|
`,
|
|
"/worker.ts": /* js */ `
|
|
export function run() {
|
|
console.log(typeof import.meta.url === "string" ? "ok" : "fail");
|
|
console.log(typeof import.meta.dir === "string" ? "ok" : "fail");
|
|
}
|
|
`,
|
|
},
|
|
run: {
|
|
stdout: "ok\nok",
|
|
},
|
|
});
|
|
}
|
|
});
|
|
});
|