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

cli: Support for large webpack stats files #2118

Closed
vio opened this issue Mar 11, 2022 · 7 comments
Closed

cli: Support for large webpack stats files #2118

vio opened this issue Mar 11, 2022 · 7 comments
Labels
feature New feature or request

Comments

@vio
Copy link
Member

vio commented Mar 11, 2022

No description provided.

@vio vio added the feature New feature or request label Mar 11, 2022
@vio vio added this to To do in relative-ci.com roadmap via automation Mar 11, 2022
@fcano-ut
Copy link

fcano-ut commented Jul 7, 2022

I'm using the cli to try to generate a stats file, but I get errors like this:

Invalid webpack stats structure, please make sure webpack stats configuration is correct.

Expected a value of type `interface<{name,size}> | interface<{type,filteredChildren,size}>[] & notEmptyArray` for `assets`
https://github.com/relative-ci/bundle-stats/tree/master/packages/cli#webpack-configuration
Filepath: ./webpack-stats.json

My stats file is +120k lines long. Do you think it can be related to this issue?

@fcano-ut
Copy link

fcano-ut commented Jul 7, 2022

Update: also I should mention that my webpack-stats.json file doesn't contain an assets key. (probably because I'm not using any asset). I should also mention I'm on webpack 4. Any of this things might be being the issue, but just in case I'm checking the CLI issues, because with the webpack plugin I didn't had any issue...

@vio
Copy link
Member Author

vio commented Jul 7, 2022

@fcano-uz the error you are getting is from bundle-stats validator and it means that the structure of the stats is not as expected. The webpack stats file is already loaded in order to validate it, so is not related to the size of the file.

Update: also I should mention that my webpack-stats.json file doesn't contain an assets key. (probably because I'm not using any asset). I should also mention I'm on webpack 4. Any of this things might be being the issue, but just in case I'm checking the CLI issues, because with the webpack plugin I didn't had any issue...

The webpack-plugin sets its own webpack stats options when getting the data, but when generating the webpack stats using the CLI method, you need to make sure the required webpack stats options are set.

If you are using a framework that sets webpack stats.preset to something less inclusive than normal, you can set stats.preset = normal or use webpack-stats-plugin to output the webpack stats with the desired config. Here is a guide that you can follow to output the webpack stats using the CLI or with a webpack plugin: https://relative-ci.com/documentation/guides/webpack-stats.

Let me know if you are still getting errors after you regenerate the webpack stats ;)

@fcano-ut
Copy link

fcano-ut commented Jul 8, 2022

My stats seem correct, If I log webpackConfig.stats (just before exporting it in the config file), I get this:

{
  assets: true,
  entrypoints: true,
  chunks: true,
  modules: true,
  builtAt: true,
  hash: true
}

Setting stats.preset gives me an "Invalid configuration object" error, I think that might be a webpack 5 option only... 🤔

I was generating the stats file this way:

webpack --json > ./webpack-stats.json

I'm seeing there's also a --profile option that adds more information about modules in the stats file (is what made my file grow from 70k to 140k lines), but after using that option I still get the same error.

(For reference: this is the webpack v4 docs for "stats")

So even setting the stats object as seen in the documentation, and even using the --profile option, I get the error when using the CLI.

My stats file has this structure:

Screenshot 2022-07-08 at 09 32 05

I can open a new issue if you prefer, maybe I can share the full stats file if that can be useful. For now this is a non-blocker, I'm going to use the webpack plugin.

@vio
Copy link
Member Author

vio commented Jul 8, 2022

Setting stats.preset gives me an "Invalid configuration object" error, I think that might be a webpack 5 option only...

Yes, you are right about that! On webpack v4, the preset values are options for stats (ex: stats: 'all').

bundle-stats supports webpack v4, and I'm still working on a couple of webpack v4 projects where it is used as a standalone CLI or with relative-ci. In this case, I suspect a config conflict with another third-party plugin.

Next, it will be interesting to see the output of the webpack stats with stats: 'all' and/or try to use webpack-stats-plugin to output the JSON file.

Let me know if you are still having problems after you try the above. If the assets are still not present, it might be helpful to try to recreate a minimal reproducible case.

@fcano-ut
Copy link

Thanks for the comment @vio

Indeed using the webpack-stats-plugin fixes the stats file and makes it work again, so this looks like a plugin overriding the stats configuration.

@vio
Copy link
Member Author

vio commented Jun 3, 2023

closed by #3420

ready for testing on v4.4.0-beta.3

@vio vio closed this as completed Jun 3, 2023
relative-ci.com roadmap automation moved this from Backlog to Done Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
No open projects
Development

No branches or pull requests

2 participants