google-closure-compiler

How to force google closure compiler to keep “use strict”; in the compiled js code?

孤者浪人 提交于 2019-11-30 11:21:18
问题 If you're using the module pattern and have something like this: (function () { "use strict"; // this function is strict... }()); and compile the code using the Google Closure Compiler, the "use strict"; directive will not make it into the compiled file. So how do you prevent the Closure Compiler from removing the ES5/strict directive? (Note that I don't want to use the other mode of enforcing ES5/strict mode, which is to simply add the "use strict"; to the first line of the compiled file. I

My source-mapped breakpoints aren't working correctly in Google Chrome

时光总嘲笑我的痴心妄想 提交于 2019-11-30 08:01:33
I have created a concatenated, minified file through the Node.js wrapper for Google Closure Compiler . When I open the Developer Tools in Google Chrome, both the source map and the mapped files all load appropriately. A problem I'm having is that breakpoints aren't triggering in the source map files like they would running an unminified, separate-file session. Sometimes I'll try to place a breakpoint in a script and it will jump several lines down rather than where I'm trying to set it. But what is most frustrating is that when I can set a breakpoint, they aren't triggered! I'll set one in the

Google Closure Compiler 100% typed

夙愿已清 提交于 2019-11-30 02:20:27
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% kayahr 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.google.com/p/closure-compiler/ Edit src/com/google/javascript/jscomp/CompilerOptions.java and change

How to force google closure compiler to keep “use strict”; in the compiled js code?

孤街醉人 提交于 2019-11-29 23:54:08
If you're using the module pattern and have something like this: (function () { "use strict"; // this function is strict... }()); and compile the code using the Google Closure Compiler, the "use strict"; directive will not make it into the compiled file. So how do you prevent the Closure Compiler from removing the ES5/strict directive? (Note that I don't want to use the other mode of enforcing ES5/strict mode, which is to simply add the "use strict"; to the first line of the compiled file. I want to use the module pattern as described here .) This isn't the greatest answer, but as far as I can

Using Google Closure compiler [duplicate]

你说的曾经没有我的故事 提交于 2019-11-29 20:05:35
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: jQuery compiled with Google Closure Compiler I am using jQuery and I have all of my JS code in application.js file. When I compile "application.js" with the Google Closure compiler (using the advance options) I get a js file with no errors and warning. However, I am unable to use the file in my page, I get an error on page load which says "TypeError: Result of expression '$("div.tile").d' [undefined] is not a

Javascript minification of comparison statements

十年热恋 提交于 2019-11-29 14:12:13
I was looking over one of the minified js files generated by closure. I found that wherever I'm checking for equality between a variable and string like, a == "13" || a == "40" closure replaces it with "13" == a || "40" == a Why is this modification done? Is there some performance advantage here? [UPDATE: See @John's answer, it makes more sense as to why a js minifier would do this, and should be the accepted answer] As a general concept, this is to avoid programmer error. If you were modifying the code manually and put the variable first and constant second, it's possible to accidentally type

Use closure compiler to remove unused parts of jQuery

落花浮王杯 提交于 2019-11-29 13:22:07
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 script is going to be included in 3rd party websites, and it requires a later version of jQuery (1.5 or

My source-mapped breakpoints aren't working correctly in Google Chrome

无人久伴 提交于 2019-11-29 10:57:54
问题 I have created a concatenated, minified file through the Node.js wrapper for Google Closure Compiler. When I open the Developer Tools in Google Chrome, both the source map and the mapped files all load appropriately. A problem I'm having is that breakpoints aren't triggering in the source map files like they would running an unminified, separate-file session. Sometimes I'll try to place a breakpoint in a script and it will jump several lines down rather than where I'm trying to set it. But

Internet Explorer, Closure Compiler and Trailing Commas

蓝咒 提交于 2019-11-29 10:52:26
I'm using html5boilerplate build script and when minifying the scripts (which uses Google Closure Compiler) I'm getting this error -js.all.minify: [echo] Minifying scripts [copy] Copying 3 files to /Users/Username/Desktop/Web/intermediate/js [apply] /Users/Juan/Desktop/Web/js/plugins.js:117: ERROR - Parse error. Internet Explorer has a non-standard intepretation of trailing commas. Arrays will have the wrong length and objects will not parse at all. [apply] }, { duration: 727 }) [apply] ^ But the code DOES work in IE 8 if run uncompiled. This is the code anim1.animate({ 'left': '+=32px',

How do you define node_modules as externs in Closure Compiler?

那年仲夏 提交于 2019-11-28 23:40:25
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 /** @constructor */function Buffer(something){} function require(path){} var process = {}; [...] It turns