flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Tynjala <joshtynj...@gmail.com>
Subject Closure compiler CompilationLevel
Date Tue, 22 Sep 2015 06:37:02 GMT
The Closure compiler has three compilation levels.

CompilationLevel.WHITESPACE_ONLY
CompilationLevel.SIMPLE_OPTIMIZATIONS
CompilationLevel.ADVANCED_OPTIMIZATIONS

Right now, JSClosureCompilerWrapper specifies the ADVANCED_OPTIMIZATIONS
compilation level. This level changes the code the most, but it can also be
the most, well, destructive.

Unfortunately, the files in js-release have never worked for one of my
projects because my projects need to call out to external libraries. The
Closure compiler supports passing in externs files to preserve the right
API names for external libraries, of course. I don't actually know if
FlexJS exposes the ability to pass in externs at this point in the
compilation process (I know externc uses externs files, obviously).
However, I'd rather not need to do that regardless. It's a pretty demanding
requirement, in my opinion. I think it adds a barrier to entry, and if
supported, it should be opt-in.

I tried creating a build that used SIMPLE_OPTIMIZATIONS instead. It worked
a little bit better. It was able to call out to external libraries, but
some things weren't clearly broken in the browser. Unfortunately, the
browser console did not show any runtime errors, so it's hard to say what
broke without some serious debugging. It seems that Closure compiler's
optimizations are still somewhat destructive at the SIMPLE_OPTIMIZATIONS
level.

When I created a build that used WHITESPACE_ONLY, everything worked as
expected. I personally think that WHITESPACE_ONLY should be the default in
JSClosureCompilerWrapper. This compilation level still minifies the code,
which is what we care about the most for a release build. Most JS
developers don't do more than basic minimization, as I've come to
understand it. The more advanced stuff that the Closure compiler does is
more out of the ordinary. Probably due to the potential for breaking
things. I remember when I worked at Yahoo, the recommended best practice
was to avoid renaming things during minification.

Can we change JSClosureCompilerWrapper to use WHITESPACE_ONLY instead?

- Josh

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message