diff options
| author | 2021-12-10 20:24:36 -0800 | |
|---|---|---|
| committer | 2021-12-16 19:18:51 -0800 | |
| commit | afe3e1334548781481e95b4cf365b8f7c16a7e77 (patch) | |
| tree | d4750c884f99a1ddc4ec0b394924a2fb1f855fae | |
| parent | 461c769ac4e5e4a45c86dcd27d04c01ac4da8756 (diff) | |
| download | bun-afe3e1334548781481e95b4cf365b8f7c16a7e77.tar.gz bun-afe3e1334548781481e95b4cf365b8f7c16a7e77.tar.zst bun-afe3e1334548781481e95b4cf365b8f7c16a7e77.zip | |
[bun install] Fix bug with optional peer deps
| -rw-r--r-- | src/install/npm.zig | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig index b7a5904a2..49b455507 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -1189,18 +1189,57 @@ pub const PackageManifest = struct { var name_list = ExternalStringList.init(all_extern_strings, this_names); var version_list = ExternalStringList.init(version_extern_strings, this_versions); + if (comptime is_peer) { + package_version.optional_peer_dependencies_len = @truncate(u32, peer_dependency_len); + } + if (count > 0) { if (comptime is_peer) { if (optional_peer_dep_names.items.len > 0) { + var optional_peer_deps_name_buf = [_]u8{ + '$', + 'o', + 'p', + 't', + 'i', + 'o', + 'n', + 'a', + 'l', + 'P', + 'e', + 'e', + 'r', + 'D', + 'e', + 'p', + 's', + ':', + 0, + 0, + 0, + 0, + }; + + std.mem.writeIntNative( + u32, + optional_peer_deps_name_buf[optional_peer_deps_name_buf.len - 4 ..][0..4], + package_version.optional_peer_dependencies_len, + ); + for (this_names[0..count]) |byte_str| { const bytes = @bitCast([8]u8, byte_str.hash); name_hasher.update(&bytes); } + name_hasher.update(&optional_peer_deps_name_buf); + for (this_versions[0..count]) |byte_str| { const bytes = @bitCast([8]u8, byte_str.hash); version_hasher.update(&bytes); } + + version_hasher.update(&optional_peer_deps_name_buf); } } const name_map_hash = name_hasher.final(); @@ -1230,10 +1269,6 @@ pub const PackageManifest = struct { .value = version_list, }; - if (comptime is_peer) { - package_version.optional_peer_dependencies_len = @truncate(u32, peer_dependency_len); - } - if (comptime Environment.allow_assert) { const dependencies_list = @field(package_version, pair.field); |
