test(ivy): support multiple compilations in the ngtsc test env (#29380)
This commit adds support for compiling the same program repeatedly in a way that's similar to how incremental builds work in a tool such as the CLI. * support is added to the compiler entrypoint for reuse of the Program object between compilations. This is the basis of the compiler's incremental compilation model. * support is added to wrap the CompilerHost the compiler creates and cache ts.SourceFiles in between compilations. * support is added to track when files are emitted, for assertion purposes. * an 'exclude' section is added to the base tsconfig to prevent .d.ts outputs from the first compilation from becoming inputs to any subsequent compilations. PR Close #29380
This commit is contained in:

committed by
Jason Aden

parent
aaa16f286d
commit
7316212c1e
@ -21,19 +21,18 @@ const NODE_MODULES_PACKAGE_NAME = /node_modules\/((\w|-|\.)+|(@(\w|-|\.)+\/(\w|-
|
||||
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
|
||||
const CSS_PREPROCESSOR_EXT = /(\.scss|\.less|\.styl)$/;
|
||||
|
||||
let augmentHostForTest: {[name: string]: Function}|null = null;
|
||||
let wrapHostForTest: ((host: ts.CompilerHost) => ts.CompilerHost)|null = null;
|
||||
|
||||
export function setAugmentHostForTest(augmentation: {[name: string]: Function} | null): void {
|
||||
augmentHostForTest = augmentation;
|
||||
export function setWrapHostForTest(wrapFn: ((host: ts.CompilerHost) => ts.CompilerHost) | null):
|
||||
void {
|
||||
wrapHostForTest = wrapFn;
|
||||
}
|
||||
|
||||
export function createCompilerHost(
|
||||
{options, tsHost = ts.createCompilerHost(options, true)}:
|
||||
{options: CompilerOptions, tsHost?: ts.CompilerHost}): CompilerHost {
|
||||
if (augmentHostForTest !== null) {
|
||||
for (const name of Object.keys(augmentHostForTest)) {
|
||||
(tsHost as any)[name] = augmentHostForTest[name];
|
||||
}
|
||||
if (wrapHostForTest !== null) {
|
||||
tsHost = wrapHostForTest(tsHost);
|
||||
}
|
||||
return tsHost;
|
||||
}
|
||||
|
Reference in New Issue
Block a user