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

Support rules validation in webpack plugin #132

Open
chrisands opened this issue Oct 19, 2021 · 8 comments
Open

Support rules validation in webpack plugin #132

chrisands opened this issue Oct 19, 2021 · 8 comments

Comments

@chrisands
Copy link
Contributor

Is your feature request related to a problem? Please describe.
It feels unnecessary to additionally install cli only to validate.

Describe the solution you'd like
Ability to pass statoscope.config.js to webpack plugin and get report warns and errors.

Describe alternatives you've considered
Installing cli and run validation only in CI

@smelukov
Copy link
Member

If you validate your stats on CI then you install Statoscoope CLI anyway. Don't you?

@chrisands
Copy link
Contributor Author

chrisands commented Oct 22, 2021

Yes, I do. But I can't see errors and warnings in the report, that has been generated with webpack.
And if there were validation then I wouldn't install cli tool.

@smelukov
Copy link
Member

smelukov commented Oct 22, 2021

@amalitsky this is another issue that is good for contribution :)
I think we can implement that like this:
webpack plugin tries to resolve statoscope.config from pwd (just like cli does)
If there is a config, then try to validate webpack stats with stat-validator and resolved config
Also, we can add config-field to specify a custom path to statoscope.config

@amalitsky
Copy link
Contributor

amalitsky commented Jan 31, 2022

If I understand correctly, as of now webpack-plugin is meant to be used during the third party application build to create statoscope report next to stats.json file. Is it right?

Now, if the above is correct, let's assume that statoscope validation (not currently there, but is suggested above) performed by webpack-plugin fails for some reason - is plugin expected to fail the third party application build also? Or console output would be sufficient?

Asking because failing the build will be a breaking change and not failing the build could be misleading.

I admit - never worked on webpack plugins before, hence my understanding is limited at this point.

It seems to me that statoscope is capable of three distinct things:

  • gathering extra information during the build. Is it even a thing? Or webpack stats file has all we need?
  • formatting it into interactive html representation. Including data required for custom requests with jora.
  • validation

Is that right?

@rcherny
Copy link

rcherny commented Jan 26, 2023

I am loving statoscope @smelukov, but for the life of me I can't figure out how to generate the HTML report with the validation messages. I've installed stats-validator-plugin-webpack -- but that usage in the readme with the statoscope.config.js file seems related to the CLI, not the webpack usage. On the sandbox site, there's a sample that includes validation messages, but when I run my webpack build I don't get that, nor does it happen when I use serve or run statoscope validate. I feel like I'm missing something obvious ... 😢

@rcherny
Copy link

rcherny commented Jan 26, 2023

Ok I got it! I think the sample code has an incorrect value for the reporter option — indicates to use "@statoscope/stats-report" but it should be '@statoscope/stats-validator-reporter-stats-report'.

When I have a moment and am not against a deadline, I'll circle back and try to describe what I did to get it working and what I found misleading in the docs.

Thanks again for the awesome package(s)!

@smelukov
Copy link
Member

@rcherny Thanks for your feedback!
There are two steps to get html-report with validation result:

  1. Specofy @statoscope/stats-validator-reporter-stats-report as a reporter (e.g. https://github.com/statoscope/statoscope.tech/blob/main/statoscope.config.js#L8)
    Also, you can specify that reporter as @statoscope/stats-report and statoscope will try to use stats-validator-reporter- as a prefix automatically.

  2. Run statoscope validate --input=path/to/stats.json and then you’ll get html-report.

If it works not like it described above, please let me know ☺️

@rcherny
Copy link

rcherny commented Jan 27, 2023

Appreciate the note! Oddly enough, originally when I tried @statoscope/stats-report and also tried to install that, NPM said it didn't exist. I'll try again soon, but I did get it working using stats-validator-reporter-stats-report. Thanks again,

cheers

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

4 participants