Closed grumd closed 2 years ago
It shows an error:
Uncaught SyntaxError: Cannot use import statement outside a module
https://vitejs.dev/guide/features.html#import-with-constructors
It looks like we need to specify module type:
const createWorker = () => new Worker(new URL("./fib.worker.js", import.meta.url), {
type: 'module'
});
This fixes it, but in DEV, it doesn't seem to work correctly.
If you vite build
, it works well.
I think it's vite issue.
Hi, Daishi! Big fan.
Tried using react-hooks-worker in Vite, and both the
result
anderror
are simplyundefined
. Maybe I'm doing something wrong, or it's just not compatible?Sandbox: https://codesandbox.io/s/react-vite-forked-w7ftgt?file=/src/App.jsx