flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Avoiding goog renaming
Date Sun, 11 Dec 2016 15:04:54 GMT
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.


On 12/11/16, 2:14 AM, "Harbs" <harbs.lists@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 +
>				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"
>   		 			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
>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
>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
>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
>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
>On Dec 6, 2016, at 6:02 PM, Alex Harui <aharui@adobe.com> wrote:
>> On 12/5/16, 11:47 PM, "Harbs" <harbs.lists@gmail.com> wrote:
>>> OK. I guess I’ll rework the definitions into extern js files when I
>>> time.
>> In theory, if you use FalconJX to cross-compile those AS files, you
>> get the right set of JS files to stick a folder called externs (instead
>> js/out).  The build scripts and settings should be almost the same as
>> we build the framework SWCs.
>> HTH,
>> -Alex

View raw message