From 1aabaf99820257cbe7d3efccb62b42254ad35e04 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Thu, 18 Feb 2021 14:35:29 +0100 Subject: [PATCH] fix: more robust variable value extraction to add support for webpack >= 5.22.0 --- .github/workflows/main.yml | 6 +- .node-version | 2 +- examples/appcache/dist/webpack-5/bundle.js | 2 + .../appcache/dist/webpack-5/manifest.appcache | 2 +- .../chunk-optimization/dist/webpack-5/73.js | 2 +- .../chunk-optimization/dist/webpack-5/805.js | 2 +- .../dist/webpack-5/entryA.js | 91 +++++++++---------- .../dist/webpack-5/entryB.js | 91 +++++++++---------- .../dist/webpack-5/libMath.js | 2 +- .../dist/webpack-5/libText.js | 2 +- .../dist/webpack-5/bundle.js | 1 + .../custom-template/dist/webpack-5/bundle.js | 2 + examples/default/dist/webpack-5/bundle.js | 2 + examples/favicon/dist/webpack-5/bundle.js | 2 + examples/html-loader/dist/webpack-5/bundle.js | 2 + examples/inline/dist/webpack-5/bundle.js | 2 + examples/inline/dist/webpack-5/index.html | 2 + .../dist/webpack-5/bundle.js | 19 +++- examples/javascript/dist/webpack-5/bundle.js | 19 +++- examples/javascript/dist/webpack-5/index.html | 2 +- examples/pug-loader/dist/webpack-5/bundle.js | 2 + examples/sort-manually/dist/webpack-5/a.js | 2 + examples/sort-manually/dist/webpack-5/b.js | 1 + examples/sort-manually/dist/webpack-5/c.js | 1 + examples/sort-manually/dist/webpack-5/d.js | 1 + examples/sort-manually/dist/webpack-5/e.js | 1 + .../dist/webpack-5/bundle.js | 1 + index.js | 4 +- 28 files changed, 153 insertions(+), 115 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 302d21de..406320b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,8 +10,10 @@ jobs: matrix: node: ['6.x', '12.x', '14.x'] os: [ubuntu-latest, windows-latest] - webpack: ['4'] - + webpack: ['4', '5'] + exclude: + - webpack: '5' + node: '6.x' steps: - name: LF run: git config --global core.autocrlf false diff --git a/.node-version b/.node-version index a0037765..5007551b 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -6.11.5 +10.16.0 diff --git a/examples/appcache/dist/webpack-5/bundle.js b/examples/appcache/dist/webpack-5/bundle.js index 9ae17651..cba1af40 100644 --- a/examples/appcache/dist/webpack-5/bundle.js +++ b/examples/appcache/dist/webpack-5/bundle.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(636); var h1 = document.createElement('h1'); diff --git a/examples/appcache/dist/webpack-5/manifest.appcache b/examples/appcache/dist/webpack-5/manifest.appcache index d9dc95c2..31cb7520 100644 --- a/examples/appcache/dist/webpack-5/manifest.appcache +++ b/examples/appcache/dist/webpack-5/manifest.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# f509954c60c2fd048c91 +# 70c9e1216086afef6e29 0714810ae3fb211173e2964249507195.png styles.css diff --git a/examples/chunk-optimization/dist/webpack-5/73.js b/examples/chunk-optimization/dist/webpack-5/73.js index 5e01f279..48c758cf 100644 --- a/examples/chunk-optimization/dist/webpack-5/73.js +++ b/examples/chunk-optimization/dist/webpack-5/73.js @@ -1,4 +1,4 @@ -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[73],{ +(self["webpackChunk"] = self["webpackChunk"] || []).push([[73],{ /***/ 173: /***/ ((module, exports, __webpack_require__) => { diff --git a/examples/chunk-optimization/dist/webpack-5/805.js b/examples/chunk-optimization/dist/webpack-5/805.js index 66796e1b..cd19b63f 100644 --- a/examples/chunk-optimization/dist/webpack-5/805.js +++ b/examples/chunk-optimization/dist/webpack-5/805.js @@ -1,4 +1,4 @@ -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[805],{ +(self["webpackChunk"] = self["webpackChunk"] || []).push([[805],{ /***/ 609: /***/ ((module) => { diff --git a/examples/chunk-optimization/dist/webpack-5/entryA.js b/examples/chunk-optimization/dist/webpack-5/entryA.js index c5be91f7..d7628726 100644 --- a/examples/chunk-optimization/dist/webpack-5/entryA.js +++ b/examples/chunk-optimization/dist/webpack-5/entryA.js @@ -42,14 +42,19 @@ 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/hasOwnProperty shorthand */ /******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/jsonp chunk loading */ /******/ (() => { +/******/ // no baseURI +/******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // Promise = chunk loading, 0 = chunk loaded @@ -70,47 +75,11 @@ document.body.appendChild(h1); /******/ /******/ // no HMR manifest /******/ -/******/ var checkDeferredModules = () => { -/******/ -/******/ }; -/******/ 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 = () => { -/******/ -/******/ } -/******/ } -/******/ return result; -/******/ } -/******/ __webpack_require__.x = () => { -/******/ // reset startup function so it can be called again when more startup code is added -/******/ __webpack_require__.x = () => { -/******/ -/******/ } -/******/ jsonpArray = jsonpArray.slice(); -/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); -/******/ return (checkDeferredModules = checkDeferredModulesImpl)(); -/******/ }; +/******/ var checkDeferredModules = x => {}; /******/ /******/ // install a JSONP callback for chunk loading -/******/ function webpackJsonpCallback(data) { -/******/ var chunkIds = data[0]; -/******/ var moreModules = data[1]; -/******/ var executeModules = data[2]; -/******/ var runtime = data[3]; +/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, 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, resolves = []; @@ -127,7 +96,7 @@ document.body.appendChild(h1); /******/ } /******/ } /******/ if(runtime) runtime(__webpack_require__); -/******/ if(parentJsonpFunction) parentJsonpFunction(data); +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -137,16 +106,44 @@ document.body.appendChild(h1); /******/ /******/ // 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)); /******/ -/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; -/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); -/******/ jsonpArray.push = webpackJsonpCallback; -/******/ var parentJsonpFunction = oldJsonpFunction; +/******/ 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)(); +/******/ }; /******/ })(); /******/ /************************************************************************/ +/******/ /******/ // run startup -/******/ return __webpack_require__.x(); +/******/ 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 8bd246f6..ddb8bd18 100644 --- a/examples/chunk-optimization/dist/webpack-5/entryB.js +++ b/examples/chunk-optimization/dist/webpack-5/entryB.js @@ -41,14 +41,19 @@ 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/hasOwnProperty shorthand */ /******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop) +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/jsonp chunk loading */ /******/ (() => { +/******/ // no baseURI +/******/ /******/ // object to store loaded and loading chunks /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched /******/ // Promise = chunk loading, 0 = chunk loaded @@ -69,47 +74,11 @@ document.body.appendChild(h1); /******/ /******/ // no HMR manifest /******/ -/******/ var checkDeferredModules = () => { -/******/ -/******/ }; -/******/ 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 = () => { -/******/ -/******/ } -/******/ } -/******/ return result; -/******/ } -/******/ __webpack_require__.x = () => { -/******/ // reset startup function so it can be called again when more startup code is added -/******/ __webpack_require__.x = () => { -/******/ -/******/ } -/******/ jsonpArray = jsonpArray.slice(); -/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); -/******/ return (checkDeferredModules = checkDeferredModulesImpl)(); -/******/ }; +/******/ var checkDeferredModules = x => {}; /******/ /******/ // install a JSONP callback for chunk loading -/******/ function webpackJsonpCallback(data) { -/******/ var chunkIds = data[0]; -/******/ var moreModules = data[1]; -/******/ var executeModules = data[2]; -/******/ var runtime = data[3]; +/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, 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, resolves = []; @@ -126,7 +95,7 @@ document.body.appendChild(h1); /******/ } /******/ } /******/ if(runtime) runtime(__webpack_require__); -/******/ if(parentJsonpFunction) parentJsonpFunction(data); +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -136,16 +105,44 @@ document.body.appendChild(h1); /******/ /******/ // 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)); /******/ -/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; -/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray); -/******/ jsonpArray.push = webpackJsonpCallback; -/******/ var parentJsonpFunction = oldJsonpFunction; +/******/ 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)(); +/******/ }; /******/ })(); /******/ /************************************************************************/ +/******/ /******/ // run startup -/******/ return __webpack_require__.x(); +/******/ var __webpack_exports__ = __webpack_require__.x(); +/******/ /******/ })() ; \ No newline at end of file diff --git a/examples/chunk-optimization/dist/webpack-5/libMath.js b/examples/chunk-optimization/dist/webpack-5/libMath.js index 6af571d9..209e9464 100644 --- a/examples/chunk-optimization/dist/webpack-5/libMath.js +++ b/examples/chunk-optimization/dist/webpack-5/libMath.js @@ -1,4 +1,4 @@ -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[494],{ +(self["webpackChunk"] = self["webpackChunk"] || []).push([[494],{ /***/ 179: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { diff --git a/examples/chunk-optimization/dist/webpack-5/libText.js b/examples/chunk-optimization/dist/webpack-5/libText.js index 6134ede5..ed9620bd 100644 --- a/examples/chunk-optimization/dist/webpack-5/libText.js +++ b/examples/chunk-optimization/dist/webpack-5/libText.js @@ -1,4 +1,4 @@ -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[491],{ +(self["webpackChunk"] = self["webpackChunk"] || []).push([[491],{ /***/ 631: /***/ ((module) => { diff --git a/examples/custom-insertion-position/dist/webpack-5/bundle.js b/examples/custom-insertion-position/dist/webpack-5/bundle.js index a81d487b..68fc1b11 100644 --- a/examples/custom-insertion-position/dist/webpack-5/bundle.js +++ b/examples/custom-insertion-position/dist/webpack-5/bundle.js @@ -1,4 +1,5 @@ /******/ (() => { // webpackBootstrap +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'Hello world!'; document.body.appendChild(h1); diff --git a/examples/custom-template/dist/webpack-5/bundle.js b/examples/custom-template/dist/webpack-5/bundle.js index 9ae17651..cba1af40 100644 --- a/examples/custom-template/dist/webpack-5/bundle.js +++ b/examples/custom-template/dist/webpack-5/bundle.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(636); var h1 = document.createElement('h1'); diff --git a/examples/default/dist/webpack-5/bundle.js b/examples/default/dist/webpack-5/bundle.js index fe5242fb..584169dc 100644 --- a/examples/default/dist/webpack-5/bundle.js +++ b/examples/default/dist/webpack-5/bundle.js @@ -657,6 +657,8 @@ module.exports = function (css) { /******/ } /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(73); var h1 = document.createElement('h1'); diff --git a/examples/favicon/dist/webpack-5/bundle.js b/examples/favicon/dist/webpack-5/bundle.js index 9ae17651..cba1af40 100644 --- a/examples/favicon/dist/webpack-5/bundle.js +++ b/examples/favicon/dist/webpack-5/bundle.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(636); var h1 = document.createElement('h1'); diff --git a/examples/html-loader/dist/webpack-5/bundle.js b/examples/html-loader/dist/webpack-5/bundle.js index 9ae17651..cba1af40 100644 --- a/examples/html-loader/dist/webpack-5/bundle.js +++ b/examples/html-loader/dist/webpack-5/bundle.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(636); var h1 = document.createElement('h1'); diff --git a/examples/inline/dist/webpack-5/bundle.js b/examples/inline/dist/webpack-5/bundle.js index a995ab3d..4854275b 100644 --- a/examples/inline/dist/webpack-5/bundle.js +++ b/examples/inline/dist/webpack-5/bundle.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { "use strict"; diff --git a/examples/inline/dist/webpack-5/index.html b/examples/inline/dist/webpack-5/index.html index 2583fe90..8b0b0b46 100644 --- a/examples/inline/dist/webpack-5/index.html +++ b/examples/inline/dist/webpack-5/index.html @@ -37,6 +37,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { "use strict"; diff --git a/examples/javascript-advanced/dist/webpack-5/bundle.js b/examples/javascript-advanced/dist/webpack-5/bundle.js index 3e1c0ed3..7bf05db3 100644 --- a/examples/javascript-advanced/dist/webpack-5/bundle.js +++ b/examples/javascript-advanced/dist/webpack-5/bundle.js @@ -1,6 +1,6 @@ /* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). - * This devtool is not neither made for production nor for readable output files. + * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". @@ -9,6 +9,13 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ +/***/ 144: +/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { + +eval("__webpack_require__(636);\n\nvar universal = __webpack_require__(184);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ }), + /***/ 184: /***/ ((module) => { @@ -51,9 +58,11 @@ eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./main /******/ /************************************************************************/ /******/ /************************************************************************/ -(() => { -eval("__webpack_require__(636);\n\nvar universal = __webpack_require__(184);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); -})(); - +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module can't be inlined because the eval devtool is used. +/******/ var __webpack_exports__ = __webpack_require__(144); +/******/ /******/ })() ; \ No newline at end of file diff --git a/examples/javascript/dist/webpack-5/bundle.js b/examples/javascript/dist/webpack-5/bundle.js index 3e1c0ed3..7bf05db3 100644 --- a/examples/javascript/dist/webpack-5/bundle.js +++ b/examples/javascript/dist/webpack-5/bundle.js @@ -1,6 +1,6 @@ /* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). - * This devtool is not neither made for production nor for readable output files. + * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". @@ -9,6 +9,13 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ +/***/ 144: +/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { + +eval("__webpack_require__(636);\n\nvar universal = __webpack_require__(184);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); + +/***/ }), + /***/ 184: /***/ ((module) => { @@ -51,9 +58,11 @@ eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./main /******/ /************************************************************************/ /******/ /************************************************************************/ -(() => { -eval("__webpack_require__(636);\n\nvar universal = __webpack_require__(184);\nvar h1 = document.createElement('h1');\nh1.innerHTML = universal();\n\ndocument.body.appendChild(h1);\n\n\n//# sourceURL=webpack:///./example.js?"); -})(); - +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module can't be inlined because the eval devtool is used. +/******/ var __webpack_exports__ = __webpack_require__(144); +/******/ /******/ })() ; \ 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 62334917..3289d23b 100644 --- a/examples/javascript/dist/webpack-5/index.html +++ b/examples/javascript/dist/webpack-5/index.html @@ -1 +1 @@ -Hello World from backend2020-03-30T16:36:46.399Z

Partial

\ No newline at end of file +Hello World from backend2021-02-18T13:25:03.187Z

Partial

\ No newline at end of file diff --git a/examples/pug-loader/dist/webpack-5/bundle.js b/examples/pug-loader/dist/webpack-5/bundle.js index 11ae57a6..ea751402 100644 --- a/examples/pug-loader/dist/webpack-5/bundle.js +++ b/examples/pug-loader/dist/webpack-5/bundle.js @@ -314,6 +314,8 @@ function pug_rethrow(err, filename, lineno, str){ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { "use strict"; diff --git a/examples/sort-manually/dist/webpack-5/a.js b/examples/sort-manually/dist/webpack-5/a.js index dbfd0573..550eaf00 100644 --- a/examples/sort-manually/dist/webpack-5/a.js +++ b/examples/sort-manually/dist/webpack-5/a.js @@ -35,6 +35,8 @@ /******/ /************************************************************************/ /******/ /************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { __webpack_require__(636); var h1 = document.createElement('h1'); diff --git a/examples/sort-manually/dist/webpack-5/b.js b/examples/sort-manually/dist/webpack-5/b.js index 7bf528af..3fae63d7 100644 --- a/examples/sort-manually/dist/webpack-5/b.js +++ b/examples/sort-manually/dist/webpack-5/b.js @@ -1,5 +1,6 @@ /******/ (() => { // webpackBootstrap /******/ /************************************************************************/ +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'b!'; document.body.appendChild(h1); diff --git a/examples/sort-manually/dist/webpack-5/c.js b/examples/sort-manually/dist/webpack-5/c.js index 82852a6f..45532ac2 100644 --- a/examples/sort-manually/dist/webpack-5/c.js +++ b/examples/sort-manually/dist/webpack-5/c.js @@ -1,5 +1,6 @@ /******/ (() => { // webpackBootstrap /******/ /************************************************************************/ +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'c!'; document.body.appendChild(h1); diff --git a/examples/sort-manually/dist/webpack-5/d.js b/examples/sort-manually/dist/webpack-5/d.js index cfd11c66..0a090fe3 100644 --- a/examples/sort-manually/dist/webpack-5/d.js +++ b/examples/sort-manually/dist/webpack-5/d.js @@ -1,5 +1,6 @@ /******/ (() => { // webpackBootstrap /******/ /************************************************************************/ +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'd!'; document.body.appendChild(h1); diff --git a/examples/sort-manually/dist/webpack-5/e.js b/examples/sort-manually/dist/webpack-5/e.js index 01886f02..f9c282b7 100644 --- a/examples/sort-manually/dist/webpack-5/e.js +++ b/examples/sort-manually/dist/webpack-5/e.js @@ -1,5 +1,6 @@ /******/ (() => { // webpackBootstrap /******/ /************************************************************************/ +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'e!'; document.body.appendChild(h1); diff --git a/examples/template-parameters/dist/webpack-5/bundle.js b/examples/template-parameters/dist/webpack-5/bundle.js index a81d487b..68fc1b11 100644 --- a/examples/template-parameters/dist/webpack-5/bundle.js +++ b/examples/template-parameters/dist/webpack-5/bundle.js @@ -1,4 +1,5 @@ /******/ (() => { // webpackBootstrap +var __webpack_exports__ = {}; var h1 = document.createElement('h1'); h1.innerHTML = 'Hello world!'; document.body.appendChild(h1); diff --git a/index.js b/index.js index 79e1c7b9..22151a0b 100644 --- a/index.js +++ b/index.js @@ -316,8 +316,8 @@ class HtmlWebpackPlugin { return Promise.reject(new Error('The child compilation didn\'t provide a result')); } // The LibraryTemplatePlugin stores the template result in a local variable. - // To extract the result during the evaluation this part has to be removed. - source = source.replace('var HTML_WEBPACK_PLUGIN_RESULT =', ''); + // Return the value from this variable + source += ';HTML_WEBPACK_PLUGIN_RESULT'; const template = this.options.template.replace(/^.+!/, '').replace(/\?.+$/, ''); const vmContext = vm.createContext(_.extend({ HTML_WEBPACK_PLUGIN: true, require: require, console: console }, global)); const vmScript = new vm.Script(source, { filename: template });