setImmediate is not defined in browsers
jhillacre opened this issue · 2 comments
Seems like Winston uses setImmediate which isn't available in browser environments.
Uncaught ReferenceError: setImmediate is not defined
at Console.log (webpack-internal:///./node_modules/winston/dist/winston/transports/console.js:88)
at Console._write (webpack-internal:///./node_modules/winston-transport/dist/index.js:90)
at doWrite (webpack-internal:///./node_modules/readable-stream/lib/_stream_writable.js:428)
at writeOrBuffer (webpack-internal:///./node_modules/readable-stream/lib/_stream_writable.js:417)
at Console.Writable.write (webpack-internal:///./node_modules/readable-stream/lib/_stream_writable.js:334)
at DerivedLogger.ondata (webpack-internal:///./node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:681)
at DerivedLogger.emit (webpack-internal:///./node_modules/events/events.js:153)
at addChunk (webpack-internal:///./node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:298)
at readableAddChunk (webpack-internal:///./node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:280)
at DerivedLogger.Readable.push (webpack-internal:///./node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:241)
I was able to work around the issue using a polyfill, as mentioned in this issue: winstonjs/winston#1354 (comment). Not sure that there is anything to do about this in dcrf-client, other than adding this workaround to documentation.
Ugh, that's super annoying. Well, https://github.com/YuzuJS/setImmediate is only ~6kb; I don't see much harm in including it in the distribution.
How do you feel about changing dcrf-client to use console.log by default, with configuration options to use winston? Node specific dependencies in an otherwise pure JS module are making my life miserable trying to convert a vue app served by vue-cli to a vue app served by vite.
Things like:
index.js:43 Uncaught ReferenceError: global is not defined
at node_modules/buffer/index.js (index.js:43)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js (_stream_readable.js:46)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston/node_modules/readable-stream/readable-browser.js (readable-browser.js:1)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston/dist/winston/logger.js (logger.js:33)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston/dist/winston/create-logger.js (create-logger.js:32)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
util.js:103 Uncaught ReferenceError: Buffer is not defined
at node_modules/core-util-is/lib/util.js (util.js:103)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/readable-stream/lib/_stream_writable.js (_stream_writable.js:67)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/readable-stream/writable-browser.js (writable-browser.js:1)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston-transport/dist/index.js (index.js:4)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/winston-transport/legacy.js (legacy.js:5)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
supports-colors.js:31 Uncaught ReferenceError: process is not defined
at node_modules/logform/node_modules/colors/lib/system/supports-colors.js (supports-colors.js:31)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/logform/node_modules/colors/lib/colors.js (colors.js:41)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/logform/node_modules/colors/safe.js (safe.js:9)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/logform/dist/colorize.js (colorize.js:9)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)
at node_modules/logform/dist/levels.js (levels.js:3)
at __require2 (chunk-IHTDASF6.js?v=9f8d8f17:17)