2017-11-20 18:21:17 +00:00
|
|
|
|
2017-06-09 21:50:57 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-06-09 21:50:57 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2018-04-06 16:53:10 +00:00
|
|
|
import {NgtscProgram} from '../ngtsc/program';
|
2018-02-16 16:45:21 +00:00
|
|
|
|
2021-11-24 21:42:28 +00:00
|
|
|
import {CompilerHost, CompilerOptions, Program} from './api';
|
2017-06-09 21:50:57 +00:00
|
|
|
|
2021-10-15 17:14:23 +00:00
|
|
|
/** Error message to show when attempting to build View Engine. */
|
|
|
|
|
const VE_DISABLED_MESSAGE = `
|
|
|
|
|
This compilation is using the View Engine compiler which is no longer supported by the Angular team
|
|
|
|
|
and is being removed. Please upgrade to the Ivy compiler by switching to \`NgtscProgram\`. See
|
|
|
|
|
https://angular.io/guide/ivy for more information.
|
|
|
|
|
`.trim().split('\n').join(' ');
|
2018-02-16 16:45:21 +00:00
|
|
|
|
2017-12-22 17:36:47 +00:00
|
|
|
export function createProgram({rootNames, options, host, oldProgram}: {
|
|
|
|
|
rootNames: ReadonlyArray<string>,
|
|
|
|
|
options: CompilerOptions,
|
2020-04-07 19:43:43 +00:00
|
|
|
host: CompilerHost,
|
|
|
|
|
oldProgram?: Program
|
2017-12-22 17:36:47 +00:00
|
|
|
}): Program {
|
2019-08-20 17:52:31 +00:00
|
|
|
if (options.enableIvy !== false) {
|
2020-01-18 00:00:07 +00:00
|
|
|
return new NgtscProgram(rootNames, options, host, oldProgram as NgtscProgram | undefined);
|
2019-08-20 17:54:02 +00:00
|
|
|
} else {
|
2021-11-24 21:42:28 +00:00
|
|
|
throw new Error(VE_DISABLED_MESSAGE);
|
2021-04-09 15:31:08 +00:00
|
|
|
}
|
2021-06-04 14:57:07 +00:00
|
|
|
}
|