@@ -25,6 +25,7 @@ export interface AotPluginOptions {
25
25
typeChecking ?: boolean ;
26
26
skipCodeGeneration ?: boolean ;
27
27
hostOverrideFileSystem ?: { [ path : string ] : string } ;
28
+ hostReplacementPaths ?: { [ path : string ] : string } ;
28
29
i18nFile ?: string ;
29
30
i18nFormat ?: string ;
30
31
locale ?: string ;
@@ -35,6 +36,8 @@ export interface AotPluginOptions {
35
36
36
37
37
38
export class AotPlugin implements Tapable {
39
+ private _options : AotPluginOptions ;
40
+
38
41
private _compilerOptions : ts . CompilerOptions ;
39
42
private _angularCompilerOptions : AngularCompilerOptions ;
40
43
private _program : ts . Program ;
@@ -62,9 +65,11 @@ export class AotPlugin implements Tapable {
62
65
private _firstRun = true ;
63
66
64
67
constructor ( options : AotPluginOptions ) {
65
- this . _setupOptions ( options ) ;
68
+ this . _options = Object . assign ( { } , options ) ;
69
+ this . _setupOptions ( this . _options ) ;
66
70
}
67
71
72
+ get options ( ) { return this . _options ; }
68
73
get basePath ( ) { return this . _basePath ; }
69
74
get compilation ( ) { return this . _compilation ; }
70
75
get compilerHost ( ) { return this . _compilerHost ; }
@@ -175,6 +180,14 @@ export class AotPlugin implements Tapable {
175
180
this . _compilerHost . writeFile ( filePath , options . hostOverrideFileSystem [ filePath ] , false ) ;
176
181
}
177
182
}
183
+ // Override some files in the FileSystem with paths from the actual file system.
184
+ if ( options . hasOwnProperty ( 'hostReplacementPaths' ) ) {
185
+ for ( const filePath of Object . keys ( options . hostReplacementPaths ) ) {
186
+ const replacementFilePath = options . hostReplacementPaths [ filePath ] ;
187
+ const content = this . _compilerHost . readFile ( replacementFilePath ) ;
188
+ this . _compilerHost . writeFile ( filePath , content , false ) ;
189
+ }
190
+ }
178
191
179
192
this . _program = ts . createProgram (
180
193
this . _rootFilePath , this . _compilerOptions , this . _compilerHost ) ;
@@ -193,8 +206,8 @@ export class AotPlugin implements Tapable {
193
206
194
207
// still no _entryModule? => try to resolve from mainPath
195
208
if ( ! this . _entryModule && options . mainPath ) {
196
- this . _entryModule = resolveEntryModuleFromMain ( options . mainPath , this . _compilerHost ,
197
- this . _program ) ;
209
+ const mainPath = path . resolve ( basePath , options . mainPath ) ;
210
+ this . _entryModule = resolveEntryModuleFromMain ( mainPath , this . _compilerHost , this . _program ) ;
198
211
}
199
212
200
213
if ( options . hasOwnProperty ( 'i18nFile' ) ) {
0 commit comments