Skip to content

concurrently imports the entire date-fns library without tree-shaking but use only 1 function #329

@guillaumeprevost

Description

@guillaumeprevost

I have found this issue while investigating why my project still had the entire date-fns library bundled even if I was carefully importing and using only a few functions.

date-fns provides a syntax that will allow bundlers like Webpack to do some "tree-shaking" and only import the needed modules rather than the full library, optimizing greatly the total bundle size.

It seems like concurrently doesn't use this syntax, which causes to import the full date-fns library instead of only the single function used in logging (formatDate in logger.ts and log-timings.ts).

How found this :

I had opened an issue about this originally on the date-fns repo because I thought it came from there.

After some discussions around the issue, someone mentioned here that it could come from another dependency importing all of date-fns by not using tree-shaking syntax. The recommendation was to use npm why date-fns to spot which other dependency may use date-fns.

When running that command, it only listed my own references to date-fns (using the syntax allowing tree-shaking) and the concurrently library.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions