aharui commented on issue #36: Slow Compiler Build Time
URL: https://github.com/apache/royale-compiler/issues/36#issuecomment-377160350
 
 
   I don't think we've tried to add external JS to the minification.  Normally 
the library represented by the typedef is loaded by the HTML template and the 
typedef only represents the API surface.  In theory though, you should be able 
to build a Royale SWC and inject raw JS into the output folder so Google 
Closure Compiler will minify it.
   
   A Royale SWC for JS output is just compiled AS to represent the API surface 
and included JS files to be copied into the output folder.  So, if you just 
write the API surface in GreenCircle.as:
   
   ```
   public class GreenCircle extends MovieClip
   {
       public var shape:Shape;
       public function GreenCircle(mode:String="0", startPosition:Number=0, 
loop:Boolean=false)
       {
       }
   }
   ```
   
   You don't need any code bodies.  Then you compile that into a SWC using only 
target=SWF and include-file the raw Animate .js file as GreenCircle.js
   
   The compiler should then compile your code against the AS APIs but then copy 
the included JS file into the output folder.   The Royale Compiler doesn't care 
too much about the code format in the JS files in a SWC, but it does expect 
goog.provide, goog.require and goog.inherits, @constructor, @extends, 
@implements.  If you can provide that the compiler will happily copy the .js 
file to the output folder.  The key point is that the .js file does not need to 
be transpiled by the Royale Compiler.
   
   I don't know if Google Closure Compiler will accept the kind of wrapped JS 
function that Animate outputs.  You may have to rewrite the JS API headers to 
use the simpler prototype style that Google Closure uses in their code.  You 
may have to add goog.provide goog.require and goog.inherits and  @extends, @ 
and other JSDoc to the raw Animate JS file.  
   
   So, I think that is your trade-off.  By porting the Animate JS to AS, the AS 
compiler will automate the annotation of the JS output for Closure.  But you 
are porting from JS to AS and back to JS.  If you just modify the API wrappings 
around the actual code in the JS output and create an empty AS API declaration 
you can skip the reading and writing of big files.
   
   I'm still going to look at the profiler to see what is taking so long and if 
there is any quick things we can do to make it faster.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to