File tree 3 files changed +22
-2
lines changed
3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -602,8 +602,13 @@ export class AngularCompilerPlugin {
602
602
private _updateForkedTypeChecker ( rootNames : string [ ] , changedCompilationFiles : string [ ] ) {
603
603
if ( this . _typeCheckerProcess ) {
604
604
if ( ! this . _forkedTypeCheckerInitialized ) {
605
+ let hostReplacementPaths = { } ;
606
+ if ( this . _options . hostReplacementPaths
607
+ && typeof this . _options . hostReplacementPaths != 'function' ) {
608
+ hostReplacementPaths = this . _options . hostReplacementPaths ;
609
+ }
605
610
this . _typeCheckerProcess . send ( new InitMessage ( this . _compilerOptions , this . _basePath ,
606
- this . _JitMode , this . _rootNames ) ) ;
611
+ this . _JitMode , this . _rootNames , hostReplacementPaths ) ) ;
607
612
this . _forkedTypeCheckerInitialized = true ;
608
613
}
609
614
this . _typeCheckerProcess . send ( new UpdateMessage ( rootNames , changedCompilationFiles ) ) ;
Original file line number Diff line number Diff line change 5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
+ import { normalize , resolve , virtualFs } from '@angular-devkit/core' ;
8
9
import { NodeJsSyncHost } from '@angular-devkit/core/node' ;
9
10
import {
10
11
CompilerHost ,
@@ -33,12 +34,25 @@ export class TypeChecker {
33
34
_basePath : string ,
34
35
private _JitMode : boolean ,
35
36
private _rootNames : string [ ] ,
37
+ hostReplacementPaths : { [ path : string ] : string } ,
36
38
) {
37
39
time ( 'TypeChecker.constructor' ) ;
40
+ const host = new virtualFs . AliasHost ( new NodeJsSyncHost ( ) ) ;
41
+
42
+ // Add file replacements.
43
+ for ( const from in hostReplacementPaths ) {
44
+ const normalizedFrom = resolve ( normalize ( _basePath ) , normalize ( from ) ) ;
45
+ const normalizedWith = resolve (
46
+ normalize ( _basePath ) ,
47
+ normalize ( hostReplacementPaths [ from ] ) ,
48
+ ) ;
49
+ host . aliases . set ( normalizedFrom , normalizedWith ) ;
50
+ }
51
+
38
52
const compilerHost = new WebpackCompilerHost (
39
53
_compilerOptions ,
40
54
_basePath ,
41
- new NodeJsSyncHost ( ) ,
55
+ host ,
42
56
) ;
43
57
// We don't set a async resource loader on the compiler host because we only support
44
58
// html templates, which are the only ones that can throw errors, and those can be loaded
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ if (process.argv.indexOf(AUTO_START_ARG) >= 0) {
34
34
initMessage . basePath ,
35
35
initMessage . jitMode ,
36
36
initMessage . rootNames ,
37
+ initMessage . hostReplacementPaths ,
37
38
) ;
38
39
break ;
39
40
case MESSAGE_KIND . Update :
You can’t perform that action at this time.
0 commit comments