module-igniter
v1.1.0
Published
Node module loader and executor.
Downloads
7
Readme
NodeJS Module Igniter
Automatic call nodejs module, originally created for load rollup-plugins.
Install
Using NPM
npm i module-igniter
Using Yarn
yarn add module-igniter
Usage
Without Argument
const igniter = require("module-igniter");
const plug = igniter({ prefix: "rollup-plugin-" });
plug("commonjs", "node-resolve");
// or plug(['commonjs', 'node-resolve'])
// result [require('rollup-plugin-commonjs')(), require('rollup-plugin-node-resolve')()]
With Single Argument
const igniter = require("module-igniter");
const plug = igniter({prefix: 'rollup-plugin-'})
// single array argument
plug({ foo: [["hello"]] });
// result [require('foo')(['hello])]
plug({replace: {'process.env.NODE_ENV': JSON.stringify(environment)})
// result [require('rollup-plugin-replace')({'process.env.NODE_ENV': JSON.stringify(environment)})]
With multiple Arguments
const igniter = require("module-igniter");
const plug = igniter();
// single array argument
plug({ foo: [["hello"], { bar: "baz" }] });
// result [require('foo')(['hello], {bar: 'baz'})]
Optional Environment (Last Boolean Parameter)
const igniter = require('module-igniter')
const plug = igniter({prefix: 'rollup-plugin-'})
plug({replace: {'process.env.NODE_ENV': JSON.stringify(environment)}, false)
// result []
Class Based Plugin (Webpack)
const igniter = require("module-igniter");
const plug = igniter({ classic: true });
plug({
"html-webpack-plugin": {
filename: "assets/admin.html"
}
});
// result [new require('html-webpack-plugin')({filename: 'assets/admin.html'})]
Example
See here for real usage example
License
MIT