-
Notifications
You must be signed in to change notification settings - Fork 517
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
Use process.browser instead of checking for window #311
Conversation
Just tested and this works for my use case. I'm a little confused by it, like why browserify comes into it at all... like does this cover all use cases? E.g. with webpack, just plain browser, etc. |
As far as I can tell, bunyan currently doesn't bundle with webpack or work in the browser straight up anyways. The README only mentions browserify compatibility. |
Yeah, I'm not sure what it supports myself. @trentm? |
+1 for this change. that would make bunyan usable in electron for instance |
@jeremyruppel @adam-lynch @jaxer @fleg Sorry for the delays, all. (#335 for some details on project maint.) I'm looking at the current Bunyan browser-related issues. This one (#311) suggests I'm guessing that attempting to
I suppose the same could be true of some other JS code in a bundle setting
If I put a potential change in a branch, would any of you be able to test: nw, electron, browserify, others? Question 2: The
Will that work with NW? IOW, does nw.js define As to my intentions for bunyan: I'm happy to have it work with NW, browserify and other environments. I just don't use those envs so I'm ignorant about what works there. Any testing or ... ownership of that functionality in node-bunyan by others (any of you interested?) would be a great help. Question 4: Do any of you have suggestions for ways to do automated testing of Bunyan working in any of these environments? |
It's used very commonly for this kind of thing as far as I know.
Yes, NW.js.
Not sure what IOW stands for but
Hmm, tricky. I guess you could run an NW.js that uses bunyan, kill it after a timeout and check if the log file exists? |
@adam-lynch Thanks for the comments, that helped clarify for me. I would appreciate a sanity check from you or other NW.js users with cd7dc6a#diff-07b7b7054e46821313709b956b86ec21 (the latest commit in #master). Let me know if you need a published npm release to test it. If others are able to test in a browser env (browserify or webpack or other), that would be helpful. This will be in [email protected], assuming it works. Thanks and sorry for the extreme delays. |
Tested on [email protected], it's working like a charm.
Maybe run all tests under nw. |
@fleg Thanks! |
published version 1.7.0 |
The browserify version of process sets
process.browser = true
that we can use instead of checking for the existence ofwindow
. This plays nice with transforms like bpb that replaceprocess.browser
with a constant which enables unreachable code branches to be removed during bundling. I don't have first-hand experience with nw.js but the project says it has complete support for all Node.js APIs so this should also fix #301 /cc @amoussard @fleg @adam-lynch.