Open sgammon opened 3 years ago
there appears to (maybe) be a builtin google that I cannot re-define
Could you reproduce the issue without rules_closure and file a bug with Closure Compiler?
a warning from JSC that I cannot suppress
IIRC, rules_closure doesn't let you suppress, and I'm not sure what criteria used there but this warning sounds something that you don't want to suppress.
I had the same issue today and even that the cause of the problem was not found, the solution was to use --env=CUSTOM
for the compiler, so the default externs are disabled. Then adding only the externs that were needed.
Here is the valuable issue #81 that gave me the hint for this solution.
When trying to use Google Maps externs, I get some very strange behavior that doesn't seem to have a remedy except for a bug fix.
consider the following property initializer in an arbitrary JS class and accompanying Bazel targets:
WORKSPACE
:BUILD.bazel
:some-thing.js
:simple, right? however, Closure Compiler fails to recognize the symbols as externs:
Diagnosis
Okay, so, let's start in the extern (
google_maps_api_v3_43.js
).google_maps_api_v3_43.js:4845
:So it's in the extern. So maybe the extern isn't getting loaded by
rules_closure
/JsChecker
? Let's check:So it's making it into the build ☹️
To make matters even more interesting, with the Firebase externs, I had to change the
firebase = {};
@namespace
toconst =
for it to work:firebase-externs.js
:No idea why, and I'm still suspicious of this change (i.e. maybe it just busted a build cache somewhere), but changing
var =
toconst =
fixed my extern issues with Firebase. Trying that with Google Maps wasn't fruitful:google_maps_api_v3_43.js:4845
:Yields:
This is already weird because I don't have a
google =
anywhere in my code (in an extern or otherwise). As far as I can tell, none of my upstream dependencies do, either. But if I add that suppression:Going back to our Google Maps sample, what's even more interesting is, it will find certain symbols in the gmaps extern, for instance:
google.maps.LatLng
google.maps.Point
google.maps.Map
(it seems to find this sometimes)So, I'm stuck at this point, because (1) there appears to (maybe) be a builtin
google
that I cannot re-define, because of (2) a warning from JSC that I cannot suppress or (3) perhaps an inability to re-declare this namespace for my use.Any ideas? Is anyone else experiencing the same thing?