To facilitate integration of janus.js
within modular JavaScript code bases, you can instruct the build system(s) to generate a modular variants of janus.js
. Generated modules may then be copied to your own JavaScript projects and seamlessly integrated with your own project's build system.
Building the modules can be done in two ways:
make
, by enabling the integrated support via configure
Each supported variant may be enabled by passing a corresponding –enable-javascript-*-module
flag (with or without a =yes
directive) to configure
before invoking make
to build Janus. Please note: if you do not pass any such flag, by default no modules will be built.
The following table provides a summary of available module formats and their corresponding configure
options:
Module format (syntax) | File name | configure flag to pass |
---|---|---|
ECMAScript | janus.es.js | –enable-javascript-es-module |
Universal Module Definition (UMD) | janus.umd.js | –enable-javascript-umd-module |
CommonJS | janus.cjs.js | –enable-javascript-common-js-module |
Immediately Invoked Function Expression (IIFE) | janus.iife.js | –enable-javascript-iffe-module |
The –enable-all-js-modules
shortcut is available, in case you want to enable and build them all.
When built and installed, these module variants may be found in the $PREFIX/share/janus/javascript
folder, alongside the janus.js
file itself (assuming $PREFIX
the installation directory passed to configure
).
install
which means npm
must be able to download dependencies. By default configure
will attempt to auto-detect available npm
on your PATH, but if you have installed NPM outside the PATH you can override this by passing the (full) path to your npm
executable, e.g.:./configure NPM=/path/to/my/custom/npm --enable-javascript-es-module=yes
You can also opt to build modules by invoking npm
manually. The npm
subdirectory contains the necessary configuration files to get you started:
cd ./npm npm install npm run rollup -- --o /path/to/desired/output/file-name.js --f cjs # or es, iffe, umd, amd, ...
Using npm
directly is useful if you want to build the JavaScript modules only, without building Janus itself or if you are looking for advanced customisation options or alternative formats which are not integrated in configure
yet. As you may have surmised from the example command, the actual build consists mostly of invoking rollup
with the correct parameters. For more information on available parameters, please refer to the rollup
documentation: