-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot importScripts
from Web Worker
#44
Comments
It should be possible.... are you able to try again with an unminified version? I guess the |
I'm afraid I'm not very proficient in JS (hence my interest in running Lua in the browser ;) ). I couldn't find a non minified release, and My test is a barebones HTML document with the following script:
And
At page load, the error mentioned above is thrown:
(Google Chrome Version 80.0.3987.163 (Official Build) (64-bit) on Windows 10, if that's relevant) |
Ha! I've no idea what I'm doing, but in webpack.config.js I changed the first |
Ok, this new way to build works (at least for my use: https://snake-eyes.io/), so the issue can be closed as far as I'm concerned. You can be the judge of whether there's a bug to fix, or a new target to add to the build system, etc. |
I have the same issue. Same line numbers in the backtrace, etc., except I'm not using webpack or anything - just a raw download of fengari-web.js that I'm loading with importScripts(). The line that's failing is the following:
It chokes on the "window". I don't see how it could ever work in a WebWorker, because there's no conditional there - the symbol will always be evaluated. Also, none of this appears in the original code - it appears to be coming from whatever minifier you're using. |
hmm, indeed the pre-compiled script contains the same thing. I guess we need to change some minifier setting |
I did the same thing as Castux: changed the webpack config target from "web" to "webworker", and that fixed it for me too. Looking at the compiled output, the only diff, across the entire bundle, is literally changing the single "window" that it's choking on to "self". I'm attaching the result for anyone else who has the same issue. However, judging from the result, I'd say it should be safe to change the main config to "webworker" for everyone. ("self" works portably in both contexts, because that's what it was designed for.) |
Is it possible to run Fengari from a Web Worker? Naively trying
importScripts("fengari-web.js");
gives the following error:Since the library is minified, it's hard to know what's going on, although the source for fengari-web.js seems to have a section that detects if there is a document, which suggests it might work without one?
The text was updated successfully, but these errors were encountered: