google-closure-compiler

Javascript Closure compiler -Exporting global variables

心已入冬 提交于 2019-12-22 10:55:57
问题 My webapp is based on a common script where I define the common functions and a global variable and dynamically loaded scripts that process those. So far, the only way I found to export the global variable is to replace any occurrence by window["myGlobalVar"] but I find it very ugly. Is there a better way to do? Here is an illustration // commonscript.js before compilation function incrementVariable() {window["myGlobalVar"]++;} window["incrementVariable"] = incrementVariable; window[

Why does Google Closure Compiler adds variable to the global namespace when the original namespace was empty?

只愿长相守 提交于 2019-12-22 09:12:07
问题 I have a long script nicely wrapped into a (function() {/.../})() to avoid all kind of name pollution. It is 100% typed with zero warning. I found out that Google Closure compiler starts by redefining i and j in the global namespace which feels both unnecessary and dangerous, especially since I am compiling a script that has zero interference with the namespace. (the compiled script starts with var i=null,j=!1; , for compactness reasons I believe). I can think of a work around which is to

using jQueryUI with closure compiler

依然范特西╮ 提交于 2019-12-22 08:24:07
问题 I am having trouble getting a js app that uses jQuery UI to work after minifying using the closure compiler. What I did: Go here and load up the jqueryui js file Asked to extern jQuery.ui Copied the result to a file and used it as an extern file The app broke, though. The dialogs do not show correctly anymore. The explosion effect doesn't work correctly, and there are several dialogs created. It is interesting that jQuery UI itself is working somewhat, since the dialogs were created. It is

Google Closure decompiler?

試著忘記壹切 提交于 2019-12-21 22:21:49
问题 I was looking for a way to decompile JavaScript that was compiled by Google Closure. I did find a Decompiler class (https://code.google.com/p/closure-compiler/source/browse/lib/rhino/src/org/mozilla/javascript/Decompiler.java?name=v20140407), however I haven't had much luck with it. Anyone try this before or know of some other method? 回答1: Usually, I just run the code through the Closure Compiler in WHITESPACE mode and enable the pretty printing options. 来源: https://stackoverflow.com

how to fix closure compiler error on css({ float: 'left' }) [duplicate]

一个人想着一个人 提交于 2019-12-20 05:40:27
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Google Closure Compiler parse error: invalid property id for css({float:'left'}) I tried to use closure compiler from http://closure-compiler.appspot.com/home to compile code // ==ClosureCompiler== // @output_file_name default.js // @compilation_level ADVANCED_OPTIMIZATIONS // ==/ClosureCompiler== css({ float: 'left' }) but got error JSC_PARSE_ERROR: Parse error. invalid property id at line 1 character 6 css({

Is there a way to tell Google Closure Compiler to *NOT* inline my local functions?

左心房为你撑大大i 提交于 2019-12-19 11:49:22
问题 Here's what I'm looking for: I want to use the wonderful features of SIMPLE mode minification while disabling just one specific feature (disable local function inline). UPDATE: The answer is NO, it's not possible given my setup. But for me there is a workaround given I am using Grails. As @Chad has explained below, "This violates core assumptions of the compiler". See my UPDATE3 below for more info. IN QUESTION FORM: I'm using CompilationLevel.SIMPLE_OPTIMIZATIONS which does everything I want

Why does Closure compiler rename properties of an extern type?

被刻印的时光 ゝ 提交于 2019-12-18 19:09:24
问题 I put this in an externs file: /** @typedef {{english: string, spanish: string}} */ var SpanishNoun; Then I have javascript: /** * @param {SpanishNoun} n */ exp1.processData3 = function (n) { console.log("pd3:", n.english, n.spanish, n['english'], n['spanish']); } Which compiles to: function(a){console.log("pd3:",a.a,a.c,a.english,a.spanish)}; So it still renamed 'english' to 'a', etc. How do you stop that? Why does it think it can rename something that is "extern". Rob Follow-up Question

Google Closure Compiler 100% typed

China☆狼群 提交于 2019-12-18 11:12:28
问题 How can I get my application to be 100% typed in regard to google closure compiler? I already tagged everything with jsdoc comments. Is it even possible to get 100? I'm at 64,6% 回答1: It IS possible to achieve 100%. My own projects are 100% typed. The closure compiler can output warnings about expressions with unknown types. Unfortunately there is no command line option to enable this feature. You have to modify the source code to enable it: Download the current sources: git clone https://code

Running a command in a Grunt Task

你离开我真会死。 提交于 2019-12-17 10:15:29
问题 I'm using Grunt (task-based command line build tool for JavaScript projects) in my project. I've created a custom tag and I am wondering if it is possible to run a command into it. To clarify, I'm trying to use Closure Templates and "the task" should call the jar file to pre-compile the Soy file to a javascript file. I'm running this jar from command line, but I want to set it as a task. 回答1: Alternatively you could load in grunt plugins to help this: grunt-shell example: shell: { make

How do I split my javascript into modules using Google's Closure Compiler?

百般思念 提交于 2019-12-17 09:34:17
问题 I want to use the google closure compiler on the javascript source we're using. In development mode we tend to break functionality to lots of files but for production would like to have them combined into modules. When calling the compiler I can give it a list of files to include for compilation, but the output of that shows that the compiler did not save the order of the files list. I searched about it and found that I can use goog.provide/good.require in order to control the dependencies