Fork me on GitHub

I'm hitting an error in attempting to compile a hello-world browser app that does (ns (:require [firebase])) with :npm-deps {:firebase "5.7.3"} :optimizations :simple :language-in :es6:

SEVERE: /Users/thomas/Develop/cljs/cljs-node-example/out/node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:4: ERROR - Module scoped variables named 'goog' must come from importing Closure Library's goog.js file..
var commonjsGlobal=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};var e;var goog=goog||{};var h=commonjsGlobal;function l(a){return"string"==typeof a}function m(a,b){a=a.split(".");b=b||h;for(var c=0;c<a.length;c++)if(b=b[a[c]],null==b)return null;return b}function aa(){}function ba(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var;if("[object Window]"==
It appears that this is related to an open Closure issue, which dnolen has already commented on. It's unclear to me whether this is fixed or not, or if there's a work around?


If I understand it correctly, which would be barely if that, the wiki mentioned in that issue suggests that the following might work:

// CommonJS import of ES6 module
var Foo = require('/path/to/es6/module/foo').default;
Is this relevant to my error?


@thosmos no. :npm-deps just can't process the firebase stuff on npm since it is a compiled version of closure code


that confuses the compiler as it thinks it is getting uncompiled code


firebase probably just isn't compatible with npm-deps


Is this a CLJS compiler issue? In other words, do I understand correctly that if the CLJS compiler knew that it was compiled closure code, that it could just load it, or create a load function for it, rather than attempting to recompile it?


probably not no. its a bit more complicated than that 😉


oh I think I'm beginning to see, it's because it's already been compiled with advanced compilation, whereas npm-deps is attempting to load uncompiled modules in order to compile them into the same build, do DCE, etc?


npm-deps will attempt to read the JS files and convert them into a format it can read


it looks like it finds a goog reference which is "reserved" for the closure library


thanks for the tips, I'll keep reading and will hopefully understand it better soon


Honestly don't waste your time with :npm-deps, it is too unreliable at this point. Use the recommended webpack approach or shadow-cljs and save your sanity 😉

💯 1

Agree w/ the the above, I use npm-deps only with cljs-test-runner and there are all sort of quirks


Well, maybe once I understand it better I'll be able to offer some help in making it better


@richiardiandrea are the quirks documented somewhere that I can see?


Well I don't know, maybe Jiras? the symptoms usually though are that the compiler cannot find a namespace associated with the XYZ npm package


FWIW I think most of the issues are actually Closure Compiler issues. There isn't much you can control from the CLJ(S) side in this regard.


I am not entirely expert in this but the problem I am specifically talking about is that sometimes Cljs cannot "discover" npm packages easily - I guess show has this covered because of the different way it analyzer npm packages...I remember a Thomas blog post on this