From b971bc6f70b19ad65dc7b68582e805f57f31351f Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 14 Jan 2021 13:59:54 +0000 Subject: [PATCH] perf(ngcc): do not copy files that have been processed (#40429) When using the `NewEntryPointWriter`, we must copy over all files from the entry-point bundle to the new entry-point. But since we are going to write out the modified files directly, there is no need to copy those. This commit skips copying the files that have been modified. PR Close #40429 --- .../ngcc/src/writing/new_entry_point_file_writer.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts b/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts index 15e2d8f414..87ac6addb6 100644 --- a/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts +++ b/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts @@ -40,7 +40,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter { // The new folder is at the root of the overall package const entryPoint = bundle.entryPoint; const ngccFolder = this.fs.join(entryPoint.packagePath, NGCC_DIRECTORY); - this.copyBundle(bundle, entryPoint.packagePath, ngccFolder); + this.copyBundle(bundle, entryPoint.packagePath, ngccFolder, transformedFiles); transformedFiles.forEach(file => this.writeFile(file, entryPoint.packagePath, ngccFolder)); this.updatePackageJson(entryPoint, formatProperties, ngccFolder); } @@ -67,9 +67,14 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter { } protected copyBundle( - bundle: EntryPointBundle, packagePath: AbsoluteFsPath, ngccFolder: AbsoluteFsPath) { + bundle: EntryPointBundle, packagePath: AbsoluteFsPath, ngccFolder: AbsoluteFsPath, + transformedFiles: FileToWrite[]) { + const doNotCopy = new Set(transformedFiles.map(f => f.path)); bundle.src.program.getSourceFiles().forEach(sourceFile => { const originalPath = absoluteFromSourceFile(sourceFile); + if (doNotCopy.has(originalPath)) { + return; + } const relativePath = this.fs.relative(packagePath, originalPath); const isInsidePackage = isLocalRelativePath(relativePath); if (!sourceFile.isDeclarationFile && isInsidePackage) {