parser icon indicating copy to clipboard operation
parser copied to clipboard

Replace Moment.js

Open johnholdun opened this issue 1 year ago • 2 comments

We're hitting file limits in the bundled extension size for Postlight Reader, and I'm pretty sure it's due to the size of this dependency. Right now we can't ship new versions to the Firefox store because of a >4mb bundle file 😅

As far as I can tell, replacing Moment would help immensely. Moment is used in a pretty limited capacity, meaning we're not passing moment() objects around or anything, but it does a lot to parse a wide variety of timestamp strings into an ISO-formatted string. There are probably more efficient ways to do this. (It's also used in a couple tests, so we could move it to devDependencies, or replace those uses as well.)

While we're at it, I believe it would help to audit dependencies that use the full lodash library rather than pulling in utility functions as needed. I'm working on doing this in Reader as well (and I already removed Moment from that codebase).

johnholdun avatar Mar 01 '23 18:03 johnholdun

@johnholdun I'm taking a look at this and have made some good progress. I've been trying to get away with a vanilla JS approach similar to yours here but the timezone and format parsing are a bit more difficult to achieve without a library. With that in mind, how do we feel about replacing Moment with a much lighter package like DayJS? Or do you think we should stick with the vanilla option?

touchRED avatar Mar 17 '23 18:03 touchRED

@touchRED I think you're right, this logic is likely better served by a library. DayJS is probably good, though I don't have much experience with it (or really any other library in this space). Ideally there's one that exposes its functionality such that we only need to import what's required to parse these timestamps. I trust whatever conclusion you come to!

johnholdun avatar Mar 17 '23 20:03 johnholdun