Open shellscape opened 8 months ago
Add a minimal reproduction to test fixtures (see other fixtures for guidance) and submit a PR. I will take a look then.
Feel free to close.
@shellscape Feel free to unsubscribe.
I'll be using this to track symlink issues.
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: https://github.com/aleclarson/vite-tsconfig-paths/blob/ca4e2aa7f3be36facbce0305cc145f9d5f9693d1/src/index.ts#L165
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.