metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Miklavcic <michael.miklav...@gmail.com>
Subject Re: [DISCUSS] Replacing Moment.js with date-fns or native functions
Date Wed, 26 Sep 2018 21:38:13 GMT
Sounds reasonable to me as well. Thank you for detailed explanation,
examples, and risk assessment! When you submit the PR for this, please link
back to the DISCUSS via permalink from the mailing list archives. +1

Thanks,
Mike

On Wed, Sep 26, 2018 at 6:40 AM Casey Stella <cestella@gmail.com> wrote:

> I think it's fine.  My only concern would be that we aren't accidentally
> using moment.js somewhere for something that date-fns doesn't do.  I
> suspect whoever picks up the ticket will figure that out pretty quick
> though. ;) . I'm +1 on the move; you convinced me.
>
> On Wed, Sep 26, 2018 at 8:36 AM Tamás Fodor <ftamas.mail@gmail.com> wrote:
>
> > I'd like to open a discussion about replacing Moment.js
> > <https://momentjs.com/> in Alerts UI. date-fns <https://date-fns.org/>
> has
> > almost the same functionality to manipulate date/time in the application.
> > Moment.js is a great library but it has a huge footprint in the bundle
> and
> > it's significant when it comes to performance optimization in order to
> > decrease the initial load time.
> >
> > Here you can find a brief introduction of the problem and a few ideas how
> > to replace it with date-fns or native functions.
> > https://github.com/you-dont-need/You-Dont-Need-Momentjs
> >
> > *The problem:*
> > In order to use Moment.js, we have to import the whole library which has
> > significant impact on the size of the production bundle of our javascript
> > code.
> >
> > *A few examples:*
> >
> >
> https://github.com/apache/metron/blob/e66cfc80e6a6fa53110c3f2fa8ee0d31ea997bf6/metron-interface/metron-alerts/src/app/utils/utils.ts#L18
> >
> >
> https://github.com/apache/metron/blob/ccdbeff5076553382091d4b9423ed48ccdba10ee/metron-interface/metron-alerts/src/app/shared/pipes/time-lapse.pipe.ts#L20
> >
> > Even though, we have tree-shaking
> > <https://webpack.js.org/guides/tree-shaking/> which is a great feature
> of
> > javascript bundlers (in our case Webpack), because of how Moment.js is
> > structured, it prevents the bundler from doing tree-shaking properly
> > <
> >
> https://github.com/you-dont-need/You-Dont-Need-Momentjs/blob/master/README.md
> > >.
> > date-fns is just fine with that
> > <https://github.com/date-fns/date-fns/issues/275#issuecomment-264934189
> >.
> > For example, to use the `format` functions we don't have to import the
> > whole library, we can import only the format function
> > <https://date-fns.org/v1.28.0/docs/format#usage> individually.
> >
> > What do you think?
> >
> > Tamas
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message