weboptimizer 2.0.1098 → 2.0.1107
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/ejsLoader.js +2 -2
- package/helper.js +2 -2
- package/index.js +3 -3
- package/package.json +36 -35
- package/type.d.ts +2 -0
- package/type.js +1 -1
- package/webpackConfigurator.js +30 -9
package/ejsLoader.js
CHANGED
|
@@ -48,9 +48,9 @@ var _configurator = _interopRequireDefault(require("./configurator"));
|
|
|
48
48
|
|
|
49
49
|
var _helper = _interopRequireDefault(require("./helper"));
|
|
50
50
|
|
|
51
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
51
|
+
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; }
|
|
52
52
|
|
|
53
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
53
|
+
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; }
|
|
54
54
|
|
|
55
55
|
// endregion
|
|
56
56
|
|
package/helper.js
CHANGED
|
@@ -38,9 +38,9 @@ var _fs = require("fs");
|
|
|
38
38
|
|
|
39
39
|
var _path = require("path");
|
|
40
40
|
|
|
41
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
41
|
+
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; }
|
|
42
42
|
|
|
43
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
43
|
+
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; }
|
|
44
44
|
|
|
45
45
|
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; } } }; }
|
|
46
46
|
|
package/index.js
CHANGED
|
@@ -60,9 +60,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
60
60
|
|
|
61
61
|
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; }
|
|
62
62
|
|
|
63
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
63
|
+
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; }
|
|
64
64
|
|
|
65
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
65
|
+
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; }
|
|
66
66
|
|
|
67
67
|
// endregion
|
|
68
68
|
// NOTE: Environment variables can only be strings.
|
|
@@ -714,7 +714,7 @@ var main = /*#__PURE__*/function () {
|
|
|
714
714
|
};
|
|
715
715
|
}();
|
|
716
716
|
|
|
717
|
-
if (require.main === module) main()
|
|
717
|
+
if (require.main === module) void main();
|
|
718
718
|
var _default = main; // region vim modline
|
|
719
719
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
720
720
|
// vim: foldmethod=marker foldmarker=region,endregion:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weboptimizer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1107",
|
|
4
4
|
"description": "A generic web optimizer, (module) bundler and development environment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"@types/favicons": "*",
|
|
115
115
|
"@types/html-minifier": "*",
|
|
116
116
|
"@types/html-minifier-terser": "*",
|
|
117
|
+
"@types/imagemin": "*",
|
|
117
118
|
"@types/jest": "*",
|
|
118
119
|
"@types/jsdom": "*",
|
|
119
120
|
"@types/mini-css-extract-plugin": "*",
|
|
@@ -160,6 +161,7 @@
|
|
|
160
161
|
"@types/ejs": "*",
|
|
161
162
|
"@types/favicons": "*",
|
|
162
163
|
"@types/html-minifier": "*",
|
|
164
|
+
"@types/imagemin": "*",
|
|
163
165
|
"@types/jest": "*",
|
|
164
166
|
"@types/jsdom": "*",
|
|
165
167
|
"@types/mini-css-extract-plugin": "*",
|
|
@@ -176,6 +178,7 @@
|
|
|
176
178
|
"favicons-webpack-plugin": "*",
|
|
177
179
|
"identity-obj-proxy": "*",
|
|
178
180
|
"image-minimizer-webpack-plugin": "*",
|
|
181
|
+
"imagemin": "*",
|
|
179
182
|
"jest": "*",
|
|
180
183
|
"jsdoc": "*",
|
|
181
184
|
"mini-css-extract-plugin": "*",
|
|
@@ -997,36 +1000,38 @@
|
|
|
997
1000
|
},
|
|
998
1001
|
"image": {
|
|
999
1002
|
"content": {
|
|
1000
|
-
"
|
|
1001
|
-
"
|
|
1002
|
-
[
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1003
|
+
"minimizer": {
|
|
1004
|
+
"options": {
|
|
1005
|
+
"plugins": [
|
|
1006
|
+
[
|
|
1007
|
+
"gifsicle",
|
|
1008
|
+
{
|
|
1009
|
+
"colors": 256,
|
|
1010
|
+
"interlanced": false,
|
|
1011
|
+
"optimizationLevel": 3
|
|
1012
|
+
}
|
|
1013
|
+
],
|
|
1014
|
+
[
|
|
1015
|
+
"jpegtran",
|
|
1016
|
+
{
|
|
1017
|
+
"arithmetic": true,
|
|
1018
|
+
"progressive": true
|
|
1019
|
+
}
|
|
1020
|
+
],
|
|
1021
|
+
[
|
|
1022
|
+
"optipng",
|
|
1023
|
+
{
|
|
1024
|
+
"optimizationLevel": 7
|
|
1025
|
+
}
|
|
1026
|
+
],
|
|
1027
|
+
[
|
|
1028
|
+
"svgo",
|
|
1029
|
+
{
|
|
1030
|
+
"plugins": []
|
|
1031
|
+
}
|
|
1032
|
+
]
|
|
1028
1033
|
]
|
|
1029
|
-
|
|
1034
|
+
}
|
|
1030
1035
|
},
|
|
1031
1036
|
"exclude": {
|
|
1032
1037
|
"__evaluate__": "self.debug || 2 < self.givenCommandLineArguments.length && self.givenCommandLineArguments[2] !== 'build' ? /.*/ : self.debug && console.warn(`Image compression disabled. Use configuration: \"{module:{optimizer:{image:{content:{exclude:undefined}}}}}\" to enable default image file including.`) || /.*/"
|
|
@@ -1034,11 +1039,7 @@
|
|
|
1034
1039
|
},
|
|
1035
1040
|
"loader": []
|
|
1036
1041
|
},
|
|
1037
|
-
"minimize": true
|
|
1038
|
-
"minimizer": {
|
|
1039
|
-
"#": "HTML-Templates shouldn't be transformed via terser to avoid html webpack plugin throwing to not get markup as intermediate result.",
|
|
1040
|
-
"__evaluate__": "[new (require('terser-webpack-plugin'))({exclude: /\\.html(?:\\.js)?(?:\\?.*)?$/, extractComments: false, parallel: true})]"
|
|
1041
|
-
}
|
|
1042
|
+
"minimize": true
|
|
1042
1043
|
},
|
|
1043
1044
|
"preprocessor": {
|
|
1044
1045
|
"cascadingStyleSheet": {
|
package/type.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import ImageMinimizerWebpackPlugin from 'image-minimizer-webpack-plugin';
|
|
|
8
8
|
import { JSDOM } from 'jsdom';
|
|
9
9
|
import MiniCSSExtractPlugin from 'mini-css-extract-plugin';
|
|
10
10
|
import { Options as RemoveDirectoryRecursivelyOptions } from 'rimraf';
|
|
11
|
+
import TerserWebpackPlugin from 'terser-webpack-plugin';
|
|
11
12
|
import { DefinePlugin as WebpackDefinePlugin, Configuration as BaseWebpackConfiguration, IgnorePlugin as WebpackIgnorePlugin, library as webpackLibrary, ModuleOptions as WebpackModuleOptions, RuleSetRule as WebpackRuleSetRule, RuleSetUseItem as WebpackRuleSetUseItem, WebpackOptionsNormalized } from 'webpack';
|
|
12
13
|
import OfflinePlugin, { CommonOptions as WorkboxCommonOptions, GenerateSWOptions as WorkboxGenerateSWOptions, InjectManifestOptions as WorkboxInjectManifestOptions } from 'workbox-webpack-plugin';
|
|
13
14
|
export interface Browser {
|
|
@@ -450,6 +451,7 @@ export declare type WebpackPlugins = Mapping<WebpackPlugin> & {
|
|
|
450
451
|
InjectManifest: typeof OfflinePlugin.InjectManifest;
|
|
451
452
|
};
|
|
452
453
|
MiniCSSExtract?: typeof MiniCSSExtractPlugin;
|
|
454
|
+
Terser?: typeof TerserWebpackPlugin;
|
|
453
455
|
};
|
|
454
456
|
export declare type WebpackResolveData = Parameters<WebpackIgnorePlugin['checkIgnore']>[0];
|
|
455
457
|
export declare type WebpackExtendedResolveData = WebpackResolveData & {
|
package/type.js
CHANGED
package/webpackConfigurator.js
CHANGED
|
@@ -64,9 +64,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
64
64
|
|
|
65
65
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
66
66
|
|
|
67
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
67
|
+
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; }
|
|
68
68
|
|
|
69
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
69
|
+
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; }
|
|
70
70
|
|
|
71
71
|
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; } } }; }
|
|
72
72
|
|
|
@@ -84,7 +84,8 @@ var pluginNameResourceMapping = {
|
|
|
84
84
|
MiniCSSExtract: 'mini-css-extract-plugin',
|
|
85
85
|
Favicon: 'favicons-webpack-plugin',
|
|
86
86
|
ImageMinimizer: 'image-minimizer-webpack-plugin',
|
|
87
|
-
Offline: 'workbox-webpack-plugin'
|
|
87
|
+
Offline: 'workbox-webpack-plugin',
|
|
88
|
+
Terser: 'terser-webpack-plugin'
|
|
88
89
|
};
|
|
89
90
|
var plugins = {};
|
|
90
91
|
|
|
@@ -560,11 +561,6 @@ if (htmlAvailable) pluginInstances.push({
|
|
|
560
561
|
});
|
|
561
562
|
}
|
|
562
563
|
}); // // endregion
|
|
563
|
-
// // region add automatic image compression
|
|
564
|
-
// NOTE: This plugin should be loaded at last to ensure that all emitted images
|
|
565
|
-
// ran through.
|
|
566
|
-
|
|
567
|
-
if (plugins.ImageMinimizer) pluginInstances.push(new plugins.ImageMinimizer(_module.optimizer.image.content)); // // endregion
|
|
568
564
|
// // region context replacements
|
|
569
565
|
|
|
570
566
|
var _iterator10 = _createForOfIteratorHelper(_module.replacements.context),
|
|
@@ -1181,6 +1177,7 @@ if (htmlAvailable && _configurator["default"].debug && _configurator["default"].
|
|
|
1181
1177
|
}
|
|
1182
1178
|
} // / endregion
|
|
1183
1179
|
// endregion
|
|
1180
|
+
// region plugins
|
|
1184
1181
|
|
|
1185
1182
|
|
|
1186
1183
|
var _iterator15 = _createForOfIteratorHelper(_configurator["default"].plugins),
|
|
@@ -1193,7 +1190,10 @@ try {
|
|
|
1193
1190
|
var _plugin = (0, _clientnode.optionalRequire)(pluginConfiguration.name.module);
|
|
1194
1191
|
|
|
1195
1192
|
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.');
|
|
1196
|
-
} //
|
|
1193
|
+
} // endregion
|
|
1194
|
+
// region minimizer and image compression
|
|
1195
|
+
// NOTE: This plugin should be loaded at last to ensure that all emitted images
|
|
1196
|
+
// ran through.
|
|
1197
1197
|
|
|
1198
1198
|
} catch (err) {
|
|
1199
1199
|
_iterator15.e(err);
|
|
@@ -1201,6 +1201,27 @@ try {
|
|
|
1201
1201
|
_iterator15.f();
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
|
+
if (!_module.optimizer.minimizer) {
|
|
1205
|
+
_module.optimizer.minimizer = [];
|
|
1206
|
+
if (plugins.Terser)
|
|
1207
|
+
/*
|
|
1208
|
+
HTML-Templates shouldn't be transformed via terser to avoid html
|
|
1209
|
+
webpack plugin throwing to not get markup as intermediate result.
|
|
1210
|
+
*/
|
|
1211
|
+
_module.optimizer.minimizer.push(new plugins.Terser({
|
|
1212
|
+
exclude: /\\.html(?:\\.js)?(?:\\?.*)?$/,
|
|
1213
|
+
extractComments: false,
|
|
1214
|
+
parallel: true
|
|
1215
|
+
}));
|
|
1216
|
+
if (plugins.ImageMinimizer) _module.optimizer.minimizer.push(new plugins.ImageMinimizer(_clientnode["default"].extend(true, {
|
|
1217
|
+
minimizer: {
|
|
1218
|
+
implementation: plugins.ImageMinimizer.imageminMinify
|
|
1219
|
+
}
|
|
1220
|
+
}, _module.optimizer.image.content)));
|
|
1221
|
+
} // endregion
|
|
1222
|
+
// region configuration
|
|
1223
|
+
|
|
1224
|
+
|
|
1204
1225
|
var customConfiguration = {};
|
|
1205
1226
|
if ((_configuration$path$c = _configurator["default"].path.configuration) !== null && _configuration$path$c !== void 0 && _configuration$path$c.json) try {
|
|
1206
1227
|
require.resolve(_configurator["default"].path.configuration.json);
|