daldridge / docusaurus-plugin-lunr

Docusaurus v2 plugin to create a local search index for use with Lunr.js
MIT License
50 stars 5 forks source link

Build error search-index.json cannot be found #11

Open smazanek opened 4 years ago

smazanek commented 4 years ago

Hi, I was a happy user of your plugin in the past already. However, for some time, when I want to build my docusaurus (latest docusaurus v2) website with your plugin I receive the following error message:

./node_modules/@aldridged/docusaurus-plugin-lunr/build/main/theme/SearchBar/index.js Module not found: Can't resolve '@generated/docusaurus-plugin-lunr/search-index.json' in '/home/ec2-user/environment/website/node_modules/@aldridged/docusaurus-plugin-lunr/build/main/theme/SearchBar' Client bundle compiled with errors therefore further build is impossible. ./node_modules/@aldridged/docusaurus-plugin-lunr/build/main/theme/SearchBar/index.js Module not found: Error: Can't resolve '@generated/docusaurus-plugin-lunr/search-index.json' in '/home/ec2-user/environment/website/node_modules/@aldridged/docusaurus-plugin-lunr/build/main/theme/SearchBar' @ ./node_modules/@aldridged/docusaurus-plugin-lunr/build/main/theme/SearchBar/index.js 4:1981-2080 @ ./node_modules/@docusaurus/theme-classic/lib/theme/Navbar/index.js @ ./node_modules/@docusaurus/theme-classic/lib/theme/Layout/index.js @ ./src/theme/NotFound/index.js @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js @ ./.docusaurus/routes.js @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js @ multi ./node_modules/@docusaurus/core/lib/client/clientEntry.js error Command failed with exit code 1.

The search index seems to be created properly: ~/environment/website (master) $ find . -name "search-index.json" ./.docusaurus/docusaurus-plugin-lunr/default/search-index.json

Do you have any ideas what could be the problem? Anybody else with the same problem?

Kind regards and thanks Steffen

pcdv commented 4 years ago

Same here. I rolled back docusaurus from 2.0.0-alpha.66 to 2.0.0-alpha.65 and it seems to fix the problem.

EDIT: I'm not so sure any more... After reverting to alpha.66 it still works now. I've tried so many things that I probably fixed the problem by accident :/

EDIT2: Managed to reproduce in a fresh website (as generated by docusaurus init with classic theme):

Looks like reverting to .50 or .59 triggers a change in generated files (but those are not tracked by git because of .gitignore so I have no idea of what change is required).

Digging further:

This is the difference between KO and OK:

diff -rc .docusaurus .docusaurus.ko
Only in .docusaurus/docusaurus-plugin-content-blog: blog-c06.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-post-list-prop-default.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-tags-docusaurus-0e0.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-tags-facebook-038.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-tags-hello-039.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-tags-hola-ea2.json
Only in .docusaurus/docusaurus-plugin-content-blog: blog-tags-tags-4c2.json
Only in .docusaurus/docusaurus-plugin-content-blog: site-blog-2019-05-28-hola-md-aed.json
Only in .docusaurus/docusaurus-plugin-content-blog: site-blog-2019-05-29-hello-world-md-843.json
Only in .docusaurus/docusaurus-plugin-content-blog: site-blog-2019-05-30-welcome-md-a9a.json
Only in .docusaurus/docusaurus-plugin-content-docs: site-docs-doc-1-md-736.json
Only in .docusaurus/docusaurus-plugin-content-docs: site-docs-doc-2-md-991.json
Only in .docusaurus/docusaurus-plugin-content-docs: site-docs-doc-3-md-225.json
Only in .docusaurus/docusaurus-plugin-content-docs: site-docs-mdx-md-45a.json
Only in .docusaurus/docusaurus-plugin-content-docs: version-current-metadata-prop-751.json
Only in .docusaurus/docusaurus-plugin-lunr: search-index.json

Hope this helps.

daldridge commented 3 years ago

Sorry I haven't been able to take a look at this yet (super swamped at work). The import of the index uses a webpack alias (@generated/...). If the Docusuarus core webpack configuration no longer defines that alias, the import would fail. (It's something this plugin relies on, but does not configure itself).