1
- import { extname } from 'path' ;
1
+ import { extname , join } from 'path' ;
2
2
import { Logger } from './logger/logger' ;
3
3
import { fillConfigDefaults , getUserConfigFile , replacePathVars } from './util/config' ;
4
4
import * as Constants from './util/constants' ;
5
5
import { BuildError } from './util/errors' ;
6
- import { getBooleanPropertyValue , webpackStatsToDependencyMap , printDependencyMap } from './util/helpers' ;
6
+ import { getBooleanPropertyValue , webpackStatsToDependencyMap , printDependencyMap , unlinkAsync } from './util/helpers' ;
7
7
import { BuildContext , TaskInfo } from './util/interfaces' ;
8
8
import { runWebpackFullBuild , WebpackConfig } from './webpack' ;
9
9
import { purgeDecorators } from './optimization/decorators' ;
@@ -23,17 +23,24 @@ export function optimization(context: BuildContext, configFile: string) {
23
23
24
24
function optimizationWorker ( context : BuildContext , configFile : string ) {
25
25
const webpackConfig = getConfig ( context , configFile ) ;
26
+ let dependencyMap : Map < string , Set < string > > = null ;
26
27
return runWebpackFullBuild ( webpackConfig ) . then ( ( stats : any ) => {
27
- const dependencyMap = webpackStatsToDependencyMap ( context , stats ) ;
28
+ dependencyMap = webpackStatsToDependencyMap ( context , stats ) ;
28
29
if ( getBooleanPropertyValue ( Constants . ENV_PRINT_ORIGINAL_DEPENDENCY_TREE ) ) {
29
30
Logger . debug ( 'Original Dependency Map Start' ) ;
30
31
printDependencyMap ( dependencyMap ) ;
31
32
Logger . debug ( 'Original Dependency Map End' ) ;
32
33
}
34
+ return deleteOptimizationJsFile ( join ( webpackConfig . output . path , webpackConfig . output . filename ) ) ;
35
+ } ) . then ( ( ) => {
33
36
return doOptimizations ( context , dependencyMap ) ;
34
37
} ) ;
35
38
}
36
39
40
+ export function deleteOptimizationJsFile ( fileToDelete : string ) {
41
+ return unlinkAsync ( fileToDelete ) ;
42
+ }
43
+
37
44
export function doOptimizations ( context : BuildContext , dependencyMap : Map < string , Set < string > > ) {
38
45
// remove decorators
39
46
const modifiedMap = new Map ( dependencyMap ) ;
0 commit comments