You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resolveId() is called with an absolute path (process.cwd() + '/virtual-file.js') that uses the platform's path separator (\ on Windows), rather than POSIX path separator
This is inconsistent behavior and lead to a bug in my plugin on Windows.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
I'm not sure this is exactly a bug. In the resolveId hook, the given id isn't guaranteed to be normalized (the term used by Vite for forward slash only paths), what Vite guarantees within its plugins and encourages others plugins to do so, is that resolved ids (returned from resolveId hook) are normalized.
Non-normalized path can also happen if user writes imports like import "foo\\bar" or import "C:\\foo\\bar", which they will be passed to resolveId as is.
Your plugin should be updated in this case to handle backslashes.
Describe the bug
In most places Vite is using POSIX path separators even on Windows (i.e in
config.root
, file identifiers and etc).However, there is one place where this is inconsistent and platform path separators are used:
If
build.lib.entry
includes a virtual file, theresolveId()
hook in plugins will be called:The
resolveId()
is called with an absolute path (process.cwd() + '/virtual-file.js') that uses the platform's path separator (\
on Windows), rather than POSIX path separatorThis is inconsistent behavior and lead to a bug in my plugin on Windows.
Reproduction
https://github.com/maxpatiiuk/vite-inconsistent-resolve-id
Steps to reproduce
Use Windows machine
Clone the reproduction repository
Install dependencies
Run build
See build output show a message like
resolveId called with C:\Users\root\...
rather thanresolveId called with C:/Users/root/...
System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: