David,
I've followed your advice and used `:target :nodejs`.

While testing my code with clojurescript.test I noticed that I was getting this 
error:

    [Error: cljs.core/*main-cli-fn* not set]

This didn't stop the tests from running though. So its just more like a 
warning. I guess I can `*main-cli-fn*` that to a trivial function. Is there any 
other to avoid doing that?

I see this coming up when you use `:target :nodejs` (and also `:hashbang 
false`) and use the generated code in something like atom-shell (now called 
electron).

Thanks for your help.

ducky

On Sunday, 26 April 2015 13:52:46 UTC+1, ducky  wrote:
> Thanks a lot for suggesting different approaches.
> 
> I'll give it a go and report back (with working code hopefully) on what 
> worked for me.
> 
> Thanks again
> 
> ducky
> 
> On Sunday, 26 April 2015 10:41:58 UTC+1, David Nolen  wrote:
> > You can do runtime feature detection as practiced by many JavaScript 
> > libraries. I would probably just use the provided `cljs.core/*target*` 
> > Closure define to make two different builds. You can check if this value is 
> > equal to the string "nodejs".
> > 
> > 
> > David
> > 
> > 
> > On Sun, Apr 26, 2015 at 10:44 AM, ducky <[email protected]> wrote:
> > Hello,
> > 
> > I am working on creating a library which interacts with a HTTP resource 
> > using Clojurescript. I want to have it work within a browser and node.js.
> > 
> > 
> > 
> > Does anyone have experience or an example showing how to target them both 
> > using a single code base?
> > 
> > 
> > 
> > The issue I have noticed that in the browser one can work with 
> > XMLHTTPRequest using goog.net.Xhrio or a clojurescript library like 
> > cljs-http. And in node.js, you are expected to work with the http module.
> > 
> > 
> > 
> > An option I have is to use XMLHttpRequest implemented using node's APIs. 
> > And then I have a common base. But I still don't know to target both in the 
> > same codebase. Having something like `(def http (js/require "http"))` is 
> > likely to produce an error in the browser.
> > 
> > 
> > 
> > So any practical help with this would be really appreciated. How to 
> > structure the code, builds, test etc.
> > 
> > 
> > 
> > Thanks!
> > 
> > 
> > 
> > ducky
> > 
> > 
> > 
> > --
> > 
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > 
> > ---
> > 
> > You received this message because you are subscribed to the Google Groups 
> > "ClojureScript" group.
> > 
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected].
> > 
> > To post to this group, send email to [email protected].
> > 
> > Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to