react-use-comlink icon indicating copy to clipboard operation
react-use-comlink copied to clipboard

Unexpected token '<'

Open RockinRonE opened this issue 5 years ago • 2 comments
trafficstars

I created a simple object similar to the example:

import { expose } from 'comlink'

export const SortWorker = {
  hello: 'world',
  sort() {
    return 'sort worker ran!'
  },
}

expose(SortWorker)

But I see this in the console: Uncaught SyntaxError: Unexpected token '<'

I am using create-react-app with hooks.

RockinRonE avatar Jul 03 '20 22:07 RockinRonE

your route seems to be returning HTML instead of JS, check the body of the request

pocesar avatar Jul 04 '20 19:07 pocesar

CRA uses Webpack 4 which does not natively support importing Workers. You need to add the worker-loader. Once CRA updates to use Webpack 5, you may be able to remove this loader.

dlindahl avatar Nov 19 '21 21:11 dlindahl