Skip to content

Commit

Permalink
perf(ngcc): do not copy files that have been processed (#40429)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petebacondarwin authored and AndrewKushnir committed Jan 14, 2021
1 parent e2e3862 commit 798aae4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down

0 comments on commit 798aae4

Please sign in to comment.