@@ -42,6 +42,19 @@ export class ProjectCompiler implements ICompiler {
42
42
return ;
43
43
}
44
44
45
+ let root = this . project . input . commonBasePath ;
46
+ let rootFilenames : string [ ] = this . project . input . getFileNames ( true ) ;
47
+ if ( ! this . project . singleOutput ) {
48
+ // Add an empty file under the root.
49
+ // This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
50
+ // We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
51
+ // directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
52
+ // The empty file is filtered out later on.
53
+ let emptyFileName = path . join ( this . project . options [ 'rootDir' ] ? path . resolve ( this . project . projectDirectory , this . project . options [ 'rootDir' ] ) : root , '________________empty.ts' ) ;
54
+ rootFilenames . push ( emptyFileName ) ;
55
+ this . project . input . addContent ( emptyFileName , '' ) ;
56
+ }
57
+
45
58
if ( ! this . project . input . isChanged ( true ) ) {
46
59
// Re-use old output
47
60
const old = this . project . previousOutput ;
@@ -64,7 +77,6 @@ export class ProjectCompiler implements ICompiler {
64
77
return ;
65
78
}
66
79
67
- let root = this . project . input . commonBasePath ;
68
80
this . project . options . sourceRoot = root ;
69
81
70
82
this . host = new Host (
@@ -75,24 +87,11 @@ export class ProjectCompiler implements ICompiler {
75
87
this . project . options . target >= ts . ScriptTarget . ES6 ? 'lib.es6.d.ts' : 'lib.d.ts'
76
88
) ;
77
89
78
- let rootFilenames : string [ ] = this . project . input . getFileNames ( true ) ;
79
-
80
90
if ( this . project . filterSettings !== undefined ) {
81
91
let filter = new Filter ( this . project , this . project . filterSettings ) ;
82
92
rootFilenames = rootFilenames . filter ( ( fileName ) => filter . match ( fileName ) ) ;
83
93
}
84
94
85
- if ( ! this . project . singleOutput ) {
86
- // Add an empty file under the root.
87
- // This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
88
- // We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
89
- // directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
90
- // The empty file is filtered out later on.
91
- let emptyFileName = path . join ( this . project . options [ 'rootDir' ] ? path . resolve ( this . project . projectDirectory , this . project . options [ 'rootDir' ] ) : root , '________________empty.ts' ) ;
92
- rootFilenames . push ( emptyFileName ) ;
93
- this . project . input . addContent ( emptyFileName , '' ) ;
94
- }
95
-
96
95
// Creating a program to compile the sources
97
96
// We cast to `tsApi.CreateProgram` so we can pass the old program as an extra argument.
98
97
// TS 1.6+ will try to reuse program structure (if possible)
0 commit comments