-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Conversation
62d838e
to
ed6c9b4
Compare
|
||
## Usage | ||
|
||
Create an instance of `ProgressPlugin` with a handler function which will be called when hooks report progress: |
There was a problem hiding this comment.
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) => {
.....
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/content/api/plugins.md
Outdated
The `reportProgress` function has this signature: | ||
|
||
```js | ||
reportProgress(percentage: number, ...args: string[]): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use JS.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
34e5ef6
to
1da1470
Compare
@EugeneHlushko Any comment on this PR? |
src/content/api/plugins.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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 |
@elliottsj Friendly ping |
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. |
1da1470
to
5a4fa0c
Compare
* afterOptimizeAssets* | ||
* afterSeal* | ||
|
||
## References |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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
5a4fa0c
to
70874a4
Compare
There was a problem hiding this 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
on a side note, please dont squash/ammend commits, easier to review 👍 |
Thanks! |
To address #2289, add a "Reporting Progress" section to the Plugin API doc, and an article for
ProgressPlugin
.