clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
T M 2021-06-10T00:10:14.167900Z

excuse me. i want to use bootstrap. is there any bootstrap for cljs library i can use? thanks

2021-06-10T10:02:27.175100Z

I don't think you'd need a library around bootstrap?

max minoS 2021-06-10T04:39:37.169600Z

I have a .json file in the same directory as my clojurescript file, how do I import that .json and convert it into a clojure object?

djblue 2021-06-10T05:09:45.169700Z

I would write a clojure macro which can load and parse the json.

max minoS 2021-06-10T05:10:16.169900Z

should I just convert the entire json into a clojure object

max minoS 2021-06-10T05:11:35.170100Z

i was initially going to put the JSONs as a gist that I can GET using cljs-ajax (which I think can parse the JSON), but then I thought that it's probably even better if i can just import the JSON in the same source directory

djblue 2021-06-10T05:12:25.170300Z

You can, although the macros still needs to return valid clojurescript code. It might be easier to return (js->clj (.parse js/JSON "..."))

max minoS 2021-06-10T05:13:02.170600Z

how do I import the JSON file in the first place?

djblue 2021-06-10T05:14:49.170800Z

(defmacro load-json [file]
  `(js->clj (.parse js/JSON ~(slurp file))))

djblue 2021-06-10T05:15:01.171Z

☝️ is a more complete solution

djblue 2021-06-10T05:15:23.171200Z

But the idea is that you use the jvm to load the file as a string and parse the json in the javascript runtime via interop

🙏 1
djblue 2021-06-10T05:16:45.171500Z

You can also leverage <http://clojure.java.io/resource|clojure.java.io/resource> if you want to load a file from the classpath, like in a jar 👌

djblue 2021-06-10T05:17:35.171700Z

(defmacro load-resource-json [file]
  `(js-&gt;clj (.parse js/JSON ~(slurp (<http://clojure.java.io/resource|clojure.java.io/resource> file)))))

2021-06-10T05:55:01.172500Z

if you're using shadow-cljs, you can just use shadow.resource/inline without creating your own slurp and worrying about compilation reload stuff yourself https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745

👀 1
Brice Ruth 2021-06-10T22:25:24.177500Z

qq: I'd like to use speclj in a cljs project ... is it possible to just use node as the test runner, instead of phantomjs? Is there a better alternative for BDD/TDD style tests in cljs these days, since speclj saw it's last release in 2016, it seems?