bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 116 forks source link

CLJS build problems with devcards-0.2.1-4 as a dependency #92

Closed samroberton closed 8 years ago

samroberton commented 8 years ago

I should preface this with: this is unlikely to be your fault, but I'm raising an issue here because I have no idea what's causing this problem, and perhaps you might -- or perhaps it might help you to know that I'm having the issue, in case someone else has something similar.

I have a boot project which uses Devcards (as a :scope "provided" dependency). With devcards-0.2.1-3, I'm fine. With devcards-0.2.1-4, CLJS :optimizations :advanced builds produce a JS file which appears to include React and ReactDOM, but which fails to include any other dependencies, and doesn't even include my own code (there's not a single reference to any of the namespaces my CLJS code exports). All the other dependencies, and my code, are built as per normal their various dependencies in <stuff>.out, but it's as if Google Closure is deciding that the entirety of my codebase is dead code.

It's a complex project, so I haven't boiled down a minimally reproducible case, I'm afraid. I have, however, verified that the single character change from 4 back to 3 in the Devcards version number fixes the problem (and that changing that single digit back again causes it to resurface again). There is perhaps one unusual aspect to my build setup: I include Devcards in my production build, not just in my development one. (Don't imagine that's causing the problem, but hey, more information is better than less...)

I'll see if I can pin down some more information for you -- a minimally reproducible case, for example -- over the next few days. But I'll be honest: I have a busy week coming up, and I don't want to promise anything.

bhauman commented 8 years ago

I looked at the commits and the only thing hat I think could cause this problem is this one https://github.com/bhauman/devcards/commit/c1da65eced5c2a3c1bf7375d58924b397c645c7b Bumping he sablono dep and explicitly requiring react is probably what is causing this. No idea why.

samroberton commented 8 years ago

Some follow-up... I managed to get myself into a state today where an :optimizations :none build was complaining in the browser that js/React wasn't defined. It turned out I'd removed a (:require cljsjs.react), in order to allow a namespace to be reused in a React Native build.

I think the Sablono dep made a difference in this original issue because sablono.core was possibly the only namespace in my whole set of code + dependencies that actually called (:require cljsjs.react). As of version 0.6.0+ of Sablono, sablono.core no longer requires React (only sablono.interpreter does).

So today's symptom was different, but it's quite possible that in this original issue, the Closure compiler was deciding that there was nothing in my entire codebase that actually did anything other than make a function call to this js/React variable which it had no reason to believe existed. My whole codebase may just have been whole-program-optimised to "undefined is not a function".

Anyway, that's the best theory I've got. I thought I'd already thanked you for your reply before, but apparently I didn't, so: thanks very much for looking into this, and for the helpful tip. I'm closing this since I doubt it's useful to you or me or anyone at this point -- I don't think there's any bug to fix in Devcards, and I don't think there's any important lesson to be learned or anything that needs documenting. (Obviously feel free to re-open it if this is something you wanted to keep on your radar in case a better explanation turns up.)

Thanks again for your help, and of course for Devcards: it's made my day-to-day life as a programmer immensely better.