diff options
author | 2022-03-19 00:44:53 -0700 | |
---|---|---|
committer | 2022-03-19 00:44:53 -0700 | |
commit | c1e8f3b593a2aa61a46e0aeb786c910fa1f2c494 (patch) | |
tree | a741ee1c5e1869efc2cfaea15d4feab3986d80cb | |
parent | 0134c14ebf7c930c771709a78b7b1cffb00aedf3 (diff) | |
download | bun-c1e8f3b593a2aa61a46e0aeb786c910fa1f2c494.tar.gz bun-c1e8f3b593a2aa61a46e0aeb786c910fa1f2c494.tar.zst bun-c1e8f3b593a2aa61a46e0aeb786c910fa1f2c494.zip |
[bun bun] don't load the bundle when bundling
Diffstat (limited to '')
-rw-r--r-- | src/options.zig | 74 |
1 files changed, 20 insertions, 54 deletions
diff --git a/src/options.zig b/src/options.zig index 8288d7ce3..dfef672a2 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1327,35 +1327,27 @@ pub const BundleOptions = struct { const is_generating_bundle = (transform.generate_node_module_bundle orelse false); - // if (!(transform.generate_node_module_bundle orelse false)) { - if (node_modules_bundle_existing) |node_mods| { - opts.node_modules_bundle = node_mods; - const pretty_path = fs.relativeTo(transform.node_modules_bundle_path.?); - opts.node_modules_bundle_url = try std.fmt.allocPrint(allocator, "{s}{s}", .{ - opts.origin, - pretty_path, - }); - } else if (transform.node_modules_bundle_path) |bundle_path| { - if (bundle_path.len > 0) { - load_bundle: { - const pretty_path = fs.relativeTo(bundle_path); - var bundle_file = std.fs.openFileAbsolute(bundle_path, .{ .mode = .read_write }) catch |err| { - if (is_generating_bundle) { + if (!is_generating_bundle) { + if (node_modules_bundle_existing) |node_mods| { + opts.node_modules_bundle = node_mods; + const pretty_path = fs.relativeTo(transform.node_modules_bundle_path.?); + opts.node_modules_bundle_url = try std.fmt.allocPrint(allocator, "{s}{s}", .{ + opts.origin, + pretty_path, + }); + } else if (transform.node_modules_bundle_path) |bundle_path| { + if (bundle_path.len > 0) { + load_bundle: { + const pretty_path = fs.relativeTo(bundle_path); + var bundle_file = std.fs.openFileAbsolute(bundle_path, .{ .mode = .read_write }) catch |err| { + Output.disableBuffering(); + defer Output.enableBuffering(); + Output.prettyErrorln("<r>error opening <d>\"<r><b>{s}<r><d>\":<r> <b><red>{s}<r>", .{ pretty_path, @errorName(err) }); break :load_bundle; - } - Output.disableBuffering(); - defer Output.enableBuffering(); - Output.prettyErrorln("<r>error opening <d>\"<r><b>{s}<r><d>\":<r> <b><red>{s}<r>", .{ pretty_path, @errorName(err) }); - break :load_bundle; - }; + }; - defer { - if (is_generating_bundle) bundle_file.close(); - } - - const time_start = std.time.nanoTimestamp(); - if (NodeModuleBundle.loadBundle(allocator, bundle_file)) |bundle| { - if (!is_generating_bundle) { + const time_start = std.time.nanoTimestamp(); + if (NodeModuleBundle.loadBundle(allocator, bundle_file)) |bundle| { var node_module_bundle = try allocator.create(NodeModuleBundle); node_module_bundle.* = bundle; opts.node_modules_bundle = node_module_bundle; @@ -1385,33 +1377,7 @@ pub const BundleOptions = struct { }, ); Output.flush(); - } - - if (transform.framework == null) { - if (bundle.container.framework) |loaded_framework| { - opts.framework = try Framework.fromLoadedFramework(loaded_framework, allocator); - - if (transform.define == null) { - if (opts.platform.isClient()) { - if (opts.framework.?.client.kind != .disabled) { - opts.env = opts.framework.?.client.env; - } else if (opts.framework.?.fallback.kind != .disabled) { - opts.env = opts.framework.?.fallback.env; - } - } else { - opts.env = opts.framework.?.server.env; - } - } - } - } - - if (transform.router == null) { - if (bundle.container.routes) |routes| { - opts.routes = RouteConfig.fromLoadedRoutes(routes); - } - } - } else |err| { - if (!is_generating_bundle) { + } else |err| { Output.disableBuffering(); Output.prettyErrorln( "<r>error reading <d>\"<r><b>{s}<r><d>\":<r> <b><red>{s}<r>, <b>deleting it<r> so you don't keep seeing this message.", |