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

Reduce gem package size #90

Merged
merged 1 commit into from Sep 27, 2020
Merged

Conversation

pocke
Copy link
Contributor

@pocke pocke commented Sep 26, 2020

This pull request reduces the gem package size.

Currently this gem is 2.5MB.

$ cd path/to/installed/dir/lib/ruby/gems/2.7.0/gems
$ du mimemagic-0.3.5/ --summarize -h
2.5M    mimemagic-0.3.5/

But it contains unnecessary files for the package users, which are under tests/ and script/ directory.
Especially script/ directory is large, but it isn't necessary for the users.

So this pull request removes them from the package.
It reduces 2.3MB.

# after this pull request
$ cd path/to/installed/dir/lib/ruby/gems/2.7.0/gems
$ du mimemagic-0.3.5/ --summarize -h
184K    mimemagic-0.3.5/

@minad
Copy link
Collaborator

minad commented Sep 26, 2020

Is it a good idea to distribute gems without tests? Is this common practice? The gem us quite mature and no one complained before, so I don't see a pressing reason to change it.

@pocke
Copy link
Contributor Author

pocke commented Sep 27, 2020

It is a common practice because Bundler generates a gemspec with a similar setting.

https://github.com/rubygems/rubygems/blob/ff86ba494d54db5a9d52f13b1adf672e5669b010/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt#L25-L29

In my case, I found some large packages when I'm trying to reduce build time on CircleCI for my Rails app.
I use a cache mechanism of CircleCI for bundler. https://circleci.com/docs/2.0/caching/#bundler-ruby
And restoring cache spends 20~30s on average, for 322MB cache. it is not fast and small enough, so I'd like to reduce the build time by reducing the package size.

@minad minad merged commit 04ce672 into mimemagicrb:master Sep 27, 2020
@pocke pocke deleted the reduce-gem-package-size branch September 28, 2020 02:11
@mimemagicrb mimemagicrb locked as resolved and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants