I have small library for client side routing and template loading. It's built from several smaller module, for example Tpl, Router..
Every module check if library namespace is defined and than apply itself to it.
Here is the code: https://github.com/sgoran/micro
For example Tpl component binds itself to Micro library (the main lib)
if(typeof Micro === "function" && Micro.prototype.isMicro){
Micro['Tpl'] = Tpl;
And than I am calling library with constructor
var micro = new Micro(properties);
Problem is if I want to make another instance...dependencies will collide internally
var micro2 = new Micro(properties);
For build, I use gulp and just concatenate modules to one file..
Can anyone propose a good way for building multiple modules to one, like sandboxing them? Or some best practices and patterns without using webpack, requireJs etc..
CommonJsarchitecture. It is the architecture which NodeJs uses. Are you familiar with NodeJs?