-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Symlink support #105
Comments
Watchman recursively watches files that are contained within a filesystem tree. Why not simply resolve the symlink and watch its target? Because it isn't simple. Here are a handful of reasons that make this a difficult prospect. This is not an exhaustive list, it's just a few reasons I can rattle off the top of my head:
Correctly handling all of the above would be tremendously complex and still be error prone. As a result, it is unlikely that we'll ever add support for resolving and tracking symlink targets. |
Taking a step back from this, can you describe what you're trying to do and why symlinks are important? I'm a casual and occasional node and npm user and am not familiar with |
I understand why this would be difficult, and I'll close the ticket and resign to using the above solution for developing local modules. I'll attempt to explain the process behind npm link, with my use case as an example. I am developing a module called react-native-waterfall, it implements a generic waterfall view. npm requires modules from either:
The second solution has 2 problems:
The third solution has 2 problems as well(both are slow)
npm link works the following way:
This allows the following benefits:
|
Thanks. How does watchman fit into this? |
I am using watchman with the react-native packager, which automatically parses dependencies, transforms code and reloads the application when you change a file. However I have to continuously restart the packager because it doesn't detect the symlinked dependencies's changes. |
Idea: /dir1/ watch dir1 Any change in a file at dir2 would trigger an event for an analogous file in dir1 |
Sorry to disappoint; it's too complex to build something to handle this that will work according to expectations. |
I've been giving this some thought. I think full-blown symlink handling is too fraught with problems to be something we can commit to, but it doesn't mean that we can't help out in some of the easier or more common cases. I'll collect some thoughts into a wiki page through the weekend and link to it from here |
Sounds good! Would be a great productivity boost for any npm-related consumers developing modules simultaneously, which seems to be a great deal of them nowadays |
This came up a few times. I think we can handle it in the RN packager by detecting symlinks and starting a new watch on these symlinks. There is also reports that the initial file system crawl (which queries watchman) is wrong if there is any linked directories. @wez: even if watchman doesn't follow the symlink shouldn't it report them like any other file? |
@amasad I've been brainstorming with @bhamiltoncx and we have a plan for this. I'd say hold off from implementing anything in RN for the moment; we have some diffs in progress. |
Any updates on this? Really makes developing modules a pain. |
👍 |
1 similar comment
+1 |
+1, unfortunately, as you know, RN is in a bit of a bind without symlinks, as it's a common practice to For now I've thrown in a bash script to recursively copy all my local dependencies into my project's |
+1 |
1 similar comment
+1 |
What are module developers doing in general to work around this? @ajwhite, your solution sounds reasonable. Do you run your script by hand or have you wired up watchman to run it for you? |
I'm running them by hand currently. I'm sure there's a better way |
I'm just opening a new project from the node modules directory and working on it that way... Sucks but it's the easiest way I'm finding without messing about with scripts and stuff. |
Hello, I am working on a lerna project which have a web app and a react native module which also support web. I now want to install and work in development from within a react native project app. I have been trying all the tools online and everyconfiguration, I am not able to setup a react native development environment because of this. What's the solution in 2021 ? |
life is what happens while developers expect to have symlink support on watchman... |
Thanks for the tip :) I am now trying with wl, but despite the folder being watched, it does not copy the change. Any hint perhaps ? I expect Watchman to support symlink because this is a widely used feature used by npm, yarn and all the node package manager available out there so it is kind of expected and needed. I am extracting a web app module so I can turn it compatible with react native, how should I configure a proper development environment within my native app if I can't use linking between the two? |
Meanwhile, literally every single major and minor bundler for the Node ecosystem supports following symlinks. That this has been an open request for over 6 years, that the metro team has fallen this far behind ecosystem norms, and that the team has remained stubborn on this issue is absolutely mind blowing. Maintainers: you were wrong. Let's own the mistake and do right by the community. |
Not sure if this workaround has been mentioned, but you can create a metro config file that explicitly adds a symlinked project to the project roots. I did it like this. In the code there's a comment with a link to the repo I stole it from. |
7 years later, symlinked packages have long since been the standard for all JS package managers. This issue makes developing a react-native app in a monorepo unnecessarily difficult and error prone. If this issue is never going to be fixed can we please close this issue with an explanation of the rationale and possible workarounds? |
Has anyone using |
The lack of symlink support was an unpleasant surprise while developing https://github.com/gajus/turbowatch/ |
Funny to see you here! The lack of symlink support was why we couldn't consider turbowatch. |
Huge 🤦♂️ We only tested Turbowatch in the context of re-building packages and apps when changes in the workspace are detected, but failed to check if it will work when the goal is to detected when symlinked dependencies change. The lack of symlink support makes Watchman unusable for our use case (monorepo with linked dependencies). For what it is worth, I am rewriting Turbowatch to allow choosing between using Watchman or chokidar as a backend. Expect an update in the next 12 hours. |
Turbowatch was developed to leverage [Watchman](https://facebook.github.io/watchman/) as a superior backend for watching a large number of files. However, along the way, we discovered that Watchman does not support symbolic links (issue [#105](facebook/watchman#105 (comment))). Unfortunately, that makes Watchman unsuitable for projects that utilize linked dependencies (which is the direction in which the ecosystem is moving for dependency management in monorepos). As such, Watchman was replaced with [chokidar](https://www.npmjs.com/package/chokidar). We are hoping to provide Watchman as a backend in the future. Therefore, we made Turbowatch expressions syntax compatible with a subset of Watchman expressions. Breaking changes: * various miscellaneous expressions have been dropped * debounce became part of the `watch` configuration * change event no longer describes `exists`, `mtime` or `size` attributes of the file that changed
Turbowatch was developed to leverage [Watchman](https://facebook.github.io/watchman/) as a superior backend for watching a large number of files. However, along the way, we discovered that Watchman does not support symbolic links (issue [#105](facebook/watchman#105 (comment))). Unfortunately, that makes Watchman unsuitable for projects that utilize linked dependencies (which is the direction in which the ecosystem is moving for dependency management in monorepos). As such, Watchman was replaced with [chokidar](https://www.npmjs.com/package/chokidar). We are hoping to provide Watchman as a backend in the future. Therefore, we made Turbowatch expressions syntax compatible with a subset of Watchman expressions. BREAKING CHANGE: * various miscellaneous expressions have been dropped * debounce became part of the `watch` configuration * change event no longer describes `exists`, `mtime` or `size` attributes of the file that changed
https://github.com/gajus/turbowatch/releases/tag/v2.0.0 Turbowatch made a switch to chokidar. However, I kept the API such that we could revert to using Watchman, or maybe even support multiple backends. |
@chadaustin @xavierd @fanzeyi (tagging recently active contributors) Is there a chance of this issue receiving attention? |
@gajus Sorry. Likely no. The harsh reality is that there is not really a case for symlink support internally (I recently chatted with folks about this), and we probably won't be motivated to implement this. |
Turbowatch uses [`fs.watch`](https://nodejs.org/api/fs.html#fswatchfilename-options-listener), which is known to have platform-specific caveats. Unfortunately, Watchman cannot be used due to it not supporting symbolic links (issue [#105](facebook/watchman#105 (comment))) and Chokidar cannot be used due to it failing to detect file changes (issue [#1240](paulmillr/chokidar#1240)). This is not an issue if you are using MacOS, though it may have undersirable side-effects on other platforms. Please raise an issue if you discover a platform-specific issue. BREAKING CHANGE: Potentially breaking changes for non-MacOS platforms.
Thank you for the response. Would you consider accepting a PR? |
Certainly. Personally I'd want to make Watchman easier to work in OSS and make contributions. |
Is there any performance / complexity reason for not supporting symlinks?
With the release of react-native, and the use of watchman in its packager, it's troubling that npm's (react-native's chosen package manager) endorsed method of developing local interdependent libraries with npm link is not supported, and having to commit to a remote repo and download on every change is obviously not ideal.
The text was updated successfully, but these errors were encountered: