refactor(ivy): allow `ImportManager` to have configurable prefix (#24897)

The ngcc compiler will want to specify its own prefix when rendering
definitions.

PR Close #24897
This commit is contained in:
Pete Bacon Darwin 2018-07-16 08:43:24 +01:00 committed by Igor Minar
parent ee2c050521
commit 67588ec606
1 changed files with 2 additions and 2 deletions

View File

@ -52,11 +52,11 @@ export class ImportManager {
private moduleToIndex = new Map<string, string>();
private nextIndex = 0;
constructor(private isCore: boolean) {}
constructor(private isCore: boolean, private prefix = 'i') {}
generateNamedImport(moduleName: string, symbol: string): string {
if (!this.moduleToIndex.has(moduleName)) {
this.moduleToIndex.set(moduleName, `i${this.nextIndex++}`);
this.moduleToIndex.set(moduleName, `${this.prefix}${this.nextIndex++}`);
}
if (this.isCore && moduleName === '@angular/core' && !CORE_SUPPORTED_SYMBOLS.has(symbol)) {
throw new Error(`Importing unexpected symbol ${symbol} while compiling core`);