@@ -14,9 +14,8 @@ import {
1414import { Path , getSystemPath , join , normalize , resolve , virtualFs } from '@angular-devkit/core' ;
1515import * as fs from 'fs' ;
1616import { Observable } from 'rxjs/Observable' ;
17- import { concat as concatObservable } from 'rxjs/observable/concat' ;
18- import { empty } from 'rxjs/observable/empty' ;
19- import { ignoreElements , switchMap } from 'rxjs/operators' ;
17+ import { of } from 'rxjs/observable/of' ;
18+ import { concat , concatMap } from 'rxjs/operators' ;
2019import * as ts from 'typescript' ; // tslint:disable-line:no-implicit-dependencies
2120import * as webpack from 'webpack' ;
2221import {
@@ -123,11 +122,11 @@ export class BrowserBuilder implements Builder<BrowserBuilderOptions> {
123122 const root = this . context . workspace . root ;
124123 const projectRoot = resolve ( root , builderConfig . root ) ;
125124
126- return concatObservable (
127- options . deleteOutputPath
125+ return of ( null ) . pipe (
126+ concatMap ( ( ) => options . deleteOutputPath
128127 ? this . _deleteOutputDir ( root , normalize ( options . outputPath ) , this . context . host )
129- : empty < BuildEvent > ( ) ,
130- new Observable ( obs => {
128+ : of ( null ) ) ,
129+ concatMap ( ( ) => new Observable ( obs => {
131130 // Ensure Build Optimizer is only used with AOT.
132131 if ( options . buildOptimizer && ! options . aot ) {
133132 throw new Error ( 'The `--build-optimizer` option cannot be used without `--aot`.' ) ;
@@ -198,7 +197,7 @@ export class BrowserBuilder implements Builder<BrowserBuilderOptions> {
198197 }
199198 throw err ;
200199 }
201- } ) ,
200+ } ) ) ,
202201 ) ;
203202 }
204203
@@ -211,7 +210,7 @@ export class BrowserBuilder implements Builder<BrowserBuilderOptions> {
211210
212211 const host = new virtualFs . AliasHost ( this . context . host as virtualFs . Host < fs . Stats > ) ;
213212
214- options . fileReplacements . forEach ( ( { from, to} ) => {
213+ options . fileReplacements . forEach ( ( { from, to } ) => {
215214 host . aliases . set (
216215 join ( root , normalize ( from ) ) ,
217216 join ( root , normalize ( to ) ) ,
@@ -284,21 +283,18 @@ export class BrowserBuilder implements Builder<BrowserBuilderOptions> {
284283 return webpackMerge ( webpackConfigs ) ;
285284 }
286285
287- private _deleteOutputDir ( root : Path , outputPath : Path , host : virtualFs . Host ) : Observable < void > {
286+ private _deleteOutputDir ( root : Path , outputPath : Path , host : virtualFs . Host ) {
288287 const resolvedOutputPath = resolve ( root , outputPath ) ;
289288 if ( resolvedOutputPath === root ) {
290289 throw new Error ( 'Output path MUST not be project root directory!' ) ;
291290 }
292291
293292 return host . exists ( resolvedOutputPath ) . pipe (
294- switchMap ( exists => {
295- if ( exists ) {
296- return host . delete ( resolvedOutputPath ) ;
297- } else {
298- return empty < void > ( ) ;
299- }
300- } ) ,
301- ignoreElements ( ) ,
293+ concatMap ( exists => exists
294+ // TODO: remove this concat once host ops emit an event.
295+ ? host . delete ( resolvedOutputPath ) . pipe ( concat ( of ( null ) ) )
296+ // ? of(null)
297+ : of ( null ) ) ,
302298 ) ;
303299 }
304300}
0 commit comments