mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add BUN_BE_BUN environment variable flag (#20251)
This commit is contained in:
44
src/cli.zig
44
src/cli.zig
@@ -1815,29 +1815,31 @@ pub const Command = struct {
|
||||
}
|
||||
|
||||
// bun build --compile entry point
|
||||
if (try bun.StandaloneModuleGraph.fromExecutable(bun.default_allocator)) |graph| {
|
||||
context_data = .{
|
||||
.args = std.mem.zeroes(Api.TransformOptions),
|
||||
.log = log,
|
||||
.start_time = start_time,
|
||||
.allocator = bun.default_allocator,
|
||||
};
|
||||
global_cli_ctx = &context_data;
|
||||
var ctx = global_cli_ctx;
|
||||
if (!bun.getRuntimeFeatureFlag(.BUN_BE_BUN)) {
|
||||
if (try bun.StandaloneModuleGraph.fromExecutable(bun.default_allocator)) |graph| {
|
||||
context_data = .{
|
||||
.args = std.mem.zeroes(Api.TransformOptions),
|
||||
.log = log,
|
||||
.start_time = start_time,
|
||||
.allocator = bun.default_allocator,
|
||||
};
|
||||
global_cli_ctx = &context_data;
|
||||
var ctx = global_cli_ctx;
|
||||
|
||||
ctx.args.target = Api.Target.bun;
|
||||
if (bun.argv.len > 1) {
|
||||
ctx.passthrough = bun.argv[1..];
|
||||
} else {
|
||||
ctx.passthrough = &[_]string{};
|
||||
ctx.args.target = Api.Target.bun;
|
||||
if (bun.argv.len > 1) {
|
||||
ctx.passthrough = bun.argv[1..];
|
||||
} else {
|
||||
ctx.passthrough = &[_]string{};
|
||||
}
|
||||
|
||||
try @import("./bun_js.zig").Run.bootStandalone(
|
||||
ctx,
|
||||
graph.entryPoint().name,
|
||||
graph,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try @import("./bun_js.zig").Run.bootStandalone(
|
||||
ctx,
|
||||
graph.entryPoint().name,
|
||||
graph,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debug("argv: [{s}]", .{bun.fmt.fmtSlice(bun.argv, ", ")});
|
||||
|
||||
@@ -5,6 +5,7 @@ const bun = @import("bun");
|
||||
/// The field names correspond exactly to the expected environment variable names.
|
||||
pub const RuntimeFeatureFlag = enum {
|
||||
BUN_ASSUME_PERFECT_INCREMENTAL,
|
||||
BUN_BE_BUN,
|
||||
BUN_DEBUG_NO_DUMP,
|
||||
BUN_DESTRUCT_VM_ON_EXIT,
|
||||
BUN_DISABLE_SLOW_LIFECYCLE_SCRIPT_LOGGING,
|
||||
|
||||
@@ -607,4 +607,23 @@ error: Hello World`,
|
||||
},
|
||||
},
|
||||
});
|
||||
itBundled("compile/BunBeBunEnvVar", {
|
||||
compile: true,
|
||||
files: {
|
||||
"/entry.ts": /* js */ `
|
||||
console.log("This is compiled code");
|
||||
`,
|
||||
},
|
||||
run: [
|
||||
{
|
||||
stdout: "This is compiled code",
|
||||
},
|
||||
{
|
||||
env: { BUN_BE_BUN: "1" },
|
||||
validate({ stdout }) {
|
||||
expect(stdout).not.toContain("This is compiled code");
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user