0

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.

rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123
  • I think you need to show the contents of `app.main.start()`. – JJJ Apr 11 '15 at 12:54
  • Suppose it says console.log('here'); – rodrigo-silveira Apr 11 '15 at 15:22
  • The Assumption here is that you have a typo and your description here does not show it. Can you build a repro case that you can show the complete code for? – John Apr 12 '15 at 06:06
  • I've edited the question to include a link to the repo where this is hosted: https://github.com/formigone/html5multiplayer/blob/master/megaman/closure/game.js – rodrigo-silveira Apr 12 '15 at 09:37
  • 1
    Your example in the question doesn't match the actual repo. In the repo you have `rokko.main.play()` inside index.html but you never pass that information to the compiler, which makes the assumption that it's dead code and leaves it out. – JJJ Apr 12 '15 at 09:43

0 Answers0