diff --git a/packages/compiler-cli/src/main.ts b/packages/compiler-cli/src/main.ts index 27c41028af..626904b7b8 100644 --- a/packages/compiler-cli/src/main.ts +++ b/packages/compiler-cli/src/main.ts @@ -53,7 +53,7 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un fileNameToModuleId: (fileName) => fileName, googmodule: false, untyped: true, - convertIndexImportShorthand: true, transformDecorators, transformTypesToClosure, + convertIndexImportShorthand: false, transformDecorators, transformTypesToClosure, }; return ({ diff --git a/packages/compiler-cli/test/ngc_spec.ts b/packages/compiler-cli/test/ngc_spec.ts index 73513d4d3f..a7fc5772f4 100644 --- a/packages/compiler-cli/test/ngc_spec.ts +++ b/packages/compiler-cli/test/ngc_spec.ts @@ -507,6 +507,43 @@ describe('ngc transformer command-line', () => { }); }); + it('should not rewrite imports when annotating with closure', () => { + writeConfig(`{ + "extends": "./tsconfig-base.json", + "compilerOptions": { + "paths": { + "submodule": ["./src/submodule/public_api.ts"] + } + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true + }, + "files": ["mymodule.ts"] + }`); + write('src/test.txt', ' '); + write('src/submodule/public_api.ts', ` + export const A = 1; + `); + write('mymodule.ts', ` + import {NgModule, Component} from '@angular/core'; + import {A} from 'submodule'; + + @Component({template: ''}) + export class MyComp { + fn(p: any) { return A; } + } + + @NgModule({declarations: [MyComp]}) + export class MyModule {} + `); + + const exitCode = main(['-p', basePath], errorSpy); + expect(exitCode).toEqual(0); + const mymodulejs = path.resolve(outDir, 'mymodule.js'); + const mymoduleSource = fs.readFileSync(mymodulejs, 'utf8'); + expect(mymoduleSource).toContain(`import { A } from "submodule"`); + }); + describe('expression lowering', () => { beforeEach(() => { writeConfig(`{