diff --git a/packages/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.ts b/packages/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.ts index 4ebecb69ae..f2b00325ae 100644 --- a/packages/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.ts +++ b/packages/compiler-cli/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.ts @@ -156,12 +156,21 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder { isEntryPoint = true; } - if (!isDirectory || !isEntryPoint) { - // This path is not an entry-point directory so we are done + if (!isDirectory) { + // This path is not a directory so we are done. continue; } + // This directory may contain entry-points of its own. 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); } } diff --git a/packages/compiler-cli/ngcc/test/entry_point_finder/directory_walker_entry_point_finder_spec.ts b/packages/compiler-cli/ngcc/test/entry_point_finder/directory_walker_entry_point_finder_spec.ts index bfd297dfdd..e10784bec7 100644 --- a/packages/compiler-cli/ngcc/test/entry_point_finder/directory_walker_entry_point_finder_spec.ts +++ b/packages/compiler-cli/ngcc/test/entry_point_finder/directory_walker_entry_point_finder_spec.ts @@ -287,6 +287,22 @@ runInEachFileSystem(() => { 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', () => { const basePath = _Abs('/path_mapped/node_modules'); const pathMappings: PathMappings = {