mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Inline process.versions.bun in bun build --compile (#14940)
This commit is contained in:
@@ -36,6 +36,7 @@ pub const BuildCommand = struct {
|
||||
const compile_define_keys = &.{
|
||||
"process.platform",
|
||||
"process.arch",
|
||||
"process.versions.bun",
|
||||
};
|
||||
|
||||
pub fn exec(ctx: Command.Context) !void {
|
||||
|
||||
@@ -429,6 +429,8 @@ pub fn defineValues(this: *const CompileTarget) []const []const u8 {
|
||||
.arm64 => "\"arm64\"",
|
||||
else => @compileError("TODO"),
|
||||
},
|
||||
|
||||
"\"" ++ Global.package_json_version ++ "\"",
|
||||
};
|
||||
}.values,
|
||||
else => @panic("TODO"),
|
||||
|
||||
@@ -14,6 +14,21 @@ describe.todoIf(isFlaky && isWindows)("bundler", () => {
|
||||
},
|
||||
run: { stdout: "Hello, world!" },
|
||||
});
|
||||
itBundled("compile/HelloWorldWithProcessVersionsBun", {
|
||||
compile: true,
|
||||
files: {
|
||||
[`/${process.platform}-${process.arch}.js`]: "module.exports = process.versions.bun;",
|
||||
"/entry.ts": /* js */ `
|
||||
process.exitCode = 1;
|
||||
process.versions.bun = "bun!";
|
||||
if (process.versions.bun === "bun!") throw new Error("fail");
|
||||
if (require("./${process.platform}-${process.arch}.js") === "${Bun.version.replaceAll("-debug", "")}") {
|
||||
process.exitCode = 0;
|
||||
}
|
||||
`,
|
||||
},
|
||||
run: { exitCode: 0 },
|
||||
});
|
||||
itBundled("compile/HelloWorldBytecode", {
|
||||
compile: true,
|
||||
bytecode: true,
|
||||
|
||||
Reference in New Issue
Block a user