diff --git a/CHANGELOG.md b/CHANGELOG.md index e3c32102..10e0f74b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ + * **Improvement** + * Support webpack builds where `output.globalObject` is set to `'self'` ([#323](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/323) by [@lemonmade](https://github.com/lemonmade)) + ## 3.5.2 * **Bug Fix** diff --git a/src/parseUtils.js b/src/parseUtils.js index 6e5dee88..b4dfeff2 100644 --- a/src/parseUtils.js +++ b/src/parseUtils.js @@ -185,6 +185,8 @@ function isAsyncChunkPushExpression(node) { callee.object.left.object && ( callee.object.left.object.name === 'window' || + // `self` is a common output.globalObject value used to support both workers and browsers + callee.object.left.object.name === 'self' || // Webpack 4 uses `this` instead of `window` callee.object.left.object.type === 'ThisExpression' ) && diff --git a/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.js b/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.js new file mode 100644 index 00000000..9e509fd9 --- /dev/null +++ b/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.js @@ -0,0 +1 @@ +(self.webpackJsonp=self.webpackJsonp||[]).push([[27],{1:function(e,n,t){console.log("Chuck Norris")}}]); diff --git a/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.modules.json b/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.modules.json new file mode 100644 index 00000000..cabfce7a --- /dev/null +++ b/test/bundles/validWebpack4AsyncChunkUsingSelfInsteadOfWindow.modules.json @@ -0,0 +1,5 @@ +{ + "modules": { + "1": "function(e,n,t){console.log(\"Chuck Norris\")}" + } +}