Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Stop outputting long list of Error parsing bundle asset errors when the build fails #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fregante opened this issue Mar 17, 2025 · 12 comments

Comments

@fregante
Copy link

When the build fails, webpack-bundle-analyzer fills up the logs with irrelevant lines:

Error parsing bundle asset "apps/admin-console/bundles/main-a005b5463f19ca11727d.min.js": no such file
Error parsing bundle asset "apps/admin-console/bundles/CustomFormComponent-648471e17196c5edc242.min.js": no such file
Error parsing bundle asset "apps/admin-console/bundles/WebAppPlatformLayout-3ff85759162b39d96eaa.bundle.min.js": no such file
Error parsing bundle asset "apps/admin-console/bundles/21983-1d2ef12ba1460dcedee5.bundle.min.js": no such file
Error parsing bundle asset "apps/admin-console/bundles/AdminConsoleLayout-86f8bbbfa0d21a23d0fe.bundle.min.js": no such file
Webpack Bundle Analyzer saved report to apps/admin-console/report.html

This time 100 because my build is generating several small bundles (icons)

The plugin should detect failure and avoid trying to read bundles that don't exist

@alexander-akait
Copy link
Member

Do you use the latest version? Because this error should be fixed

@fregante
Copy link
Author

    "webpack": "^5.96.1",
    "webpack-build-notifier": "^3.1.0",
    "webpack-bundle-analyzer": "^4.10.2",

@fregante
Copy link
Author

I wonder if it's the same issue reported here #647

@valscion
Copy link
Member

Yeah I haven't yet got to releasing a new version with #649 changes in. I was meaning to analyze the regression I saw in CI when I fixed it to again work before I'd release a new major version. I commented on #650 for those mysterious cases that had now been failing but I hadn't yet figured out which changes could've caused the tests to start failing.

So it could be that once a new version with #649 are in, this would be fixed.

Can you test that out by following the "Develop with your own project" steps in CONTRIBUTING.md to see if your problem would be fixed with the changes we have in master but haven't yet released? https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CONTRIBUTING.md#develop-with-your-own-project

@fregante
Copy link
Author

Tried, not fixed

@alexander-akait
Copy link
Member

@fregante Can you create reproducible test repo? Because it means your code is not parsable by acorn, that is very weird

@fregante
Copy link
Author

Because it means your code is not parsable by acorn, that is very weird

Yes, it happens, that's the issue. The real issue (syntax error) is lost in webpack-bundle-analyzer's output. What I do to repro it is just break a file by adding / at a random place. If that doesn't do it for you, I can try creating a repro later

@alexander-akait
Copy link
Member

alexander-akait commented Mar 24, 2025

@fregante I fully understand why and when parsers are failed (and reasons), the question - why you have broken JS code in your output? And I ask about the reproducible test repo to understand - why you have broken code.

@fregante
Copy link
Author

I think the point is that webpack will not generate the builds, so there's no output. The build fails completely because of the syntax error in my source files. But webpack-bundle-analyzer still knows about the files that are supposed to be generated.

As the error says:

Error parsing bundle asset ——: no such file

@alexander-akait
Copy link
Member

@fregante Got it, so we need to skip files which contains errors or was not generated

@fregante
Copy link
Author

fregante commented Mar 24, 2025

Correct.

Repro

It's as basic as can be:

npm init -y
npm install webpack webpack-cli webpack-bundle-analyzer --save-dev
echo '/' > index.js

then copy-paste this into webpack.config.js

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = {
  plugins: [
    new BundleAnalyzerPlugin({analyzerMode: 'static', openAnalyzer:false})
  ]
}

and run

npx webpack ./index.js --mode production

Output

Error parsing bundle asset "./main.js": no such file

No bundles were parsed. Analyzer will show only original module sizes from stats file.

Webpack Bundle Analyzer saved report to ./report.html
assets by status 261 bytes [cached] 1 asset
./index.js 2 bytes [built] [code generated] [1 error]

ERROR in ./index.js 1:1
Module parse failed: Unterminated regular expression (1:1)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> /
| 

webpack 5.98.0 compiled with 1 error in 87 ms

@valscion
Copy link
Member

Thanks! I'll convert this to a feature request discussion to have them be in the same place ☺

@webpack-contrib webpack-contrib locked and limited conversation to collaborators Mar 25, 2025
@valscion valscion converted this issue into discussion #658 Mar 25, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants