aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-08 03:01:12 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-08 03:01:12 -0800
commitce5cbb04914673957a36d63ac3672a15a01356d7 (patch)
treec26d59b738ecb8bec940fed51ade81e63e526f26
parent9bf03a84c1f3622a58da320aa8e031c6dfa4e41e (diff)
downloadbun-ce5cbb04914673957a36d63ac3672a15a01356d7.tar.gz
bun-ce5cbb04914673957a36d63ac3672a15a01356d7.tar.zst
bun-ce5cbb04914673957a36d63ac3672a15a01356d7.zip
Install optional dependencies for auto-install
-rw-r--r--src/install/install.zig39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/install/install.zig b/src/install/install.zig
index 81db2128d..bac5835cf 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -1562,6 +1562,7 @@ pub const PackageManager = struct {
version_buf: []const u8,
version: Dependency.Version,
behavior: Dependency.Behavior,
+ is_main: bool,
) DependencyToEnqueue {
var root_deps = this.dynamicRootDependencies();
const existing: []const Dependency.Pair = root_deps.items;
@@ -1603,17 +1604,31 @@ pub const PackageManager = struct {
.dependency = cloned_dependency,
},
) catch unreachable;
- this.enqueueDependencyWithMainAndSuccessFn(
- index,
- cloned_dependency,
- invalid_package_id,
- true,
- assignRootResolution,
- failRootResolution,
- ) catch |err| {
- root_deps.items.len = index;
- return .{ .failure = err };
- };
+ if (is_main) {
+ this.enqueueDependencyWithMainAndSuccessFn(
+ index,
+ cloned_dependency,
+ invalid_package_id,
+ true,
+ assignRootResolution,
+ failRootResolution,
+ ) catch |err| {
+ root_deps.items.len = index;
+ return .{ .failure = err };
+ };
+ } else {
+ this.enqueueDependencyWithMainAndSuccessFn(
+ index,
+ cloned_dependency,
+ invalid_package_id,
+ false,
+ assignRootResolution,
+ failRootResolution,
+ ) catch |err| {
+ root_deps.items.len = index;
+ return .{ .failure = err };
+ };
+ }
if (root_deps.items[index].failed) |fail| {
root_deps.items.len = index;
@@ -3447,7 +3462,7 @@ pub const PackageManager = struct {
positionals: []const string = &[_]string{},
update: Update = Update{},
dry_run: bool = false,
- remote_package_features: Features = Features{ .peer_dependencies = false },
+ remote_package_features: Features = Features{ .peer_dependencies = false, .optional_dependencies = true },
local_package_features: Features = Features{ .peer_dependencies = false, .dev_dependencies = true },
allowed_install_scripts: []const PackageNameHash = &default_allowed_install_scripts,
// The idea here is: