# tinyify

> a browserify plugin that runs various optimizations, so you don't have to install them all manually.

Latest version **4.0.0** (published 2022-10-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install tinyify
pnpm add tinyify
yarn add tinyify
bun add tinyify
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2022-10-16 |
| First published | 2017-10-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 405 |
| Author | Renée Kooi |
| Maintainers | feross, gkatsev, zertosh, mafintosh, maxogden, thlorenz, terinjokes, jmm, mellowmelon, ashaffer88, balupton, cwmma, jprichardson, indutny, jryans, sethvincent, yoshuawuyts, ungoldman, ahdinosaur, elnounch, parshap, yerkopalma, forbeslindesay, leichtgewicht, garann, bret, anandthakker, mattdesl, hughsk, fpereira1, goto-bus-stop, bpostlethwaite, emilbayes, stevemao, pkrumins, tehshrike, defunctzombie, lukechilds, raynos, toddself |
| Keywords | browserify, minify, optimize, tree-shaking, uglify |

## Links

- npm: https://www.npmjs.com/package/tinyify
- Repository: https://github.com/browserify/tinyify
- Issues: https://github.com/browserify/tinyify/issues
- npm.io page: https://npm.io/package/tinyify

## Dependencies (10)

- [terser](https://npm.io/package/terser.md) 3.16.1
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [multisplice](https://npm.io/package/multisplice.md) ^1.0.0
- [unassertify](https://npm.io/package/unassertify.md) ^3.0.1
- [minify-stream](https://npm.io/package/minify-stream.md) ^2.0.1
- [common-shakeify](https://npm.io/package/common-shakeify.md) ^1.1.1
- [bundle-collapser](https://npm.io/package/bundle-collapser.md) ^1.3.0
- [browser-pack-flat](https://npm.io/package/browser-pack-flat.md) ^3.0.9
- [@browserify/envify](https://npm.io/package/@browserify/envify.md) ^6.0.0
- [@browserify/uglifyify](https://npm.io/package/@browserify/uglifyify.md) ^6.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2022-10-16
- 3.1.0 — 2022-06-28
- 3.0.0 — 2020-07-31
- 2.5.2 — 2019-11-02
- 2.5.1 — 2019-05-24
- 2.5.0 — 2018-11-15
- 2.4.3 — 2018-06-02
- 2.4.2 — 2018-06-01
- 2.4.1 — 2018-05-16
- 2.4.0 — 2017-12-03
- 2.3.0 — 2017-11-14
- 2.2.1 — 2017-11-06
- 2.2.0 — 2017-10-21
- 2.1.1 — 2017-10-17
- 2.1.0 — 2017-10-17
- … 2 more at https://npm.io/package/tinyify/versions

## README

# tinyify

a browserify plugin that runs various optimizations, so you don't have to install them all manually.

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/tinyify.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/tinyify
[travis-image]: https://img.shields.io/travis/browserify/tinyify.svg?style=flat-square
[travis-url]: https://travis-ci.org/browserify/tinyify
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

```bash
npm install --save-dev tinyify

browserify -p tinyify app.js
```

## Included

 - [unassertify][] - Remove `assert()` calls
 - [@browserify/envify][] - Replace environment variables—by default, replaces `NODE_ENV` with `"production"`
 - [@browserify/uglifyify][] - Remove dead code from modules
 - [common-shakeify][] - Remove unused exports from modules
 - [browser-pack-flat][] - Output a "flat" bundle, with all modules in a single scope
 - [bundle-collapser][] - When using the `--no-flat` option, bundle-collapser replaces file paths in `require()` calls with short module IDs
 - [minify-stream][] - Uglify the final bundle

[browser-pack-flat][] and [bundle-collapser][] are both not used if the `--full-paths` option is passed to Browserify.
This way you can still get all of tinyify's other optimizations when building for [disc][].

## Options

Options can be provided on the command line using subarg syntax, or in a separate options object using the browserify API.

### `env: {}`

Supply custom environment variables for [@browserify/envify][].

```js
b.plugin('tinyify', {
  env: {
    PUBLIC_PATH: 'https://mywebsite.surge.sh/'
  }
})
```

This option is only available in the API.
On the CLI, you can define environment variables beforehand instead:

```bash
PUBLIC_PATH=https://mywebsite.surge.sh browserify app.js -p tinyify
```

### `--no-flat`, `flat: false`

Disable [browser-pack-flat][].
This enables [bundle-collapser][] instead which will still shrink the output bundle a bit by replacing file paths with short module IDs.

```bash
browserify app.js -p [ tinyify --no-flat ]
```

```js
b.plugin('tinyify', { flat: false })
```

## More options?

If you need further customisation, I recommend installing the tools separately instead:

```bash
npm install --save-dev unassertify @browserify/envify @browserify/uglifyify common-shakeify browser-pack-flat terser
browserify entry.js \
  -g unassertify \
  -g @browserify/envify \
  -g @browserify/uglifyify \
  -p common-shakeify \
  -p browser-pack-flat/plugin \
| terser -cm \
> output.js
```

Or with the Node API:

```js
browserify('entry.js')
    .transform('unassertify', { global: true })
    .transform('@browserify/envify', { global: true })
    .transform('@browserify/uglifyify', { global: true })
    .plugin('common-shakeify')
    .plugin('browser-pack-flat/plugin')
    .bundle()
    .pipe(require('minify-stream')({ sourceMap: false }))
    .pipe(fs.createWriteStream('./output.js'))
```

Alternatively you can fork this repo and publish it on npm under a scope with your modifications.

## License

[Apache-2.0](./LICENSE.md)

[unassertify]: https://github.com/unassert-js/unassertify
[@browserify/envify]: https://github.com/browserify/envify
[@browserify/uglifyify]: https://github.com/browserify/uglifyify
[common-shakeify]: https://github.com/browserify/common-shakeify
[browser-pack-flat]: https://github.com/goto-bus-stop/browser-pack-flat
[bundle-collapser]: https://github.com/substack/bundle-collapser
[minify-stream]: https://github.com/goto-bus-stop/minify-stream
[browser-pack]: https://github.com/browserify/browser-pack
[disc]: https://github.com/hughsk/disc

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