-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(v2): avoid duplicated imports in npm2yarn plugin #4964
Conversation
const transformer = (node) => { | ||
if (node.type === 'import' && node.value.includes('@theme/Tabs')) { |
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 intentionally check import only one Tabs
component, because I think that using TabItem
without importing Tabs
makes no sense at all, so we can omit checking these two components.
✔️ [V2] 🔨 Explore the source changes: 9f56fcc 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60c7c5f78174610007a355fc 😎 Browse the preview: https://deploy-preview-4964--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4964--docusaurus-2.netlify.app/ |
Size Change: +46 B (0%) Total Size: 621 kB
ℹ️ View Unchanged
|
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, LGTM!
@@ -0,0 +1,7 @@ | |||
import Tabs from '@theme/Tabs'; |
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.
will it work if you use npm2yarn above the imports?
I think it will but I'd suggest adding usage of npm2yarn above/under the imports just to be 100% sure :)
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.
Yes, done it.
thanks 👍 |
Motivation
Resolves #4544
Currently, we cannot use
@docusaurus/remark-plugin-npm2yarn
plugin in document that already importsTabs
/TabItem
components. This is because the plugin imports them no matter what they can already be imported in mdx doc file.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Put the following code into any md file and try to start site.
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)