fix(ivy): support late-initialized variables in ngcc/ngtsc (#26236)

In some formats variables are declared as `var` or `let` and only
assigned a value later in the code.

The ngtsc resolver still needs to be able to resolve this value,
so the host now provides a `host.getVariableValue(declaration)`
method that can do this resolution based on the format.

The hosts make some assumptions about the layout of the
code, so they may only work in the constrained scenarios that
ngcc expects.

PR Close #26236
This commit is contained in:
Pete Bacon Darwin
2018-10-01 11:10:55 +01:00
committed by Jason Aden
parent 9320ec0f43
commit 13cdd13511
5 changed files with 114 additions and 2 deletions

View File

@ -50,3 +50,15 @@ export function getFakeCore() {
`
};
}
export function convertToDirectTsLibImport(filesystem: {name: string, contents: string}[]) {
return filesystem.map(file => {
const contents =
file.contents
.replace(
`import * as tslib_1 from 'tslib';`,
`import { __decorate, __metadata, __read, __values, __param, __extends, __assign } from 'tslib';`)
.replace('tslib_1.', '');
return {...file, contents};
});
}