mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
This commit is contained in:
@@ -323,7 +323,16 @@ pub const BuildCommand = struct {
|
||||
defer Output.flush();
|
||||
var writer = Output.writer();
|
||||
var output_dir = this_bundler.options.output_dir;
|
||||
if (outfile.len > 0 and output_files.len == 1 and output_files[0].value == .buffer) {
|
||||
|
||||
const will_be_one_file =
|
||||
// --outdir is not supported with --compile
|
||||
// but you can still use --outfile
|
||||
// in which case, we should set the output dir to the dirname of the outfile
|
||||
// https://github.com/oven-sh/bun/issues/8697
|
||||
ctx.bundler_options.compile or
|
||||
(output_files.len == 1 and output_files[0].value == .buffer);
|
||||
|
||||
if (output_dir.len == 0 and outfile.len > 0 and will_be_one_file) {
|
||||
output_dir = std.fs.path.dirname(outfile) orelse ".";
|
||||
output_files[0].dest_path = std.fs.path.basename(outfile);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,22 @@ describe("bundler", () => {
|
||||
},
|
||||
run: { stdout: "Hello, world!" },
|
||||
});
|
||||
// https://github.com/oven-sh/bun/issues/8697
|
||||
itBundled("compile/EmbeddedFileOutfile", {
|
||||
compile: true,
|
||||
files: {
|
||||
"/entry.ts": /* js */ `
|
||||
import bar from './foo.file' with {type: "file"};
|
||||
if ((await Bun.file(bar).text()).trim() !== "abcd") throw "fail";
|
||||
console.log("Hello, world!");
|
||||
`,
|
||||
"/foo.file": /* js */ `
|
||||
abcd
|
||||
`.trim(),
|
||||
},
|
||||
outfile: "dist/out",
|
||||
run: { stdout: "Hello, world!" },
|
||||
});
|
||||
itBundled("compile/pathToFileURLWorks", {
|
||||
compile: true,
|
||||
files: {
|
||||
|
||||
Reference in New Issue
Block a user