React-dates: Moment.js Optional

Created on 30 Apr 2018  路  3Comments  路  Source: airbnb/react-dates

I recently installed a vscode extension that shows me how large certain imports are, and I was really shocked at just how big moment.js is. The issue is I really love and want to keep using react-dates, which is the only thing I'm really using moment for.

image

I know it's an open issue for moment to modularize, but in the mean time it would be cool if moment were optional, so you could pass a vanilla js Date object in instead of a moment object

Alternatively, would you recommend I fork and add this functionality myself? Or is it so deeply rooted that you think I'd run into a bunch of unforeseen stuff?

Thank you, and thank you for all the open source work airbnb does!! 馃槉馃尭

Most helpful comment

Typically what one does in their bundler is only include the locale for the given request, which means that your IDE plugin is over-reporting the actual size.

Moment usage is definitely so deeply rooted that it's likely not worth the effort.

All 3 comments

Typically what one does in their bundler is only include the locale for the given request, which means that your IDE plugin is over-reporting the actual size.

Moment usage is definitely so deeply rooted that it's likely not worth the effort.

how about using this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat (ECMA-402) instead of moment, this can be polyfilled if needed, on newer browsers you have all the goodies, so you dont have to #usetheplatform :)

How large is the polyfill compared to moment? I suspect you'll find it's much much larger, because it contains all the ICU data.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krissalvador27 picture krissalvador27  路  3Comments

Adam-Pendleton picture Adam-Pendleton  路  3Comments

sag1v picture sag1v  路  3Comments

Jesus-Gonzalez picture Jesus-Gonzalez  路  3Comments

aaronvanston picture aaronvanston  路  3Comments