2011/7/4 Seb
<bou...@gmail.com>
Hi,
Indeed this feature would be very interesting to compile resthub framework or application JS files, thanks a lot for your proposal.
Do you plan to use UglifyJS runned in Rhino ?
Yes actually I use UglifyJS, which is included by default with RequireJS
optimisation. I tried to use Google Closure, but I had some bad exceptions, so I stay on UglifyJS.
For exemple, when I use the script like this :
import org.filirom1.concoct.requireJs.RequireJsCompiler;
@Test
public void testCompileBigRequireJsProject() throws IOException {
//fixture
File jsToCompile = new File(getClass().getClassLoader().getResource("app.js").getFile());
//execute
String result = new RequireJsCompiler().compile(jsToCompile);
//check
File compiled = new File(getClass().getClassLoader().getResource("compiled.js").getFile());
Assert.assertEquals(result, FileUtils.readFileToString(compiled));
}
Here is the input
And here is the output : compressed and aggregated
In term of needs, what we have already identify is :
- Be able to build an compressed + aggregated version of resthub.js with all modules in it.
It's already done :). With a maven plugin, it could be executed automatically.
- Be able to compress only (we keep the sample granularity of files) applications JS files, in order to keep lazy loading behaviour.
I think that for this, UglifyJS alone will do the work. I will add it to
concoct.
Regards,
Seb