1.0.1 • Published 4 years ago
rosid-handler-js-next v1.0.1
rosid-handler-js-next
A function that loads a JS file and transforms, bundles and compresses its content.
Install
npm install rosid-handler-js-nextUsage
API
const handler = require('rosid-handler-js-next')
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-next will transform, bundles and compresses all matching JS files in your source folder.
{
"name" : "JS",
"path" : "[^_]*.js",
"handler" : "rosid-handler-js-next"
}// 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 tofalse. -replace{?Object}- Variables for @rollup/plugin-replace. Defaults to an object withprocess.env.NODE_ENVset toproductionwhenoptimizeis enabled. -babel{?Object}- Variables for @rollup/plugin-babel. Defaults to an object with the presets env and react. -nodeGlobals{?Boolean}- Enable to disable rollup-plugin-node-globals. Defaults tofalse. -rollupInput{?Object}- Input variables for rollup.js. -rollupOutput{?Object}- Output variables for rollup.js.
Returns
{Promise<String|Buffer>}The transformed file content.