There is a compiler option to turn off renaming in the release build if
you don't care about size.

IMO, use of * and plain Object is going to result in renaming issues.  Use
class definitions everywhere.  I've mentioned in the past about a compiler
warning on use of * and Object to help.  For Object you might also be able
to use JSON quoted keys.

HTH,
-Ales

On 12/11/16, 2:14 AM, "Harbs" <harbs.li...@gmail.com> wrote:

>I’ve been spending WAY too much time dealing with goog renaming.
>
>I have a good example of the kind of issues I’ve been dealing with. I
>think this is an area where Falcon needs to do a better job.
>
>I have some code which looks like this:
>
>                       var JSZip:* = require("jszip");
>
>                       var zip:* = new JSZip();
>                       var name:String = folderToZip.name;
>                       recursiveAdd(folderToZip,zip,"");
>                       var promise:Promise = new 
> Promise(function(resolve:*,reject:*):void{
>                               var zipFile:File = 
> destinationFolder.resolvePath(folderToZip.name +
>".zip");
>                               var zipStream:Stream  = zip.generateNodeStream(
>                               {type:'nodebuffer',streamFiles:true}).pipe(
>                               fs.createWriteStream(zipFile.nativePath));
>
>                               zipStream.on('finish', function ():* {
>                               // JSZip generates a readable stream with a 
> "end" event,
>                               // but is piped here in a writable stream which 
> emits a "finish"
>event.
>                                       console.log(zipFile.name + " written.");
>                                               resolve(zipFile);
>                               });
>                               zipStream.on('error',function():void{
>                                       console.log("zip error");
>                                       reject("error");
>                               })
>                       });
>                       return promise;
>
>jszip is a Node module I’m using with require().
>
>This code works perfectly in a debug build of my app.
>
>When I run a release build I get an “undefined function” error.
>
>The problematic code is here:
>                               var zipStream:Stream  = zip.generateNodeStream(
>                               {type:'nodebuffer',streamFiles:true}).pipe(
>                               fs.createWriteStream(zipFile.nativePath));
>
>The code gets minified to this:
>
>return new Promise(function(d,f){var
>h=b.ba(a.name+Zc),k=c.Br({type:yA,Vr:!0}).pipe(fs.createWriteStream(h.nati
>vePath));k.on(Nw,function(){console.log(h.name+ib);d(h)});k.on(vw,function
>(){console.log(hI);f(vw)
>
>This is broken on multiple fronts:
>1. zip. zip.generateNodeStream is renamed to c.Br. Br is quite obviously
>not defined.
>2. streamFiles is renamed to Vr, so the wrong options are being passed
>into jszip. I have no idea why streamFiles is being renamed, but type is
>not.
>
>To fix this you need to do something like this:
>
>                               var zipStream:Stream  = 
> zip["generateNodeStream"](
>                               
> {"type":'nodebuffer',"streamFiles":true})["pipe"](
>                               fs.createWriteStream(zipFile.nativePath));
>
>Which generates:
>return new Promise(function(d,f){var
>h=b.ba(a.name+Zc),k=c.generateNodeStream({type:yA,streamFiles:!0}).pipe(fs
>.createWriteStream(h.nativePath));k.on(Nw,function(){console.log(h.name+ib
>);d(h)});k.on(vw,function(){console.log(hI);f(vw)})}
>
>I also have no idea why nativePath is not renamed. It’s a property of a
>class which I defined. It seems like it would be a good candidate for
>renaming.
>
>We need some kind of annotation in ActionScript code to enable output of
>annotations for the Google Compiler to know that it’s not okay to rename
>properties of the objects. I’ve had this problem with object literals
>that are being sent as well as accessing properties and methods of
>external objects.
>
>Having manually use bracket notation instead of dot notation is error
>prone. It would be much better to have Falcon automatically change the
>notations or annotate the code in such a way that goog does not rename
>them.
>
>On Dec 6, 2016, at 6:02 PM, Alex Harui <aha...@adobe.com> wrote:
>
>> 
>> 
>> On 12/5/16, 11:47 PM, "Harbs" <harbs.li...@gmail.com> wrote:
>> 
>>> OK. I guess I’ll rework the definitions into extern js files when I
>>>have
>>> time.
>> 
>> In theory, if you use FalconJX to cross-compile those AS files, you
>>should
>> get the right set of JS files to stick a folder called externs (instead
>>of
>> js/out).  The build scripts and settings should be almost the same as
>>how
>> we build the framework SWCs.
>> 
>> HTH,
>> -Alex
>> 
>

Reply via email to