1

There is a javascript application I would like to modify for my use*. The problem is, the js is compiled with Google Closure Compiler. Obviously, I should modify the sources (which are available in the repository), and re-compile.

This is my first encounter with GCC. I skimmed the documentation and came to the conclusion that the key is using the sources mentioned in deps.js via goog.addDependency keywords. So I set up an HTML file and referenced all the sources. Loading this file I got 118 ReferenceError: goog is not defined errors in firebug console.

Then I read some more and found the app has been compiled with the help of kbuild, and that it uses a config file, config.kb, to send the right parameters to GCC. This file, indicates the first file should be loader.js, so I reordered the <script> tags and moved

<script type="text/javascript" src="./eightball/loader.js"></script>

to the top. but the same errors are thrown. So, what is missing?

* The license is MIT and there is no issue with the rights.

4
  • See developers.google.com/closure/library/docs/closurebuilder
    – Matt
    Commented Apr 25, 2013 at 18:57
  • @Matt you deleted your answer just in time to duck getting a +1 ;) Thanks for the answer and this pointer. Commented Apr 25, 2013 at 19:00
  • Haha, I can undelete it if you found it useful, but I thought I'd misread your question, and you'd already completed what I said in my answer, and are instead looking at how to minify the code using Closure Compiler... in which case the above link is what you need :).
    – Matt
    Commented Apr 25, 2013 at 19:02
  • Your answer helped a lot. You are right the question is a bit long, but your first impression was correct -- I have not succeeded in getting the uncompiled version working. Commented Apr 25, 2013 at 19:17

1 Answer 1

2

First, it would seem the application is using Google Closure, which is a JavaScript library developed by Google.

This is (of course), completely different to Google Closure Compiler, which is a JavaScript minification and obfuscation engine (dang these large companies and their quest to name everything the same).

That means you should include the Closure bootstrap before deps you've got listed; which is what the application itself does, as in the main view, it calls the game_js helper, which includes the base file of Closure if the application hasn't been compiled.


TLDR:

Try including the /javascripts/closure/closure/goog/base.js file first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.