fix(ivy): ngcc - capture entry-points in top-level path-mapped folders (#31027)
The `EntryPointFinder` computes the base paths to consider when searching for entry-points. When there are `pathMappings` provided it works out the best top level base-paths that cover all the potential mappings. If this computed basePath happens to coincide with an entry-point path itself then we were missing it. Now we check for an entry-point even at the base-path itself. Related to https://github.com/angular/angular-cli/pull/14755 PR Close #31027
This commit is contained in:

committed by
Andrew Kushnir

parent
cc0bd11a5e
commit
0c3bb6a731
@ -70,7 +70,12 @@ export class EntryPointFinder {
|
||||
* @param sourceDirectory An absolute path to the root directory where searching begins.
|
||||
*/
|
||||
private walkDirectoryForEntryPoints(sourceDirectory: AbsoluteFsPath): EntryPoint[] {
|
||||
const entryPoints: EntryPoint[] = [];
|
||||
const entryPoints = this.getEntryPointsForPackage(sourceDirectory);
|
||||
if (entryPoints.length > 0) {
|
||||
// The `sourceDirectory` is an entry-point itself so no need to search its sub-directories.
|
||||
return entryPoints;
|
||||
}
|
||||
|
||||
this.fs
|
||||
.readdir(sourceDirectory)
|
||||
// Not interested in hidden files
|
||||
@ -86,16 +91,12 @@ export class EntryPointFinder {
|
||||
// Either the directory is a potential package or a namespace containing packages (e.g
|
||||
// `@angular`).
|
||||
const packagePath = AbsoluteFsPath.join(sourceDirectory, p);
|
||||
if (p.startsWith('@')) {
|
||||
entryPoints.push(...this.walkDirectoryForEntryPoints(packagePath));
|
||||
} else {
|
||||
entryPoints.push(...this.getEntryPointsForPackage(packagePath));
|
||||
entryPoints.push(...this.walkDirectoryForEntryPoints(packagePath));
|
||||
|
||||
// Also check for any nested node_modules in this package
|
||||
const nestedNodeModulesPath = AbsoluteFsPath.join(packagePath, 'node_modules');
|
||||
if (this.fs.exists(nestedNodeModulesPath)) {
|
||||
entryPoints.push(...this.walkDirectoryForEntryPoints(nestedNodeModulesPath));
|
||||
}
|
||||
// Also check for any nested node_modules in this package
|
||||
const nestedNodeModulesPath = AbsoluteFsPath.join(packagePath, 'node_modules');
|
||||
if (this.fs.exists(nestedNodeModulesPath)) {
|
||||
entryPoints.push(...this.walkDirectoryForEntryPoints(nestedNodeModulesPath));
|
||||
}
|
||||
});
|
||||
return entryPoints;
|
||||
@ -111,11 +112,14 @@ export class EntryPointFinder {
|
||||
|
||||
// Try to get an entry point from the top level package directory
|
||||
const topLevelEntryPoint = getEntryPointInfo(this.fs, this.logger, packagePath, packagePath);
|
||||
if (topLevelEntryPoint !== null) {
|
||||
entryPoints.push(topLevelEntryPoint);
|
||||
|
||||
// If there is no primary entry-point then exit
|
||||
if (topLevelEntryPoint === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Now search all the directories of this package for possible entry points
|
||||
// Otherwise store it and search for secondary entry-points
|
||||
entryPoints.push(topLevelEntryPoint);
|
||||
this.walkDirectory(packagePath, subdir => {
|
||||
const subEntryPoint = getEntryPointInfo(this.fs, this.logger, packagePath, subdir);
|
||||
if (subEntryPoint !== null) {
|
||||
|
Reference in New Issue
Block a user