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

Replace Moment.js #731

Open
johnholdun opened this issue Mar 1, 2023 · 2 comments
Open

Replace Moment.js #731

johnholdun opened this issue Mar 1, 2023 · 2 comments
Assignees

Comments

@johnholdun
Copy link
Contributor

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).

@touchRED touchRED self-assigned this Mar 16, 2023
@touchRED
Copy link
Contributor

@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?

@johnholdun
Copy link
Contributor Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants