typesense / docusaurus-theme-search-typesense

A fork of the awesome @docusaurus/theme-search-algolia library customized to work with Typesense
https://typesense.org/docs/guide/docsearch.html
MIT License
67 stars 15 forks source link

Can't resolve '../../client' error after swizzling SearchBar #25

Open dtlhlbs opened 1 year ago

dtlhlbs commented 1 year ago

Description

When I try to swizzle the docusaurus-theme-search-typesense SearchBar component it fails to compile docusaurus with an error.

Steps to reproduce

  1. Run yarn run swizzle docusaurus-theme-search-typesense SearchBar
  2. Select the 'Eject' option
  3. Run yarn start

Expected Behavior

Local Docusaurus will start without error with a copied version of the typesense searchbar as it was previously

Actual Behavior

Docusaurus launches with an error:

Compiled with problems:X

ERROR in ./src/theme/SearchBar/index.js 7:143-199

Module not found: Error: Can't resolve '../../client' in '<redacted>\content\src\theme\SearchBar'

Metadata

docusaurus/core: 2.2.0 docusaurus-theme-search-typesense: 0.8.0

Kyriakos-Bekas commented 1 year ago

I have the same issue.

My Metadata is the same, however I use npm instead of yarn and I swizzled the SearchBar component using the Typescript flag.

The issue seems to the relative path to the client module in the following line (inside src/theme/SearchBar/index.tsx - directory created by running the swizzling command)

import {useTypesenseContextualFilters} from '../../client';

I tried to manually change the path to the client module by replacing the previous import statement as such:

import { useTypesenseContextualFilters } from "docusaurus-theme-search-typesense/lib/client/index";

But got

Module not found: Error: Package path ./lib/client/index is not exported from package <redacted>/node_modules/docusaurus-theme-search-typesense (see exports field in <redacted>/node_modules/docusaurus-theme-search-typesense/package.json)
client (webpack 5.75.0) compiled with 1 error

And also as such

import { useTypesenseContextualFilters } from "docusaurus-theme-search-typesense/src/client/index";

But got again

Module not found: Error: Package path ./lib/client/index is not exported from package <redacted>/node_modules/docusaurus-theme-search-typesense (see exports field in <redacted>/node_modules/docusaurus-theme-search-typesense/package.json)
client (webpack 5.75.0) compiled with 1 error
dtlhlbs commented 1 year ago

Just noting here that Ejecting SearchPage also gives errors:

Module not found: Error: Can't resolve '../../hooks/useSearchPage' in 'C:\Users\DavidL\source\repos\hilltop-docs\content\src\theme\SearchPage'
Module not found: Error: Can't resolve '../../utils/generalUtils' in 'C:\Users\DavidL\source\repos\hilltop-docs\content\src\theme\SearchPage'