# rosid-handler-js

> Load, transform, bundle and compress JS

Latest version **13.0.2** (published 2020-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install rosid-handler-js
pnpm add rosid-handler-js
yarn add rosid-handler-js
bun add rosid-handler-js
```

## 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 | 13.0.2 |
| Published | 2020-12-24 |
| First published | 2015-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | electerious |
| Keywords | rosid, handler, transform, compile, js, babel, browserify, terser |

## Links

- npm: https://www.npmjs.com/package/rosid-handler-js
- Repository: https://github.com/electerious/rosid-handler-js
- Issues: https://github.com/electerious/rosid-handler-js/issues
- npm.io page: https://npm.io/package/rosid-handler-js

## Dependencies (7)

- [terser](https://npm.io/package/terser.md) ^5.3.5
- [babelify](https://npm.io/package/babelify.md) ^10.0.0
- [browserify](https://npm.io/package/browserify.md) ^17.0.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.8.4
- [loose-envify](https://npm.io/package/loose-envify.md) ^1.4.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.8.4
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.8.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 13.0.2 (latest) — 2020-12-24
- 7.0.0-beta.0 (beta) — 2017-02-01
- 13.0.1 — 2020-10-18
- 13.0.0 — 2020-03-20
- 12.2.1 — 2020-01-31
- 12.2.0 — 2019-08-17
- 12.1.0 — 2019-03-07
- 12.0.1 — 2019-02-23
- 12.0.0 — 2018-09-14
- 11.0.0 — 2018-08-25
- 10.1.0 — 2017-12-09
- 10.0.1 — 2017-08-08
- 10.0.0 — 2017-07-19
- 9.0.1 — 2017-06-10
- 9.0.0 — 2017-05-31
- … 23 more at https://npm.io/package/rosid-handler-js/versions

## README

# rosid-handler-js

[![Travis Build Status](https://travis-ci.org/electerious/rosid-handler-js.svg?branch=master)](https://travis-ci.org/electerious/rosid-handler-js) [![Coverage Status](https://coveralls.io/repos/github/electerious/rosid-handler-js/badge.svg?branch=master)](https://coveralls.io/github/electerious/rosid-handler-js?branch=master) [![Dependencies](https://david-dm.org/electerious/rosid-handler-js.svg)](https://david-dm.org/electerious/rosid-handler-js#info=dependencies) [![Greenkeeper badge](https://badges.greenkeeper.io/electerious/rosid-handler-js.svg)](https://greenkeeper.io/)

A function that loads a JS file and transforms, bundles and compresses its content.

## Install

```
npm install rosid-handler-js
```

## Usage

### API

```js
const handler = require('rosid-handler-js')

handler('main.js').then((data) => {})
handler('main.js', { optimize: true }).then((data) => {})
```

### Rosid

Add the following object to your `rosidfile.json`, `rosidfile.js` or [routes array](https://github.com/electerious/Rosid/blob/master/docs/Routes.md). `rosid-handler-js` will transform, bundles and compresses all matching JS files in your source folder.

```json
{
  "name"    : "JS",
  "path"    : "[^_]*.js",
  "handler" : "rosid-handler-js"
}
```

```js
// main.js
export default () => 'Hello World'
```

```js
// main.js (output)
"use strict"
Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=function(){return"Hello World"}
```

## Parameters

- `filePath` `{String}` Absolute path to file.
- `opts` `{?Object}` Options.
	- `optimize` `{?Boolean}` - Optimize output. Defaults to `false`.
	- `env` `{?Object}` - Environment variables for [loose-envify](https://github.com/zertosh/loose-envify). Defaults to an object with `NODE_ENV` set to `production` when `optimize` is enabled.
	- `browserify` `{?Object}` - Browserify [options](https://github.com/browserify/browserify). Defaults to an object with `debug` enabled.
	- `babel` `{?Object}` - Babel [options](https://babeljs.io/docs/usage/api/). Defaults to an object with the presets [env](http://babeljs.io/docs/plugins/preset-env/) and [react](http://babeljs.io/docs/plugins/preset-react/).

## Returns

- `{Promise<String|Buffer>}` The transformed file content.

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