leaf-require, resolve module dependencies in browser, like in nodejs.
Mar 02, 2014
leaf-require allows you to manage modules with CommonJs module standard, and requires no precompile like browserify do.
The trick is simple. Preload all js file of the context, wrap them in a function that closured with some CommonJS variables like require, module, exports, and finally do some magic to solve the dependencies and execute the code once when being required. There are many other interesting ideas that come with it, like localStorage script caching, upgrade detection ,the partially program update, and even easy frontend package publish like npm.
You can checkout the repo at github.Share