An open API service indexing awesome lists of open source software.

https://github.com/professormanhattan/probundle

👀 A tool that handles compressing, bundling, and unpacking production node_modules dependencies that you want to store in source control
https://github.com/professormanhattan/probundle

automation bin cli commander cosmicconfig go go-lang golang inquirer manpage mblabs megabytelabs nestjs professormanhattan terminal washingtondc

Last synced: about 1 month ago
JSON representation

👀 A tool that handles compressing, bundling, and unpacking production node_modules dependencies that you want to store in source control

Awesome Lists containing this project

README

        




Probundle logo





Bundle Your Production Dependencies with Probundle


An NPM CLI maintained by Megabyte Labs





Homepage


Contributing


Slack


Gitter


GitHub


GitLab






Version: 3.10.3


Build status


Dependency status reported by Depfu


Zip file size


Total downloads of probundle on npmjs.org


Number of vulnerabilities from Snyk scan on probundle


Documentation


License: MIT

>

**A tool that handles compressing, bundling, and unpacking production node_modules dependencies that you want to store in source control**


## Table of Contents

- [Overview](#overview)
- [Requirements](#requirements)
- [Developer Requirements](#developer-requirements)
- [Usage](#usage)
- [Optimization](#optimization)
- [Advanced Usage](#advanced-usage)
- [Performance](#performance)
- [Contributing](#contributing)
- [Affiliates](#affiliates)
- [License](#license)

## Overview

**Probundle** is a project that brings [pac](https://www.npmjs.com/package/pac) back to life (and support modern versions of Node.js. To achieve the fastest deployments possible, the production `node_modules/` (not devDependencies or any of that optional stuff) can be compressed by running `probundle pack` and stored in source control. Then, when deployment time comes all you have to do is uncompress or run `probundle unpack`. This works well when you also run [node-prune](https://github.com/tj/node-prune) on your `node_modules/` folder, before compressing your production dependencies. We even take it a step further in some cases and create global shared configurations for libraries like [ESLint](https://github.com/ProfessorManhattan/eslint-config-strict-mode) and [Prettier](https://github.com/ProfessorManhattan/prettier-config-sexy-mode) that dynamically load their plugins into `node_modules/` by downloading compressed plugins from source control without having to run `npm install`. We fuss about the performance of our `node_modules/` installation time because it is often a bottleneck.

## Requirements

If you are simply including this library in your project, all you need is a recent version of Node.js. **[Node.js >14.18.0](repository.project.node)** is sometimes required and is the only version range we actively support. Albeit, it is highly probable that lower versions will work as well depending on the requirements that this project imports.

### Developer Requirements

The following versions of Node.js and Python are required for development:

- **[Node.js >14.18.0](repository.project.node)**
- **[Python >3.10.0](repository.project.python)**

Other versions may work, but only the above versions are supported. Most development dependencies are installed automatically by our `Taskfile.yml` set-up (even Node.js and Python). Run `bash start.sh` to install **[Bodega](https://github.com/ProfessorManhattan/Bodega)** (an improved fork of [go-task](https://github.com/go-task/task)) and run the initialization sequence. The taskfiles will automatically install dependencies as they are needed, based on what development tasks you are running. For more information, check out the [CONTRIBUTING.md](https://github.com/megabyte-labs/Probundle/blob/main/docs/CONTRIBUTING.md) or simply run:

```shell
npm run help
```

`npm run help` will ensure Bodega is installed and then open an interactive dialog where you can explore and learn about various developer commands.

## Usage

After ensuring your `node_modules/` folder only contains the files you want in your compressed, production packages, simply run:

```shell
probundle pack
```

This will create compressed `.tgz` files for each of the packages in the `node_modules/` folder. You can then save these in source control or wherever you like. The compressed files will be stored in the `.modules/` folder.

When you are ready to deploy your compressed packages, perhaps after freshly cloning your repository, just run:

```shell
probundle unpack
```

## Optimization

Before compressing your production `node_modules/`, you might want to take a couple steps to ensure that only what is needed is present in the `node_modules/` folder.

Start off by clearing your `node_modules/` folder:

```shell
rm -rf node_modules
```

Then, install only the _dependencies_ by running:

```shell
npm install --only=prod
```

Next, ensure [node-prune](https://github.com/tj/node-prune) is installed and use it to remove unnecessary files from the `node_modules/` folder by running:

```shell
node-prune
```

At this point, you should check the size of the `node_modules/` folder and ensure that it is a modest size. If it is not and you still want to keep your production `node_modules/` in your source control repository, then you might want to consider wiping the history of the `.modules/` folder periodically. You can follow the [instructions here](https://stackoverflow.com/a/17824718/2476265), replacing `rm -rf node_modules` with `rm -rf .modules`.

## Advanced Usage

The `node_modules/` folder can get pretty big, pretty quickly, so you might want to consider saving your `.modules` to an S3 bucket. You can get really fancy with it and actually bind the `.modules` folder in your project to an S3 Fuse mount using software like [goofys](https://github.com/kahing/goofys). If you are interested, check out our free [Ansible role for goofys](https://github.com/ProfessorManhattan/ansible-goofys).

You can get even fancier with it by doing things like dynamically loading your `node_modules/`. Sometimes you might have a library that only needs a dependency sometimes. In that case, you can download the compressed `.tgz` wherever it is stored and load it on-demand. You can load a single module by running a command similar to this one:

```shell
probundle unpack eslint
```

For the above snippet to work, you would have to have the compressed `eslint.tgz` file stored in `.modules/eslint.tgz`.

## Performance

For even more performance, consider using [`pnpm`](https://pnpm.io/). Although we use `pnpm` normally, we actually use `npm` for building the `node_modules/` folder that **Probundle** compresses. You can get a better idea of how we implement Probundle by checking out this [Taskfile.yml](https://github.com/ProfessorManhattan/Probundle/tree/master/.config/taskfiles/npm/Taskfile-bundle.yml) which is powered by our custom task-runner called [Bodega](https://github.com/ProfessorManhattan/Bodega).

## Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/megabyte-labs/Probundle/issues). If you would like to contribute, please take a look at the [contributing guide](https://github.com/megabyte-labs/Probundle/blob/master/docs/CONTRIBUTING.md).

Sponsorship





Dear Awesome Person,


I create open source projects out of love. Although I have a job, shelter, and as much fast food as I can handle, it would still be pretty cool to be appreciated by the community for something I have spent a lot of time and money on. Please consider sponsoring me! Who knows? Maybe I will be able to quit my job and publish open source full time.


Sincerely,

**_Brian Zalewski_**


Open Collective sponsors


GitHub sponsors


Patreon

### Affiliates

Below you will find a list of services we leverage that offer special incentives for signing up for their services through our special links:


MailChimp


DigitalOcean Referral Badge

## License

Copyright © 2020-2021 [Megabyte LLC](https://megabyte.space). This project is [MIT](https://gitlab.com/megabyte-labs/npm/cli/probundle/-/blob/master/LICENSE) licensed.