Skip to content

Conversation

@mernen
Copy link
Contributor

@mernen mernen commented Aug 23, 2017

Even though angular2-jsonapi only weighs about 3 KiB gzipped, it currently depends on moment.js, which adds about 65 KiB gzipped to a project. That absolutely kills the “lightweight” aspect of this library.

A major reason for moment.js being so big is that it bundles all its locales when imported, and getting rid of them requires fiddling with Webpack config (not currently possible with angular-cli). But even if all locales were removed, moment.js core is still 16 KiB gzipped, more than five times the size of this library’s core. We can do better!

This patch replaces moment with date-fns, a highly modular date library that allows us to import just the components we need, with minimal overhead. These are the numbers I got on my project:

  minified min+gzip
moment.js 305.8 KiB 65.5 KiB
date-fns 8.6 KiB 2.9 KiB

(By the way, this patch preserves a serialization bug, as fixing it might break those who are already relying on it. I will make a different pull request for that)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 83.52% when pulling 1a45104 on mernen:use-datefns into 17e4b72 on ghidoz:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 83.52% when pulling 1a45104 on mernen:use-datefns into 17e4b72 on ghidoz:master.

@HennerM
Copy link
Collaborator

HennerM commented Aug 24, 2017

Alright looks good, can you elaborate on what the mentioned bug is?

@HennerM HennerM merged commit 00af920 into ghidoz:master Aug 24, 2017
@mernen
Copy link
Contributor Author

mernen commented Aug 24, 2017

Sorry for being so needlessly vague about it, I should have opened an issue already rather than waiting for the patch. An explanation and a patch are now provided in #90.

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

Successfully merging this pull request may close these issues.

3 participants