Search code examples
javascriptnode.jswinston

How is the module exported in Winston package?


I am trying to read winston code base and I am having a problem understanding how this main module is exported? I have never seen this pattern, can someone explain to me how it works under the hood? isn't it supposed to be const exports = winston and not the other way around?

this is what I'm talking about:

/**
* Setup to expose.
* @type {Object}
*/
const winston = exports;

Solution

  • exports is just an object. winston is a reference to the exports object.

    It's the same as writing exports.version = ... etc.