ES2015 import fails with Rollup, no docs
See original GitHub issueI’m using Winston in an ES2015 project. I import Winston with import log from 'winston'
and log with log.info()
, log.debug()
, etc. When I transpile and run with Babel it works just fine.
However if I use Rollup to resolve all the relative import paths and then the babel
Rollup plugin to transpile (with the es2015-rollup
plugin for Babel), the import of Winston fails. In particular, it imports the following object:
{ transports:
{ console:
EventEmitter {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
silent: false,
raw: false,
name: 'console',
formatter: undefined,
level: undefined,
handleExceptions: false,
exceptionsLevel: 'error',
humanReadableUnhandledException: false,
json: false,
colorize: false,
prettyPrint: false,
timestamp: false,
showLevel: true,
label: null,
logstash: false,
depth: null,
align: false,
stderrLevels: [Object],
eol: '\n',
_onError: [Function: bound ] } },
exceptionHandlers: {} }
This can be fixed by using import * as log from 'winston'
, but this is not at all obvious. I’m not sure what Rollup is doing in detail, but it looks like a great piece of ES2015 tooling, so Winston should work with it cleanly.
I would recommend adding a section to the Winston README on how to use it with ES2015, and perhaps add a caveat with respect to Rollup. Currently there is no guidance, and nothing on Google either.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:11 (1 by maintainers)
Top GitHub Comments
Definitely still broken in 3.1.0.
If you use Node’s builtin ‘stream’ module instead of ‘readable-stream’ from NPM, you resolve the undefined / circular dependency thing, and if you get rid of the dynamic import crap in logform, then it works for me.
To put that in the hackiest possible terms…
This issue has been solved in 3.0.0