@@ -23,6 +23,18 @@ var ProjectCompiler = (function () {
2323 this . project . output . finish ( reporter_1 . emptyCompilationResult ( ) ) ;
2424 return ;
2525 }
26+ var root = this . project . input . commonBasePath ;
27+ var rootFilenames = this . project . input . getFileNames ( true ) ;
28+ if ( ! this . project . singleOutput ) {
29+ // Add an empty file under the root.
30+ // This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
31+ // We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
32+ // directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
33+ // The empty file is filtered out later on.
34+ var emptyFileName = path . join ( this . project . options [ 'rootDir' ] ? path . resolve ( this . project . projectDirectory , this . project . options [ 'rootDir' ] ) : root , '________________empty.ts' ) ;
35+ rootFilenames . push ( emptyFileName ) ;
36+ this . project . input . addContent ( emptyFileName , '' ) ;
37+ }
2638 if ( ! this . project . input . isChanged ( true ) ) {
2739 // Re-use old output
2840 var old = this . project . previousOutput ;
@@ -42,24 +54,12 @@ var ProjectCompiler = (function () {
4254 this . project . output . finish ( old . results ) ;
4355 return ;
4456 }
45- var root = this . project . input . commonBasePath ;
4657 this . project . options . sourceRoot = root ;
4758 this . host = new host_1 . Host ( this . project . typescript , this . project . currentDirectory , this . project . input , ! this . project . noExternalResolve , this . project . options . target >= ts . ScriptTarget . ES6 ? 'lib.es6.d.ts' : 'lib.d.ts' ) ;
48- var rootFilenames = this . project . input . getFileNames ( true ) ;
4959 if ( this . project . filterSettings !== undefined ) {
5060 var filter_2 = new filter_1 . Filter ( this . project , this . project . filterSettings ) ;
5161 rootFilenames = rootFilenames . filter ( function ( fileName ) { return filter_2 . match ( fileName ) ; } ) ;
5262 }
53- if ( ! this . project . singleOutput ) {
54- // Add an empty file under the root.
55- // This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
56- // We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
57- // directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
58- // The empty file is filtered out later on.
59- var emptyFileName = path . join ( this . project . options [ 'rootDir' ] ? path . resolve ( this . project . projectDirectory , this . project . options [ 'rootDir' ] ) : root , '________________empty.ts' ) ;
60- rootFilenames . push ( emptyFileName ) ;
61- this . project . input . addContent ( emptyFileName , '' ) ;
62- }
6363 // Creating a program to compile the sources
6464 // We cast to `tsApi.CreateProgram` so we can pass the old program as an extra argument.
6565 // TS 1.6+ will try to reuse program structure (if possible)
0 commit comments