diff options
author | 2023-09-27 23:26:03 -0300 | |
---|---|---|
committer | 2023-09-27 19:26:03 -0700 | |
commit | 3d376842537764ceaa296f846f7cbfbeb17d3ffe (patch) | |
tree | e6f0d81e2d57bf32fc29d33d662a47290a2f7cb7 /src/bun.js | |
parent | 06a82b7725eee86781c9884ff63d75450bfdf4a9 (diff) | |
download | bun-3d376842537764ceaa296f846f7cbfbeb17d3ffe.tar.gz bun-3d376842537764ceaa296f846f7cbfbeb17d3ffe.tar.zst bun-3d376842537764ceaa296f846f7cbfbeb17d3ffe.zip |
`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
Diffstat (limited to 'src/bun.js')
-rw-r--r-- | src/bun.js/api/JSTranspiler.zig | 6 |
1 files changed, 6 insertions, 0 deletions
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 |