Skip to content

Commit 79cea54

Browse files
authored
Update watcher rules (#6420)
* Update watcher rules * Update changelog * Update changelog message * Remove path.join cwd
1 parent 6aab920 commit 79cea54

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 11.0.0-rc.4 (Unreleased)
1414

15+
#### :boom: Breaking Change
16+
17+
- 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
18+
1519
#### :bug: Bug Fix
1620

1721
- Fix issue with GenType and labelled arguments. https://github.com/rescript-lang/rescript-compiler/pull/6406

rescript

+12-26
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ process.env.BSB_PROJECT_ROOT = cwd;
2222
const isTtyError = process.stderr.isTTY;
2323
const isTtyStd = process.stdout.isTTY;
2424

25-
var bsConfig = "bsconfig.json"
26-
var resConfig = "rescript.json";
27-
var resConfigFile = path.join(cwd, resConfig);
28-
if (!fs.existsSync(resConfigFile)) {
29-
resConfig = bsConfig;
30-
resConfigFile = path.join(cwd, bsConfig);
31-
}
32-
33-
// If the project uses gentype and uses custom file extension
34-
// via generatedFileExtension, ignore them in watch mode
35-
var genTypeFileExtension = ".gen.tsx";
36-
if (fs.existsSync(resConfigFile)) {
37-
var genTypeConfig = require(resConfigFile).gentypeconfig
38-
if (genTypeConfig) {
39-
genTypeFileExtension = genTypeConfig.generatedFileExtension;
40-
}
41-
}
42-
4325
let verbose = false;
4426

4527
/**
@@ -239,6 +221,11 @@ if (maybeSubcommand === "build" && process_argv.includes("-w")) {
239221
let webSocketHost = "localhost";
240222
let webSocketPort = 9999;
241223

224+
let resConfig = "rescript.json";
225+
if (!fs.existsSync(resConfig)) {
226+
resConfig = "bsconfig.json";
227+
}
228+
242229
const sourcedirs = path.join("lib", "bs", ".sourcedirs.json");
243230

244231
let LAST_BUILD_START = 0;
@@ -364,14 +351,13 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
364351
// This could cause problems if source builds (generating js files in the same directory) are supported.
365352
if (!fileName) return true;
366353

367-
return !(
368-
fileName === ".merlin" ||
369-
fileName.endsWith(".js") ||
370-
fileName.endsWith(".mjs") ||
371-
fileName.endsWith(".cjs") ||
372-
fileName.endsWith(genTypeFileExtension) ||
373-
watchGenerated.indexOf(fileName) >= 0 ||
374-
fileName.endsWith(".swp")
354+
return (
355+
((fileName.endsWith(".res") ||
356+
fileName.endsWith(".resi") ||
357+
fileName.endsWith(".ml") ||
358+
fileName.endsWith(".mli")) &&
359+
!watchGenerated.includes(fileName)) ||
360+
fileName === resConfig
375361
);
376362
}
377363

0 commit comments

Comments
 (0)