-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
"Docs plugin enabled" detection no longer does anything #7207
Comments
This is my major dissatisfaction with the ongoing refactors. Everything gets intertwined and our architecture is getting more and more monolithic despite being allegedly "plugin-based". |
I don't think it's a big deal considering theme-classic/theme-common are supposed to be an implementation of docs/blog/page content plugins. There's little value in optimizing install time for users that are not willing to use a specific content plugin IMHO, there are much lower hanging fruits to reduce install time. #3360 was about a different issue: a blog would not build if the user is using
I agree that we can clean up the lazy NavbarItem require now, also wanted to do this cleanup Also agree to use dynamic imports, but it requires SSR support for dynamically imported components
I'm not sure to understand what you mean here. What change makes things worse exactly?
I agree with that, but at the same time we have the theme implementing 3 content plugins so it's expected to be coupled to these plugins on purpose. We could have a more modular architecture, having a plugin being able to register its own navbar item etc (slightly related to the other discussion in #7152 (comment)) But then, if we have 2 themes, then we'll have docs-classic + docs-tailwind + blog-classic + blog-tailwind? |
Yeah, I'm mainly talking about directly importing The theme aliases somehow work like inversion of control. Instead of having direct dependency relationship, the alias allows them to communicate through a shared protocol where plugin provides the data and theme provides the components. There's no hard dependence in this relationship and unplugging anything naturally works. I'm not asking to split the theme—just that importing from
Ah, I understand now. Scratch the point about skipping installation of a package (maybe we still can in the future with optional peer dependencies, but we have been bitten by peer dependencies, so not in the near future). Bundle size is still a valid claim, though |
I understand that, but at the same time it can become quite tedious to maintain the "contract" between content plugin and theme this way. Remember most of these docs apis are internal and undocumented. Adding indirection only increase maintenance cost from us. These apis are not really meant to be overridden with aliases. If user is unhappy with a behavior, they can swizzle the component and provide a brand new implementation using documented apis like
I don't understand why it's worse to import it in theme-common compared to theme-classic? Maybe you are against both, and I can understand that. IMHO coupling isn't always a bad thing. Here it's done on purpose to avoid the extra cost of an unnecessary indirection layer. Unless you can give a strong use-case for introducing back this indirection (pragmatic use-case, not theoretical), I'd rather keep it this way for now. |
The use-case is that now theme-common is explicitly dependent on content-docs instead of implicitly through theme aliases, and there's no way to rid |
Then if a user reports using I don't think this is valuable to dedicate much time to this atm, but conceptually I agree. |
Yes, that's basically the idea. Quite annoying (because it signals smelly architecture) but not high-priority. Just here to raise awareness and discuss some solutions. |
I guess we can close this now that theme-common does not depend on content plugins anymore (at least it will be the case in v4 soon: see #10316) |
Because
theme-common
has a direct dependency onplugin-content-docs
, it is no longer possible to make a site without ever installingcontent-docs
(previously discussed in #3360). Not really a big deal because the user can still installtheme-classic
andplugin-content-blog
and pretend she never pulls incontent-docs
transitively, but it's still not desirable.We have some checks in our codebase about whether docs is enabled:
docusaurus/packages/docusaurus-theme-common/src/utils/docsUtils.tsx
Lines 32 to 33 in c8d6c7e
docusaurus/packages/docusaurus-theme-classic/src/theme/NavbarItem/index.tsx
Lines 18 to 38 in c8d6c7e
Because we are now always directly importing these hooks from
@docusaurus/plugin-content-docs/client
instead of letting the docs plugin register theme aliases, these things always statically exist. We should either remove the checks, or dynamically importcontent-docs/client
everywhere (better IMO in terms of bundle size)The text was updated successfully, but these errors were encountered: