fix(ngcc): handle entry-points within container folders (#36305)
The previous optimizations in #35756 to the `DirectoryWalkerEntryPointFinder` were over zealous with regard to packages that have entry-points stored in "container" directories in the package, where the container directory was not an entry-point itself. Now we will also walk such "container" folders as long as they do not contain `.js` files, which we regard as an indicator that the directory will not contain entry-points. Fixes #36216 PR Close #36305
This commit is contained in:
parent
372b9101e2
commit
38ad1d97ab
|
@ -156,12 +156,21 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder {
|
||||||
isEntryPoint = true;
|
isEntryPoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDirectory || !isEntryPoint) {
|
if (!isDirectory) {
|
||||||
// This path is not an entry-point directory so we are done
|
// This path is not a directory so we are done.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This directory may contain entry-points of its own.
|
||||||
const childPaths = this.fs.readdir(absolutePath);
|
const childPaths = this.fs.readdir(absolutePath);
|
||||||
|
if (!isEntryPoint &&
|
||||||
|
childPaths.some(
|
||||||
|
childPath => childPath.endsWith('.js') &&
|
||||||
|
this.fs.stat(this.fs.resolve(absolutePath, childPath)).isFile())) {
|
||||||
|
// We do not consider non-entry-point directories that contain JS files as they are very
|
||||||
|
// unlikely to be containers for sub-entry-points.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.collectSecondaryEntryPoints(entryPoints, packagePath, absolutePath, childPaths);
|
this.collectSecondaryEntryPoints(entryPoints, packagePath, absolutePath, childPaths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,22 @@ runInEachFileSystem(() => {
|
||||||
expect(entryPoints).toEqual([]);
|
expect(entryPoints).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should process sub-entry-points within a non-entry-point containing folder in a package',
|
||||||
|
() => {
|
||||||
|
const basePath = _Abs('/containing_folders/node_modules');
|
||||||
|
loadTestFiles([
|
||||||
|
...createPackage(basePath, 'package'),
|
||||||
|
...createPackage(fs.resolve(basePath, 'package/container'), 'entry-point-1'),
|
||||||
|
]);
|
||||||
|
const finder = new DirectoryWalkerEntryPointFinder(
|
||||||
|
fs, config, logger, resolver, manifest, basePath, undefined);
|
||||||
|
const {entryPoints} = finder.findEntryPoints();
|
||||||
|
expect(dumpEntryPointPaths(basePath, entryPoints)).toEqual([
|
||||||
|
['package', 'package'],
|
||||||
|
['package', 'package/container/entry-point-1'],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle dependencies via pathMappings', () => {
|
it('should handle dependencies via pathMappings', () => {
|
||||||
const basePath = _Abs('/path_mapped/node_modules');
|
const basePath = _Abs('/path_mapped/node_modules');
|
||||||
const pathMappings: PathMappings = {
|
const pathMappings: PathMappings = {
|
||||||
|
|
Loading…
Reference in New Issue