weboptimizer 2.0.1235 → 2.0.1237
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +20 -62
- package/configurator.js +53 -126
- package/ejsLoader.js +8 -52
- package/helper.js +53 -198
- package/index.js +31 -167
- package/jestEnvironmentBrowser.js +1 -12
- package/jestSetup.js +5 -7
- package/package.json +9 -2
- package/stylelintConfigurator.js +1 -6
- package/type.js +4 -4
- package/webpackConfigurator.js +99 -244
package/helper.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #!/usr/bin/env babel-node
|
|
2
2
|
// -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
3
|
/** @module helper */
|
|
5
4
|
'use strict';
|
|
5
|
+
|
|
6
6
|
/* !
|
|
7
7
|
region header
|
|
8
8
|
Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
|
|
@@ -16,64 +16,43 @@
|
|
|
16
16
|
endregion
|
|
17
17
|
*/
|
|
18
18
|
// region imports
|
|
19
|
-
|
|
20
19
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
21
|
-
|
|
22
20
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
23
|
-
|
|
24
21
|
Object.defineProperty(exports, "__esModule", {
|
|
25
22
|
value: true
|
|
26
23
|
});
|
|
27
24
|
exports["default"] = exports.KNOWN_FILE_EXTENSIONS = exports.Helper = void 0;
|
|
28
|
-
|
|
29
25
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
30
|
-
|
|
31
26
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
32
|
-
|
|
33
27
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
34
|
-
|
|
35
28
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
36
|
-
|
|
37
29
|
var _clientnode = _interopRequireWildcard(require("clientnode"));
|
|
38
|
-
|
|
39
30
|
var _fs = require("fs");
|
|
40
|
-
|
|
41
31
|
var _path = require("path");
|
|
42
|
-
|
|
43
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
44
|
-
|
|
45
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
46
|
-
|
|
47
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
48
|
-
|
|
49
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
50
|
-
|
|
51
36
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
52
|
-
|
|
53
37
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
54
|
-
|
|
55
38
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
56
|
-
|
|
57
39
|
// endregion
|
|
58
40
|
// region constants
|
|
59
|
-
var KNOWN_FILE_EXTENSIONS = ['js', 'ts', 'json', 'css', 'eot', 'gif', 'html', 'ico', 'jpg', 'png', 'ejs', 'svg', 'ttf', 'woff', '.woff2'];
|
|
41
|
+
var KNOWN_FILE_EXTENSIONS = ['js', 'ts', 'json', 'css', 'eot', 'gif', 'html', 'ico', 'jpg', 'png', 'ejs', 'svg', 'ttf', 'woff', '.woff2'];
|
|
42
|
+
// endregion
|
|
60
43
|
// region methods
|
|
61
|
-
|
|
62
44
|
/**
|
|
63
45
|
* Provides a class of static methods with generic use cases.
|
|
64
46
|
*/
|
|
65
|
-
|
|
66
47
|
exports.KNOWN_FILE_EXTENSIONS = KNOWN_FILE_EXTENSIONS;
|
|
67
|
-
|
|
68
48
|
var Helper = /*#__PURE__*/function () {
|
|
69
49
|
function Helper() {
|
|
70
50
|
(0, _classCallCheck2["default"])(this, Helper);
|
|
71
51
|
}
|
|
72
|
-
|
|
73
52
|
(0, _createClass2["default"])(Helper, null, [{
|
|
74
53
|
key: "isFilePathInLocation",
|
|
75
|
-
value:
|
|
76
|
-
|
|
54
|
+
value:
|
|
55
|
+
// region boolean
|
|
77
56
|
/**
|
|
78
57
|
* Determines whether given file path is within given list of file
|
|
79
58
|
* locations.
|
|
@@ -86,8 +65,7 @@ var Helper = /*#__PURE__*/function () {
|
|
|
86
65
|
*/
|
|
87
66
|
function isFilePathInLocation(filePath, locationsToCheck) {
|
|
88
67
|
var _iterator = _createForOfIteratorHelper(locationsToCheck),
|
|
89
|
-
|
|
90
|
-
|
|
68
|
+
_step;
|
|
91
69
|
try {
|
|
92
70
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
71
|
var pathToCheck = _step.value;
|
|
@@ -98,11 +76,10 @@ var Helper = /*#__PURE__*/function () {
|
|
|
98
76
|
} finally {
|
|
99
77
|
_iterator.f();
|
|
100
78
|
}
|
|
101
|
-
|
|
102
79
|
return false;
|
|
103
|
-
}
|
|
80
|
+
}
|
|
81
|
+
// endregion
|
|
104
82
|
// region string
|
|
105
|
-
|
|
106
83
|
/**
|
|
107
84
|
* Strips loader informations form given module request including loader
|
|
108
85
|
* prefix and query parameter.
|
|
@@ -111,15 +88,14 @@ var Helper = /*#__PURE__*/function () {
|
|
|
111
88
|
*
|
|
112
89
|
* @returns Given module id stripped.
|
|
113
90
|
*/
|
|
114
|
-
|
|
115
91
|
}, {
|
|
116
92
|
key: "stripLoader",
|
|
117
93
|
value: function stripLoader(moduleID) {
|
|
118
94
|
var moduleIDWithoutLoader = moduleID.substring(moduleID.lastIndexOf('!') + 1).replace(/\.webpack\[.+\/.+\]$/, '');
|
|
119
95
|
return moduleIDWithoutLoader.includes('?') ? moduleIDWithoutLoader.substring(0, moduleIDWithoutLoader.indexOf('?')) : moduleIDWithoutLoader;
|
|
120
|
-
}
|
|
96
|
+
}
|
|
97
|
+
// endregion
|
|
121
98
|
// region array
|
|
122
|
-
|
|
123
99
|
/**
|
|
124
100
|
* Converts given list of path to a normalized list with unique values.
|
|
125
101
|
* @param this - Indicates an unbound method.
|
|
@@ -127,7 +103,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
127
103
|
*
|
|
128
104
|
* @returns The given file path list with normalized unique values.
|
|
129
105
|
*/
|
|
130
|
-
|
|
131
106
|
}, {
|
|
132
107
|
key: "normalizePaths",
|
|
133
108
|
value: function normalizePaths(paths) {
|
|
@@ -136,9 +111,9 @@ var Helper = /*#__PURE__*/function () {
|
|
|
136
111
|
if (givenPath.endsWith('/')) return givenPath.substring(0, givenPath.length - 1);
|
|
137
112
|
return givenPath;
|
|
138
113
|
})));
|
|
139
|
-
}
|
|
114
|
+
}
|
|
115
|
+
// endregion
|
|
140
116
|
// region file handler
|
|
141
|
-
|
|
142
117
|
/**
|
|
143
118
|
* Applies file path/name placeholder replacements with given bundle
|
|
144
119
|
* associated informations.
|
|
@@ -148,7 +123,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
148
123
|
*
|
|
149
124
|
* @returns Processed file path.
|
|
150
125
|
*/
|
|
151
|
-
|
|
152
126
|
}, {
|
|
153
127
|
key: "renderFilePathTemplate",
|
|
154
128
|
value: function renderFilePathTemplate(template) {
|
|
@@ -161,15 +135,12 @@ var Helper = /*#__PURE__*/function () {
|
|
|
161
135
|
'[name]': '.__dummy__'
|
|
162
136
|
}, scope);
|
|
163
137
|
var filePath = template;
|
|
164
|
-
|
|
165
138
|
for (var _i = 0, _Object$entries = Object.entries(scope); _i < _Object$entries.length; _i++) {
|
|
166
139
|
var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
placeholderName = _Object$entries$_i[0],
|
|
141
|
+
value = _Object$entries$_i[1];
|
|
170
142
|
filePath = filePath.replace(new RegExp(_clientnode["default"].stringEscapeRegularExpressions(placeholderName), 'g'), "".concat(value));
|
|
171
143
|
}
|
|
172
|
-
|
|
173
144
|
return filePath;
|
|
174
145
|
}
|
|
175
146
|
/**
|
|
@@ -187,7 +158,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
187
158
|
*
|
|
188
159
|
* @returns A new resolved request.
|
|
189
160
|
*/
|
|
190
|
-
|
|
191
161
|
}, {
|
|
192
162
|
key: "applyContext",
|
|
193
163
|
value: function applyContext(request) {
|
|
@@ -197,18 +167,14 @@ var Helper = /*#__PURE__*/function () {
|
|
|
197
167
|
var moduleReplacements = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
198
168
|
var relativeModuleLocations = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ['node_modules'];
|
|
199
169
|
referencePath = (0, _path.resolve)(referencePath);
|
|
200
|
-
|
|
201
170
|
if (request.startsWith('./') && (0, _path.resolve)(context) !== referencePath) {
|
|
202
171
|
request = (0, _path.resolve)(context, request);
|
|
203
|
-
|
|
204
172
|
var _iterator2 = _createForOfIteratorHelper(relativeModuleLocations),
|
|
205
|
-
|
|
206
|
-
|
|
173
|
+
_step2;
|
|
207
174
|
try {
|
|
208
175
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
209
176
|
var modulePath = _step2.value;
|
|
210
177
|
var pathPrefix = (0, _path.resolve)(referencePath, modulePath);
|
|
211
|
-
|
|
212
178
|
if (request.startsWith(pathPrefix)) {
|
|
213
179
|
request = request.substring(pathPrefix.length);
|
|
214
180
|
if (request.startsWith('/')) request = request.substring(1);
|
|
@@ -220,14 +186,12 @@ var Helper = /*#__PURE__*/function () {
|
|
|
220
186
|
} finally {
|
|
221
187
|
_iterator2.f();
|
|
222
188
|
}
|
|
223
|
-
|
|
224
189
|
if (request.startsWith(referencePath)) {
|
|
225
190
|
request = request.substring(referencePath.length);
|
|
226
191
|
if (request.startsWith('/')) request = request.substring(1);
|
|
227
192
|
return Helper.applyModuleReplacements(Helper.applyAliases(request.substring(request.lastIndexOf('!') + 1), aliases), moduleReplacements);
|
|
228
193
|
}
|
|
229
194
|
}
|
|
230
|
-
|
|
231
195
|
return request;
|
|
232
196
|
}
|
|
233
197
|
/**
|
|
@@ -270,7 +234,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
270
234
|
* @returns A new resolved request indicating whether given request is an
|
|
271
235
|
* external one.
|
|
272
236
|
*/
|
|
273
|
-
|
|
274
237
|
}, {
|
|
275
238
|
key: "determineExternalRequest",
|
|
276
239
|
value: function determineExternalRequest(request) {
|
|
@@ -301,15 +264,14 @@ var Helper = /*#__PURE__*/function () {
|
|
|
301
264
|
var encoding = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : 'utf-8';
|
|
302
265
|
context = (0, _path.resolve)(context);
|
|
303
266
|
requestContext = (0, _path.resolve)(requestContext);
|
|
304
|
-
referencePath = (0, _path.resolve)(referencePath);
|
|
305
|
-
|
|
267
|
+
referencePath = (0, _path.resolve)(referencePath);
|
|
268
|
+
// NOTE: We apply alias on externals additionally.
|
|
306
269
|
var resolvedRequest = Helper.applyModuleReplacements(Helper.applyAliases(request.substring(request.lastIndexOf('!') + 1), aliases), moduleReplacements);
|
|
307
270
|
if (resolvedRequest === false || _clientnode["default"].isAnyMatching(resolvedRequest, excludePattern)) return null;
|
|
308
271
|
/*
|
|
309
272
|
NOTE: Aliases and module replacements doesn't have to be forwarded
|
|
310
273
|
since we pass an already resolved request.
|
|
311
274
|
*/
|
|
312
|
-
|
|
313
275
|
var filePath = Helper.determineModuleFilePath(resolvedRequest, {}, {}, {
|
|
314
276
|
file: extensions.file.external
|
|
315
277
|
}, context, requestContext, pathsToIgnore, relativeModuleLocations, packageEntryFileNames, packageMainPropertyNames, packageAliasPropertyNames, encoding);
|
|
@@ -317,15 +279,11 @@ var Helper = /*#__PURE__*/function () {
|
|
|
317
279
|
NOTE: We mark dependencies as external if there file couldn't be
|
|
318
280
|
resolved or are specified to be external explicitly.
|
|
319
281
|
*/
|
|
320
|
-
|
|
321
282
|
if (!(filePath || inPlaceNormalLibrary) || _clientnode["default"].isAnyMatching(resolvedRequest, includePattern)) return Helper.applyContext(resolvedRequest, requestContext, referencePath, aliases, moduleReplacements, relativeModuleLocations) || null;
|
|
322
|
-
|
|
323
283
|
for (var _i2 = 0, _Object$values = Object.values(normalizedGivenInjection); _i2 < _Object$values.length; _i2++) {
|
|
324
284
|
var chunk = _Object$values[_i2];
|
|
325
|
-
|
|
326
285
|
var _iterator3 = _createForOfIteratorHelper(chunk),
|
|
327
|
-
|
|
328
|
-
|
|
286
|
+
_step3;
|
|
329
287
|
try {
|
|
330
288
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
331
289
|
var moduleID = _step3.value;
|
|
@@ -339,14 +297,11 @@ var Helper = /*#__PURE__*/function () {
|
|
|
339
297
|
_iterator3.f();
|
|
340
298
|
}
|
|
341
299
|
}
|
|
342
|
-
|
|
343
300
|
var parts = context.split('/');
|
|
344
301
|
var externalModuleLocations = [];
|
|
345
|
-
|
|
346
302
|
while (parts.length > 0) {
|
|
347
303
|
var _iterator4 = _createForOfIteratorHelper(relativeExternalModuleLocations),
|
|
348
|
-
|
|
349
|
-
|
|
304
|
+
_step4;
|
|
350
305
|
try {
|
|
351
306
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
352
307
|
var relativePath = _step4.value;
|
|
@@ -357,7 +312,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
357
312
|
} finally {
|
|
358
313
|
_iterator4.f();
|
|
359
314
|
}
|
|
360
|
-
|
|
361
315
|
parts.splice(-1, 1);
|
|
362
316
|
}
|
|
363
317
|
/*
|
|
@@ -365,8 +319,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
365
319
|
loader in their request and aren't part of the current main package
|
|
366
320
|
or have a file extension other than javaScript aware.
|
|
367
321
|
*/
|
|
368
|
-
|
|
369
|
-
|
|
370
322
|
if (!inPlaceNormalLibrary && (extensions.file.external.length === 0 || filePath && extensions.file.external.includes((0, _path.extname)(filePath)) || !filePath && extensions.file.external.includes('')) && !(inPlaceDynamicLibrary && request.includes('!')) && (!filePath && inPlaceDynamicLibrary || filePath && (!filePath.startsWith(context) || Helper.isFilePathInLocation(filePath, externalModuleLocations)))) return Helper.applyContext(resolvedRequest, requestContext, referencePath, aliases, moduleReplacements, relativeModuleLocations) || null;
|
|
371
323
|
return null;
|
|
372
324
|
}
|
|
@@ -382,27 +334,22 @@ var Helper = /*#__PURE__*/function () {
|
|
|
382
334
|
* @returns Determined file type or "null" of given file couldn't be
|
|
383
335
|
* determined.
|
|
384
336
|
*/
|
|
385
|
-
|
|
386
337
|
}, {
|
|
387
338
|
key: "determineAssetType",
|
|
388
339
|
value: function determineAssetType(filePath, buildConfiguration, paths) {
|
|
389
340
|
var result = null;
|
|
390
|
-
|
|
391
341
|
for (var type in buildConfiguration) {
|
|
392
342
|
if ((0, _path.extname)(filePath) === ".".concat(buildConfiguration[type].extension)) {
|
|
393
343
|
result = type;
|
|
394
344
|
break;
|
|
395
345
|
}
|
|
396
346
|
}
|
|
397
|
-
|
|
398
347
|
if (!result) for (var _i3 = 0, _arr = [paths.source, paths.target]; _i3 < _arr.length; _i3++) {
|
|
399
348
|
var _type = _arr[_i3];
|
|
400
|
-
|
|
401
349
|
for (var _i4 = 0, _Object$entries2 = Object.entries(_type.asset); _i4 < _Object$entries2.length; _i4++) {
|
|
402
350
|
var _Object$entries2$_i = (0, _slicedToArray2["default"])(_Object$entries2[_i4], 2),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
351
|
+
assetType = _Object$entries2$_i[0],
|
|
352
|
+
assetConfiguration = _Object$entries2$_i[1];
|
|
406
353
|
if (assetType !== 'base' && assetConfiguration && filePath.startsWith(assetConfiguration)) return assetType;
|
|
407
354
|
}
|
|
408
355
|
}
|
|
@@ -421,7 +368,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
421
368
|
*
|
|
422
369
|
* @returns Converted build configuration.
|
|
423
370
|
*/
|
|
424
|
-
|
|
425
371
|
}, {
|
|
426
372
|
key: "resolveBuildConfigurationFilePaths",
|
|
427
373
|
value: function resolveBuildConfigurationFilePaths(configuration) {
|
|
@@ -429,23 +375,18 @@ var Helper = /*#__PURE__*/function () {
|
|
|
429
375
|
var pathsToIgnore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['.git'];
|
|
430
376
|
var mainFileBasenames = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ['index', 'main'];
|
|
431
377
|
var buildConfiguration = [];
|
|
432
|
-
|
|
433
378
|
for (var _i5 = 0, _Object$values2 = Object.values(configuration); _i5 < _Object$values2.length; _i5++) {
|
|
434
379
|
var value = _Object$values2[_i5];
|
|
435
|
-
|
|
436
380
|
var newItem = _clientnode["default"].extend(true, {
|
|
437
381
|
filePaths: []
|
|
438
382
|
}, value);
|
|
439
|
-
|
|
440
383
|
var _iterator5 = _createForOfIteratorHelper(_clientnode["default"].walkDirectoryRecursivelySync(entryPath, function (file) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
384
|
+
if (Helper.isFilePathInLocation(file.path, pathsToIgnore)) return false;
|
|
385
|
+
})),
|
|
386
|
+
_step5;
|
|
445
387
|
try {
|
|
446
388
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
447
389
|
var _file$stats;
|
|
448
|
-
|
|
449
390
|
var file = _step5.value;
|
|
450
391
|
if ((_file$stats = file.stats) !== null && _file$stats !== void 0 && _file$stats.isFile() && file.path.endsWith(".".concat(newItem.extension)) && !(newItem.ignoredExtension && file.path.endsWith(".".concat(newItem.ignoredExtension))) && !new RegExp(newItem.filePathPattern).test(file.path)) newItem.filePaths.push(file.path);
|
|
451
392
|
}
|
|
@@ -454,24 +395,20 @@ var Helper = /*#__PURE__*/function () {
|
|
|
454
395
|
} finally {
|
|
455
396
|
_iterator5.f();
|
|
456
397
|
}
|
|
457
|
-
|
|
458
398
|
newItem.filePaths.sort(function (firstFilePath, secondFilePath) {
|
|
459
399
|
if (mainFileBasenames.includes((0, _path.basename)(firstFilePath, (0, _path.extname)(firstFilePath)))) {
|
|
460
400
|
if (mainFileBasenames.includes((0, _path.basename)(secondFilePath, (0, _path.extname)(secondFilePath)))) return 0;
|
|
461
401
|
} else if (mainFileBasenames.includes((0, _path.basename)(secondFilePath, (0, _path.extname)(secondFilePath)))) return 1;
|
|
462
|
-
|
|
463
402
|
return 0;
|
|
464
403
|
});
|
|
465
404
|
buildConfiguration.push(newItem);
|
|
466
405
|
}
|
|
467
|
-
|
|
468
406
|
return buildConfiguration.sort(function (first, second) {
|
|
469
407
|
if (first.outputExtension !== second.outputExtension) {
|
|
470
408
|
if (first.outputExtension === 'js') return -1;
|
|
471
409
|
if (second.outputExtension === 'js') return 1;
|
|
472
410
|
return first.outputExtension < second.outputExtension ? -1 : 1;
|
|
473
411
|
}
|
|
474
|
-
|
|
475
412
|
return 0;
|
|
476
413
|
});
|
|
477
414
|
}
|
|
@@ -502,7 +439,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
502
439
|
* @returns Object with a file path and directory path key mapping to
|
|
503
440
|
* corresponding list of paths.
|
|
504
441
|
*/
|
|
505
|
-
|
|
506
442
|
}, {
|
|
507
443
|
key: "determineModuleLocations",
|
|
508
444
|
value: function determineModuleLocations(givenInjection) {
|
|
@@ -524,18 +460,14 @@ var Helper = /*#__PURE__*/function () {
|
|
|
524
460
|
var filePaths = [];
|
|
525
461
|
var directoryPaths = [];
|
|
526
462
|
var normalizedGivenInjection = Helper.resolveModulesInFolders(Helper.normalizeGivenInjection(givenInjection), aliases, moduleReplacements, context, referencePath, pathsToIgnore);
|
|
527
|
-
|
|
528
463
|
for (var _i6 = 0, _Object$values3 = Object.values(normalizedGivenInjection); _i6 < _Object$values3.length; _i6++) {
|
|
529
464
|
var chunk = _Object$values3[_i6];
|
|
530
|
-
|
|
531
465
|
var _iterator6 = _createForOfIteratorHelper(chunk),
|
|
532
|
-
|
|
533
|
-
|
|
466
|
+
_step6;
|
|
534
467
|
try {
|
|
535
468
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
536
469
|
var moduleID = _step6.value;
|
|
537
470
|
var filePath = Helper.determineModuleFilePath(moduleID, aliases, moduleReplacements, extensions, context, referencePath, pathsToIgnore, relativeModuleLocations, packageEntryFileNames, packageMainPropertyNames, packageAliasPropertyNames, encoding);
|
|
538
|
-
|
|
539
471
|
if (filePath) {
|
|
540
472
|
filePaths.push(filePath);
|
|
541
473
|
var directoryPath = (0, _path.dirname)(filePath);
|
|
@@ -548,7 +480,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
548
480
|
_iterator6.f();
|
|
549
481
|
}
|
|
550
482
|
}
|
|
551
|
-
|
|
552
483
|
return {
|
|
553
484
|
filePaths: filePaths,
|
|
554
485
|
directoryPaths: directoryPaths
|
|
@@ -569,7 +500,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
569
500
|
*
|
|
570
501
|
* @returns Given injections with resolved folder pointing modules.
|
|
571
502
|
*/
|
|
572
|
-
|
|
573
503
|
}, {
|
|
574
504
|
key: "resolveModulesInFolders",
|
|
575
505
|
value: function resolveModulesInFolders(normalizedGivenInjection) {
|
|
@@ -579,38 +509,29 @@ var Helper = /*#__PURE__*/function () {
|
|
|
579
509
|
var referencePath = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
|
|
580
510
|
var pathsToIgnore = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ['.git'];
|
|
581
511
|
if (referencePath.startsWith('/')) referencePath = (0, _path.relative)(context, referencePath);
|
|
582
|
-
|
|
583
512
|
for (var _i7 = 0, _Object$values4 = Object.values(normalizedGivenInjection); _i7 < _Object$values4.length; _i7++) {
|
|
584
513
|
var chunk = _Object$values4[_i7];
|
|
585
514
|
var index = 0;
|
|
586
|
-
|
|
587
515
|
var _iterator7 = _createForOfIteratorHelper(chunk),
|
|
588
|
-
|
|
589
|
-
|
|
516
|
+
_step7;
|
|
590
517
|
try {
|
|
591
518
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
592
519
|
var moduleID = _step7.value;
|
|
593
520
|
var resolvedModuleID = Helper.applyModuleReplacements(Helper.applyAliases(Helper.stripLoader(moduleID), aliases), moduleReplacements);
|
|
594
|
-
|
|
595
521
|
if (resolvedModuleID === false) {
|
|
596
522
|
chunk.splice(index, 1);
|
|
597
523
|
continue;
|
|
598
524
|
}
|
|
599
|
-
|
|
600
525
|
var resolvedPath = (0, _path.resolve)(referencePath, resolvedModuleID);
|
|
601
|
-
|
|
602
526
|
if (_clientnode["default"].isDirectorySync(resolvedPath)) {
|
|
603
527
|
chunk.splice(index, 1);
|
|
604
|
-
|
|
605
528
|
var _iterator8 = _createForOfIteratorHelper(_clientnode["default"].walkDirectoryRecursivelySync(resolvedPath, function (file) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
529
|
+
if (Helper.isFilePathInLocation(file.path, pathsToIgnore)) return false;
|
|
530
|
+
})),
|
|
531
|
+
_step8;
|
|
610
532
|
try {
|
|
611
533
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
612
534
|
var _file$stats2;
|
|
613
|
-
|
|
614
535
|
var file = _step8.value;
|
|
615
536
|
if ((_file$stats2 = file.stats) !== null && _file$stats2 !== void 0 && _file$stats2.isFile()) chunk.push('./' + (0, _path.relative)(context, (0, _path.resolve)(resolvedPath, file.path)));
|
|
616
537
|
}
|
|
@@ -620,7 +541,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
620
541
|
_iterator8.f();
|
|
621
542
|
}
|
|
622
543
|
} else if (resolvedModuleID.startsWith('./') && !resolvedModuleID.startsWith("./".concat((0, _path.relative)(context, referencePath)))) chunk[index] = "./".concat((0, _path.relative)(context, resolvedPath));
|
|
623
|
-
|
|
624
544
|
index += 1;
|
|
625
545
|
}
|
|
626
546
|
} catch (err) {
|
|
@@ -629,7 +549,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
629
549
|
_iterator7.f();
|
|
630
550
|
}
|
|
631
551
|
}
|
|
632
|
-
|
|
633
552
|
return normalizedGivenInjection;
|
|
634
553
|
}
|
|
635
554
|
/**
|
|
@@ -641,7 +560,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
641
560
|
*
|
|
642
561
|
* @returns Normalized representation of given entry injection.
|
|
643
562
|
*/
|
|
644
|
-
|
|
645
563
|
}, {
|
|
646
564
|
key: "normalizeGivenInjection",
|
|
647
565
|
value: function normalizeGivenInjection(givenInjection) {
|
|
@@ -653,12 +571,10 @@ var Helper = /*#__PURE__*/function () {
|
|
|
653
571
|
};else if (_clientnode["default"].isPlainObject(givenInjection)) {
|
|
654
572
|
var hasContent = false;
|
|
655
573
|
var chunkNamesToDelete = [];
|
|
656
|
-
|
|
657
574
|
for (var _i8 = 0, _Object$entries3 = Object.entries(givenInjection); _i8 < _Object$entries3.length; _i8++) {
|
|
658
575
|
var _Object$entries3$_i = (0, _slicedToArray2["default"])(_Object$entries3[_i8], 2),
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
576
|
+
chunkName = _Object$entries3$_i[0],
|
|
577
|
+
chunk = _Object$entries3$_i[1];
|
|
662
578
|
if (Array.isArray(chunk)) {
|
|
663
579
|
if (chunk.length > 0) {
|
|
664
580
|
hasContent = true;
|
|
@@ -669,11 +585,9 @@ var Helper = /*#__PURE__*/function () {
|
|
|
669
585
|
result[chunkName] = [chunk];
|
|
670
586
|
}
|
|
671
587
|
}
|
|
672
|
-
|
|
673
588
|
if (hasContent) {
|
|
674
589
|
var _iterator9 = _createForOfIteratorHelper(chunkNamesToDelete),
|
|
675
|
-
|
|
676
|
-
|
|
590
|
+
_step9;
|
|
677
591
|
try {
|
|
678
592
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
679
593
|
var _chunkName = _step9.value;
|
|
@@ -709,7 +623,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
709
623
|
*
|
|
710
624
|
* @returns Given injection with resolved marked indicators.
|
|
711
625
|
*/
|
|
712
|
-
|
|
713
626
|
}, {
|
|
714
627
|
key: "resolveAutoInjection",
|
|
715
628
|
value: function resolveAutoInjection(givenInjection, buildConfigurations) {
|
|
@@ -726,32 +639,25 @@ var Helper = /*#__PURE__*/function () {
|
|
|
726
639
|
var context = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : './';
|
|
727
640
|
var referencePath = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
|
|
728
641
|
var pathsToIgnore = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : ['.git'];
|
|
729
|
-
|
|
730
642
|
var injection = _clientnode["default"].copy(givenInjection);
|
|
731
|
-
|
|
732
643
|
var moduleFilePathsToExclude = Helper.determineModuleLocations(givenInjection.autoExclude, aliases, moduleReplacements, {
|
|
733
644
|
file: extensions.file.internal
|
|
734
645
|
}, context, referencePath, pathsToIgnore).filePaths;
|
|
735
|
-
|
|
736
646
|
var _iterator10 = _createForOfIteratorHelper(['entry', 'external']),
|
|
737
|
-
|
|
738
|
-
|
|
647
|
+
_step10;
|
|
739
648
|
try {
|
|
740
649
|
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
741
650
|
var name = _step10.value;
|
|
742
651
|
var injectionType = injection[name];
|
|
743
652
|
/* eslint-disable curly */
|
|
744
|
-
|
|
745
653
|
if (_clientnode["default"].isPlainObject(injectionType)) {
|
|
746
654
|
for (var _i9 = 0, _Object$entries4 = Object.entries(injectionType); _i9 < _Object$entries4.length; _i9++) {
|
|
747
655
|
var _Object$entries4$_i = (0, _slicedToArray2["default"])(_Object$entries4[_i9], 2),
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
656
|
+
chunkName = _Object$entries4$_i[0],
|
|
657
|
+
chunk = _Object$entries4$_i[1];
|
|
751
658
|
if (chunk === '__auto__') {
|
|
752
659
|
chunk = injectionType[chunkName] = [];
|
|
753
660
|
var modules = Helper.getAutoInjection(buildConfigurations, moduleFilePathsToExclude, referencePath);
|
|
754
|
-
|
|
755
661
|
for (var _i10 = 0, _Object$values5 = Object.values(modules); _i10 < _Object$values5.length; _i10++) {
|
|
756
662
|
var subChunk = _Object$values5[_i10];
|
|
757
663
|
chunk.push(subChunk);
|
|
@@ -760,13 +666,10 @@ var Helper = /*#__PURE__*/function () {
|
|
|
760
666
|
Reverse array to let javaScript and main files be
|
|
761
667
|
the last ones to export them rather.
|
|
762
668
|
*/
|
|
763
|
-
|
|
764
|
-
|
|
765
669
|
chunk.reverse();
|
|
766
670
|
}
|
|
767
671
|
}
|
|
768
|
-
} else if (injectionType === '__auto__')
|
|
769
|
-
/* eslint-enable curly */
|
|
672
|
+
} else if (injectionType === '__auto__') /* eslint-enable curly */
|
|
770
673
|
injection[name] = Helper.getAutoInjection(buildConfigurations, moduleFilePathsToExclude, referencePath);
|
|
771
674
|
}
|
|
772
675
|
} catch (err) {
|
|
@@ -774,7 +677,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
774
677
|
} finally {
|
|
775
678
|
_iterator10.f();
|
|
776
679
|
}
|
|
777
|
-
|
|
778
680
|
return injection;
|
|
779
681
|
}
|
|
780
682
|
/**
|
|
@@ -788,39 +690,33 @@ var Helper = /*#__PURE__*/function () {
|
|
|
788
690
|
*
|
|
789
691
|
* @returns All determined module file paths.
|
|
790
692
|
*/
|
|
791
|
-
|
|
792
693
|
}, {
|
|
793
694
|
key: "getAutoInjection",
|
|
794
695
|
value: function getAutoInjection(buildConfigurations, moduleFilePathsToExclude, context) {
|
|
795
696
|
var result = {};
|
|
796
697
|
var injectedModuleIDs = {};
|
|
797
|
-
|
|
798
698
|
var _iterator11 = _createForOfIteratorHelper(buildConfigurations),
|
|
799
|
-
|
|
800
|
-
|
|
699
|
+
_step11;
|
|
801
700
|
try {
|
|
802
701
|
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
803
702
|
var buildConfiguration = _step11.value;
|
|
804
703
|
if (!injectedModuleIDs[buildConfiguration.outputExtension]) injectedModuleIDs[buildConfiguration.outputExtension] = [];
|
|
805
|
-
|
|
806
704
|
var _iterator12 = _createForOfIteratorHelper(buildConfiguration.filePaths),
|
|
807
|
-
|
|
808
|
-
|
|
705
|
+
_step12;
|
|
809
706
|
try {
|
|
810
707
|
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
811
708
|
var moduleFilePath = _step12.value;
|
|
812
|
-
|
|
813
709
|
if (!moduleFilePathsToExclude.includes(moduleFilePath)) {
|
|
814
710
|
var relativeModuleFilePath = "./".concat((0, _path.relative)(context, moduleFilePath));
|
|
815
711
|
var directoryPath = (0, _path.dirname)(relativeModuleFilePath);
|
|
816
712
|
var baseName = (0, _path.basename)(relativeModuleFilePath, ".".concat(buildConfiguration.extension));
|
|
817
713
|
var moduleID = baseName;
|
|
818
714
|
if (directoryPath !== '.') moduleID = (0, _path.join)(directoryPath, baseName);
|
|
715
|
+
|
|
819
716
|
/*
|
|
820
717
|
Ensure that each output type has only one source
|
|
821
718
|
representation.
|
|
822
719
|
*/
|
|
823
|
-
|
|
824
720
|
if (!injectedModuleIDs[buildConfiguration.outputExtension].includes(moduleID)) {
|
|
825
721
|
/*
|
|
826
722
|
Ensure that same module ids and different output
|
|
@@ -846,10 +742,9 @@ var Helper = /*#__PURE__*/function () {
|
|
|
846
742
|
} finally {
|
|
847
743
|
_iterator11.f();
|
|
848
744
|
}
|
|
849
|
-
|
|
850
745
|
return result;
|
|
851
|
-
}
|
|
852
|
-
|
|
746
|
+
}
|
|
747
|
+
// TODO test
|
|
853
748
|
/**
|
|
854
749
|
* Determines a resolved module file path in given package path.
|
|
855
750
|
* @param this - Indicates an unbound method.
|
|
@@ -862,7 +757,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
862
757
|
*
|
|
863
758
|
* @returns Path if found and / or additional package aliases to consider.
|
|
864
759
|
*/
|
|
865
|
-
|
|
866
760
|
}, {
|
|
867
761
|
key: "determineModuleFilePathInPackage",
|
|
868
762
|
value: function determineModuleFilePathInPackage(packagePath) {
|
|
@@ -873,13 +767,10 @@ var Helper = /*#__PURE__*/function () {
|
|
|
873
767
|
fileName: null,
|
|
874
768
|
packageAliases: null
|
|
875
769
|
};
|
|
876
|
-
|
|
877
770
|
if (_clientnode["default"].isDirectorySync(packagePath)) {
|
|
878
771
|
var pathToPackageJSON = (0, _path.resolve)(packagePath, 'package.json');
|
|
879
|
-
|
|
880
772
|
if (_clientnode["default"].isFileSync(pathToPackageJSON)) {
|
|
881
773
|
var localConfiguration = {};
|
|
882
|
-
|
|
883
774
|
try {
|
|
884
775
|
localConfiguration = JSON.parse((0, _fs.readFileSync)(pathToPackageJSON, {
|
|
885
776
|
encoding: encoding
|
|
@@ -887,14 +778,11 @@ var Helper = /*#__PURE__*/function () {
|
|
|
887
778
|
} catch (error) {
|
|
888
779
|
console.warn("Package configuration file \"".concat(pathToPackageJSON, "\" ") + "could not parsed: ".concat(_clientnode["default"].represent(error)));
|
|
889
780
|
}
|
|
890
|
-
|
|
891
781
|
var _iterator13 = _createForOfIteratorHelper(packageMainPropertyNames),
|
|
892
|
-
|
|
893
|
-
|
|
782
|
+
_step13;
|
|
894
783
|
try {
|
|
895
784
|
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
896
785
|
var propertyName = _step13.value;
|
|
897
|
-
|
|
898
786
|
if (Object.prototype.hasOwnProperty.call(localConfiguration, propertyName) && typeof localConfiguration[propertyName] === 'string' && localConfiguration[propertyName]) {
|
|
899
787
|
result.fileName = localConfiguration[propertyName];
|
|
900
788
|
break;
|
|
@@ -905,14 +793,11 @@ var Helper = /*#__PURE__*/function () {
|
|
|
905
793
|
} finally {
|
|
906
794
|
_iterator13.f();
|
|
907
795
|
}
|
|
908
|
-
|
|
909
796
|
var _iterator14 = _createForOfIteratorHelper(packageAliasPropertyNames),
|
|
910
|
-
|
|
911
|
-
|
|
797
|
+
_step14;
|
|
912
798
|
try {
|
|
913
799
|
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
914
800
|
var _propertyName = _step14.value;
|
|
915
|
-
|
|
916
801
|
if (Object.prototype.hasOwnProperty.call(localConfiguration, _propertyName) && _clientnode["default"].isPlainObject(localConfiguration[_propertyName])) {
|
|
917
802
|
result.packageAliases = localConfiguration[_propertyName];
|
|
918
803
|
break;
|
|
@@ -925,7 +810,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
925
810
|
}
|
|
926
811
|
}
|
|
927
812
|
}
|
|
928
|
-
|
|
929
813
|
return result;
|
|
930
814
|
}
|
|
931
815
|
/**
|
|
@@ -954,7 +838,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
954
838
|
* @returns File path or given module id if determinations has failed or
|
|
955
839
|
* wasn't necessary.
|
|
956
840
|
*/
|
|
957
|
-
|
|
958
841
|
}, {
|
|
959
842
|
key: "determineModuleFilePath",
|
|
960
843
|
value: function determineModuleFilePath(moduleID) {
|
|
@@ -983,11 +866,9 @@ var Helper = /*#__PURE__*/function () {
|
|
|
983
866
|
}));
|
|
984
867
|
var parts = context.split('/');
|
|
985
868
|
parts.splice(-1, 1);
|
|
986
|
-
|
|
987
869
|
while (parts.length > 0) {
|
|
988
870
|
var _iterator15 = _createForOfIteratorHelper(relativeModuleLocations),
|
|
989
|
-
|
|
990
|
-
|
|
871
|
+
_step15;
|
|
991
872
|
try {
|
|
992
873
|
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
993
874
|
var relativePath = _step15.value;
|
|
@@ -998,41 +879,32 @@ var Helper = /*#__PURE__*/function () {
|
|
|
998
879
|
} finally {
|
|
999
880
|
_iterator15.f();
|
|
1000
881
|
}
|
|
1001
|
-
|
|
1002
882
|
parts.splice(-1, 1);
|
|
1003
883
|
}
|
|
1004
|
-
|
|
1005
884
|
var _iterator16 = _createForOfIteratorHelper([referencePath].concat(moduleLocations)),
|
|
1006
|
-
|
|
1007
|
-
|
|
885
|
+
_step16;
|
|
1008
886
|
try {
|
|
1009
887
|
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1010
888
|
var moduleLocation = _step16.value;
|
|
1011
|
-
|
|
1012
889
|
var _iterator17 = _createForOfIteratorHelper(['', '__package__'].concat(packageEntryFileNames)),
|
|
1013
|
-
|
|
1014
|
-
|
|
890
|
+
_step17;
|
|
1015
891
|
try {
|
|
1016
892
|
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1017
893
|
var fileName = _step17.value;
|
|
1018
|
-
|
|
1019
894
|
var _iterator18 = _createForOfIteratorHelper([''].concat(extensions.file)),
|
|
1020
|
-
|
|
1021
|
-
|
|
895
|
+
_step18;
|
|
1022
896
|
try {
|
|
1023
897
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
1024
898
|
var fileExtension = _step18.value;
|
|
1025
899
|
var currentModuleFilePath = void 0;
|
|
1026
900
|
if (moduleFilePath.startsWith('/')) currentModuleFilePath = (0, _path.resolve)(moduleFilePath);else currentModuleFilePath = (0, _path.resolve)(moduleLocation, moduleFilePath);
|
|
1027
901
|
var packageAliases = {};
|
|
1028
|
-
|
|
1029
902
|
if (fileName === '__package__') {
|
|
1030
903
|
var result = Helper.determineModuleFilePathInPackage(currentModuleFilePath, packageMainPropertyNames, packageAliasPropertyNames, encoding);
|
|
1031
904
|
if (result.fileName) fileName = result.fileName;
|
|
1032
905
|
if (result.packageAliases) packageAliases = result.packageAliases;
|
|
1033
906
|
if (fileName === '__package__') continue;
|
|
1034
907
|
}
|
|
1035
|
-
|
|
1036
908
|
var resolvedFileName = Helper.applyModuleReplacements(Helper.applyAliases(fileName, packageAliases), moduleReplacements);
|
|
1037
909
|
if (resolvedFileName === false) continue;
|
|
1038
910
|
if (resolvedFileName) currentModuleFilePath = (0, _path.resolve)(currentModuleFilePath, "".concat(resolvedFileName).concat(fileExtension));else currentModuleFilePath += "".concat(resolvedFileName).concat(fileExtension);
|
|
@@ -1056,10 +928,9 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1056
928
|
} finally {
|
|
1057
929
|
_iterator16.f();
|
|
1058
930
|
}
|
|
1059
|
-
|
|
1060
931
|
return null;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
932
|
+
}
|
|
933
|
+
// endregion
|
|
1063
934
|
/**
|
|
1064
935
|
* Determines a concrete file path for given module id.
|
|
1065
936
|
* @param this - Indicates an unbound method.
|
|
@@ -1068,20 +939,17 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1068
939
|
*
|
|
1069
940
|
* @returns The alias applied given module id.
|
|
1070
941
|
*/
|
|
1071
|
-
|
|
1072
942
|
}, {
|
|
1073
943
|
key: "applyAliases",
|
|
1074
944
|
value: function applyAliases(moduleID, aliases) {
|
|
1075
945
|
for (var _i11 = 0, _Object$entries5 = Object.entries(aliases); _i11 < _Object$entries5.length; _i11++) {
|
|
1076
946
|
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i11], 2),
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
947
|
+
name = _Object$entries5$_i[0],
|
|
948
|
+
alias = _Object$entries5$_i[1];
|
|
1080
949
|
if (name.endsWith('$')) {
|
|
1081
950
|
if (moduleID === name.substring(0, name.length - 1)) moduleID = alias;
|
|
1082
951
|
} else if (typeof moduleID === 'string') moduleID = moduleID.replace(name, alias);
|
|
1083
952
|
}
|
|
1084
|
-
|
|
1085
953
|
return moduleID;
|
|
1086
954
|
}
|
|
1087
955
|
/**
|
|
@@ -1093,20 +961,16 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1093
961
|
*
|
|
1094
962
|
* @returns The replacement applied given module id.
|
|
1095
963
|
*/
|
|
1096
|
-
|
|
1097
964
|
}, {
|
|
1098
965
|
key: "applyModuleReplacements",
|
|
1099
966
|
value: function applyModuleReplacements(moduleID, replacements) {
|
|
1100
967
|
if (moduleID === false) return moduleID;
|
|
1101
|
-
|
|
1102
968
|
for (var _i12 = 0, _Object$entries6 = Object.entries(replacements); _i12 < _Object$entries6.length; _i12++) {
|
|
1103
969
|
var _Object$entries6$_i = (0, _slicedToArray2["default"])(_Object$entries6[_i12], 2),
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
970
|
+
search = _Object$entries6$_i[0],
|
|
971
|
+
replacement = _Object$entries6$_i[1];
|
|
1107
972
|
moduleID = moduleID.replace(new RegExp(search), replacement);
|
|
1108
973
|
}
|
|
1109
|
-
|
|
1110
974
|
return moduleID;
|
|
1111
975
|
}
|
|
1112
976
|
/**
|
|
@@ -1117,28 +981,23 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1117
981
|
*
|
|
1118
982
|
* @returns Determined file path.
|
|
1119
983
|
*/
|
|
1120
|
-
|
|
1121
984
|
}, {
|
|
1122
985
|
key: "findPackageDescriptorFilePath",
|
|
1123
986
|
value: function findPackageDescriptorFilePath(start) {
|
|
1124
987
|
var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'package.json';
|
|
1125
|
-
|
|
1126
988
|
if (typeof start === 'string') {
|
|
1127
989
|
if (!start.endsWith(_path.sep)) start += _path.sep;
|
|
1128
990
|
start = start.split(_path.sep);
|
|
1129
991
|
}
|
|
1130
|
-
|
|
1131
992
|
if (!start.length) return null;
|
|
1132
993
|
start.pop();
|
|
1133
994
|
var result = (0, _path.resolve)(start.join(_path.sep), fileName);
|
|
1134
|
-
|
|
1135
995
|
try {
|
|
1136
996
|
if ((0, _fs.existsSync)(result)) return result;
|
|
1137
997
|
/* eslint-disable no-empty */
|
|
1138
998
|
} catch (error) {}
|
|
1139
999
|
/* eslint-enable no-empty */
|
|
1140
1000
|
|
|
1141
|
-
|
|
1142
1001
|
return Helper.findPackageDescriptorFilePath(start, fileName);
|
|
1143
1002
|
}
|
|
1144
1003
|
/**
|
|
@@ -1152,7 +1011,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1152
1011
|
* @returns A object containing found parsed configuration an their
|
|
1153
1012
|
* corresponding file path.
|
|
1154
1013
|
*/
|
|
1155
|
-
|
|
1156
1014
|
}, {
|
|
1157
1015
|
key: "getClosestPackageDescriptor",
|
|
1158
1016
|
value: function getClosestPackageDescriptor(modulePath) {
|
|
@@ -1164,7 +1022,6 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1164
1022
|
If the package.json does not have a name property, try again from
|
|
1165
1023
|
one level higher.
|
|
1166
1024
|
*/
|
|
1167
|
-
|
|
1168
1025
|
if (!configuration.name) return Helper.getClosestPackageDescriptor((0, _path.resolve)((0, _path.dirname)(filePath), '..'), fileName);
|
|
1169
1026
|
if (!configuration.version) configuration.version = 'not set';
|
|
1170
1027
|
return {
|
|
@@ -1175,12 +1032,10 @@ var Helper = /*#__PURE__*/function () {
|
|
|
1175
1032
|
}]);
|
|
1176
1033
|
return Helper;
|
|
1177
1034
|
}();
|
|
1178
|
-
|
|
1179
1035
|
exports.Helper = Helper;
|
|
1180
1036
|
var _default = Helper; // endregion
|
|
1181
1037
|
// region vim modline
|
|
1182
1038
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
1183
1039
|
// vim: foldmethod=marker foldmarker=region,endregion:
|
|
1184
1040
|
// endregion
|
|
1185
|
-
|
|
1186
1041
|
exports["default"] = _default;
|