Re: Re : Require-js compiler

11 views
Skip to first unread message

Romain

unread,
Jul 4, 2011, 4:57:50 PM7/4/11
to resth...@googlegroups.com
Hi

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


Cheers
Romain

Romain

unread,
Jul 6, 2011, 11:04:44 AM7/6/11
to resth...@googlegroups.com
Thanks

I dicovered this project this morning :-/ .But I will try to do something with them: 

Cheers
Romain

2011/7/6 Objelean Alex <alex.o...@gmail.com>
In case you find it useful, there is already a project which uses uglifyJs with Rhino (as well as many other existing js compressors, like packerJs, YuiCompressor, GoogleClosure, DojoShrinkSafe, etc): wro4j (web resource optimizer for java)

Regards,
Alex

Reply all
Reply to author
Forward
0 new messages