This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-26
Channels
- # announcements (4)
- # beginners (160)
- # boot (2)
- # calva (40)
- # cider (41)
- # clara (24)
- # cljdoc (2)
- # cljs-dev (99)
- # clojars (4)
- # clojure (71)
- # clojure-dev (9)
- # clojure-europe (4)
- # clojure-italy (2)
- # clojure-nl (19)
- # clojure-spec (97)
- # clojure-uk (103)
- # clojurescript (57)
- # core-logic (1)
- # cursive (15)
- # data-science (31)
- # datomic (24)
- # duct (1)
- # emacs (39)
- # events (7)
- # figwheel-main (14)
- # fulcro (44)
- # garden (7)
- # jobs (13)
- # juxt (1)
- # leiningen (29)
- # music (2)
- # nyc (4)
- # off-topic (37)
- # pathom (12)
- # re-frame (26)
- # ring (1)
- # ring-swagger (10)
- # shadow-cljs (35)
- # spacemacs (2)
- # specter (4)
- # test-check (67)
Hi. I want to write a server with ClojureScript, running on Node. Basically, I want to be able to use Express or Hapi, other JS libraries such as ones for i18n, but do so using ClojureScript and Hiccups with a view to starting with server-side rendering, and over time doing more client side stuff (so integrating reagent etc later).
Here is a nice example of doing something like this using shadow-cljs: https://github.com/lambdaisland/npmdemo/tree/master/shadow-cljs
I wanted to check in here on the following:
- There are not a lot of examples of a setup like this to be found googling - is anyone here running a similar server-side stack with ClojureScript in production?
- Any gotchas with shadow-cljs, which I have not used before?
Any other thoughts and shared experience would be helpful. I could also do this on the JVM, but I like the idea of sharing frontend/backend code in future iterations. Also, I need to use gettext, and there don't seem to be any Clojure libraries for that (I want to use .po
files etc.), and I need things like unicode URIs which in a very quick check, don't work as expected in Compojure.
@vikeri came across an old question of yours asking about RSA in goog.crypt. Did you find anything? I'd like to use RSA in react native and I couldn't find anything in goog.crypt either...
@U051H1KL1 turns out rn doesn't support any native random number generator out of the box and thus a lot of vanilla js crypto libs don't work. I resorted to using react-native-libsodium which gets the job done. Didn't end up using RSA but I'm pretty sure libsodium supports it or possibly something better
ah cool thanks for that. I needed to use RSA for compatability with our payment provider. Ended up using their javascript sdk in a webview!
@pwalsh most clojure devs use clojure on the server-side but there are a couple people using CLJS on the server-side (using shadow-cljs). happy to help if you have specific questions.
@thheller at this stage the main thing is, how risky is it 🙂. Shadow CLJS looks very slick; I just don't know what I don't know. FWIW this is a pretty simple app - it gets data from a GraphQL endpoint and renders an ecommerce site, basically. Most of the business logic is on the API server which I wrote in Python.
@pwalsh I’ve been using ClojureScript for a node.js server (via shadow-cljs) and it’s been a great experience
@mhuebert oh great to hear. any open code that I can peek at? Are you integrating with express, hapi, next.js or any other such framework?
unfortunately that project isn’t open-source. I have been migrating an existing (2012-era) coffeescript app, gradually re-writing pieces of it in cljs
- are you templating with hiccups? - is it a good REPL-driven development flow? - which GraphQL client are you using? - how is the compiled js, can you debug from the production js back to the class code? - are you doing any localisation or internationalisation?
I haven’t been doing SSR yet, but I did need to generate some simple html files from cljs and I used a JS library for that, https://github.com/thi-ng/umbrella/tree/master/packages/hiccup - mainly because it is very fast and simple. When I do get to implementing SSR, it will be react-based, because that’s what my entire front-end is written in.
I wrote my own GraphQL layer, intending to publish it, though I am not entirely sure if it’s something I want to support as an open-source project - I’ve been really interested in approaches like Pathom
so i am actually writing my graphql queries in a hiccup-syntax which compiles to graphql queries
i am doing some localisation but just using some small utils that I wrote, i plan on migrating to something more established
at some point I had set up source-mapping with sentry (uploading source-maps there on deploy)
the eventual goal is to finish deleting all the legacy stuff and be 100% cljs, am at about 75% now
I'm super interested in the hiccup > graphql stuff. Pity there is not an existing open source solution for that.
Is there metadata about a function value that one can access in clojurescript? I'm putting the function that caused the exception in my error messages, and right now it prints the source of the function (which is awesome! much more than I hoped for) BUT I would also like to just get the name. Is that accessible in any form?
@idiomancy the name accessible via the .-name
property on the fn but it will only be useful in development builds. :advanced
optimized builds will strip that name or shorten it. and no there is no way to get other metadata about the function
@darwin Thanks for Chromex! I'm using chromex-sample
to figure out my own WebExtension. Just wondering how deeply you dug into the content_script
init issue under :optimizations :none
(referenced here: https://github.com/binaryage/chromex-sample/blob/master/project.clj#L57). It looks to me like the assets are being loaded from the page domain, rather than the extension domain. I guess under :optimizations :advanced
the issue is sidestepped since everything's in one .js
file.
Has anyone else used CLJS for a WebExtension content_script
? Where can I learn more about how asset loading works under :optimizations :none
?
Yeah, so, it's doable but nontrivial @robert.mather.rmm. I've got an extension that injects a figwheel repl into any arbitrary webpage. I'll try to publish it tonight.
The only question I'm wondering about is whether or not to monetize it or not. Or to have an optional upgrade/donation button...
I was thinking a 3 dollar monthly subscription, where 1 dollar goes to figwheel, 1 dollar goes to Clojurists Together, and 1 dollar goes to my project (and whoever is contributing to it)
Not sure... But going that way, I could probably just, what, have a string somewhere saying "non-commercial version, click here to upgrade." And then just trust the user to upgrade if they're commercial?
I think that’s how REBL does it right? It’s just stated in both the docs and its license that REBL is free for open source projects but you gotta have a datatomic or active paetron subscription to use it commercially.
Honestly, I don't expect to get much beer out of a dollar a month subscription. For me, it's more about helping to normalize charge-models around open source software. So I'm generally fine with a "trusted upgrade" or donation model, or not charging anything at all. It's more-so an experiment for the principle of it.
That makes sense. What I like about the trusted upgrade approach is that it gives people the option to try it out on a personal, OSS side-project, get excited about it, then purchase it for work.
But if all the monetization bits prove to complicated, I'll probably just release a non-monetized version tonight, just to get it out the door, for people to play with - with a "trusted upgrade" versions soon to follow.
BTW @jayzawrotny, I'll be using your template as inspiration for docs... The solution comes in two components: 1) the extension you install, and 2) a template that you run with lein new
or clj -A:new
which wraps figwheel's default template, with the extra configuration bits necessary to let the extension connect back to it. So your template docs are going to come in super handy as I build out that template, thanks!