-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add support for using Winston in the browser #582
Conversation
I'm thinking that perhaps the best route re: transports is to require a separate "transports" module altogether if running in the browser. This way we can leave the existing transports.js module as is, but use a different loading pattern altogether for browser transports. |
…ent transports module if running in the browser.
I like the idea, but I would prefer to see it fleshed out more. One small nitpick: filenames should always be |
Hi @joshacheson, thanks for your PR! My idea about this was that we should make it compatible with browserify. On that way, we don't need to handle the special cases with |
@pose my concern with The decision to isolate winston core from transports seems like a great one. |
@joshacheson Yes, I agree that making it only compatible with browserify would be a mistake. I'll need to do some research as well on how webpack implements CommonJS. Thanks! |
@indexzero, @pose, @joshacheson Two thoughts:
Any feedback would be greatly appreciated |
Yet one thought:
As before, any feedback would be greatly appreciated |
Going to close this out for now. If you'd like to continue pursuit of this feature please open a new PR. Thanks again for your contribution even though it didn't land. |
brfs is supported in webpack by https://github.com/webpack/transform-loader; perhaps this is worth reopening? |
Looks like the main discussion is in #287 |
I'm opening this pull request now so that people can comment with ideas / criticisms etc.
Some things that could use input:
fs
module in the browser. Immediately it occurs to me to wrap require calls tofs
intry/catch
and make generally to ensure that if winston is being run in the browser,fs
reliant code is avoided altogether.fs
or other node specific modules (perhapshttp
if there is no shim) should probably not be loaded. We should probably establish a pattern that avoids loading node specific modules altogether. Another option is to load these transports but throw errors if they're used in the browser.process.stderr/process.stdout
. We could either load a different transport under the same name when running in the browser or provide a transport by a different (but similar) name such asbrowserConsole
. I lean towards the former.Please leave any comments / suggestions if you're inclined.