cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
438 stars 67 forks source link

v3.5.0 docusaurus upgrade failure #217

Closed fartbagxp closed 1 month ago

fartbagxp commented 1 month ago

Please describe the bug you are seeing

As of v3.5.0 docusaurus release, there's some internal refactoring going so having this search plugin breaks on compiling on every file, it probably has to do with useContextualSearchFilters.

        Error: Can't render static file for pathname "/docs/example-doc"
            at generateStaticFile (/home/fartbagxp/test-doc/node_modules/@docusaurus/core/lib/ssg.js:119:15)
            at runNextTicks (node:internal/process/task_queues:60:5)
            at process.processImmediate (node:internal/timers:454:9)
            at async /home/fartbagxp/test-doc/node_modules/p-map/index.js:57:22 {
          [cause]: TypeError: (0 , lib_namespaceObject.useContextualSearchFilters) is not a function
              at SearchBar (server.bundle.js:66187:833)
              at Uc (server.bundle.js:73557:44)
              at Xc (server.bundle.js:73559:253)
              at Z (server.bundle.js:73565:89)
              at Yc (server.bundle.js:73568:98)
              at Xc (server.bundle.js:73560:145)
              at Z (server.bundle.js:73565:89)
              at Xc (server.bundle.js:73559:481)
              at Z (server.bundle.js:73565:89)
              at Yc (server.bundle.js:73568:98)
        }

How can we best reproduce the bug?

Build project with Docusaurus v3.5.0, use either v1.1.0 or v1.2.0 of the plugin and run docusaurus build.

Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?

v1.1.0 and v1.2.0 both fail.

Which Node.js version are you using?

v20.16.0

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

  require.resolve('@cmfcmf/docusaurus-search-local'),
      {
        indexDocs: true,
        indexDocSidebarParentCategories: 0,
        indexBlog: true,
        indexPages: false,
        language: 'en',
        style: undefined,
        maxSearchResults: 8,
        lunr: {
          tokenizerSeparator: /[\s\-]+/,
          b: 0.75,
          k1: 1.2,
          titleBoost: 5,
          contentBoost: 1,
          tagsBoost: 3,
          parentCategoriesBoost: 2, // Only used when indexDocSidebarParentCategories > 0
        },
      },
    ],

Additional context

No response

slorber commented 1 month ago

Sorry about this, it's my fault while refactoring code in https://github.com/facebook/docusaurus/pull/10316

Although this API is not documented, it's not exported as /internal and so this change can be considered as a breaking change.

I will look into adding back retrocompatibility soon, so that this plugin works again.

slorber commented 1 month ago

Docusaurus v3.5.2 has been released, fixing this retro-compatibility problem.


Note, it's possible that you get another error while building your site.

[ERROR] Error: Unable to build website for locale en.
  ...
  [cause]: TypeError: Cannot read properties of undefined (reading 'load')
      at getDocusaurusTag (.../@cmfcmf/docusaurus-search-local/lib/server/parse.js:194:33)
      at .../@cmfcmf/docusaurus-search-local/lib/server/index.js:288:60

It is a different issue, related to a recent release of Cheerio v1.0 that did unexpected breaking changes. See my PR for details and workarounds: https://github.com/cmfcmf/docusaurus-search-local/pull/218

fartbagxp commented 1 month ago

Thanks @slorber!