From ed783d0321cee89918960fef0150cd44914db589 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Sat, 30 Sep 2023 17:28:49 +0300 Subject: [PATCH 1/4] Update watcher rules --- rescript | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/rescript b/rescript index a667e9a46c..7f55a3be07 100755 --- a/rescript +++ b/rescript @@ -22,24 +22,6 @@ process.env.BSB_PROJECT_ROOT = cwd; const isTtyError = process.stderr.isTTY; const isTtyStd = process.stdout.isTTY; -var bsConfig = "bsconfig.json" -var resConfig = "rescript.json"; -var resConfigFile = path.join(cwd, resConfig); -if (!fs.existsSync(resConfigFile)) { - resConfig = bsConfig; - resConfigFile = path.join(cwd, bsConfig); -} - -// If the project uses gentype and uses custom file extension -// via generatedFileExtension, ignore them in watch mode -var genTypeFileExtension = ".gen.tsx"; -if (fs.existsSync(resConfigFile)) { - var genTypeConfig = require(resConfigFile).gentypeconfig - if (genTypeConfig) { - genTypeFileExtension = genTypeConfig.generatedFileExtension; - } -} - let verbose = false; /** @@ -239,6 +221,14 @@ if (maybeSubcommand === "build" && process_argv.includes("-w")) { let webSocketHost = "localhost"; let webSocketPort = 9999; + let resConfig = "rescript.json"; + let resConfigFile = path.join(cwd, resConfig); + if (!fs.existsSync(resConfigFile)) { + const bsConfig = "bsconfig.json"; + resConfig = bsConfig; + resConfigFile = path.join(cwd, bsConfig); + } + const sourcedirs = path.join("lib", "bs", ".sourcedirs.json"); let LAST_BUILD_START = 0; @@ -364,14 +354,13 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`); // This could cause problems if source builds (generating js files in the same directory) are supported. if (!fileName) return true; - return !( - fileName === ".merlin" || - fileName.endsWith(".js") || - fileName.endsWith(".mjs") || - fileName.endsWith(".cjs") || - fileName.endsWith(genTypeFileExtension) || - watchGenerated.indexOf(fileName) >= 0 || - fileName.endsWith(".swp") + return ( + ((fileName.endsWith(".res") || + fileName.endsWith(".resi") || + fileName.endsWith(".ml") || + fileName.endsWith(".mli")) && + !watchGenerated.includes(fileName)) || + fileName === resConfig ); } From d6deab588622b71ec17e4dba00275ad091b4c29b Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Sat, 30 Sep 2023 17:43:16 +0300 Subject: [PATCH 2/4] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 592e177892..e715435dcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ # 11.0.0-rc.4 (Unreleased) +#### :boom: Breaking Change + +- Updated watcher rules to recompile only on `bsconfig.json`/`*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript-compiler/pull/6420 + #### :bug: Bug Fix - Fix issue with GenType and labelled arguments. https://github.com/rescript-lang/rescript-compiler/pull/6406 From e20ff549aa353253acc7c0b24362b80e93ad9b76 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Mon, 9 Oct 2023 22:24:49 +0300 Subject: [PATCH 3/4] Update changelog message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e715435dcb..da8c9a582d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ #### :boom: Breaking Change -- Updated watcher rules to recompile only on `bsconfig.json`/`*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript-compiler/pull/6420 +- Updated watcher rules to recompile only on config and `*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript-compiler/pull/6420 #### :bug: Bug Fix From 978618fccecf53c3b1c88c84d4f001b8cc262762 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Mon, 9 Oct 2023 22:31:24 +0300 Subject: [PATCH 4/4] Remove path.join cwd --- rescript | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rescript b/rescript index 7f55a3be07..23fe253b46 100755 --- a/rescript +++ b/rescript @@ -222,11 +222,8 @@ if (maybeSubcommand === "build" && process_argv.includes("-w")) { let webSocketPort = 9999; let resConfig = "rescript.json"; - let resConfigFile = path.join(cwd, resConfig); - if (!fs.existsSync(resConfigFile)) { - const bsConfig = "bsconfig.json"; - resConfig = bsConfig; - resConfigFile = path.join(cwd, bsConfig); + if (!fs.existsSync(resConfig)) { + resConfig = "bsconfig.json"; } const sourcedirs = path.join("lib", "bs", ".sourcedirs.json");