On 10/20/15, 5:08 PM, "Josh Tynjala" <joshtynj...@gmail.com> wrote:
>As long as FlexJS apps don't use external libraries, it should be safe to >do more drastic optimization like automatically renaming variables and >things. This must be disabled for code transpiled with asjsc because >external JS libraries can be referenced in the transpiled code, and those >names must remain unchanged. It's possible to pass in externs files to the >closure compiler, but that presents a high barrier to entry. I think I see code where, when you compile externs files into SWCs, you can also pack the JS for the externs in the SWC in an folder called “externs” and the transpiler will use that JS file as an externs file during the compilation, which should prevent renaming. I believe that isn’t necessary for JS.swc because its externs are defaults in GCC. Maybe it will matter for GCL.swc once I turn on optimizations again. But we may need to verify that these code paths work as expected. The SWC should be able to package the externs files you need to prevent renaming when using third-party libraries. > >I could not find a way to turn off the advanced optimizations for asjsc >apps without also turning it off in FlexJS apps. As I recall, it gets >configured in the middle of a big method, so it wasn't easy for me to >override something. Some refactoring could make that more easily >configurable across different JS output types. My current thought on this is to add a new compiler option that works sort of like -define where you can specify as many as you want and just about anything after. For lack of a better name, I am going to call it -js-compiler-option. Better name suggestion are welcome. So you can add compiler arguments like -js-compiler-option=“—compilation_level SIMPLE”. One problem with this plan is that we don’t actually use the GCC command line. We use the Java APIs which uses a data structure. We will have to write code that maps strings like “—compilation_level SIMPLE” to actual code that sets data structure properties. If GCC adds new options, we’ll have to keep changing the mapper to stay up-to-date. Thoughts? -Alex