bug: fix windows drive letter casing issue #183
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #178
The root cause is vite always passes in a path with upper case drive letter for
importer
, butvite.normalizePath
does not change the drive letter casing, so when invoked from working directory with lower case drive letter, the config dir is lower case and the importer is upper case, and it will fail to compute a relative path from config dir to importerIn the previous fix, the paths are normalized to lower case, but vite still passes in upper case drive letter for
importer
and the previous fix didn't callfixFilePathCasing
on the importer. So no paths could ever get resolved on Windows (sinceimporter
is always upper andconfigDir
always lower case)I'm fixing this using a simpler approach by only changing
path.normalize
to capitalize the drive letter. This way, the change is a no-op for non-Windows and for people always using upper case drive letters, which should be much lower risk.I looked at the
is-fs-case-sensitive
package and it uses a really dirty hack IMO, which doesn't even cover all the cases since Windows can have per-directory filesystem case sensitivity. So IMO it's better to only change the drive letter part, which should be always case insensitiveTesting
Tested on a minimal project on my Windows environment and the environment I initially discovered this in (which uses lower case drive letter by default)
Verified running build succeeds with both upper and lower case drive letter as working directory