-
SummaryI am creating a directory outside of the project, let's call it I've tried to trace the code and it seems to be resolving the symlinks correctly in the I've created a minimal reproduction of the issue and linked the repo to this discussion. Steps to reproduce:
Observe the following: If you remove the symlink and paste the vendor files directly into the Link to repo with reproduction. Additional informationNo response Examplehttps://github.com/snivels/symlinks-not-working |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
It seems like watchpack is the issue, it's using Next.js itself has correct support for symlinks. If anyone wants to use symlinks in their project, you can change the calls from
Then use patch-package to create a patch for your version of Next.js: npx patch-package next And then update your Closing the discussion with a resolution in case anyone wants a temporary solution until watchpack updates this. Also updated the reproduction branch to now include the patch. |
Beta Was this translation helpful? Give feedback.
-
The scope of this bug is relatively small: You can symlink files and non-route directories, just not route directories. The bug is in the development server's route manifest generation. I don't have the time to prioritize and fix this myself, but hopefully this helps explain things if somebody does want to try to fix it. I looked into this. Unfortunately, a proper fix would be a lot more complicated than modifying watchpack:
Watchpack has a
if you watch
If you use
However, it won't watch the contents of We can simplify things a bit by not allowing symlinks for route directories that point outside of the watched project directory/repository, but a proper solution would still be rather complicated:
If fixed, this may reveal other issues with directory traversal in other parts of Next.js. |
Beta Was this translation helpful? Give feedback.
-
After upgrading to Next 15, my hot reloading stopped working for all my symlinked components. None of them are routes. Is this the same issue, or different? It's a complete show stopper. I have a closed source Next.js website / repo. It uses an open source editor / repo. I symlink the repo folder into the Next.js repo so I can develop on both at once, and get hot reloading. $ ls -al src/
editor -> /Users/andrewray/editor/src I have a "paths": {
"@editor/*": ["./src/editor/*"],
"@editor-components/*": ["./src/editor/editor/components/*"],
} I import components from there - like in import { Shader } from '@editor/model/Shader'; I also do dynamic imports for client-only components in export const Three = dynamic(
() => import('@editor/editor-engine-plugins/three/ThreeEditor'),
{
loading: () => <Loading icon="three" name="Three.js" />,
ssr: false,
}
); Hot reloading worked in these files in Next.js 13, but not 15. The files load fine, and are not imported route directories. But they no longer hot reload. Next 15 has made local development unusable. It's unclear to me fro the description of this bug if this is the same issue or different. |
Beta Was this translation helpful? Give feedback.
-
@snivels your answer does not work. Also, there is no file named @bgw If Nextjs 15 doesn't allow hot reloading of any symlinked files, I would argue this is not a small issue. Let me know if I should file a new issue if this is a separate problem from the original discussion. Right now local development is impossible for me with Next 15 To clarify, any changes to the symlinked files require a full nextjs server restart to pick up. I'm also running without Turbopack. Using Turbopack does not work either, it flat out fails to build with |
Beta Was this translation helpful? Give feedback.
It seems like watchpack is the issue, it's using
fs.lstat
instead offs.stat
and is not recognizing symlinks.Next.js itself has correct support for symlinks.
If anyone wants to use symlinks in their project, you can change the calls from
.lstat(
to.stat(
in the following file:Then use patch-package to create a patch for your version of Next.js:
And then update your
postinstall
to patch packages after install:Closing the discussion with a resolution in case anyone wants a temporary solution until watchpack updates this.
Also updated the reproduction branch to now include the patch.