ClojureScript

Simple interface wanted to convert cljs forms to js

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 0.0-3211
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

In our project (a clojurescript debugger) we want to convert cljs forms or a sequence of forms into javascript so that they can be executed in the javascript console.

We would like something similar to closure/compile-form-seq (https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/closure.clj#L308)

However, we need to supply, the namespace requires and locals in an env like this

{:ns {:name "test.core" :requires {(quote gstring) (quote goog.string)}} :locals {}}

This code seems to do what we want.

(defn compile-form-seq
    \"Compile a sequence of forms to a JavaScript source string.\"
    [forms env]
    (env/ensure
    (compiler/with-core-cljs nil
      (fn []
        (with-out-str
            (doseq [form forms]
              (compiler/emit (analyzer/analyze env form))))))))

I am not sure why I need env/ensure.

Would you be able to patch compile-form-seq to provide the needed interface, or suggest what we should be doing.

Thanks
Stu

Activity

David Nolen made changes -
Field Original Value New Value
Fix Version/s Next [ 10362 ]
Affects Version/s 0.0-3211 [ 10356 ]
Priority Major [ 3 ] Minor [ 4 ]
David Nolen made changes -
Fix Version/s Next [ 10362 ]
Mike Fikes made changes -
Patch Code [ 10001 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: