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

feat(v2): Allow plugins to consume webpack stats #4021

Merged
merged 4 commits into from Jan 11, 2021
Merged

feat(v2): Allow plugins to consume webpack stats #4021

merged 4 commits into from Jan 11, 2021

Conversation

RDIL
Copy link
Contributor

@RDIL RDIL commented Jan 8, 2021

Signed-off-by: Reece Dunham me@rdil.rocks

Motivation

I need to use one of these stats in my own plugin, so it was patch-package, or do this, which gives plugins a LOT more options for post-processing and other capabilities.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

My test plugin worked against the branch.

Related PRs

n/a

Signed-off-by: Reece Dunham <me@rdil.rocks>
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 8, 2021
@netlify
Copy link

netlify bot commented Jan 8, 2021

✔️ Deploy preview for docusaurus-2 ready!
Built without sensitive environment variables

🔨 Explore the source changes: 96a4232

🔍 Inspect the deploy logs: https://app.netlify.com/sites/docusaurus-2/deploys/5ffc5cdef3a490000784e920

😎 Browse the preview: https://deploy-preview-4021--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Jan 8, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 88
🟢 Accessibility 99
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4021--docusaurus-2.netlify.app/classic/

@github-actions
Copy link

github-actions bot commented Jan 8, 2021

Size Change: 0 B

Total Size: 26.7 kB

ℹ️ View Unchanged
Filename Size Change
website/build/blog/2017/12/14/introducing-docusaurus/index.html 20.7 kB 0 B
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 5.83 kB 0 B

compressed-size-action

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 👍

Was wondering why the start.ts type is updated?

@@ -103,7 +103,7 @@ export default async function start(
cwd: siteDir,
ignoreInitial: true,
usePolling: !!cliOptions.poll,
interval: Number.isInteger(cliOptions.poll)
interval: Number.isInteger((cliOptions.poll as unknown) as never)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what was the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I was going to need to update this for this PR, and my IDE was complaining about it. I'll revert if you want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As it's not strictly related to the PR and I don't understand the intent, I'd prefer removing this line and discuss it as a separate issue/PR if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

console.error(e);
});
reject(new Error('Failed to compile with errors.'));
}
if (stats?.hasWarnings()) {
// Custom filtering warnings (see https://github.com/webpack/webpack/issues/7841).
let {warnings} = stats.toJson('errors-warnings');
let warnings = [...allStats.warnings];
Copy link
Collaborator

Choose a reason for hiding this comment

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

are there cases where the warning array is not defined?

Maybe we could replace the condition with if (allStats.warnings?.length > 0), and TS would understand better that the array is there or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is there so the original stats.warnings doesn't get modified.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see thanks.
It shouldn't be, but won't harm to keep this code

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Jan 11, 2021
@slorber slorber changed the title refactor(v2): Allow plugins to consume webpack stats feat(v2): Allow plugins to consume webpack stats Jan 11, 2021
@slorber
Copy link
Collaborator

slorber commented Jan 11, 2021

thanks 👍

@slorber slorber merged commit 66cc736 into facebook:master Jan 11, 2021
@RDIL RDIL deleted the plugin-stats branch January 11, 2021 14:35
@RDIL
Copy link
Contributor Author

RDIL commented Jan 11, 2021

No, thank you! My plugin is now a little closer to completion 😄

@slorber
Copy link
Collaborator

slorber commented Jan 11, 2021

great to know 👍 add it to the community section when ready

This was referenced Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants