Skip to content

Would it be possible to remove the dependency on moment? #2323

@ez-alexfrazer

Description

@ez-alexfrazer

in my project, moment takes up an inordinate amount of the bundle, so I've been trying to remove it. The documentation site itself says it's a deprecated project

Another common argument against using Moment in modern applications is its size. Moment doesn't work well with modern "tree shaking" algorithms, so it tends to increase the size of web application bundles. If one needs internationalization or time zone support, Moment can get quite large. Modern web browsers (and Node.js) expose internationalization and time zone support via the Intl object, codified as ECMA-402. Libraries like Luxon (and others) take advantage of this, reducing or removing the need to ship your own data files.

I used yarn why moment to try to figure out why.

image

I then traced it down to these lines:

https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-language-server/src/format.ts#L1-L17

I thought it seemed a bit strange as these seem to be constants, as far as I can tell, and moment is adding little but readability at the cost of bundle size.

Would it be possible to remove moment in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions