-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: normalize resolved result on Windows #322
fix: normalize resolved result on Windows #322
Conversation
@@ -44,7 +44,7 @@ impl<Fs: FileSystem> Cache<Fs> { | |||
pub fn value(&self, path: &Path) -> CachedPath { | |||
let hash = { | |||
let mut hasher = FxHasher::default(); | |||
path.as_os_str().hash(&mut hasher); | |||
path.hash(&mut hasher); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.hash(&mut hasher); | |
#[cfg(windows)] | |
path.hash(&mut hasher); | |
#[cfg(not(windows))] | |
path.as_os_str().hash(&mut hasher); |
It might be possible to do this. But I'm not sure that's safe for all non-Windows OSs.
CodSpeed Performance ReportMerging #322 will degrade performances by 17.72%Comparing Summary
Benchmarks breakdown
|
Ah, it seems the test passes with this diff + 08a19d7, but it doesn't with the main branch. |
I wonder whether we should force upstream to normalize all paths ... let me think about this. Or, change to a simpler, customized hasher. |
I thought it would work with a simple revert, but it turns out it needs a bigger change than that 😅. |
I'll leave this one for now. |
No worries, I'll take over. |
#316 seems to break Windows.
If the specifier or the base directory contains a forward slash, the resolved result contained a forward slash.
This causes the same module to be resolved differently (e.g.
C:\\foo.js
andC:/foo.js
) and ends up bundling the same module twice.For example,
import './foo.js'; import '.\\foo.js'
should resolve to the same path.To fix this, without reverting #316, I think it requires thinking about where to normalize the slashes. But it takes some time for me to do that, so in this PR I simply reverted the change.
reverts #316