diff --git a/tools/@angular/tsc-wrapped/src/main.ts b/tools/@angular/tsc-wrapped/src/main.ts index 5a5ca27a4d256..220e883a1c338 100644 --- a/tools/@angular/tsc-wrapped/src/main.ts +++ b/tools/@angular/tsc-wrapped/src/main.ts @@ -99,12 +99,8 @@ export function main( addGeneratedFileName(name); } - const tsickleCompilerHostOptions: tsickle.Options = { - googmodule: false, - untyped: true, - convertIndexImportShorthand: - ngOptions.target === ts.ScriptTarget.ES2015, // This covers ES6 too - }; + const tsickleCompilerHostOptions: + tsickle.Options = {googmodule: false, untyped: true, convertIndexImportShorthand: true}; const tsickleHost: tsickle.TsickleHost = { shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName), diff --git a/tools/@angular/tsc-wrapped/test/main.spec.ts b/tools/@angular/tsc-wrapped/test/main.spec.ts index a5419de29f926..287bd95abc444 100644 --- a/tools/@angular/tsc-wrapped/test/main.spec.ts +++ b/tools/@angular/tsc-wrapped/test/main.spec.ts @@ -366,4 +366,57 @@ describe('tsc-wrapped', () => { }) .catch(e => done.fail(e)); }); + + it('should expand shorthand imports for ES2015 modules', (done) => { + write('tsconfig.json', `{ + "compilerOptions": { + "experimentalDecorators": true, + "types": [], + "outDir": "built", + "declaration": true, + "moduleResolution": "node", + "target": "es2015", + "module": "es2015" + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true + }, + "files": ["test.ts"] + }`); + + main(basePath, {basePath}) + .then(() => { + const fileOutput = readOut('js'); + expect(fileOutput).toContain(`export { A, B } from './dep/index'`); + done(); + }) + .catch(e => done.fail(e)); + }); + + it('should expand shorthand imports for ES5 CommonJS modules', (done) => { + write('tsconfig.json', `{ + "compilerOptions": { + "experimentalDecorators": true, + "types": [], + "outDir": "built", + "declaration": true, + "moduleResolution": "node", + "target": "es5", + "module": "commonjs" + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true + }, + "files": ["test.ts"] + }`); + + main(basePath, {basePath}) + .then(() => { + const fileOutput = readOut('js'); + expect(fileOutput).toContain(`var index_1 = require("./dep/index");`); + done(); + }) + .catch(e => done.fail(e)); + }); + });