google-closure-compiler

How to indicate param is optional using inline JSDoc?

我们两清 提交于 2019-12-02 14:34:02
According to the JSDoc wiki for @param you can indicate a @param is optional using /** @param {String} [name] */ function getPerson(name) { } and you can indicate a param inline using function getPerson(/**String*/ name) { } And I can combine them like the following, which works ok. /** @param [name] */ function getPerson(/**String*/name) { } But I would like to know if there is a way to do it all inline if possible. From official documentation : Optional parameter An optional parameter named foo. @param {number} [foo] // or: @param {number=} foo An optional parameter foo with default value 1.

JavaScript “this” keyword and Closure Compiler warnings

陌路散爱 提交于 2019-12-02 12:09:41
问题 I have production code that I am now trying to minify with the Closure Compiler using the advanced option. The code uses Paul's client side cookie libraries. The compiler generates over 30 of these warnings: JSC_USED_GLOBAL_THIS: dangerous use of the global this object Here are some code snippets from Paul's library (oroginal code uses named functions, not anonymous functions): var cookieObject = function (name, expires, accessPath) { var i, j this.name = name this.fieldSeparator = "#" //

How to prevent Closure Compiler from renaming any property or method of a specific object?

给你一囗甜甜゛ 提交于 2019-12-02 11:19:05
I am working with a huge 3rdparty library ( Babylon JS ) that will be served from its own CDN and cannot be included in my Closure Compiler run. The library contains one object and everything defined as parts of it. It has no externs file available so I started to write one but it is growing quickly. It would be easier to just tell Closure Compiler to not mangle any properties I am setting, including the ones I am setting on objects created by constructors on the object. EDIT: Added the name of the library. The Closure Compiler has no feature that would allow you to say "don't rename any

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

爱⌒轻易说出口 提交于 2019-12-02 08:32:00
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({ float: 'left' }) How to fix it? This code is used in Oleg jqGrid createContexMenuFromNavigatorButtons method posted in stackoverflow answer. float is likely to be

JavaScript “this” keyword and Closure Compiler warnings

那年仲夏 提交于 2019-12-02 03:51:38
I have production code that I am now trying to minify with the Closure Compiler using the advanced option. The code uses Paul's client side cookie libraries . The compiler generates over 30 of these warnings: JSC_USED_GLOBAL_THIS: dangerous use of the global this object Here are some code snippets from Paul's library (oroginal code uses named functions, not anonymous functions): var cookieObject = function (name, expires, accessPath) { var i, j this.name = name this.fieldSeparator = "#" // this.found = false this['found'] = false; // don't allow Closure-Compiler to rename this.expires =

Why does Closure Compiler not rename objects with certain names?

一世执手 提交于 2019-12-02 01:37:54
问题 When I test the following code in closure compiler at http://closure-compiler.appspot.com: // ==ClosureCompiler== // @output_file_name default.js // @compilation_level ADVANCED_OPTIMIZATIONS // @formatting pretty_print // ==/ClosureCompiler== // These get renamed window.foo = {}; window.bar = {}; // These don't window.uid = {}; window.test = {}; The output is: window.a = {}; window.b = {}; window.uid = {}; window.test = {}; Why does it rename : window.foo = {}; window.bar = {}; But not:

How to analyze Closure Compiler bundle size

∥☆過路亽.° 提交于 2019-12-01 18:47:59
I have an app in ClojureScript, which uses Google's Closure Compiler as a compiler backend. The resulting bundle using advanced optimizations seems way too big for what it is. I blame the dependencies but how do I find out which modules are taking the most bytes in the output bundle? I scanned through all the Closure Compiler options and didn't find anything useful. Then I tried to learn about source maps and use that to calculate individual module size but with no success. I would like a tree-like output where I can dig in and find the biggest modules in terms of size, eg. [+] goog 100kb [+]

Google Closure Compiler parse error: invalid property id for `css({float:'left'})`

岁酱吖の 提交于 2019-12-01 17:14:02
问题 I'm using Google Closure Compiler application (command line interface). When I run it I get the below error. deploy/js/Home.js:40: ERROR - Parse error. invalid property id this.$images.wrapAll('<div id="slideInner"></div>').css({float:'left'}); ^ 1 error(s), 0 warning(s) 回答1: I believe that you need to do: {'float':'left'} This is because float is on the list of Java keywords reserved by JavaScript, so it cannot be used as a property name. This may no longer be an issue in newer JS engines,

Purpose of (0, obj.method)(param1, param2) in Closure Compiler minified code

ぃ、小莉子 提交于 2019-12-01 16:37:40
问题 What is this approach for? For instance, from the Google OAuth API: (0, _.Q)("gapi.auth.authorize", _.Ek.Ff); (0, _.Q)("gapi.auth.checkSessionState", _.Ek.MH); (0, _.Q)("gapi.auth.getAuthHeaderValueForFirstParty", _.Ek.Qe); (0, _.Q)("gapi.auth.getToken", _.Ek.$f); (0, _.Q)("gapi.auth.getVersionInfo", _.Ek.Wk); (0, _.Q)("gapi.auth.init", _.Ek.gb); (0, _.Q)("gapi.auth.setToken", _.Ek.Ym); To me, this would seem to be identical to simply outputting _.Q("gapi.auth.authorize", _.Ek.Ff); _.Q("gapi

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

核能气质少年 提交于 2019-12-01 14:24:35
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, except that it's inlining my local functions. Is there any way around this? For example, is there a