google-closure-compiler

No exported symbols with es6 modules library compiled by Closure Compiler

不想你离开。 提交于 2019-12-11 07:00:48
问题 Starting point : Many js files are successfully compiled (no warning/error) by Closure Compiler (ADVANCED_OPTIMIZATIONS level) in a single library file. In these js files: goog.require and goog.provide are used to import/export things between them /** @export */ is used in front of whatever (const/function/Class/var) is required outside the library. Some HTML files include the library and some non compiled js accessing successfully to all whatever defined in this library. What I want: move to

Google closure compiler and UMD pattern

时间秒杀一切 提交于 2019-12-11 06:25:02
问题 I am developing a javascript library which uses closure compiler to combine/minify & typecheck. To avoid pouting global namespace I want to use UMD pattern & closue @export(or goog.exportSymbol('workspace', lkr.workspace) goog.provide('workspace'); goog.require('lkr.workspace'); /** * Exposed external access point * @export * @return {component} */ workspace = function() { return lkr.workspace.Core; } I have used an output-wrapper-file to generate the UMD wrapper //UMD bundling closure code

JSLint Weird assignment, required for closure compiler

回眸只為那壹抹淺笑 提交于 2019-12-11 05:29:14
问题 I'm using the closure compiler to minify and speed up my code but I'm running into some issues with JSLint when I try to export my functions. Basically, I have an object, foo{} with a function, foo.bar() that gets called via an external file as. In order for this function to be called externally I need to add some declarations to my script before it gets compiled: window['foo'] = foo; window['foo']['bar'] = foo.bar; This works great, but—as ever—JSLint thinks I'm mental for even attempting

How to rename property created by Object.defineProperty with GCC

徘徊边缘 提交于 2019-12-11 05:23:45
问题 I wish to rename object property in ADVANCED_OPTIMIZATIONS mode. Code before optimization: /** * @constructor */ function Container() { var items = []; Object.defineProperty(this, 'items', { set: function(value) { items = value; }, get: function() { return items; } }); } var container = new Container(); container.items = [1,2,3]; console.log(container.items); After optimization: var b = new function() { var a = []; Object.defineProperty(this, "items", {set:function(c) { a = c }, get:function(

Google Closure Compiler Includes

穿精又带淫゛_ 提交于 2019-12-11 03:04:55
问题 I've been using google closure compiler for a little bit with my projects, it's awesome! I've been trying to find out whether or not you can do "includes" in a javascript file that includes other javascript files. I'm trying to have 1 javascript file that "includes" all the files I need then compiles, much like you can do with a LESS import statement, ("@import "../less/bootstrap") for example. Is this possible? - Or do you have to provide the list of source files at time of compilation in

Google Closure Compiler type annotations for array

随声附和 提交于 2019-12-11 01:24:11
问题 While playing around with Google Closure Compiler, I found a case where I couldn't force the compiler to give a warning for a wrong variable type. I used the following sample: /** @typedef ({name: string, token: string}) */ var pendingItem; /** @type (Array.<pendingItem>) */ var pending = []; // NOTICE: the token is intentionally misspelled as "toke" to cause a warning var dummyItem = { name: 'NameHere', toke: 'SomeToken' }; // This should cause a warning, because of the // type mismatch

Closure Compiler warns “Bad type annotation. Unknown type …” when Ecmascript 6 class is extended

馋奶兔 提交于 2019-12-11 00:33:34
问题 I'm getting a warning for every Ecmascript 6 class that inherits from another class when compiling with Closure Compiler: I've dumbed things down as much as possible and still get the warning: /src/main/js/com/tm/dev/Dog.js: WARNING - Bad type annotation. Unknown type module$$src$main$js$com$tm$dev$Animal.default The compiled code does run correctly. (I've tried a number of annotations which only made things worse.) Anyone know what's expected here? Animal.js: export default class{

How to workaround renaming of object properties in Closure Compiler?

百般思念 提交于 2019-12-10 23:18:16
问题 I have a JS library that uses has something like the following method: this.on('doAction', function (args) { console.log(args.name); console.log(args.arg1 + ' ' 9 args.arg2); }); this.trigger('doAction', {name: 'write', arg1: 1, arg2: 2}); But after advanced optimization objects properties name , arg1 and arg2 will be a , b , c , so I can't get them in doAction handler. I know I can to use quotes for a property names to prevent it from changing, but is there any better approach like special

Why does Closure Compiler not shorten this?

霸气de小男生 提交于 2019-12-10 17:28:34
问题 I'm not sure whether this is just a bug or an intended feature. Basically, I have this tiny function (I now see end is colored blue here but this works just fine, if I rename it to something else I still have the issue): function f(a, b) { var start = Math.min(a, b); var end = Math.max(a, b); tb.selectionStart = start; tb.selectionEnd = end; }; When closure-compiling it, I get: function f(a,b){var c=Math.max(a,b);tb.selectionStart=Math.min(a,b);tb.selectionEnd=c}; However, why is

ECMASCRIPT 5 with wro4j and Google Closure Compiler

空扰寡人 提交于 2019-12-10 17:20:15
问题 We are using wro4j with Google Closure and Maven to minify our JS. By default it does not suport strict mode in the JS ("use strict";).. it just strips it out. Is there any configuration I can do in pom.xml or somewhere else to get it to leave use strict in there? This is the configuration for google closure complier to do it: --language_in=ECMASCRIPT5_STRICT Not sure how to plug that in to Wro4j. Any ideas? 回答1: Create a custom implementation of the manager factory which adds ECMAScript5: