Skip to content

Commit ed783d0

Browse files
committed
Update watcher rules
1 parent 6aab920 commit ed783d0

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

rescript

+15-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,14 @@ if (maybeSubcommand === "build" && process_argv.includes("-w")) {
239221
let webSocketHost = "localhost";
240222
let webSocketPort = 9999;
241223

224+
let resConfig = "rescript.json";
225+
let resConfigFile = path.join(cwd, resConfig);
226+
if (!fs.existsSync(resConfigFile)) {
227+
const bsConfig = "bsconfig.json";
228+
resConfig = bsConfig;
229+
resConfigFile = path.join(cwd, bsConfig);
230+
}
231+
242232
const sourcedirs = path.join("lib", "bs", ".sourcedirs.json");
243233

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

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")
357+
return (
358+
((fileName.endsWith(".res") ||
359+
fileName.endsWith(".resi") ||
360+
fileName.endsWith(".ml") ||
361+
fileName.endsWith(".mli")) &&
362+
!watchGenerated.includes(fileName)) ||
363+
fileName === resConfig
375364
);
376365
}
377366

0 commit comments

Comments
 (0)