Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
helios-merge
Advanced tools
helios-merge
is a command-line tool which bundles JavaScript modules
based upon the Helios Kernel
module format. This tool can be used to prepare a library internally
managed as several Helios Kernel modules to release as a plain
JavaScript file (suitable for using without Helios Kernel), or to
simply get a bundled module suitable for further
minimizaiton. helios-merge
is based upon the
Esprima and
Escodegen projects.
Install helios-merge
using npm:
$ sudo npm install helios-merge -g
Optionally you may download the distribution using this
link.
In latter case you will have to launch it as node path/to/helios-merge.js
instead of simply helios-merge
in the examples below.
$ helios-merge --input=path --output=path [additional options]
--input
path of the main module to start merging from (defaults to
./main.js
)
--output
path to write the bundled script into. After the bundle is
prepared, it could be reused instead of the original file (provided to
the --input
option) with the same effect
--quiet
suppress informational messages display
--plain
create a plain .js file suitable to be used without Helios
Kernel (implies --scope=global
)
--scope=subdir
(default) — bundle only the scripts in the directory
and subdirectories. All modules outside of the bundling scope will be
treated as external dependencies and will be included into the bundled
module head using the include()
function of Helios Kernel
--scope=local
bundle all sources available by a local path, but
treat remote dependencies as external
--scope=global
bundle all local and remote files (paths starting
form http://...
)
--help
or whatever unrecognized — show help message
In this example we have a library splitted between several modules relying on each other, and we are going to merge it into a single module. The source of the artificial example library could be like this:
./myLibrary.js
— main library module, provides a method to say 'Hello World!':include('./base.js');
include('./print.js');
init = function() {
myLibrary.helloWorld = function() {
myLibrary.print('Hello World!');
}
}
./print.js
— prints a given message:include('./base.js');
init = function() {
myLibrary.print = function(text) {
console.log(text);
}
}
./base.js
— declares library object:init = function() {
myLibrary = {};
}
Bundling the library using helios-merge
like this:
$ helios-merge --input=./myLibrary.js --output=./myLibraryBundled.js
The generated myLibraryBundled.js
will contain the code of all
modules sorted in order of dependence and will behave like this:
init = function() {
myLibrary = {};
myLibrary.print = function(text) {
console.log(text);
}
myLibrary.helloWorld = function() {
myLibrary.print('Hello World!');
}
}
This code demonstrates the behaviour of the generated bundle, but in fact the code of each original module will additionally be wrapped into an anonymous function to make use of local variables declared in each original module's initializer.
FAQs
Tool for merging Helios Kernel modules
We found that helios-merge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.