From 2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4 Mon Sep 17 00:00:00 2001 From: Aaron Melocik Date: Mon, 16 Aug 2021 15:21:03 -0700 Subject: [PATCH 01/13] Remove archived plugin The plugin at https://github.com/GoogleChrome/preload-webpack-plugin is in archive-only mode and is implemented by the (maintained) https://github.com/jantimon/resource-hints-webpack-plugin or https://github.com/principalstudio/html-webpack-inject-preload --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a06e48b7..a27337fb 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp * [html-webpack-include-assets-plugin](https://github.com/jharris4/html-webpack-include-assets-plugin) for including lists of js or css file paths (such as those copied by the copy-webpack-plugin). * [html-webpack-injector](https://github.com/thearchitgarg/html-webpack-injector) to inject chunks in `head` or `body` (different locations ) of same html document. * [resource-hints-webpack-plugin](https://github.com/jantimon/resource-hints-webpack-plugin) to add resource hints for faster initial page loads using `` and `` - * [preload-webpack-plugin](https://github.com/GoogleChrome/preload-webpack-plugin) for automatically wiring up asynchronous (and other types) of JavaScript chunks using `` helping with lazy-loading * [link-media-html-webpack-plugin](https://github.com/yaycmyk/link-media-html-webpack-plugin) allows for injected stylesheet `` tags to have their media attribute set automatically; useful for providing specific desktop/mobile/print etc. stylesheets that the browser will conditionally download * [html-webpack-inline-style-plugin](https://github.com/djaax/html-webpack-inline-style-plugin) for inlining styles to HTML elements using [juice](https://github.com/Automattic/juice). Useful for email generation automatisation. * [html-webpack-exclude-empty-assets-plugin](https://github.com/KnisterPeter/html-webpack-exclude-empty-assets-plugin) removes empty assets from being added to the html. This fixes some problems with extract-text-plugin with webpack 4. From d62a10f306d8ec6a07aec779758af674e0632881 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Wed, 29 Sep 2021 13:18:54 -0700 Subject: [PATCH 02/13] [chore] upgrades html-minifier-terser@5.0.0 -> 6.0.2 --- index.js | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 45f286ad..b82f6c52 100644 --- a/index.js +++ b/index.js @@ -1041,12 +1041,12 @@ function hookIntoCompiler (compiler, options, plugin) { * * @param {string} html */ - function minifyHtml (html) { + async function minifyHtml (html) { if (typeof options.minify !== 'object') { return html; } try { - return require('html-minifier-terser').minify(html, options.minify); + return await require('html-minifier-terser').minify(html, options.minify); } catch (e) { const isParseError = String(e.message).indexOf('Parse Error') === 0; if (isParseError) { diff --git a/package.json b/package.json index e4c9407e..067e9977 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,8 @@ "webpack-recompilation-simulator": "3.2.0" }, "dependencies": { - "@types/html-minifier-terser": "^5.0.0", - "html-minifier-terser": "^5.0.1", + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", "lodash": "^4.17.21", "pretty-error": "^3.0.4", "tapable": "^2.0.0" From f08bd025e34166612226e07213eb40cacf5eacb3 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Wed, 29 Sep 2021 13:38:56 -0700 Subject: [PATCH 03/13] [chore] updates fixtures --- examples/custom-template/dist/webpack-5/bundle.js | 5 ++--- examples/default/dist/webpack-5/bundle.js | 5 ++--- examples/favicon/dist/webpack-5/bundle.js | 5 ++--- examples/html-loader/dist/webpack-5/bundle.js | 5 ++--- examples/inline/dist/webpack-5/bundle.js | 5 ++--- examples/inline/dist/webpack-5/index.html | 5 ++--- examples/javascript-advanced/dist/webpack-5/bundle.js | 5 ++--- examples/javascript/dist/webpack-5/bundle.js | 5 ++--- examples/multi-page/dist/webpack-5/first.js | 5 ++--- examples/multi-page/dist/webpack-5/second.js | 5 ++--- examples/pug-loader/dist/webpack-5/bundle.js | 9 ++++----- examples/sort-manually/dist/webpack-5/a.js | 5 ++--- 12 files changed, 26 insertions(+), 38 deletions(-) diff --git a/examples/custom-template/dist/webpack-5/bundle.js b/examples/custom-template/dist/webpack-5/bundle.js index 11f6fc71..62ede7bd 100644 --- a/examples/custom-template/dist/webpack-5/bundle.js +++ b/examples/custom-template/dist/webpack-5/bundle.js @@ -19,9 +19,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/default/dist/webpack-5/bundle.js b/examples/default/dist/webpack-5/bundle.js index 74c2c303..6f94dfe5 100644 --- a/examples/default/dist/webpack-5/bundle.js +++ b/examples/default/dist/webpack-5/bundle.js @@ -405,9 +405,8 @@ module.exports = function (list, options) { /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/favicon/dist/webpack-5/bundle.js b/examples/favicon/dist/webpack-5/bundle.js index 11f6fc71..62ede7bd 100644 --- a/examples/favicon/dist/webpack-5/bundle.js +++ b/examples/favicon/dist/webpack-5/bundle.js @@ -19,9 +19,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/html-loader/dist/webpack-5/bundle.js b/examples/html-loader/dist/webpack-5/bundle.js index 11f6fc71..62ede7bd 100644 --- a/examples/html-loader/dist/webpack-5/bundle.js +++ b/examples/html-loader/dist/webpack-5/bundle.js @@ -19,9 +19,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/inline/dist/webpack-5/bundle.js b/examples/inline/dist/webpack-5/bundle.js index 46f301a8..e8487f4b 100644 --- a/examples/inline/dist/webpack-5/bundle.js +++ b/examples/inline/dist/webpack-5/bundle.js @@ -19,9 +19,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/inline/dist/webpack-5/index.html b/examples/inline/dist/webpack-5/index.html index 0477e011..c401f660 100644 --- a/examples/inline/dist/webpack-5/index.html +++ b/examples/inline/dist/webpack-5/index.html @@ -21,9 +21,8 @@ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/javascript-advanced/dist/webpack-5/bundle.js b/examples/javascript-advanced/dist/webpack-5/bundle.js index 235bdd89..21942cec 100644 --- a/examples/javascript-advanced/dist/webpack-5/bundle.js +++ b/examples/javascript-advanced/dist/webpack-5/bundle.js @@ -40,9 +40,8 @@ eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extr /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/javascript/dist/webpack-5/bundle.js b/examples/javascript/dist/webpack-5/bundle.js index d6c3e3c3..75d23d21 100644 --- a/examples/javascript/dist/webpack-5/bundle.js +++ b/examples/javascript/dist/webpack-5/bundle.js @@ -37,9 +37,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/multi-page/dist/webpack-5/first.js b/examples/multi-page/dist/webpack-5/first.js index 74c2c303..6f94dfe5 100644 --- a/examples/multi-page/dist/webpack-5/first.js +++ b/examples/multi-page/dist/webpack-5/first.js @@ -405,9 +405,8 @@ module.exports = function (list, options) { /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/multi-page/dist/webpack-5/second.js b/examples/multi-page/dist/webpack-5/second.js index 74c2c303..6f94dfe5 100644 --- a/examples/multi-page/dist/webpack-5/second.js +++ b/examples/multi-page/dist/webpack-5/second.js @@ -405,9 +405,8 @@ module.exports = function (list, options) { /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/pug-loader/dist/webpack-5/bundle.js b/examples/pug-loader/dist/webpack-5/bundle.js index e51f2102..73b20e76 100644 --- a/examples/pug-loader/dist/webpack-5/bundle.js +++ b/examples/pug-loader/dist/webpack-5/bundle.js @@ -284,7 +284,7 @@ function pug_rethrow(err, filename, lineno, str) { } var context, lines, start, end; try { - str = str || __webpack_require__(672).readFileSync(filename, {encoding: 'utf8'}); + str = str || __webpack_require__(993).readFileSync(filename, {encoding: 'utf8'}); context = 3; lines = str.split('\n'); start = Math.max(lineno - context, 0); @@ -323,7 +323,7 @@ function pug_rethrow(err, filename, lineno, str) { /***/ }), -/***/ 672: +/***/ 993: /***/ (() => { /* (ignored) */ @@ -338,9 +338,8 @@ function pug_rethrow(err, filename, lineno, str) { /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { diff --git a/examples/sort-manually/dist/webpack-5/a.js b/examples/sort-manually/dist/webpack-5/a.js index 3dd2e8c3..8a6b9450 100644 --- a/examples/sort-manually/dist/webpack-5/a.js +++ b/examples/sort-manually/dist/webpack-5/a.js @@ -19,9 +19,8 @@ __webpack_require__.r(__webpack_exports__); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { From e38ac97683664b902f55b3682e3cf8c1136af8bc Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Sat, 9 Oct 2021 10:23:10 -0400 Subject: [PATCH 04/13] Update index.js Co-authored-by: Jan Nicklas --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b82f6c52..4276e8ed 100644 --- a/index.js +++ b/index.js @@ -1046,7 +1046,7 @@ function hookIntoCompiler (compiler, options, plugin) { return html; } try { - return await require('html-minifier-terser').minify(html, options.minify); + return require('html-minifier-terser').minify(html, options.minify); } catch (e) { const isParseError = String(e.message).indexOf('Parse Error') === 0; if (isParseError) { From 3bb7c171e04e2498e8cbe148f5a1137e7ac5cd5e Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Sat, 9 Oct 2021 10:23:16 -0400 Subject: [PATCH 05/13] Update index.js Co-authored-by: Jan Nicklas --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4276e8ed..45f286ad 100644 --- a/index.js +++ b/index.js @@ -1041,7 +1041,7 @@ function hookIntoCompiler (compiler, options, plugin) { * * @param {string} html */ - async function minifyHtml (html) { + function minifyHtml (html) { if (typeof options.minify !== 'object') { return html; } From 16a841a84bac251feee20a8af3a39182b600152b Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Sat, 9 Oct 2021 10:26:04 -0400 Subject: [PATCH 06/13] [chore] rebuild examples --- .../dist/webpack-5/entryA.js | 108 +++++++++--------- .../dist/webpack-5/entryB.js | 108 +++++++++--------- examples/javascript/dist/webpack-5/index.html | 2 +- examples/pug-loader/dist/webpack-5/index.html | 2 +- 4 files changed, 116 insertions(+), 104 deletions(-) diff --git a/examples/chunk-optimization/dist/webpack-5/entryA.js b/examples/chunk-optimization/dist/webpack-5/entryA.js index 979e0f53..1c761428 100644 --- a/examples/chunk-optimization/dist/webpack-5/entryA.js +++ b/examples/chunk-optimization/dist/webpack-5/entryA.js @@ -22,9 +22,8 @@ document.body.appendChild(h1); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { @@ -43,38 +42,10 @@ document.body.appendChild(h1); /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = __webpack_modules__; /******/ +/******/ // the startup function +/******/ // It's empty as some runtime module handles the default behavior +/******/ __webpack_require__.x = x => {}; /************************************************************************/ -/******/ /* webpack/runtime/chunk loaded */ -/******/ (() => { -/******/ var deferred = []; -/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { -/******/ if(chunkIds) { -/******/ priority = priority || 0; -/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; -/******/ deferred[i] = [chunkIds, fn, priority]; -/******/ return; -/******/ } -/******/ var notFulfilled = Infinity; -/******/ for (var i = 0; i < deferred.length; i++) { -/******/ var [chunkIds, fn, priority] = deferred[i]; -/******/ var fulfilled = true; -/******/ for (var j = 0; j < chunkIds.length; j++) { -/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { -/******/ chunkIds.splice(j--, 1); -/******/ } else { -/******/ fulfilled = false; -/******/ if(priority < notFulfilled) notFulfilled = priority; -/******/ } -/******/ } -/******/ if(fulfilled) { -/******/ deferred.splice(i--, 1) -/******/ result = fn(); -/******/ } -/******/ } -/******/ return result; -/******/ }; -/******/ })(); -/******/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules @@ -121,11 +92,14 @@ document.body.appendChild(h1); /******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched -/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ // Promise = chunk loading, 0 = chunk loaded /******/ var installedChunks = { /******/ 938: 0 /******/ }; /******/ +/******/ var deferredModules = [ +/******/ [727,494,491,219,965] +/******/ ]; /******/ // no chunk on demand loading /******/ /******/ // no prefetching @@ -136,43 +110,75 @@ document.body.appendChild(h1); /******/ /******/ // no HMR manifest /******/ -/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); +/******/ var checkDeferredModules = x => {}; /******/ /******/ // install a JSONP callback for chunk loading /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { -/******/ var [chunkIds, moreModules, runtime] = data; +/******/ var [chunkIds, moreModules, runtime, executeModules] = data; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback -/******/ var moduleId, chunkId, i = 0; +/******/ var moduleId, chunkId, i = 0, resolves = []; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ resolves.push(installedChunks[chunkId][0]); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } /******/ for(moduleId in moreModules) { /******/ if(__webpack_require__.o(moreModules, moduleId)) { /******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ if(runtime) runtime(__webpack_require__); /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); -/******/ for(;i < chunkIds.length; i++) { -/******/ chunkId = chunkIds[i]; -/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { -/******/ installedChunks[chunkId][0](); -/******/ } -/******/ installedChunks[chunkIds[i]] = 0; +/******/ while(resolves.length) { +/******/ resolves.shift()(); /******/ } -/******/ return __webpack_require__.O(result); +/******/ +/******/ // add entry modules from loaded chunk to deferred list +/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules); +/******/ +/******/ // run deferred modules when all chunks ready +/******/ return checkDeferredModules(); /******/ } /******/ /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || []; /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ +/******/ function checkDeferredModulesImpl() { +/******/ var result; +/******/ for(var i = 0; i < deferredModules.length; i++) { +/******/ var deferredModule = deferredModules[i]; +/******/ var fulfilled = true; +/******/ for(var j = 1; j < deferredModule.length; j++) { +/******/ var depId = deferredModule[j]; +/******/ if(installedChunks[depId] !== 0) fulfilled = false; +/******/ } +/******/ if(fulfilled) { +/******/ deferredModules.splice(i--, 1); +/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); +/******/ } +/******/ } +/******/ if(deferredModules.length === 0) { +/******/ __webpack_require__.x(); +/******/ __webpack_require__.x = x => {}; +/******/ } +/******/ return result; +/******/ } +/******/ var startup = __webpack_require__.x; +/******/ __webpack_require__.x = () => { +/******/ // reset startup function so it can be called again when more startup code is added +/******/ __webpack_require__.x = startup || (x => {}); +/******/ return (checkDeferredModules = checkDeferredModulesImpl)(); +/******/ }; /******/ })(); /******/ /************************************************************************/ /******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [494,491,219,965], () => (__webpack_require__(727))) -/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); +/******/ // run startup +/******/ var __webpack_exports__ = __webpack_require__.x(); /******/ /******/ })() ; \ No newline at end of file diff --git a/examples/chunk-optimization/dist/webpack-5/entryB.js b/examples/chunk-optimization/dist/webpack-5/entryB.js index ef4a863c..2c0fa57a 100644 --- a/examples/chunk-optimization/dist/webpack-5/entryB.js +++ b/examples/chunk-optimization/dist/webpack-5/entryB.js @@ -21,9 +21,8 @@ document.body.appendChild(h1); /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; +/******/ if(__webpack_module_cache__[moduleId]) { +/******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { @@ -42,38 +41,10 @@ document.body.appendChild(h1); /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = __webpack_modules__; /******/ +/******/ // the startup function +/******/ // It's empty as some runtime module handles the default behavior +/******/ __webpack_require__.x = x => {}; /************************************************************************/ -/******/ /* webpack/runtime/chunk loaded */ -/******/ (() => { -/******/ var deferred = []; -/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { -/******/ if(chunkIds) { -/******/ priority = priority || 0; -/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; -/******/ deferred[i] = [chunkIds, fn, priority]; -/******/ return; -/******/ } -/******/ var notFulfilled = Infinity; -/******/ for (var i = 0; i < deferred.length; i++) { -/******/ var [chunkIds, fn, priority] = deferred[i]; -/******/ var fulfilled = true; -/******/ for (var j = 0; j < chunkIds.length; j++) { -/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { -/******/ chunkIds.splice(j--, 1); -/******/ } else { -/******/ fulfilled = false; -/******/ if(priority < notFulfilled) notFulfilled = priority; -/******/ } -/******/ } -/******/ if(fulfilled) { -/******/ deferred.splice(i--, 1) -/******/ result = fn(); -/******/ } -/******/ } -/******/ return result; -/******/ }; -/******/ })(); -/******/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules @@ -120,11 +91,14 @@ document.body.appendChild(h1); /******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched -/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ // Promise = chunk loading, 0 = chunk loaded /******/ var installedChunks = { /******/ 513: 0 /******/ }; /******/ +/******/ var deferredModules = [ +/******/ [282,494,219,965] +/******/ ]; /******/ // no chunk on demand loading /******/ /******/ // no prefetching @@ -135,43 +109,75 @@ document.body.appendChild(h1); /******/ /******/ // no HMR manifest /******/ -/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); +/******/ var checkDeferredModules = x => {}; /******/ /******/ // install a JSONP callback for chunk loading /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { -/******/ var [chunkIds, moreModules, runtime] = data; +/******/ var [chunkIds, moreModules, runtime, executeModules] = data; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback -/******/ var moduleId, chunkId, i = 0; +/******/ var moduleId, chunkId, i = 0, resolves = []; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ resolves.push(installedChunks[chunkId][0]); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } /******/ for(moduleId in moreModules) { /******/ if(__webpack_require__.o(moreModules, moduleId)) { /******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ if(runtime) runtime(__webpack_require__); /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); -/******/ for(;i < chunkIds.length; i++) { -/******/ chunkId = chunkIds[i]; -/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { -/******/ installedChunks[chunkId][0](); -/******/ } -/******/ installedChunks[chunkIds[i]] = 0; +/******/ while(resolves.length) { +/******/ resolves.shift()(); /******/ } -/******/ return __webpack_require__.O(result); +/******/ +/******/ // add entry modules from loaded chunk to deferred list +/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules); +/******/ +/******/ // run deferred modules when all chunks ready +/******/ return checkDeferredModules(); /******/ } /******/ /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || []; /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ +/******/ function checkDeferredModulesImpl() { +/******/ var result; +/******/ for(var i = 0; i < deferredModules.length; i++) { +/******/ var deferredModule = deferredModules[i]; +/******/ var fulfilled = true; +/******/ for(var j = 1; j < deferredModule.length; j++) { +/******/ var depId = deferredModule[j]; +/******/ if(installedChunks[depId] !== 0) fulfilled = false; +/******/ } +/******/ if(fulfilled) { +/******/ deferredModules.splice(i--, 1); +/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); +/******/ } +/******/ } +/******/ if(deferredModules.length === 0) { +/******/ __webpack_require__.x(); +/******/ __webpack_require__.x = x => {}; +/******/ } +/******/ return result; +/******/ } +/******/ var startup = __webpack_require__.x; +/******/ __webpack_require__.x = () => { +/******/ // reset startup function so it can be called again when more startup code is added +/******/ __webpack_require__.x = startup || (x => {}); +/******/ return (checkDeferredModules = checkDeferredModulesImpl)(); +/******/ }; /******/ })(); /******/ /************************************************************************/ /******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [494,219,965], () => (__webpack_require__(282))) -/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); +/******/ // run startup +/******/ var __webpack_exports__ = __webpack_require__.x(); /******/ /******/ })() ; \ No newline at end of file diff --git a/examples/javascript/dist/webpack-5/index.html b/examples/javascript/dist/webpack-5/index.html index 0e9b63d2..835e767f 100644 --- a/examples/javascript/dist/webpack-5/index.html +++ b/examples/javascript/dist/webpack-5/index.html @@ -1 +1 @@ -Hello World from backend2021-06-22T13:06:30.743Z

Partial

\ No newline at end of file +Hello World from backend2021-10-09T14:25:52.580Z

Partial

\ No newline at end of file diff --git a/examples/pug-loader/dist/webpack-5/index.html b/examples/pug-loader/dist/webpack-5/index.html index 5f9744d5..203953b6 100644 --- a/examples/pug-loader/dist/webpack-5/index.html +++ b/examples/pug-loader/dist/webpack-5/index.html @@ -1 +1 @@ -pug demo
Current time

1998-12-31T23:00:00.000Z

\ No newline at end of file +pug demo
Current time

1999-01-01T05:00:00.000Z

\ No newline at end of file From 48131d39f99224a6c25a089282c7bf87c9edc063 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Fri, 15 Oct 2021 13:09:18 +0200 Subject: [PATCH 07/13] chore(release): 5.4.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f52def9..0b582342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.4.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.3.2...v5.3.3) (2021-10-15) + +### Features + +* update terser ([9c7fba0](https://github.com/jantimon/html-webpack-plugin/pull/1688) + ### [5.3.2](https://github.com/jantimon/html-webpack-plugin/compare/v5.3.1...v5.3.2) (2021-06-22) ### Bug Fixes diff --git a/package.json b/package.json index 067e9977..6845ff17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "5.3.2", + "version": "5.4.0", "license": "MIT", "description": "Simplifies creation of HTML files to serve your webpack bundles", "author": "Jan Nicklas (https://github.com/jantimon)", From b7e5859db3974fbbcc2049bbf0e0950fe8dfa61c Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Sat, 16 Oct 2021 10:02:43 -0700 Subject: [PATCH 08/13] [chore] fixes CI to avoid race conditions --- examples/javascript/dist/webpack-5/index.html | 2 +- examples/pug-loader/dist/webpack-5/index.html | 2 +- package.json | 4 ++-- spec/support/jasmine.json | 8 -------- 4 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 spec/support/jasmine.json diff --git a/examples/javascript/dist/webpack-5/index.html b/examples/javascript/dist/webpack-5/index.html index 835e767f..eb255934 100644 --- a/examples/javascript/dist/webpack-5/index.html +++ b/examples/javascript/dist/webpack-5/index.html @@ -1 +1 @@ -Hello World from backend2021-10-09T14:25:52.580Z

Partial

\ No newline at end of file +Hello World from backend2021-10-16T17:01:43.132Z

Partial

\ No newline at end of file diff --git a/examples/pug-loader/dist/webpack-5/index.html b/examples/pug-loader/dist/webpack-5/index.html index 203953b6..dab0b0ea 100644 --- a/examples/pug-loader/dist/webpack-5/index.html +++ b/examples/pug-loader/dist/webpack-5/index.html @@ -1 +1 @@ -pug demo
Current time

1999-01-01T05:00:00.000Z

\ No newline at end of file +pug demo
Current time

1999-01-01T08:00:00.000Z

\ No newline at end of file diff --git a/package.json b/package.json index 6845ff17..4b5118c3 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,9 @@ "commitizen": "^4.2.4", "css-loader": "5.0.1", "cz-conventional-changelog": "2.1.0", - "dir-compare": "1.7.2", + "dir-compare": "^3.3.0", "html-loader": "2.1.1", - "jest": "26.5.3", + "jest": "^27.2.5", "mini-css-extract-plugin": "^1.6.0", "pug": "3.0.2", "pug-loader": "2.4.0", diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json deleted file mode 100644 index 54750e1d..00000000 --- a/spec/support/jasmine.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "stopSpecOnExpectationFailure": false, - "random": true -} From 79be7799c9a038b18f3fd7c01359ec76728e30d2 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Sat, 16 Oct 2021 10:06:22 -0700 Subject: [PATCH 09/13] [chore] changes actions to run on pull_requests --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 51f1a2ad..61d5c24d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,8 @@ name: CI -on: [push] + push: + branches: [main] + pull_request: + branches: [main] jobs: build: name: test Node ${{ matrix.node }} Webpack ${{ matrix.webpack }} ${{ matrix.os }} From 7d3645b01a491278d85f84b7f7c986e7f103523d Mon Sep 17 00:00:00 2001 From: Mo Beigi Date: Sun, 24 Oct 2021 15:10:34 +1100 Subject: [PATCH 10/13] Bump pretty-error to 4.0.0 to fix transitive vuln for ansi-regex CVE-2021-3807 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b5118c3..28b8ef63 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@types/html-minifier-terser": "^6.0.0", "html-minifier-terser": "^6.0.2", "lodash": "^4.17.21", - "pretty-error": "^3.0.4", + "pretty-error": "^4.0.0", "tapable": "^2.0.0" }, "peerDependencies": { From 1e4262528ff02a83e1fc7739b42472680fd205c2 Mon Sep 17 00:00:00 2001 From: Oskari Noppa Date: Sat, 7 Aug 2021 01:16:51 +0300 Subject: [PATCH 11/13] feat: Support type=module via scriptLoading option Add third option, `'module'`, to the `scriptLoading` option. This partially fixes issue #1663, which is also where this solution to the problem was proposed. Although this patch doesn't give a way to freely set `type` attribute to any value, setting `scriptLoading: "module" now makes the scripts have attribute `type="module"`, which was the original motivation behind the issue. --- README.md | 2 +- index.js | 5 +++-- spec/basic.spec.js | 14 ++++++++++++++ typings.d.ts | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a27337fb..8080d1ae 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Allowed values are as follows: |**`templateParameters`**|`{Boolean\|Object\|Function}`| `false`| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters) | |**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element. Passing `true` will add it to the head/body depending on the `scriptLoading` option. Passing `false` will disable automatic injections. - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)| |**`publicPath`**|`{String\|'auto'}`|`'auto'`|The publicPath used for script and link tags| -|**`scriptLoading`**|`{'blocking'\|'defer'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. | +|**`scriptLoading`**|`{'blocking'\|'defer'\|'module'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type="module"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies "defer", since modules are automatically deferred. | |**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML| |**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`| |**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`| diff --git a/index.js b/index.js index 45f286ad..de9a6294 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ class HtmlWebpackPlugin { this.options = options; // Assert correct option spelling - assert(options.scriptLoading === 'defer' || options.scriptLoading === 'blocking', 'scriptLoading needs to be set to "defer" or "blocking'); + assert(options.scriptLoading === 'defer' || options.scriptLoading === 'blocking' || options.scriptLoading === 'module', 'scriptLoading needs to be set to "defer", "blocking" or "module"'); assert(options.inject === true || options.inject === false || options.inject === 'head' || options.inject === 'body', 'inject needs to be set to true, false, "head" or "body'); // Default metaOptions if no template is provided @@ -741,7 +741,8 @@ function hookIntoCompiler (compiler, options, plugin) { voidTag: false, meta: { plugin: 'html-webpack-plugin' }, attributes: { - defer: options.scriptLoading !== 'blocking', + defer: options.scriptLoading === 'defer', + type: options.scriptLoading === 'module' ? 'module' : undefined, src: scriptAsset } })); diff --git a/spec/basic.spec.js b/spec/basic.spec.js index 794e14c6..b325f7cd 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -2526,6 +2526,20 @@ describe('HtmlWebpackPlugin', () => { }, [/Hello World from backend2021-10-16T17:01:43.132Z

Partial

\ No newline at end of file +Hello World from backend2021-10-25T11:10:42.875Z

Partial

\ No newline at end of file diff --git a/examples/pug-loader/dist/webpack-5/index.html b/examples/pug-loader/dist/webpack-5/index.html index dab0b0ea..5f9744d5 100644 --- a/examples/pug-loader/dist/webpack-5/index.html +++ b/examples/pug-loader/dist/webpack-5/index.html @@ -1 +1 @@ -pug demo
Current time

1999-01-01T08:00:00.000Z

\ No newline at end of file +pug demo
Current time

1998-12-31T23:00:00.000Z

\ No newline at end of file From 873d75bbcbd28ef7dff0a1549d3e442119e278d3 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Mon, 25 Oct 2021 14:27:15 +0200 Subject: [PATCH 13/13] chore(release): 5.5.0 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b582342..e85923e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [5.5.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.4.0...v5.5.0) (2021-10-25) + + +### Features + +* Support type=module via scriptLoading option ([1e42625](https://github.com/jantimon/html-webpack-plugin/commit/1e4262528ff02a83e1fc7739b42472680fd205c2)), closes [#1663](https://github.com/jantimon/html-webpack-plugin/issues/1663) + ### [5.4.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.3.2...v5.3.3) (2021-10-15) ### Features diff --git a/package.json b/package.json index 28b8ef63..bc3c6b49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-plugin", - "version": "5.4.0", + "version": "5.5.0", "license": "MIT", "description": "Simplifies creation of HTML files to serve your webpack bundles", "author": "Jan Nicklas (https://github.com/jantimon)",