fix(ivy): ngcc - do not copy external files when writing bundles (#30085)
Only the JS files that are actually part of the entry-point should be copied to the new entry-point folder in the `NewEntryPointFileWriter`. Previously some typings and external JS files were being copied which was messing up the node_modules structure. Fixes https://github.com/angular/angular-cli/issues/14193 PR Close #30085
This commit is contained in:

committed by
Andrew Kushnir

parent
0b5f480eca
commit
6af9b8fb92
@ -35,15 +35,17 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
||||
const relativeEntryPointPath = relative(entryPoint.package, entryPoint.path);
|
||||
const relativeNewDir = join(NGCC_DIRECTORY, relativeEntryPointPath);
|
||||
const newDir = AbsoluteFsPath.fromUnchecked(join(entryPoint.package, relativeNewDir));
|
||||
this.copyBundle(bundle, entryPoint.path, newDir);
|
||||
this.copyBundle(bundle, entryPoint.package, entryPoint.path, newDir);
|
||||
transformedFiles.forEach(file => this.writeFile(file, entryPoint.path, newDir));
|
||||
this.updatePackageJson(entryPoint, bundle.formatProperty, newDir);
|
||||
}
|
||||
|
||||
protected copyBundle(
|
||||
bundle: EntryPointBundle, entryPointPath: AbsoluteFsPath, newDir: AbsoluteFsPath) {
|
||||
bundle: EntryPointBundle, packagePath: AbsoluteFsPath, entryPointPath: AbsoluteFsPath,
|
||||
newDir: AbsoluteFsPath) {
|
||||
bundle.src.program.getSourceFiles().forEach(sourceFile => {
|
||||
if (!sourceFile.isDeclarationFile) {
|
||||
const isOutsidePackage = relative(packagePath, sourceFile.fileName).startsWith('..');
|
||||
if (!sourceFile.isDeclarationFile && !isOutsidePackage) {
|
||||
const relativePath = relative(entryPointPath, sourceFile.fileName);
|
||||
const newFilePath = join(newDir, relativePath);
|
||||
mkdir('-p', dirname(newFilePath));
|
||||
|
Reference in New Issue
Block a user