@@ -276,6 +276,81 @@ export class someClass2 { }`);
276
276
verifyWatches ( host ) ;
277
277
} ) ;
278
278
279
+ it ( "when referenced using prepend, builds referencing project even for non local change" , ( ) => {
280
+ const coreTsConfig : File = {
281
+ path : core [ 0 ] . path ,
282
+ content : JSON . stringify ( {
283
+ compilerOptions : { composite : true , declaration : true , outFile : "index.js" }
284
+ } )
285
+ } ;
286
+ const coreIndex : File = {
287
+ path : core [ 1 ] . path ,
288
+ content : `function foo() { return 10; }`
289
+ } ;
290
+ const logicTsConfig : File = {
291
+ path : logic [ 0 ] . path ,
292
+ content : JSON . stringify ( {
293
+ compilerOptions : { composite : true , declaration : true , outFile : "index.js" } ,
294
+ references : [ { path : "../core" , prepend : true } ]
295
+ } )
296
+ } ;
297
+ const logicIndex : File = {
298
+ path : logic [ 1 ] . path ,
299
+ content : `function bar() { return foo() + 1 };`
300
+ } ;
301
+
302
+ const projectFiles = [ coreTsConfig , coreIndex , logicTsConfig , logicIndex ] ;
303
+ const host = createWatchedSystem ( [ libFile , ...projectFiles ] , { currentDirectory : projectsLocation } ) ;
304
+ createSolutionBuilderWithWatch ( host , [ `${ project } /${ SubProject . logic } ` ] ) ;
305
+ verifyWatches ( ) ;
306
+ checkOutputErrorsInitial ( host , emptyArray ) ;
307
+ const outputFileStamps = getOutputFileStamps ( ) ;
308
+ for ( const stamp of outputFileStamps ) {
309
+ assert . isDefined ( stamp [ 1 ] , `${ stamp [ 0 ] } expected to be present` ) ;
310
+ }
311
+
312
+ // Make non local change
313
+ verifyChangeInCore ( `${ coreIndex . content }
314
+ function myFunc() { return 10; }` ) ;
315
+
316
+ // Make local change to function bar
317
+ verifyChangeInCore ( `${ coreIndex . content }
318
+ function myFunc() { return 100; }` ) ;
319
+
320
+ function verifyChangeInCore ( content : string ) {
321
+ const outputFileStamps = getOutputFileStamps ( ) ;
322
+ host . writeFile ( coreIndex . path , content ) ;
323
+
324
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds core
325
+ const changedCore = getOutputFileStamps ( ) ;
326
+ verifyChangedFiles ( changedCore , outputFileStamps , [
327
+ ...getOutputFileNames ( SubProject . core , "index" )
328
+ ] ) ;
329
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds logic
330
+ const changedLogic = getOutputFileStamps ( ) ;
331
+ verifyChangedFiles ( changedLogic , changedCore , [
332
+ ...getOutputFileNames ( SubProject . logic , "index" )
333
+ ] ) ;
334
+ host . checkTimeoutQueueLength ( 0 ) ;
335
+ checkOutputErrorsIncremental ( host , emptyArray ) ;
336
+ verifyWatches ( ) ;
337
+ }
338
+
339
+ function getOutputFileStamps ( ) : OutputFileStamp [ ] {
340
+ const result = [
341
+ ...getOutputStamps ( host , SubProject . core , "index" ) ,
342
+ ...getOutputStamps ( host , SubProject . logic , "index" ) ,
343
+ ] ;
344
+ return result ;
345
+ }
346
+
347
+ function verifyWatches ( ) {
348
+ checkWatchedFiles ( host , projectFiles . map ( f => f . path ) ) ;
349
+ checkWatchedDirectories ( host , emptyArray , /*recursive*/ false ) ;
350
+ checkWatchedDirectories ( host , [ projectPath ( SubProject . core ) , projectPath ( SubProject . logic ) ] , /*recursive*/ true ) ;
351
+ }
352
+ } ) ;
353
+
279
354
// TODO: write tests reporting errors but that will have more involved work since file
280
355
} ) ;
281
356
}
0 commit comments