This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-25
Channels
- # aleph (18)
- # announcements (7)
- # asami (18)
- # babashka (15)
- # babashka-sci-dev (79)
- # beginners (61)
- # calva (4)
- # clj-kondo (23)
- # cljfx (16)
- # cljs-dev (6)
- # clojure (63)
- # clojure-bay-area (3)
- # clojure-europe (33)
- # clojure-nl (1)
- # clojure-survey (4)
- # clojure-uk (5)
- # clojurescript (136)
- # conjure (1)
- # cursive (8)
- # datahike (7)
- # datalevin (1)
- # datomic (30)
- # emacs (10)
- # events (2)
- # figwheel (2)
- # fulcro (20)
- # google-cloud (1)
- # lsp (6)
- # luminus (4)
- # malli (5)
- # music (3)
- # nextjournal (1)
- # off-topic (9)
- # other-languages (3)
- # pathom (16)
- # polylith (34)
- # re-frame (14)
- # reagent (19)
- # releases (6)
- # sci (2)
- # shadow-cljs (33)
Hi @dnolen I am just checking Clojurescript open issues. There are close to 2000 issues. I hope a lot of aging tickets are corner cases/low priority items. Was it assessed how many of them are critical and production breaking ? Can I bet my next billion dollar super duper awesome app or website on Clojurescript? Does Cognitect provide commercial support?
Any large open source project has a lot of open old bugs, that's just software. There are several billion dollar companies built on Clojure and ClojureScript so I think the answer is yes there. Cognitect does not currently provide commercial support contracts. We used to, and we sold a few, but no one ever found anything that they needed us to fix.
True for any large open source project, except elixir which currently has https://github.com/elixir-lang/elixir/issues. Always amazed how they manage to keep it that low.
By the nature of Clojure and ClojureScript, being Lisps, the scope of things you can fix yourself if absolutely needed is large
My guess is that if you had an urgent bug, you'd probably find far better free support here on this Slack than you'd get from most commercial support contracts
Our company is currently deploying two largish, mission-critical apps that depend on Clojure and ClojureScript, and I'd say it's not merely reliable, it's a huge advantage to us.
Hi Alex, that was a very quick response. Thank you very much.
@manas.marthi I think the user base is large enough (and it used for serious work) so truly critical bugs are usually communicated and addressed in a reasonable amount of time.
I've got a figwheel cljs project that's big enough that hot reloading is failing because the bootstrapping/initialization sequence is still running before all the dependent files reload. Yes, yes, I know that it should just be engineered better, but does anyone have a band-aid?
Slowing reloads down Depending on your environment Figwheel may reload files too quickly. If it does reload too soon it may be reloading the old file before it has changed. This is not an ideal experience. For example you may be working with a Jekyll site where Jekyll copies all the assets of the site to a _site directory and serves the site from there. Jekyll currently doesn’t copy the files fast enough to beat Figwheel’s reload time. You can slow down this reload time with the :wait-time-ms option. It defaults to 50 milliseconds. You can make each reload wait a second after each compile by setting :wait-time-ms to 1000.
Found this on the documentation
For now I've disabled hot reload but that's such a bummer
Play online with CLJS and Reagent in CodePen via #scittle :) https://codepen.io/Prestance/pen/PoOdZQw Thanks @admin055
@goomba I think Figwheel has a hook so you can wait for reload, you can probably conditionalize it
Yeah, I was using the ^:after-load
hook but it doesn't seem to actually wait until ALL dependent files are reloaded. Not sure how to conventionalize on all dependencies reloaded, although I suppose (a/<! (a/timeout 2500))
or something would be a hack worth trying
Can someone tell me how "format" works on clojurescript? I would like to format numbers and dates.
I found goog clojure libraries to format numbers, and tick.core library to format dates.
What I did not find is an interface where I can register tick.core to format dates and goog clojure to format numbers.
When you say you want to “register” one of those libraries to format dates and numbers, where exactly are you needing formatted values to go? Are you formatting them for display on a webpage? to the console? the REPL? storing them in a database? is this for “over the wire” data as part of JSON or transit?
it's Friday and if you're looking to slack off for a few minutes, why not answer the 2022 Clojure survey? takes 5-10 min. https://www.surveymonkey.com/r/clojure2022
Wondering if anyone has seen this error before in the browser from their compiled CLJS: Uncaught SyntaxError: Invalid left-hand side in assignment
.
It’s happening at this line in my output file, bundle.js
:
38472 "development" = goog.define("process.env.NODE_ENV", "development");
… which, of course, is invalid. It seems to be happening while I run my :bundle-cmd
. Here’s my full compilation call:
(cljs.build.api/build
{:output-dir "public/cljs",
:output-to "public/cljs/prebundle.js",
:asset-path "cljs",
:main "cljs.user",
:install-deps true,
:optimizations :whitespace,
:target :bundle
:bundle-cmd {:default ["esbuild" "public/cljs/prebundle.js"
"--bundle" "--outfile=public/cljs/bundle.js"]}
:npm-deps {"react" "17.0.2",
"react-dom" "17.0.2",
"@react-spring/web" "9.4.2"}})
As you can see, I’m running esbuild
on prebundle.js
to produce bundle.js
. The weird thing is that if I look at the same line in prebundle.js
, then I see this:
process.env.NODE_ENV=goog.define("process.env.NODE_ENV","development")
Seems like my :bundle-cmd
is replacing process.env.NODE_ENV
with the literal string "development"
, and then trying to assign to it.
I realize this could be esbuild
messing up… but I wanted to ask if anyone’s run into this before.Upon further experimentation, I’m realizing this only happens with :optimizations :whitespace
. The other optimization levels work properly.
Does anyone have any insight into why this happens?
Resulted in a new error, though. This time from the Clojure process that’s doing the compilation.
Feb 25, 2022 12:01:42 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: public/cljs/inferred_externs.js:15:0: WARNING - [JSC_UNDEFINED_EXTERN_VAR_ERROR] name goog is not defined in the externs.
15| goog.dependencies_;
this is standard practice in JS to replace NODE_ENV
. you are never expected to assign it in your program.
also don't use :whitespace
ever. at the very least you need :simple
better even :advanced
I know this is old, but I got the same thing with :whitespace
optimizations in recent 2023 stack using webpack as the bundler. It seems to me that goog closure is misinterpreting what process.env.NODE_ENV
is to be a goog.define
or something…
I find it odd that we just cannot use :whitespace
. I wanted to just for a debug friendly build when trying to run a JS test runner.
yes, do not use :whitespace
. I have no clue why you think you need it. it should not exist, it only exists for historic reasons. :whitespace
is pointless, just don't use it.
Well, I was using jsdom for a bit and it couldn’t deal with :none
optimizations at all. Doesn’t like document.write("<script>...");
This was no using shadow - which I think may go a different route
But either way, if you use :simple
there is a bunch of name munging. If using a devtools step debugger on that, it’s less than ideal.
I’m also just really curious for no other reason than curiosity of how:
"development" = goog.define("process.env.NODE_ENV", "development");
ends up happeningI see it happens with webpack and esbuild. It seems it isn’t responsible for it. I guess the cljs compiler is? But I don’t see how.
I’m only doing mode=dev
for webpack, so nothing else ever even mentions process.env.NODE_ENV
directly, very strange.
Also, weird that only whitespace has this issue. Nothing else.
webpack tends to just replace process.env.NODE_ENV
with whatever value it is supposed to have
process.env.NODE_ENV = goog.define...
but I don’t understand what step in the tooling could be pulling this off
since it says goog.define
- I assume cljs compiler + closure right? I don’t do anything beyond that
I guess its this? https://github.com/clojure/clojurescript/blob/01884de5cf39ef3e49b229bf042f51ee9d008f7e/src/main/cljs/process/env.cljs#L12
I don’t understand why cljs is doing that. I guess it only breaks whitespace because in simple/advanced it is somehow dead-code eliminated or something? super weird
in :simple
the goog.define
is just inlined with whatever value it is supposed to have
This is an “implicit option” cljs adds to :preloads
here https://github.com/clojure/clojurescript/blob/v1.11/src/main/clojure/cljs/closure.clj#L2517
https://github.com/clojure/clojurescript/commit/537f60c975a29983c62647b4ea67b0bc08979366
So I guess this is a feature for if you are trying to use node modules directly within the cljs compilation - rather than handling them independently via a separate bundler
Hah, in a funny twist of fate. Setting :process-shim false
did help me remove this.
Then I started to get errors with goog.dom
being undefined, which points me more at https://clojurians.slack.com/archives/C03S1L9DN/p1656184727433179?thread_ts=1656183740.910699&cid=C03S1L9DN
Which is an issue I just checked earlier and linked to this issue.
So basically, I came full circle.
Yeah, I think I understand this implicit preload for when you try to bring node modules directly through the closure compiler? but I’d think it’d always be a problem in a bundler with that sort of JS produced.
But yeah, I think I don’t need it. Funny how I then got to goog.dom
broken. I think I’ve had goog.dom
issues before.
Perhaps the takeaway is just that :whitespace
is pretty unreliable/broken in pure cljs 😆
I just had a cljs :require
on goog.dom
here. Nothing with node other than using it as the bundler later.
Also, jdk 11 min compliicates our CI pipeline. We have to use jdk8 for our bytecode stuff.
Not the end of the world, just requires work. I’m trying to way the pros/cons of shadow-cljs
So basically, I’d have to have steps like:
use jdk8
somebuildtool compile-clj
use jdk11
somebuildtool compile-cljs
use jdk8
... the rest...
you can target any specific java version, so even jdk19 can produce bytecode for jdk8
yeah sorry I'm out. sounds like a self imposed problem. and just a warning CLJS will be moving to java11 too, it has to or left behind a years old closure compiler version.
Yeah, I recognize cljs is going to have to go jdk11 soon when taking on newer closure
You are lucky if you aren’t involved in a prod delivery mode with the jvm though. Java 8 is going to be a burden to deal with for probably at least 5 more years
I have left jdk8 behind a long time ago, in every setup. don't know why you'd stick with something that old today anways 😛
It was the last version of the old release cadence era. It got special cased by a bunch of enterprise’y contracts and LTS support lines.
If you are able to cloud host your own stuff or something like that - much more ideal
Doesn’t matter too much. We’d prefer our tests in clj to run against jdk8 just to check what we deliver, but that’s it
I mean just use the -source
and -target
options and some discipline to not use that doesn't exist in jdk8
Yeah, that can work. It’s just when you use open source libs - you have to be careful they do not use what doesn’t exist.
Thanks though. This has been illuminating. And at least now I know why there was this “invalid left-hand side in assignment”
https://clojurians.slack.com/archives/C1AC4BU2K/p1686319130660819 See type hint issues with using higher jdk to compile lower javac. Just as another reason to worry a bit about doing it that way. ☠️
Hello firends, I am trying to integrate clojurescript in my frontend, my backend being python and using node/socketio for websockets. What library would you recommend to talk over websockets with socketio from my clojurescript? Sente seems to expect my backend to also run Sente, or does it? Thank you 🙂
> Sente seems to expect my backend to also run Sente That's correct. There are probably JS clients for socketio that you can use from CLJS via interop. And if not, you can always just use a raw WebSocket connection, without any libraries.
Wow, perfect, I will check that also, as soon as I have my other problem fixed 😉 Thank you @U0JUR9FPH. Maybe you guts can help me also with the other thing I posted in the mainchannel :))
I am really struggeling to get Calva to connect to my app.... I am serving my javascript code from another webserver....
I have this in my shadow-cljs.edn
{:app {:target :browser
:output-dir "../public/js"
:asset-path "/js"
:modules {:main {:entries []}}}}
The shadow-cljs watch app
is working and when I navigate to the file where I server the main.js
everything seems to work fine. When I save my source.cljs file, the code gets "hot-reloaded".
But when I Calva jack in to my :app and select browser repl, it wants me to connect to localhost:9630 for the js execution environment. When I do, it also works, but when I insert
(js/alert "hello world")
the alert will then appear in that localhost:9630 tab and not, where my app is running.
Any Ideas?