Open saran1856 opened 2 years ago
Here's my implementation. I hope you find it helpful.
import elasticlunr from "elasticlunr";
export const index = elasticlunr<Record<string, string | number>>(function () {
this.addField("name");
this.setRef("id");
});
You can also extend the index further and use across various files
import {index} from 'filepath';
index.addField('fieldName');
index.search('textToSearch');
...
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.