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
> 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.
@vnctaing is there a support from the customer/sponsor to switch technologies?
@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
I must admit, from what I read that I don’t see a business case for rewriting to CLJS.
In all honesty, I'd sit back and consider if adding clojurescript is a good idea.
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
Hey all, quick question– is it possible to use (intern)
with clojurescript?
I get a "use of undeclared Var intern at line..." when I try it with the cljs compiler
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)
(def name "Bob") (= (type name) js/String) ;; => true (string? name) ;; => true (not= (type name) js/Number) ;; => true (not (number? name)) ;; => true
you should be able to use (type thing)
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
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.
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).
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.
: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?
No, there is no such thing as a var at runtime in CLJS
Is there a ClojureScript compiler option to have output .js files mirror the file/directory structure of the source .cljs files?
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
I would love anyone's input on https://stackoverflow.com/q/64036018/59439
does this not exist in cljs? https://clojuredocs.org/clojure.core/intern
any other way to dynamically "def" a var ?
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.
> 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.
You should have separate sets of dependencies for each, don't try to share them
No: https://clojurescript.org/about/differences#_vars_and_the_global_environment
(From the ClojureScript article on "Differences from Clojure")
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.
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
@isak, thanks so much! I will look into how to split them up.
👍 thanks!
that doesn't matter at all, just keep both
@thheller, Thank you for your SO answer. That fixed it!