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:
parent
f89ac92e5e
commit
c9f8718d2a
@ -111,7 +111,7 @@ export function main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tsickleCompilerHostOptions:
|
const tsickleCompilerHostOptions:
|
||||||
tsickle.Options = {googmodule: false, untyped: true, convertIndexImportShorthand: true};
|
tsickle.Options = {googmodule: false, untyped: true, convertIndexImportShorthand: false};
|
||||||
|
|
||||||
const tsickleHost: tsickle.TsickleHost = {
|
const tsickleHost: tsickle.TsickleHost = {
|
||||||
shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName),
|
shouldSkipTsickleProcessing: (fileName) => /\.d\.ts$/.test(fileName),
|
||||||
|
@ -75,7 +75,7 @@ describe('tsc-wrapped', () => {
|
|||||||
// No helpers since decorators were lowered
|
// No helpers since decorators were lowered
|
||||||
expect(out).not.toContain('__decorate');
|
expect(out).not.toContain('__decorate');
|
||||||
// Expand `export *` and fix index import
|
// 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
|
// Annotated for Closure compiler
|
||||||
expect(out).toContain('* @param {?} x');
|
expect(out).toContain('* @param {?} x');
|
||||||
// Comments should stay multi-line
|
// Comments should stay multi-line
|
||||||
@ -112,7 +112,7 @@ describe('tsc-wrapped', () => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
const out = readOut('js');
|
const out = readOut('js');
|
||||||
// Expand `export *` and fix index import
|
// 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
|
// Annotated for Closure compiler
|
||||||
expect(out).toContain('* @param {?} x');
|
expect(out).toContain('* @param {?} x');
|
||||||
done();
|
done();
|
||||||
@ -367,7 +367,7 @@ describe('tsc-wrapped', () => {
|
|||||||
.catch(e => done.fail(e));
|
.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', `{
|
write('tsconfig.json', `{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
@ -387,13 +387,13 @@ describe('tsc-wrapped', () => {
|
|||||||
main(basePath, {basePath})
|
main(basePath, {basePath})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const fileOutput = readOut('js');
|
const fileOutput = readOut('js');
|
||||||
expect(fileOutput).toContain(`export { A, B } from './dep/index'`);
|
expect(fileOutput).toContain(`export { A, B } from './dep'`);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(e => done.fail(e));
|
.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', `{
|
write('tsconfig.json', `{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
@ -413,7 +413,7 @@ describe('tsc-wrapped', () => {
|
|||||||
main(basePath, {basePath})
|
main(basePath, {basePath})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const fileOutput = readOut('js');
|
const fileOutput = readOut('js');
|
||||||
expect(fileOutput).toContain(`var index_1 = require("./dep/index");`);
|
expect(fileOutput).toContain(`var dep_1 = require("./dep");`);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(e => done.fail(e));
|
.catch(e => done.fail(e));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user