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

fix(deps): fix cheerio version to rc.12 #218

Open slorber opened 1 month ago

slorber commented 1 month ago

Cheerio just released v1.0.0 after 7 years of RC

https://cheerio.js.org/blog/cheerio-1.0

The only problem is that RC users used semver ranges (^) and the 1.0 is not retro-compatible with the latest RC.12, published 2 years ago

Notably:

Docusaurus users installing this plugin will now get Cheerio v1.0, and the following error:

[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

A temporary solution: fix the Cheerio version to rc.12 in this lib so that users never use Cheerio v1.0, until you fix the problems, or Cheerio adds back retrocompatibility.

-  "cheerio": "^1.0.0-rc.9",
+  "cheerio": "1.0.0-rc.12",

Until this PR gets merged/released, users will have to force resolution to rc.12 on their side using their package managers features.

For example, Yarn users can do:

  "resolutions": {
    "cheerio": "1.0.0-rc.12"
  },
Alevale commented 1 month ago

I think you need to amend your commit and push again based on this rules 😉 https://github.com/cmfcmf/docusaurus-search-local/blob/main/CONTRIBUTING.md#commit-message-guidelines probably adding fix(deps): at the start should do

garronej commented 1 month ago

Well summed up @slorber

rbcm1 commented 4 weeks ago

Pinning the version to the RC is a viable workaround. Nevertheless, the real fix in order to use v1.0.0 of cheerio is also fairly easy (see: https://github.com/cmfcmf/docusaurus-search-local/issues/219).

Instead of using cheerio.default.load(...), this just needs to be changed to cheerio.load(...) (so just removing the usage of "default"). According to my tests, everything works fine with this change (which BTW is also used in other parts of the docusaurus-search-local plugin).

slorber commented 4 weeks ago

Yes, that would also work but you'd have to also change deps to ensure all RC users upgrade to v1.0 stable

v1.0 stable only works for Node 18.17+ and Docusaurus v3 has support for 18.0. If you upgrade Cheerio to v1.0 stable, you also ask your users to potentially upgrade Node, which is a breaking change.

My suggestion is to release this PR as a minor/patch, and then upgrade Cheerio in the next major, mentioning it requires upgrading Node.