Feel free to revisit.  IIRC, the issue is that you can't @export a "var".  You 
can only @export a function because @export sets up a reference to the renamed 
function and you can't set up a reference to simple vars.

Class Josh {
  Static var foo:int = 1;
}

Compiles to:

  Josh.foo = 1;

Gets renamed to:

  a.b = 1;

The @export will result in:

  ['Josh']['foo'] = a.b;

And then code that does:

  Josh.foo = 2;

Will not change

  Console.log(a.b); // 1 (not 2)

Of course, I could be wrong..

-Alex

On 9/16/19, 9:57 AM, "Josh Tynjala" <[email protected]> wrote:

    I guess I was assuming that @nocollapse combined with @export would make it
    also prevent renaming. I suppose I can test it and see what happens.
    
    --
    Josh Tynjala
    Bowler Hat LLC 
<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev&amp;data=02%7C01%7Caharui%40adobe.com%7Cd0c7fd54329c4f08a85708d73ac6ea33%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637042498316114014&amp;sdata=N30d559D3wJpJJ5%2BPNSp%2BLR5jg64caj3rCByjf41iyk%3D&amp;reserved=0>
    
    
    On Mon, Sep 16, 2019 at 9:54 AM Alex Harui <[email protected]> wrote:
    
    > IMO, the -warn-public-vars is more about the "renaming" mentioned in that
    > link than the "collapse".
    >
    > If you have:
    >
    > Package {
    > Class Josh {
    >   Public var name:String;
    > }
    > Var foo:Josh = new Josh();
    > foo.name = 'josh';
    >
    > I don't think @nocollapse will prevent renaming the 'name' property to
    > something random like 'jt':
    >
    > Var foo = new Josh();
    > foo.jt = 'josh';
    >
    > AIUI, @nocollapse is used for things that are not obviously mutable.  If
    > you look in the globals in the browser debugger for any js-debug version 
of
    > a Royale app, you can see the structure:
    >
    >    org.apache.royale.core
    >
    > It was created by code similar to:
    >
    > window.org = {};
    > window.org.apache = {};
    > window.org.apache.royale = {};
    > window.org.apache.royale.core = {};
    >
    > Then some class gets added:
    >
    > window.org.apache.royale.core.UIBase = function ()...
    >
    > And some static might get added to that:
    >
    > window.org.apache.royale.core.UIBase.FOO = "BAR";
    >
    > Closure will collapse org.apache.royale.core to just something like "bb"
    > in the js-release output.  And that means that code that sets UIBase.FOO
    > will break because there won't be an org.apache.royale.core structure.
    > AIUI, nocollapse would prevent collapsing that structure, but won't 
prevent
    > UIBase and FOO from being renamed.  And the renaming mainly causes 
problems
    > when deserializing data structures coming from a server or other external
    > source.
    >
    > Of course, I could be wrong...
    > -Alex
    >
    > On 9/16/19, 9:07 AM, "Josh Tynjala" <[email protected]> wrote:
    >
    >     I was looking through the Closure compiler annotations, and I noticed
    >     @nocollapse:
    >
    >     Denotes a property that should not be collapsed by the compiler into a
    >     > variable. The primary use for @nocollapse is to allow exporting of
    > mutable
    >     > properties.
    >     >
    >
    >
    > 
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgoogle%2Fclosure-compiler%2Fwiki%2FAnnotating-JavaScript-for-the-Closure-Compiler%23nocollapse&amp;data=02%7C01%7Caharui%40adobe.com%7Cd0c7fd54329c4f08a85708d73ac6ea33%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637042498316114014&amp;sdata=EyhgKMiOJL%2B7svlJUvqEb%2BWCC5J8ac5R2xPw2chkR3U%3D&amp;reserved=0
    >
    >     Isn't this collapsing behavior the reason why we needed to add
    >     -warn-public-vars?
    >
    >     --
    >     Josh Tynjala
    >     Bowler Hat LLC <
    > 
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev&amp;data=02%7C01%7Caharui%40adobe.com%7Cd0c7fd54329c4f08a85708d73ac6ea33%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637042498316114014&amp;sdata=N30d559D3wJpJJ5%2BPNSp%2BLR5jg64caj3rCByjf41iyk%3D&amp;reserved=0
    > >
    >
    >
    >
    

Reply via email to