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(core): allow plugins to self-disable by returning null #10286

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jul 9, 2024

Motivation

A plugin should be able to self-disable depending on context/options by returning null

We actually need this for our own plugins:

export default function pluginPWA(
  context: LoadContext,
  options: PluginOptions,
): Plugin<void> | null {
  if (process.env.NODE_ENV !== 'production') {
    return null;
  }
  if (context.siteConfig.future.experimental_router === 'hash') {
    logger.warn(
      `${PluginName} does not support the Hash Router and will be disabled.`,
    );
    return null;
  }
  
  return {
    name: PluginName, 
    // rest of plugin here...
  }
}

See also #10228 (comment)

Test Plan

unit tests

Test links

https://deploy-preview-10286--docusaurus-2.netlify.app/

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Jul 9, 2024
@slorber slorber requested a review from Josh-Cena as a code owner July 9, 2024 18:53
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 9, 2024
@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Jul 9, 2024
Copy link

github-actions bot commented Jul 9, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 62 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 60 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 69 🟢 100 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 48 🟢 96 🟢 100 🟢 100 Report
/blog/tags/release 🟠 69 🟢 100 🟢 100 🟠 86 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟠 86 Report

Copy link

netlify bot commented Jul 10, 2024

[V2]

Name Link
🔨 Latest commit 5dd12e1
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/668e671924b3650008bedda9
😎 Deploy Preview https://deploy-preview-10286--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

argos-ci bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 10, 2024, 10:55 AM

Copy link

github-actions bot commented Jul 10, 2024

Size Change: 0 B

Total Size: 1.85 MB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/codeTranslations.json 2 B
website/.docusaurus/docusaurus.config.mjs 27.3 kB
website/.docusaurus/globalData.json 123 kB
website/.docusaurus/i18n.json 930 B
website/.docusaurus/registry.js 304 kB
website/.docusaurus/routes.js 202 kB
website/.docusaurus/routesChunkNames.json 130 kB
website/.docusaurus/site-metadata.json 2.17 kB
website/build/assets/css/styles.********.css 113 kB
website/build/assets/js/main.********.js 907 kB
website/build/index.html 38.1 kB

compressed-size-action

@slorber slorber merged commit 80203b3 into main Jul 10, 2024
34 of 35 checks passed
@slorber slorber deleted the slorber/allow-null-plugin branch July 10, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. 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.

2 participants