flexsearch
flexsearch copied to clipboard
The Worker dose not work
Hi!
Thanks for the lib, but for some reason, the Worker
index does not work for me.
What I do:
- I create a new project:
npx create-react-app test-search --template typescript
; - Add the dependency:
npm install flexsearch
andnpm i --save-dev @types/flexsearch
; - I clean the
src/index.tsx
and left there only following code:
import { Worker } from "flexsearch"
const searchIndex = new Worker()
searchIndex.add(1, "some text")
An I see the following error in the browser console:
Uncaught TypeError: Cannot read properties of undefined (reading 'postMessage')
at flexsearch.bundle.js:22:1
(anonymous) @ flexsearch.bundle.js:22
setTimeout (async)
(anonymous) @ flexsearch.bundle.js:22
P.O.<computed>.O.<computed> @ flexsearch.bundle.js:22
./src/index.tsx @ index.tsx:22
options.factory @ react refresh:6
__webpack_require__ @ bootstrap:24
(anonymous) @ startup:7
(anonymous) @ startup:7
Is it an issue or it is my doing something wrong?
the same to me . mark
In Node.js:
const { Worker } = require("flexsearch");
(async function(){
const worker = new Worker();
await worker.add(1, "some text");
console.log(await worker.search("some text"));
}());
As ES6-Module:
import Worker from "./worker/index.js";
(async function(){
const worker = new Worker();
await worker.add(1, "some text");
console.log(await worker.search("some text"));
}());