Meteor-Community-Packages / ground-db

GroundDB is a thin layer providing Meteor offline database and methods
https://atmospherejs.com/ground/db
MIT License
572 stars 77 forks source link

packages sizes in appcache: ground_servertime takes 375KB ?? #176

Closed hervejegou closed 4 weeks ago

hervejegou commented 7 years ago

I use Ground:db and it works great for mobile app with offline data. I use react, react-meteor-data and the latest grounddb caching and follow instructions in v2 usage and I get offline data in my mobile app and full reactivity while connected with almost no extra work. Thanks for a great package!

I do notice that my appcache size is quite big (14MB) so I checked which packages take most space:

Package Size
ddp-client.js 581KB
blaze.js 455KB
ground_db 452KB
minimongo.js 428KB
aldeed_simple-schema.js 375KB
ground_servertime.js 353 KB

No issue with ground_db package.js size, but ground_servertime.js? I checked the repositories and I cannot understand why ground_servertime would take so much space? Code seems to be only a few lines?

Versions used:

Appcache size screenshot:

grounddb appcache sizes

raix commented 7 years ago

not sure - the latest ground db is much less code - but it relies on mozillas "localforage". The servertime though... that's like 5 lines of code,

raix commented 7 years ago

unless meteor bundles localforage in both bundles...

hervejegou commented 7 years ago

If servertime uses localforage too, then Meteor may in fact bundle it in both packages and that would explain the significant size?

Have you considered a single package (integrate servertime in ground:db) ??

raix commented 7 years ago

Previously I had a meteor wrapper package for localforage, this would only get included once - but wanted to use the npm module directly. (assumed it would work the same...)

If you can prove that localforage is added twice I would consider it a serious issue in the meteor build tool, might be worth opening an issue there or ask in forum.meteor.com.

hervejegou commented 7 years ago

I will check if I can find out more, but I am a bit new to NPM and Meteor packages. It seems that Meteor bundles each Meteor package separately in a single file which is compresses and sent to client?? so yes localforage is packaged twice probably??

Maybe to avoid these issues:

  1. you could have 3 Meteor packages?? one for ground:db, one for servertime and one for localforage (as a dependency for both?). Like this there is no danger of bundling twice...
  2. you can consider using NPM instead of Meter for distribution. This is the preferred module manager for Meteor going forward (from 1.5 onwards) so it would probably work better long term? NPM will definitely not have this problem, and having local forage as an NPM dependency means it can be used in the app by other modules also?
  3. the easiest, less effort solution short term would be to put servertime in ground:db package so there is only one package to install and no such issues?

I would be happy with 3 since servertime is 5 lines of code??

raix commented 7 years ago

Let me know if this is still an issue in 2.0.0-rc.5

StorytellerCZ commented 4 weeks ago

Did not get a response, so I assume that this was fixed.