source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/babel/presets/application.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.3 KB
Line 
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 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29const fs = __importStar(require("fs"));
30const path = __importStar(require("path"));
31function createI18nDiagnostics(reporter) {
32 // Babel currently is synchronous so import cannot be used
33 const diagnostics = new (require('@angular/localize/src/tools/src/diagnostics').Diagnostics)();
34 if (!reporter) {
35 return diagnostics;
36 }
37 const baseAdd = diagnostics.add;
38 diagnostics.add = function (type, message, ...args) {
39 if (type !== 'ignore') {
40 baseAdd.call(diagnostics, type, message, ...args);
41 reporter(type, message);
42 }
43 };
44 const baseError = diagnostics.error;
45 diagnostics.error = function (message, ...args) {
46 baseError.call(diagnostics, message, ...args);
47 reporter('error', message);
48 };
49 const baseWarn = diagnostics.warn;
50 diagnostics.warn = function (message, ...args) {
51 baseWarn.call(diagnostics, message, ...args);
52 reporter('warning', message);
53 };
54 const baseMerge = diagnostics.merge;
55 diagnostics.merge = function (other, ...args) {
56 baseMerge.call(diagnostics, other, ...args);
57 for (const diagnostic of other.messages) {
58 reporter(diagnostic.type, diagnostic.message);
59 }
60 };
61 return diagnostics;
62}
63function createI18nPlugins(locale, translation, missingTranslationBehavior, diagnosticReporter) {
64 const diagnostics = createI18nDiagnostics(diagnosticReporter);
65 const plugins = [];
66 if (translation) {
67 const { makeEs2015TranslatePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/es2015_translate_plugin');
68 plugins.push(makeEs2015TranslatePlugin(diagnostics, translation, {
69 missingTranslation: missingTranslationBehavior,
70 }));
71 const { makeEs5TranslatePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/es5_translate_plugin');
72 plugins.push(makeEs5TranslatePlugin(diagnostics, translation, {
73 missingTranslation: missingTranslationBehavior,
74 }));
75 }
76 const { makeLocalePlugin, } = require('@angular/localize/src/tools/src/translate/source_files/locale_plugin');
77 plugins.push(makeLocalePlugin(locale));
78 return plugins;
79}
80function createNgtscLogger(reporter) {
81 return {
82 level: 1,
83 debug(...args) { },
84 info(...args) {
85 reporter === null || reporter === void 0 ? void 0 : reporter('info', args.join());
86 },
87 warn(...args) {
88 reporter === null || reporter === void 0 ? void 0 : reporter('warning', args.join());
89 },
90 error(...args) {
91 reporter === null || reporter === void 0 ? void 0 : reporter('error', args.join());
92 },
93 };
94}
95function default_1(api, options) {
96 var _a;
97 const presets = [];
98 const plugins = [];
99 let needRuntimeTransform = false;
100 if ((_a = options.angularLinker) === null || _a === void 0 ? void 0 : _a.shouldLink) {
101 // Babel currently is synchronous so import cannot be used
102 const { createEs2015LinkerPlugin } = require('@angular/compiler-cli/linker/babel');
103 plugins.push(createEs2015LinkerPlugin({
104 linkerJitMode: options.angularLinker.jitMode,
105 // This is a workaround until https://github.com/angular/angular/issues/42769 is fixed.
106 sourceMapping: false,
107 logger: createNgtscLogger(options.diagnosticReporter),
108 fileSystem: {
109 resolve: path.resolve,
110 exists: fs.existsSync,
111 dirname: path.dirname,
112 relative: path.relative,
113 readFile: fs.readFileSync,
114 // Node.JS types don't overlap the Compiler types.
115 // eslint-disable-next-line @typescript-eslint/no-explicit-any
116 },
117 }));
118 }
119 if (options.forceES5) {
120 presets.push([
121 require('@babel/preset-env').default,
122 {
123 bugfixes: true,
124 modules: false,
125 // Comparable behavior to tsconfig target of ES5
126 targets: { ie: 9 },
127 exclude: ['transform-typeof-symbol'],
128 },
129 ]);
130 needRuntimeTransform = true;
131 }
132 if (options.i18n) {
133 const { locale, missingTranslationBehavior, translation } = options.i18n;
134 const i18nPlugins = createI18nPlugins(locale, translation, missingTranslationBehavior || 'ignore', options.diagnosticReporter);
135 plugins.push(...i18nPlugins);
136 }
137 if (options.forceAsyncTransformation) {
138 // Always transform async/await to support Zone.js
139 plugins.push(require('@babel/plugin-transform-async-to-generator').default, require('@babel/plugin-proposal-async-generator-functions').default);
140 needRuntimeTransform = true;
141 }
142 if (needRuntimeTransform) {
143 // Babel equivalent to TypeScript's `importHelpers` option
144 plugins.push([
145 require('@babel/plugin-transform-runtime').default,
146 {
147 useESModules: true,
148 version: require('@babel/runtime/package.json').version,
149 absoluteRuntime: path.dirname(require.resolve('@babel/runtime/package.json')),
150 },
151 ]);
152 }
153 return { presets, plugins };
154}
155exports.default = default_1;
Note: See TracBrowser for help on using the repository browser.