Web Worker compatibility
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
This broke with 1c625d4, which landed in yesterday's version 2.4.5 release.
Crap! Yup, this is totally on me. Will submit an update shortly
@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();
}
This should be fixed for 2.5.x Can you confirm?
Also @Joris-van-der-Wel we'd love to integrate that into our workflow. I tried earlier but I kept getting missing framework errors :(
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
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.
@thebigredgeek any traction on this? We're almost there. Need to close issue on jsdom and currently blocked. /cc @Joris-van-der-Wel
On it right now. Merry Christmas everyone!