You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to integrate elasticlunr library into my web component library. I'm using stencil and TypeScript for building web components. I'm trying to create index like this:
import elasticlunr from "elasticlunr";
// Create a sample search index for thread view rendering.
export const createThreadSearchIndex = (docs: any[]) => {
const index = elasticlunr();
// Set fields to index. we can even set
index.addField("content" as never);
// Set the field used to identify documents.
index.setRef("id" as never);
// include content data with the index data.
index.saveDocument(true);
// Add the docs to the index
docs.forEach((doc) => index.addDoc(doc));
return index;
};
But this approach doesn't seem to work as my unit tests are failing with the following error message:
TypeError: (0 , elasticlunr_1.default) is not a function
Now I can fix this by changing the import statement and bringing in elasticlunr using require. However, the issue is that now my components won't render in browser because it doesn't support require. My tsconfig file looks like this:
I'm trying to integrate elasticlunr library into my web component library. I'm using stencil and TypeScript for building web components. I'm trying to create index like this:
But this approach doesn't seem to work as my unit tests are failing with the following error message:
TypeError: (0 , elasticlunr_1.default) is not a function
Now I can fix this by changing the import statement and bringing in elasticlunr using
require
. However, the issue is that now my components won't render in browser because it doesn't support require. My tsconfig file looks like this:Can anyone please help me out here? There is no guidance anywhere as to how to solve it.
The text was updated successfully, but these errors were encountered: