Using Lumo and the files mentioned below I am able to run $ node main.js and presto! "Hello world!". This is great but there are drawbacks to using Lumo, and I would like to know if this is possible with the cljs.jar.
How can I create a single javascript file from clojurescript using the ClojureScript Compiler (cljs.jar) that can be ran by NodeJs.
core.cljs
(ns hello-world.core
(:require [cljs.nodejs :as nodejs]))
(nodejs/enable-util-print!)
(defn -main [& args]
(println "Hello world!"))
(set! *main-cli-fn* -main)
node.cljs
(require '[lumo.build.api :as b])
(b/build "src"
{:main 'hello-world.core
:output-to "main.js"
:optimizations :advanced
:target :nodejs})
The goal is to have a single file that is all inclusive with no import/require of external files.
Why do I want this? There are many websites that have developer challenges for creating and/or enhancing algorithms. The problem is that most of these sites do not all you to use clojure, nor clojurescript. But they do let you use javascript.
These sites usually allow you to use Java as well...so if there is a another way perhaps get an export of a "java" file, not a Class file, that would also work. I doubt thats possible but figured I'd ask.
node.cljsgenerate a single javascript file that can be run withnode?lumo.build.api. I think you can do the same withcljs.build.api.