Skip to content

Commit

Permalink
fix: more robust variable value extraction to add support for webpack…
Browse files Browse the repository at this point in the history
… >= 5.22.0
  • Loading branch information
jantimon committed Feb 18, 2021
1 parent ccacfa3 commit 1aabaf9
Show file tree
Hide file tree
Showing 28 changed files with 153 additions and 115 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.11.5
10.16.0
2 changes: 2 additions & 0 deletions examples/appcache/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion examples/appcache/dist/webpack-5/manifest.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# f509954c60c2fd048c91
# 70c9e1216086afef6e29

0714810ae3fb211173e2964249507195.png
styles.css
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/73.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[73],{
(self["webpackChunk"] = self["webpackChunk"] || []).push([[73],{

/***/ 173:
/***/ ((module, exports, __webpack_require__) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/805.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[805],{
(self["webpackChunk"] = self["webpackChunk"] || []).push([[805],{

/***/ 609:
/***/ ((module) => {
Expand Down
91 changes: 44 additions & 47 deletions examples/chunk-optimization/dist/webpack-5/entryA.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [];
Expand All @@ -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()();
/******/ }
Expand All @@ -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();
/******/
/******/ })()
;
91 changes: 44 additions & 47 deletions examples/chunk-optimization/dist/webpack-5/entryB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [];
Expand All @@ -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()();
/******/ }
Expand All @@ -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();
/******/
/******/ })()
;
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/libMath.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[494],{
(self["webpackChunk"] = self["webpackChunk"] || []).push([[494],{

/***/ 179:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/chunk-optimization/dist/webpack-5/libText.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[491],{
(self["webpackChunk"] = self["webpackChunk"] || []).push([[491],{

/***/ 631:
/***/ ((module) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
var h1 = document.createElement('h1');
h1.innerHTML = 'Hello world!';
document.body.appendChild(h1);
Expand Down
2 changes: 2 additions & 0 deletions examples/custom-template/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions examples/default/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions examples/favicon/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions examples/html-loader/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions examples/inline/dist/webpack-5/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 2 additions & 0 deletions examples/inline/dist/webpack-5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Loading

0 comments on commit 1aabaf9

Please sign in to comment.