Skip to content
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

If webpack stats object gets large enough, JSON.stringify crashes #109

Open
2 tasks done
maclockard opened this issue Feb 5, 2025 · 2 comments
Open
2 tasks done

Comments

@maclockard
Copy link

maclockard commented Feb 5, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Code Sandbox link

No response

Bug report

The same bug that webpack/webpack-cli#2190 fixes. The issue here is if webpack stats object is large enough you can no longer just call JSON.stringify on it, otherwise you get errors along the lines of RangeError: Invalid string length.

The fix here is to stream the JSON serialization rather than doing it at once. Fixing this might be tricky without making a breaking change to the plugin API since I'm not sure how it can be compatible with the current opts.transform

@maclockard maclockard added the bug label Feb 5, 2025
@ryan-roemer
Copy link
Member

The plugin supports promised-based transforms that you can use JSON streaming. Here's an example: https://github.com/FormidableLabs/webpack-stats-plugin/blob/main/test/scenarios/webpack5/webpack.config.js#L172-L196

@ryan-roemer ryan-roemer added unverified and removed bug labels Feb 5, 2025
@maclockard
Copy link
Author

Ahh, gotcha, the trick here being not using the file output from webpack-stats-plugin (emit: false) and just doing it yourself. Thanks for the pointer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants