fix(compiler-cli): don't rewrite imports when annotating for closure (#19444)
Closure no longer needs to have the imports rewritten avoid rewriting as this can cause issues when the source directory structure differs from what is deployed. Fixes: #19026
This commit is contained in:
parent
c1b029a413
commit
f24ea59f74
|
@ -53,7 +53,7 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un
|
||||||
fileNameToModuleId: (fileName) => fileName,
|
fileNameToModuleId: (fileName) => fileName,
|
||||||
googmodule: false,
|
googmodule: false,
|
||||||
untyped: true,
|
untyped: true,
|
||||||
convertIndexImportShorthand: true, transformDecorators, transformTypesToClosure,
|
convertIndexImportShorthand: false, transformDecorators, transformTypesToClosure,
|
||||||
};
|
};
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
|
|
|
@ -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', () => {
|
describe('expression lowering', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
writeConfig(`{
|
writeConfig(`{
|
||||||
|
|
Loading…
Reference in New Issue