superjoin
v0.6.3
Published
Brings node.js like module loader support to the web
Downloads
26
Readme
Superjoin
Superjoin is a module loader for the web. It brings Node.js like require support to the front-end. It uses npm or bower as package storage and gives you the possibility to use your own local packages.
Installation
Superjoin is available on NPM the packagemanager for Node.js
The command to install it global:
npm install -g superjoin
If you prefer a local installation then remove the -g
flag from install command.
Requirements
Node.js >= 4.2.0
Usage of Superjoin:
Superjoin can be configured with a superjoin.json
file placed everywhere in your project.
A minimum configuration looks like:
{
"name": "myproject",
"main": "index.js",
"files": [
"hello.js"
]
}
Superjoin parse all modules an includes submodules automatically. You mustn't add all your requirements in the superjoin file.
Run the build job
$ superjoin -o build.js
Run this command from the same folder where your superjoin.json file is. That command will create a bundle with all modules and their requirements.
Include the build file
Place this simple html snippet in the head of your index.html
<script type="text/javascript" src="build.js"></script>
Inside your code
//Load local modules
var myModule = require('./modules/myModule.js');
//Load from node_modules or bower_components
var $ = require('jquery');
The difference of local and npm/bower modules is the leading ./
or ../
.
If a module name starts with ./
or ../
it will be loaded as a local file.
All other modules are being processed as npm or bower modules.
The loading order of npm/bower modules is the following:
Tries to load it from
bower_components
. If no bower_module folder is found, tries to load it from a bower_components folder in the parent directory, until the root directory.Tries to load it from
node_modules
. If no bower_module folder is found, tries to load it from a node_modules folder in the parent directory, until the root directory.Tries to resolve the path as a local module.
Throws a module not found error.
Superjoin as a plugin
Looking for plugins?
Superjoin plugin for Grunt.