Giter VIP home page Giter VIP logo

lumo's Introduction

lumo logo

Lumo

Backers on Open Collective Sponsors on Open Collective

Lumo is a standalone ClojureScript environment that runs on Node.js and the V8 JavaScript engine. It starts up instantaneously and provides out-of-the-box access to the entire Node.js ecosystem, including a ClojureScript REPL.

Lumo also provides a ClojureScript build API, making it possible to compile ClojureScript projects entirely without the JVM, thanks to the experimental JavaScript version of the Google Closure Compiler.

Read the announcement blog post and our pledge!

If you enjoy Lumo, consider backing or sponsoring the project on Open Collective

Build status

Platform Status
macOS CircleCI
Linux Build Status
Windows Build status

Contents

Installation

Via NPX

npx is a package runner that comes with node6+. You can try lumo "without install" with:

npx -p lumo-cljs lumo

Via NPM

$ npm install -g lumo-cljs

If you get a permission failure, try this:

$ npm install -g lumo-cljs --unsafe-perm

Note: the installed binary will be named lumo rather than lumo-cljs

Via Homebrew (macOS)

$ brew install lumo

Note: If you want to install a binary built from master, run brew install --HEAD lumo (at your own responsibility).

$ docker pull anmonteiro/lumo:latest
$ docker run -it anmonteiro/lumo

Manual

  1. Download the latest release.
  2. Move it to somewhere in your $PATH.

Using Lumo

Interactive ClojureScript REPL

Enter lumo at the command line to launch the ClojureScript REPL.

$ npm init -y && npm install express request request-promise
$ lumo
Lumo 1.10.1
ClojureScript 1.10.520
...
cljs.user=> (require 'express)
cljs.user=> (require '[request-promise :as rp])
cljs.user=> (def port 3000)
#'cljs.user/port
cljs.user=> (-> (express)
       #_=>     (.get "/" (fn [req res] (.send res "Hello Lumo")))
       #_=>     (.listen port))
#object[Server [object Object]]
cljs.user=> (-> (str "http://localhost:" port)
       #_=>     rp
       #_=>     (.then (fn [body] (println "\nReceived:" body)))
       #_=>     (.catch (fn [err] (println "\nOops:" (.-stack err)))))
#object[Promise [object Promise]]
Received: Hello Lumo

Check out lumo -h for usage instructions and supported command line options. Also, see the announcement blog post.

Compile ClojureScript

Lumo can compile ClojureScript code as of version 1.2.0. See the introductory blog post. It is still considered experimental, given the relatively new Google Closure Compiler port to JavaScript, but it aims to be at feature parity with the JVM ClojureScript compiler.

The build API mirrors the ClojureScript one. Please reference its Quick Start and the Compiler Options. You can basically just replace the namespace with lumo.build.api:

(require 'lumo.build.api)

(lumo.build.api/build "src" {:output-to "out/main.js"})

The following example also shows how to use multiple source folders.

(require '[lumo.build.api :as b])

(b/build
 (b/inputs "src1" "src2") ;; variadic
 {:output-to "out/main.js"})

Building

To build Lumo from source:

  1. Make sure you have installed Boot, Yarn and Node.js (version >= 8).
  2. At the root of the repository, run: boot release.
  3. The resulting binary can be found in build/lumo (or build\lumo.exe if you're on Windows).

Contributing

See CONTRIBUTING.md.

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

Copyright & License

Copyright © 2016-2017 António Nuno Monteiro

Distributed under the Eclipse Public License (see LICENSE).

lumo's People

Contributors

abhi18av avatar anmonteiro avatar arichiardi avatar bolasblack avatar filipesilva avatar futuro avatar hlolli avatar jmfirth avatar jobez avatar jonpither avatar leppert avatar mchowning avatar mhuebert avatar moxaj avatar onetom avatar penryu avatar pkova avatar plexus avatar priyatam avatar slipset avatar souenzzo avatar tiye avatar ulrikstrid avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lumo's Issues

On remote debugging of Node in Lumo

Since node 7 there is https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js

$ node --inspect index.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node

How does lumo support that?

Option to cache only libraries?

As I'm trying cache in my project I found caching libraries is quite necessary while caching my code breaks my (require 'x.y.z :reload) code. So I guess that might be how I use caches:

  • generate caches for libraries
  • run REPL and load the main file
  • reload changed file via REPL(no cache for them, so loads new files)
  • when dependencies change, regenerate libraries caches

How do you use caches? Is such an option useful for your cases?


Update: I mean libraries in jar files with versions. I figured out Lumo caches code in my src/ folder too when I added them into classpath. I want code src/ not cached during development.

Print stacktraces

We only print error messages and not their stacktraces when an error occurs

TypeError: Cannot read property 'StringBuffer' of undefined

Running this:

npm i google-closure-library
lumo -e "(js/require \"google-closure-library\")"

Results in:

cljs.user=> (js/require "google-closure-library")
readline.js:983
            throw err;
            ^

TypeError: Cannot read property 'StringBuffer' of undefined
    at Object.cljs.core.pr_sb_with_opts (<embedded>:1650:94)
    at Object.cljs.core.pr_str_with_opts (<embedded>:1650:332)
    at Object.cljs.core.pr_with_opts (<embedded>:1651:78)
    at Function.cljs.core.println.cljs$core$IFn$_invoke$arity$variadic (<embedded>:1659:78)
    at Object.lumo.repl.handle_repl_error (<embedded>:7802:120)
    at Object.lumo.repl.execute_text (<embedded>:7833:432)
    at Object.lumo.repl.execute_source (<embedded>:7834:391)
    at Object.lumo.repl.execute (<embedded>:7835:170)
    at Object.p [as execute] ([eval]:5:6356)
    at c ([eval]:5:11730)

Package management

Any plans of officially integrating with MacOS's homebrew, Arch's AUR, etc? I'm very excited about a faster REPL (takes 16 seconds to start lein repl on my machine) and I think a quick and familiar installation would help bring in new users.

How about watching files and reload namespaces

Since lumo now utilizes Node.js API, we may do more than Planck. One things I tried but felt clumsy is that I want to write small Node.js apps in ClojureScript so I tried fighweel. But it requires quite some code to config figwheel, what's more, when I'm migrated to Boot, it's even more configs.

How about such a feature in lumo? Like detect file changes, and reload namespaces, and call a on-jsload function. It's like we do (require 'x.y :reload) (x.core/on-jsload) manually but now we do it with lumo.

I guess anyway we have to compile ClojureScript in :advanced mode to make performant. No mention to use it in production.

Rejected promises can't be catched

The problem is that catch method is due to some reason (catch is reserved word in javascript) renamed to catch$, which is obviously not available on returned promise:

(let [Promise (js/require "bluebird")]
  (.catch (Promise. #(%2 "x")) #(println %)))
(function (){var Promise = require("bluebird");
return (new Promise(((function (Promise){
return (function (p1__47_SHARP_,p2__46_SHARP_){
return p2__46_SHARP_.call(null,"x");
});})(Promise))
)).catch$(((function (Promise){
return (function (p1__48_SHARP_){
return cljs.core.println.call(null,p1__48_SHARP_);
});})(Promise))
);
})()
TypeError: (intermediate value).catch$ is not a function

TCP Socket REPL

I wanted to open an issue to discuss and track efforts for implementing a TCP socket REPL, in the vein of Planck's REPL, for Lumo.

(js/Object.keys js/cljs.core) crashes lumo

Calling (js/Object.keys js/cljs.core) crashes lumo. Not a big deal, just thought you might want to know.

js/Object.keys works on other namespace objects, must be something specific to cljs.core.

cljs.user=> (js/Object.keys js/Object)
#js []
cljs.user=> (js/Object.keys js/cljs)
#js ["core" "tools" "env" "reader" "tagged_literals" "analyzer" "source_map" "compiler" "core$macros" "pprint" "test" "js" "spec" "repl" "nodejs" "user" "spec$macros"]
cljs.user=> (js/Object.keys js/cljs.core)

C:\Users\sub>lumo
Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (str (js/Object.keys js/cljs.core))

C:\Users\sub>lumo
Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (js/Object.keys js/cljs)
#js ["core" "tools" "env" "reader" "tagged_literals" "analyzer" "source_map" "compiler" "core$macros" "pprint" "test" "js" "spec" "repl" "nodejs" "user" "spec$macros"]
cljs.user=> (js/Object.keys js/cljs.nodejs)
#js ["require" "process" "enable_util_print_BANG_"]
cljs.user=>

Call function from cljs file from command line

After scripting a little with lumo, a small pain point is the inability to call a main function from the command line. The scripts must all end with imperative calls to functions, which doesn't feel right for Clojure code. Beyond style complaints, the imperative function calls have negative effects when putting multiple files on the classpath, as all the imperative function calls are made from all the files. It would be beneficial to be able to call a specific function after all the code is evaluated, either through user specification on the command line, or by convention (always call -main if it exits).

Missing cljs.repl/doc

doc is useful for working from the REPL (http://cljs.github.io/api/cljs.repl/doc) but it's not included yet:

cljs.user=> (require 'cljs.repl)
#error {:message No such namespace: cljs.repl, could not locate cljs/repl.cljs, cljs/repl.cljc, or Closure namespace "cljs.repl", :data {:tag :cljs/analysis-error}}

Same for cljs.repl/source.

The fns should be automatically interned in the REPL, as they are in clojure repls.

lumo not support `defmacro` in `cljc` file

  • foo/bar.cljc
(ns foo.bar)

#?(:clj (defmacro koo [x] ...)) ;; case 1

(defmacro koo [x] ...) ;; case 2

(:require-macros [foo.bar :refer [koo]]) not working for case 1, but working for case 2

Slower compared to planck interpreting a file

Lumo turned out to be slower in my project:

=>> time lumo -c $boot_deps:src/ -i render.cljs

real	0m23.149s
user	0m21.812s
sys	0m1.913s

=>> time planck -c $boot_deps:src/ -i render.cljs

real	0m5.097s
user	0m7.212s
sys	0m0.301s

I'm using a personal workflow that pre-renders HTML with cljs. The script is render.cljs.

export boot_deps=`boot show -c`
lumo -c $boot_deps:src/ -i render.cljs

In order to render that, I have to load some dependencies:

(ns ssr-stages.boot
  (:require
    [respo.alias :refer [html head title script style meta' div link body]]
    [respo.render.html :refer [make-html make-string]]
    [stack-workflow.comp.container :refer [comp-container]]
    [planck.core :refer [spit]]))

from quite some classpathes:

=>> echo $boot_deps
/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/System/Library/Java/Extensions/MRJToolkit.jar:/usr/local/Cellar/boot-clj/2.5.2/bin/boot:/Users/chen/.boot/cache/bin/2.6.0/boot.jar:/Users/chen/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar:/Users/chen/.m2/repository/boot/core/2.6.0/core-2.6.0.jar:/Users/chen/.m2/repository/boot/pod/2.6.0/pod-2.6.0.jar:/Users/chen/.m2/repository/org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar:/Users/chen/.m2/repository/org/projectodd/shimdandy/shimdandy-impl/1.2.0/shimdandy-impl-1.2.0.jar:/Users/chen/.boot/cache/tmp/Users/chen/repo/mvc-works/stack-workflow/1nye/11lgcg/:/Users/chen/.boot/cache/tmp/Users/chen/repo/mvc-works/stack-workflow/1nye/6qp7pj/:/Users/chen/.boot/cache/tmp/Users/chen/repo/mvc-works/stack-workflow/1nye/rcesf6/:/Users/chen/.boot/cache/tmp/Users/chen/repo/mvc-works/stack-workflow/1nye/-x24pa9/:/Users/chen/.boot/cache/tmp/Users/chen/repo/mvc-works/stack-workflow/1nye/-lsqdbp/:/Users/chen/.m2/repository/respo/respo/0.3.31/respo-0.3.31.jar:/Users/chen/.m2/repository/org/clojure/clojurescript/1.9.293/clojurescript-1.9.293.jar:/Users/chen/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20160911/closure-compiler-unshaded-v20160911.jar:/Users/chen/.m2/repository/com/google/jsinterop/jsinterop-annotations/1.0.0/jsinterop-annotations-1.0.0.jar:/Users/chen/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/Users/chen/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar:/Users/chen/.m2/repository/com/google/guava/guava/19.0/guava-19.0.jar:/Users/chen/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar:/Users/chen/.m2/repository/adzerk/boot-test/1.1.2/boot-test-1.1.2.jar:/Users/chen/.m2/repository/org/mozilla/rhino/1.7R5/rhino-1.7R5.jar:/Users/chen/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/Users/chen/.m2/repository/com/google/javascript/closure-compiler-externs/v20160911/closure-compiler-externs-v20160911.jar:/Users/chen/.m2/repository/adzerk/boot-reload/0.4.12/boot-reload-0.4.12.jar:/Users/chen/.m2/repository/mvc-works/hsl/0.1.2/hsl-0.1.2.jar:/Users/chen/.m2/repository/respo/ui/0.1.4/ui-0.1.4.jar:/Users/chen/.m2/repository/org/clojure/tools.reader/1.0.0-beta3/tools.reader-1.0.0-beta3.jar:/Users/chen/.m2/repository/args4j/args4j/2.0.26/args4j-2.0.26.jar:/Users/chen/.m2/repository/org/clojure/google-closure-library/0.0-20160609-f42b4a24/google-closure-library-0.0-20160609-f42b4a24.jar:/Users/chen/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20160609-f42b4a24/google-closure-library-third-party-0.0-20160609-f42b4a24.jar:/Users/chen/.m2/repository/cirru/boot-stack-server/0.1.22/boot-stack-server-0.1.22.jar:/Users/chen/.m2/repository/clansi/clansi/1.0.0/clansi-1.0.0.jar:/Users/chen/.m2/repository/ring-cors/ring-cors/0.1.8/ring-cors-0.1.8.jar:/Users/chen/.m2/repository/cirru/sepal/0.0.14/sepal-0.0.14.jar:/Users/chen/.m2/repository/cumulo/shallow-diff/0.1.1/shallow-diff-0.1.1.jar:/Users/chen/.m2/repository/cirru/parser/0.0.3/parser-0.0.3.jar:/Users/chen/.m2/repository/fipp/fipp/0.6.6/fipp-0.6.6.jar:/Users/chen/.m2/repository/org/clojure/core.rrb-vector/0.0.11/core.rrb-vector-0.0.11.jar:/Users/chen/.m2/repository/cheshire/cheshire/5.5.0/cheshire-5.5.0.jar:/Users/chen/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.5.3/jackson-dataformat-smile-2.5.3.jar:/Users/chen/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.5.3/jackson-dataformat-cbor-2.5.3.jar:/Users/chen/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar:/Users/chen/.m2/repository/ring/ring-jetty-adapter/1.5.0/ring-jetty-adapter-1.5.0.jar:/Users/chen/.m2/repository/ring/ring-servlet/1.5.0/ring-servlet-1.5.0.jar:/Users/chen/.m2/repository/org/eclipse/jetty/jetty-server/9.2.10.v20150310/jetty-server-9.2.10.v20150310.jar:/Users/chen/.m2/repository/org/eclipse/jetty/jetty-io/9.2.10.v20150310/jetty-io-9.2.10.v20150310.jar:/Users/chen/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/chen/.m2/repository/ring/ring-core/1.5.0/ring-core-1.5.0.jar:/Users/chen/.m2/repository/clj-time/clj-time/0.11.0/clj-time-0.11.0.jar:/Users/chen/.m2/repository/joda-time/joda-time/2.8.2/joda-time-2.8.2.jar:/Users/chen/.m2/repository/crypto-equality/crypto-equality/1.0.0/crypto-equality-1.0.0.jar:/Users/chen/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar:/Users/chen/.m2/repository/ring/ring-codec/1.0.1/ring-codec-1.0.1.jar:/Users/chen/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/Users/chen/.m2/repository/commons-fileupload/commons-fileupload/1.3.1/commons-fileupload-1.3.1.jar:/Users/chen/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.5.3/jackson-core-2.5.3.jar:/Users/chen/.m2/repository/org/eclipse/jetty/jetty-http/9.2.10.v20150310/jetty-http-9.2.10.v20150310.jar:/Users/chen/.m2/repository/org/eclipse/jetty/jetty-util/9.2.10.v20150310/jetty-util-9.2.10.v20150310.jar:/Users/chen/.m2/repository/adzerk/boot-cljs/1.7.228-1/boot-cljs-1.7.228-1.jar:/Users/chen/.m2/repository/crypto-random/crypto-random/1.2.0/crypto-random-1.2.0.jar

So why it's slow?

Return error code on exception

Currently lumo foo.cljs returns 0 if script exits because of an exception. It should return error code 1.

It may be useful for external tools (e.g. CI server) for detecting errors.

package for homebrew

Would be cool if homebrew users could brew install lumo. The instructions for adding a new homebrew formula are here. Opening this in case anyone wants to beat me to it.

Use leiningen dependencies

Hey, nice work !
It would be nice if lumo could detect the presence of then parse project.clj (if present) and guess dependencies, then automatically add those if present in ~/.m2/repository... ( so we dont waste time loading them evereytime)

This way we can run a project -aware repl :)

Search history with buffer on pressing arrow key

It's a feature in Boot REPL. I don't know what to call it but I use it for long. For example I got some histories:

(+ 1 2)
(+ 2 3)
(- 2 1)
(- 3 2)

Now I typed (+ in the REPL and use Up key to find history. Currently I got any history one by one. But in Boot, only (+ 1 2) (+ 2 3) are matched since the beginner characters are the same.

I'm considering it as a new feature we need.

Isolate REPL sessions

Currently, REPL sessions share an input buffer, allowing sessions to complete each other's forms. Input buffers for these sessions should be isolated to prevent this behavior.

Documentation for dependency inclusion

First off, kudos on the great work on this project! I love Clojure, but needing the JVM for ClojureScript has been very offputting.

Is there any documentation for how to include dependencies? From looking around, it seems like Lumo supports both Node packages, as well as some lein-sourced packages?

It would be nice to have this information in the readme so people can get up and running quickly.

Consume/bundle source maps

Currently we don't bundle source maps for the libraries that ship with Lumo.

This makes errors hard to trace because the messages include only references to the lines in compiled JS.

Runtime option for disabling --use_strict

Some node modules use octal literals, causing errors when node runs in strict mode. Although these node libraries could be patched, it might be useful to include a runtime flag to disable strict mode. Maybe, maybe not. Adding this per Slack request.

Need "replace all" semantics in `lumo.repl/root-resource`

In the ClojureScript implementation of the root-resource, the (Clojure/Java) implementation of .replace has "all" semantics. For example:

user=> (.replace "ABCB" "B" "Z")
"AZCZ"

This becomes important in the event that namespaces has multiple dashes or dots in their name. For example:

cljs.user=> (lumo.repl/root-resource 'foo-bar-baz.boo.core)
"/foo_bar-baz/boo.core"

In the Planck copy of this code, I adjusted this slightly https://github.com/mfikes/planck/blob/d9613862bd9b54d436e439f8eb5dd94848c08ae3/planck-cljs/src/planck/repl.cljs#L1311-L1312

resulting in the needed behavior (which is what ClojureScript is doing for this case as well):

cljs.user=> (planck.repl/root-resource 'foo-bar-baz.boo.core)
"/foo_bar_baz/boo/core"

Windows: extraneous header appears on stdout

On Windows when I pipe the text contents of the script to the script to echo it lead asterisks, I get two extra lines: a blank line (denoted by two dots) followed by the command line and its args.

Run this:

C:\Users\me>type .\ast.cljs | lumo -q .\ast.cljs

Output:

..
C:\Users\me>"C:\Users\me\AppData\Roaming\npm\\node_modules\lumo-cljs\bin\lumo"   -q .\ast.cljs
**** (def process (js/require "process"))
****
**** (defn readlines [f]
****   (->
****     (.createInterface (js/require "readline") (clj->js {
****       "input"  (.-stdin process),
****       "output" (.-stdout process)
****       "terminal" false
****     }))
****     (.on "line" f)))
****
**** (readlines (partial println "****"))

What would cause the blank line and the echoing of the command not to be send to stdout? Is the preferred method of processing std in/out to access the node api or are there plans to provide something with a more integrated feel since this is a primary use case?

Building lumo fails on Arch

Running boot release fails while packaging up the first stage binary, specifically task package-executable. This fails because node requires the python executable to point to python 2.6 or 2.7, but on arch the default python is 3.x. From the nodejs-git aur PKGBUILD the following find + sed combo fixes all the references to python.

  find -type f -exec sed \
    -e 's_^#!/usr/bin/env python$_&2_' \
    -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \
    -e 's_^#!/usr/bin/python$_&2_' \
    -e 's_^\( *exec \+\)python\( \+.*\)$_\1python2\2_'\
    -e 's_^\(.*\)python\( \+-c \+.*\)$_\1python2\2_'\
    -e "s_'python'_'python2'_" -i {} \;
  find test/ -type f -exec sed 's_python _python2 _' -i {} \;

Another approach could be to link the python2 binary into a sub-path of the project during build, such as the tmp directory that's created to hold the node source for nexe, then prepend the PATH directory with that path.

ln -s /usr/bin/python2 tmp/python
PATH=$PWD/tmp:$PATH
boot release

Honestly, I don't particularly like either of these options, but the latter avoids issues around failing to replace every call to python.

NixOS can't execute Lumo binary

[vagrant@nixbox:~]$ uname -a
Linux nixbox 4.4.24 #1-NixOS SMP Fri Oct 7 13:23:59 UTC 2016 i686 GNU/Linux

[vagrant@nixbox:~]$ curl -L https://github.com/anmonteiro/lumo/releases/download/1.0.0/lumo_linux64.zip > lumo_linux64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   593    0   593    0     0   4966      0 --:--:-- --:--:-- --:--:--  5294
100 13.1M  100 13.1M    0     0  6754k      0  0:00:01  0:00:01 --:--:-- 8287k

[vagrant@nixbox:~]$ unzip lumo_linux64.zip
Archive:  lumo_linux64.zip
  inflating: lumo

[vagrant@nixbox:~]$ ./lumo
-bash: ./lumo: cannot execute binary file: Exec format error

[vagrant@nixbox:~]$ file lumo
lumo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=9d329f8b37bafc84544ffcc1fbf2f90a25a0a869, not stripped

installation failure using NPM with a GC error.

Hi there,

Using NPM 3.9.3 on Node 6.2.1 on OSX sierra, lumo failed to install with the following trace:

λ npm install -g lumo-cljs
/Users/pauliglot/.nvm/versions/node/v6.2.1/bin/lumo -> /Users/pauliglot/.nvm/versions/node/v6.2.1/lib/node_modules/lumo-cljs/bin/lumo

> [email protected] install /Users/pauliglot/.nvm/versions/node/v6.2.1/lib/node_modules/lumo-cljs
> node scripts/npm_install.js


<--- Last few GCs --->

   43633 ms: Mark-sweep 1374.2 (1435.0) -> 1374.2 (1435.0) MB, 659.6 / 0 ms [allocation failure] [GC in old space requested].
   44427 ms: Mark-sweep 1374.2 (1435.0) -> 1374.2 (1435.0) MB, 711.3 / 0 ms [allocation failure] [GC in old space requested].
   45200 ms: Mark-sweep 1374.2 (1435.0) -> 1374.2 (1435.0) MB, 687.1 / 0 ms [last resort gc].
   46337 ms: Mark-sweep 1374.2 (1435.0) -> 1374.2 (1435.0) MB, 1137.2 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x116a76dc9e59 <JS Object>
    2: fromCharCode(aka fromCharCode) [native string.js:~372] [pc=0x165590d9651a] (this=0x116a76d04101 <null>,an=224)
    3: arguments adaptor frame: 65536->1
    4: string(aka arrayLikeToString) [/Users/pauliglot/.nvm/versions/node/v6.2.1/lib/node_modules/lumo-cljs/node_modules/jszip/lib/utils.js:116] [pc=0x165590d38753] (this=0x1b830f375bd9 <an Object with map 0x171117540381>,array=0x2630781b...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
[1]    5140 abort      npm install -g lumo-cljs

Compatibility with reagent

I'm trying to play with reagent from lumo.

Initial problems:

Now I can require the ns:

lumo -c x/reagent-0.6.0:$HOME/.m2/repository/cljsjs/react/15.2.1-0/react-15.2.1-0.jar:$HOME/.m2/repository/cljsjs/react-dom-server/15.2.1-0/react-dom-server-15.2.1-0.jar:$HOME/.m2/repository/cljsjs/react-dom/15.2.1-0/react-dom-15.2.1-0.jar
Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[reagent.core :as r])
nil
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
cljs.user=> (r/create-element "div" #js {:className "foo"} "Hi")
#object[TypeError TypeError: Cannot convert a Symbol value to a string]

However, as you can see, calling create-element (or as-element) fails with a TypeError. Unfortunately without stacktraces, it's hard to figure where the error might be...

installation: "This method has been removed in JSZip 3.0"

Hi, I found that I had to install these npm modules for lumo:
jszip
set-immediate

After doing that, I still get this error with npm 3.10.9 and node v7.2.0:

sudo npm install -g lumo-cljs
/usr/local/bin/lumo -> /usr/local/lib/node_modules/lumo-cljs/bin/lumo

> [email protected] install /usr/local/lib/node_modules/lumo-cljs
> node scripts/npm_install.js

/usr/local/lib/node_modules/jszip/lib/object.js:170
        throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
        ^

Error: This method has been removed in JSZip 3.0, please check the upgrade guide.
    at JSZip.load (/usr/local/lib/node_modules/jszip/lib/object.js:170:15)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/lumo-cljs/scripts/npm_install.js:40:34)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "lumo-cljs"
npm ERR! node v7.2.0
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node scripts/npm_install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node scripts/npm_install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the lumo-cljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/npm_install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs lumo-cljs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls lumo-cljs
npm ERR! There is likely additional logging output above.

I can insert the npm-debug.log file, too, if that's helpful.

I'm not a regular node or npm user, and have had wierd difficulties with npm in the past as well. I'm sure they're great once you get them working, but npm has only caused headaches for me. Sigh. If you find this problem mysterious, and if I'm the only person who reports it, it's OK to ignore it. I have planck working, which seems quite fast enough, so I can live without trying lumo if need be. Thanks.

require lumo.core?

Hey, I hope I'm not missing something obvious. I just installed a fresh copy of Lumo, and I can't seem to require lumo.core to read *command-line-args*:

Lumo 1.0.0-alpha3
ClojureScript 1.9.293
 Exit: Control+D or :cljs/quit or exit
cljs.user=> (require 'lumo.repl)
nil
cljs.user=> (require '[lumo.core :refer [*command-line-args*]])
#error {:message No such namespace: lumo.core, could not locate lumo/core.cljs, lumo/core.cljc, or Closure namespace "lumo.core", :data {:tag :cljs/analysis-error}}
cljs.user=>

Problem with macros: "Wrong number of args "

Lumo throws this warning when macros are defined. For example

Lumo 1.0.0-alpha3
ClojureScript 1.9.293
 Exit: Control+D or :cljs/quit or exit
cljs.user=> (defmacro one [] 1)
true
cljs.user=> (prn (one))
WARNING: Wrong number of args (0) passed to cljs.user/one at line 1 
1
nil
cljs.user=>

The warning is WARNING: Wrong number of args (0) passed to cljs.user/one at line 1

Making the classpath dynamic

Lumo is capable of having dynamic classpath, something that ClojureScript on the JVM cannot do. While not a critical feature, a dynamic classpath opens some interesting options for programs using Lumo.

Clarifying Lumo's role

Hi @anmonteiro,

After thinking about #16 as well as the file watch ticket, I think it's probably better to clarify the role of Lumo in the README. My current understanding is that lumo is very similar to clojure.jar in that it is the smallest minimal thing that allows one to run scripts. Sometime down the road, we should probably expect a separate build tool to give us additional ergonomics much like npm/yarn do for the node ecosystem or lein/boot for clojure. Is this correct? If so, I think perhaps if we put it in the readme, we would get fewer issues here :).

Moreover, if we do take the approach above, I'd propose build a new one instead of extending boot or lein. The reason is in order to stay in the same fast repl spirit, we essentially can not touch the JVM in any stage of the tool chain. Otherwise it will feel slow again. I'd love to hear your thoughts on this.

Failure to compile on Ubuntu 16.04

Following the instructions given in the README I installed boot and subsequently yarn to run boot dev on a cloned version of your master branch here on github. But I ended up with the following error:

Applying optimizations :simple to 259 sources
nov 10, 2016 11:06:05 FM com.google.javascript.jscomp.LoggerErrorManager println
VARNING: file:/home/rovanion/.m2/repository/org/clojure/google-closure-library/0.0-20160609-f42b4a24/google-closure-library-0.0-20160609-f42b4a24.jar!/goog/format/htmlprettyprinter.js:135: WARNING - Found duplicate value 'BR' in set
goog.format.HtmlPrettyPrinter.BREAKS_FLOW_TAGS_ = goog.object.createSet(
                                                  ^

nov 10, 2016 11:06:05 FM com.google.javascript.jscomp.LoggerErrorManager printSummary
VARNING: 0 error(s), 1 warning(s)
Optimizing with Google Closure Compiler, elapsed time: 24555.474424 msecs
Optimizing 259 sources, elapsed time: 25260.562676 msecs
Sifting output files...
Sifting output files...
Sifting output files...
Sifting output files...
Writing target dir(s)...
/home/rovanion/source/clj/lumo/scripts/build.js:13
  let pos = 0;
  ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
java.lang.Exception: node: non-zero exit status (1)
                      boot.util/dosh                          util.clj:  403
                                 ...                                        
          boot.user/eval885/fn/fn/fn  boot.user5715467476412782232.clj:   23
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  303
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  493
          boot.user/eval970/fn/fn/fn  boot.user5715467476412782232.clj:   29
          boot.user/eval927/fn/fn/fn  boot.user5715467476412782232.clj:   27
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  493
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  493
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  493
   adzerk.boot-cljs/eval311/fn/fn/fn                     boot_cljs.clj:  208
   adzerk.boot-cljs/eval257/fn/fn/fn                     boot_cljs.clj:  135
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  167
boot.task.built-in/fn/fn/fn/fn/fn/fn                      built_in.clj:  348
   boot.task.built-in/fn/fn/fn/fn/fn                      built_in.clj:  348
      boot.task.built-in/fn/fn/fn/fn                      built_in.clj:  345
          boot.user/eval845/fn/fn/fn  boot.user5715467476412782232.clj:   21
                 boot.core/run-tasks                          core.clj:  938
                   boot.core/boot/fn                          core.clj:  948
 clojure.core/binding-conveyor-fn/fn                          core.clj: 2020
                                 ...                                        
Elapsed time: 68,781 sec

Macro reference from the selfsame namespace fails

I don't know if this is supposed to work, but here's a repro anyway:

./ lumo.exe
   lumo-test/core.cljc 
(ns lumo-test.core
  #?(:cljs (:require-macros [lumo-test.core :refer [baz]])))

#?(:clj (defmacro baz [] 10))

(baz)
> lumo.exe -c .
  ...
cljs.user=> (require 'lumo-test.core)
WARNING: Use of undeclared Var lumo-test.core$macros/baz ...

Preamble should be removed when running in a script

First and foremost, thanks for the work on pulling lumo together! Great work!

When scripting with lumo via a shebang'd file, lumo prints the preamble message from the repl initialization. This is problematic if you're piping commands together or otherwise redirecting the output.

For example, given the executable file test.cljs

#!/usr/bin/env lumo

(println "Hello World")

... will result in:

$ ./test.cljs
Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

Hello World!

child_process.fork() causes repl to be run in subprocess

Pleasingly, clojurescript "just works" in the child process, along with the repl. Sadly this means two things:
a) the banner and prompt are printed again when a child process is forked
b) keyboard input is processed by both processes

Not sure what the solution is here, I've not spent too much time in the nodejs ecosystem.

Repro cljs:

(def child-process (js/require "child_process"))
(.fork child-process "noop.js")

noop.js:

"use strict";
module.exports = function () {};

Could not load file http://foo...

When I do lumo -h, the main options include this:
path Run a script from a file or resource

Running a script from a (local) file works fine, but does "resource" imply the ability to run a script file on the net? When I tried this

lumo http://folk.uio.no/jkleiser/clojure/fib.cljs

then I got this:

#error {:message Could not load file http://folk.uio.no/jkleiser/clojure/fib.cljs, :data {}}

I'm using OSX 10.11.6 and node v6.5.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.