From c9f8718d2a72640da3889ac0ddf47a40ee627f67 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Thu, 5 Oct 2017 10:39:12 -0700 Subject: [PATCH] fix(tsc-wrapped): don't rewrite imports when annotating for closure (#19579) Port of f24ea59f74552113f8e8586d2d69045254512aa to 4.4.x Closure no longer needs to have the imports rewritten so avoid rewriting as this can cause issues when the source directory structure differs from what is deployed. Fixes: #17171 PR Close #19579 --- tools/@angular/tsc-wrapped/src/main.ts | 2 +- tools/@angular/tsc-wrapped/test/main.spec.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/@angular/tsc-wrapped/src/main.ts b/tools/@angular/tsc-wrapped/src/main.ts index e3b485b90e..83070f6c0d 100644 --- a/tools/@angular/tsc-wrapped/src/main.ts +++ b/tools/@angular/tsc-wrapped/src/main.ts @@ -111,7 +111,7 @@ export function main( } const tsickleCompilerHostOptions: - tsickle.Options = {googmodule: false, untyped: true, convertIndexImportShorthand: true}; + tsickle.Options = {googmodule: false, untyped: true, convertIndexImportShorthand: false}; 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 287bd95abc..df2b890f99 100644 --- a/tools/@angular/tsc-wrapped/test/main.spec.ts +++ b/tools/@angular/tsc-wrapped/test/main.spec.ts @@ -75,7 +75,7 @@ describe('tsc-wrapped', () => { // No helpers since decorators were lowered expect(out).not.toContain('__decorate'); // Expand `export *` and fix index import - expect(out).toContain(`export { A, B } from './dep/index'`); + expect(out).toContain(`export { A, B } from './dep'`); // Annotated for Closure compiler expect(out).toContain('* @param {?} x'); // Comments should stay multi-line @@ -112,7 +112,7 @@ describe('tsc-wrapped', () => { .then(() => { const out = readOut('js'); // Expand `export *` and fix index import - expect(out).toContain(`export { A, B } from './dep/index'`); + expect(out).toContain(`export { A, B } from './dep'`); // Annotated for Closure compiler expect(out).toContain('* @param {?} x'); done(); @@ -367,7 +367,7 @@ describe('tsc-wrapped', () => { .catch(e => done.fail(e)); }); - it('should expand shorthand imports for ES2015 modules', (done) => { + it('should not expand shorthand imports for ES2015 modules', (done) => { write('tsconfig.json', `{ "compilerOptions": { "experimentalDecorators": true, @@ -387,13 +387,13 @@ describe('tsc-wrapped', () => { main(basePath, {basePath}) .then(() => { const fileOutput = readOut('js'); - expect(fileOutput).toContain(`export { A, B } from './dep/index'`); + expect(fileOutput).toContain(`export { A, B } from './dep'`); done(); }) .catch(e => done.fail(e)); }); - it('should expand shorthand imports for ES5 CommonJS modules', (done) => { + it('should not expand shorthand imports for ES5 CommonJS modules', (done) => { write('tsconfig.json', `{ "compilerOptions": { "experimentalDecorators": true, @@ -413,7 +413,7 @@ describe('tsc-wrapped', () => { main(basePath, {basePath}) .then(() => { const fileOutput = readOut('js'); - expect(fileOutput).toContain(`var index_1 = require("./dep/index");`); + expect(fileOutput).toContain(`var dep_1 = require("./dep");`); done(); }) .catch(e => done.fail(e));