Skip to content

docs: add ProgressPlugin + progress reporting #2293

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

Merged
merged 4 commits into from
Aug 26, 2018

Conversation

elliottsj
Copy link
Member

To address #2289, add a "Reporting Progress" section to the Plugin API doc, and an article for ProgressPlugin.

@elliottsj elliottsj force-pushed the progress-reporting branch 2 times, most recently from 62d838e to ed6c9b4 Compare June 23, 2018 23:03

## Usage

Create an instance of `ProgressPlugin` with a handler function which will be called when hooks report progress:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a showcase within your own plugin right? maybe provide a context e.g.

myPlugin.js

const handler = (percentage, message, ...args) => {
.....

Copy link
Member Author

@elliottsj elliottsj Jun 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can used inside of a plugin (e.g. progress-bar-webpack-plugin), but ProgressPlugin can also be used standalone, e.g.

// webpack.config.js

module.exports = {
  plugins: [
    new ProgressPlugin((percentage, message, ...args) => {
      console.info(percentage, message, ...args);
    })
  ]
};

I'd like to keep the initial "Usage" code snippet simple and consistent with the other plugin pages on the site.

I agree that it would be useful to showcase / link to examples of using ProgressPlugin within a parent plugin. What if I add an "Examples" section and link to ProgressPlugin usage within progress-bar-webpack-plugin / webpack-cli / webpack-command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the example you gave is much better in my opinion, maybe replace it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to include the console.info() line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think I should include the module.exports = { plugins: [ part too? Leaving it out for now for consistency with the other plugin docs

The `reportProgress` function has this signature:

```js
reportProgress(percentage: number, ...args: string[]): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use JS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, add basic JSDoc notation or a link to its Source code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now updated to use JS

@elliottsj elliottsj force-pushed the progress-reporting branch 2 times, most recently from 34e5ef6 to 1da1470 Compare June 25, 2018 18:47
@montogeek
Copy link
Member

@EugeneHlushko Any comment on this PR?

@@ -99,6 +99,36 @@ compiler.hooks.myCustomHook.call(a, b, c);
Again, see the [documentation](https://github.com/webpack/tapable) for `tapable` to learn more about the
different hook classes and how they work.

## Reporting Progress

Plugins can report progress information, which is printed by [the CLI](/api/cli/) when the `--progress` argument is used. More generally, progress information is passed to [`ProgressPlugin`](/plugins/progress-plugin/), which can be used to customize how progress information is reported to the user.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to remove More generally, . Just go with Progress information... for being clear.

To be honest it doesnt read well the whole paragraph.

Plugins can report progress via ProgressPlugin which prints progress messages by the CLI. In order to enable progress reporting, pass a --progress argument when running webpack.

It is possible to customize the printed output by passing different arguments to the reportProgress function of the ProgressPlugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@montogeek what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, and sorry for the delay!

I'm not sure about the wording of "...ProgressPlugin which prints progress messages by the CLI.", since ProgressPlugin may be used outside of the CLI.

I've updated the wording with yours, but edited this line slightly. Let me know what you think.


T> _Hooks marked with * allow plugins to report progress information using `reportProgress`. For more, see [Plugin API: Reporting Progress](/api/plugins/#reporting-progress)_

### Compiler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will show in the sidebar menu as Compiler, maybe dont use ### here but just make it bold? Because the name of sidebar entry should say Compiler's hooks which support reporting progress to make sense but it is too long to fit in. I think the previous heading is enough as an entry for the sidebar (Supported Hooks)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@EugeneHlushko
Copy link
Member

Sorry for late reply, i think its a great addition that needs small tweaks, i did leave two more comments in the changes. Would be nice to get another eye at it, maybe @jeremenichelli has time

@montogeek
Copy link
Member

@elliottsj Friendly ping

@elliottsj
Copy link
Member Author

Hey, sorry for the silence! Been a bit busy the past few weeks, but I'll try to take a look at this this evening.

* afterOptimizeAssets*
* afterSeal*

## References
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there are none, just remove this heading

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean just say Source... or references, dont do two headers in a row please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@EugeneHlushko EugeneHlushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good, just a minor tweak request if no objections

Copy link
Member

@EugeneHlushko EugeneHlushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, you could also remove _ italic from T> block but it is not that important

@EugeneHlushko
Copy link
Member

on a side note, please dont squash/ammend commits, easier to review 👍

@montogeek montogeek merged commit b96d505 into webpack:master Aug 26, 2018
@montogeek
Copy link
Member

Thanks!

@elliottsj elliottsj deleted the progress-reporting branch August 27, 2018 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants