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

fix(core): make plugin lifecycles consistently bound to the plugin instance #6850

Merged
merged 1 commit into from
Mar 5, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Motivation

This should always work:

function plugin() {
  return {
    foo() { console.log("Bar"); }
    configureWebpack() { this.foo(); }
  };
}

Unfortunately, it doesn't work if configureWebpack is unbound from the plugin instance. We should always bind the lifecycle so plugin authors can write code in the most intuitive way.

Have you read the Contributing Guidelines on pull requests?

Yes

@Josh-Cena Josh-Cena added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 5, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 5, 2022
@netlify
Copy link

netlify bot commented Mar 5, 2022

✔️ [V2]

🔨 Explore the source changes: 67f69b7

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/62232c7183c1e800087daa8a

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

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 54
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

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

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

Size Change: 0 B

Total Size: 791 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 49.9 kB
website/build/assets/css/styles.********.css 105 kB
website/build/assets/js/main.********.js 597 kB
website/build/index.html 38.4 kB

compressed-size-action

@Josh-Cena Josh-Cena merged commit b2d6e45 into main Mar 5, 2022
@Josh-Cena Josh-Cena deleted the jc/fix-plugin-this branch March 5, 2022 09:57
@slorber
Copy link
Collaborator

slorber commented Mar 9, 2022

👍

Not particularly fan of this binding but why not 🤷‍♂️

If we want to keep this behavior over time it's worth adding some tests

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: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants