Skip to content

Conversation

@Tofandel
Copy link
Contributor

@Tofandel Tofandel commented Jan 15, 2026

a

PR Checklist

What is the current behavior?

In windows __dirname returns /C:/Users... which does not resolve properly

What is the new behavior?

It now returns the correct dirname in windows

Fixes/Implements/Closes #[Issue Number].

@Tofandel Tofandel mentioned this pull request Jan 15, 2026
6 tasks
@nx-cloud
Copy link

nx-cloud bot commented Jan 15, 2026

View your CI Pipeline Execution ↗ for commit 9417b61

Command Status Duration Result
nx test apps-automated -c=ios ✅ Succeeded 2m 57s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-15 20:28:33 UTC

@NathanWalker
Copy link
Contributor

Thanks for this @Tofandel, were you able to confirm macOS still ok with dirname in that?

@NathanWalker
Copy link
Contributor

NathanWalker commented Jan 15, 2026

Some build errors here:

  Compiling TypeScript files for project "vite"...
  packages/vite/helpers/project.ts:11:33 - error TS2448: Block-scoped variable '__dirname' used before its declaration.
  
  11 export const __dirname = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;

You can npx nx build vite --skip-nx-cache to confirm locally.

@Tofandel
Copy link
Contributor Author

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

@Tofandel
Copy link
Contributor Author

Tofandel commented Jan 15, 2026

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));

@Tofandel
Copy link
Contributor Author

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

@NathanWalker
Copy link
Contributor

Nice thanks yes, v9 cli is node 22+ required so 👍

@NathanWalker NathanWalker merged commit f09f4e9 into NativeScript:main Jan 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants