what is the use of watchman for react native?
Asked Answered
L

1

35

Can anybody describe clearly what the use of watchman available in npm library?

----Details I found---

npm - npm is the largest NodeJS package manager

NodeJS - Server-side Javascript runtime

Watchman - Simple utility that watches files/directories for changes and performs an action when they change(This is not clear for me/ what it deoes?/is there any example?)

Legal answered 14/2, 2017 at 20:40 Comment(0)
C
40

React Native uses watchman to detect when you've made code changes and then automatically build and push the update to your device without you needing to manually refresh it.

https://facebook.github.io/watchman/ is the home page for the watchman used by React Native. Note that it is different and completely unrelated to https://www.npmjs.com/package/watchman which has some similar functionality.

The Facebook watchman service is designed to scale to very large filesystem trees and to aggregate watching resources across multiple projects. This allows us to re-use those system resources across React Native, Nuclide, Buck and Mercurial and keep them all running faster than they could without the aid of watchman.

You can read more about watchman in this blog post from when we released it.

Cyclostyle answered 15/2, 2017 at 7:6 Comment(8)
did you mean Live Reloading??Diploblastic
somehow I always had problems that saving a file in vim was not picked up by watchman on MacOS. Now I installed a new machine and forgot to add watchman...and it works smoother then ever before! is watchman needed at all? so far everything works nicely...remote debugging, live reload.Steep
Is there a place in facebook's source where I can see how facebook implements watchman in react-native? I've been searching so that I can find a solution to this SO question and am needing a little help along the way. Wez Furlong would you happen to know?Gunstock
@JayGee: I'd suggest asking the React Native folks as I'm only familiar with watchman itself.Cyclostyle
Ok. Will do. I would like to look at my working RN project and see what happens when a fast refresh / reload occurs. How can I monitor watchman and see what triggers it hits and what actions get taken?Gunstock
As I understand watchman watches for javascript changes and rebuild main.jsbundle file if needed. It somehow works with metro bundler. Documentation unclear.Schild
Does anyone know what watchman listens for? In a react-native project, I’m trying to fake a change in my project folder with a node script to trigger a bundle refresh. I’m thinking something like a “touch -m filename.js” to change a timestamp on the file, but so far I’ve been unsuccessfulCollinear
I've been using React Native, Metro, iOS simulator and VSCode without using Watchman, on my macOS machine, and hot reloading already works. What extra does watchman give me, if anything?Discant

© 2022 - 2024 — McMap. All rights reserved.