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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMR runtime references global by wrong name in Worker #528
Comments
related to #476 |
Oops, I think I forgot to search for PRs. This is indeed the same issue, sorry for the duplicate. |
The name of the global object may differ based on the context in which the script is running. For example, web workers use "self" instead of "window". As location is a property of the global, it can be referenced directly as a global variable, which avoids having to deal with this naming inconsistency. Fixes #528
The name of the global object may differ based on the context in which the script is running. For example, web workers use "self" instead of "window". As location is a property of the global, it can be referenced directly as a global variable, which avoids having to deal with this naming inconsistency. Fixes #528
The name of the global object may differ based on the context in which the script is running. For example, web workers use "self" instead of "window". As location is a property of the global, it can be referenced directly as a global variable, which avoids having to deal with this naming inconsistency. Fixes #528
Hello, I'm currently getting an HMR error in my WebWorkers that seems to be related to a use of the |
馃悰 bug report
I've created a very simple project with a web worker. It looks like the script reference in the Worker constructor call is picked up automatically by Parcel and compiled into a separate bundle, which is great. However, the generated bundle by default includes the hot module reloading runtime, which contains code referencing
window.location
. In a Worker scope, the global is calledself
, and the bundle code throws a ReferenceError before the actual worker script can run.馃帥 Configuration / code sample
Create the following files and run
parcel serve index.html
index.js
worker.js
index.html
馃 Expected Behavior
Expected code to load and work correctly.
馃槸 Current Behavior
Uncaught ReferenceError: window is not defined
The code in worker.js does not run and no "test" messages are logged to the console.
馃拋 Possible Solution
The error is thrown in what looks to be the following code, included in the Worker bundle:
parcel/src/builtins/hmr-runtime.js
Line 18 in 06d5ffc
The HRM runtime should either detect it is running in a Worker scope and use the self global, or be disabled for Worker bundles if there are other issues that prevent it from working in that context.
馃實 Your Environment
The text was updated successfully, but these errors were encountered: