weboptimizer 2.0.1263 → 2.0.1264
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 +142 -146
- package/configurator.js +1 -1
- package/ejsLoader.js +1 -3
- package/helper.js +4 -6
- package/index.js +571 -546
- package/package.json +1 -1
- package/webpackConfigurator.js +85 -95
package/package.json
CHANGED
package/webpackConfigurator.js
CHANGED
|
@@ -45,7 +45,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
45
45
|
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; }
|
|
46
46
|
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; } } }; }
|
|
47
47
|
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); }
|
|
48
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
48
|
+
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; }
|
|
49
49
|
/// region optional imports
|
|
50
50
|
// NOTE: Has to be defined here to ensure to resolve from here.
|
|
51
51
|
var currentRequire =
|
|
@@ -268,17 +268,9 @@ if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenComm
|
|
|
268
268
|
|
|
269
269
|
// NOTE: Avoid if you still want to emit the runtime chunks:
|
|
270
270
|
hooks.afterEmit.tap('inPlaceHTMLAssets', function (asset) {
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
275
|
-
var _name3 = _step3.value;
|
|
276
|
-
delete compilation.assets[_name3];
|
|
277
|
-
}
|
|
278
|
-
} catch (err) {
|
|
279
|
-
_iterator3.e(err);
|
|
280
|
-
} finally {
|
|
281
|
-
_iterator3.f();
|
|
271
|
+
for (var _i6 = 0, _inPlacedAssetNames = inPlacedAssetNames; _i6 < _inPlacedAssetNames.length; _i6++) {
|
|
272
|
+
var _name3 = _inPlacedAssetNames[_i6];
|
|
273
|
+
delete compilation.assets[_name3];
|
|
282
274
|
}
|
|
283
275
|
return asset;
|
|
284
276
|
});
|
|
@@ -310,11 +302,11 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
310
302
|
if (typeof request !== 'string') return callback();
|
|
311
303
|
request = request.replace(/^!+/, '');
|
|
312
304
|
if (request.startsWith('/')) request = (0, _path.relative)(configuration.path.context, request);
|
|
313
|
-
var
|
|
314
|
-
|
|
305
|
+
var _iterator3 = _createForOfIteratorHelper(_module.directoryNames),
|
|
306
|
+
_step3;
|
|
315
307
|
try {
|
|
316
|
-
for (
|
|
317
|
-
var _filePath =
|
|
308
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
309
|
+
var _filePath = _step3.value;
|
|
318
310
|
if (request.startsWith(_filePath)) {
|
|
319
311
|
request = request.substring(_filePath.length);
|
|
320
312
|
if (request.startsWith('/')) request = request.substring(1);
|
|
@@ -323,15 +315,15 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
323
315
|
}
|
|
324
316
|
// region pattern based aliasing
|
|
325
317
|
} catch (err) {
|
|
326
|
-
|
|
318
|
+
_iterator3.e(err);
|
|
327
319
|
} finally {
|
|
328
|
-
|
|
320
|
+
_iterator3.f();
|
|
329
321
|
}
|
|
330
322
|
var filePath = _helper["default"].determineModuleFilePath(request, {}, {}, {
|
|
331
323
|
file: configuration.extensions.file.external
|
|
332
324
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
333
|
-
if (filePath) for (var
|
|
334
|
-
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[
|
|
325
|
+
if (filePath) for (var _i7 = 0, _Object$entries5 = Object.entries(configuration.injection.external.aliases); _i7 < _Object$entries5.length; _i7++) {
|
|
326
|
+
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i7], 2),
|
|
335
327
|
pattern = _Object$entries5$_i[0],
|
|
336
328
|
targetConfiguration = _Object$entries5$_i[1];
|
|
337
329
|
if (pattern.startsWith('^')) {
|
|
@@ -367,44 +359,44 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
367
359
|
"default": request
|
|
368
360
|
};
|
|
369
361
|
if (typeof configuration.injection.external.aliases[request] === 'string') {
|
|
370
|
-
var
|
|
371
|
-
|
|
362
|
+
var _iterator4 = _createForOfIteratorHelper(keys),
|
|
363
|
+
_step4;
|
|
372
364
|
try {
|
|
373
|
-
for (
|
|
374
|
-
var key =
|
|
365
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
366
|
+
var key = _step4.value;
|
|
375
367
|
result[key] = configuration.injection.external.aliases[request];
|
|
376
368
|
}
|
|
377
369
|
} catch (err) {
|
|
378
|
-
|
|
370
|
+
_iterator4.e(err);
|
|
379
371
|
} finally {
|
|
380
|
-
|
|
372
|
+
_iterator4.f();
|
|
381
373
|
}
|
|
382
374
|
} else if (typeof configuration.injection.external.aliases[request] === 'function') {
|
|
383
|
-
var
|
|
384
|
-
|
|
375
|
+
var _iterator5 = _createForOfIteratorHelper(keys),
|
|
376
|
+
_step5;
|
|
385
377
|
try {
|
|
386
|
-
for (
|
|
387
|
-
var _key2 =
|
|
378
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
379
|
+
var _key2 = _step5.value;
|
|
388
380
|
result[_key2] = configuration.injection.external.aliases[request](request, _key2);
|
|
389
381
|
}
|
|
390
382
|
} catch (err) {
|
|
391
|
-
|
|
383
|
+
_iterator5.e(err);
|
|
392
384
|
} finally {
|
|
393
|
-
|
|
385
|
+
_iterator5.f();
|
|
394
386
|
}
|
|
395
387
|
} else if (configuration.injection.external.aliases[request] !== null && (0, _typeof2["default"])(configuration.injection.external.aliases[request]) === 'object') _clientnode["default"].extend(result, configuration.injection.external.aliases[request]);
|
|
396
388
|
if (Object.prototype.hasOwnProperty.call(result, 'default')) {
|
|
397
|
-
var
|
|
398
|
-
|
|
389
|
+
var _iterator6 = _createForOfIteratorHelper(keys),
|
|
390
|
+
_step6;
|
|
399
391
|
try {
|
|
400
|
-
for (
|
|
401
|
-
var _key3 =
|
|
392
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
393
|
+
var _key3 = _step6.value;
|
|
402
394
|
if (!Object.prototype.hasOwnProperty.call(result, _key3)) result[_key3] = result["default"];
|
|
403
395
|
}
|
|
404
396
|
} catch (err) {
|
|
405
|
-
|
|
397
|
+
_iterator6.e(err);
|
|
406
398
|
} finally {
|
|
407
|
-
|
|
399
|
+
_iterator6.f();
|
|
408
400
|
}
|
|
409
401
|
}
|
|
410
402
|
// endregion
|
|
@@ -450,12 +442,12 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
450
442
|
link: 'href',
|
|
451
443
|
script: 'src'
|
|
452
444
|
};
|
|
453
|
-
for (var
|
|
454
|
-
var _Object$entries6$_i = (0, _slicedToArray2["default"])(_Object$entries6[
|
|
445
|
+
for (var _i8 = 0, _Object$entries6 = Object.entries(linkables); _i8 < _Object$entries6.length; _i8++) {
|
|
446
|
+
var _Object$entries6$_i = (0, _slicedToArray2["default"])(_Object$entries6[_i8], 2),
|
|
455
447
|
tagName = _Object$entries6$_i[0],
|
|
456
448
|
attributeName = _Object$entries6$_i[1];
|
|
457
|
-
for (var
|
|
458
|
-
var domNode = _Array$from[
|
|
449
|
+
for (var _i9 = 0, _Array$from = Array.from(dom.window.document.querySelectorAll("".concat(tagName, "[").concat(attributeName, "*=\"?") + "".concat(configuration.hashAlgorithm, "=\"]"))); _i9 < _Array$from.length; _i9++) {
|
|
450
|
+
var domNode = _Array$from[_i9];
|
|
459
451
|
/*
|
|
460
452
|
NOTE: Removing symbols after a "&" in hash
|
|
461
453
|
string is necessary to match the generated
|
|
@@ -472,35 +464,35 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
472
464
|
return "".concat(startTag).concat(styleContents.shift()) + endTag;
|
|
473
465
|
});
|
|
474
466
|
// region post compilation
|
|
475
|
-
var
|
|
476
|
-
|
|
467
|
+
var _iterator7 = _createForOfIteratorHelper(configuration.files.html),
|
|
468
|
+
_step7;
|
|
477
469
|
try {
|
|
478
|
-
for (
|
|
479
|
-
var htmlFileSpecification =
|
|
470
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
471
|
+
var htmlFileSpecification = _step7.value;
|
|
480
472
|
if (htmlFileSpecification.filename === data.plugin.options.filename) {
|
|
481
|
-
var
|
|
482
|
-
|
|
473
|
+
var _iterator8 = _createForOfIteratorHelper([].concat(htmlFileSpecification.template.use)),
|
|
474
|
+
_step8;
|
|
483
475
|
try {
|
|
484
|
-
for (
|
|
476
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
485
477
|
var _loaderConfiguration$;
|
|
486
|
-
var loaderConfiguration =
|
|
478
|
+
var loaderConfiguration = _step8.value;
|
|
487
479
|
if ((_loaderConfiguration$ = loaderConfiguration.options) !== null && _loaderConfiguration$ !== void 0 && _loaderConfiguration$.compileSteps && typeof loaderConfiguration.options.compileSteps === 'number') data.html = _ejsLoader["default"].bind({
|
|
488
480
|
query: _clientnode["default"].extend(true, _clientnode["default"].copy(loaderConfiguration.options) || {}, htmlFileSpecification.template.postCompileOptions)
|
|
489
481
|
})(data.html);
|
|
490
482
|
}
|
|
491
483
|
} catch (err) {
|
|
492
|
-
|
|
484
|
+
_iterator8.e(err);
|
|
493
485
|
} finally {
|
|
494
|
-
|
|
486
|
+
_iterator8.f();
|
|
495
487
|
}
|
|
496
488
|
break;
|
|
497
489
|
}
|
|
498
490
|
}
|
|
499
491
|
// endregion
|
|
500
492
|
} catch (err) {
|
|
501
|
-
|
|
493
|
+
_iterator7.e(err);
|
|
502
494
|
} finally {
|
|
503
|
-
|
|
495
|
+
_iterator7.f();
|
|
504
496
|
}
|
|
505
497
|
return data;
|
|
506
498
|
});
|
|
@@ -509,11 +501,11 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
509
501
|
});
|
|
510
502
|
//// endregion
|
|
511
503
|
//// region context replacements
|
|
512
|
-
var
|
|
513
|
-
|
|
504
|
+
var _iterator9 = _createForOfIteratorHelper(_module.replacements.context),
|
|
505
|
+
_step9;
|
|
514
506
|
try {
|
|
515
|
-
for (
|
|
516
|
-
var contextReplacement =
|
|
507
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
508
|
+
var contextReplacement = _step9.value;
|
|
517
509
|
pluginInstances.push((0, _construct2["default"])(_webpack.ContextReplacementPlugin, (0, _toConsumableArray2["default"])(contextReplacement.map(function (value) {
|
|
518
510
|
var evaluated = _clientnode["default"].stringEvaluate(value, {
|
|
519
511
|
configuration: configuration,
|
|
@@ -533,9 +525,9 @@ try {
|
|
|
533
525
|
them as same dependency.
|
|
534
526
|
*/
|
|
535
527
|
} catch (err) {
|
|
536
|
-
|
|
528
|
+
_iterator9.e(err);
|
|
537
529
|
} finally {
|
|
538
|
-
|
|
530
|
+
_iterator9.f();
|
|
539
531
|
}
|
|
540
532
|
if (_module.enforceDeduplication) {
|
|
541
533
|
var absoluteContextPath = (0, _path.resolve)(configuration.path.context);
|
|
@@ -556,35 +548,33 @@ if (_module.enforceDeduplication) {
|
|
|
556
548
|
*/
|
|
557
549
|
pathPrefixes.pop();
|
|
558
550
|
var index = 0;
|
|
559
|
-
var
|
|
560
|
-
|
|
551
|
+
var _iterator10 = _createForOfIteratorHelper(pathPrefixes),
|
|
552
|
+
_step10;
|
|
561
553
|
try {
|
|
562
|
-
for (
|
|
563
|
-
var pathPrefix =
|
|
554
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
555
|
+
var pathPrefix = _step10.value;
|
|
564
556
|
if (index > 0) pathPrefixes[index] = (0, _path.resolve)(pathPrefixes[index - 1], pathPrefix);
|
|
565
557
|
index += 1;
|
|
566
558
|
}
|
|
567
559
|
} catch (err) {
|
|
568
|
-
|
|
560
|
+
_iterator10.e(err);
|
|
569
561
|
} finally {
|
|
570
|
-
|
|
562
|
+
_iterator10.f();
|
|
571
563
|
}
|
|
572
564
|
pathSuffix = targetPath.replace(/(?:^|.*\/)node_modules\/(.+$)/, '$1');
|
|
573
565
|
} else {
|
|
574
566
|
pathPrefixes = [(0, _path.resolve)(absoluteContextPath, 'node_modules')];
|
|
575
567
|
// Find longest common prefix.
|
|
576
568
|
var _index = 0;
|
|
577
|
-
while (_index < absoluteContextPath.length && absoluteContextPath.charAt(_index) === targetPath.charAt(_index))
|
|
578
|
-
_index += 1;
|
|
579
|
-
}
|
|
569
|
+
while (_index < absoluteContextPath.length && absoluteContextPath.charAt(_index) === targetPath.charAt(_index)) _index += 1;
|
|
580
570
|
pathSuffix = targetPath.substring(_index).replace(/^.*\/node_modules\//, '');
|
|
581
571
|
}
|
|
582
572
|
var redundantRequest = null;
|
|
583
|
-
var
|
|
584
|
-
|
|
573
|
+
var _iterator11 = _createForOfIteratorHelper(pathPrefixes),
|
|
574
|
+
_step11;
|
|
585
575
|
try {
|
|
586
|
-
for (
|
|
587
|
-
var _pathPrefix =
|
|
576
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
577
|
+
var _pathPrefix = _step11.value;
|
|
588
578
|
var alternateTargetPath = (0, _path.resolve)(_pathPrefix, pathSuffix);
|
|
589
579
|
if (_clientnode["default"].isFileSync(alternateTargetPath)) {
|
|
590
580
|
var otherPackageDescriptor = _helper["default"].getClosestPackageDescriptor(alternateTargetPath);
|
|
@@ -609,9 +599,9 @@ if (_module.enforceDeduplication) {
|
|
|
609
599
|
}
|
|
610
600
|
}
|
|
611
601
|
} catch (err) {
|
|
612
|
-
|
|
602
|
+
_iterator11.e(err);
|
|
613
603
|
} finally {
|
|
614
|
-
|
|
604
|
+
_iterator11.f();
|
|
615
605
|
}
|
|
616
606
|
if (redundantRequest) console.warn('\nIncluding different versions of same package "' + "".concat(packageDescriptor.configuration.name, "\". Module \"") + "".concat(targetPath, "\" (version ") + "".concat(packageDescriptor.configuration.version, ") has ") + "redundancies with \"".concat(redundantRequest.path, "\" (") + "version ".concat(redundantRequest.version, ")."));
|
|
617
607
|
}
|
|
@@ -847,17 +837,17 @@ var genericLoader = {
|
|
|
847
837
|
include: function include(filePath) {
|
|
848
838
|
var result = evaluate(_module.preprocessor.javaScript.include, filePath);
|
|
849
839
|
if ([null, undefined].includes(result)) {
|
|
850
|
-
var
|
|
851
|
-
|
|
840
|
+
var _iterator12 = _createForOfIteratorHelper(includingPaths),
|
|
841
|
+
_step12;
|
|
852
842
|
try {
|
|
853
|
-
for (
|
|
854
|
-
var includePath =
|
|
843
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
844
|
+
var includePath = _step12.value;
|
|
855
845
|
if (filePath.startsWith(includePath)) return true;
|
|
856
846
|
}
|
|
857
847
|
} catch (err) {
|
|
858
|
-
|
|
848
|
+
_iterator12.e(err);
|
|
859
849
|
} finally {
|
|
860
|
-
|
|
850
|
+
_iterator12.f();
|
|
861
851
|
}
|
|
862
852
|
return false;
|
|
863
853
|
}
|
|
@@ -929,17 +919,17 @@ var genericLoader = {
|
|
|
929
919
|
include: function include(filePath) {
|
|
930
920
|
var result = evaluate(_module.cascadingStyleSheet.include, filePath);
|
|
931
921
|
if ([null, undefined].includes(result)) {
|
|
932
|
-
var
|
|
933
|
-
|
|
922
|
+
var _iterator13 = _createForOfIteratorHelper(includingPaths),
|
|
923
|
+
_step13;
|
|
934
924
|
try {
|
|
935
|
-
for (
|
|
936
|
-
var includePath =
|
|
925
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
926
|
+
var includePath = _step13.value;
|
|
937
927
|
if (filePath.startsWith(includePath)) return true;
|
|
938
928
|
}
|
|
939
929
|
} catch (err) {
|
|
940
|
-
|
|
930
|
+
_iterator13.e(err);
|
|
941
931
|
} finally {
|
|
942
|
-
|
|
932
|
+
_iterator13.f();
|
|
943
933
|
}
|
|
944
934
|
return false;
|
|
945
935
|
}
|
|
@@ -1090,11 +1080,11 @@ if (htmlAvailable && configuration.debug && configuration.development.server.liv
|
|
|
1090
1080
|
/// endregion
|
|
1091
1081
|
// endregion
|
|
1092
1082
|
// region plugins
|
|
1093
|
-
var
|
|
1094
|
-
|
|
1083
|
+
var _iterator14 = _createForOfIteratorHelper(configuration.plugins),
|
|
1084
|
+
_step14;
|
|
1095
1085
|
try {
|
|
1096
|
-
for (
|
|
1097
|
-
var pluginConfiguration =
|
|
1086
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1087
|
+
var pluginConfiguration = _step14.value;
|
|
1098
1088
|
var _plugin = optionalRequire(pluginConfiguration.name.module);
|
|
1099
1089
|
if (_plugin) pluginInstances.push((0, _construct2["default"])(_plugin[pluginConfiguration.name.initializer], (0, _toConsumableArray2["default"])(pluginConfiguration.parameters)));else console.warn("Configured plugin module \"".concat(pluginConfiguration.name.module, "\" ") + 'could not be loaded.');
|
|
1100
1090
|
}
|
|
@@ -1103,9 +1093,9 @@ try {
|
|
|
1103
1093
|
// NOTE: This plugin should be loaded at last to ensure that all emitted images
|
|
1104
1094
|
// ran through.
|
|
1105
1095
|
} catch (err) {
|
|
1106
|
-
|
|
1096
|
+
_iterator14.e(err);
|
|
1107
1097
|
} finally {
|
|
1108
|
-
|
|
1098
|
+
_iterator14.f();
|
|
1109
1099
|
}
|
|
1110
1100
|
if (!_module.optimizer.minimizer) {
|
|
1111
1101
|
_module.optimizer.minimizer = [];
|
|
@@ -1210,8 +1200,8 @@ var webpackConfiguration = _clientnode["default"].extend(true, {
|
|
|
1210
1200
|
cacheGroups: {
|
|
1211
1201
|
defaultVendors: {
|
|
1212
1202
|
chunks: function chunks(chunk) {
|
|
1213
|
-
if ((0, _typeof2["default"])(configuration.inPlace.javaScript) === 'object' && configuration.inPlace.javaScript !== null) for (var
|
|
1214
|
-
var _name4 = _Object$keys[
|
|
1203
|
+
if ((0, _typeof2["default"])(configuration.inPlace.javaScript) === 'object' && configuration.inPlace.javaScript !== null) for (var _i10 = 0, _Object$keys = Object.keys(configuration.inPlace.javaScript); _i10 < _Object$keys.length; _i10++) {
|
|
1204
|
+
var _name4 = _Object$keys[_i10];
|
|
1215
1205
|
if (_name4 === '*' || _name4 === chunk.name) return false;
|
|
1216
1206
|
}
|
|
1217
1207
|
return true;
|