Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9b8a252
make isolated installs the default
dylan-conway Oct 6, 2025
88a2f36
only for projects with workspaces
dylan-conway Oct 7, 2025
257ba67
update
dylan-conway Oct 7, 2025
46244ae
fix creating patches with isolated installer
dylan-conway Oct 7, 2025
7b31bbe
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 7, 2025
3c031da
fix windows
dylan-conway Oct 7, 2025
6e39987
fix windows more
dylan-conway Oct 7, 2025
e3bf024
some tests
dylan-conway Oct 7, 2025
9722655
make it work on windows
dylan-conway Oct 7, 2025
0c2951c
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 7, 2025
d116f9c
update
dylan-conway Oct 7, 2025
84c04c8
fix(patch): support both isolated and hoisted installs in patch command
Oct 7, 2025
0b411c4
test: remove redundant bun patch is-odd call
Oct 7, 2025
6778cee
fix(patch): support isolated installs in patch commit and fix workspa…
Oct 7, 2025
d4eeaed
fix(patch): address CodeRabbit review - deep-clone logs and support p…
Oct 7, 2025
1b901d2
fix(patch): fix memory leaks and update misleading comment
Oct 7, 2025
e52b3f0
update test
dylan-conway Oct 7, 2025
3e253e0
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 7, 2025
e9d6b0e
fix(test): refactor Windows junction path matching in toBeWorkspaceLink
Oct 7, 2025
51d83a3
Revert "fix(test): refactor Windows junction path matching in toBeWor…
dylan-conway Oct 8, 2025
93bef3b
Revert "[autofix.ci] apply automated fixes"
dylan-conway Oct 8, 2025
6df179b
Revert "fix(patch): fix memory leaks and update misleading comment"
dylan-conway Oct 8, 2025
d0680cf
Revert "fix(patch): address CodeRabbit review - deep-clone logs and s…
dylan-conway Oct 8, 2025
cec1af1
Revert "fix(patch): support isolated installs in patch commit and fix…
dylan-conway Oct 8, 2025
70ac9a7
Revert "test: remove redundant bun patch is-odd call"
dylan-conway Oct 8, 2025
efdc068
Revert "fix(patch): support both isolated and hoisted installs in pat…
dylan-conway Oct 8, 2025
690c48e
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 8, 2025
ba454ca
update
dylan-conway Oct 8, 2025
c44b552
update
dylan-conway Oct 8, 2025
eb1fc82
fix before each
dylan-conway Oct 8, 2025
b43e29e
fix remaining install tests
dylan-conway Oct 8, 2025
31027da
Merge branch 'main' into dylan/default-isolated-install
dylan-conway Oct 8, 2025
28038b3
update
dylan-conway Oct 8, 2025
d2e383f
delete node_modules if unknown
dylan-conway Oct 8, 2025
848b20a
Merge branch 'main' into dylan/default-isolated-install
dylan-conway Oct 8, 2025
b3f8978
fix windows mkdirat
dylan-conway Oct 8, 2025
92c4561
update
dylan-conway Oct 8, 2025
f52b4e9
update
dylan-conway Oct 8, 2025
2404d30
update
dylan-conway Oct 8, 2025
d1e145c
rename instead of delete
dylan-conway Oct 8, 2025
9288f8e
rename entries on windows, rename node_modules on posix
dylan-conway Oct 8, 2025
3ff799b
update
dylan-conway Oct 8, 2025
41a073c
update
dylan-conway Oct 8, 2025
f30ff00
fix
dylan-conway Oct 8, 2025
794559a
unused code
dylan-conway Oct 8, 2025
0bffe4c
more test
dylan-conway Oct 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/StandaloneModuleGraph.zig
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ pub const StandaloneModuleGraph = struct {

pub fn inject(bytes: []const u8, self_exe: [:0]const u8, inject_options: InjectOptions, target: *const CompileTarget) bun.FileDescriptor {
var buf: bun.PathBuffer = undefined;
var zname: [:0]const u8 = bun.span(bun.fs.FileSystem.instance.tmpname("bun-build", &buf, @as(u64, @bitCast(std.time.milliTimestamp()))) catch |err| {
var zname: [:0]const u8 = bun.fs.FileSystem.tmpname("bun-build", &buf, @as(u64, @bitCast(std.time.milliTimestamp()))) catch |err| {
Output.prettyErrorln("<r><red>error<r><d>:<r> failed to get temporary file name: {s}", .{@errorName(err)});
return bun.invalid_fd;
});
};

const cleanup = struct {
pub fn toClean(name: [:0]const u8, fd: bun.FileDescriptor) void {
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/ModuleLoader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn resolveEmbeddedFile(vm: *VirtualMachine, input_path: []const u8, extname:

// atomically write to a tmpfile and then move it to the final destination
var tmpname_buf: bun.PathBuffer = undefined;
const tmpfilename = bun.sliceTo(bun.fs.FileSystem.instance.tmpname(extname, &tmpname_buf, bun.hash(file.name)) catch return null, 0);
const tmpfilename = bun.fs.FileSystem.tmpname(extname, &tmpname_buf, bun.hash(file.name)) catch return null;

const tmpdir: bun.FD = .fromStdDir(bun.fs.FileSystem.instance.tmpdir() catch return null);

Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/RuntimeTranspilerCache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub const RuntimeTranspilerCache = struct {

// atomically write to a tmpfile and then move it to the final destination
var tmpname_buf: bun.PathBuffer = undefined;
const tmpfilename = bun.sliceTo(try bun.fs.FileSystem.instance.tmpname(std.fs.path.extension(destination_path.slice()), &tmpname_buf, input_hash), 0);
const tmpfilename = try bun.fs.FileSystem.tmpname(std.fs.path.extension(destination_path.slice()), &tmpname_buf, input_hash);

const output_bytes = output_code.byteSlice();

Expand Down
2 changes: 1 addition & 1 deletion src/compile_target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn downloadToPath(this: *const CompileTarget, env: *bun.DotEnv.Loader, alloc

const libarchive = bun.libarchive;
var tmpname_buf: [1024]u8 = undefined;
const tempdir_name = bun.span(try bun.fs.FileSystem.instance.tmpname("tmp", &tmpname_buf, bun.fastRandom()));
const tempdir_name = try bun.fs.FileSystem.tmpname("tmp", &tmpname_buf, bun.fastRandom());
var tmpdir = try std.fs.cwd().makeOpenPath(tempdir_name, .{});
defer tmpdir.close();
defer std.fs.cwd().deleteTree(tempdir_name) catch {};
Expand Down
2 changes: 1 addition & 1 deletion src/fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub const FileSystem = struct {
}

var tmpname_id_number = std.atomic.Value(u32).init(0);
pub fn tmpname(_: *const FileSystem, extname: string, buf: []u8, hash: u64) ![*:0]u8 {
pub fn tmpname(extname: string, buf: []u8, hash: u64) std.fmt.BufPrintError![:0]u8 {
const hex_value = @as(u64, @truncate(@as(u128, @intCast(hash)) | @as(u128, @intCast(std.time.nanoTimestamp()))));

return try std.fmt.bufPrintZ(buf, ".{any}-{any}.{s}", .{
Expand Down
5 changes: 1 addition & 4 deletions src/install/PackageInstaller.zig
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ pub const PackageInstaller = struct {

return (try bun.sys.openDirAtWindowsA(.fromStdDir(root), this.path.items, .{
.can_rename_or_delete = false,
.create = false,
.read_only = false,
}).unwrap()).stdDir();
}
Expand All @@ -132,11 +131,9 @@ pub const PackageInstaller = struct {
break :brk try root.makeOpenPath(this.path.items, .{ .iterate = true, .access_sub_paths = true });
}

// TODO: is this `makePath` necessary with `.create = true` below
try bun.MakePath.makePath(u8, root, this.path.items);
break :brk (try bun.sys.openDirAtWindowsA(.fromStdDir(root), this.path.items, .{
.can_rename_or_delete = false,
.create = true,
.op = .open_or_create,
.read_only = false,
}).unwrap()).stdDir();
};
Expand Down
2 changes: 1 addition & 1 deletion src/install/PackageManager.zig
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ var ensureTempNodeGypScriptOnce = bun.once(struct {

const tempdir = manager.getTemporaryDirectory();
var path_buf: bun.PathBuffer = undefined;
const node_gyp_tempdir_name = bun.span(try Fs.FileSystem.instance.tmpname("node-gyp", &path_buf, 12345));
const node_gyp_tempdir_name = try Fs.FileSystem.tmpname("node-gyp", &path_buf, 12345);

// used later for adding to path for scripts
manager.node_gyp_tempdir_name = try manager.allocator.dupe(u8, node_gyp_tempdir_name);
Expand Down
2 changes: 1 addition & 1 deletion src/install/PackageManager/PackageManagerDirectories.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var getTemporaryDirectoryOnce = bun.once(struct {
};
};
var tmpbuf: bun.PathBuffer = undefined;
const tmpname = Fs.FileSystem.instance.tmpname("hm", &tmpbuf, bun.fastRandom()) catch unreachable;
const tmpname = Fs.FileSystem.tmpname("hm", &tmpbuf, bun.fastRandom()) catch unreachable;
var timer: std.time.Timer = if (manager.options.log_level != .silent) std.time.Timer.start() catch unreachable else undefined;
brk: while (true) {
var file = tempdir.createFileZ(tmpname, .{ .truncate = true }) catch |err2| {
Expand Down
33 changes: 26 additions & 7 deletions src/install/PackageManager/install_with_manager.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn installWithManager(
manager.options.enable.force_save_lockfile = manager.options.enable.force_save_lockfile or
(load_result == .ok and
// if migrated always save a new lockfile
(load_result.ok.was_migrated or
(load_result.ok.migrated != .none or

// if loaded from binary and save-text-lockfile is passed
(load_result.ok.format == .binary and
Expand Down Expand Up @@ -776,9 +776,29 @@ pub fn installWithManager(
}

switch (manager.options.node_linker) {
.auto => {
if (manager.lockfile.workspace_paths.count() > 0 and
!load_result.migratedFromNpm())
{
break :install_summary bun.handleOom(installIsolatedPackages(
manager,
ctx,
install_root_dependencies,
workspace_filters,
null,
));
}
break :install_summary try installHoistedPackages(
manager,
ctx,
workspace_filters,
install_root_dependencies,
log_level,
null,
);
},

.hoisted,
// TODO
.auto,
=> break :install_summary try installHoistedPackages(
manager,
ctx,
Expand All @@ -788,15 +808,14 @@ pub fn installWithManager(
null,
),

.isolated => break :install_summary installIsolatedPackages(
.isolated,
=> break :install_summary bun.handleOom(installIsolatedPackages(
manager,
ctx,
install_root_dependencies,
workspace_filters,
null,
) catch |err| switch (err) {
error.OutOfMemory => bun.outOfMemory(),
},
)),
}
};

Expand Down
Loading