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(theme-common): restore useContextualSearchFilters public API for retrocompatibility #10397

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import {DEFAULT_SEARCH_TAG} from './utils/searchUtils';

// TODO Docusaurus v4: remove these workarounds as a breaking change
// and remove docs plugin peerDeps in theme-common/package.json
// This is public API surface that we need to keep for v3
Expand All @@ -27,6 +30,14 @@ export function useDocsPreferredVersion(...args: unknown[]): unknown {
...args,
);
}
export function useContextualSearchFilters() {
const {i18n} = useDocusaurusContext();
const docsTags =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@docusaurus/plugin-content-docs/client').useDocsContextualSearchTags();
Copy link

@dubzzz dubzzz Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this line to be the one causing me troubles on the official build of fast-check's documentation. This require makes theme-common pull things from @docusaurus/plugin-content-docs, which is just a peer.

The issue I'm facing appeared on 3.5.0. I need to come up with a repro implying a simplified version of my setup: yarn berry with docs being on.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the issue I'm facing is probably that the very same 3.5.0 moved @docusaurus/plugin-content-docs from dependency to peer 🤔

Copy link
Collaborator Author

@slorber slorber Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand @dubzzz are you even using the fix in 3.5.2? Because you say you use 3.5.0

I can't help if I don't have a repro, or at least an error message or something.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My CI passes against 3.4.0 and fails with 3.5.2. I have not checked the intermediate versions yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would have been helpful to share the PR and CI job logs 😅

dubzzz/fast-check#5196
https://github.com/dubzzz/fast-check/actions/runs/10911561615/job/30284617054?pr=5196

Not sure why I can't see any CI logs there:
CleanShot 2024-09-26 at 11 44 42

What do the logs say and how do you know it's related to this PR?

Copy link
Collaborator Author

@slorber slorber Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it looks like, try using node linker instead

but we have e2e tests for Yarn / PnP so technically it should work, maybe it's a bug in a specific version of Yarn?

Our init template can build with Yarn 4.5.1 with PnP:
https://github.com/facebook/docusaurus/actions/runs/11611426378/job/32332737573

Using package extensions is a workaround that usually works to please PnP errors: https://yarnpkg.com/features/pnp#how-can-i-fix-ghost-dependencies

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the trick. I'll try it.

By the way I'm still trying to make up my mind on whether or not I stick to yarn or move to pnpm.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, I'm also using 4.5.1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still like Yarn but this PnP thing is too innovative and always cause troubles 😅

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It solved my issue. Thank you so much for the trick

const tags = [DEFAULT_SEARCH_TAG, ...docsTags];
return {locale: i18n.currentLocale, tags};
}

/*
* APIs to document
Expand Down