Closed dancerphil closed 5 years ago
Hi there, welcome!
If you are in a web worker, you can’t use document
, indeed.
We support browsers and non-browsers.
Your bundler (such as Webpack / Rollup / Browserify) picks up on this (by default it’ll pick the browser version).
If you are planning to bundle something for a web worker, you should tell your bundler to not pickup the browser version.
How to do that, depends on your bundler, for webpack, it’s described here I think.
I'm using
web worker
to highlight code, but in some case, refractor tried to use document and failed since we do not havedocument
inweb worker
.It is quite difficult to reproduce this bug because it only happens to a huge file and I don't know which line cause this problem.
I think the error may help:
It will be grateful if you know why and how to fix it.
If not, I could help find some reproduce.