If you use
stitch and you don't have enough of it, and
browserify seemed complicated in settings - try a
clinch .
What is in the box:
- simple API
- support
.js
, .json
, .coffee
, .eco
, .jade
- develop-mode ready - easy to integrate into express, smart cache with disability
- minor overhead on bundle ~ 40 SLOC
- simple mechanism for replacing modules and simulating global objects
The main feature I wanted to solve is the native use of CommonJS modules, including dependencies installed via npm. It is clear that modules using IO or having C-bindings will not work, but a large layer of simple modules can be transferred to the client.
The second trick - I like the development through testing, ideally - all client code would be good to
run through
mocha , in an automated version.
Well, nice bonuses - a reasonable amount of “binding” code, unambiguous resolution of dependencies, versioning, elimination of duplicates, the ability to have any number of bundles on the page.
In my opinion, all the ideas have been quite successfully implemented.
')
Installation - local
npm install clinch
.
Well, a simple example of use:
for 'hello_world.coffee' containing
module.exports = hello_world : -> 'Hello World!'
on output will give something like this
(function() { <... skip clinch header ...> dependencies = {}; sources = { "2377150448": function(exports, module, require) { module.exports = { hello_world: function() { return 'Hello World!'; } }; }}; this.my_package = { "main": require(2377150448)}; }).call(this);
And in the browser the function will be available like this.
hello_world = my_package.main.hello_world
If you don’t like the idea of ​​injecting into the global object of properties, you can turn it off, besides there are several settings for the jade compiler.
The project has a
Russian-language manual , which will probably be better thanks to your questions and comments.
In addition, there is a
demo project in which you can see the code and
results on the client.
Ps. I will be immensely grateful to anyone who teaches how to write good manuals.
Update: since 0.2.5 it is possible to register your own handler (or override the embedded ones), the method is called
registerProcessor()
.
It works like this:
An example of how to configure and use Handlebars -
look here .