-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(vite): __dirname to work in windows #11046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
View your CI Pipeline Execution ↗ for commit 9417b61
☁️ Nx Cloud last updated this comment at |
|
Thanks for this @Tofandel, were you able to confirm macOS still ok with dirname in that? |
|
Some build errors here: You can |
|
Ah yeah typescript doesn't like that both the global and local __dirname are used, since vite doesn't have a CJS build, we can remove it anyways |
|
I don't have mac OS, but since it just uses an ESM variable instead, I see no reason why it wouldn't work on any platform. This is node 20+ only though; if we need to support less than node 20, then we should use import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
export const __dirname = dirname(fileURLToPath(import.meta.url)); |
|
Since vite 7 is already node 20.19+, I guess no need for that either https://github.com/vitejs/vite/blob/main/packages/vite/package.json#L49 |
|
Nice thanks yes, v9 cli is node 22+ required so 👍 |
PR Checklist
What is the current behavior?
In windows
__dirnamereturns/C:/Users...which does not resolve properlyWhat is the new behavior?
It now returns the correct dirname in windows
Fixes/Implements/Closes #[Issue Number].