inventid / tails

Models on the fly!
MIT License
1 stars 0 forks source link

Bundling and dependencies #22

Closed steffansluis closed 10 years ago

steffansluis commented 10 years ago

So, I've been working on this for a while now but I can't really find the right way to do this. When running grunt build, the coffeescript gets compiled into javascript and concatenated into a file called tails.js by the coffeescript compiler. This file can be tested by using grunt jasmine, which manages the dependencies by specifying them as vendor libraries.

This leaves the user to do this manually when he actually wants to use tails, which is not a problem, but a lot of unnecessary trouble we really should avoid on behalf of the user. A simple solution is to concatenate all the dependencies with tails.js to a new file, say bunde.js, and call that the build result. However, this could potentially lead to a lot of code duplication and it's ugly.

Then there is browserify, which gives you the ability to use a node-like require method in browers, so you can dynamically load stuff anywhere, and then backtracks your require calls to analyse and bundle your dependencies. Sound cool, but it's a bit of a pain setting it up correctly with grunt (I've given it a few too many tries) and I don't really think it's worth the trouble since it will bundle everything anyway so the only gain is the magic require function we don't really need. @joostverdoorn @rogierslag What's your take on this?

steffansluis commented 10 years ago

I've sorted stuff out a bit and we are now supporting the first two option with grunt dist and grunt bundle. I've tested it and the bundle is indeed the only file you need to include to get tails working :) I'm still interested in your opinions about this though.