Skip to content
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

Web Worker compatibility #382

Closed
Joris-van-der-Wel opened this issue Dec 18, 2016 · 9 comments · Fixed by #393
Closed

Web Worker compatibility #382

Joris-van-der-Wel opened this issue Dec 18, 2016 · 9 comments · Fixed by #393

Comments

@Joris-van-der-Wel
Copy link

Over at jsdom, our web worker test fail if we update our dependencies. Here is the error that I got:

ReferenceError: window is not defined at https://github.com/visionmedia/debug/blob/17d0e0bb49b46f53bd97aa6d7b56bf9990a8cb62/browser.js#L13

This line is missing a typeof window !== 'undefined' check. This check is present in other locations in this file, so this issue looks like a small oversight.

After #378 is resolved, you might be interested in https://www.npmjs.com/package/karma-mocha-webworker @yamikuronue

@KlausTrainer
Copy link
Contributor

This broke with 1c625d4, which landed in yesterday's version 2.4.5 release.

@thebigredgeek
Copy link
Contributor

Crap! Yup, this is totally on me. Will submit an update shortly

hawkrives added a commit to hawkrives/gobbldygook that referenced this issue Dec 20, 2016
hawkrives added a commit to hawkrives/gobbldygook that referenced this issue Dec 20, 2016
* upgrade webpack

* upgrade webpack-dev-server

* update extract-text-webpack-plugin

* tell eslint not to ignore webpackrc

* allow webpack to see es modules

* update webpack module.loaders

* continue poking at webpackrc

* remove package:main

* fix import in loadData.worker

* fix modules:false invocation

* fix import of serialize-error in load-data.worker

* fix template string use in load-data.worker

* remove duplicate lodash imports from load-data.worker

* remove "--production" invocation from `npm run build`

* downgrade "debug" dep

see debug-js/debug#382

* change webpack `devtool` choices

* remove comment

* update invocations for {style,css,scss}-loader

* fix invocations for url-loader

* remove this comment as it no longer applies

* remove webpack-dedupe-plugin

* fix options passing to url-loader

* disable chunks for now

* revert devtool choices

* re-enable chunks

* fix tests
@lirongfei123
Copy link

@thebigredgeek I find you have a commit six hours ago, do you fix it?

if (typeof window !== 'undefined') {
  exports.storage = 'undefined' != typeof window.chrome
               && 'undefined' != typeof window.chrome.storage
                  ? window.chrome.storage.local
                  : localstorage();
} 
else {
  exports.storage = localstorage();
}

@thebigredgeek
Copy link
Contributor

This should be fixed for 2.5.x Can you confirm?

@thebigredgeek
Copy link
Contributor

Also @Joris-van-der-Wel we'd love to integrate that into our workflow. I tried earlier but I kept getting missing framework errors :(

@Joris-van-der-Wel
Copy link
Author

Also @Joris-van-der-Wel we'd love to integrate that into our workflow. I tried earlier but I kept getting missing framework errors :(

Odd, it is working properly for the jsdom repo. This is our configuration file for jsdom: karma-webworker.conf.js, however it is a bit extra complicated because it has to deal with browserify. Here is a travis build that uses it.

You can find more example configurations in the test directory of karma-mocha-webworker

@Joris-van-der-Wel
Copy link
Author

This should be fixed for 2.5.x Can you confirm?

Almost ;), the issue still occurs on line 185:

/** Attach to Window*/
if (window) {
  window.debug = exports;
}

This line should be if (typeof window !== 'undefined') {

Alternatively, you could replace all instances of window with self. This works within a worker, but also outside of a worker.


I noticed that a lot of other modules pin debug to specific versions instead of using a version range, I end up with 13 different copies of debug in jsdom. Luckily the only one that ends up in my browserify bundle is pinned at ^2.0.0.

@snuggs
Copy link

snuggs commented Dec 25, 2016

@thebigredgeek any traction on this? We're almost there. Need to close issue on jsdom and currently blocked. /cc @Joris-van-der-Wel

@thebigredgeek
Copy link
Contributor

On it right now. Merry Christmas everyone!

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.

5 participants