Using absolute paths and vite.
This is ok because the import is processed by vite
or rollup
and node never sees this.
import "C:/users/edivados/index.js" ;
await import ( "C:/users/edivados/index.js" ) ;
resolver
mode
sees
comment
✔️
vite
dev
/@fs/C:/users/edivados/index.js
/@fs/
gets added by vite. vite:resolve
plugin removes /@fs/ and normalizes to slash. /@fs/ skips checking if the file exists.
✔️
rollup
build
?
valid Windows path
✔️
node
runtime
bundler output
This is ok because the import is processed by vite
or rollup
and node never sees this.
import "C:\\users\\edivados\\index.js" ;
await import ( "C:\\users\\edivados\\index.js" ) ;
resolver
mode
sees
comment
✔️
vite
dev
/@fs/C:/users/edivados/index.js
/@fs/
gets added by vite + normalization. vite:resolve plugin
removes /@fs/ and normalizes to slash. /@fs/ skips checking if the file exists.
✔️
rollup
build
?
valid Windows path
✔️
node
runtime
bundler output
✔️ Leading slash (Posix style path)
import "/C:/users/edivados/index.js" ;
await import ( "/C:/users/edivados/index.js" ) ;
resolver
mode
sees
comment
✔️
vite
dev
/@fs/C:/users/edivados/index.js
✔️
rollup
build
?
valid Windows path
✔️
node
runtime
bundler output
// path = C:/users/edivados/index.js
if ( import . meta . env . DEV ) path = posix . resolve ( "/@fs" , path ) ;
else path = pathToFileURL ( path ) . href ;
await import ( path )
resolver
mode
sees
comment
✔️
vite
dev
/@fs/C:/users/edivados/index.js
vite:resolve
plugin removes /@fs/
and normalizes to slash. /@fs/
skips checking if the file exists.
✔️
rollup
build
noop
✔️
node
runtime
file:///C:/users/edivados/index.js
✔️ Leading slash (Posix style path)
// path = C:/users/edivados/index.js
path = posix . resolve ( "/" , path ) ;
await import ( path ) ;
resolver
mode
sees
comment
✔️
vite
dev
/C:/users/edivados/index.js
vite:resolve
plugin removes the leading slash, calls resolve(root, path) and also checks if the file exists.
✔️
rollup
build
noop
✔️
node
runtime
file:///C:/users/edivados/index.js
ok?
// path = C:/users/edivados/index.js
await import ( path )
resolver
mode
sees
comment
❌
vite
dev
C:/users/edivados/index.js
uses nodeImport
and fails
✔️
rollup
build
noop
❌
node
runtime
C:/users/edivados/index.js
has to be a file url
// path = C:\\users\\edivados\\index.js
await import ( path )
resolver
mode
sees
comment
❌
vite
dev
C:\users\edivados\index.js
uses nodeImport
and fails
✔️
rollup
build
noop
❌
node
runtime
C:\users\edivados\index.js
has to be a file url