@@ -46,6 +46,7 @@ type IncrementallyCompiledFileInfo = {
46
46
/** Location of the original type file. */
47
47
originalTypeFileLocation : string ;
48
48
} ;
49
+ buildSystem : "bsb" | "rewatch" ;
49
50
/** Cache for build.ninja assets. */
50
51
buildNinja : {
51
52
/** When build.ninja was last modified. Used as a cache key. */
@@ -226,11 +227,13 @@ function getBscArgs(
226
227
return new Promise ( async ( resolve , _reject ) => {
227
228
function resolveResult ( result : Array < string > | RewatchCompilerArgs ) {
228
229
if ( stat != null && Array . isArray ( result ) ) {
230
+ entry . buildSystem = "bsb" ;
229
231
entry . buildNinja = {
230
232
fileMtime : stat . mtimeMs ,
231
233
rawExtracted : result ,
232
234
} ;
233
235
} else if ( ! Array . isArray ( result ) ) {
236
+ entry . buildSystem = "rewatch" ;
234
237
entry . buildRewatch = {
235
238
lastFile : entry . file . sourceFilePath ,
236
239
compilerArgs : result ,
@@ -459,6 +462,7 @@ function triggerIncrementalCompilationOfFile(
459
462
bscBinaryLocation,
460
463
incrementalFolderPath,
461
464
} ,
465
+ buildSystem : foundRewatchLockfileInProjectRoot ? "rewatch" : "bsb" ,
462
466
buildRewatch : null ,
463
467
buildNinja : null ,
464
468
compilation : null ,
@@ -545,15 +549,12 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
545
549
path . resolve ( entry . project . rootPath , c . compilerDirPartialPath , value )
546
550
) ;
547
551
} else {
552
+ // TODO: once ReScript v12 is out we can remove this check for `.`
548
553
if ( value === "." ) {
549
554
callArgs . push (
550
555
"-I" ,
551
556
path . resolve ( entry . project . rootPath , c . compilerOcamlDirPartialPath )
552
557
) ;
553
- } else if ( value . startsWith ( ".." ) && value . endsWith ( "ocaml" ) ) {
554
- // This should be the lib/ocaml folder of the project
555
- // This is a hack to support incremental compilation in monorepos
556
- callArgs . push ( "-I" , path . resolve ( entry . project . incrementalFolderPath , ".." , ".." , "ocaml" ) ) ;
557
558
} else {
558
559
callArgs . push ( "-I" , value ) ;
559
560
}
@@ -622,11 +623,15 @@ async function compileContents(
622
623
623
624
try {
624
625
fs . writeFileSync ( entry . file . incrementalFilePath , fileContent ) ;
625
-
626
+ let cwd = entry . buildSystem === "bsb" ? entry . project . rootPath : path . resolve ( entry . project . rootPath , c . compilerDirPartialPath )
627
+ if ( debug ( ) ) {
628
+ console . log ( `About to invoke bsc from \"${ cwd } \", used ${ entry . buildSystem } ` ) ;
629
+ console . log ( `${ entry . project . bscBinaryLocation } ${ callArgs . map ( c => `"${ c } "` ) . join ( " " ) } ` ) ;
630
+ }
626
631
const process = cp . execFile (
627
632
entry . project . bscBinaryLocation ,
628
633
callArgs ,
629
- { cwd : entry . project . rootPath } ,
634
+ { cwd } ,
630
635
async ( error , _stdout , stderr ) => {
631
636
if ( ! error ?. killed ) {
632
637
if ( debug ( ) )
0 commit comments