import type * as d from '../../declarations' ; import { catchError } from '@utils' ; import { outputServiceWorkers } from '../output-targets/output-service-workers' ; import { validateBuildFiles } from './validate-files' ; export const writeBuild = async ( config , compilerCtx , buildCtx ) => { const timeSpan = buildCtx . createTimeSpan ( `writeBuildFiles started` , true ) ; let totalFilesWrote = 0 ; try { const commitResults = await compilerCtx . fs . commit ( ) ; buildCtx . filesWritten = commitResults . filesWritten ; buildCtx . filesDeleted = commitResults . filesDeleted ; buildCtx . dirsDeleted = commitResults . dirsDeleted ; buildCtx . dirsAdded = commitResults . dirsAdded ; totalFilesWrote = commitResults . filesWritten . length ; buildCtx . debug ( `in-memory-fs: ${ compilerCtx . fs . getMemoryStats ( ) }` ) ; await outputServiceWorkers ( config , buildCtx ) , await validateBuildFiles ( config , compilerCtx , buildCtx ) ; } catch ( e ) { catchError ( buildCtx . diagnostics , e ) ; } timeSpan . finish ( `writeBuildFiles finished, files wrote: ${ totalFilesWrote }` ) ; } ;