Skip to content

No longer works in web worker since version 1.0.3 #1126

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

Closed
icidasset opened this issue May 21, 2018 · 5 comments · Fixed by #1127
Closed

No longer works in web worker since version 1.0.3 #1126

icidasset opened this issue May 21, 2018 · 5 comments · Fixed by #1127

Comments

@icidasset
Copy link

Hey folks 👋

I was using version 1.0.2 in my project and decided to upgrade to 1.0.3.
But now I'm getting the following error:

Uncaught ReferenceError: window is not defined

The issue only pops up in web workers.

I'm using remoteStorage through browserify and I'm requiring it as follows:

self.RemoteStorage = require("remotestoragejs/release/remotestorage");

Any thoughts?
Thanks!

@raucao
Copy link
Member

raucao commented May 22, 2018

Thanks for the report. Can you confirm that 1.0.2 does not have the same issue in a worker?

@icidasset
Copy link
Author

@skddc Yeah, works fine with 1.0.2.

@galfert
Copy link
Member

galfert commented May 22, 2018

I think the issue might be in the build generated by Webpack.

In version 1.0.3 the build contains this:

[...] exports.RemoteStorage=t():e.RemoteStorage=t()}(window,function(){ [...]

while in version 1.0.2 it looked like this:

[...] exports.RemoteStorage=t():e.RemoteStorage=t()}(this,function(){ [...]

using this instead of window.

@raucao
Copy link
Member

raucao commented May 22, 2018

Ah, we did update Webpack to a new major at some point. Thanks for the confirmation.

galfert added a commit that referenced this issue May 23, 2018
Fixes #1126

This fixes a reference error when using the build in a WebWorker.

This is a workaround taken from webpack/webpack#6642 (comment)
and should be replaced by `target: "universal" when webpack/webpack#6525
has been implemented.
@galfert
Copy link
Member

galfert commented May 23, 2018

I created a PR at #1127 that should fix this issue.

raucao pushed a commit that referenced this issue Oct 31, 2018
Fixes #1126

This fixes a reference error when using the build in a WebWorker.

This is a workaround taken from webpack/webpack#6642 (comment)
and should be replaced by `target: "universal" when webpack/webpack#6525
has been implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants