Skip to content
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

Winston does not rollup well #1607

Closed
1 of 2 tasks
westonpace opened this issue Feb 26, 2019 · 3 comments
Closed
1 of 2 tasks

Winston does not rollup well #1607

westonpace opened this issue Feb 26, 2019 · 3 comments

Comments

@westonpace
Copy link
Contributor

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3.2.1
  • node -v outputs:
v10.15.1
  • Operating System? (Windows, macOS, or Linux)
    Not relevant but Linux
  • Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart)
    Plain JS

What is the problem?

I have created a minimal test repository here: https://github.com/westonpace/winston-rollup-test

First, readable-stream does not work with rollup (nodejs/readable-stream#348). There is, at the time of writing this, no one that is working on this problem. One workaround is to use builtin streams instead of readable-stream when rolling up. The test repository has a demonstration of this using rollup-plugin-replace.

Second, logform does not rollup. I'll be opening a second issue on that repository.

Finally, even if the above two were addressed, the final rolled up artifact is quite large. The test repository includes rollup-plugin-size-snapshot to give a sense of things. A minimal hello world using only the console transport comes in at 263KB.

Even though only the Console transport is being used both the File and Http transports are included in the bundle which indicates rollup is having trouble statically analyzing the file. It may be that there is a better way to import/require things in my test. This is the same sort of trouble that motivated moment to convert to luxon (although moment is more of a pure-browser library so size is more important).

git clone https://github.com/westonpace/winston-rollup-test
cd winston-rollup-test
npm install
npm run build
node bundle.cjs.js

What do you expect to happen instead?

I would expect a small working bundle to be generated with no warnings.

Other information

To be fair, I understand that winston is primarily a non-browser module and rollup is not a typical use case for such modules. Furthermore, the first two critical issues above are really issues with external libraries. However, I believe this information can be useful to others that are hoping to use rollup and running into problems with winston.

I understand if fixing these problems is a lower priority. Furthermore, once native ES6 support is more widespread (node 11) and more code bases move from require to import these problems should just sort of magically go away.

@westonpace
Copy link
Contributor Author

I've requested winstonjs/logform#5 be reopened instead of opening a new issue as I had originally stated in my description to track the logform issue.

@DABH
Copy link
Contributor

DABH commented Feb 26, 2019

See discussion there^^

@DABH DABH closed this as completed Feb 26, 2019
@tamas-kiss-resideo
Copy link

may or may not be related, but I got blocked using rollup with winston too and the reason was that winston adds a "default" object property. When rollup does it's job with the commonjs plugin, it rewrites stuff to access default module exports with a direct notation (i.e. winston['default']) and of course this no longer points to the default export!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants