aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bundler.zig8
-rw-r--r--src/env_loader.zig5
-rw-r--r--src/options.zig5
3 files changed, 18 insertions, 0 deletions
diff --git a/src/bundler.zig b/src/bundler.zig
index 26a75ec43..6b55c8037 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -514,7 +514,12 @@ pub const Bundler = struct {
var dir: *Fs.FileSystem.DirEntry = ((this.resolver.readDirInfo(this.fs.top_level_dir) catch return) orelse return).getEntries() orelse return;
// Process always has highest priority.
+ const was_production = this.options.production;
this.env.loadProcess();
+ if (!was_production and this.env.isProduction()) {
+ this.options.setProduction(true);
+ }
+
if (this.options.production) {
try this.env.load(&this.fs.fs, dir, false);
} else {
@@ -523,6 +528,9 @@ pub const Bundler = struct {
},
.disable => {
this.env.loadProcess();
+ if (this.env.isProduction()) {
+ this.options.setProduction(true);
+ }
},
else => {},
}
diff --git a/src/env_loader.zig b/src/env_loader.zig
index 361b79894..e9c15fb3a 100644
--- a/src/env_loader.zig
+++ b/src/env_loader.zig
@@ -411,6 +411,11 @@ pub const Loader = struct {
const empty_string_value: string = "\"\"";
+ pub fn isProduction(this: *const Loader) bool {
+ const env = this.map.get("BUN_ENV") orelse this.map.get("NODE_ENV") orelse return false;
+ return strings.eqlComptime(env, "production");
+ }
+
pub fn getNodePath(this: *Loader, fs: *Fs.FileSystem, buf: *Fs.PathBuffer) ?[:0]const u8 {
if (this.get("NODE") orelse this.get("npm_node_execpath")) |node| {
@memcpy(buf, node.ptr, node.len);
diff --git a/src/options.zig b/src/options.zig
index 863e12e14..2169e4263 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -1253,6 +1253,11 @@ pub const BundleOptions = struct {
inlining: bool = false,
minify_whitespace: bool = false,
+ pub fn setProduction(this: *BundleOptions, value: bool) void {
+ this.production = value;
+ this.jsx.development = !value;
+ }
+
pub inline fn cssImportBehavior(this: *const BundleOptions) Api.CssInJsBehavior {
switch (this.platform) {
.neutral, .browser => {