Fork me on GitHub
#clojurescript
<
2020-09-23
>
vnctaing02:09:20

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

jimmy03:09:51

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

vnctaing03:09:34

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

p-himik07:09:03

> 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.

😮 3
jiriknesl10:09:31

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

vnctaing05:09:34

@U061C5DAA 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

jiriknesl11:09:53

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

nickt12:09:03

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

lilactown19:09:05

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

nickt12:09:24

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

nickt13:09:31

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)

Jeff Evans15:09:10

you should be able to use (type thing)

Garrett Everding14:09:55

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

nickt21:09:30

👍 thanks!

Jeff Evans16:09:34

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

adamrenklint13:09:14

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.

Jeff Evans13:09:28

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).

👍 3
jeaye18:09:34

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.

dpsutton18:09:46

: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?

neilyio20:09:00

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

neilyio20:09:36

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

isak21:09:22

> 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.

isak21:09:01

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

ballpark21:09:30

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

3
thheller22:09:06

that doesn't matter at all, just keep both

👍 3
ballpark23:09:58

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

👍 3
johanatan20:09:36

any other way to dynamically "def" a var ?

isak21:09:56

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

johanatan21:09:38

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.

isak21:09:50

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

johanatan02:09:21

Honestly I think i will just emit a dynamic def with a macro. Thx!

thheller07:09:51

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.

3