Name AMD modules foo rather than foo/index.
Fixes https://github.com/angular/angular/issues/23810
PiperOrigin-RevId: 196142916
diff --git a/internal/tsc_wrapped/compiler_host.ts b/internal/tsc_wrapped/compiler_host.ts
index 580985f..8494077 100644
--- a/internal/tsc_wrapped/compiler_host.ts
+++ b/internal/tsc_wrapped/compiler_host.ts
@@ -321,6 +321,13 @@
relativeFileName) {
return this.bazelOpts.moduleName;
}
+ // Support the common case of commonjs convention that index is the
+ // default module in a directory.
+ // This makes our module naming scheme more conventional and lets users
+ // refer to modules with the natural name they're used to.
+ if (relativeFileName === 'index') {
+ return this.bazelOpts.moduleName;
+ }
return path.posix.join(this.bazelOpts.moduleName, relativeFileName);
}
}