@isaacs said in #5702 that it's impossible to tell if two filenames with different case point to the same file or not.
However, on mac OS at least with a case-insensitive filesystem, fs.stat will give the same ino for the same filename with different case. So it's completely possible, unless ino is somehow unreliable on some OSes.
I just ran into this issue due to a typo and it was mega confusing and annoying. Maybe ino was unavailable in the 0.x days, but it seems like there's no reason not to fix this now.
Seems to me that ino should be the real cache key, and require.cache should actually be retrofitted to proxy to an underlying ino-keyed cache. (I assume this would avoid duplicate loading multiple hardlinks to the same file as well). delete require.cache[key] would only actually delete the module if key is the last remaining path for the underlying ino.
However, I do read that inodes on windows are...complicated...so someone feel free to shoot holes in this proposal.
@isaacs said in #5702 that it's impossible to tell if two filenames with different case point to the same file or not.
However, on mac OS at least with a case-insensitive filesystem,
fs.statwill give the sameinofor the same filename with different case. So it's completely possible, unlessinois somehow unreliable on some OSes.I just ran into this issue due to a typo and it was mega confusing and annoying. Maybe
inowas unavailable in the 0.x days, but it seems like there's no reason not to fix this now.Seems to me that
inoshould be the real cache key, andrequire.cacheshould actually be retrofitted to proxy to an underlyingino-keyed cache. (I assume this would avoid duplicate loading multiple hardlinks to the same file as well).delete require.cache[key]would only actually delete the module ifkeyis the last remaining path for the underlyingino.However, I do read that inodes on windows are...complicated...so someone feel free to shoot holes in this proposal.