weboptimizer 3.0.29 → 4.0.1

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/jestSetup.js CHANGED
@@ -16,12 +16,14 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- var _clientnode = require("clientnode");
20
- var _util = require("util");
21
- _clientnode.globalContext.TextEncoder = _util.TextEncoder;
22
- _clientnode.globalContext.TextDecoder = _util.TextDecoder;
19
+ import { globalContext } from 'clientnode';
20
+ import { TextEncoder, TextDecoder } from 'util'
21
+ // endregion
22
+ ;
23
+ globalContext.TextEncoder = TextEncoder;
24
+ globalContext.TextDecoder = TextDecoder;
23
25
  try {
24
26
  if (eval('require')('jest-canvas-mock')) console.info('Canvas mocking module loaded.');
25
- } catch (_unused) {
27
+ } catch {
26
28
  // Do nothing.
27
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "3.0.29",
3
+ "version": "4.0.1",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -63,11 +63,11 @@
63
63
  },
64
64
  "scripts": {
65
65
  "build": "yarn build:types; yarn build:lint; yarn build:plain",
66
- "build:lint": " babel --extensions '.ts' --plugins @babel/plugin-proposal-class-properties,@babel/plugin-syntax-top-level-await,babel-plugin-transform-modern-regexp --presets @babel/preset-typescript --out-file eslint.config.mjs eslint.config.ts",
67
- "build:plain": "command=\"babel --extensions '.ts' --plugins @babel/plugin-proposal-class-properties,@babel/plugin-syntax-top-level-await,@babel/plugin-transform-runtime,babel-plugin-transform-modern-regexp --presets @babel/preset-env,@babel/preset-typescript --out-file\" && $command browser.js browser.ts && $command configurator.js configurator.ts && $command ejsLoader.js ejsLoader.ts && $command helper.js helper.ts && $command index.js index.ts && $command jestSetup.js jestSetup.ts && $command plugins/HTMLTransformation.js plugins/HTMLTransformation.ts && $command plugins/InPlaceAssetsIntoHTML.js plugins/InPlaceAssetsIntoHTML.ts && $command stylelintConfigurator.js stylelintConfigurator.ts && $command type.js type.ts && $command webpackConfigurator.js webpackConfigurator.ts && shx chmod +x index.js && shx sed -i 's/(#!\\\\/usr\\\\/bin\\\\/env )babel-(node)/$1$2/' index.js 1>/dev/null",
66
+ "build:lint": " babel --extensions '.ts' --out-file eslint.config.mjs eslint.config.ts",
67
+ "build:plain": "command=\"babel --extensions '.ts' --out-file\" && $command browser.js browser.ts && $command configurator.js configurator.ts && $command ejsLoader.js ejsLoader.ts && $command helper.js helper.ts && $command index.js index.ts && $command jestSetup.js jestSetup.ts && $command plugins/HTMLTransformation.js plugins/HTMLTransformation.ts && $command plugins/InPlaceAssetsIntoHTML.js plugins/InPlaceAssetsIntoHTML.ts && $command stylelintConfigurator.js stylelintConfigurator.ts && $command type.js type.ts && $command webpackConfigurator.js webpackConfigurator.ts && shx chmod +x index.js && shx sed -i 's/(#!\\\\/usr\\\\/bin\\\\/env )babel-(node)/$1$2/' index.js 1>/dev/null",
68
68
  "build:copy-test-artefacts": "cd test/simple && shx touch yarn.lock && rimraf node_modules && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install; cd ../../ && cd test/scss && shx touch yarn.lock && rimraf node_modules && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install; cd ../../ && rimraf node_modules/weboptimizer test/simple/node_modules/weboptimizer test/scss/node_modules/weboptimizer && shx mkdir -p node_modules/weboptimizer test/simple/node_modules/weboptimizer test/scss/node_modules/weboptimizer && copyCommand='shx cp -r plugins *.ts *.js *.mjs *.json *.ejs' && $copyCommand node_modules/weboptimizer/ && $copyCommand test/simple/node_modules/weboptimizer/ && $copyCommand test/scss/node_modules/weboptimizer/",
69
- "build:test": " yarn clear && yarn build && command='babel --extensions '.ts' --plugins @babel/plugin-proposal-class-properties,@babel/plugin-syntax-top-level-await,@babel/plugin-transform-runtime --presets @babel/preset-env,@babel/preset-typescript --source-root ../ --out-file' && yarn build:copy-test-artefacts && $command test/browser.js test/browser.ts && $command test/configurator.js test/configurator.ts && $command test/helper.js test/helper.ts && $command test/ejsLoader.js test/ejsLoader.ts && $command test/stylelintConfigurator.js test/stylelintConfigurator.ts && $command test/index.js test/index.ts && $command test/webpackConfigurator.js test/webpackConfigurator.ts",
70
- "build:test:source-map": "yarn clear && yarn build && command='babel --extensions '.ts' --plugins @babel/plugin-proposal-class-properties,@babel/plugin-syntax-top-level-await,@babel/plugin-transform-runtime --presets @babel/preset-env,@babel/preset-typescript --source-maps inline --source-root ../ --out-file' && yarn build:copy-test-artefacts && $command test/browser.js test/browser.ts && $command test/configurator.js test/configurator.ts && $command test/helper.js test/helper.ts && $command test/ejsLoader.js test/ejsLoader.ts && $command test/stylelintConfigurator.js test/stylelintConfigurator.ts && $command test/index.js test/index.ts && $command test/webpackConfigurator.js test/webpackConfigurator.ts",
69
+ "build:test": " yarn clear && yarn build && command='babel --extensions '.ts' --source-root ../ --out-file' && yarn build:copy-test-artefacts && $command test/browser.js test/browser.ts && $command test/configurator.js test/configurator.ts && $command test/helper.js test/helper.ts && $command test/ejsLoader.js test/ejsLoader.ts && $command test/stylelintConfigurator.js test/stylelintConfigurator.ts && $command test/index.js test/index.ts && $command test/webpackConfigurator.js test/webpackConfigurator.ts",
70
+ "build:test:source-map": "yarn clear && yarn build && command='babel --extensions '.ts' --source-maps inline --source-root ../ --out-file' && yarn build:copy-test-artefacts && $command test/browser.js test/browser.ts && $command test/configurator.js test/configurator.ts && $command test/helper.js test/helper.ts && $command test/ejsLoader.js test/ejsLoader.ts && $command test/stylelintConfigurator.js test/stylelintConfigurator.ts && $command test/index.js test/index.ts && $command test/webpackConfigurator.js test/webpackConfigurator.ts",
71
71
  "build:types": "tsc --declaration --emitDeclarationOnly",
72
72
  "check": "yarn check:types; yarn lint",
73
73
  "check:types": "tsc --noEmit",
@@ -85,17 +85,13 @@
85
85
  "update:documentation": "web-documentation"
86
86
  },
87
87
  "dependencies": {
88
- "@babel/core": "^7.29.7",
89
- "@babel/plugin-proposal-class-properties": "^7.18.6",
90
- "@babel/plugin-proposal-decorators": "^7.29.7",
91
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
92
- "@babel/plugin-syntax-top-level-await": "^7.14.5",
93
- "@babel/plugin-transform-runtime": "^7.29.7",
94
- "@babel/preset-env": "^7.29.7",
95
- "@babel/preset-typescript": "^7.29.7",
96
- "@babel/runtime": "^7.29.7",
88
+ "@babel/core": "^8.0.1",
89
+ "@babel/plugin-proposal-decorators": "^8.0.2",
90
+ "@babel/plugin-transform-class-properties": "^8.0.1",
91
+ "@babel/preset-env": "^8.0.2",
92
+ "@babel/preset-typescript": "^8.0.1",
97
93
  "babel-loader": "^10.1.1",
98
- "babel-plugin-transform-modern-regexp": "^0.0.6",
94
+ "babel-plugin-polyfill-corejs3": "^1.0.0",
99
95
  "babel-preset-minify": "^0.5.2",
100
96
  "clientnode": "4.0.1428",
101
97
  "ejs": "^6.0.1",
@@ -115,8 +111,8 @@
115
111
  "webpack-sources": "^3.5.0"
116
112
  },
117
113
  "devDependencies": {
118
- "@babel/cli": "^7.29.7",
119
- "@babel/eslint-parser": "^7.29.7",
114
+ "@babel/cli": "^8.0.1",
115
+ "@babel/eslint-parser": "^8.0.1",
120
116
  "@eslint/js": "^10.0.1",
121
117
  "@stylistic/eslint-plugin": "^5.10.0",
122
118
  "@types/ejs": "^3.1.5",
@@ -124,7 +120,7 @@
124
120
  "@types/html-minifier": "^4.0.6",
125
121
  "@types/html-minifier-terser": "^7.0.2",
126
122
  "@types/imagemin": "^9.0.1",
127
- "@types/node": "^25.9.4",
123
+ "@types/node": "^26.0.1",
128
124
  "@types/postcss-import": "^14.0.3",
129
125
  "@types/postcss-url": "^10.0.4",
130
126
  "@types/webpack-env": "^1.18.8",
@@ -1183,9 +1179,7 @@
1183
1179
  "minified": {
1184
1180
  "__evaluate__": "!self.debug"
1185
1181
  },
1186
- "#": "NOTE: \"@babel/plugin-proposal-nullish-coalescing-operator\" and \"@babel/plugin-proposal-optional-chaining\" is needed to let typescript be able to parse result. \"@babel/plugin-transform-parameters\" is needed caused by a bug when transforming parameters coming from the preceding transformer.",
1187
1182
  "plugins": [
1188
- "@babel/plugin-proposal-nullish-coalescing-operator",
1189
1183
  [
1190
1184
  "@babel/plugin-proposal-decorators",
1191
1185
  {
@@ -1199,10 +1193,7 @@
1199
1193
  }
1200
1194
  ],
1201
1195
  [
1202
- "@babel/proposal-class-properties",
1203
- {
1204
- "loose": true
1205
- }
1196
+ "@babel/plugin-transform-class-properties"
1206
1197
  ],
1207
1198
  [
1208
1199
  "transform-modern-regexp",
@@ -1213,11 +1204,11 @@
1213
1204
  ]
1214
1205
  }
1215
1206
  ],
1216
- "@babel/plugin-transform-runtime"
1207
+ "babel-plugin-polyfill-corejs3"
1217
1208
  ],
1218
1209
  "presets": {
1219
1210
  "#": "NOTE: We have to disable module export/import transformation to allow tree shaking by the final (minimizer).",
1220
- "__evaluate__": "[['@babel/preset-env', {loose: true, modules: false, targets: self.generic.isWeb ? {browsers: self.generic.supportedBrowsers, node: packageConfiguration.engines.node.replace(/>?=?([0-9]+)/, '$1')} : {node: packageConfiguration.engines.node.replace(/>?=?([0-9]+)/, '$1')}}], '@babel/preset-typescript'].concat((self.debug || !self.module.optimizer.babelMinify.module || 2 < self.givenCommandLineArguments.length && self.givenCommandLineArguments[2] === 'document') ? [] : [['minify', self.module.optimizer.babelMinify.module]])"
1211
+ "__evaluate__": "[['@babel/preset-env', {modules: false, targets: self.generic.isWeb ? {browsers: self.generic.supportedBrowsers, node: packageConfiguration.engines.node.replace(/>?=?([0-9]+)/, '$1')} : {node: packageConfiguration.engines.node.replace(/>?=?([0-9]+)/, '$1')}}], '@babel/preset-typescript'].concat((self.debug || !self.module.optimizer.babelMinify.module || 2 < self.givenCommandLineArguments.length && self.givenCommandLineArguments[2] === 'document') ? [] : [['minify', self.module.optimizer.babelMinify.module]])"
1221
1212
  }
1222
1213
  },
1223
1214
  "regularExpression": "\\.[jt]sx?(?:\\?.*)?$"
@@ -16,119 +16,78 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
20
- Object.defineProperty(exports, "__esModule", {
21
- value: true
22
- });
23
- exports["default"] = exports.HTMLTransformation = void 0;
24
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
25
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
26
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
27
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
28
- var _clientnode = require("clientnode");
29
- var _jsdom = require("jsdom");
30
- var _ejsLoader = _interopRequireDefault(require("../ejsLoader"));
31
- 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; } } }; }
32
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
33
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
34
- 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; }
35
- 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; }
19
+ import "core-js/modules/es.array.push.js";
20
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ import { copy, extend, Mapping } from 'clientnode';
24
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
25
+ import { JSDOM as DOM } from 'jsdom';
26
+ import { Compilation, Compiler, LoaderContext } from 'webpack';
27
+ import ejsLoader, { LoaderConfiguration as EJSLoaderConfiguration } from '../ejsLoader';
28
+ import { HTMLTransformationOptions, HTMLWebpackPluginBeforeEmitData, WebpackLoader } from '../type';
36
29
  // endregion
37
- var HTMLTransformation = exports.HTMLTransformation = /*#__PURE__*/function () {
38
- function HTMLTransformation() {
39
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
- (0, _classCallCheck2["default"])(this, HTMLTransformation);
41
- (0, _defineProperty2["default"])(this, "defaultOptions", {});
42
- this.options = _objectSpread(_objectSpread({}, this.defaultOptions), options);
30
+
31
+ export class HTMLTransformation {
32
+ constructor(options = {}) {
33
+ _defineProperty(this, "defaultOptions", {});
34
+ _defineProperty(this, "options", void 0);
35
+ this.options = {
36
+ ...this.defaultOptions,
37
+ ...options
38
+ };
43
39
  }
44
- return (0, _createClass2["default"])(HTMLTransformation, [{
45
- key: "process",
46
- value: function process(data) {
40
+ process(data) {
41
+ /*
42
+ NOTE: We have to prevent creating native "style" dom nodes to
43
+ prevent jsdom from parsing the entire cascading style sheet. Which
44
+ is error prune and very resource intensive.
45
+ */
46
+ const styleContents = [];
47
+ data.html = data.html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style[^>]*>)/gi, (match, startTag, content, endTag) => {
48
+ styleContents.push(content);
49
+ return `${startTag}${endTag}`;
50
+ });
51
+ let dom;
52
+ try {
47
53
  /*
48
- NOTE: We have to prevent creating native "style" dom nodes to
49
- prevent jsdom from parsing the entire cascading style sheet. Which
50
- is error prune and very resource intensive.
54
+ NOTE: We have to translate template delimiter to html
55
+ compatible sequences and translate it back later to avoid
56
+ unexpected escape sequences in resulting html.
51
57
  */
52
- var styleContents = [];
53
- data.html = data.html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style[^>]*>)/gi, function (match, startTag, content, endTag) {
54
- styleContents.push(content);
55
- return "".concat(startTag).concat(endTag);
56
- });
57
- var dom;
58
- try {
59
- /*
60
- NOTE: We have to translate template delimiter to html
61
- compatible sequences and translate it back later to avoid
62
- unexpected escape sequences in resulting html.
63
- */
64
- dom = new _jsdom.JSDOM(data.html.replace(/<%/g, '##+#+#+##').replace(/%>/g, '##-#-#-##'));
65
- } catch (_unused) {
66
- return data;
67
- }
68
- var linkables = {
69
- link: 'href',
70
- script: 'src'
71
- };
72
- for (var _i = 0, _Object$entries = Object.entries(linkables); _i < _Object$entries.length; _i++) {
73
- var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
74
- tagName = _Object$entries$_i[0],
75
- attributeName = _Object$entries$_i[1];
76
- for (var _i2 = 0, _Array$from = Array.from(dom.window.document.querySelectorAll("".concat(tagName, "[").concat(attributeName, "*=\"?") + "".concat(this.options.hashAlgorithm, "=\"]"))); _i2 < _Array$from.length; _i2++) {
77
- var domNode = _Array$from[_i2];
78
- /*
79
- NOTE: Removing symbols after a "&" in hash string is
80
- necessary to match the generated request strings in offline
81
- plugin.
82
- */
83
- var value = domNode.getAttribute(attributeName);
84
- if (value) domNode.setAttribute(attributeName, value.replace(new RegExp("(\\?".concat(this.options.hashAlgorithm, "=[^&]+).*$")), '$1'));
85
- }
86
- }
87
- // NOTE: We have to restore template delimiter and style contents.
88
- data.html = dom.serialize().replace(/##\+#\+#\+##/g, '<%').replace(/##-#-#-##/g, '%>').replace(/(<style[^>]*>)[\s\S]*?(<\/style[^>]*>)/gi, function (match, startTag, endTag) {
89
- return "".concat(startTag).concat(styleContents.shift()).concat(endTag);
90
- });
91
- // region post compilation
92
- var _iterator = _createForOfIteratorHelper(this.options.files),
93
- _step;
94
- try {
95
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
96
- var htmlFileSpecification = _step.value;
97
- if (htmlFileSpecification.filename === data.plugin.options.filename) {
98
- var _iterator2 = _createForOfIteratorHelper([].concat(htmlFileSpecification.template.use)),
99
- _step2;
100
- try {
101
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
102
- var _loaderConfiguration$;
103
- var loaderConfiguration = _step2.value;
104
- if ((_loaderConfiguration$ = loaderConfiguration.options) !== null && _loaderConfiguration$ !== void 0 && _loaderConfiguration$.compileSteps && typeof loaderConfiguration.options.compileSteps === 'number') data.html = _ejsLoader["default"].bind({
105
- query: (0, _clientnode.extend)(true, Object.prototype.hasOwnProperty.call(loaderConfiguration, 'options') ? (0, _clientnode.copy)(loaderConfiguration.options) : {}, htmlFileSpecification.template.postCompileOptions)
106
- })(data.html);
107
- }
108
- } catch (err) {
109
- _iterator2.e(err);
110
- } finally {
111
- _iterator2.f();
112
- }
113
- break;
114
- }
115
- }
116
- // endregion
117
- } catch (err) {
118
- _iterator.e(err);
119
- } finally {
120
- _iterator.f();
121
- }
58
+ dom = new DOM(data.html.replace(/<%/g, '##+#+#+##').replace(/%>/g, '##-#-#-##'));
59
+ } catch {
122
60
  return data;
123
61
  }
124
- }, {
125
- key: "apply",
126
- value: function apply(compiler) {
127
- var _this = this;
128
- compiler.hooks.compilation.tap('WebOptimizer', function (compilation) {
129
- _this.options.htmlPlugin.getHooks(compilation).beforeEmit.tap('WebOptimizerPostProcessHTML', _this.process.bind(_this));
130
- });
62
+ const linkables = {
63
+ link: 'href',
64
+ script: 'src'
65
+ };
66
+ for (const [tagName, attributeName] of Object.entries(linkables)) for (const domNode of Array.from(dom.window.document.querySelectorAll(`${tagName}[${attributeName}*="?` + `${this.options.hashAlgorithm}="]`))) {
67
+ /*
68
+ NOTE: Removing symbols after a "&" in hash string is
69
+ necessary to match the generated request strings in offline
70
+ plugin.
71
+ */
72
+ const value = domNode.getAttribute(attributeName);
73
+ if (value) domNode.setAttribute(attributeName, value.replace(new RegExp(`(\\?${this.options.hashAlgorithm}=[^&]+).*$`), '$1'));
74
+ }
75
+ // NOTE: We have to restore template delimiter and style contents.
76
+ data.html = dom.serialize().replace(/##\+#\+#\+##/g, '<%').replace(/##-#-#-##/g, '%>').replace(/(<style[^>]*>)[\s\S]*?(<\/style[^>]*>)/gi, (match, startTag, endTag) => `${startTag}${styleContents.shift()}${endTag}`);
77
+ // region post compilation
78
+ for (const htmlFileSpecification of this.options.files) if (htmlFileSpecification.filename === data.plugin.options.filename) {
79
+ for (const loaderConfiguration of [].concat(htmlFileSpecification.template.use)) if (loaderConfiguration.options?.compileSteps && typeof loaderConfiguration.options.compileSteps === 'number') data.html = ejsLoader.bind({
80
+ query: extend(true, Object.prototype.hasOwnProperty.call(loaderConfiguration, 'options') ? copy(loaderConfiguration.options) : {}, htmlFileSpecification.template.postCompileOptions)
81
+ })(data.html);
82
+ break;
131
83
  }
132
- }]);
133
- }();
134
- var _default = exports["default"] = HTMLTransformation;
84
+ // endregion
85
+ return data;
86
+ }
87
+ apply(compiler) {
88
+ compiler.hooks.compilation.tap('WebOptimizer', compilation => {
89
+ this.options.htmlPlugin.getHooks(compilation).beforeEmit.tap('WebOptimizerPostProcessHTML', this.process.bind(this));
90
+ });
91
+ }
92
+ }
93
+ export default HTMLTransformation;
@@ -16,76 +16,73 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
20
- Object.defineProperty(exports, "__esModule", {
21
- value: true
22
- });
23
- exports["default"] = exports.InPlaceAssetsIntoHTML = void 0;
24
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
25
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
26
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
- 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; }
28
- 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; }
19
+ import "core-js/modules/es.array.push.js";
20
+ import "core-js/modules/es.iterator.constructor.js";
21
+ import "core-js/modules/es.iterator.map.js";
22
+ import "core-js/modules/es.iterator.some.js";
23
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
25
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
+ import { Compilation, Compiler } from 'webpack';
27
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
28
+ import { InPlaceAssetConfiguration, InPlaceAssetsIntoHTMLOptions, WebpackAssets, WebpackBaseAssets } from '../type';
29
29
  // endregion
30
- var InPlaceAssetsIntoHTML = exports.InPlaceAssetsIntoHTML = /*#__PURE__*/function () {
31
- function InPlaceAssetsIntoHTML() {
32
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
- (0, _classCallCheck2["default"])(this, InPlaceAssetsIntoHTML);
34
- (0, _defineProperty2["default"])(this, "defaultOptions", {});
35
- this.options = _objectSpread(_objectSpread({}, this.defaultOptions), options);
36
- }
37
- return (0, _createClass2["default"])(InPlaceAssetsIntoHTML, [{
38
- key: "apply",
39
- value: function apply(compiler) {
40
- var _this = this;
41
- var publicPath = compiler.options.output.publicPath || '';
42
- if (publicPath && !publicPath.endsWith('/')) publicPath += '/';
43
- compiler.hooks.compilation.tap('inPlaceHTMLAssets', function (compilation) {
44
- var hooks = _this.options.htmlPlugin.getHooks(compilation);
45
- var inPlacedAssetNames = [];
46
- hooks.alterAssetTagGroups.tap('inPlaceHTMLAssets', function (assets) {
47
- var inPlace = function inPlace(type, tag) {
48
- var settings = null;
49
- var url = false;
50
- if (tag.tagName === 'script') {
51
- settings = _this.options.javaScript;
52
- url = tag.attributes.src;
53
- } else if (tag.tagName === 'style') {
54
- settings = _this.options.cascadingStyleSheet;
55
- url = tag.attributes.href;
56
- }
57
- if (!(url && typeof url === 'string')) return tag;
58
- var name = publicPath ? url.replace(publicPath, '') : url;
59
- if (Object.prototype.hasOwnProperty.call(compilation.assets, name) && settings && settings[type] && [].concat(settings[type]).some(function (pattern) {
60
- return new RegExp(pattern).test(name);
61
- })) {
62
- var newAttributes = _objectSpread({}, tag.attributes);
63
- delete newAttributes.href;
64
- delete newAttributes.src;
65
- inPlacedAssetNames.push(name);
66
- return _objectSpread(_objectSpread({}, tag), {}, {
67
- attributes: newAttributes,
68
- innerHTML: compilation.assets[name].source(),
69
- tagName: 'script'
70
- });
71
- }
72
- return tag;
73
- };
74
- assets.headTags = assets.headTags.map(inPlace.bind(_this, 'head'));
75
- assets.bodyTags = assets.bodyTags.map(inPlace.bind(_this, 'body'));
76
- return assets;
77
- });
78
30
 
79
- // NOTE: Avoid if you still want to emit the runtime chunks:
80
- hooks.afterEmit.tap('inPlaceHTMLAssets', function (asset) {
81
- for (var _i = 0, _inPlacedAssetNames = inPlacedAssetNames; _i < _inPlacedAssetNames.length; _i++) {
82
- var name = _inPlacedAssetNames[_i];
83
- delete compilation.assets[name];
31
+ export class InPlaceAssetsIntoHTML {
32
+ constructor(options = {}) {
33
+ _defineProperty(this, "defaultOptions", {});
34
+ _defineProperty(this, "options", void 0);
35
+ this.options = {
36
+ ...this.defaultOptions,
37
+ ...options
38
+ };
39
+ }
40
+ apply(compiler) {
41
+ let publicPath = compiler.options.output.publicPath || '';
42
+ if (publicPath && !publicPath.endsWith('/')) publicPath += '/';
43
+ compiler.hooks.compilation.tap('inPlaceHTMLAssets', compilation => {
44
+ const hooks = this.options.htmlPlugin.getHooks(compilation);
45
+ const inPlacedAssetNames = [];
46
+ hooks.alterAssetTagGroups.tap('inPlaceHTMLAssets', assets => {
47
+ const inPlace = (type, tag) => {
48
+ let settings = null;
49
+ let url = false;
50
+ if (tag.tagName === 'script') {
51
+ settings = this.options.javaScript;
52
+ url = tag.attributes.src;
53
+ } else if (tag.tagName === 'style') {
54
+ settings = this.options.cascadingStyleSheet;
55
+ url = tag.attributes.href;
56
+ }
57
+ if (!(url && typeof url === 'string')) return tag;
58
+ const name = publicPath ? url.replace(publicPath, '') : url;
59
+ if (Object.prototype.hasOwnProperty.call(compilation.assets, name) && settings && settings[type] && [].concat(settings[type]).some(pattern => new RegExp(pattern).test(name))) {
60
+ const newAttributes = {
61
+ ...tag.attributes
62
+ };
63
+ delete newAttributes.href;
64
+ delete newAttributes.src;
65
+ inPlacedAssetNames.push(name);
66
+ return {
67
+ ...tag,
68
+ attributes: newAttributes,
69
+ innerHTML: compilation.assets[name].source(),
70
+ tagName: 'script'
71
+ };
84
72
  }
85
- return asset;
86
- });
73
+ return tag;
74
+ };
75
+ assets.headTags = assets.headTags.map(inPlace.bind(this, 'head'));
76
+ assets.bodyTags = assets.bodyTags.map(inPlace.bind(this, 'body'));
77
+ return assets;
87
78
  });
88
- }
89
- }]);
90
- }();
91
- var _default = exports["default"] = InPlaceAssetsIntoHTML;
79
+
80
+ // NOTE: Avoid if you still want to emit the runtime chunks:
81
+ hooks.afterEmit.tap('inPlaceHTMLAssets', asset => {
82
+ for (const name of inPlacedAssetNames) delete compilation.assets[name];
83
+ return asset;
84
+ });
85
+ });
86
+ }
87
+ }
88
+ export default InPlaceAssetsIntoHTML;
@@ -16,13 +16,9 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
20
- Object.defineProperty(exports, "__esModule", {
21
- value: true
22
- });
23
- exports["default"] = void 0;
24
- var _configurator = _interopRequireDefault(require("./configurator"));
19
+ import getConfiguration from './configurator';
20
+ import { ResolvedConfiguration } from './type';
25
21
  // endregion
26
- var configuration = (0, _configurator["default"])();
22
+ const configuration = getConfiguration();
27
23
  module.exports = configuration.stylelint;
28
- var _default = exports["default"] = module.exports;
24
+ export default module.exports;
package/type.js CHANGED
@@ -16,24 +16,33 @@
16
16
  endregion
17
17
  */
18
18
  // region imports
19
- Object.defineProperty(exports, "__esModule", {
20
- value: true
21
- });
22
- exports.TaskTypes = exports.SubConfigurationTypes = void 0;
19
+ import { AnyFunction, Encoding, Mapping, PlainObject, SecondParameter } from 'clientnode';
20
+ import { FaviconWebpackPlugionOptions as FaviconWebpackPluginOptions } from 'favicons-webpack-plugin/src/options';
21
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
22
+ import { PluginOptions as ImageMinimizerOptions } from 'image-minimizer-webpack-plugin';
23
+ import { JSDOM } from 'jsdom';
24
+ 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';
25
+ import { WebpackPartial as WorkboxBaseCommonOptions, BasePartial as WorkboxCommonOptions, WebpackGenerateSWOptions as WorkboxGenerateSWOptions, WebpackInjectManifestOptions as WorkboxInjectManifestOptions } from 'workbox-build';
26
+
23
27
  // endregion
24
28
  // region exports
25
29
  /// region generic
30
+
26
31
  /// endregion
27
32
  /// region injection
33
+
28
34
  /// endregion
29
35
  /// region configuration
30
36
  // region plugins
37
+
31
38
  // endregion
32
39
  //// region path
40
+
33
41
  //// endregion
34
42
  //// region build
35
- var SubConfigurationTypes = exports.SubConfigurationTypes = ['debug', 'document', 'test', 'test:browser'];
36
- var TaskTypes = exports.TaskTypes = ['build', 'serve'].concat(SubConfigurationTypes);
43
+
44
+ export const SubConfigurationTypes = ['debug', 'document', 'test', 'test:browser'];
45
+ export const TaskTypes = ['build', 'serve', ...SubConfigurationTypes];
37
46
  //// endregion
38
47
  //// region loader
39
48