apollographql / apollographql/apollo-tooling

Would it be possible to remove the dependency on moment?

Open
#2,323 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

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](https://momentjs.com/)

> 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](https://user-images.githubusercontent.com/77698413/117996081-d9822b00-b30f-11eb-80e1-38c6e0f2dd85.png)

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?

Contributor guide

Open the contributing guide

Research direction

Start in packages/apollo-language-server/src/format.ts at lines 1-17 and inspect how moment is used for the reported constants. Check the package dependency and use yarn why moment to confirm its remaining source; done means the unnecessary moment dependency is removed without changing the formatting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.