cmfcmf / docusaurus-search-local

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

Webpack error when serving development build #179

Closed vixducis closed 1 year ago

vixducis commented 1 year ago

Please describe the bug you are seeing

error

When running the dev server, I get the above error. I was able to trace this down to @cmfcmf\docusaurus-search-local\lib\client\theme\SearchBar\index.js, where on several occasions mylunr is accessed.

It is imported on the following line:

import { mylunr, tokenize } from "./d-s-l-a-generated";

./d-s-l-a-generated just contains export {}; however, which explains the failing imports. The weird thing is that this is only happening with the node windows executable (v18.15.0), when I use node inside my WSL (v16.17.1), there doesn't seem to be an issue.

How can we best reproduce the bug?

No response

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

"@docusaurus/core": "2.4.0" "@cmfcmf/docusaurus-search-local": "1.0.0"

Which Node.js version are you using?

v18.15.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"),
        {
          indexBlog: false,
        },
]

Additional context

No response

aamir1995 commented 1 year ago

You can downgrade to 0.11.0 until the issue is fixed.

cmfcmf commented 1 year ago

The weird thing is that this is only happening with the node windows executable (v18.15.0), when I use node inside my WSL (v16.17.1), there doesn't seem to be an issue.

Thanks a lot for providing this additional insight! It turns out that the issue was Windows-specific - the d-s-l-a-generated.js file should have been generated with Webpack here: https://github.com/cmfcmf/docusaurus-search-local/blob/e0baecf85cf4a0ec838e5e5a673d3f5f2fc3b34d/packages/docusaurus-search-local/src/server/index.ts#L598

However, I didn't realize that Webpack's rules.test option doesn't normalize backslashes and slashes, and so the file wasn't created on Windows.

I fixed this in https://github.com/cmfcmf/docusaurus-search-local/pull/180 and will release a new version with this fix shortly.

vixducis commented 1 year ago

Truly awesome, man!