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
Creating this issue so someone with more closure compiler experience might be able to help. Or gather information we have.
The issue is to keep devices code readable and maintainable, registers and constant values should not go directly into the code, but kept in separate objects like var C = { ... }. Looks like previously Closure Compiler inlined these constant, but now it doesn't. And if you define long & readable constant names, that can use up quite some variables.
Might worth investigating, and possibly pulling in a specific version, if we can find one that does more aggressive inlining.
Advanced mode I think is pretty much out of question for modules, because it removes and renames too much. Did some fiddling with annotations and advanced optimizations, but no luck. Might work for final application, but didn't try that.
Example
An example using the BME280 as base. The constant is inlined. One thing I noticed is if I add another const, and use it in the constructor, C is no longer inlined. Even if you explicitly tell the compiler it's const.
/** @const */constC={/** @const */BME280_ADDRESS: 0x76,/** @const */BLA: 123}...// in ctor:constt_sb=5+C.BLA;//The funny thing is, you can calculate this value at "compile time"// minified (˙C` is renamed to `g`):a=5+g.BLA<<5|0;
But if I use the same constant in the exports.connect function it's inlined. Even without explicitly telling the compiler that it's a constant:
varC={BME280_ADDRESS: 0x76,BLA: 123}...// in exports.connecti2c.writeTo(addr,reg+C.BLA);// minified (123 is inlined):a.writeTo(b,c+123)
Creating this issue so someone with more closure compiler experience might be able to help. Or gather information we have.
The issue is to keep devices code readable and maintainable, registers and constant values should not go directly into the code, but kept in separate objects like
var C = { ... }
. Looks like previously Closure Compiler inlined these constant, but now it doesn't. And if you define long & readable constant names, that can use up quite some variables.Might worth investigating, and possibly pulling in a specific version, if we can find one that does more aggressive inlining.
Advanced mode I think is pretty much out of question for modules, because it removes and renames too much. Did some fiddling with annotations and advanced optimizations, but no luck. Might work for final application, but didn't try that.
Example
An example using the BME280 as base. The constant is inlined. One thing I noticed is if I add another const, and use it in the constructor,
C
is no longer inlined. Even if you explicitly tell the compiler it'sconst
.But if I use the same constant in the exports.connect function it's inlined. Even without explicitly telling the compiler that it's a constant:
No idea why does it work this way..
The two code samples here
Closure compiler online
The text was updated successfully, but these errors were encountered: