feat: resolved ids rollup compat for win32 (#1522) #1693
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.
Context
This PR aligns Vite server resolved ids in Windows with the way paths are handled in Rollup. I tried to assess the impact of this change as best as I could, further review and testing may be needed.
In Rollup, if the
resolveId
hook defaults the resolution of absolute paths to a fully resolved path that includes the volume.@rollup/plugin-alias internally normalizes paths by removing the volume, but this id is fed to the resolveId hook manually, and ends up being resolved so the volume is part of the final id.
The rest of the official rollup plugins, uses the
createFilter(include,exclude)
pattern internally that normalizes paths by switching all slashes to posix, but leaves the volume untouched.Vite server is currently removing the volume as part of its path normalization, so the filters for rollup plugins are not compatible. The
createFilter
pattern is common practice in official rollup plugins, so I think it is important to try to fix this compatibility issue.Changes
These changes only affect windows
normalizePath
only changes slashes to posix, aligned with rollupfsPathFromId
keeps the volume in windowstryResolveFile
invite:resolve
plugin usespath.resolve
in windows to ensure the volume is presentTests
createFilter(include,exclude)
pattern should also work now.Observations
normalizePath
from @rolluputils could be used instead of the current version. This may help avoid compatibility issues in the future.