Load, transform, bundle and compress JS.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src Updated to Babel 7 Sep 14, 2018
test
.gitignore Ignore `yarn.lock` and `package-lock.json` files Aug 8, 2017
.travis.yml Updated test environments Aug 25, 2018
CHANGELOG.md Updated to Babel 7 Sep 14, 2018
LICENSE Copyright year Jan 22, 2018
README.md docs(readme): add Greenkeeper badge Jun 5, 2018
appveyor.yml Updated test environments Aug 25, 2018
package.json 12.0.0 Sep 14, 2018

README.md

rosid-handler-js

Travis Build Status AppVeyor Status Coverage Status Dependencies Greenkeeper badge

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

Install

npm install rosid-handler-js

Usage

API

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. rosid-handler-js will transform, bundles and compresses all matching JS files in your source folder.

{
  "name"    : "JS",
  "path"    : "[^_]*.js",
  "handler" : "rosid-handler-js"
}
// main.js
export default () => 'Hello World'
// 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.
    • browserify {?Object} - Browserify options. Defaults to an object with debug enabled.
    • babel {?Object} - Babel options. Defaults to an object with the presets env and react.

Returns

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