Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/electerious/rosid-handler-js
Load, transform, bundle and compress JS.
https://github.com/electerious/rosid-handler-js
babel browserify js rosid transpiler uglify
Last synced: 3 months ago
JSON representation
Load, transform, bundle and compress JS.
- Host: GitHub
- URL: https://github.com/electerious/rosid-handler-js
- Owner: electerious
- License: mit
- Created: 2015-12-27T21:21:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-13T06:33:32.000Z (6 months ago)
- Last Synced: 2024-10-12T16:33:40.464Z (3 months ago)
- Topics: babel, browserify, js, rosid, transpiler, uglify
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
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}` The transformed file content.