fix(compiler-cli): flatModuleIndex files not generated on windows with multiple input files (#27200)

* Currently when building a `ng_module` with Bazel and having the flat module id option set, the flat module files are not being generated because `@angular/compiler-cli` does not properly determine the entry-point file.

Note that this logic is not necessarily specific to Bazel and the same problem can happen without Bazel if multiple TypeScript input files are specified while the `flatModuleIndex` option has been enabled.

PR Close #27200
This commit is contained in:
Paul Gschwendtner 2018-12-04 12:23:49 +01:00 committed by Igor Minar
parent 4f9374951d
commit d3c08e74f6
1 changed files with 4 additions and 2 deletions

View File

@ -71,8 +71,10 @@ export function createBundleIndexHost<H extends ts.CompilerHost>(
indexFile = files[0]; indexFile = files[0];
} else { } else {
for (const f of files) { for (const f of files) {
// Assume the shortest file path called index.ts is the entry point // Assume the shortest file path called index.ts is the entry point. Note that we
if (f.endsWith(path.sep + 'index.ts')) { // need to use the posix path delimiter here because TypeScript internally only
// passes posix paths.
if (f.endsWith('/index.ts')) {
if (!indexFile || indexFile.length > f.length) { if (!indexFile || indexFile.length > f.length) {
indexFile = f; indexFile = f;
} }