-
Notifications
You must be signed in to change notification settings - Fork 3
Compiling
dturnbull edited this page Dec 25, 2010
·
13 revisions
Using the compiler can be quite easy. All you have to do is make a Googlyscript template. If there are any errors with the compilation, you will see them on your javascript console.
compile.js.erb
<% @response = goog.compile(%w{
--compilation_level ADVANCED_OPTIMIZATIONS
--js_output_file js.out
--ns myapp.HelloWorld
}).to_response_with_console %>
If you are using the js_output_file option then the compiler will skip compilation if none of the sources are new than the output. This is important to remember if you want your compile.js.erb to support parameters. Make sure your output filenames are uniquely hashed against the variable arguments.
epic_fail.js.erb
<!-- This will fail because you are sharing the output file -->
<%=goog.compile [
'--compilation_level', params['comp_level'],
'--ns', 'googly.demos.compiler',
'--js_output_file', 'out.js'
]%>
<!-- The fix: '--js_output_file', "#{params['comp_level']}_out.js" -->