aboutsummaryrefslogtreecommitdiff
path: root/src/cli/build_command.zig
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-04-20 05:23:12 -0700
committerGravatar GitHub <noreply@github.com> 2023-04-20 05:23:12 -0700
commitd78ecc76c854310fd47da32071d22301b0782ec3 (patch)
treedcee5bde1b3598203de25f07a632cfb55aaa01e5 /src/cli/build_command.zig
parent9e7bfdec8cd4fc1827a5d793844afe36638ded37 (diff)
downloadbun-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/build_command.zig')
-rw-r--r--src/cli/build_command.zig9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig
index 0f0cd2609..33ab05632 100644
--- a/src/cli/build_command.zig
+++ b/src/cli/build_command.zig
@@ -27,7 +27,6 @@ const resolve_path = @import("../resolver/resolve_path.zig");
const configureTransformOptionsForBun = @import("../bun.js/config.zig").configureTransformOptionsForBun;
const bundler = bun.bundler;
const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
-const GenerateNodeModuleBundle = @import("../bundler/generate_node_modules_bundle.zig");
const DotEnv = @import("../env_loader.zig");
const fs = @import("../fs.zig");
@@ -53,12 +52,16 @@ pub const BuildCommand = struct {
this_bundler.resolver.opts.react_server_components = ctx.bundler_options.react_server_components;
this_bundler.options.code_splitting = ctx.bundler_options.code_splitting;
this_bundler.resolver.opts.code_splitting = ctx.bundler_options.code_splitting;
+
this_bundler.options.minify_syntax = ctx.bundler_options.minify_syntax;
- this_bundler.resolver.opts.minify_whitespace = ctx.bundler_options.minify_whitespace;
+ this_bundler.resolver.opts.minify_syntax = ctx.bundler_options.minify_syntax;
this_bundler.options.minify_whitespace = ctx.bundler_options.minify_whitespace;
this_bundler.resolver.opts.minify_whitespace = ctx.bundler_options.minify_whitespace;
+ this_bundler.options.minify_identifiers = ctx.bundler_options.minify_identifiers;
+ this_bundler.resolver.opts.minify_identifiers = ctx.bundler_options.minify_identifiers;
+
this_bundler.configureLinker();
// This step is optional
@@ -99,6 +102,8 @@ pub const BuildCommand = struct {
if (ctx.bundler_options.transform_only) {
this_bundler.linker.options.resolve_mode = .lazy;
this_bundler.options.import_path_format = .relative;
+ this_bundler.options.allow_runtime = false;
+ this_bundler.resolver.opts.allow_runtime = false;
// TODO: refactor this .transform function
const result = try this_bundler.transform(