1
|
"use strict";
|
2
|
/**
|
3
|
* @license
|
4
|
* Copyright Google Inc. 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
|
var __extends = (this && this.__extends) || (function () {
|
10
|
var extendStatics = Object.setPrototypeOf ||
|
11
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
12
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
13
|
return function (d, b) {
|
14
|
extendStatics(d, b);
|
15
|
function __() { this.constructor = d; }
|
16
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
17
|
};
|
18
|
})();
|
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
/**
|
21
|
* This is a private API for the ngtools toolkit.
|
22
|
*
|
23
|
* This API should be stable for NG 2. It can be removed in NG 4..., but should be replaced by
|
24
|
* something else.
|
25
|
*/
|
26
|
var compiler_1 = require("@angular/compiler");
|
27
|
var codegen_1 = require("./codegen");
|
28
|
var compiler_host_1 = require("./compiler_host");
|
29
|
var extractor_1 = require("./extractor");
|
30
|
var ngtools_impl_1 = require("./ngtools_impl");
|
31
|
var path_mapped_compiler_host_1 = require("./path_mapped_compiler_host");
|
32
|
/**
|
33
|
* A ModuleResolutionHostAdapter that overrides the readResource() method with the one
|
34
|
* passed in the interface.
|
35
|
*/
|
36
|
var CustomLoaderModuleResolutionHostAdapter = (function (_super) {
|
37
|
__extends(CustomLoaderModuleResolutionHostAdapter, _super);
|
38
|
function CustomLoaderModuleResolutionHostAdapter(_readResource, host) {
|
39
|
var _this = _super.call(this, host) || this;
|
40
|
_this._readResource = _readResource;
|
41
|
return _this;
|
42
|
}
|
43
|
CustomLoaderModuleResolutionHostAdapter.prototype.readResource = function (path) { return this._readResource(path); };
|
44
|
return CustomLoaderModuleResolutionHostAdapter;
|
45
|
}(compiler_host_1.ModuleResolutionHostAdapter));
|
46
|
/**
|
47
|
* @internal
|
48
|
* @private
|
49
|
*/
|
50
|
var NgTools_InternalApi_NG_2 = (function () {
|
51
|
function NgTools_InternalApi_NG_2() {
|
52
|
}
|
53
|
/**
|
54
|
* @internal
|
55
|
* @private
|
56
|
*/
|
57
|
NgTools_InternalApi_NG_2.codeGen = function (options) {
|
58
|
var hostContext = new CustomLoaderModuleResolutionHostAdapter(options.readResource, options.host);
|
59
|
var cliOptions = {
|
60
|
i18nFormat: options.i18nFormat,
|
61
|
i18nFile: options.i18nFile,
|
62
|
locale: options.locale,
|
63
|
missingTranslation: options.missingTranslation,
|
64
|
basePath: options.basePath
|
65
|
};
|
66
|
var ngOptions = options.angularCompilerOptions;
|
67
|
if (ngOptions.enableSummariesForJit === undefined) {
|
68
|
// default to false
|
69
|
ngOptions.enableSummariesForJit = false;
|
70
|
}
|
71
|
// Create the Code Generator.
|
72
|
var codeGenerator = codegen_1.CodeGenerator.create(ngOptions, cliOptions, options.program, options.host, hostContext);
|
73
|
return codeGenerator.codegen();
|
74
|
};
|
75
|
/**
|
76
|
* @internal
|
77
|
* @private
|
78
|
*/
|
79
|
NgTools_InternalApi_NG_2.listLazyRoutes = function (options) {
|
80
|
var angularCompilerOptions = options.angularCompilerOptions;
|
81
|
var program = options.program;
|
82
|
var moduleResolutionHost = new compiler_host_1.ModuleResolutionHostAdapter(options.host);
|
83
|
var usePathMapping = !!angularCompilerOptions.rootDirs && angularCompilerOptions.rootDirs.length > 0;
|
84
|
var ngCompilerHost = usePathMapping ?
|
85
|
new path_mapped_compiler_host_1.PathMappedCompilerHost(program, angularCompilerOptions, moduleResolutionHost) :
|
86
|
new compiler_host_1.CompilerHost(program, angularCompilerOptions, moduleResolutionHost);
|
87
|
var symbolCache = new compiler_1.StaticSymbolCache();
|
88
|
var summaryResolver = new compiler_1.AotSummaryResolver(ngCompilerHost, symbolCache);
|
89
|
var symbolResolver = new compiler_1.StaticSymbolResolver(ngCompilerHost, symbolCache, summaryResolver);
|
90
|
var staticReflector = new compiler_1.StaticReflector(summaryResolver, symbolResolver);
|
91
|
var routeMap = ngtools_impl_1.listLazyRoutesOfModule(options.entryModule, ngCompilerHost, staticReflector);
|
92
|
return Object.keys(routeMap).reduce(function (acc, route) {
|
93
|
acc[route] = routeMap[route].absoluteFilePath;
|
94
|
return acc;
|
95
|
}, {});
|
96
|
};
|
97
|
/**
|
98
|
* @internal
|
99
|
* @private
|
100
|
*/
|
101
|
NgTools_InternalApi_NG_2.extractI18n = function (options) {
|
102
|
var hostContext = new CustomLoaderModuleResolutionHostAdapter(options.readResource, options.host);
|
103
|
// Create the i18n extractor.
|
104
|
var locale = options.locale || null;
|
105
|
var extractor = extractor_1.Extractor.create(options.angularCompilerOptions, options.program, options.host, locale, hostContext);
|
106
|
return extractor.extract(options.i18nFormat, options.outFile || null);
|
107
|
};
|
108
|
return NgTools_InternalApi_NG_2;
|
109
|
}());
|
110
|
exports.NgTools_InternalApi_NG_2 = NgTools_InternalApi_NG_2;
|
111
|
//# sourceMappingURL=ngtools_api.js.map
|