It's been a while since I've used Closure library + advanced mode with the compiler. My compilation is outputting this:
({})();
and I'm getting this compilation warning:
Error: index.js:4: WARNING - {} expressions are not callable
app.main.start();
^
Everything works fine in dev mode (using base.js). Here's my set up:
// index.js -> let compiler know app entry point
goog.provide('app.main.start');
goog.require('app.main');
app.main.start();
The actual application starts here
// app.js
goog.provide('app.main');
goog.require('goog.dom.fullscreen');
// ... other goog.requires
/**
*
*/
app.main.start = function(){
// ... app definition.
// see https://github.com/formigone/html5multiplayer/blob/master/megaman/closure/game.js
};
And here's how I'm compiling (using Gulp)
gulp.task('build', function () {
gulp.src(['index.js', 'app.js', 'src/**/*.js', 'node_modules/closure-library/closure/goog/**/*.js'])
.pipe(closureCompiler({
compilerPath: '/usr/local/google-closure/compiler.jar',
fileName: '../dist/app.min.js',
compilerFlags: {
closure_entry_point: 'app.main.start',
compilation_level: 'ADVANCED_OPTIMIZATIONS',
define: [
"goog.DEBUG=false"
],
only_closure_dependencies: true,
warning_level: 'VERBOSE',
create_source_map: 'app.comp.js.map'
}
}));
});
Even on SIMPLE_OPTIMIZATIONS app.main is just a blank object literal.