mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
fix(windows): fix directory cache regression "expected to end with a trailing slash" (#9144)
* okaaaaaaaay
* Revert "resolver: fix debug mode crash in test/bundler/bun-build-api.test.ts (#9140)"
This reverts commit 331d079dad.
* correctly fix the cache bust bug
this was introduced a couple of commits ago in my random fixes,
where i put the wrong fix to another directory caching bug.
i still stand by the assertion in place despite it causing many people
issues. it's precense will prevent subtle module resolutions failures.
* add an extra comment
* fix building a release build locally
* add a better test case for 3216
* staging
* fix mac issues
* ok
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -1710,21 +1710,17 @@ pub const VirtualMachine = struct {
|
||||
if (std.fs.path.isAbsolute(normalized_specifier)) {
|
||||
if (std.fs.path.dirname(normalized_specifier)) |dir| {
|
||||
// Normalized with trailing slash
|
||||
break :name bun.strings.normalizeSlashesOnly(
|
||||
&specifier_cache_resolver_buf,
|
||||
if (dir.len == 1) dir else normalized_specifier[0 .. dir.len + 1],
|
||||
'/',
|
||||
);
|
||||
break :name bun.strings.normalizeSlashesOnly(&specifier_cache_resolver_buf, dir, std.fs.path.sep);
|
||||
}
|
||||
}
|
||||
|
||||
var parts = [_]string{
|
||||
source_to_use,
|
||||
normalized_specifier,
|
||||
bun.pathLiteral("../"),
|
||||
bun.pathLiteral(".."),
|
||||
};
|
||||
|
||||
break :name bun.path.joinAbsStringBufZTrailingSlash(
|
||||
break :name bun.path.joinAbsStringBufZ(
|
||||
jsc_vm.bundler.fs.top_level_dir,
|
||||
&specifier_cache_resolver_buf,
|
||||
&parts,
|
||||
@@ -1732,9 +1728,11 @@ pub const VirtualMachine = struct {
|
||||
);
|
||||
};
|
||||
|
||||
// Only re-query if we previously had something cached.
|
||||
if (jsc_vm.bundler.resolver.bustDirCache(buster_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return error.ModuleNotFound;
|
||||
},
|
||||
};
|
||||
@@ -3446,7 +3444,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime
|
||||
// on windows we receive file events for all items affected by a directory change
|
||||
// so we only need to clear the directory cache. all other effects will be handled
|
||||
// by the file events
|
||||
_ = resolver.bustDirCache(file_path);
|
||||
_ = resolver.bustDirCache(strings.pathWithoutTrailingSlashOne(file_path));
|
||||
continue;
|
||||
}
|
||||
var affected_buf: [128][]const u8 = undefined;
|
||||
@@ -3496,7 +3494,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime
|
||||
}
|
||||
}
|
||||
|
||||
_ = resolver.bustDirCache(file_path);
|
||||
_ = resolver.bustDirCache(strings.pathWithoutTrailingSlashOne(file_path));
|
||||
|
||||
if (entries_option) |dir_ent| {
|
||||
var last_file_hash: GenericWatcher.HashType = std.math.maxInt(GenericWatcher.HashType);
|
||||
|
||||
Reference in New Issue
Block a user