1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var aot_compiler_1 = require("./aot/aot-compiler");
|
4 | var util_1 = require("./deep-linking/util");
|
5 | var logger_1 = require("./logger/logger");
|
6 | var config_1 = require("./util/config");
|
7 | var Constants = require("./util/constants");
|
8 | var helpers_1 = require("./util/helpers");
|
9 | function ngc(context, configFile) {
|
10 | configFile = config_1.getUserConfigFile(context, taskInfo, configFile);
|
11 | var logger = new logger_1.Logger('ngc');
|
12 | return ngcWorker(context, configFile)
|
13 | .then(function () {
|
14 | logger.finish();
|
15 | })
|
16 | .catch(function (err) {
|
17 | throw logger.fail(err);
|
18 | });
|
19 | }
|
20 | exports.ngc = ngc;
|
21 | function ngcWorker(context, configFile) {
|
22 | return transformTsForDeepLinking(context).then(function () {
|
23 | return runNgc(context, configFile);
|
24 | });
|
25 | }
|
26 | exports.ngcWorker = ngcWorker;
|
27 | function runNgc(context, configFile) {
|
28 | return aot_compiler_1.runAot(context, { entryPoint: process.env[Constants.ENV_APP_ENTRY_POINT],
|
29 | rootDir: context.rootDir,
|
30 | tsConfigPath: process.env[Constants.ENV_TS_CONFIG],
|
31 | appNgModuleClass: process.env[Constants.ENV_APP_NG_MODULE_CLASS],
|
32 | appNgModulePath: process.env[Constants.ENV_APP_NG_MODULE_PATH]
|
33 | });
|
34 | }
|
35 | exports.runNgc = runNgc;
|
36 | function transformTsForDeepLinking(context) {
|
37 | if (helpers_1.getBooleanPropertyValue(Constants.ENV_PARSE_DEEPLINKS)) {
|
38 | var tsFiles = util_1.filterTypescriptFilesForDeepLinks(context.fileCache);
|
39 | tsFiles.forEach(function (tsFile) {
|
40 | tsFile.content = util_1.purgeDeepLinkDecorator(tsFile.content);
|
41 | });
|
42 | var tsFile = context.fileCache.get(helpers_1.getStringPropertyValue(Constants.ENV_APP_NG_MODULE_PATH));
|
43 | if (!util_1.hasExistingDeepLinkConfig(tsFile.path, tsFile.content)) {
|
44 | var deepLinkString = util_1.convertDeepLinkConfigEntriesToString(helpers_1.getParsedDeepLinkConfig());
|
45 | tsFile.content = util_1.getUpdatedAppNgModuleContentWithDeepLinkConfig(tsFile.path, tsFile.content, deepLinkString);
|
46 | }
|
47 | }
|
48 | return Promise.resolve();
|
49 | }
|
50 | exports.transformTsForDeepLinking = transformTsForDeepLinking;
|
51 | var taskInfo = {
|
52 | fullArg: '--ngc',
|
53 | shortArg: '-n',
|
54 | envVar: 'IONIC_NGC',
|
55 | packageConfig: 'ionic_ngc',
|
56 | defaultConfigFile: null
|
57 | };
|