aboutsummaryrefslogtreecommitdiff
path: root/src/install/install.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-24 22:01:37 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-24 22:01:37 -0800
commit1795b6570cae668fa75231a9be8b88cd5fe55543 (patch)
tree9aec52ae7fec28d458260d1061311b3ff334518c /src/install/install.zig
parent152e3cb7bf95602e7fd7cf03273ae5e5e288d5cc (diff)
downloadbun-1795b6570cae668fa75231a9be8b88cd5fe55543.tar.gz
bun-1795b6570cae668fa75231a9be8b88cd5fe55543.tar.zst
bun-1795b6570cae668fa75231a9be8b88cd5fe55543.zip
[bun install] Skip saving the lockfile if there are no changes
Diffstat (limited to '')
-rw-r--r--src/install/install.zig38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/install/install.zig b/src/install/install.zig
index 0967c87a1..68bd071fc 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -2662,20 +2662,13 @@ pub const PackageManager = struct {
this.native_bin_link_allowlist = buf;
}
- if (bun_install.production) |production| {
- if (production) {
- this.local_package_features.dev_dependencies = false;
- this.enable.fail_early = true;
- this.enable.frozen_lockfile = true;
- }
- }
-
if (bun_install.save_yarn_lockfile orelse false) {
this.do.save_yarn_lock = true;
}
if (bun_install.save_lockfile) |save_lockfile| {
this.do.save_lockfile = save_lockfile;
+ this.enable.force_save_lockfile = true;
}
if (bun_install.save_dev) |save| {
@@ -2686,6 +2679,15 @@ pub const PackageManager = struct {
this.remote_package_features.peer_dependencies = save;
}
+ if (bun_install.production) |production| {
+ if (production) {
+ this.local_package_features.dev_dependencies = false;
+ this.enable.fail_early = true;
+ this.enable.frozen_lockfile = true;
+ this.enable.force_save_lockfile = false;
+ }
+ }
+
if (bun_install.save_optional) |save| {
this.remote_package_features.optional_dependencies = save;
this.local_package_features.optional_dependencies = save;
@@ -2910,6 +2912,7 @@ pub const PackageManager = struct {
if (cli.force) {
this.enable.manifest_cache_control = false;
this.enable.force_install = true;
+ this.enable.force_save_lockfile = true;
}
this.update.development = cli.development;
@@ -2935,6 +2938,10 @@ pub const PackageManager = struct {
/// Probably need to be a little smarter
deduplicate_packages: bool = false,
+ // Don't save the lockfile unless there were actual changes
+ // unless...
+ force_save_lockfile: bool = false,
+
force_install: bool = false,
};
};
@@ -4809,7 +4816,9 @@ pub const PackageManager = struct {
// sleep on since we might not need it anymore
NetworkThread.global.pool.sleep_on_idle_network_thread = true;
- if (had_any_diffs or needs_new_lockfile or manager.package_json_updates.len > 0) {
+ const needs_clean_lockfile = had_any_diffs or needs_new_lockfile or manager.package_json_updates.len > 0;
+
+ if (needs_clean_lockfile) {
manager.lockfile = try manager.lockfile.clean(manager.package_json_updates);
}
@@ -4828,7 +4837,16 @@ pub const PackageManager = struct {
try manager.setupGlobalDir(&ctx);
}
- if (manager.options.do.save_lockfile) {
+ // We don't always save the lockfile.
+ // This is for two reasons.
+ // 1. It's unnecessary work if there are no changes
+ // 2. There is a determinism issue in the file where alignment bytes might be garbage data
+ // This is a bug that needs to be fixed, however we can work around it for now
+ // by avoiding saving the lockfile
+ if (manager.options.do.save_lockfile and (needs_clean_lockfile or
+ manager.lockfile.isEmpty() or
+ manager.options.enable.force_save_lockfile))
+ {
save: {
if (manager.lockfile.isEmpty()) {
if (!manager.options.dry_run) {