diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e866146..786df86f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ * **Bug Fix** * Fix tooltip styling in dark mode when using CSS Modules ([#688](https://github.com/webpack/webpack-bundle-analyzer/pull/688) by [@theEquinoxDev](https://github.com/theEquinoxDev)) - + * Avoid parse failures for bundles with IIFE ([#685](https://github.com/webpack/webpack-bundle-analyzer/pull/685) by [@hai-x](https://github.com/hai-x)) ## 5.1.0 diff --git a/src/parseUtils.js b/src/parseUtils.js index bdfd71bb..ead50de2 100644 --- a/src/parseUtils.js +++ b/src/parseUtils.js @@ -53,7 +53,7 @@ function parseBundle(bundlePath, opts) { if (firstVariableDeclaration) { for (const declaration of firstVariableDeclaration.declarations) { - if (declaration.init) { + if (declaration.init && isModulesList(declaration.init)) { state.locations = getModulesLocations(declaration.init); if (state.locations) { diff --git a/test/bundles/validBundleWithIIFE.js b/test/bundles/validBundleWithIIFE.js new file mode 100644 index 00000000..0ac4bd51 --- /dev/null +++ b/test/bundles/validBundleWithIIFE.js @@ -0,0 +1 @@ +(()=>{const e=console.log("foo");})(); diff --git a/test/bundles/validBundleWithIIFE.modules.json b/test/bundles/validBundleWithIIFE.modules.json new file mode 100644 index 00000000..ffce6828 --- /dev/null +++ b/test/bundles/validBundleWithIIFE.modules.json @@ -0,0 +1,3 @@ +{ + "modules": {} +}