I prepare three files:
java -jar compiler.jar --js=utf8.js --js_output_file=utf8-advanced.js --charset=utf8 --compilation_level=ADVANCED_OPTIMIZATIONS --formatting=SINGLE_QUOTES --formatting=PRETTY_PRINT --externs=externs.js --use_only_custom_externs
Javascript:
window.erest['module'] = window.erest['module'] || {};
window.erest.module = window.erest['module'];
var module = window.erest.module;
window.erest.module.hello = function() {
for (var i = 0; i < 5; i++) {
window.erest.debug.hello();
}
}
window.erest.module.max = function() {
var list = [];
for (var i = 0; i < list.length; i++) {
window.erest.debug.hello();
}
}
window.erest.module.maximum = function() {
window.erest.debug.hello();
}
Externs:
/**
* @externs
*/
/**
* @noalias
*/
var erest = {};
erest.debug = {};
/**
* @return null
*/
erest.debug.hello = function () {};
Output:
window.a.module = window.a.module || {};
window.a.b = window.a.module;
window.a.b.hello = function() {
for (var b = 0;5 > b;b++) {
window.a.debug.hello();
}
};
window.a.b.max = function() {
for (var b = [], c = 0;c < b.length;c++) {
window.a.debug.hello();
}
};
window.a.b.c = function() {
window.a.debug.hello();
};
Question - why externs not works here:
window.a.debug.hello() should be window.erest.debug.hello()
Why this extern not help:
var erest = {};