# package-light

> cut only package dependencies to package-light.json

Latest version **1.1.1** (published 2019-10-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install package-light
pnpm add package-light
yarn add package-light
bun add package-light
```

Provides the command `package-light`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-10-24 |
| First published | 2019-10-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | nalliffunt |

## Links

- npm: https://www.npmjs.com/package/package-light
- Repository: https://github.com/NaLLiFFuNT/package-light
- Homepage: https://github.com/NaLLiFFuNT/package-light#readme
- Issues: https://github.com/NaLLiFFuNT/package-light/issues
- npm.io page: https://npm.io/package/package-light

## Recent versions

- 1.1.1 (latest) — 2019-10-24
- 1.1.0 — 2019-10-23
- 1.0.1 — 2019-10-06
- 1.0.0 — 2019-10-06

## README

[![npm version](https://badge.fury.io/js/package-light.svg)](//npmjs.com/package/package-light)
[![dependencies Status](https://david-dm.org/nalliffunt/package-light/status.svg)](https://david-dm.org/nalliffunt/package-light)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/nalliffunt/package-light.svg)

# Why ?

to reduce time you spent waiting your docker image is being built.

# How to use?

- Install as a dev dependency

```
npm i -d package-light
```

or

```
yarn add --dev package-light
```

- Add to your  `.gitignore` file
 
```
package-light.json
package-light-lock.json
```
 

- Add `pre` script for building docker image `npx package-light` which generate `package-light.json` and `package-light-lock.json` in case your use npm.

# Example

somewhere in your package.json
```
"scripts": {
"prebuild:docker": "npx package-light",             // generate `package-light.json` and `package-light-lock.json` (if needed)
"build:docker": "docker build -t my-image-tag .",   // your command to build docker image
}
``` 

# Dockerfile example
## npm
```
FROM node:12.13

# Install app dependencies
COPY ./package-light.json ./package.json
COPY ./package-light-lock.json ./package-lock.json
RUN npm i
## <-- this layer is cached until your dependencies change

# App source
COPY . .
# do your stuff here
```

## yarn
```
FROM node:12.13

# Install app dependencies
COPY package-light.json package.json
COPY yarn.lock ./
RUN yarn
## <-- this layer is cached until your dependencies change
# App source
COPY . .
# do your stuff here
```

This will greatly help to cache dependencies layer.
After dependencies are installed you should copy the rest files and may override package-light.json with original package.json
you may change your scripts, package version or other fields in your package json, it does not matter, dependencies layer remain unchanged.


// TODO:
- add example for react-create-app
- add example for express app

---
_Source: https://npm.io/package/package-light · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
