diff --git a/CHANGELOG.md b/CHANGELOG.md index 95fc3796..7ea7a3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ + * **Bug Fix** + * Support any custom `globalObject` option in Webpack Config. ([#352](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/352) by [@Gongreg](https://github.com/Gongreg)) + ## 3.7.0 * **New Feature** diff --git a/src/parseUtils.js b/src/parseUtils.js index 0c667a43..c31e6745 100644 --- a/src/parseUtils.js +++ b/src/parseUtils.js @@ -198,14 +198,6 @@ function isAsyncChunkPushExpression(node) { callee.type === 'MemberExpression' && callee.property.name === 'push' && callee.object.type === 'AssignmentExpression' && - 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' - ) && args.length === 1 && args[0].type === 'ArrayExpression' && mayBeAsyncChunkArguments(args[0].elements) && diff --git a/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.js b/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.js new file mode 100644 index 00000000..c7752cd5 --- /dev/null +++ b/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.js @@ -0,0 +1 @@ +(("undefined" != typeof self ? self : this).webpackJsonp_someCustomName = ("undefined" != typeof self ? self : this).webpackJsonp_someCustomName || []).push([[27],{1:function(e,n,t){console.log("Chuck Norris")}}]); diff --git a/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.modules.json b/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.modules.json new file mode 100644 index 00000000..8bc08246 --- /dev/null +++ b/test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.modules.json @@ -0,0 +1,6 @@ +{ + "modules": { + "1": "function(e,n,t){console.log(\"Chuck Norris\")}" + } +} +