source: trip-planner-front/node_modules/@ngtools/webpack/src/ivy/loader.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 3.1 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 });
29exports.default = exports.angularWebpackLoader = void 0;
30const path = __importStar(require("path"));
31const symbol_1 = require("./symbol");
32function angularWebpackLoader(content, map) {
33 const callback = this.async();
34 if (!callback) {
35 throw new Error('Invalid webpack version');
36 }
37 const fileEmitter = this[symbol_1.AngularPluginSymbol];
38 if (!fileEmitter || typeof fileEmitter !== 'object') {
39 if (this.resourcePath.endsWith('.js')) {
40 // Passthrough for JS files when no plugin is used
41 this.callback(undefined, content, map);
42 return;
43 }
44 callback(new Error('The Angular Webpack loader requires the AngularWebpackPlugin.'));
45 return;
46 }
47 fileEmitter
48 .emit(this.resourcePath)
49 .then((result) => {
50 if (!result) {
51 if (this.resourcePath.endsWith('.js')) {
52 // Return original content for JS files if not compiled by TypeScript ("allowJs")
53 this.callback(undefined, content, map);
54 }
55 else {
56 // File is not part of the compilation
57 const message = `${this.resourcePath} is missing from the TypeScript compilation. ` +
58 `Please make sure it is in your tsconfig via the 'files' or 'include' property.`;
59 callback(new Error(message));
60 }
61 return;
62 }
63 result.dependencies.forEach((dependency) => this.addDependency(dependency));
64 let resultContent = result.content || '';
65 let resultMap;
66 if (result.map) {
67 resultContent = resultContent.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
68 resultMap = JSON.parse(result.map);
69 resultMap.sources = resultMap.sources.map((source) => path.join(path.dirname(this.resourcePath), source));
70 }
71 callback(undefined, resultContent, resultMap);
72 })
73 .catch((err) => {
74 callback(err);
75 });
76}
77exports.angularWebpackLoader = angularWebpackLoader;
78exports.default = angularWebpackLoader;
Note: See TracBrowser for help on using the repository browser.