-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
theme-common doesn't deduplicate if site using pnpm/PnP installs it #7880
Comments
It is a known problem that using pnpm and other no-hoisting linking strategies (a.k.a. PnP) has caused theme-common to be duplicated in the package tree. In this case, the provider and the consumer of the same React context would be supplied by different copies of theme-common and cause this problem. (Also for reference: easyops-cn/docusaurus-search-local#205; I've answered this multiple times but I can't find other occurrences now)
If you look into It's not something I'd like to recommend, but I'd like to point out that adding Again, I was pretty sure this had been brought up in the issue tracker but I can't find an open issue now, so I'll keep this open. We'll likely migrate theme-common to peer dependency some time in the future. |
@Josh-Cena okay great, thanks for the detailed answer! That worked. I did not find anything while searching, but was probably looking way too specifically for my issue, related to the sidebar items / DocsCardLink The Any other idea how to do this programmatically so that automated CI builds on Vercel, for example, also work? @Josh-Cena |
Ah, forgot to mention—you need to remove it from your site dependencies as well. That's the point of using |
Curious, why isn't this a problem for the ReactJS package in the first place? Just because we use peerDependencies for it? |
Okay this ended up working for the For some reason the marquee icon thing we use on our home page (https://next-auth.js.org - hero background) broke though with docusaurus v2 now. Throwing illegal hook call (useState) on render.
|
Yes. Everything is declaring react as a peer dependency, as they should do. |
So maybe it's a similar issue and React is duplicated by pnpm? 🤷♂️ Unrelated but that looks heavy to load styled-components just for that hero background slider 😅 (+ Docusaurus does not even have a proper SSR integration with that lib yet) |
Yes you're very right 😅 broke my heart, but we really love the animation 🎉 EDIT: Doesn't look like |
@Josh-Cena is there still plan to move |
I ended up using My configs ended up being: "packageExtensions": {
"@docusaurus/theme-live-codeblock": {
"peerDependencies": {
"@docusaurus/theme-common": "*"
},
"dependencies": {
"@docusaurus/theme-common": "*"
}
},
"@docusaurus/preset-classic": {
"peerDependencies": {
"@docusaurus/theme-common": "*"
},
"dependencies": {
"@docusaurus/theme-common": "*"
}
},
"@docusaurus/theme-classic": {
"peerDependencies": {
"@docusaurus/theme-common": "*"
},
"dependencies": {
"@docusaurus/theme-common": "*"
}
},
"@docusaurus/theme-search-algolia": {
"peerDependencies": {
"@docusaurus/theme-common": "*"
},
"dependencies": {
"@docusaurus/theme-common": "*"
}
}
} that seems to do the trick of making sure they all look at the same version of |
it will not take effect when in monorep based on rush |
In my case, I actually had to add |
Thanks! It works for me! |
This fixed my |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
So I've tried to copy the code from your own docs and make a custom category index page. With the sub-pages displayed as cards, and some additional text on the page. Therefore, I don't want to use the
type: generate-index
category page.The pre-existing code worked fine in docusaurus
v2.0.0-beta.21
, however, when upgrading tov2.0.1
the page crashes upon visiting it in local dev, and Vercel preview deployments fail to build.I can't reproduce the issue in a fresh Stackblitz actually. It works as expected there. However, here is my draft PR in which it does not work as expected anymore. As previously mentioned, the same code worked in
v2.0.0-beta.21
(i.e. in our currentmain
/ prod deployment - https://next-auth.js.org/guides).So when rendering the markdown below, I get the following error:
Hook useDocsSidebar is called outside the <DocsSidebarProvider>.
all of a sudden.docs/guides/index.md
Reproducible demo
https://stackblitz.com/edit/github-e83uag?file=sidebars.js,package.json,docusaurus.config.js
Steps to reproduce
/guides
page<DocCardList />
render throw an errorExpected behavior
Render a custom category index page with the sub-pages listed in
DocCardList
components next to some more additional custom text.Actual behavior
Opening the page in question causes the following error:
Hook useDocsSidebar is called outside the <DocsSidebarProvider>.
Your environment
2.0.1
Self-service
The text was updated successfully, but these errors were encountered: