rosid-handler-js-next
v2.0.0
Published
Load, transform, bundle and compress modern JS
Maintainers
Readme
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.options{?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>}The transformed file content.
