1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.forwardSlashPath = exports.isIvyEnabled = void 0;
|
---|
11 | const core_1 = require("@angular-devkit/core");
|
---|
12 | const json_file_1 = require("../../utility/json-file");
|
---|
13 | function isIvyEnabled(tree, tsConfigPath) {
|
---|
14 | // In version 9, Ivy is turned on by default
|
---|
15 | // Ivy is opted out only when 'enableIvy' is set to false.
|
---|
16 | let tsconfigJson;
|
---|
17 | try {
|
---|
18 | tsconfigJson = new json_file_1.JSONFile(tree, tsConfigPath);
|
---|
19 | }
|
---|
20 | catch {
|
---|
21 | return true;
|
---|
22 | }
|
---|
23 | const enableIvy = tsconfigJson.get(['angularCompilerOptions', 'enableIvy']);
|
---|
24 | if (enableIvy !== undefined) {
|
---|
25 | return !!enableIvy;
|
---|
26 | }
|
---|
27 | const configExtends = tsconfigJson.get(['extends']);
|
---|
28 | if (configExtends && typeof configExtends === 'string') {
|
---|
29 | const extendedTsConfigPath = core_1.resolve(core_1.dirname(core_1.normalize(tsConfigPath)), core_1.normalize(configExtends));
|
---|
30 | return isIvyEnabled(tree, extendedTsConfigPath);
|
---|
31 | }
|
---|
32 | return true;
|
---|
33 | }
|
---|
34 | exports.isIvyEnabled = isIvyEnabled;
|
---|
35 | // TS represents paths internally with '/' and expects paths to be in this format.
|
---|
36 | // angular.json expects paths with '/', but doesn't enforce them.
|
---|
37 | function forwardSlashPath(path) {
|
---|
38 | return path.replace(/\\/g, '/');
|
---|
39 | }
|
---|
40 | exports.forwardSlashPath = forwardSlashPath;
|
---|