From 1000c4e9d29a4a89e0cb934233a7bbd4db033ad3 Mon Sep 17 00:00:00 2001 From: Gytis Vinclovas Date: Tue, 19 May 2020 13:30:29 +0300 Subject: [PATCH 1/3] Removed left side check to support custom global object which can be any string --- src/parseUtils.js | 8 -------- .../validWebpack4AsyncChunkUsingCustomGlobalObject.js | 1 + ...Webpack4AsyncChunkUsingCustomGlobalObject.modules.json | 6 ++++++ 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.js create mode 100644 test/bundles/validWebpack4AsyncChunkUsingCustomGlobalObject.modules.json 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\")}" + } +} + From 5a282ddcabe8f15ecb68f11fd0f6e7d9f68f5677 Mon Sep 17 00:00:00 2001 From: Gytis Vinclovas Date: Tue, 19 May 2020 13:46:10 +0300 Subject: [PATCH 2/3] Changelog update --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95fc3796..e78f8139 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. + ## 3.7.0 * **New Feature** From b861e135dbfa8890b812ec491ee5fb7d7d226cab Mon Sep 17 00:00:00 2001 From: Gytis Vinclovas Date: Tue, 19 May 2020 13:48:01 +0300 Subject: [PATCH 3/3] format --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e78f8139..7ea7a3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ * **Bug Fix** - * Support any custom `globalObject` option in Webpack Config. + * 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