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

moment.js is deprecated and should be replaced #672

Open
Tracked by #6414
mojoaxel opened this issue Sep 15, 2020 · 12 comments · May be fixed by #1261
Open
Tracked by #6414

moment.js is deprecated and should be replaced #672

mojoaxel opened this issue Sep 15, 2020 · 12 comments · May be fixed by #1261
Labels
Hacktoberfest hacktoberfest.digitalocean.com help wanted Extra attention is needed

Comments

@mojoaxel
Copy link
Member

mojoaxel commented Sep 15, 2020

moment.js consideres itself now deprecated.

moment.js takes up over 10% of the bundle size:

-----------------------------
Rollup File Analysis
-----------------------------
bundle size:    1.456 MB
original size:  1.414 MB
code reduction: 0 %
module count:   509

/node_modules/moment/moment.js
█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 10.48 % (152.665 KB)
/node_modules/vis-util/esnext/esm/vis-util.js
████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 8.92 % (129.931 KB)
/lib/timeline/component/ItemSet.js
███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 6.79 % (98.892 KB)
/node_modules/vis-data/esnext/esm/vis-data.js
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 5.82 % (84.813 KB)
/node_modules/@egjs/hammerjs/dist/hammer.esm.js
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 5.15 % (75.003 KB)
/lib/timeline/Core.js
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3.83 % (55.844 KB)
/lib/timeline/component/Group.js
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 3.02 % (43.997 KB)
/lib/timeline/component/LineGraph.js
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.51 % (36.608 KB)
/lib/timeline/Range.js
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.29 % (33.327 KB)
/lib/timeline/Timeline.js
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 2.11 % (30.676 KB)

The vis.js universe should switch to a different library (e.g. Luxon, Day.js, date-fns, js-Joda)

@mojoaxel mojoaxel added help wanted Extra attention is needed Hacktoberfest hacktoberfest.digitalocean.com labels Sep 15, 2020
@mojoaxel mojoaxel changed the title moment.js is deprecated ans should be replaced moment.js is deprecated and should be replaced Oct 5, 2020
@Glandos
Copy link
Contributor

Glandos commented Dec 15, 2020

See #12 (comment)

@imagoiq
Copy link

imagoiq commented Jun 25, 2021

Maybe as well use Intl native object as much as possible?

@mojoaxel
Copy link
Member Author

I propose to use dayjs instead of moment.js in the future. Dayjs has a good support for locals and is very small. An alternative would be to use native date functionalities (e.g. Intl) wherever possible and sprinkle in some function from date-fns wherever necessary. But using dayjs will definitely be easier!

https://github.com/you-dont-need/You-Dont-Need-Momentjs

@mojoaxel
Copy link
Member Author

mojoaxel commented Oct 11, 2021

I would suggest the following procedure:

  • find all the places moment is used. (Here eslint-plugin-you-dont-need-momentjs can help)
  • replace all moment-operations with functions from the DateUtil. If functions are missing add them to the DateUtils.
  • Create intensive tests for all function within the DateUtils!
  • Remove moment from the DateUtils-function one by one while running and improving the test to ensure everything works like expected.
  • In the end remove moment from global space and all the documentation.
  • this than needs to be released a mayor release!

@mojoaxel mojoaxel linked a pull request Oct 11, 2021 that will close this issue
@Fanna1119
Copy link

Fanna1119 commented Nov 16, 2021

Any progress on this? Momentjs is a big ball of ugly bloat.

@michealroberts
Copy link

I am in favour of day.js ... can I take the responsible person for this PR?

@mojoaxel
Copy link
Member Author

Instead on just using dayjs we could introduce a neutral adapter layer. Similar of what chart.js is doing with their "adapters".
That way people could choose an adapter with a library they already use in their project.

This is not a trivial task to do, but well-tested PRs are very welcomed!

@michealroberts
Copy link

@mojoaxel What about date.io? https://github.com/dmtrKovalenko/date-io

@mojoaxel
Copy link
Member Author

date-io looks really promising. It looks like it does not support tree-shaking, but that is maybe a price we should pay!?

merge-requests welcome!

mojoaxel added a commit that referenced this issue Mar 13, 2023
…idden\nremove parameter moment from DateUtil.getHiddenDurationBefore
mojoaxel added a commit that referenced this issue Mar 13, 2023
@krishna217
Copy link

Hi All, is this still in the roadmap ?

@eg9y
Copy link

eg9y commented Jan 5, 2024

Bump

@rubennaatje
Copy link

#1569

This should help, it's merged but is unfortunately not released yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest hacktoberfest.digitalocean.com help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants