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

`Docusaurus Build` fails when using 1.0.0 with Typescript #175

Closed matthew-west-unity closed 1 year ago

matthew-west-unity commented 1 year ago

Please describe the bug you are seeing

I've started a new Docusaurus project and when I run docusaurus build with version 1.0.0 of the docusaurus-search-local plugin it fails with the following error:

TypeError: (0 , d_s_l_a_generated_namespaceObject.mylunr) is not a function

And the stack trace:

[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
    at C:\MY_PATH\node_modules\@docusaurus\core\lib\webpack\utils.js:180:24
    at C:\MY_PATH\node_modules\webpack\lib\MultiCompiler.js:554:14
    at processQueueWorker (C:\MY_PATH\node_modules\webpack\lib\MultiCompiler.js:491:6)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

If I use 0.11.0 of this package the build completes successfully.

How can we best reproduce the bug?

No response

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

+-- @cmfcmf/docusaurus-search-local@1.0.0
| `-- @docusaurus/core@2.0.1 deduped
+-- @docusaurus/core@2.0.1
`-- @docusaurus/preset-classic@2.0.1
  +-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-content-blog@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-content-docs@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-content-pages@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-debug@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-google-analytics@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-google-gtag@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/plugin-sitemap@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  +-- @docusaurus/theme-classic@2.0.1
  | `-- @docusaurus/core@2.0.1 deduped
  `-- @docusaurus/theme-search-algolia@2.0.1
    `-- @docusaurus/core@2.0.1 deduped

Which Node.js version are you using?

v16.16.0

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

plugins: [require.resolve("@cmfcmf/docusaurus-search-local")]

Additional context

No response

Porkalanchiyam commented 1 year ago

I'm also facing the same issue .

Beluk commented 1 year ago

Have the same issue.

AamiRobin commented 1 year ago

same issue here.

cmfcmf commented 1 year ago

Thank you all for letting me know; I will take a look as soon as possible.

mariuszkrzaczkowski commented 1 year ago

Have the same issue.

TypeError: (0 , d_s_l_a_generated_namespaceObject.mylunr) is not a function
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"1:1172-1178","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"1:2112-2129","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"21:553-561","message":"export 'tokenize' (imported as 'tokenize') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"21:832-862","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"21:988-1018","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"21:1132-1162","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"21:1374-1404","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"client"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"1:859-865","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"5:58-75","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"26:236-244","message":"export 'tokenize' (imported as 'tokenize') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"26:431-461","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"26:587-617","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"26:731-761","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[WARNING] {"moduleIdentifier":"d:\\www\\YetiForceDoc\\node_modules\\babel-loader\\lib\\index.js??ruleSet[1].rules[6].use[0]!d:\\www\\YetiForceDoc\\node_modules\\@cmfcmf\\docusaurus-search-local\\lib\\client\\theme\\SearchBar\\index.js","moduleName":"./node_modules/@cmfcmf/docusaurus-search-local/lib/client/theme/SearchBar/index.js","loc":"26:973-1003","message":"export 'mylunr' (imported as 'mylunr') was not found in './d-s-l-a-generated' (module has no exports)","compilerPath":"server"}
[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
    at d:\www\YetiForceDoc\node_modules\@docusaurus\core\lib\webpack\utils.js:180:24
    at d:\www\YetiForceDoc\node_modules\webpack\lib\MultiCompiler.js:554:14
    at processQueueWorker (d:\www\YetiForceDoc\node_modules\webpack\lib\MultiCompiler.js:491:6)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
[INFO] Docusaurus version: 2.4.0
Node version: v16.17.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
cmfcmf commented 1 year ago

Thank you all for reporting this and apologies for the delay! 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.