Minimising payload when publishing a package

Is there a way of specifying (or ignoring) files that should be included in a package when it is published? In the same way as .npmignore works perhaps?

I have a package with less than 200k of elm code, but 18Mb of documentation, tests etc. They are all currently in the same repo and ideally I would like to keep them all together. But this does make for a weighty download for anyone installing the package.

If there isn’t a mechanism for selecting the files to be included in a package, is there any recommended good practice for separating core package files from other non-essential content?

5 Likes

The elm-community/webgl folks found themselves in a similar situation. Turns out that, indeed, it is possible! The trick is quite simple - Elm requires a tagged release to be present. There is, however, no requirement for that tag to be made on a commit on your master branch - or indeed any branch.

So what they do is checkout the HEAD commit by hash, which puts you in a detached HEAD state. They retain only the files they want to publish, create a commit for those, tag that commit and push it to GitHub.

The end result, as a script, is this: https://github.com/elm-community/webgl/blob/master/release.sh

9 Likes

Brilliant! Looks like a perfect solution. Thanks.