google-closure-compiler

Google closure variable window/event/console/… is undeclared error

◇◆丶佛笑我妖孽 提交于 2019-12-07 07:41:46
问题 I'm trying to compile one of my HTML5 project using Google Closure. I'm recieving several errors that I don't know how to solve. In fact, it's the same error but for different variables. Here the errors messages: variable window is undeclared variable event is undeclared variable console is undeclared variable Audio is undeclared These variables are Javascript built-in variables. If I compile this same project directly in command-line, it works. But, in my case, I need to compile this project

Details on returning an object literal from a closure in JavaScript

左心房为你撑大大i 提交于 2019-12-07 06:57:54
问题 Background : I want to rewrite a library (which I did not write) to avoid having the Closure Compiler generate warnings with the advanced option. Per this question JavaScript “this” keyword and Closure Compiler warnings the answer was to rewrite the code using a closure. The intent is to avoid using the keyword this (which generates the compiler warnings). As the library has a number of functions, I though it would be best for the new closure to return an object literal. I want to understand

ignore compiler warning from one file in Google Closure

拈花ヽ惹草 提交于 2019-12-07 02:15:37
问题 I'm using an external library (Phonegap) in a fairly large Closure project. Unfortunately Phonegap generates a ton was compiler warnings (all "dangerous use of this"). Enough that it makes searching through the compiler output for warning about my own code pretty annoying. Is there a way to silence just the warnings from one file? 回答1: I suppose you mean type warnings when you are using VERBOSE or checkTypes. Put the following into any file: /** * @fileoverview * @suppress {checkTypes} */ to

Exposing dynamically created functions on objects with closure compiler

徘徊边缘 提交于 2019-12-06 22:01:38
I am trying to annotate my javascript so that closure doesnt rename all the symbols since i am working with vanilla javascript as well. /** * @constructor * @expose * @type{foo} */ foo = function (el, args) { "use strict"; var s = "Hello World"; /* * @expose * @this {foo} * @type {function} */ this.introduce = function () { return s; }; }; However the generated output when i run it through the closure compiler with advanced optimization is foo = function() { this.a = function() { return"Hello World" } }; How do i ask closure to preserve the name introduce since this will be called from an

Javascript Module pattern, Prototype and Google Closure

两盒软妹~` 提交于 2019-12-06 14:07:23
I am having trouble getting this code structure to survive obfuscation with the Google Closure Compiler. Here's some sample code: var MyModule = (function() { function myModule() { // Constructor } function moduleFoo(url) { // Method } function moduleBar() { // Method } myModule.prototype = { constructor: myModule, foo: moduleFoo, bar: moduleBar }; return myModule; })(); Elsewhere in my code I need be able to write things like the following: var myMod = new MyModule(); myMod.foo(); myMod.bar(); However the compiler is renaming everything (as expected). How can I make the prototype that I have

compress all js in a folder to new folder useing google closure compiler?

余生长醉 提交于 2019-12-06 11:52:24
问题 how can i compress all my js in a folder to a new folder ? i have search around google and stackoverflow, what i found is just Compress all file .js with Google Closure Compiler Application in one File that puting it all to one.. + can we put a wildcard or something? so i can do something like java -jar bin/compiler.jar ../../path/my/*.js --js_output_file ../../path/new/*.js thanks for looking in Adam Ramadhan 回答1: Bash scripting to the rescue. Something like files=`find ../../path/my -name "

Use Closure Compiler with AngularJS in ADVANCED_MODE

久未见 提交于 2019-12-06 10:05:27
I'm trying to compile one of our angular & openLayers project but I'm not able to use Angular. I've put the angular external parameter, but after compiling i get this error : Error: [$injector:unpr] Unknown provider: aProvider <- a <- myCtrl http://errors.angularjs.org/1.3.15/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20myCtrl at REGEX_STRING_REGEXP (angular.js:63) at angular.js:4015 at Object.getService [as get] (angular.js:4162) at angular.js:4020 at getService (angular.js:4162) at Object.invoke (angular.js:4194) at $get.extend.instance (angular.js:8493) at angular.js:7739 at forEach

Google Closure Compiler, how to handle JSC_INEXISTENT_PROPERTY gracefully?

孤人 提交于 2019-12-06 09:38:16
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); } return { myPublicFunc: someFunc }; } var myClassInstance = new MyClass(); myClassInstance.myPublicFunc(

How can I easily maintain a cross-file JavaScript Library Development Environment

送分小仙女□ 提交于 2019-12-06 05:44:22
问题 I have been developing a new JavaScript application which is rapidly growing in size. My entire JavaScript Application has been encapsulated inside a single function, in a single file, in a way like this: (function(){ var uniqueApplication = window.uniqueApplication = function(opts){ if (opts.featureOne) { this.featureOne = new featureOne(opts.featureOne); } if (opts.featureTwo) { this.featureTwo = new featureTwo(opts.featureTwo); } if (opts.featureThree) { this.featureThree = new

Closure Compiler issues warning with namespaced enum

穿精又带淫゛_ 提交于 2019-12-06 02:56:27
The following sample code generates a compiler warning on advanced optimization: "JSC_UNSAFE_NAMESPACE: incomplete alias created for namespace NS". If I remove the @enum comment, it doesn't give the warning. var NS = {}; /** * @enum {string} */ NS.type = { FOO : 'bar' }; NS.foobar = function(){ alert(NS.type.FOO); }; window['NS'] = NS; window['NS']['foobar'] = NS.foobar; Exporting only the function and not the namespace also seems to work: window['NS_foobar'] = NS.foobar; What am I doing wrong? Is there a way around this? I'd rather not include the Closure library if possible. The compiler