@@ -60,6 +60,9 @@ export interface AngularCompilerPluginOptions {
60
60
mainPath ?: string ;
61
61
skipCodeGeneration ?: boolean ;
62
62
hostReplacementPaths ?: { [ path : string ] : string } ;
63
+ // TODO: remove singleFileIncludes for 2.0, this is just to support old projects that did not
64
+ // include 'polyfills.ts' in `tsconfig.spec.json'.
65
+ singleFileIncludes ?: string [ ] ;
63
66
i18nInFile ?: string ;
64
67
i18nInFormat ?: string ;
65
68
i18nOutFile ?: string ;
@@ -83,6 +86,7 @@ export class AngularCompilerPlugin implements Tapable {
83
86
// TS compilation.
84
87
private _compilerOptions : CompilerOptions ;
85
88
private _rootNames : string [ ] ;
89
+ private _singleFileIncludes : string [ ] = [ ] ;
86
90
private _program : ( ts . Program | Program ) ;
87
91
private _compilerHost : WebpackCompilerHost & CompilerHost ;
88
92
private _moduleResolutionCache : ts . ModuleResolutionCache ;
@@ -157,17 +161,19 @@ export class AngularCompilerPlugin implements Tapable {
157
161
basePath = path . resolve ( process . cwd ( ) , options . basePath ) ;
158
162
}
159
163
160
- // TODO: check if we can get this from readConfiguration
161
- this . _basePath = basePath ;
164
+ if ( options . singleFileIncludes !== undefined ) {
165
+ this . _singleFileIncludes . push ( ...options . singleFileIncludes ) ;
166
+ }
162
167
163
168
// Parse the tsconfig contents.
164
169
const config = readConfiguration ( this . _tsConfigPath ) ;
165
170
if ( config . errors && config . errors . length ) {
166
171
throw new Error ( formatDiagnostics ( config . errors ) ) ;
167
172
}
168
173
169
- this . _rootNames = config . rootNames ;
174
+ this . _rootNames = config . rootNames . concat ( ... this . _singleFileIncludes ) ;
170
175
this . _compilerOptions = config . options ;
176
+ this . _basePath = config . options . basePath ;
171
177
172
178
// Overwrite outDir so we can find generated files next to their .ts origin in compilerHost.
173
179
this . _compilerOptions . outDir = '' ;
@@ -295,7 +301,8 @@ export class AngularCompilerPlugin implements Tapable {
295
301
// Get the root files from the ts config.
296
302
// When a new root name (like a lazy route) is added, it won't be available from
297
303
// following imports on the existing files, so we need to get the new list of root files.
298
- this . _rootNames = readConfiguration ( this . _tsConfigPath ) . rootNames ;
304
+ const config = readConfiguration ( this . _tsConfigPath ) ;
305
+ this . _rootNames = config . rootNames . concat ( ...this . _singleFileIncludes ) ;
299
306
300
307
// Update the forked type checker with all changed compilation files.
301
308
// This includes templates, that also need to be reloaded on the type checker.
0 commit comments