From 3d376842537764ceaa296f846f7cbfbeb17d3ffe Mon Sep 17 00:00:00 2001 From: jhmaster <32803471+jhmaster2000@users.noreply.github.com> Date: Wed, 27 Sep 2023 23:26:03 -0300 Subject: `deadCodeElimination` toggle for Bun.Transpiler (#5932) * add Bun.Transpiler DCE option * mark DCE toggle experimental + tests * full (hopefully) DCE toggle * update DCE toggle tests * add DCE option to types * run fmt * Removed uws submodule --- src/bun.js/api/JSTranspiler.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/bun.js') diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index 8cec025eb..d41458acb 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -72,6 +72,7 @@ const TranspilerOptions = struct { trim_unused_imports: ?bool = null, inlining: bool = false, + dead_code_elimination: bool = true, minify_whitespace: bool = false, minify_identifiers: bool = false, minify_syntax: bool = false, @@ -541,6 +542,10 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std transpiler.minify_whitespace = flag.toBoolean(); } + if (object.get(globalThis, "deadCodeElimination")) |flag| { + transpiler.dead_code_elimination = flag.toBoolean(); + } + if (object.getTruthy(globalThis, "minify")) |hot| { if (hot.isBoolean()) { transpiler.minify_whitespace = hot.coerce(bool, globalThis); @@ -800,6 +805,7 @@ pub fn constructor( bundler.options.macro_remap = transpiler_options.macro_map; } + bundler.options.dead_code_elimination = transpiler_options.dead_code_elimination; bundler.options.minify_whitespace = transpiler_options.minify_whitespace; // Keep defaults for these -- cgit v1.2.3