Fork me on GitHub

i’m trying to use some javascript game libraries from clojurescript. i have a simple shadow-cljs project, and an npm install of, and I’ve successfully been able use it to draw sprites. now i’m trying to use, but when i require that library it’s namespace is empty. how do i debug this issue?


Shadow-cljs documentation has a table on how to convert JS requires into CLJS requires. Have you tried other ways of requiring the second library?


this is where my javascript knowledge shows gaps. i’m looking at , and i’ve tried a require as both ["gamecontroller.js" :as gcjs] and ["gamecontroller.js" :refer (gameControl)], but gcjs is an empty map in the first case, and gameControl is undefined in the second case.


> but gcjs is an empty map in the first case This seems very wrong. Open up gamecontroller.js and see how it actually exports things.


If the contents of this file here are the same as what you have locally, then I think the author of the library didn't export it correctly.


Same with the minified version - it just modifies window instead of exporting stuff. You can try to access it in your code as (.-gameControl js/window) after you require that library. But it's still not great.


yeah, that’s the one.


awesome.. that worked. and i see that now—the gameControl.init() adds event handlers to window and doesn’t actually create anything.


thanks for your help @U2FRKM4TW

👍 3