From dee21c9f9bd5aff3bd6b8e336a7b333a48dcb654 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 6 Jul 2025 15:59:27 +0200 Subject: [PATCH 1/3] Remove outdated rewatch README file --- rewatch/README.md | 134 ---------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 rewatch/README.md diff --git a/rewatch/README.md b/rewatch/README.md deleted file mode 100644 index 665ebc7df1..0000000000 --- a/rewatch/README.md +++ /dev/null @@ -1,134 +0,0 @@ -# Rewatch - -## [![Release](https://github.com/rolandpeelen/rewatch/actions/workflows/build.yml/badge.svg?branch=master&event=release)](https://github.com/rolandpeelen/rewatch/actions/workflows/build.yml) - -# Info - -Rewatch is an alternative build system for the [Rescript Compiler](https://rescript-lang.org/) (which uses a combination of Ninja, OCaml and a Node.js script). It strives to deliver consistent and faster builds in monorepo setups. Bsb doesn't support a watch-mode in a monorepo setup, and when setting up a watcher that runs a global incremental compile it's consistent but very inefficient and thus slow. - -We couldn't find a way to improve this without re-architecting the whole build system. The benefit of having a specialized build system is that it's possible to completely tailor it to ReScript and not being dependent of the constraints of a generic build system like Ninja. This allowed us to have significant performance improvements even in non-monorepo setups (30% to 3x improvements reported). - -# Project Status - -This project should be considered in beta status. We run it in production at [Walnut](https://github.com/teamwalnut/). We're open to PR's and other contributions to make it 100% stable in the ReScript toolchain. - -# Usage - - 1. Install the package - - ``` - yarn add @rolandpeelen/rewatch - ``` - - 2. Build / Clean / Watch - - ``` - yarn rewatch build - ``` - - ``` - yarn rewatch clean - ``` - - ``` - yarn rewatch watch - ``` - - You can pass in the folder as the second argument where the 'root' `bsconfig.json` lives. If you encounter a 'stale build error', either directly, or after a while, a `clean` may be needed to clean up some old compiler assets. - -## Full Options - -Find this output by running `yarn rewatch --help`. - -``` -Rewatch is an alternative build system for the Rescript Compiler bsb (which uses Ninja internally). It strives to deliver consistent and faster builds in monorepo setups with multiple packages, where the default build system fails to pick up changed interfaces across multiple packages - -Usage: rewatch [OPTIONS] [FOLDER] - rewatch - -Commands: - build Build using Rewatch - watch Build, then start a watcher - clean Clean the build artifacts - format Alias to `legacy format` - dump Alias to `legacy dump` - compiler-args This prints the compiler arguments. It expects the path to a rescript file (.res or .resi) - legacy Use the legacy build system - help Print this message or the help of the given subcommand(s) - -Arguments: - [FOLDER] - The relative path to where the main rescript.json resides. IE - the root of your project - - [default: .] - -Options: - -v, --verbose... - Increase logging verbosity - - -q, --quiet... - Decrease logging verbosity - - -f, --filter - Filter files by regex - - Filter allows for a regex to be supplied which will filter the files to be compiled. For instance, to filter out test files for compilation while doing feature work. - - -a, --after-build - Action after build - - This allows one to pass an additional command to the watcher, which allows it to run when finished. For instance, to play a sound when done compiling, or to run a test suite. NOTE - You may need to add '--color=always' to your subcommand in case you want to output color as well - - -c, --create-sourcedirs [] - Create source_dirs.json - - This creates a source_dirs.json file at the root of the monorepo, which is needed when you want to use Reanalyze - - [default: false] - [possible values: true, false] - - --dev [] - Build development dependencies - - This is the flag to also compile development dependencies It's important to know that we currently do not discern between project src, and dependencies. So enabling this flag will enable building _all_ development dependencies of _all_ packages - - [default: false] - [possible values: true, false] - - -n, --no-timing [] - Disable timing on the output - - [default: false] - [possible values: true, false] - - -s, --snapshot-output [] - simple output for snapshot testing - - [default: false] - [possible values: true, false] - - --bsc-path - Custom path to bsc - - -h, --help - Print help (see a summary with '-h') - - -V, --version - Print version -``` - -# Contributing - - Pre-requisites: - - - [Rust](https://rustup.rs/) - - [NodeJS](https://nodejs.org/en/) - For running testscripts only - - [Yarn](https://yarnpkg.com/) or [Npm](https://www.npmjs.com/) - Npm probably comes with your node installation - - 1. `cd testrepo && yarn` (install dependencies for submodule) - 2. `cargo run` - - Running tests: - - 1. `cargo build --release` - 2. `./tests/suite.sh` From 4d73caa9687122f8f21c19f916edb442fc2b88f5 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 6 Jul 2025 16:02:01 +0200 Subject: [PATCH 2/3] rewatch.lock -> rescript.lock --- rewatch/src/lock.rs | 2 +- rewatch/src/watcher.rs | 5 +++-- rewatch/tests/lock.sh | 2 +- rewatch/tests/watch.sh | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rewatch/src/lock.rs b/rewatch/src/lock.rs index 9eca7ed604..8068a21ca3 100644 --- a/rewatch/src/lock.rs +++ b/rewatch/src/lock.rs @@ -9,7 +9,7 @@ use sysinfo::{PidExt, System, SystemExt}; * that's running, when trying to aquire a lock, it checks wether that process is still running. If * not, it rewrites the lockfile to have its own PID instead. */ -pub static LOCKFILE: &str = "rewatch.lock"; +pub static LOCKFILE: &str = "rescript.lock"; pub enum Error { Locked(u32), diff --git a/rewatch/src/watcher.rs b/rewatch/src/watcher.rs index 9151028937..e95616aabf 100644 --- a/rewatch/src/watcher.rs +++ b/rewatch/src/watcher.rs @@ -10,6 +10,7 @@ use crate::queue::*; use futures_timer::Delay; use notify::event::ModifyKind; use notify::{Config, Error, Event, EventKind, RecommendedWatcher, RecursiveMode, Watcher}; +use crate::lock::LOCKFILE; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::Mutex; @@ -109,8 +110,8 @@ async fn async_watch( } for event in events { - // if there is a file named rewatch.lock in the events path, we can quit the watcher - if let Some(_) = event.paths.iter().find(|path| path.ends_with("rewatch.lock")) { + // if there is a file named rescript.lock in the events path, we can quit the watcher + if let Some(_) = event.paths.iter().find(|path| path.ends_with(LOCKFILE)) { match event.kind { EventKind::Remove(_) => { if show_progress { diff --git a/rewatch/tests/lock.sh b/rewatch/tests/lock.sh index edfa3f01b0..982622965a 100755 --- a/rewatch/tests/lock.sh +++ b/rewatch/tests/lock.sh @@ -17,7 +17,7 @@ fi exit_watcher() { # kill watcher by removing lock file - rm lib/rewatch.lock + rm lib/rescript.lock } rewatch_bg watch > /dev/null 2>&1 & diff --git a/rewatch/tests/watch.sh b/rewatch/tests/watch.sh index 7f89837bfc..314d74dc83 100755 --- a/rewatch/tests/watch.sh +++ b/rewatch/tests/watch.sh @@ -15,7 +15,7 @@ fi exit_watcher() { # kill watcher by removing lock file - rm lib/rewatch.lock + rm lib/rescript.lock } rewatch_bg watch > /dev/null 2>&1 & From ff06257c5ee6d5f884a5dabec3e6f523b7fffba2 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 6 Jul 2025 16:11:19 +0200 Subject: [PATCH 3/3] Remove "rewatch" from wording in message texts --- rewatch/src/cli.rs | 6 ++---- rewatch/src/lock.rs | 2 +- rewatch/src/main.rs | 2 +- rewatch/tests/lock.sh | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rewatch/src/cli.rs b/rewatch/src/cli.rs index c15ca4ad79..d588c1243c 100644 --- a/rewatch/src/cli.rs +++ b/rewatch/src/cli.rs @@ -3,9 +3,7 @@ use std::{ffi::OsString, ops::Deref}; use clap::{Args, Parser, Subcommand}; use clap_verbosity_flag::InfoLevel; -/// Rewatch is an alternative build system for the Rescript Compiler bsb (which uses Ninja internally). It strives -/// to deliver consistent and faster builds in monorepo setups with multiple packages, where the -/// default build system fails to pick up changed interfaces across multiple packages. +/// ReScript - Fast, Simple, Fully Typed JavaScript from the Future #[derive(Parser, Debug)] #[command(version)] #[command(args_conflicts_with_subcommands = true)] @@ -147,7 +145,7 @@ pub struct WatchArgs { #[derive(Subcommand, Clone, Debug)] pub enum Command { - /// Build using Rewatch + /// Build the project Build(BuildArgs), /// Build, then start a watcher Watch(WatchArgs), diff --git a/rewatch/src/lock.rs b/rewatch/src/lock.rs index 8068a21ca3..c0c3061abd 100644 --- a/rewatch/src/lock.rs +++ b/rewatch/src/lock.rs @@ -21,7 +21,7 @@ pub enum Error { impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { let msg = match self { - Error::Locked(pid) => format!("Rewatch is already running. The process ID (PID) is {}", pid), + Error::Locked(pid) => format!("A ReScript build is already running. The process ID (PID) is {}", pid), Error::ParsingLockfile(e) => format!( "Could not parse lockfile: \n {} \n (try removing it and running the command again)", e diff --git a/rewatch/src/main.rs b/rewatch/src/main.rs index 3cd1c5d084..211d60ae96 100644 --- a/rewatch/src/main.rs +++ b/rewatch/src/main.rs @@ -128,7 +128,7 @@ fn main() -> Result<()> { fn get_lock(folder: &str) -> lock::Lock { match lock::get(folder) { lock::Lock::Error(error) => { - println!("Could not start Rewatch: {error}"); + println!("Could not start ReScript build: {error}"); std::process::exit(1); } acquired_lock => acquired_lock, diff --git a/rewatch/tests/lock.sh b/rewatch/tests/lock.sh index 982622965a..9e56060340 100755 --- a/rewatch/tests/lock.sh +++ b/rewatch/tests/lock.sh @@ -25,7 +25,7 @@ success "Watcher Started" sleep 2 -if rewatch build | grep 'Could not start Rewatch:' &> /dev/null; +if rewatch build | grep 'Could not start ReScript build:' &> /dev/null; then success "Lock is correctly set" exit_watcher @@ -43,7 +43,7 @@ success "Watcher Started" sleep 2 -if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null; +if cat tmp.txt | grep 'Could not start ReScript build:' &> /dev/null; then error "Lock not removed correctly" exit_watcher