Back to News for Developers

ELI5: Watchman - Watching for Changes to Build Faster

In this post, we talk about a project called Watchman, a file watching service. If you would like to watch a video about Watchman, go to the Facebook Open Source YouTube channel.

Why Watchman?

Web development has changed dramatically in the past decade. Let's consider what goes into developing and deploying a web app today. After deploying your changes, your web app needs to rebuild itself. The build process usually involves mapping routes and file paths, traversing JavaScript and CSS sources, and handling hundreds, even sometimes thousands, of node packages. It would take a very long time for a large web app like Facebook to rebuild its site from scratch, especially over and over again. And besides, why would you want to rebuild the entire site if you only made changes to a handful of files? Watchman allows developers to focus on managing the files they worked on in the web app development process. This approach is also known as an incremental build.

Watchman is a file watching service, with clients for a command line, NodeJS and more. It records any changes and triggers assigned actions. In the example with the Facebook app, Watchman would have made sure that only files that are changed or affected by our developers get updated. We previously shared how this service reduced build time by 60% in some cases!

Beyond the build system, Watchman has been updated to support other use cases. It can log changes, trigger test suites, transform files and more. Watchman was also updated to support a wide range of operating systems, including Windows.

Where is it used?

Watchman was first open sourced by Facebook in 2013. Ever since then, Watchman has been used daily by our developers at Facebook. It was also integrated with many other open source projects like React Native and Buck.

Where can I learn more?

To learn more about Watchman, visit their website. The project has an excellent starter and advanced documentation. The project has an active community chat on the Freenode and StackOverflow. If you were to encounter an issue, there is also a troubleshooting page available on the project’s site.

If you have any thoughts or questions about Watchman, let us know on our YouTube channel, or tweet at us.

About the ELI5 series

In a series of short videos (~1 min in length), one of our Developer Advocates on the Facebook Open Source team explains a Facebook open source project in a way that is easy to understand and use.

We will write an accompanying blog post (like the one you're reading right now) for each of these videos, which you can find on our YouTube channel.

To learn more about Facebook Open Source, visit our open source site, subscribe to our YouTube channel, or follow us on Twitter and Facebook.

Interested in working with open source at Facebook? Check out our open source-related job postings on our career page by taking this quick survey.