v0.5.0

Superjoin Docs

Superjoin uses a `superjoin.json` file to get its configuration. Place this file in the project root or in a subdirectory under your project root.

A minimum configuration looks like:

{ "name": "myproject", "main": "index.js", "files": [ "hello.js" ] }

Options

List of all options, supported by a superjoin.json file

OptionDatatypeDescription
filesarrayAn array of dependencies. See module paths section to get involved into module names and how they be used.
namestringDefines a name for the bundle file.
mainstringDefines a main file. This module will be automatically required.
devbooleanEnables dev-mode. Superjoin loads modules automatically by using XHR if they aren't defined in the files property. Use this feature only for development. This feature slows down the loading speed of your page!
rootstringSets a web-root path. A web-root path is the folder which contains all your public web-docs. If this property isn't set, the current working dir is used as web-root.
outfilestringFilename for the bundle file. The bundler resolves this path relative to the web-root directory if it isn't absolute.
skipSubmodulesbooleanDisable auto loading of submodules that hadn't been added to the `files` option
noRequirebooleanDon't add therequire() method to the output.
umdboolean or stringEnables UMD support. Superjoin creates an standalone package. This value can be either a boolean or a string. A string is also used as the module name. If value is true, the module name will be read from name property.
umdDependenciesobjectDefines dependencies for an UMD bundle. The object key defines the name of the dependency within your module, the value is an array of the dependencies for AMD, CommonJS and window.

{ 'jquery': ['jquery', 'jquery', 'jQuery'], 'xqcore': ['xqcore', 'xqcore', 'XQCore'] }

Require method

Use the global require method inside your code to load a module.
var XQCore = require('xqcore'); var mymodule = require('./mymodule');
All modules are being cached. If a module returns an object you'll get the same instance of that module on each require call. The `require()` method loads modules either from a module folder or a as a local file. If path is a filename and if path has no file extension, `.js` is added as file extension. If file extension is `.json`, the module will be handled as a JSON file.

Module paths

This table lists all allowed module path and describes how they being handled.
PathDescription
mymoduleLoad module from modules dir.
1. Tries to load the module from bower_components
2. Tries to load the module from node_modules
4. Throws a module not found error
./mymodule.jsLoad as local file, relative to the current file
../mymodule.jsLoad as local file, relative to the current file (Goes one level up)
/mymodule.jsLoad as local file, absolute from root dir
mymodule.jsTries to load as local file, relative to current file. (Contains a dot, but no slash) If it fails the file will be loaded as a module
$lib/mymoduleLoad as module from lib dir
$npm/mymoduleLoad as module from node_modules dir
$bower/mymoduleLoad as module from bower_components dir

Defining modules

The module.exports object is created by the module system and is available in all files that have been loaded by require(). Assign every value to module.exports to get it exported
//sayHello.js module.exports = function(msg) { console.log(msg); };var sayHello = require('./sayHallo'); // This loads sayHello.js from the same folder //Call sayHello sayHello('Hello world'); //Logs 'Hello world' to the console

Commandline

The commandline tool has a few options. Run `superjoin --help` to get a list of all options. The commandline option overrides options loaded from a superjoin.json file.

Programatic Usage

Superjoin can be used programatic as well. A minimal setup lokks like:
let Superjoin = require('superjoin'); let superjoin = new Superjoin(); superjoin.build().then(data => { }).catch(err => { console.error('Something went wrong!', err.stack); });
The constructor accepts as first parameter a configuration object. These configuration parameters will override configurations loded from a superjoin.json file. See the list below to get an overview of all configuration parameters
OptionDatatypeDescription
filesarrayAn array of dependencies. See module paths section to get involved into module names and how they be used.
namestringDefines a name for the bundle file.
mainstringDefines a main file. This module will be automatically required.
devbooleanEnables dev-mode. Superjoin loads modules automatically by using XHR if they aren't defined in the files property. Use this feature only for development. This feature slows down the loading speed of your page!
rootstringSets a web-root path. A web-root path is the folder which contains all your public web-docs. If this property isn't set, the current working dir is used as web-root.
outfilestringFilename for the bundle file. The bundler resolves this path relative to the web-root directory if it isn't absolute.
skipSubmodulesbooleanDisable auto loading of submodules that hadn't been added to the `files` option
noRequirebooleanDon't add therequire() method to the output.
umdboolean or stringEnables UMD support. Superjoin creates an standalone package. This value can be either a boolean or a string. A string is also used as the module name. If value is true, the module name will be read from name property.
umdDependenciesobjectDefines dependencies for an UMD bundle. The object key defines the name of the dependency within your module, the value is an array of the dependencies for AMD, CommonJS and window.

{ 'jquery': ['jquery', 'jquery', 'jQuery'], 'xqcore': ['xqcore', 'xqcore', 'XQCore'] }