lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
richiardiandrea 2017-10-22T01:28:51.000102Z

@johnjelinek which scaffolding are you talking about exactly? Maybe I can help. You use javascript libraries transparently using npm install (or yarn) and then you require them in your code. Pretty much like JS.

johnjelinek 2017-10-22T20:18:41.000092Z

@richiardiandrea: ok, I think I'm able to answer this a little better now. I've translated some step definitions for cucumber-js from .js to .cljs, so my tree looks like this:

$ tree features

features
├── documentation.feature
├── step_definitions
│   ├── browser_steps.cljs
│   └── hooks.cljs
└── support
    └── world.cljs
so -- to build, I think I want to do something like this:
$ lumo -c features build.clj
but my out/ doesn't seem to have any of the transpiled .js step_definitions.

johnjelinek 2017-10-22T20:19:15.000075Z

because after it builds, I want to do something like:

./node_modules/.bin/cucumber-js out

richiardiandrea 2017-10-22T20:21:41.000058Z

So the compilation is not something that is done using the above lumo command: lumo was born as REPL and then added a compiler

johnjelinek 2017-10-22T20:22:01.000023Z

maybe my files aren't being transpiled in out because they don't have a namespace? ie: world.cljs

(js/require "chromedriver")
(def seleniumWebdriver (js/require "selenium-webdriver"))
(def defineSupportCode (.-defineSupportCode (js/require "cucumber")))

(defn custom-world []
  (this-as this
    (let [builder (new (.-Builder seleniumWebdriver))
          forBrowser (.forBrowser builder "chrome")]
      (set! (.-driver this) (.build forBrowser)))))

(defineSupportCode
  #(% ((.-setWorldConstructor %) custom-world)))

richiardiandrea 2017-10-22T20:22:18.000114Z

So yeah, they are not

richiardiandrea 2017-10-22T20:23:02.000085Z

In order to do that, you have to build: use lumo.build.api. There is no doc at the moment but you can easily follow the ClojureScript one

richiardiandrea 2017-10-22T20:23:09.000042Z

Let me fetch a link for you

johnjelinek 2017-10-22T20:23:49.000013Z

here's my build.clj:

(require 'lumo.build.api)

(lumo.build.api/build "features"
  {:output-to "out/main.js"
   :target :nodejs
   :optimizations :none
   :language-out :es6})

richiardiandrea 2017-10-22T20:24:24.000005Z

Oh ok cool

richiardiandrea 2017-10-22T20:25:16.000089Z

Sorry so the problem is elsewhere, why is it build.clj?

richiardiandrea 2017-10-22T20:25:25.000056Z

Usually those are macro files

richiardiandrea 2017-10-22T20:25:38.000067Z

I'd try build.cljs just to be sure

johnjelinek 2017-10-22T20:25:48.000003Z

I was following the cljs Quick Start ¯\(ツ)

johnjelinek 2017-10-22T20:27:25.000004Z

if I do the hello world example in the Quick Start (`hello-world.core`) and put a :main in build.clj, it transpiles it and I can run it in node/lumo

johnjelinek 2017-10-22T20:27:54.000060Z

so I'm thinking maybe I'm missing a namespace entry that allows it to transpile these files in features/

richiardiandrea 2017-10-22T20:29:32.000016Z

Uhm not sure that's an issue

johnjelinek 2017-10-22T20:33:32.000096Z

or maybe I need to do some kind of file-globbing reference to get it to pick up all the folders with .cljs files in it

richiardiandrea 2017-10-22T21:04:48.000028Z

No well the folder should be fine, if it contains .cljs files they should be picked up bugs aside. I would try the namespace thing just to be sure..

richiardiandrea 2017-10-22T01:29:31.000015Z

About Javascript interop, there is minimal syntax to learn, then after that you should be good

richiardiandrea 2017-10-22T01:30:03.000059Z

this can be of help: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/

johnjelinek 2017-10-22T02:06:42.000074Z

cool, I'll check it out -- right now I'm trying to translate some of the cucumber JS examples into CLJS and then I'll see if cucumber (CLI) can pick up the changes in my out directory

johnjelinek 2017-10-22T20:15:34.000077Z

correct me if I'm wrong, but lumo still requires the JDK to build, because of Boot, correct?

johnjelinek 2017-10-22T20:18:41.000092Z

@richiardiandrea: ok, I think I'm able to answer this a little better now. I've translated some step definitions for cucumber-js from .js to .cljs, so my tree looks like this:

$ tree features

features
├── documentation.feature
├── step_definitions
│   ├── browser_steps.cljs
│   └── hooks.cljs
└── support
    └── world.cljs
so -- to build, I think I want to do something like this:
$ lumo -c features build.clj
but my out/ doesn't seem to have any of the transpiled .js step_definitions.

johnjelinek 2017-10-22T20:19:15.000075Z

because after it builds, I want to do something like:

./node_modules/.bin/cucumber-js out

richiardiandrea 2017-10-22T20:21:41.000058Z

So the compilation is not something that is done using the above lumo command: lumo was born as REPL and then added a compiler

johnjelinek 2017-10-22T20:22:01.000023Z

maybe my files aren't being transpiled in out because they don't have a namespace? ie: world.cljs

(js/require "chromedriver")
(def seleniumWebdriver (js/require "selenium-webdriver"))
(def defineSupportCode (.-defineSupportCode (js/require "cucumber")))

(defn custom-world []
  (this-as this
    (let [builder (new (.-Builder seleniumWebdriver))
          forBrowser (.forBrowser builder "chrome")]
      (set! (.-driver this) (.build forBrowser)))))

(defineSupportCode
  #(% ((.-setWorldConstructor %) custom-world)))

richiardiandrea 2017-10-22T20:22:18.000114Z

So yeah, they are not

richiardiandrea 2017-10-22T20:23:02.000085Z

In order to do that, you have to build: use lumo.build.api. There is no doc at the moment but you can easily follow the ClojureScript one

richiardiandrea 2017-10-22T20:23:09.000042Z

Let me fetch a link for you

johnjelinek 2017-10-22T20:23:49.000013Z

here's my build.clj:

(require 'lumo.build.api)

(lumo.build.api/build "features"
  {:output-to "out/main.js"
   :target :nodejs
   :optimizations :none
   :language-out :es6})

richiardiandrea 2017-10-22T20:24:24.000005Z

Oh ok cool

richiardiandrea 2017-10-22T20:25:16.000089Z

Sorry so the problem is elsewhere, why is it build.clj?

richiardiandrea 2017-10-22T20:25:25.000056Z

Usually those are macro files

richiardiandrea 2017-10-22T20:25:38.000067Z

I'd try build.cljs just to be sure

johnjelinek 2017-10-22T20:25:48.000003Z

I was following the cljs Quick Start ¯\(ツ)

johnjelinek 2017-10-22T20:27:25.000004Z

if I do the hello world example in the Quick Start (`hello-world.core`) and put a :main in build.clj, it transpiles it and I can run it in node/lumo

johnjelinek 2017-10-22T20:27:54.000060Z

so I'm thinking maybe I'm missing a namespace entry that allows it to transpile these files in features/

richiardiandrea 2017-10-22T20:29:32.000016Z

Uhm not sure that's an issue

pesterhazy 2017-10-22T20:31:03.000015Z

to build lumo itself, yes

johnjelinek 2017-10-22T20:33:32.000096Z

or maybe I need to do some kind of file-globbing reference to get it to pick up all the folders with .cljs files in it

johnjelinek 2017-10-22T20:34:18.000035Z

it'd be pretty cool to have Boot written in cljs as well so there's only a dependency on a single node runtime

pesterhazy 2017-10-22T20:35:30.000004Z

IMHO doesn't seem worth it just for the convenience of people interested in hacking on lumo itself

johnjelinek 2017-10-22T20:39:00.000026Z

ya, but it sure would give me some boilerplate for my own non-JDK cljs project

richiardiandrea 2017-10-22T21:04:48.000028Z

No well the folder should be fine, if it contains .cljs files they should be picked up bugs aside. I would try the namespace thing just to be sure..

johnjelinek 2017-10-22T21:54:26.000069Z

question: if I'm going to build a non-trivial application, I'll prolly implement something like boot just like lumo does -- and if I do that, then I'll already have a dependency on the JDK -- so, why go with lumo to compile my cljs at that point instead of depending on the JDK that boot uses?

richiardiandrea 2017-10-22T22:44:23.000051Z

@johnjelinek you gave yourself a pretty good question 😄 Personally I really believe that there should be a non-JVM workflow for working in ClojureScript and I adopted lumo in order to completely avoid building with it. So far I am only rarely using boot or lein when I add a new Clojure dependency and build using yarn (`scripts` section calls a small bash script). I use JS deps from npm as much as I can. If you need a fully fledged build tool with no JVM have a look at calvin. Also make sure to read Antonio's blog posts about the compiler: it is there, but it's got some limitation being quite a recent port of the Google Closure Compiler. I have found and reported some (and solved?), but I am ok with it because I support 100% the project, things are not super super smooth yet.