import * as deepmerge from 'deepmerge' ; import { typescriptCompilationTargets } from './typescript-compilation-targets' ; import { getFileNameByPackageName } from '../utilities/get-file-name-by-package-name' ; /**
 * TypeScript Configuartion Builder
 */ export class TypeScriptConfigurationBuilder { /**
     * List of entry files
     */ private files : Array < string > ; /**
     * TypeScript compiler options
     */ private typescriptCompilerOptions : { [ option ] : any ; } ; /**
     * Angular compiler options
     */ private angularCompilerOptions : { [ option ] : any ; } ; /**
     * Constructor
     */ constructor ( ) { this . typescriptCompilerOptions = { baseUrl : '' , declaration : true , emitDecoratorMetadata : true , experimentalDecorators : true , lib : [ 'es6' , 'dom' , 'dom.iterable' , 'scripthost' ] , inlineSources : true , module : 'ES2015' , moduleResolution : 'node' , newLine : 'LF' , pretty : true , sourceMap : true } ; this . files = [ ] ; this . angularCompilerOptions = { annotateForClosureCompiler : true , preserveWhitespaces : false , skipTemplateCodegen : true , strictMetadataEmit : true } ; } param entryFile param entryDir returns public setEntry ( entryFile , entryDir ) { this . files . push ( entryFile ) ; return this ; } param outDir returns public setOutDir ( outDir ) { this . typescriptCompilerOptions . outDir = outDir ; return this ; } param packageName returns public setPackageName ( packageName ) { this . angularCompilerOptions . flatModuleId = packageName ; this . angularCompilerOptions . flatModuleOutFile = `${ getFileNameByPackageName ( packageName ) }.js` ; return this ; } param target returns public setCompilationTarget ( target ) { this . typescriptCompilerOptions . target = typescriptCompilationTargets [ target ] ; return this ; } param typescriptCompilerOptions returns public setCustomTypescriptCompilerOptions ( typescriptCompilerOptions ) { this . typescriptCompilerOptions = deepmerge ( this . typescriptCompilerOptions , typescriptCompilerOptions ) ; return this ; } param angularCompilerOptions returns public setCustomAngularCompilerOptions ( angularCompilerOptions ) { this . angularCompilerOptions = deepmerge ( this . angularCompilerOptions , angularCompilerOptions ) ; return this ; } returns public build ( ) { return { compilerOptions : this . typescriptCompilerOptions , files : this . files , angularCompilerOptions : this . angularCompilerOptions } ; } }