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
This commit is contained in:
Pete Bacon Darwin 2021-01-14 13:59:54 +00:00 committed by Andrew Kushnir
parent ad0fb9c6bb
commit b971bc6f70
1 changed files with 7 additions and 2 deletions

View File

@ -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) {