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
This may affect more than MacOS, but on MacOS /private/tmp is aliased to /tmp. When started, Vite (really Rollup) will start inspecting imports and any imports from /tmp will appear as /private/tmp/... as the importer. This is important, because the way that vite-tsconfig-paths configures the projectDir uses the alias of /tmp in this scenario.
To inspect what was happening, I added some debugging around this line:
And we can see that the matching is going to fail because the directory that the plugin is looking for doesn't include /private. When we start the Vite server targeting /private/temp/app instead, everything works as expected.
This also applies if one uses the $TMPDIR environment variable, which returns a value like /var/folders/07/ywbfgwc57_z4yx4m8vzhr8580000gp/T/, which is then prefixed with /private on MacOS to appear as /private/var/folders/07/ywbfgwc57_z4yx4m8vzhr8580000gp/T/ during resolution.
This is a pretty nuanced edge case, but I wanted to share for folks that might run into a similar problem. I think the package could also do with a good bit more debug output so people can triage without having to source dive.
To resolve this case, the plugin should always wrap paths with fs.realpathSync() or equivalent.
The text was updated successfully, but these errors were encountered:
This may affect more than MacOS, but on MacOS
/private/tmp
is aliased to/tmp
. When started, Vite (really Rollup) will start inspecting imports and any imports from/tmp
will appear as/private/tmp/...
as theimporter
. This is important, because the way that vite-tsconfig-paths configures theprojectDir
uses the alias of/tmp
in this scenario.To inspect what was happening, I added some debugging around this line:
vite-tsconfig-paths/src/index.ts
Line 165 in ca4e2aa
And we can see that the matching is going to fail because the directory that the plugin is looking for doesn't include
/private
. When we start the Vite server targeting/private/temp/app
instead, everything works as expected.This also applies if one uses the
$TMPDIR
environment variable, which returns a value like/var/folders/07/ywbfgwc57_z4yx4m8vzhr8580000gp/T/
, which is then prefixed with/private
on MacOS to appear as/private/var/folders/07/ywbfgwc57_z4yx4m8vzhr8580000gp/T/
during resolution.This is a pretty nuanced edge case, but I wanted to share for folks that might run into a similar problem. I think the package could also do with a good bit more debug output so people can triage without having to source dive.
To resolve this case, the plugin should always wrap paths with
fs.realpathSync()
or equivalent.The text was updated successfully, but these errors were encountered: