Skip to content

Remove dependency on moment.js #341

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

Merged
merged 1 commit into from
Apr 7, 2022
Merged

Remove dependency on moment.js #341

merged 1 commit into from
Apr 7, 2022

Conversation

wojtekmaj
Copy link
Contributor

No description provided.

@wbt
Copy link
Collaborator

wbt commented Mar 24, 2022

Thanks for the contribution; could you share some of the motivating rationale?
It appears that the moment.js data format is used in the datePattern option, though this is only and directly passed to the date_format option of file_stream_rotator's getStream function. Has that been updated to remove the dependency? If so, do we need to update documentation here which refers to moment.js?

@wojtekmaj
Copy link
Contributor Author

I think we don't really need 4 MB of dependencies just to format one date as string.

moment creators themselves discourage using it, advising for, among others, date-fns and leveraging Intl.

file_stream_rotator is indeed using moment at the (nomen omen) moment, but I can see how, given the above, its creator(s) could drop it as well at some point.

@wbt
Copy link
Collaborator

wbt commented Mar 24, 2022

At present, this is only a dev dependency so the weight should only affect those developing on and building winston-daily-rotate-file directly, which is a pretty minor difference for a pretty small set of folks, and actually a zero difference while the dependency is still using moment. Therefore, I'm not going to prioritize this for an in-depth review at present (on quick review, it looks good as it stands), but I will definitely leave the PR open, and any other maintainers who want to do a review are welcome to merge if desired.
Thanks for the contribution and for adding the explanation!

@kyle-zimmerman-manulife
Copy link

For what it's worth, moment.js@2.29.1 has a High severity CVE (CVE-2022-24785) that has been fixed in 2.29.2.

The dependency should be updated so that the CVE isn't introduced through winston-daily-rotate-file, but it shows that there might be some value in removing it as a dependency that increases the attack surface for relatively little value given it's only used once.

@wbt wbt merged commit 9e88c1d into winstonjs:master Apr 7, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants