weboptimizer 2.0.1205 → 2.0.1209

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "2.0.1205",
3
+ "version": "2.0.1209",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -81,6 +81,7 @@
81
81
  "update": "yarn version --patch && yarn publish",
82
82
  "update:documentation": "documentation-website"
83
83
  },
84
+ "runkitExample": "require('@babel/runtime/package.json')\n\nconst {default: main} = require('weboptimizer')\n\nawait main('./', './', ['clear'])",
84
85
  "dependencies": {
85
86
  "@babel/core": "*",
86
87
  "@babel/plugin-proposal-decorators": "*",
@@ -611,30 +612,26 @@
611
612
  },
612
613
  "favicon": {
613
614
  "background": "white",
614
- "emitStats": false,
615
- "icons": {
616
- "android": true,
617
- "appleIcon": true,
618
- "appleStartup": true,
619
- "coast": true,
620
- "favicons": true,
621
- "firefox": true,
622
- "opengraph": true,
623
- "twitter": true,
624
- "windows": true,
625
- "yandex": true
615
+ "cache": true,
616
+ "favicons": {
617
+ "appName": {
618
+ "__evaluate__": "self.name"
619
+ },
620
+ "icons": {
621
+ "android": true,
622
+ "appleIcon": true,
623
+ "appleStartup": true,
624
+ "favicons": true,
625
+ "windows": true,
626
+ "yandex": true
627
+ }
626
628
  },
627
629
  "inject": true,
628
630
  "logo": {
629
631
  "__evaluate__": "self.path.source.asset.favicon"
630
632
  },
631
- "persistentCache": true,
632
633
  "prefix": {
633
634
  "__evaluate__": "`${path.relative(self.path.target.base, path.resolve(self.path.target.asset.image, 'favicons-[chunkhash]'))}/`"
634
- },
635
- "statsFilename": "iconStats.json",
636
- "title": {
637
- "__evaluate__": "self.name"
638
635
  }
639
636
  },
640
637
  "files": {
package/readme.md CHANGED
@@ -31,6 +31,8 @@ Project status
31
31
  -->
32
32
  [![documentation website](https://img.shields.io/website-up-down-green-red/https/torben.website/weboptimizer.svg?label=documentation-website)](https://torben.website/weboptimizer)
33
33
 
34
+ [![Try out](https://badge.runkitcdn.com/weboptimizer.svg)](https://npm.runkit.com/weboptimizer)
35
+
34
36
  Use case
35
37
  --------
36
38
 
package/type.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="webpack-env" />
3
3
  import { AnyFunction, Encoding, Mapping, PlainObject, SecondParameter } from 'clientnode/type';
4
- import { FaviconStreamOptions } from 'favicons';
5
4
  import FaviconWebpackPlugin from 'favicons-webpack-plugin';
5
+ import { FaviconWebpackPlugionOptions as FaviconWebpackPluginOptions } from 'favicons-webpack-plugin/src/options';
6
6
  import HtmlWebpackPlugin from 'html-webpack-plugin';
7
7
  import ImageMinimizerWebpackPlugin, { PluginOptions as ImageMinimizerOptions } from 'image-minimizer-webpack-plugin';
8
8
  import { JSDOM } from 'jsdom';
@@ -278,9 +278,7 @@ export interface ResolvedConfiguration {
278
278
  self: ExportFormat;
279
279
  };
280
280
  extensions: Extensions;
281
- favicon: Mapping<FaviconStreamOptions> & {
282
- logo: string;
283
- };
281
+ favicon: FaviconWebpackPluginOptions;
284
282
  files: {
285
283
  additionalPaths: Array<string>;
286
284
  compose: {
@@ -1,3 +1,4 @@
1
1
  import { WebpackConfiguration } from './type';
2
+ export declare const optionalRequire: <T = unknown>(id: string) => T | null;
2
3
  export declare let webpackConfiguration: WebpackConfiguration;
3
4
  export default webpackConfiguration;
@@ -19,12 +19,10 @@
19
19
 
20
20
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
21
21
 
22
- var _typeof3 = require("@babel/runtime/helpers/typeof");
23
-
24
22
  Object.defineProperty(exports, "__esModule", {
25
23
  value: true
26
24
  });
27
- exports.webpackConfiguration = exports["default"] = void 0;
25
+ exports.webpackConfiguration = exports.optionalRequire = exports["default"] = void 0;
28
26
 
29
27
  var _construct2 = _interopRequireDefault(require("@babel/runtime/helpers/construct"));
30
28
 
@@ -36,7 +34,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
36
34
 
37
35
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
38
36
 
39
- var _clientnode = _interopRequireWildcard(require("clientnode"));
37
+ var _clientnode = _interopRequireDefault(require("clientnode"));
40
38
 
41
39
  var _jsdom = require("jsdom");
42
40
 
@@ -61,10 +59,6 @@ var _optionalRequire,
61
59
  _configuration$cache2,
62
60
  _configuration$path$c2;
63
61
 
64
- 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); }
65
-
66
- 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; }
67
-
68
62
  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; }
69
63
 
70
64
  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; }
@@ -75,12 +69,31 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
75
69
 
76
70
  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; }
77
71
 
78
- var postcssCSSnano = (0, _clientnode.optionalRequire)('cssnano');
79
- var postcssFontpath = (0, _clientnode.optionalRequire)('postcss-fontpath');
80
- var postcssImport = (0, _clientnode.optionalRequire)('postcss-import');
81
- var postcssSprites = (0, _clientnode.optionalRequire)('postcss-sprites');
82
- var updateRule = (_optionalRequire = (0, _clientnode.optionalRequire)('postcss-sprites/lib/core')) === null || _optionalRequire === void 0 ? void 0 : _optionalRequire.updateRule;
83
- var postcssURL = (0, _clientnode.optionalRequire)('postcss-url');
72
+ /// region optional imports
73
+ // NOTE: Has to be defined here to ensure to resolve from here.
74
+ var currentRequire =
75
+ /*
76
+ typeof __non_webpack_require__ === 'function' ?
77
+ __non_webpack_require__ :
78
+ */
79
+ eval("typeof require === 'undefined' ? null : require");
80
+
81
+ var optionalRequire = function optionalRequire(id) {
82
+ try {
83
+ return currentRequire ? currentRequire(id) : null;
84
+ } catch (error) {
85
+ return null;
86
+ }
87
+ };
88
+
89
+ exports.optionalRequire = optionalRequire;
90
+ var postcssCSSnano = optionalRequire('cssnano');
91
+ var postcssFontpath = optionalRequire('postcss-fontpath');
92
+ var postcssImport = optionalRequire('postcss-import');
93
+ var postcssSprites = optionalRequire('postcss-sprites');
94
+ var updateRule = (_optionalRequire = optionalRequire('postcss-sprites/lib/core')) === null || _optionalRequire === void 0 ? void 0 : _optionalRequire.updateRule;
95
+ var postcssURL = optionalRequire('postcss-url'); /// endregion
96
+
84
97
  var pluginNameResourceMapping = {
85
98
  HTML: 'html-webpack-plugin',
86
99
  MiniCSSExtract: 'mini-css-extract-plugin',
@@ -96,7 +109,7 @@ for (var _i = 0, _Object$entries = Object.entries(pluginNameResourceMapping); _i
96
109
  name = _Object$entries$_i[0],
97
110
  alias = _Object$entries$_i[1];
98
111
 
99
- var plugin = (0, _clientnode.optionalRequire)(alias);
112
+ var plugin = optionalRequire(alias);
100
113
  if (plugin) plugins[name] = plugin;else console.debug("Optional webpack plugin \"".concat(name, "\" not available."));
101
114
  }
102
115
 
@@ -819,7 +832,7 @@ var scope = {
819
832
  configuration: configuration,
820
833
  isFilePathInDependencies: isFilePathInDependencies,
821
834
  loader: loader,
822
- require: _clientnode.currentRequire
835
+ require: currentRequire
823
836
  };
824
837
 
825
838
  var evaluate = function evaluate(object) {
@@ -862,7 +875,7 @@ var cssUse = _module.preprocessor.cascadingStyleSheet.additional.pre.map(evaluat
862
875
  options: _module.cascadingStyleSheet.options || {}
863
876
  }, _module.preprocessor.cascadingStyleSheet.loader ? {
864
877
  loader: _module.preprocessor.cascadingStyleSheet.loader,
865
- options: _clientnode["default"].extend(true, (0, _clientnode.optionalRequire)('postcss') ? {
878
+ options: _clientnode["default"].extend(true, optionalRequire('postcss') ? {
866
879
  postcssOptions: {
867
880
  /*
868
881
  NOTE: Some plugins like "postcss-import" are
@@ -1216,7 +1229,7 @@ try {
1216
1229
  for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1217
1230
  var pluginConfiguration = _step15.value;
1218
1231
 
1219
- var _plugin = (0, _clientnode.optionalRequire)(pluginConfiguration.name.module);
1232
+ var _plugin = optionalRequire(pluginConfiguration.name.module);
1220
1233
 
1221
1234
  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.');
1222
1235
  } // endregion
@@ -1256,7 +1269,7 @@ if ((_configuration$path$c = configuration.path.configuration) !== null && _conf
1256
1269
  require.resolve(configuration.path.configuration.json);
1257
1270
 
1258
1271
  try {
1259
- customConfiguration = (0, _clientnode.currentRequire)(configuration.path.configuration.json);
1272
+ customConfiguration = currentRequire(configuration.path.configuration.json);
1260
1273
  } catch (error) {
1261
1274
  console.debug('Importing provided json webpack configuration file path ' + "under \"".concat(configuration.path.configuration.json, "\" failed: ") + _clientnode["default"].represent(error));
1262
1275
  }
@@ -1370,7 +1383,7 @@ if (!Array.isArray(_module.skipParseRegularExpressions) || _module.skipParseRegu
1370
1383
  if ((_configuration$path$c2 = configuration.path.configuration) !== null && _configuration$path$c2 !== void 0 && _configuration$path$c2.javaScript) try {
1371
1384
  require.resolve(configuration.path.configuration.javaScript);
1372
1385
 
1373
- var result = (0, _clientnode.optionalRequire)(configuration.path.configuration.javaScript);
1386
+ var result = optionalRequire(configuration.path.configuration.javaScript);
1374
1387
  if (_clientnode["default"].isPlainObject(result)) {
1375
1388
  if (Object.prototype.hasOwnProperty.call(result, 'replaceWebOptimizer')) exports.webpackConfiguration = webpackConfiguration = result.replaceWebOptimizer;else _clientnode["default"].extend(true, webpackConfiguration, result);
1376
1389
  } else console.debug('Failed to load given JavaScript configuration file path "' + "".concat(configuration.path.configuration.javaScript, "\"."));