You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After generating markdown.js from gopherjs, then I run the closure compiler on it. There are a bunch of warnings about unreachable code which I ignored, but 2 errors look like they could be problematic, and result in closure compiler not producing output.
Aside: it looks like closure -O ADVANCED will compress a 3MB gopherjs generated javascript file down to 1.6MB (minified and dead-code elimination done); once I manually removed the commas--nice to know.
run:
bash-3.2$ java -jar ./build/compiler.jar < markdown.js > markdown-minified.js
The compiler is waiting for input via stdin.
stdin:320: ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
set: function(value) { obj[fieldProp] = value; },
^
stdin:1528: ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
},
^
2 error(s), 0 warning(s)
bash-3.2$
the errors detected are here:
var $pointerOfStructConversion = function(obj, type) {
if(obj.$proxies === undefined) {
obj.$proxies = {};
obj.$proxies[obj.constructor.string] = obj;
}
var proxy = obj.$proxies[type.string];
if (proxy === undefined) {
var properties = {};
for (var i = 0; i < type.elem.fields.length; i++) {
(function(fieldProp) {
properties[fieldProp] = {
get: function() { return obj[fieldProp]; },
set: function(value) { obj[fieldProp] = value; }, /////<<< line 320, has extra comma at end
};
})(type.elem.fields[i].prop);
}
proxy = Object.create(type.prototype, properties);
proxy.$val = proxy;
obj.$proxies[type.string] = proxy;
proxy.$proxies = obj.$proxies;
}
return proxy;
};
var $send = function(chan, value) {
if (chan.$closed) {
$throwRuntimeError("send on closed channel");
}
var queuedRecv = chan.$recvQueue.shift();
if (queuedRecv !== undefined) {
queuedRecv([value, true]);
return;
}
if (chan.$buffer.length < chan.$capacity) {
chan.$buffer.push(value);
return;
}
var thisGoroutine = $curGoroutine;
chan.$sendQueue.push(function() {
$schedule(thisGoroutine);
return value;
});
$block();
return {
$blk: function() {
if (chan.$closed) {
$throwRuntimeError("send on closed channel");
}
}, /////<<<< line 1528, extra comma at end
};
};
The text was updated successfully, but these errors were encountered:
GopherJS knows more about the code than the closure compiler can ever know (because of JS' dynamic nature). In theory, the minification that GopherJS can perform is always better than the closure compiler. If you can get the closure compiler to reduce the size of the output without breaking any functionality, then I'll be happy to build such optimization into GopherJS itself. Hint: It's very likely that the closue compiler will break reflection (see #186).
@neelance: thanks, and good point about reflection. I don't think there's more to do here that isn't discussed more extensively in #186, so I'll close this.
google's closure javascript compiler (https://developers.google.com/closure/compiler/) detects some extra trailing commas in the javascript generated by gopherjs.
I tried closure out on Dmitri's live-refreshing markdown code; http://dmitri.shuralyov.com/projects/live-markdown/markdown.go. (Btw this is a very cool project.)
After generating markdown.js from gopherjs, then I run the closure compiler on it. There are a bunch of warnings about unreachable code which I ignored, but 2 errors look like they could be problematic, and result in closure compiler not producing output.
Aside: it looks like closure -O ADVANCED will compress a 3MB gopherjs generated javascript file down to 1.6MB (minified and dead-code elimination done); once I manually removed the commas--nice to know.
run:
the errors detected are here:
The text was updated successfully, but these errors were encountered: