UNPKG

1.46 kBJavaScriptView Raw
1"use strict";
2exports.__esModule = true;
3exports.isIvyEnabled = void 0;
4var core_1 = require("@angular-devkit/core");
5var json_utilts_1 = require("./json-utilts");
6// https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/migrations/update-9/utils.ts
7function isIvyEnabled(tree, tsConfigPath) {
8 // In version 9, Ivy is turned on by default
9 // Ivy is opted out only when 'enableIvy' is set to false.
10 var buffer = tree.read(tsConfigPath);
11 if (!buffer) {
12 return true;
13 }
14 var tsCfgAst = core_1.parseJsonAst(buffer.toString(), core_1.JsonParseMode.Loose);
15 if (tsCfgAst.kind !== 'object') {
16 return true;
17 }
18 var ngCompilerOptions = json_utilts_1.findPropertyInAstObject(tsCfgAst, 'angularCompilerOptions');
19 if (ngCompilerOptions && ngCompilerOptions.kind === 'object') {
20 var enableIvy = json_utilts_1.findPropertyInAstObject(ngCompilerOptions, 'enableIvy');
21 if (enableIvy) {
22 return !!enableIvy.value;
23 }
24 }
25 var configExtends = json_utilts_1.findPropertyInAstObject(tsCfgAst, 'extends');
26 if (configExtends && configExtends.kind === 'string') {
27 var extendedTsConfigPath = core_1.resolve(core_1.dirname(core_1.normalize(tsConfigPath)), core_1.normalize(configExtends.value));
28 return isIvyEnabled(tree, extendedTsConfigPath);
29 }
30 return true;
31}
32exports.isIvyEnabled = isIvyEnabled;
33//# sourceMappingURL=angular-utils.js.map
\No newline at end of file