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
support webpack@5 #327
Comments
I wonder what's needed to support webpack 5? What kinds of failures are there when running with webpack 5 currently? |
Some developers from webpack/webpack#9802 say what webpack-bundle-analyzer doesn't work with webpack@5, will be great setup CI to ensure all works fine, also acorn should be updated 😄 |
Ok thanks for pointin to that issue! That one is a doozy, 281 comments as of now 😅 |
I don't see a mention in webpack/webpack#9802 to This repository only has a development dependency to webpack as it's used only in a few tests. Mostly we rely on stats files generated from various webpack versions instead of running CI with multiple different webpack versions. |
@valscion Can we add webpack@5 stats as test for CI, just want to ensure all works fine |
Oh, actually, I mean that instead of stats, we use bundles generated by different versions of webpack. In specific cases, there are stats also but the most brittle piece of code relates to generated bundle parsing and module extraction from there. https://github.com/webpack-contrib/webpack-bundle-analyzer/tree/master/test/bundles contains those tests and are automatically used in tests in pairs: webpack-bundle-analyzer/test/parseUtils.js Lines 8 to 25 in 7cefb58
|
So basically the easiest way we could have more assurance that webpack @ 5 works would be to create small bundles made with webpack 5 and write out the expected modules JSON next to the bundle output. I don't have time to do that right now, but if you or someone else is willing to add this kind of small test case for webpack@5, it would be nice |
webpack has a different output AST so the parser need to be adjusted. It also gets a little bit more challenging as more variations are possible: /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
MODULES HERE
/******/ ]); /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ([
MODULES HERE
/******/ ]); (() => {
var e = [
MODULES HERE
], r = {};
function t(o) {
if (r[o]) return r[o].exports;
var n = (r[o] = { exports: {} });
return e[o](n, n.exports, t), n.exports;
} Arrow functions may also be normal functions when Arrays might be objects too, as with webpack 4. There might also be one entry module inlined into the runtime code, which is very difficult to identify in production mode. |
Thank you @sokra for the extensive information! This looks like something we can work with. Seems like what we could do would be to pick the modules from the first variable definition in the bundles when the other conditionals have failed. We already handle both arrays and objects form of modules, so we only need to change the code to find modules from the variable and then do the parsing as before. If we fail to parse some output bundles, the analyzer will just show the original module size from the stats file. So we should get a graceful degradation instead of a bad crash. |
Seems, analyzer works with webpack 5 beta 12 now |
After upgrading to Interestingly, after I added back Webpack 4 with Any ideas on how to build using Webpack 5 normally, but use Webpack 4 just for |
I haven't fully debugged it yet, but this seems to cause an error with webpack v5:
|
Looks the same as #384 |
I'm trying to update |
Please help #384 go through by adding tests and discover more information on why that code is necessary. Then we can merge it once we understand why it is needed and if it can have any tests. |
I don't have the availability, sorry. I'm already fixing an issue with a project by fixing an issue with a package, that requires a fix to another package, which in turn requires another package fixed 🥲 It's a bit strange; almost no one must be using webpack v5 given the lack of movement on some of these issues. This one for example has been open almost a year, and the webpack v5 stable release was over a month ago. |
Do note that We even test that this package works with webpack v5: https://github.com/webpack-contrib/webpack-bundle-analyzer/tree/master/test/webpack-versions/5.4.0 So this is only an edge case that is broken, not the entire support for webpack 5. |
Issue description
...
Technical info
Debug info
Support webpack@5 (will be great have CI and fix test to ensure all works as expected)
Additional comment by @valscion in #327 (comment):
Do note that
webpack-bundle-analyzer
does work with webpack version 5. There is some combination of options which breaks, but not all of webpack 5.We even test that this package works with webpack v5: https://github.com/webpack-contrib/webpack-bundle-analyzer/tree/master/test/webpack-versions/5.4.0
So this is only an edge case that is broken, not the entire support for webpack 5.
The text was updated successfully, but these errors were encountered: