wmr icon indicating copy to clipboard operation
wmr copied to clipboard

Prerendering throws errors when prerendering a worker

Open marvinhagemeister opened this issue 4 years ago • 1 comments

Describe the bug Due to environmental API differences between Web Workers and Node's Worker Threads there are a bunch of undefined global variables that the Web Worker API expects. Things like global Worker in non-worker scripts/modules, global self/addEventListener inside instantiated workers etc.

To Reproduce Prerender a worker.

Expected behavior No error.

Bug occurs with:

  • [ ] wmr or wmr start (development)
  • [x] wmr build (production) + --prerender
  • [ ] wmr serve

marvinhagemeister avatar Sep 06 '21 06:09 marvinhagemeister

We could probably inject self.Worker as a global and point it at web-worker, like we do for location: https://github.com/preactjs/wmr/blob/2c8521c9e4f525bc428a338bd6dfb80627826085/packages/wmr/src/lib/prerender.js#L61

developit avatar Sep 06 '21 15:09 developit