clojurescript-npm icon indicating copy to clipboard operation
clojurescript-npm copied to clipboard

Dependencies

Open nasser opened this issue 8 years ago • 11 comments

How do I declare and acquire ClojureScript dependencies from node? Do we implement project.clj and defproject? Something like we did in Arcadia?

nasser avatar May 22 '16 16:05 nasser

I'm got some code to recursively get dependencies for a given (group, artifact, version) tuple. I'm gonna expand on it in my free time.

I've taken some inspiration from the Arcadia code.

ducky427 avatar May 31 '16 11:05 ducky427

Awesome! I was looking at xml2json as well. Glad the Arcadia code could be helpful.

nasser avatar May 31 '16 15:05 nasser

All the async operations make the code slightly convoluted. But core.async atleast makes it possible without the callback hell.

I should have something which lets you download all the dependencies into a particular directory soon enough.

Just a thought: I think the biggest use case for this project beyond the cljs-repl could be to finally enabling cljs as a scripting language. so something like this but for clojurescript.

The issue with using leiningen etc is that you have to spin up a jvm and load Clojure which isn't a quick option whereas this would be as it would be using node.

ducky427 avatar May 31 '16 16:05 ducky427

I agree. The REPL is an important step, but my real goal is scripting and embedding in frameworks like electron. Startup time is better than the JVM, but we still have to parse the ~6Mb of javascript that is the cljs language, compiler, and standard library, so there's a ~1s hiccup when we load.

nasser avatar May 31 '16 16:05 nasser

good point. hmmm...

btw, I maintain a leiningen template which creates all the scaffolding required for an electron project. It is here. I've used it for a 10k+ loc project at work.

ducky427 avatar May 31 '16 18:05 ducky427

Nice! I've used https://github.com/Gonzih/cljs-electron in the past. I am just trying to get away from lein and generated scaffolding...

nasser avatar May 31 '16 19:05 nasser

I've updated my code to be able to fetch all the dependencies for a give project and download them into a given folder.

ducky427 avatar Jun 01 '16 10:06 ducky427

Amazing! I will check it when I get the chance.

nasser avatar Jun 01 '16 18:06 nasser

sweet. obviously this downloading code can be improved but it is just a start. Currently I am only downloading the jar and not checking for signatures etc. I'd like to implement that as well so that it is at par with leiningen and boot etc.

An idea I had for specifying the dependencies for the script is to specify them as comments on the top of the file. This way the file could be self contained. just an idea though.

ducky427 avatar Jun 01 '16 19:06 ducky427

that's a great idea, I'd like it if it's more like the grape type stuff you find in groovy http://docs.groovy-lang.org/latest/html/documentation/grape.html

maybe we can have a fn at the begging of the file that pulls of the dependencies before it executes

eginez avatar Sep 02 '16 23:09 eginez

Interesting precedent. Makes me think of F#'s #r and #I scripting stuff.

nasser avatar Sep 09 '16 22:09 nasser