From 7539a4215f5ee11994b4fcb20fe1d52af101318e Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Fri, 24 Feb 2023 08:46:09 +0530 Subject: [PATCH 1/3] tried to solve eror --- packages/docusaurus-search-local/src/server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-search-local/src/server/index.ts b/packages/docusaurus-search-local/src/server/index.ts index 3703dbe..c053083 100644 --- a/packages/docusaurus-search-local/src/server/index.ts +++ b/packages/docusaurus-search-local/src/server/index.ts @@ -185,7 +185,7 @@ export default function cmfcmfDocusaurusSearchLocal( generated += 'import "./index.css";\n'; } - generated += 'const lunr = require("../../../lunr.js");\n'; + generated += 'import * as lunr from "../../../lunr.js";\n'; function handleLangCode(code: string) { let generated = ""; From b08e93a15d90071f87bd4f370f1f28661aea236c Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Fri, 24 Feb 2023 08:57:26 +0530 Subject: [PATCH 2/3] Missing initializer in const declaration --- packages/docusaurus-search-local/src/server/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/docusaurus-search-local/src/server/index.ts b/packages/docusaurus-search-local/src/server/index.ts index c053083..d05bc46 100644 --- a/packages/docusaurus-search-local/src/server/index.ts +++ b/packages/docusaurus-search-local/src/server/index.ts @@ -179,14 +179,13 @@ export default function cmfcmfDocusaurusSearchLocal( let generated = "// THIS FILE IS AUTOGENERATED\n" + "// DO NOT EDIT THIS FILE!\n\n"; + generated += 'import * as lunr from "../../../lunr";\n'; if (style !== "none") { generated += 'import "@algolia/autocomplete-theme-classic";\n'; generated += 'import "./index.css";\n'; } - generated += 'import * as lunr from "../../../lunr.js";\n'; - function handleLangCode(code: string) { let generated = ""; From f01555042ade197dbe3aaed66add5156f037aca4 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Fri, 24 Feb 2023 15:43:26 +0530 Subject: [PATCH 3/3] fixed again --- packages/docusaurus-search-local/src/server/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-search-local/src/server/index.ts b/packages/docusaurus-search-local/src/server/index.ts index 3703dbe..8e68124 100644 --- a/packages/docusaurus-search-local/src/server/index.ts +++ b/packages/docusaurus-search-local/src/server/index.ts @@ -179,14 +179,13 @@ export default function cmfcmfDocusaurusSearchLocal( let generated = "// THIS FILE IS AUTOGENERATED\n" + "// DO NOT EDIT THIS FILE!\n\n"; + generated += 'import * as lunr from "../../../lunr.js";\n'; if (style !== "none") { generated += 'import "@algolia/autocomplete-theme-classic";\n'; generated += 'import "./index.css";\n'; } - generated += 'const lunr = require("../../../lunr.js");\n'; - function handleLangCode(code: string) { let generated = ""; @@ -254,6 +253,9 @@ lunr.tokenizer.separator = ${lunrTokenizerSeparator.toString()};\n`; export const tokenize = (input) => lunr.tokenizer(input) .map(token => token.str);\n`; } + if (!lunr) { + generated += `import * as lunr from '../../../lunr.js';\n`; + } generated += `export const mylunr = lunr;\n`; ["src", "lib"].forEach((folder) => {