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
This commit is contained in:
Chuck Jazdzewski 2017-10-05 10:39:12 -07:00
parent f89ac92e5e
commit c9f8718d2a
2 changed files with 7 additions and 7 deletions

View File

@ -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),

View File

@ -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));