honestbleeps/Reddit-Enhancement-Suite — pull request #711 by thybag (2014-01-12 10:31:13+00:00)
Title: Proposal: Splitting RES into different files

Hello,

I noticed there was a, now fairly old, issue in housekeeping for looking at splitting up the "reddit_enhancement_suite.user.js" file (due to its fairly significant size) https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues/332

Given no solution was agreed upon, I wanted to propose an alternative mechanism which should in theory avoid some of the original pitfalls & hopefully be a bit easier to implement.

Essentially my proposal is to use node.js and a [grunt](http://gruntjs.com/) to build the final "reddit_enhancement_suite.user.js" file (which has the bonus of removing the need to creating hard links). Node is very easy to install/run on pretty much any platform, and if node is installed grunt & its dependencies can be installed with nothing more than a `npm install` thanks to the package.json.

Currently this branch hasn't actually split the files at all, but just shows the build scripts working with the existing code base.

As a simple demo, say if i want to start developing on chrome, i go to the top level RES directory and run

grunt chrome

This will copy the css files & then concat all the js in to a reddit_enhancement_suite.user.js file within the chrome directory. It will also start a watch task, which will automatically perform the same action any time a file changes in lib, so i can work directly on the lib copy of the code (and have the changes automatically copied over to the chrome directory, meaning i can test in my browser as normal)

Once grunt is run i can add the chrome extension to chrome in the standard way, and develop & reload normally. Once done, all i have to do is commit the files in lib and I'm done. I've also setup demo grunt scripts for the other 5 browsers also (assuming they work in much the same way), you'd just need to type `grunt firefox` or `grunt safari`.

Once this build script is in place, it would be pretty trivial to split (for example) all the modules off in to there own files in a modules directory and then have the build script pull them in as well when generating the RES file for browsers to use.

Would be interested to get some feedback on this idea, pros/cons.

In my own view the grunt option would actually be simpler to use (as a develop) than creating hard-links is now (which is a pain on windows). It also open the door to easily adding additional functionality to the build scripts (stripping comments/minifying/maybe even only including certain bits of code for certain browser builds etc) in the future.

Thanks,
Carl