google-closure-compiler

Why does Closure Compiler insist on adding more bytes?

白昼怎懂夜的黑 提交于 2019-12-12 07:40:08
问题 If I give Closure Compiler something like this: window.array = '0123456789'.split(''); It "compiles" it to this: window.array="0,1,2,3,4,5,6,7,8,9".split(","); Now as you can tell, that's bigger. Is there any reason why Closure Compiler is doing this? 回答1: I think this is what's going on, but I am by no means certain... The code that causes the insertion of commas is tryMinimizeStringArrayLiteral in PeepholeSubstituteAlternateSyntax.java. That method contains a list of characters that are

Bad type annotation. Unknown type

最后都变了- 提交于 2019-12-12 04:58:27
问题 I keep getting the warning mentioned above but can't figure out why. I've added deps.js and deps.js contains a reference to the type. Here is the offending code: goog.provide("MyCompany.MyApp.dom"); MyCompany.MyApp.dom.getArticleAmountInput_=function(){ return document.getElementById("articleAmount"); }; /** * Gets the article amount input value * @type {function(this:MyCompany.MyApp.dom):number} */ MyCompany.MyApp.dom.getArticleAmount=function(){ var tmp=this.getArticleAmountInput_(); return

Google Closure Compiler - How to create an Extern for a variable (variable name can't change as it is in an Eval)

好久不见. 提交于 2019-12-12 03:17:23
问题 I am using Google Closure Compiler in "SIMPLE_OPTIMIZATIONS" mode. The JavaScript uses an "Eval" statement with the variable "_u" embedded in the string. When Google Closure Compiler obfuscates the code, the variable name is changed to "a" and I get an error that "_u" is not defined in the console. My understanding is that an Extern will solve this problem, but I'm not sure how to write it. Thoughts? Code Snippet: var FuncName = (function(){ var ht=escape(_w.location.href) function _fC(_u){

java.lang.classnotfoundexception: com.google,javascript.jscomp.SourceFile

南笙酒味 提交于 2019-12-11 22:44:23
问题 I need to call Closure Compiler from a .bat file passing a flag language_in=ECMASCRIPT5 I am using the following script but I receive an error java.lang.classnotfoundexception: com.google,javascript.jscomp.SourceFile I would like to know: When I omit the flag code compile fine, so am I passing correctly the flag? Could you provide me more information about this error? java -Xms256m -Xmx256m -cp "%~dp0../shrinksafe/js.jar";"%~dp0../closureCompiler/compiler.jar --language_in=ECMASCRIPT5";"%~dp0

Compiling Dart into minifier friendly javascript: From dartdevc into google-closure-compiler

给你一囗甜甜゛ 提交于 2019-12-11 15:28:57
问题 What compiler options are best to ensure that dartdevc generates minifier friendly javascript code which can be compressed by google closure compiler in ADVANCED mode. Please show a tested example that specifies options for 1. dartdevc, and 2. java -jar goolge-closure-compiler.jar as a simple bash script, without pub. Module type should be 'common' if possible, dart_sdk.js should be included, the final result should be es3 or es5 for compatibility with all browsers, and all output goes into

ClosureCompiler removing dead code with advanced optimizations

為{幸葍}努か 提交于 2019-12-11 12:06:38
问题 The following code: (function() { var hello = function(name) { alert('Hello, ' + name); } hello('New user'); })(); with ADVANCED_OPTIMIZATIONS is compiled to: alert("Hello, New user"); But this code: (function() { var hello = function(name) { alert('Hello, ' + name); } hello.a = 5; hello('New user'); })(); is compiled to: function a(b){alert("Hello, "+b)}a.a=5;a("New user"); Why it cannot ignore the hello.a = 5 ? (It cannot be used outside the context, there is no eval , no [] and no new

Prevent Closure compiler from duplicating string

回眸只為那壹抹淺笑 提交于 2019-12-11 11:48:22
问题 I'm using Google's Closure compiler to shrink my JS. There are several places in my code where I have a repeated string, e.g. (function($){ $('.bat').append('<p>the red car has a fantastically wonderfully awe inspiringly world class engine</p><p>the blue car has a fantastically wonderfully awe inspiringly world class stereo</p><p>the green car has a fantastically wonderfully awe inspiringly world class horn</p>') })(jQuery); The compiler wasn't minimizing that redundancy (to be expected) so I

Documenting callback parameters using Google Closure Compiler

左心房为你撑大大i 提交于 2019-12-11 10:33:25
问题 How can you document names and descriptions of callback parameters using the Google Closure Compiler? After reading this answer on documenting callbacks with JSDoc, I tried using @callback and @typedef and @name tags, but ran into issues with each one. With @callback , Closure gives an "illegal use of unknown JSDoc tag" warning: /** * @callback EndDrawCallback * @param {string} action - either "keep", "discard", or "cancel" * @param {boolean} saveChanges - whether to mark changes as saved **/

CompilerOptions: NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

纵饮孤独 提交于 2019-12-11 09:49:57
问题 Anybody got any Idea why this error appears? Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(Z)V at com.google.common.collect.Lists.computeArrayListCapacity(Lists.java:105) at com.google.common.collect.Lists.newArrayList(Lists.java:98) at com.google.javascript.jscomp.ComposeWarningsGuard.<init> (ComposeWarningsGuard.java:83) at com.google.javascript.jscomp.CompilerOptions.<init>(CompilerOptions.java:791) Code import java.io.File;

How do I tell the closure compiler to ignore code?

走远了吗. 提交于 2019-12-11 07:45:29
问题 I decided I needed something to help me a bit while implementing interfaces. So I added this function to the base.js file in the closure library. /** * Throws an error if the contructor does not implement all the methods from * the interface constructor. * * @param {Function} ctor Child class. * @param {Function} interfaceCtor class. */ goog.implements = function (ctor, interfaceCtor) { if (! (ctor && interfaceCtor)) throw "Constructor not supplied, are you missing a require?"; window