Using superjoin

This is a quick introduction into Superjoin.

All what we need is a module and a index.js file.
The module contains a function which logs a massage to the browser console. And the index.js as
our entry point.

It's always a good way to save modules in a separate folder.
I often place my local modules under modules or libs.

Our file structure may looks like:

/test-project /libs //Our modules folder sayHello.js index.js index.html

Lets create the module first.

// libs/sayHello.js module.exports = function(greeting) { alert(greeting); };

Next step, the index.js file.

// index.js var sayHello = require('./libs/sayHello.js'); sayHello('Hello Superjoin');

Perfect, we are ready to make a build.

Open a terminal window and change into the project directory. Then run this command.

$ superjoin -o build.js index.js sayHello.js

This command creates a build.js file which contains a global require method, the module loading system, and our modules.

Last step, creating an index.html file

<html> <head> <title>Say hello</title> <script type="text/javascript" src="build.js"></script> </head> <body> </body> </html>

Thats it! Open the index.html file in your browser to see the result.

Dev mode

Superjoin loads missing modules in dev mode automatically by using an XHR call. You should never use this feature in production, it slows down the page loading time.


The superjoin build can be configured by a superjoin.json file. Place this file somewhere under your project root.

{ "main": "index.js", "files": [ "./sayHello.js" ], "scriptFile": "build.js" }

Run the build job again, but without any arguments and you'll get the same build file as above.

$ superjoin

I hope you'll like Superjoin. Feel free and star us at github.com