Fix module resolution cache keys (#14901)

Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: cirospaciari <cirospaciari@users.noreply.github.com>
This commit is contained in:
Ciro Spaciari
2024-10-30 22:06:21 -07:00
committed by GitHub
parent 9647291d73
commit f8d5b2e6e2
9 changed files with 111 additions and 59 deletions

View File

@@ -2343,7 +2343,7 @@ pub const VirtualMachine = struct {
const buster_name = name: {
if (std.fs.path.isAbsolute(normalized_specifier)) {
if (std.fs.path.dirname(normalized_specifier)) |dir| {
// Normalized with trailing slash
// Normalized without trailing slash
break :name bun.strings.normalizeSlashesOnly(&specifier_cache_resolver_buf, dir, std.fs.path.sep);
}
}
@@ -2363,7 +2363,7 @@ pub const VirtualMachine = struct {
};
// Only re-query if we previously had something cached.
if (jsc_vm.bundler.resolver.bustDirCache(buster_name)) {
if (jsc_vm.bundler.resolver.bustDirCache(bun.strings.withoutTrailingSlashWindowsPath(buster_name))) {
continue;
}
@@ -4398,7 +4398,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
_ = this.ctx.bustDirCache(strings.pathWithoutTrailingSlashOne(file_path));
_ = this.ctx.bustDirCache(strings.withoutTrailingSlashWindowsPath(file_path));
continue;
}
var affected_buf: [128][]const u8 = undefined;
@@ -4448,7 +4448,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime
}
}
_ = this.ctx.bustDirCache(strings.pathWithoutTrailingSlashOne(file_path));
_ = this.ctx.bustDirCache(strings.withoutTrailingSlashWindowsPath(file_path));
if (entries_option) |dir_ent| {
var last_file_hash: GenericWatcher.HashType = std.math.maxInt(GenericWatcher.HashType);