weboptimizer 2.0.1491 → 2.0.1493
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 +7 -5
- package/configurator.js +12 -12
- package/declarations.d.ts +3 -7
- package/ejsLoader.d.ts +1 -1
- package/ejsLoader.js +24 -23
- package/eslint.config.d.ts +2 -2
- package/eslint.config.mjs +40 -18
- package/helper.d.ts +242 -261
- package/helper.js +830 -894
- package/index.js +15 -13
- package/jestEnvironmentBrowser.js +3 -1
- package/jestSetup.js +1 -1
- package/package.json +23 -42
- package/plugins/HTMLTransformation.js +4 -3
- package/plugins/InPlaceAssetsIntoHTML.js +1 -1
- package/tsconfig.json +3 -1
- package/type.d.ts +14 -13
- package/webpackConfigurator.js +84 -74
package/webpackConfigurator.js
CHANGED
|
@@ -23,8 +23,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
23
23
|
exports.webpackConfiguration = exports.optionalRequire = exports["default"] = void 0;
|
|
24
24
|
var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
|
|
25
25
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
26
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
27
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
28
28
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
29
29
|
var _clientnode = require("clientnode");
|
|
30
30
|
var _path = require("path");
|
|
@@ -32,10 +32,10 @@ var _util = _interopRequireDefault(require("util"));
|
|
|
32
32
|
var _webpack = require("webpack");
|
|
33
33
|
var _webpackSources = require("webpack-sources");
|
|
34
34
|
var _configurator = _interopRequireDefault(require("./configurator"));
|
|
35
|
-
var _helper =
|
|
35
|
+
var _helper = require("./helper");
|
|
36
36
|
var _InPlaceAssetsIntoHTML = _interopRequireDefault(require("./plugins/InPlaceAssetsIntoHTML"));
|
|
37
37
|
var _HTMLTransformation = _interopRequireDefault(require("./plugins/HTMLTransformation"));
|
|
38
|
-
var _optionalRequire, _configuration$
|
|
38
|
+
var _optionalRequire, _configuration$cache$, _configuration$cache, _configuration$cache2, _configuration$cache3;
|
|
39
39
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
40
40
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
41
41
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -52,7 +52,7 @@ eval("typeof require === 'undefined' ? null : require");
|
|
|
52
52
|
var optionalRequire = exports.optionalRequire = function optionalRequire(id) {
|
|
53
53
|
try {
|
|
54
54
|
return currentRequire ? currentRequire(id) : null;
|
|
55
|
-
} catch (
|
|
55
|
+
} catch (_error) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
@@ -131,29 +131,31 @@ for (var _i2 = 0, _Object$entries2 = Object.entries(_module.replacements.normal)
|
|
|
131
131
|
//// endregion
|
|
132
132
|
//// region generate html file
|
|
133
133
|
var htmlAvailable = false;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
if (plugins.HTML) {
|
|
135
|
+
var _iterator2 = _createForOfIteratorHelper(configuration.files.html),
|
|
136
|
+
_step2;
|
|
137
|
+
try {
|
|
138
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
139
|
+
var htmlConfiguration = _step2.value;
|
|
140
|
+
if ((0, _clientnode.isFileSync)(htmlConfiguration.template.filePath)) {
|
|
141
|
+
pluginInstances.push(new plugins.HTML(_objectSpread(_objectSpread({}, htmlConfiguration), {}, {
|
|
142
|
+
template: htmlConfiguration.template.request
|
|
143
|
+
})));
|
|
144
|
+
htmlAvailable = true;
|
|
145
|
+
}
|
|
144
146
|
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
_iterator2.e(err);
|
|
149
|
+
} finally {
|
|
150
|
+
_iterator2.f();
|
|
145
151
|
}
|
|
146
|
-
//// endregion
|
|
147
|
-
//// region generate favicons
|
|
148
|
-
} catch (err) {
|
|
149
|
-
_iterator2.e(err);
|
|
150
|
-
} finally {
|
|
151
|
-
_iterator2.f();
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
//// endregion
|
|
154
|
+
//// region generate favicons
|
|
155
|
+
if (htmlAvailable && Object.prototype.hasOwnProperty.call(configuration, 'favicon') && plugins.Favicon && (0, _clientnode.isFileSync)([].concat(configuration.favicon.logo)[0])) pluginInstances.push(new plugins.Favicon(configuration.favicon));
|
|
154
156
|
//// endregion
|
|
155
157
|
//// region provide offline functionality
|
|
156
|
-
if (htmlAvailable && configuration
|
|
158
|
+
if (htmlAvailable && Object.prototype.hasOwnProperty.call(configuration, 'offline') && Object.prototype.hasOwnProperty.call(plugins, 'Offline')) {
|
|
157
159
|
if (!['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2])) for (var _i3 = 0, _Object$entries3 = Object.entries({
|
|
158
160
|
cascadingStyleSheet: 'css',
|
|
159
161
|
javaScript: 'js'
|
|
@@ -171,12 +173,12 @@ if (htmlAvailable && configuration.offline && plugins.Offline) {
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
|
-
if ([].concat(configuration.offline.use).includes('injectionManifest')) pluginInstances.push(new plugins.InjectManifest((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.injectionManifest)));
|
|
175
|
-
if ([].concat(configuration.offline.use).includes('generateServiceWorker')) pluginInstances.push(new plugins.GenerateServiceWorker((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.serviceWorker)));
|
|
176
|
+
if (plugins.InjectManifest && [].concat(configuration.offline.use).includes('injectionManifest')) pluginInstances.push(new plugins.InjectManifest((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.injectionManifest)));
|
|
177
|
+
if (plugins.GenerateServiceWorker && [].concat(configuration.offline.use).includes('generateServiceWorker')) pluginInstances.push(new plugins.GenerateServiceWorker((0, _clientnode.extend)(true, configuration.offline.common, configuration.offline.serviceWorker)));
|
|
176
178
|
}
|
|
177
179
|
//// endregion
|
|
178
180
|
//// region provide build environment
|
|
179
|
-
if (configuration.buildContext
|
|
181
|
+
if (Object.prototype.hasOwnProperty.call(configuration.buildContext, 'definitions')) pluginInstances.push(new _webpack.DefinePlugin(configuration.buildContext.definitions));
|
|
180
182
|
if (_module.provide) pluginInstances.push(new _webpack.ProvidePlugin(_module.provide));
|
|
181
183
|
//// endregion
|
|
182
184
|
//// region modules/assets
|
|
@@ -195,8 +197,8 @@ pluginInstances.push({
|
|
|
195
197
|
request = _Object$entries4$_i[0],
|
|
196
198
|
asset = _Object$entries4$_i[1];
|
|
197
199
|
var filePath = request.replace(/\?[^?]+$/, '');
|
|
198
|
-
var _type = _helper
|
|
199
|
-
if (_type && configuration.assetPattern
|
|
200
|
+
var _type = (0, _helper.determineAssetType)(filePath, configuration.buildContext.types, configuration.path);
|
|
201
|
+
if (_type && Object.prototype.hasOwnProperty.call(configuration.assetPattern, _type) && new RegExp(configuration.assetPattern[_type].includeFilePathRegularExpression).test(filePath) && !new RegExp(configuration.assetPattern[_type].excludeFilePathRegularExpression).test(filePath)) {
|
|
200
202
|
var source = asset.source();
|
|
201
203
|
if (typeof source === 'string') compilation.assets[request] = new _webpackSources.RawSource(configuration.assetPattern[_type].pattern.replace(/\{1\}/g, source.replace(/\$/g, '$$$')));
|
|
202
204
|
}
|
|
@@ -227,7 +229,7 @@ pluginInstances.push({
|
|
|
227
229
|
.replace(/##-#-#-##/g, '%>')
|
|
228
230
|
*/
|
|
229
231
|
|
|
230
|
-
if (htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]) && configuration.inPlace
|
|
232
|
+
if (plugins.HTML && htmlAvailable && !['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]) && Object.prototype.hasOwnProperty.call(configuration.inPlace, 'cascadingStyleSheet') && Object.keys(configuration.inPlace.cascadingStyleSheet).length || Object.prototype.hasOwnProperty.call(configuration.inPlace, 'javaScript') && Object.keys(configuration.inPlace.javaScript).length) pluginInstances.push(new _InPlaceAssetsIntoHTML["default"]({
|
|
231
233
|
cascadingStyleSheet: configuration.inPlace.cascadingStyleSheet,
|
|
232
234
|
javaScript: configuration.inPlace.javaScript,
|
|
233
235
|
htmlPlugin: plugins.HTML
|
|
@@ -254,7 +256,10 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
254
256
|
configuration.injection.external.modules = function (_ref, callback) {
|
|
255
257
|
var context = _ref.context,
|
|
256
258
|
request = _ref.request;
|
|
257
|
-
if (typeof request !== 'string')
|
|
259
|
+
if (typeof request !== 'string') {
|
|
260
|
+
callback();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
258
263
|
request = request.replace(/^!+/, '');
|
|
259
264
|
if (request.startsWith('/')) request = (0, _path.relative)(configuration.path.context, request);
|
|
260
265
|
var _iterator3 = _createForOfIteratorHelper(_module.directoryNames),
|
|
@@ -274,14 +279,14 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
274
279
|
} finally {
|
|
275
280
|
_iterator3.f();
|
|
276
281
|
}
|
|
277
|
-
var filePath = _helper
|
|
282
|
+
var filePath = (0, _helper.determineModuleFilePath)(request, {}, {}, {
|
|
278
283
|
file: configuration.extensions.file.external
|
|
279
284
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
|
|
280
285
|
if (filePath) for (var _i6 = 0, _Object$entries5 = Object.entries(configuration.injection.external.aliases); _i6 < _Object$entries5.length; _i6++) {
|
|
281
286
|
var _Object$entries5$_i = (0, _slicedToArray2["default"])(_Object$entries5[_i6], 2),
|
|
282
287
|
pattern = _Object$entries5$_i[0],
|
|
283
288
|
targetConfiguration = _Object$entries5$_i[1];
|
|
284
|
-
if (pattern.startsWith('^')) {
|
|
289
|
+
if (targetConfiguration && pattern.startsWith('^')) {
|
|
285
290
|
var regularExpression = new RegExp(pattern);
|
|
286
291
|
if (regularExpression.test(filePath)) {
|
|
287
292
|
var match = false;
|
|
@@ -292,7 +297,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
292
297
|
if (target.startsWith('?')) {
|
|
293
298
|
target = target.substring(1);
|
|
294
299
|
var aliasedRequest = request.replace(replacementRegularExpression, target);
|
|
295
|
-
if (aliasedRequest !== request) match = Boolean(_helper
|
|
300
|
+
if (aliasedRequest !== request) match = Boolean((0, _helper.determineModuleFilePath)(aliasedRequest, {}, {}, {
|
|
296
301
|
file: configuration.extensions.file.external
|
|
297
302
|
}, configuration.path.context, context, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding));
|
|
298
303
|
} else match = true;
|
|
@@ -304,7 +309,7 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
304
309
|
}
|
|
305
310
|
}
|
|
306
311
|
// endregion
|
|
307
|
-
var resolvedRequest = _helper
|
|
312
|
+
var resolvedRequest = (0, _helper.determineExternalRequest)(request, configuration.path.context, context, configuration.injection.entry.normalized, _module.directoryNames, _module.aliases, _module.replacements.normal, configuration.extensions, configuration.path.source.asset.base, configuration.path.ignore, _module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.injection.external.implicit.pattern.include, configuration.injection.external.implicit.pattern.exclude, configuration.inPlace.externalLibrary.normal, configuration.inPlace.externalLibrary.dynamic, configuration.encoding);
|
|
308
313
|
if (resolvedRequest) {
|
|
309
314
|
var keys = ['amd', 'commonjs', 'commonjs2', 'root'];
|
|
310
315
|
var result = resolvedRequest;
|
|
@@ -356,18 +361,19 @@ if (configuration.injection.external.modules === '__implicit__')
|
|
|
356
361
|
}
|
|
357
362
|
// endregion
|
|
358
363
|
}
|
|
359
|
-
if (typeof result !== 'string' && Object.prototype.hasOwnProperty.call(result, 'root')) result.root = [].concat(result.root).map(function (name) {
|
|
364
|
+
if (typeof result !== 'string' && Object.prototype.hasOwnProperty.call(result, 'root') && Array.isArray(result.root)) result.root = [].concat(result.root).map(function (name) {
|
|
360
365
|
return (0, _clientnode.convertToValidVariableName)(name);
|
|
361
366
|
});
|
|
362
|
-
var exportFormat = configuration.exportFormat.external
|
|
363
|
-
|
|
367
|
+
var exportFormat = Object.prototype.hasOwnProperty.call(configuration.exportFormat, 'external') ? configuration.exportFormat.external : configuration.exportFormat.self;
|
|
368
|
+
callback(undefined, exportFormat === 'umd' || typeof result === 'string' ? result : result[exportFormat], exportFormat);
|
|
369
|
+
return;
|
|
364
370
|
}
|
|
365
|
-
|
|
371
|
+
callback();
|
|
366
372
|
};
|
|
367
373
|
///// endregion
|
|
368
374
|
//// endregion
|
|
369
375
|
//// region apply final html modifications/fixes
|
|
370
|
-
if (htmlAvailable) pluginInstances.push(new _HTMLTransformation["default"]({
|
|
376
|
+
if (htmlAvailable && plugins.HTML) pluginInstances.push(new _HTMLTransformation["default"]({
|
|
371
377
|
hashAlgorithm: configuration.hashAlgorithm,
|
|
372
378
|
htmlPlugin: plugins.HTML,
|
|
373
379
|
files: configuration.files.html
|
|
@@ -407,7 +413,7 @@ if (_module.enforceDeduplication) {
|
|
|
407
413
|
var consolidator = function consolidator(result) {
|
|
408
414
|
var targetPath = result.createData.resource;
|
|
409
415
|
if (targetPath && /((?:^|\/)node_modules\/.+)/.test(targetPath) && (!targetPath.startsWith(absoluteContextPath) || /((?:^|\/)node_modules\/.+){2}/.test(targetPath)) && (0, _clientnode.isFileSync)(targetPath)) {
|
|
410
|
-
var packageDescriptor = _helper
|
|
416
|
+
var packageDescriptor = (0, _helper.getClosestPackageDescriptor)(targetPath);
|
|
411
417
|
if (packageDescriptor) {
|
|
412
418
|
var pathPrefixes;
|
|
413
419
|
var pathSuffix;
|
|
@@ -450,7 +456,7 @@ if (_module.enforceDeduplication) {
|
|
|
450
456
|
var _pathPrefix = _step9.value;
|
|
451
457
|
var alternateTargetPath = (0, _path.resolve)(_pathPrefix, pathSuffix);
|
|
452
458
|
if ((0, _clientnode.isFileSync)(alternateTargetPath)) {
|
|
453
|
-
var otherPackageDescriptor = _helper
|
|
459
|
+
var otherPackageDescriptor = (0, _helper.getClosestPackageDescriptor)(alternateTargetPath);
|
|
454
460
|
if (otherPackageDescriptor) {
|
|
455
461
|
if (packageDescriptor.configuration.version === otherPackageDescriptor.configuration.version) {
|
|
456
462
|
console.info('\nConsolidate module request "' + "".concat(targetPath, "\" to \"") + "".concat(alternateTargetPath, "\"."));
|
|
@@ -482,8 +488,8 @@ if (_module.enforceDeduplication) {
|
|
|
482
488
|
};
|
|
483
489
|
pluginInstances.push({
|
|
484
490
|
apply: function apply(compiler) {
|
|
485
|
-
|
|
486
|
-
|
|
491
|
+
compiler.hooks.normalModuleFactory.tap('WebOptimizerModuleConsolidation', function (nmf) {
|
|
492
|
+
nmf.hooks.afterResolve.tap('WebOptimizerModuleConsolidation', consolidator);
|
|
487
493
|
});
|
|
488
494
|
}
|
|
489
495
|
});
|
|
@@ -574,8 +580,8 @@ new NormalModuleReplacementPlugin(
|
|
|
574
580
|
/// endregion
|
|
575
581
|
/// region loader helper
|
|
576
582
|
var isFilePathInDependencies = function isFilePathInDependencies(filePath) {
|
|
577
|
-
filePath = _helper
|
|
578
|
-
return _helper
|
|
583
|
+
filePath = (0, _helper.stripLoader)(filePath);
|
|
584
|
+
return (0, _helper.isFilePathInLocation)(filePath, configuration.path.ignore.concat(_module.directoryNames, configuration.loader.directoryNames).map(function (filePath) {
|
|
579
585
|
return (0, _path.resolve)(configuration.path.context, filePath);
|
|
580
586
|
}).filter(function (filePath) {
|
|
581
587
|
return !configuration.path.context.startsWith(filePath);
|
|
@@ -586,7 +592,7 @@ var scope = {
|
|
|
586
592
|
configuration: configuration,
|
|
587
593
|
isFilePathInDependencies: isFilePathInDependencies,
|
|
588
594
|
loader: loader,
|
|
589
|
-
require: currentRequire
|
|
595
|
+
require: currentRequire !== null && currentRequire !== void 0 ? currentRequire : require
|
|
590
596
|
};
|
|
591
597
|
var evaluateAnThrow = function evaluateAnThrow(object) {
|
|
592
598
|
var filePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : configuration.path.context;
|
|
@@ -605,7 +611,7 @@ var evaluateMapper = function evaluateMapper(value) {
|
|
|
605
611
|
var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderConfiguration(loaderConfiguration) {
|
|
606
612
|
return {
|
|
607
613
|
exclude: function exclude(filePath) {
|
|
608
|
-
return
|
|
614
|
+
return evaluateAnThrow(loaderConfiguration.exclude, filePath);
|
|
609
615
|
},
|
|
610
616
|
include: loaderConfiguration.include && evaluateAnThrow(loaderConfiguration.include) || configuration.path.source.base,
|
|
611
617
|
test: new RegExp(evaluateAnThrow(loaderConfiguration.test)),
|
|
@@ -613,7 +619,7 @@ var evaluateAdditionalLoaderConfiguration = function evaluateAdditionalLoaderCon
|
|
|
613
619
|
};
|
|
614
620
|
};
|
|
615
621
|
var getIncludingPaths = function getIncludingPaths(path) {
|
|
616
|
-
return _helper
|
|
622
|
+
return (0, _helper.normalizePaths)([path].concat(_module.locations.directoryPaths));
|
|
617
623
|
};
|
|
618
624
|
var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluateMapper).concat({
|
|
619
625
|
loader: _module.style.loader,
|
|
@@ -653,7 +659,7 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
653
659
|
}) : [], postcssSprites ? postcssSprites({
|
|
654
660
|
filterBy: function filterBy() {
|
|
655
661
|
return new Promise(function (resolve, reject) {
|
|
656
|
-
|
|
662
|
+
(configuration.files.compose.image ? resolve : reject)();
|
|
657
663
|
});
|
|
658
664
|
},
|
|
659
665
|
hooks: {
|
|
@@ -668,9 +674,9 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
|
|
|
668
674
|
(e.g. linear gradient instead).
|
|
669
675
|
*/
|
|
670
676
|
onUpdateRule: function onUpdateRule(rule, token, image) {
|
|
671
|
-
if (token.value.includes(token.text)) updateRule(rule, token, image);else token.cloneAfter({
|
|
677
|
+
if (updateRule) if (token.value.includes(token.text)) updateRule(rule, token, image);else token.cloneAfter({
|
|
672
678
|
type: 'decl',
|
|
673
|
-
prop: 'background-image',
|
|
679
|
+
prop: 'background-' + 'image',
|
|
674
680
|
value: token.value
|
|
675
681
|
});
|
|
676
682
|
}
|
|
@@ -686,9 +692,9 @@ var genericLoader = {
|
|
|
686
692
|
// region generic template
|
|
687
693
|
ejs: {
|
|
688
694
|
exclude: function exclude(filePath) {
|
|
689
|
-
return _helper
|
|
695
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
690
696
|
return htmlConfiguration.template.filePath;
|
|
691
|
-
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false :
|
|
697
|
+
})).includes(filePath) || _module.preprocessor.ejs.exclude === null ? false : evaluateAnThrow(_module.preprocessor.ejs.exclude, filePath);
|
|
692
698
|
},
|
|
693
699
|
include: getIncludingPaths(configuration.path.source.asset.template),
|
|
694
700
|
test: /^(?!.+\.html\.ejs$).+\.ejs$/i,
|
|
@@ -707,7 +713,7 @@ var genericLoader = {
|
|
|
707
713
|
// region script
|
|
708
714
|
script: {
|
|
709
715
|
exclude: function exclude(filePath) {
|
|
710
|
-
return
|
|
716
|
+
return evaluateAnThrow(_module.preprocessor.javaScript.exclude, filePath);
|
|
711
717
|
},
|
|
712
718
|
include: function include(filePath) {
|
|
713
719
|
var result = evaluateAnThrow(_module.preprocessor.javaScript.include, filePath);
|
|
@@ -744,9 +750,9 @@ var genericLoader = {
|
|
|
744
750
|
},
|
|
745
751
|
ejs: {
|
|
746
752
|
exclude: function exclude(filePath) {
|
|
747
|
-
return _helper
|
|
753
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
748
754
|
return htmlConfiguration.template.filePath;
|
|
749
|
-
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false :
|
|
755
|
+
})).includes(filePath) || (_module.preprocessor.html.exclude === null ? false : evaluateAnThrow(_module.preprocessor.html.exclude, filePath));
|
|
750
756
|
},
|
|
751
757
|
include: configuration.path.source.asset.template,
|
|
752
758
|
test: /\.html\.ejs(?:\?.*)?$/i,
|
|
@@ -768,9 +774,9 @@ var genericLoader = {
|
|
|
768
774
|
},
|
|
769
775
|
html: {
|
|
770
776
|
exclude: function exclude(filePath) {
|
|
771
|
-
return _helper
|
|
777
|
+
return (0, _helper.normalizePaths)(configuration.files.html.concat(configuration.files.defaultHTML).map(function (htmlConfiguration) {
|
|
772
778
|
return htmlConfiguration.template.filePath;
|
|
773
|
-
})).includes(filePath) || (_module.html.exclude === null ? true :
|
|
779
|
+
})).includes(filePath) || (_module.html.exclude === null ? true : evaluateAnThrow(_module.html.exclude, filePath));
|
|
774
780
|
},
|
|
775
781
|
include: configuration.path.source.asset.template,
|
|
776
782
|
test: /\.html(?:\?.*)?$/i,
|
|
@@ -789,7 +795,7 @@ var genericLoader = {
|
|
|
789
795
|
// region style
|
|
790
796
|
style: {
|
|
791
797
|
exclude: function exclude(filePath) {
|
|
792
|
-
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) :
|
|
798
|
+
return _module.cascadingStyleSheet.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.cascadingStyleSheet.exclude, filePath);
|
|
793
799
|
},
|
|
794
800
|
include: function include(filePath) {
|
|
795
801
|
var result = evaluateAnThrow(_module.cascadingStyleSheet.include, filePath);
|
|
@@ -819,7 +825,7 @@ var genericLoader = {
|
|
|
819
825
|
font: {
|
|
820
826
|
eot: {
|
|
821
827
|
exclude: function exclude(filePath) {
|
|
822
|
-
return _module.optimizer.font.eot.exclude === null ? false :
|
|
828
|
+
return _module.optimizer.font.eot.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.eot.exclude, filePath);
|
|
823
829
|
},
|
|
824
830
|
generator: {
|
|
825
831
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -835,7 +841,7 @@ var genericLoader = {
|
|
|
835
841
|
},
|
|
836
842
|
svg: {
|
|
837
843
|
exclude: function exclude(filePath) {
|
|
838
|
-
return _module.optimizer.font.svg.exclude === null ? false :
|
|
844
|
+
return _module.optimizer.font.svg.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.svg.exclude, filePath);
|
|
839
845
|
},
|
|
840
846
|
include: configuration.path.source.asset.font,
|
|
841
847
|
generator: {
|
|
@@ -853,7 +859,7 @@ var genericLoader = {
|
|
|
853
859
|
},
|
|
854
860
|
ttf: {
|
|
855
861
|
exclude: function exclude(filePath) {
|
|
856
|
-
return _module.optimizer.font.ttf.exclude === null ? false :
|
|
862
|
+
return _module.optimizer.font.ttf.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.ttf.exclude, filePath);
|
|
857
863
|
},
|
|
858
864
|
generator: {
|
|
859
865
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -870,7 +876,7 @@ var genericLoader = {
|
|
|
870
876
|
},
|
|
871
877
|
woff: {
|
|
872
878
|
exclude: function exclude(filePath) {
|
|
873
|
-
return _module.optimizer.font.woff.exclude === null ? false :
|
|
879
|
+
return _module.optimizer.font.woff.exclude === null ? false : evaluateAnThrow(_module.optimizer.font.woff.exclude, filePath);
|
|
874
880
|
},
|
|
875
881
|
generator: {
|
|
876
882
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.font), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -889,7 +895,7 @@ var genericLoader = {
|
|
|
889
895
|
// region image
|
|
890
896
|
image: {
|
|
891
897
|
exclude: function exclude(filePath) {
|
|
892
|
-
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) :
|
|
898
|
+
return _module.optimizer.image.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.image.exclude, filePath);
|
|
893
899
|
},
|
|
894
900
|
generator: {
|
|
895
901
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.image), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -909,7 +915,7 @@ var genericLoader = {
|
|
|
909
915
|
data: {
|
|
910
916
|
exclude: function exclude(filePath) {
|
|
911
917
|
if (typeof filePath !== 'string') return false;
|
|
912
|
-
return configuration.extensions.file.internal.includes((0, _path.extname)(_helper
|
|
918
|
+
return configuration.extensions.file.internal.includes((0, _path.extname)((0, _helper.stripLoader)(filePath))) || (_module.optimizer.data.exclude === null ? isFilePathInDependencies(filePath) : evaluateAnThrow(_module.optimizer.data.exclude, filePath));
|
|
913
919
|
},
|
|
914
920
|
generator: {
|
|
915
921
|
filename: (0, _path.join)((0, _path.relative)(configuration.path.target.base, configuration.path.target.asset.data), '[name][ext]') + "?".concat(configuration.hashAlgorithm, "=[contenthash]")
|
|
@@ -943,8 +949,8 @@ if (configuration.files.compose.cascadingStyleSheet && plugins.MiniCSSExtract) {
|
|
|
943
949
|
last module which would shadow main module (e.g. index).
|
|
944
950
|
So we inject live reload and hot module replacement manually.
|
|
945
951
|
*/
|
|
946
|
-
if (htmlAvailable && configuration.debug && configuration.development.server.liveReload && !configuration.injection.entry.normalized
|
|
947
|
-
configuration.injection.entry.normalized.developmentHandler = ['webpack-dev-server/client/index.js?' + 'live-reload=
|
|
952
|
+
if (htmlAvailable && configuration.debug && configuration.development.server.liveReload && !Object.prototype.hasOwnProperty.call(configuration.injection.entry.normalized, 'developmentHandler') && (configuration.development.includeClient || typeof configuration.development.includeClient !== 'boolean' && ['serve', 'test:browser'].includes(configuration.givenCommandLineArguments[2]))) {
|
|
953
|
+
configuration.injection.entry.normalized.developmentHandler = ['webpack-dev-server/client/index.js?' + 'live-reload=true' + "&hot=".concat(configuration.development.server.hot ? 'true' : 'false') + "&http".concat(configuration.development.server.https ? 's' : '', "://") + "".concat(configuration.development.server.host, ":") + String(configuration.development.server.port)];
|
|
948
954
|
if (configuration.development.server.hot) {
|
|
949
955
|
configuration.injection.entry.normalized.developmentHandler.push('webpack/hot/dev-server.js');
|
|
950
956
|
configuration.development.server.hot = false;
|
|
@@ -992,14 +998,14 @@ if (!_module.optimizer.minimizer) {
|
|
|
992
998
|
// endregion
|
|
993
999
|
// region configuration
|
|
994
1000
|
var customConfiguration = {};
|
|
995
|
-
if (
|
|
1001
|
+
if (configuration.path.configuration.json) try {
|
|
996
1002
|
require.resolve(configuration.path.configuration.json);
|
|
997
1003
|
try {
|
|
998
1004
|
customConfiguration = currentRequire(configuration.path.configuration.json);
|
|
999
1005
|
} catch (error) {
|
|
1000
1006
|
console.debug('Importing provided json webpack configuration file path ' + "under \"".concat(configuration.path.configuration.json, "\" failed: ") + (0, _clientnode.represent)(error));
|
|
1001
1007
|
}
|
|
1002
|
-
} catch (
|
|
1008
|
+
} catch (_error) {
|
|
1003
1009
|
console.debug('Optional configuration file "' + "".concat(configuration.path.configuration.json, "\" not available."));
|
|
1004
1010
|
}
|
|
1005
1011
|
var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend)(true, {
|
|
@@ -1019,7 +1025,7 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1019
1025
|
extensions: configuration.extensions.file.internal,
|
|
1020
1026
|
mainFields: configuration["package"].main.propertyNames,
|
|
1021
1027
|
mainFiles: configuration["package"].main.fileNames,
|
|
1022
|
-
modules: _helper
|
|
1028
|
+
modules: (0, _helper.normalizePaths)(_module.directoryNames),
|
|
1023
1029
|
symlinks: _module.resolveSymlinks,
|
|
1024
1030
|
unsafeCache: Boolean((_configuration$cache$ = (_configuration$cache = configuration.cache) === null || _configuration$cache === void 0 ? void 0 : _configuration$cache.unsafe) !== null && _configuration$cache$ !== void 0 ? _configuration$cache$ : (_configuration$cache2 = configuration.cache) === null || _configuration$cache2 === void 0 ? void 0 : _configuration$cache2.main)
|
|
1025
1031
|
},
|
|
@@ -1074,7 +1080,7 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1074
1080
|
cacheGroups: {
|
|
1075
1081
|
defaultVendors: {
|
|
1076
1082
|
chunks: function chunks(chunk) {
|
|
1077
|
-
if ((0, _typeof2["default"])(configuration.inPlace.javaScript) === 'object'
|
|
1083
|
+
if ((0, _typeof2["default"])(configuration.inPlace.javaScript) === 'object') for (var _i7 = 0, _Object$keys = Object.keys(configuration.inPlace.javaScript); _i7 < _Object$keys.length; _i7++) {
|
|
1078
1084
|
var _name3 = _Object$keys[_i7];
|
|
1079
1085
|
if (_name3 === '*' || _name3 === chunk.name) return false;
|
|
1080
1086
|
}
|
|
@@ -1100,15 +1106,19 @@ var webpackConfiguration = exports.webpackConfiguration = (0, _clientnode.extend
|
|
|
1100
1106
|
}, (_configuration$cache3 = configuration.cache) !== null && _configuration$cache3 !== void 0 && _configuration$cache3.main ? {
|
|
1101
1107
|
cache: configuration.cache.main
|
|
1102
1108
|
} : {}, configuration.webpack, customConfiguration);
|
|
1103
|
-
if (configuration.nodeENV !== null) webpackConfiguration.optimization.nodeEnv = configuration.nodeENV;
|
|
1104
|
-
|
|
1105
|
-
|
|
1109
|
+
if (configuration.nodeENV !== null) if ((0, _typeof2["default"])(webpackConfiguration.optimization) === 'object') webpackConfiguration.optimization.nodeEnv = configuration.nodeENV;else webpackConfiguration.optimization = {
|
|
1110
|
+
nodeEnv: configuration.nodeENV
|
|
1111
|
+
};
|
|
1112
|
+
if (!Array.isArray(_module.skipParseRegularExpressions) || _module.skipParseRegularExpressions.length) if ((0, _typeof2["default"])(webpackConfiguration.module) === 'object') webpackConfiguration.module.noParse = _module.skipParseRegularExpressions;else webpackConfiguration.module = {
|
|
1113
|
+
noParse: _module.skipParseRegularExpressions
|
|
1114
|
+
};
|
|
1115
|
+
if (configuration.path.configuration.javaScript) try {
|
|
1106
1116
|
require.resolve(configuration.path.configuration.javaScript);
|
|
1107
1117
|
var result = optionalRequire(configuration.path.configuration.javaScript);
|
|
1108
1118
|
if ((0, _clientnode.isPlainObject)(result)) {
|
|
1109
1119
|
if (Object.prototype.hasOwnProperty.call(result, 'replaceWebOptimizer')) exports.webpackConfiguration = webpackConfiguration = result.replaceWebOptimizer;else (0, _clientnode.extend)(true, webpackConfiguration, result);
|
|
1110
1120
|
} else console.debug('Failed to load given JavaScript configuration file path "' + "".concat(configuration.path.configuration.javaScript, "\"."));
|
|
1111
|
-
} catch (
|
|
1121
|
+
} catch (_error) {
|
|
1112
1122
|
console.debug('Optional configuration file script "' + "".concat(configuration.path.configuration.javaScript, "\" not available."));
|
|
1113
1123
|
}
|
|
1114
1124
|
if (configuration.showConfiguration) {
|