diff options
author | 2023-07-16 21:17:47 -0700 | |
---|---|---|
committer | 2023-07-16 21:17:47 -0700 | |
commit | dc766eb18a2b457393f7f13668d3f6640406aff4 (patch) | |
tree | e208e6c2c466c2d29b148e36805152df599d027b | |
parent | 209dc981c0ef52de5c80eab5d24ec8a8eba765e8 (diff) | |
download | bun-dc766eb18a2b457393f7f13668d3f6640406aff4.tar.gz bun-dc766eb18a2b457393f7f13668d3f6640406aff4.tar.zst bun-dc766eb18a2b457393f7f13668d3f6640406aff4.zip |
Add `--smol` flag
-rw-r--r-- | src/bun.js/javascript.zig | 3 | ||||
-rw-r--r-- | src/bun_js.zig | 1 | ||||
-rw-r--r-- | src/cli.zig | 8 | ||||
-rw-r--r-- | src/cli/test_command.zig | 1 | ||||
-rw-r--r-- | src/http.zig | 1 | ||||
-rw-r--r-- | src/js_ast.zig | 1 |
6 files changed, 14 insertions, 1 deletions
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 3534a5316..cfa791d63 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -908,6 +908,7 @@ pub const VirtualMachine = struct { _log: ?*logger.Log, env_loader: ?*DotEnv.Loader, store_fd: bool, + smol: bool, ) !*VirtualMachine { var log: *logger.Log = undefined; if (_log) |__log| { @@ -987,7 +988,7 @@ pub const VirtualMachine = struct { @intCast(i32, global_classes.len), vm.console, -1, - false, + smol, ); vm.regular_event_loop.global = vm.global; vm.regular_event_loop.virtual_machine = vm; diff --git a/src/bun_js.zig b/src/bun_js.zig index 72b7f8de9..79f1c2596 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -151,6 +151,7 @@ pub const Run = struct { ctx.log, null, ctx.debug.hot_reload != .none, + ctx.runtime_options.smol, ), .arena = arena, .ctx = ctx, diff --git a/src/cli.zig b/src/cli.zig index f0cc47918..0c093681a 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -153,6 +153,7 @@ pub const Arguments = struct { clap.parseParam("-l, --loader <STR>... Parse files with .ext:loader, e.g. --loader .js:jsx. Valid loaders: js, jsx, ts, tsx, json, toml, text, file, wasm, napi") catch unreachable, clap.parseParam("-u, --origin <STR> Rewrite import URLs to start with --origin. Default: \"\"") catch unreachable, clap.parseParam("-p, --port <STR> Port to serve bun's dev server on. Default: \"3000\"") catch unreachable, + clap.parseParam("--smol Use less memory, but run garbage collection more often") catch unreachable, clap.parseParam("--minify Minify (experimental)") catch unreachable, clap.parseParam("--minify-syntax Minify syntax and inline data (experimental)") catch unreachable, clap.parseParam("--minify-whitespace Minify whitespace (experimental)") catch unreachable, @@ -479,6 +480,8 @@ pub const Arguments = struct { } else if (preloads.len > 0) { ctx.preloads = preloads; } + + ctx.runtime_options.smol = args.flag("--smol"); } if (opts.port != null and opts.origin == null) { @@ -960,10 +963,15 @@ pub const Command = struct { debug: DebugOptions = DebugOptions{}, test_options: TestOptions = TestOptions{}, bundler_options: BundlerOptions = BundlerOptions{}, + runtime_options: RuntimeOptions = RuntimeOptions{}, preloads: []const string = &[_]string{}, has_loaded_global_config: bool = false, + pub const RuntimeOptions = struct { + smol: bool = false, + }; + pub const BundlerOptions = struct { compile: bool = false, diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 3c6db7fc2..5314c6e52 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -493,6 +493,7 @@ pub const TestCommand = struct { // in the future we should investigate if refactoring this to not // rely on the dir fd yields a performance improvement true, + ctx.runtime_options.smol, ); vm.argv = ctx.passthrough; vm.preload = ctx.preloads; diff --git a/src/http.zig b/src/http.zig index b1d97c382..ff67d8ce5 100644 --- a/src/http.zig +++ b/src/http.zig @@ -1472,6 +1472,7 @@ pub const RequestContext = struct { handler.log, handler.env_loader, true, + false, ) catch |err| { handler.handleJSError(.create_vm, err) catch {}; javascript_disabled = true; diff --git a/src/js_ast.zig b/src/js_ast.zig index 0007cf2ad..357f11223 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -9627,6 +9627,7 @@ pub const Macro = struct { log, env, false, + false, ); _vm.enableMacroMode(); |