google-closure-compiler

How to analyze Closure Compiler bundle size

时光怂恿深爱的人放手 提交于 2020-01-11 09:20:07
问题 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

Debugging Closure-compiler Compiled Javascript

人走茶凉 提交于 2020-01-11 05:46:09
问题 I have a complex dojo app that works correctly uncompiled, but after compiling with Google's Closure Compiler, I get subtle differences in some behaviours. As it is, it's exceedingly difficult to debug, and I've been unable to find any information about possible functional differences between compiled and uncompiled Javascript with Google Closure. Can anyone point me in the direction of known differences, or share any similar experiences and some ideas of where to start looking? 回答1: General

Google Closure and generated getters/setters

只谈情不闲聊 提交于 2020-01-04 02:34:07
问题 I'm trying to get KineticJS to work with Google Closure Compiler. KineticJS, however, generated it's getters & setters based on the name of the variables. Something like this: // add getter and setter methods Kinetic.Node.addSetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addSetter(constructor, attr); } }; Kinetic.Node.addGetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addGetter

Google Closure and generated getters/setters

谁说我不能喝 提交于 2020-01-04 02:34:06
问题 I'm trying to get KineticJS to work with Google Closure Compiler. KineticJS, however, generated it's getters & setters based on the name of the variables. Something like this: // add getter and setter methods Kinetic.Node.addSetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addSetter(constructor, attr); } }; Kinetic.Node.addGetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addGetter

Google Closure Compiler, how to handle JSC_INEXISTENT_PROPERTY gracefully?

十年热恋 提交于 2020-01-02 11:00:19
问题 I'm using a design pattern that uses the return statement to expose public class methods. Problem is: I'm getting a lot of JSC_INEXISTENT_PROPERTY warnings in Closure Compiler's Advanced mode, which makes it difficult to check the warnings that actually matter. Example of the pattern I use: // ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // ==/ClosureCompiler== /** * @constructor */ var MyClass = function() { var someFunc = function(myString) { console.log(myString); }

Google Closure Compiler: How to preserve code that caches “this”?

六眼飞鱼酱① 提交于 2020-01-02 08:03:51
问题 Introduction I use Google Closure Compiler frequently for compressing my JavaScript files. Now, it seems to compress my code fairly well. Now, I try to make a habit of storing the this object in a local variable, because this cannot be obfuscated, but a local variable certainly can be obfuscated. However, Google Closure Compiler does not recognize this, and instead removes all instances of the local variable, replacing it with this . Regarding optimization... I am well aware that one should

How to auto-generate externs for the Google Closure Compiler

﹥>﹥吖頭↗ 提交于 2020-01-01 04:30:08
问题 Suppose you are working in a javascript project with several external library dependencies, and want to compile your sources using the Google Closure Compiler in ADVANCED_OPTIMIZATIONS mode. Since in this mode the compiler will rename your code calls to the external libraries objects and functions, you must provide externs, to prevent this renaming from happening. But, it is a lot of work to produce the externs by hand, so, what is the best way to auto-generate the appropriate extern from a

Use closure compiler to remove unused parts of jQuery

老子叫甜甜 提交于 2019-12-29 08:29:09
问题 Is it possible to use the closure compiler to remove unused parts of jQuery? I have a script which only uses jQuery's networking (json) functions, and I'd like a minified script which removes everything else. I've tried invoking it with: java -jar compiler.jar --compilation_level=ADVANCED_OPTIMIZATIONS --js=jquery-latest.js --js=my_script.js --js_output_file=out.js But I end up with a file no smaller than the regular minified jQuery source. Edit: I should mention the reason behind this. This

“dangerous use of the global this object” warning in Google Closure Compiler

纵然是瞬间 提交于 2019-12-29 08:08:13
问题 I have some code that looks like this: var MyObject = function () { this.Prop1 = ""; this.Prop2 = []; this.Prop3 = {}; this.Prop4 = 0; } And then I later have this: var SomeObject = new MyObject(); When I run my code through closure compiler in advanced mode, I'm getting the warning dangerous use of the global this object on every line where I have this.Prop = What am I doing that's "dangerous" and how should I rewrite my code? Thanks for your suggestions. 回答1: I would recommend writing it

How do you define node_modules as externs in Closure Compiler?

帅比萌擦擦* 提交于 2019-12-28 13:35:53
问题 I have a Node.js project that I want to compile with Closure Compiler. I do not want it to run in the browser/use browserify. I mainly want the utility of type checking. I originally got the compiler to work correctly using the following: java -jar compiler.jar -W VERBOSE --language_in ECMASCRIPT5_STRICT --externs closure-externs.js --js="lib/**.js" Where closure-externs.js manually defined variables and functions which I was using from Node.js in a rather crude way: // closure-externs.js /**