diff options
author | 2023-04-20 05:23:12 -0700 | |
---|---|---|
committer | 2023-04-20 05:23:12 -0700 | |
commit | d78ecc76c854310fd47da32071d22301b0782ec3 (patch) | |
tree | dcee5bde1b3598203de25f07a632cfb55aaa01e5 /src/cli.zig | |
parent | 9e7bfdec8cd4fc1827a5d793844afe36638ded37 (diff) | |
download | bun-d78ecc76c854310fd47da32071d22301b0782ec3.tar.gz bun-d78ecc76c854310fd47da32071d22301b0782ec3.tar.zst bun-d78ecc76c854310fd47da32071d22301b0782ec3.zip |
Symbol minification (#2695)
* minify
* Update renamer.zig
* --minify-whitespace
* Speed up minification a little
* handle private names
* 5% faster minification
* use helper function
* fix nested scope slots
* `bun build --minify` gets another +8% faster
* print semicolons afterwards
* print semicolon after checking error
* after all error checking
* Delete code for generating legacy bundes
* remove extra whitespace around if statements
* print space before import identifier
* Use `@constCast`
* Make `S.Local#decls` use `BabyList(Decl)`
* Add `fromSlice` helper to `BabyList`
* Remove unnecessary optional chains
* minify `undefined, true, false`
* Another @constCast
* Implement merge adjacent local var
* Support --minify in `bun build --transform`
* skip comments when counting character frequencies
* Don't wrap commonjs with --transform on (unless targeting bun)
* Support --minify in the runtime
* Fix edgecase with import * as
* don't infinite loop
* --trnasform shouldn't mess with require
* Only track comments when minifying
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/cli.zig')
-rw-r--r-- | src/cli.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cli.zig b/src/cli.zig index e5065fd79..61e236bad 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -165,6 +165,10 @@ pub const Arguments = struct { clap.parseParam("-l, --loader <STR>... Parse files with .ext:loader, e.g. --loader .js:jsx. Valid loaders: jsx, js, json, tsx, ts, css") 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("--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, + clap.parseParam("--minify-identifiers Minify identifiers") catch unreachable, clap.parseParam("<POS>... ") catch unreachable, }; @@ -208,8 +212,6 @@ pub const Arguments = struct { clap.parseParam("--server-components Enable React Server Components (experimental)") catch unreachable, clap.parseParam("--splitting Split up code!") catch unreachable, clap.parseParam("--transform Do not bundle") catch unreachable, - clap.parseParam("--minify-syntax Minify syntax and inline data (experimental)") catch unreachable, - clap.parseParam("--minify-whitespace Minify whitespace (experimental)") catch unreachable, }; // TODO: update test completions @@ -476,10 +478,14 @@ pub const Arguments = struct { const production = false; var output_file: ?string = null; + const minify_flag = args.flag("--minify"); + ctx.bundler_options.minify_syntax = minify_flag or args.flag("--minify-syntax"); + ctx.bundler_options.minify_whitespace = minify_flag or args.flag("--minify-whitespace"); + ctx.bundler_options.minify_identifiers = minify_flag or args.flag("--minify-identifiers"); + if (cmd == .BuildCommand) { ctx.bundler_options.transform_only = args.flag("--transform"); - ctx.bundler_options.minify_syntax = args.flag("--minify-syntax"); - ctx.bundler_options.minify_whitespace = args.flag("--minify-whitespace"); + if (args.option("--outdir")) |outdir| { if (outdir.len > 0) { ctx.bundler_options.outdir = outdir; @@ -922,6 +928,7 @@ pub const Command = struct { transform_only: bool = false, minify_syntax: bool = false, minify_whitespace: bool = false, + minify_identifiers: bool = false, }; const _ctx = Command.Context{ |