File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
packages/ngtools/webpack/src Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -602,8 +602,13 @@ export class AngularCompilerPlugin {
602602 private _updateForkedTypeChecker ( rootNames : string [ ] , changedCompilationFiles : string [ ] ) {
603603 if ( this . _typeCheckerProcess ) {
604604 if ( ! this . _forkedTypeCheckerInitialized ) {
605+ let hostReplacementPaths = { } ;
606+ if ( this . _options . hostReplacementPaths
607+ && typeof this . _options . hostReplacementPaths != 'function' ) {
608+ hostReplacementPaths = this . _options . hostReplacementPaths ;
609+ }
605610 this . _typeCheckerProcess . send ( new InitMessage ( this . _compilerOptions , this . _basePath ,
606- this . _JitMode , this . _rootNames ) ) ;
611+ this . _JitMode , this . _rootNames , hostReplacementPaths ) ) ;
607612 this . _forkedTypeCheckerInitialized = true ;
608613 }
609614 this . _typeCheckerProcess . send ( new UpdateMessage ( rootNames , changedCompilationFiles ) ) ;
Original file line number Diff line number Diff line change 55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8+ import { normalize , resolve , virtualFs } from '@angular-devkit/core' ;
89import { NodeJsSyncHost } from '@angular-devkit/core/node' ;
910import {
1011 CompilerHost ,
@@ -33,12 +34,25 @@ export class TypeChecker {
3334 _basePath : string ,
3435 private _JitMode : boolean ,
3536 private _rootNames : string [ ] ,
37+ hostReplacementPaths : { [ path : string ] : string } ,
3638 ) {
3739 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+
3852 const compilerHost = new WebpackCompilerHost (
3953 _compilerOptions ,
4054 _basePath ,
41- new NodeJsSyncHost ( ) ,
55+ host ,
4256 ) ;
4357 // We don't set a async resource loader on the compiler host because we only support
4458 // 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) {
3434 initMessage . basePath ,
3535 initMessage . jitMode ,
3636 initMessage . rootNames ,
37+ initMessage . hostReplacementPaths ,
3738 ) ;
3839 break ;
3940 case MESSAGE_KIND . Update :
You can’t perform that action at this time.
0 commit comments