clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
vnctaing 2020-09-23T02:31:20.000800Z

We have inherited this old angularjs 1.x project served by ASP .NET framework, I’m not sure where to start on how converting this app and introduce clojurescript to this. Full rewrite does not seem an option, what would you do ? I’m a newbie to cljs

p-himik 2020-09-23T07:36:03.002Z

> net framework only runs on windows Not entirely true, given the Mono project. .NET landing page explicitly talks about being able to run your apps on macOS and "Supported on Linux, Windows, and macOS" if you scroll down.

😮 1
jiriknesl 2020-09-23T10:18:31.002600Z

@vnctaing is there a support from the customer/sponsor to switch technologies?

vnctaing 2020-09-24T05:18:34.022500Z

@jiriknesl Not really… there’s limited resources available, maybe we could switch to .net core but that’s about it, we need those projects running. I’m trying out the mono project. Having my usual tools would be a start, I’ll see if I bump into some examples of migration AngularJS to CLJS that don’t involve complete rewrite

jiriknesl 2020-09-25T11:17:53.040Z

I must admit, from what I read that I don’t see a business case for rewriting to CLJS.

jimmy 2020-09-23T03:15:51.001200Z

In all honesty, I'd sit back and consider if adding clojurescript is a good idea.

vnctaing 2020-09-23T03:18:34.001400Z

Right, that’s what I’m also thinking :white_frowning_face:. I’ve never pushed cljs in production, I’ve never developed on windows (.net framework only runs on windows). I don’t know how’s the cljs tooling in that OS

nickt 2020-09-23T12:56:03.003400Z

Hey all, quick question– is it possible to use (intern) with clojurescript?

nickt 2020-09-23T12:56:24.003800Z

I get a "use of undeclared Var intern at line..." when I try it with the cljs compiler

nickt 2020-09-23T13:17:31.004600Z

hmm... another question too actually: how shall I check the typeof an object in clojurescript? I want to distinguish whether I'm operating on a number or an an object (map)

Garrett Everding 2020-09-23T14:15:55.005Z

(def name "Bob") (= (type name) js/String) ;; => true (string? name) ;; => true (not= (type name) js/Number) ;; => true (not (number? name)) ;; => true

Garrett Everding 2020-09-23T14:16:13.005200Z

https://kanaka.github.io/clojurescript/web/synonym.html

Garrett Everding 2020-09-23T14:16:49.005600Z

@nickt

2020-09-23T15:05:10.006Z

you should be able to use (type thing)

2020-09-23T16:13:34.007600Z

Can someone point me to a good project to use as a starting point for embedding a REPL in a browser, which can invoke third party code (ex: com.library/whatever)? I have been playing around with this, but it’s a bit difficult for me to understand how to expose “new” API calls that invoke the libraries: https://github.com/timothypratley/power-turtle

adamrenklint 2020-09-28T13:06:14.121500Z

If you’re using Shadow CLJS, it has a build target called “bootstrap” which handles loading all the dependencies for using the set-hosted ClojureScript compiler. This article explains it a bit: https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html Here’s a minimal working example: https://github.com/mhuebert/shadow-bootstrap-example There’s a bit of info missing in these two resources about how to get a nice reloaded workflow. I just managed to get that working well, so if it’s interesting, ping me and I’ll tell you more.

2020-09-28T13:11:28.121900Z

Thanks so much for the details. I actually did have a few issues, even when starting with that project, for what I was trying to do. However, I came to realize that the problem was in the library I was trying to bootstrap (has some macros that need to be reworked to support bootstrap).

👍 1
jeaye 2020-09-23T18:28:34.010300Z

I notice that, even when I specify :output-to and :output-dir to somewhere other that target/, CLJS compilation still makes files in target/ . Is there a way I can change that? I'm trying to run two separate compilations at once and they're both clobbering target/, when I configured them to output somewhere else entirely.

dpsutton 2020-09-23T18:34:46.011100Z

:output-to and output-dir are the way to change that. The clojurescript webpack guide uses out rather than target and it works. How are you building your clojurescript files?

lilactown 2020-09-23T19:52:05.012Z

No, there is no such thing as a var at runtime in CLJS

neilyio 2020-09-23T20:32:00.014300Z

Is there a ClojureScript compiler option to have output .js files mirror the file/directory structure of the source .cljs files?

neilyio 2020-09-23T20:34:36.016700Z

e.g.

src/foo/core.cljs
........util.cljs
....bar/main/core.cljs
.............foo2.cljs
becomes
out/foo/core.js
........util.js
....bar/main/core.js
.............foo2.js

ballpark 2020-09-23T20:53:12.017100Z

I would love anyone's input on https://stackoverflow.com/q/64036018/59439

johanatan 2020-09-23T20:55:25.017400Z

does this not exist in cljs? https://clojuredocs.org/clojure.core/intern

johanatan 2020-09-23T20:55:36.017700Z

any other way to dynamically "def" a var ?

thheller 2020-09-24T07:24:51.000100Z

don't do "var" based programming in CLJS. you are in for all sorts of issues if you do. just (def thing (atom "value")) and swap that instead of working on the "var" if possible. CLJS doesn't have vars at runtime and even less so after :advanced. thats where the issues usually show even if everything sort of work in development.

1
isak 2020-09-23T21:01:22.017900Z

> I have both the cognitect.transit-clj and cognitect.transit-cljs dependencies because my project is Clojure on the backend and CLJS on the frontend. This is a really bad idea, causes all sorts of problems. This may be one of them, not sure.

isak 2020-09-23T21:02:01.018100Z

You should have separate sets of dependencies for each, don't try to share them

isak 2020-09-23T21:17:56.018500Z

(From the ClojureScript article on "Differences from Clojure")

johanatan 2020-09-23T21:28:38.018700Z

somehow i find that hard to believe. you can do a lot of "dynamic" things in "dynamic" languages (and both cljs and the host language are "dynamic"). it's only a matter of finding out how.

isak 2020-09-23T21:30:50.018900Z

Well you can just do (aset js/window "foo" "something"), of course. But if you really mean var, and you don't trust the official docs, I don't think I can help you

ballpark 2020-09-23T21:46:30.019100Z

@isak, thanks so much! I will look into how to split them up.

1
nickt 2020-09-23T21:53:30.019600Z

👍 thanks!

thheller 2020-09-23T22:54:06.021Z

that doesn't matter at all, just keep both

👍 1
ballpark 2020-09-23T23:16:58.021600Z

@thheller, Thank you for your SO answer. That fixed it!

👍 1