source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/webpack/utils/helpers.js

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

initial commit

  • Property mode set to 100644
File size: 5.6 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.assetNameTemplateFactory = exports.getWatchOptions = exports.isPolyfillsEntry = exports.getEsVersionForFileName = exports.getSourceMapDevTool = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
30const core_1 = require("@angular-devkit/core");
31const path = __importStar(require("path"));
32const typescript_1 = require("typescript");
33const webpack_1 = require("webpack");
34function getOutputHashFormat(option, length = 20) {
35 const hashFormats = {
36 none: { chunk: '', extract: '', file: '', script: '' },
37 media: { chunk: '', extract: '', file: `.[hash:${length}]`, script: '' },
38 bundles: {
39 chunk: `.[chunkhash:${length}]`,
40 extract: `.[contenthash:${length}]`,
41 file: '',
42 script: `.[hash:${length}]`,
43 },
44 all: {
45 chunk: `.[chunkhash:${length}]`,
46 extract: `.[contenthash:${length}]`,
47 file: `.[hash:${length}]`,
48 script: `.[hash:${length}]`,
49 },
50 };
51 return hashFormats[option] || hashFormats['none'];
52}
53exports.getOutputHashFormat = getOutputHashFormat;
54function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
55 return extraEntryPoints.map((entry) => {
56 if (typeof entry === 'string') {
57 return { input: entry, inject: true, bundleName: defaultBundleName };
58 }
59 const { inject = true, ...newEntry } = entry;
60 let bundleName;
61 if (entry.bundleName) {
62 bundleName = entry.bundleName;
63 }
64 else if (!inject) {
65 // Lazy entry points use the file name as bundle name.
66 bundleName = core_1.basename(core_1.normalize(entry.input.replace(/\.(js|css|scss|sass|less|styl)$/i, '')));
67 }
68 else {
69 bundleName = defaultBundleName;
70 }
71 return { ...newEntry, inject, bundleName };
72 });
73}
74exports.normalizeExtraEntryPoints = normalizeExtraEntryPoints;
75function getSourceMapDevTool(scriptsSourceMap, stylesSourceMap, hiddenSourceMap = false, inlineSourceMap = false) {
76 const include = [];
77 if (scriptsSourceMap) {
78 include.push(/js$/);
79 }
80 if (stylesSourceMap) {
81 include.push(/css$/);
82 }
83 return new webpack_1.SourceMapDevToolPlugin({
84 filename: inlineSourceMap ? undefined : '[file].map',
85 include,
86 // We want to set sourceRoot to `webpack:///` for non
87 // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
88 // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
89 // there is no way to set the 'webRoot'
90 sourceRoot: 'webpack:///',
91 moduleFilenameTemplate: '[resource-path]',
92 append: hiddenSourceMap ? false : undefined,
93 });
94}
95exports.getSourceMapDevTool = getSourceMapDevTool;
96/**
97 * Returns an ES version file suffix to differentiate between various builds.
98 */
99function getEsVersionForFileName(scriptTarget, esVersionInFileName = false) {
100 if (!esVersionInFileName || scriptTarget === undefined) {
101 return '';
102 }
103 if (scriptTarget === typescript_1.ScriptTarget.ESNext) {
104 return '-esnext';
105 }
106 return '-' + typescript_1.ScriptTarget[scriptTarget].toLowerCase();
107}
108exports.getEsVersionForFileName = getEsVersionForFileName;
109function isPolyfillsEntry(name) {
110 return name === 'polyfills' || name === 'polyfills-es5';
111}
112exports.isPolyfillsEntry = isPolyfillsEntry;
113function getWatchOptions(poll) {
114 return {
115 poll,
116 ignored: poll === undefined ? '**/$_lazy_route_resources' : 'node_modules/**',
117 };
118}
119exports.getWatchOptions = getWatchOptions;
120function assetNameTemplateFactory(hashFormat) {
121 const visitedFiles = new Map();
122 return (resourcePath) => {
123 if (hashFormat.file) {
124 // File names are hashed therefore we don't need to handle files with the same file name.
125 return `[name]${hashFormat.file}.[ext]`;
126 }
127 const filename = path.basename(resourcePath);
128 // Check if the file with the same name has already been processed.
129 const visited = visitedFiles.get(filename);
130 if (!visited) {
131 // Not visited.
132 visitedFiles.set(filename, resourcePath);
133 return filename;
134 }
135 else if (visited === resourcePath) {
136 // Same file.
137 return filename;
138 }
139 // File has the same name but it's in a different location.
140 return '[path][name].[ext]';
141 };
142}
143exports.assetNameTemplateFactory = assetNameTemplateFactory;
Note: See TracBrowser for help on using the repository browser.